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