From 22fb0cbdcf399b7fa1e118ae3c03b0e6a5c8d9c9 Mon Sep 17 00:00:00 2001 From: jjLv <1981429112@qq.com> Date: Fri, 4 Jul 2025 13:40:56 +0800 Subject: [PATCH] =?UTF-8?q?=E8=90=A5=E5=85=BB=E7=B1=BB=E5=88=AB=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=A2=9E=E5=8A=A0=E9=A3=9F=E6=9D=90=E5=88=A4=E6=96=AD?= =?UTF-8?q?=20=E6=95=B0=E6=8D=AE=E6=80=BB=E8=A7=88=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E4=B8=BA=E6=98=A8=E6=97=A5=E6=95=B0=E6=8D=AE=EF=BC=88=E4=B9=8B?= =?UTF-8?q?=E5=89=8D=E4=B8=BA=E4=B8=8A=E4=B8=80=E4=B8=AA=E6=9C=89=E9=A3=9F?= =?UTF-8?q?=E5=A0=82=E8=AE=A2=E5=8D=95=E6=95=B0=E6=8D=AE=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../canteen/core/cook/mapper/CookNutritionTypeMapper.java | 6 ++++++ .../cook/service/impl/CookNutritionTypeServiceImpl.java | 5 +++++ .../core/screening/service/DataScreeningServiceImpl.java | 5 ++++- .../main/resources/mapper/cook/CookNutritionTypeMapper.xml | 7 +++++++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/mapper/CookNutritionTypeMapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/mapper/CookNutritionTypeMapper.java index a1d62c7..d17cf4d 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/mapper/CookNutritionTypeMapper.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/mapper/CookNutritionTypeMapper.java @@ -86,4 +86,10 @@ public interface CookNutritionTypeMapper { * @return 食材小类列表 */ public List selectLittleTypeList(String id); + /** + * 检查是否存在菜品使用了指定的营养类型 + * @param nutritionTypeIds 营养类型ID数组 + * @return 存在的数量 + */ + int checkIsExistCook(@Param("nutritionTypeIds") Long[] nutritionTypeIds); } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookNutritionTypeServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookNutritionTypeServiceImpl.java index cef73b5..850eec9 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookNutritionTypeServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookNutritionTypeServiceImpl.java @@ -123,6 +123,11 @@ public class CookNutritionTypeServiceImpl implements ICookNutritionTypeService { if (code > 0) { throw new ServiceException("删除失败,营养类型下存在子集"); } + // 检查是否有食材使用该营养类型 + int count = cookNutritionTypeMapper.checkIsExistCook(nutritionTypeIds); + if (count > 0) { + throw new ServiceException("删除失败,营养类型下存在食材"); + } return cookNutritionTypeMapper.deleteCookNutritionTypeByNutritionTypeIds(nutritionTypeIds); } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/screening/service/DataScreeningServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/screening/service/DataScreeningServiceImpl.java index 46fd720..419abb9 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/screening/service/DataScreeningServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/screening/service/DataScreeningServiceImpl.java @@ -47,7 +47,7 @@ public class DataScreeningServiceImpl implements DataScreeningService { String currentDate = DateUtils.getDate(); String yesterday = getLastDate(-1); //获取上一个有食堂订单的日期 - yesterday = getLastDate(lastDay, yesterday); +// yesterday = getLastDate(lastDay, yesterday); // 查询各项数据 addSingleItem("今日食堂营业额(元)", currentDate, yesterday, list, 11, TURNOVER); addSingleItem("今日食堂订单量(个)", currentDate, yesterday, list, 11, ORDER); @@ -135,6 +135,9 @@ public class DataScreeningServiceImpl implements DataScreeningService { BigDecimal rate = todayNum.subtract(yesterdayNum) .divide(yesterdayNum, 4, RoundingMode.HALF_UP) .multiply(BigDecimal.valueOf(100)); + if (rate.compareTo(BigDecimal.valueOf(100)) > 0) { + rate = BigDecimal.valueOf(100); + } today.setRate(String.format("%.2f", rate)); } diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookNutritionTypeMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookNutritionTypeMapper.xml index 37d7162..747236f 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookNutritionTypeMapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookNutritionTypeMapper.xml @@ -99,4 +99,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{nutritionTypeId} + + \ No newline at end of file