From 1895152fd4c75ee440f9961f371259866d1ce32c Mon Sep 17 00:00:00 2001 From: liux <963924687@qq.com> Date: Tue, 29 Apr 2025 14:33:59 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../menu/domain/MenuMaterialCategory.java | 3 ++ .../mapper/MenuMaterialCategoryMapper.java | 2 +- .../core/menu/mapper/MenuRecipeMapper.java | 2 +- .../impl/AppletRecipeH5ServiceImpl.java | 1 - .../service/impl/MenuDishesServiceImpl.java | 17 ++++----- .../impl/MenuMaterialCategoryServiceImpl.java | 20 +++++------ .../impl/MenuNutritionTypeServiceImpl.java | 3 ++ .../service/impl/MenuRecipeServiceImpl.java | 36 ++++++++++--------- .../menu/MenuMaterialCategoryMapper.xml | 3 +- .../mapper/menu/MenuNutritionMapper.xml | 4 +-- .../mapper/menu/MenuNutritionTypeMapper.xml | 6 +--- .../mapper/menu/MenuRecipeMapper.xml | 10 +++--- 12 files changed, 52 insertions(+), 55 deletions(-) diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/domain/MenuMaterialCategory.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/domain/MenuMaterialCategory.java index 1a8b878..128ccdc 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/domain/MenuMaterialCategory.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/domain/MenuMaterialCategory.java @@ -3,6 +3,7 @@ package com.bonus.canteen.core.menu.domain; import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.extension.activerecord.Model; import com.bonus.common.core.annotation.Excel; import io.swagger.annotations.ApiModelProperty; @@ -22,6 +23,7 @@ import java.time.LocalDateTime; @Data @ToString +@TableName("menu_material_category") public class MenuMaterialCategory extends Model { private static final long serialVersionUID = 1L; @@ -39,6 +41,7 @@ public class MenuMaterialCategory extends Model { @ApiModelProperty("类型(1原料2商品)") private Integer categoryType; @ApiModelProperty("删除标识(1-删除,2-正常)") + @TableField(exist = false) private Integer delFlag; @ApiModelProperty("乐观锁") private Integer revision; diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/mapper/MenuMaterialCategoryMapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/mapper/MenuMaterialCategoryMapper.java index 7cdd645..ad89e9f 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/mapper/MenuMaterialCategoryMapper.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/mapper/MenuMaterialCategoryMapper.java @@ -70,7 +70,7 @@ public interface MenuMaterialCategoryMapper extends BaseMapper selectCategoryTree(CategoryTreeListDTO content); - @Select({"select MAX(category_num) from menu_material_category where parent_id = #{parentId} and category_type = #{categoryType} and del_flag = #{delFlag}"}) + @Select({"select MAX(category_num) from menu_material_category where parent_id = #{parentId} and category_type = #{categoryType} "}) String getCategoryChildMaxNum(@Param("parentId") Long parentId, @Param("categoryType") Integer categoryType, @Param("delFlag") Integer delFlag); MenuMaterialCategory getOne(MenuMaterialCategory menuMaterialCategory); diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/mapper/MenuRecipeMapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/mapper/MenuRecipeMapper.java index c8f6db2..06260a8 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/mapper/MenuRecipeMapper.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/mapper/MenuRecipeMapper.java @@ -245,7 +245,7 @@ public interface MenuRecipeMapper extends BaseMapper { void insertMenuDishesType(MenuDishesType dishesType); - Map getDishesCookMap(); + List getDishesCookMap(); int insertMenuMateralDishes(@Param("materialList") ArrayList menuMaterialDishesList); diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/AppletRecipeH5ServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/AppletRecipeH5ServiceImpl.java index 32bc931..271385e 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/AppletRecipeH5ServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/AppletRecipeH5ServiceImpl.java @@ -147,7 +147,6 @@ public class AppletRecipeH5ServiceImpl extends ServiceImpl { typeMap.put(map.getKey(), toLong(map.getValue())); }); -// typeMapList.stream() -// .flatMap(map -> map.entrySet().stream()) -// .collect(Collectors.toMap( -// Map.Entry::getKey, // 键 -// entry -> toLong(entry.getValue()), -// (v1, v2) -> v1 // 合并函数:遇到重复键时保留第一个值 -// // 或者 (v1, v2) -> v1 + v2 // 如果需要合并值(求和) -// )); - // Map dishesCookMap = this.menuRecipeMapper.getDishesCookMap(); - Map dishesCookMap = new HashMap<>(); + List dishesCookMList = this.menuRecipeMapper.getDishesCookMap(); + Map dishesCookMap = new HashMap<>(); + dishesCookMList.forEach(map -> { + dishesCookMap.put(map.getKey(), toLong(map.getValue())); + }); importDishesContext.setAllocAreaMap(areaMap); importDishesContext.setAllocStallMap(stallMap); diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/MenuMaterialCategoryServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/MenuMaterialCategoryServiceImpl.java index 9baf511..237d7a8 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/MenuMaterialCategoryServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/MenuMaterialCategoryServiceImpl.java @@ -78,10 +78,8 @@ public class MenuMaterialCategoryServiceImpl extends ServiceImpl 0L) { throw new ServiceException(I18n.getMessage("添加物品已存在", new Object[0])); } else { @@ -124,7 +122,7 @@ public class MenuMaterialCategoryServiceImpl extends ServiceImpl(MenuMaterialCategory.class) - .eq(MenuMaterialCategory::getDelFlag, DelFlagEnum.DEL_FALSE.key()) + // .eq(MenuMaterialCategory::getDelFlag, DelFlagEnum.DEL_FALSE.key()) .isNull(MenuMaterialCategory::getBigCategoryId).or() .isNull(MenuMaterialCategory::getLevel)); System.err.println("[货品类别_所有货品类别的所属大类和等级]_未赋值大类id和等级的类别数量:{}"+checkIfExistLevel); @@ -172,8 +171,9 @@ public class MenuMaterialCategoryServiceImpl extends ServiceImpl topCategoryList = this.baseMapper.selectList(Wrappers.lambdaQuery(MenuMaterialCategory.class) - .eq(MenuMaterialCategory::getParentId, -1).eq(MenuMaterialCategory::getDelFlag, - DelFlagEnum.DEL_FALSE.key())); + .eq(MenuMaterialCategory::getParentId, -1)); +// .eq(MenuMaterialCategory::getDelFlag, +// DelFlagEnum.DEL_FALSE.key())); Iterator var3 = topCategoryList.iterator(); while(true) { @@ -241,7 +241,7 @@ public class MenuMaterialCategoryServiceImpl extends ServiceImpl0){ - this.generateCategoryNum(menuMaterialCategory.getCategoryId(), menuMaterialCategory.getParentId(), menuMaterialCategory.getCategoryType()); + this.generateCategoryNum(menuMaterialCategory.getCategoryId()!=null?menuMaterialCategory.getCategoryId():menuMaterialCategory.getId(), menuMaterialCategory.getParentId(), menuMaterialCategory.getCategoryType()); } return num; } catch (Exception e) { diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/MenuNutritionTypeServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/MenuNutritionTypeServiceImpl.java index 958dae1..5e7982d 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/MenuNutritionTypeServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/MenuNutritionTypeServiceImpl.java @@ -112,6 +112,9 @@ public class MenuNutritionTypeServiceImpl implements IMenuNutritionTypeService { */ @Override public int deleteMenuNutritionTypeByIds(Integer[] ids) { + if(ids == null || ids.length == 0){ + throw new ServiceException("请选择要删除的营养基础类型"); + } return menuNutritionTypeMapper.deleteMenuNutritionTypeByIds(ids); } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/MenuRecipeServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/MenuRecipeServiceImpl.java index 8f438c7..1f32422 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/MenuRecipeServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/MenuRecipeServiceImpl.java @@ -449,6 +449,7 @@ public class MenuRecipeServiceImpl extends ServiceImpl recipeDetailV2List = result.getRecipeDetails(); - if (ObjectUtil.isNotEmpty(recipeDetailV2List)) { - menuRecipeMapper.insertMenuDetails(recipeDetailV2List); - } - - List recipeDishesV2List = result.getRecipeDishes(); - if (ObjectUtil.isNotEmpty(recipeDishesV2List)) { - recipeDishesV2List.forEach((r) -> { - r.setId((Long) null); - Integer surplusNum = r.getSurplusNum(); - if (ObjectUtil.isNull(surplusNum) || surplusNum <= 0) { - r.setSurplusNum(0); - } - - }); - menuRecipeMapper.insertMenuDishes(recipeDishesV2List); - } LeMqConstant.DataChangeType type; String redisKey; @@ -740,6 +724,24 @@ private IMenuRecipeDetailService menuRecipeDetailService; } } + List recipeDetailV2List = result.getRecipeDetails(); + if (ObjectUtil.isNotEmpty(recipeDetailV2List)) { + menuRecipeMapper.insertMenuDetails(recipeDetailV2List); + } + + List recipeDishesV2List = result.getRecipeDishes(); + if (ObjectUtil.isNotEmpty(recipeDishesV2List)) { + recipeDishesV2List.forEach((r) -> { + r.setId((Long) null); + Integer surplusNum = r.getSurplusNum(); + if (ObjectUtil.isNull(surplusNum) || surplusNum <= 0) { + r.setSurplusNum(0); + } + + }); + menuRecipeMapper.insertMenuDishes(recipeDishesV2List); + } + MqUtil.sendDataChange(menuRecipe, type, LeMqConstant.Topic.DATA_CHANGE_RECIPE); redisKey = String.format("yst:%s:recipe:%s:detail:%s", TenantContextHolder.getTenantId(), result.getRecipeId(), "*"); RedisUtil.deleteByPattern(redisKey); diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/menu/MenuMaterialCategoryMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/menu/MenuMaterialCategoryMapper.xml index d46d830..34f061a 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/menu/MenuMaterialCategoryMapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/menu/MenuMaterialCategoryMapper.xml @@ -107,7 +107,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - update menu_material_category set del_flag =1 where category_id in + + delete from menu_material_category where category_id in #{id} diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/menu/MenuNutritionMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/menu/MenuNutritionMapper.xml index 6c48cdf..d71061d 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/menu/MenuNutritionMapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/menu/MenuNutritionMapper.xml @@ -131,8 +131,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and nutrition_code like concat('%', #{nutritionCode}, '%') and nutrition_name like concat('%', #{nutritionName}, '%') - - + and big_type = #{bigType} + and little_type = #{littleType} and category_id in diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/menu/MenuNutritionTypeMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/menu/MenuNutritionTypeMapper.xml index 9c0a6bb..7a6016c 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/menu/MenuNutritionTypeMapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/menu/MenuNutritionTypeMapper.xml @@ -77,11 +77,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - update menu_nutrition_type set del_flag = 1 where id in - - #{id} - - or parent_id in + update menu_nutrition_type set del_flag = 0 where id in #{id} diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/menu/MenuRecipeMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/menu/MenuRecipeMapper.xml index 3a3853c..e0168ee 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/menu/MenuRecipeMapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/menu/MenuRecipeMapper.xml @@ -1351,12 +1351,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - - - insert into menu_material_dishes (dishes_id, material_id, weight, material_type, crby) @@ -1411,5 +1405,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + +