bug修复

This commit is contained in:
liux 2025-04-29 14:33:59 +08:00
parent 36556300a4
commit 1895152fd4
12 changed files with 52 additions and 55 deletions

View File

@ -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<MenuMaterialCategory> {
private static final long serialVersionUID = 1L;
@ -39,6 +41,7 @@ public class MenuMaterialCategory extends Model<MenuMaterialCategory> {
@ApiModelProperty("类型(1原料2商品)")
private Integer categoryType;
@ApiModelProperty("删除标识(1-删除,2-正常)")
@TableField(exist = false)
private Integer delFlag;
@ApiModelProperty("乐观锁")
private Integer revision;

View File

@ -70,7 +70,7 @@ public interface MenuMaterialCategoryMapper extends BaseMapper<MenuMaterialCateg
@Select({"select category_id id, parent_id, category_name,category_type,area_id from menu_material_category ${ew.customSqlSegment}"})
List<MenuCategoryTreeVO> 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);

View File

@ -245,7 +245,7 @@ public interface MenuRecipeMapper extends BaseMapper<MenuRecipe> {
void insertMenuDishesType(MenuDishesType dishesType);
Map<String, Long> getDishesCookMap();
List<MapBean> getDishesCookMap();
int insertMenuMateralDishes(@Param("materialList") ArrayList<MenuMaterialDishes> menuMaterialDishesList);

View File

@ -147,7 +147,6 @@ public class AppletRecipeH5ServiceImpl extends ServiceImpl<MenuRecipeMapper, Men
effIdSet = Sets.newTreeSet();
effIdSet.add(-1L);
}
recipeIdList = this.appletRecipeH5Mapper.selectWeekRecipeId(content.getRecipeId(), (Set) effIdSet);
if (ObjectUtil.isEmpty(recipeIdList)) {
return Lists.newArrayList();

View File

@ -168,7 +168,7 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
throw new ServiceException("菜品基础ID不能为空");
}
MenuDishes menuDishesOne = menuDishesMapper.getOne(menuDishesDTO);
if(menuDishesOne !=null && String.valueOf(menuDishesOne.getDishesId()).equals(menuDishesDTO.getDishesId())){
if(menuDishesOne !=null && String.valueOf(menuDishesOne.getDishesName()).equals(menuDishesDTO.getDishesName())){
throw new ServiceException("菜品已存在");
}
addIds(menuDishesDTO);
@ -1002,18 +1002,13 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
typeMapList.forEach(map -> {
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<String, Long> dishesCookMap = this.menuRecipeMapper.getDishesCookMap();
Map<String, Long> dishesCookMap = new HashMap<>();
List<MapBean> dishesCookMList = this.menuRecipeMapper.getDishesCookMap();
Map<String, Long> dishesCookMap = new HashMap<>();
dishesCookMList.forEach(map -> {
dishesCookMap.put(map.getKey(), toLong(map.getValue()));
});
importDishesContext.setAllocAreaMap(areaMap);
importDishesContext.setAllocStallMap(stallMap);

View File

@ -78,10 +78,8 @@ public class MenuMaterialCategoryServiceImpl extends ServiceImpl<MenuMaterialCat
int num = 0;
Long count = this.baseMapper.selectCount(Wrappers.lambdaQuery(MenuMaterialCategory.class)
.eq(MenuMaterialCategory::getCategoryName, content.getCategoryName())
.eq(content.getAreaId() != null, MenuMaterialCategory::getAreaId,
content.getAreaId())
.isNull(content.getAreaId() == null, MenuMaterialCategory::getAreaId)
.eq(MenuMaterialCategory::getDelFlag, DelFlagEnum.DEL_FALSE.key()));
.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]));
} else {
@ -124,7 +122,7 @@ public class MenuMaterialCategoryServiceImpl extends ServiceImpl<MenuMaterialCat
MenuMaterialCategory parentCategory = this.baseMapper.selectOne(Wrappers.lambdaQuery(MenuMaterialCategory.class)
.eq(MenuMaterialCategory::getCategoryId, parentId)
.eq(MenuMaterialCategory::getCategoryType, categoryType)
.eq(MenuMaterialCategory::getDelFlag, DelFlagEnum.DEL_FALSE.key())
// .eq(MenuMaterialCategory::getDelFlag, DelFlagEnum.DEL_FALSE.key())
.select(MenuMaterialCategory::getCategoryId, MenuMaterialCategory::getParentId,
MenuMaterialCategory::getCategoryNum));
if (ObjectUtil.isNotEmpty(parentCategory)) {
@ -154,7 +152,8 @@ public class MenuMaterialCategoryServiceImpl extends ServiceImpl<MenuMaterialCat
}
MenuMaterialCategory menuMaterialCategory = this.baseMapper.selectOne(Wrappers.lambdaQuery(MenuMaterialCategory.class)
.eq(MenuMaterialCategory::getCategoryId, categoryId).eq(MenuMaterialCategory::getDelFlag, DelFlagEnum.DEL_FALSE.key())
.eq(MenuMaterialCategory::getCategoryId, categoryId)
//.eq(MenuMaterialCategory::getDelFlag, DelFlagEnum.DEL_FALSE.key())
.select(MenuMaterialCategory::getCategoryNum));
if (!ObjectUtil.isNotEmpty(menuMaterialCategory) || !CharSequenceUtil.isNotEmpty(menuMaterialCategory.getCategoryNum())) {
this.generateCategoryNum(categoryId, parentId, categoryType);
@ -164,7 +163,7 @@ public class MenuMaterialCategoryServiceImpl extends ServiceImpl<MenuMaterialCat
@Override
public void syncAllCategoryBigCategoryAndLevel() {
Long checkIfExistLevel = this.baseMapper.selectCount(new LambdaQueryWrapper<>(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<MenuMaterialCat
System.err.println("[货品类别_所有货品类别的所属大类和等级]_不需要同步,跳过!");
} else {
List<MenuMaterialCategory> 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 ServiceImpl<MenuMaterialCat
}
int num = menuMaterialCategoryMapper.updateMenuMaterialCategory(menuMaterialCategory);
if(num >0){
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) {

View File

@ -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);
}

View File

@ -449,6 +449,7 @@ public class MenuRecipeServiceImpl extends ServiceImpl<MenuRecipeMapper, MenuRec
recipe.setCanteenId(ObjectUtil.isNull(dto.getCanteenId()) ? -1L : dto.getCanteenId());
recipe.setStallId(ObjectUtil.isNull(dto.getStallId()) ? -1L : dto.getStallId());
recipe.setCreateBy(userName);
recipe.setUpdateTime(LocalDateTime.now());
menuRecipeMapper.insertData(recipe);
add = true;
} else {
@ -692,23 +693,6 @@ private IMenuRecipeDetailService menuRecipeDetailService;
menuRecipeMapper.deleteMenuRecipeDishesByIds(haveDetailIds);
}
List<MenuRecipeDetail> recipeDetailV2List = result.getRecipeDetails();
if (ObjectUtil.isNotEmpty(recipeDetailV2List)) {
menuRecipeMapper.insertMenuDetails(recipeDetailV2List);
}
List<MenuRecipeDishes> 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<MenuRecipeDetail> recipeDetailV2List = result.getRecipeDetails();
if (ObjectUtil.isNotEmpty(recipeDetailV2List)) {
menuRecipeMapper.insertMenuDetails(recipeDetailV2List);
}
List<MenuRecipeDishes> 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);

View File

@ -107,7 +107,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<update id="deleteMenuMaterialCategoryByIds" parameterType="java.lang.String">
update menu_material_category set del_flag =1 where category_id in
<!-- update menu_material_category set del_flag =1 where category_id in-->
delete from menu_material_category where category_id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>

View File

@ -131,8 +131,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<where>
<if test="nutritionCode != null and nutritionCode != ''"> and nutrition_code like concat('%', #{nutritionCode}, '%')</if>
<if test="nutritionName != null and nutritionName != ''"> and nutrition_name like concat('%', #{nutritionName}, '%')</if>
<!-- <if test="bigType != null and bigType != ''"> and big_type = #{bigType}</if>-->
<!-- <if test="littleType != null and littleType != ''"> and little_type = #{littleType}</if>-->
<if test="bigType != null and bigType != ''"> and big_type = #{bigType}</if>
<if test="littleType != null and littleType != ''"> and little_type = #{littleType}</if>
<!-- <if test="categoryId != null and categoryId != ''"> and category_id = #{categoryId}</if>-->
<if test="categoryIds != null and categoryIds.length > 0">
and category_id in

View File

@ -77,11 +77,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<update id="deleteMenuNutritionTypeByIds" parameterType="String">
update menu_nutrition_type set del_flag = 1 where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
or parent_id in
update menu_nutrition_type set del_flag = 0 where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>

View File

@ -1351,12 +1351,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</insert>
<select id="getDishesCookMap" resultType="java.util.Map">
select cook_name as cookName, cook_id as cookId from menu_dishes_cook
</select>
<insert id="insertMenuMateralDishes" parameterType="List">
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"
<select id="getMenuMaterialTypeMap" resultType="com.bonus.canteen.core.menu.domain.MapBean">
select type_name as `key` ,type_id as `value` from menu_dishes_type
</select>
<select id="getDishesCookMap" resultType="com.bonus.canteen.core.menu.domain.MapBean">
select dict_label as `key`, dict_value as `value` from sys_dict_data where dict_type = 'dishes_cook'
</select>
</mapper>