bug修复

This commit is contained in:
liux 2025-05-08 17:24:44 +08:00
parent 164cf9b4c9
commit 4008305517
7 changed files with 66 additions and 18 deletions

View File

@ -68,4 +68,7 @@ public interface MenuNutritionMapper {
* @return 食材营养基础信息
*/
MenuNutrition queryIfExistMenuNutrition(MenuNutrition menuNutrition);
MenuNutrition getOneByCode(MenuNutrition menuNutrition);
MenuNutrition getOneByName(MenuNutrition menuNutrition);
}

View File

@ -177,6 +177,15 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
}
menuDishesDTO.setUpdateBy(SecurityUtils.getUsername());
int baseNum = menuDishesMapper.updateMenuDishesBase(menuDishesDTO);
if(menuDishesDTO.getAreaId()==null){
menuDishesDTO.setAreaId(-1L);
}
if(menuDishesDTO.getCanteenId() == null){
menuDishesDTO.setCanteenId(-1L);
}
if(menuDishesDTO.getShopstallId() == null){
menuDishesDTO.setShopstallId(-1L);
}
int dishesNum = menuDishesMapper.editMenuDishes(menuDishesDTO);
List<MenuDishesAddMaterialDTO> materialList= menuDishesDTO.getMaterialList();
List<NutritionEntity> nutritionEntityList = new ArrayList<>();
@ -430,7 +439,15 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
if(-1 == menuDishesDTO1.getCookId()){
menuDishesDTO1.setCookId(null);
}
if(menuDishesDTO1.getAreaId()== -1L){
menuDishesDTO1.setAreaId(null);
}
if(menuDishesDTO1.getCanteenId() == -1L){
menuDishesDTO1.setCanteenId(null);
}
if(menuDishesDTO1.getShopstallId() == -1L){
menuDishesDTO1.setShopstallId(null);
}
return menuDishesDTO1;
}

View File

@ -52,7 +52,7 @@ public class MenuDishesTypeServiceImpl extends ServiceImpl<MenuDishesTypeMapper
.eq(MenuDishesType::getTypeName, content.getTypeName())
.eq(MenuDishesType::getDelFlag, DelFlagEnum.DEL_FALSE.key()));
if (CollUtil.isNotEmpty(cookList)) {
throw new ServiceException(I18n.getMessage("菜品已存在", new Object[0]));
throw new ServiceException("菜品已存在");
} else {
String username = SecurityUtils.getUsername();
MenuDishesType dishesType = new MenuDishesType();

View File

@ -81,14 +81,14 @@ public class MenuMaterialCategoryServiceImpl extends ServiceImpl<MenuMaterialCat
.eq(content.getAreaId() != null, MenuMaterialCategory::getAreaId,content.getAreaId())
.isNull(content.getAreaId() == null, MenuMaterialCategory::getAreaId));
if (ObjectUtil.isNotNull(count) && count > 0L) {
throw new ServiceException(I18n.getMessage("添加物品已存在", new Object[0]));
throw new ServiceException("添加物品已存在");
} else {
Long parentId = content.getParentId();
if (ObjectUtil.isNotNull(parentId) && parentId != -1L) {
Long countParent = this.baseMapper.selectCount(Wrappers.lambdaQuery(MenuMaterialCategory.class)
.eq(MenuMaterialCategory::getCategoryId, parentId));
if (ObjectUtil.isNull(countParent) || countParent <= 0L) {
throw new ServiceException(I18n.getMessage("菜单无父级节点", new Object[0]));
throw new ServiceException("菜单无父级节点");
}
}
@ -237,7 +237,7 @@ public class MenuMaterialCategoryServiceImpl extends ServiceImpl<MenuMaterialCat
MenuMaterialCategory one = menuMaterialCategoryMapper.getOne(menuMaterialCategory);
if(one != null){
throw new ServiceException(I18n.getMessage("修改物品已存在!", new Object[0]));
throw new ServiceException("修改物品已存在!");
}
int num = menuMaterialCategoryMapper.updateMenuMaterialCategory(menuMaterialCategory);
if(num >0){

View File

@ -91,10 +91,18 @@ public class MenuNutritionServiceImpl implements IMenuNutritionService {
try {
menuNutrition.setUpdateBy(SecurityUtils.getUsername());
menuNutrition.setUpdateTime(DateUtils.getNowDate());
MenuNutrition getOneByCode =menuNutritionMapper.getOneByCode(menuNutrition);
if(getOneByCode != null){
throw new ServiceException("营养编码重复");
}
MenuNutrition getOneByName =menuNutritionMapper.getOneByName(menuNutrition);
if(getOneByName != null){
throw new ServiceException("营养名称重复");
}
return menuNutritionMapper.updateMenuNutrition(menuNutrition);
} catch (Exception e) {
log.error("更新营养数据出错, ", e.getMessage());
throw new ServiceException("更新营养数据出错");
throw new ServiceException(e.getMessage());
}
}

View File

@ -152,7 +152,7 @@ public class MenuRecipeServiceImpl extends ServiceImpl<MenuRecipeMapper, MenuRec
MenuRecipeSortEnum sortEnum = bindTypeMap.get(content.getKey());
List<AllocRecipeStallVO> records = new ArrayList<>();
if (ObjectUtil.isEmpty(sortEnum)) {
throw new ServiceException(I18n.getMessage("参数错误", new Object[0]));
throw new ServiceException("参数错误");
}else{
content.setDeviceTypeList(sortEnum.getDeviceType());
content.setBindType(sortEnum.getBindType());
@ -213,7 +213,7 @@ public class MenuRecipeServiceImpl extends ServiceImpl<MenuRecipeMapper, MenuRec
if(content.getStallId() !=null){
deviceInfoList = this.menuRecipeMapper.getDeviceIdByDevivce(null, String.valueOf(content.getStallId()));
if(deviceInfoList == null || deviceInfoList.isEmpty() || deviceInfoList.size() == 0){
throw new ServiceException(I18n.getMessage("该食堂档口下没有设备信息", new Object[0]));
throw new ServiceException("该食堂档口下没有设备信息");
}
}
List<String> deviceSnList = this.menuRecipeMapper.getDeviceSnByIds(deviceInfoList);
@ -224,7 +224,7 @@ public class MenuRecipeServiceImpl extends ServiceImpl<MenuRecipeMapper, MenuRec
mar.setBindType(content.getBindType());
List<Integer> deviceTypeList = menuRecipeMapper.getDeviceIdByDevivce(null, String.valueOf(menuRecipe.getStallId()));
if (ObjectUtil.isEmpty(sortEnum)) {
throw new ServiceException(I18n.getMessage("bingType值异常", new Object[0]));
throw new ServiceException("bingType值异常");
} else {
List<Integer> deviceTypes = sortEnum.getDeviceType();
if (content.getHandleType().equals(1)) {
@ -232,12 +232,12 @@ public class MenuRecipeServiceImpl extends ServiceImpl<MenuRecipeMapper, MenuRec
if (MenuBindTypeEnum.RESERVE.key().equals(content.getBindType())) {
exists = this.checkCanteenIfReserve(menuRecipe.getCanteenId(), menuRecipe.getStallId());
if (!exists) {
throw new ServiceException(I18n.getMessage("不支持预订餐", new Object[0]));
throw new ServiceException("不支持预订餐");
}
}
exists = this.menuRecipeMapper.exists(mar);
if (exists) {
throw new ServiceException(I18n.getMessage("菜谱已被使用,请勿重复绑定", new Object[0]));
throw new ServiceException("菜谱已被使用,请勿重复绑定");
}
List<Long> sourceRecipeList = this.menuRecipeMapper.selectRecipeInSameShop(menuRecipe.getStallId(), null, content.getBindType(), content.getMealLineId());
if (ObjectUtil.isNotEmpty(sourceRecipeList)) {
@ -439,7 +439,7 @@ public class MenuRecipeServiceImpl extends ServiceImpl<MenuRecipeMapper, MenuRec
if (ObjectUtil.isNull(recipeId)) {
Long count = menuRecipeMapper.selectCount(dto);
if (ObjectUtil.isNotNull(count) && count > 0L) {
throw new ServiceException(I18n.getMessage("菜单菜谱名称重复", new Object[0]));
throw new ServiceException("菜单菜谱名称重复");
}
recipeId = Id.next();
recipe = new MenuRecipe();
@ -513,9 +513,9 @@ public class MenuRecipeServiceImpl extends ServiceImpl<MenuRecipeMapper, MenuRec
Integer recipeMacBindNumber = this.menuRecipeMapper.getRecipeBindCount(recipeId);
int appCount = this.menuRecipeMapper.selectMenuAppRecipeCount(recipeId);
if (recipeMacBindNumber > 0) {
throw new ServiceException(I18n.getMessage("设备已被绑定", new Object[0]));
throw new ServiceException("菜谱已绑定设备");
} else if (appCount > 0) {
throw new ServiceException(I18n.getMessage("菜谱已绑定设备", new Object[0]));
throw new ServiceException("菜谱已绑定设备");
} else {
// this.baseMapper.delete( Wrappers.lambdaUpdate(MenuRecipe.class)
// .in(MenuRecipe::getRecipeId, recipeId));
@ -1048,7 +1048,7 @@ private IMenuRecipeDetailService menuRecipeDetailService;
.map(MenuRecipeDateAddDTO::getDetailList)
.map(list -> list.get(0))
.map(MenuRecipeDetailAddDTO::getMealtimeType)
.orElseThrow(() -> new ServiceException(I18n.getMessage("详情id为空")));
.orElseThrow(() -> new ServiceException("详情id为空"));
}
return menuRecipeMapper.selectDetailIds(getRecipeDto, mealType);
}
@ -1064,7 +1064,7 @@ private IMenuRecipeDetailService menuRecipeDetailService;
.map(MenuRecipeDateAddDTO::getDetailList)
.map(list -> list.get(0))
.map(MenuRecipeDetailAddDTO::getMealtimeType)
.orElseThrow(() -> new ServiceException(I18n.getMessage("详情id为空")));
.orElseThrow(() -> new ServiceException("详情id为空"));
}
return this.menuRecipeMapper.selectDetailsList(getRecipeDto, LocalDate.now(), mealType);
}
@ -1266,7 +1266,7 @@ private IMenuRecipeDetailService menuRecipeDetailService;
return x.getSizeType() != 3L;
}).count();
if (count > 99L) {
throw new ServiceException(I18n.getMessage("菜谱信息达到上限", new Object[0]));
throw new ServiceException("菜谱信息达到上限");
} else {
dishesList.stream().filter((x) -> {
return x.getSizeType() == 3L;
@ -1277,7 +1277,7 @@ private IMenuRecipeDetailService menuRecipeDetailService;
return Integer.valueOf(1).equals(d.getRecommendFlag());
}).count();
if (dishesCount > 3L) {
throw new ServiceException(I18n.getMessage("无推荐菜谱", new Object[0]));
throw new ServiceException("无推荐菜谱");
}
}
}

View File

@ -472,4 +472,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where nutrition_code = #{nutritionCode} or nutrition_name = #{nutritionName} limit 1
</select>
<select id="getOneByCode" resultMap="MenuNutritionResult">
select *
from menu_nutrition
where nutrition_code = #{nutritionCode}
<if test="id !=null and id !=''">
and id != #{id}
</if>
limit 1
</select>
<select id="getOneByName" resultMap="MenuNutritionResult">
select *
from menu_nutrition
where nutrition_name = #{nutritionName} and little_type = #{littleType}
<if test="id !=null and id !=''">
and id != #{id}
</if>
limit 1
</select>
</mapper>