营养、原料、菜品、菜谱相关优化

This commit is contained in:
jjLv 2025-05-14 13:23:20 +08:00
parent 3350f26b4d
commit 41e65e2a01
18 changed files with 296 additions and 149 deletions

View File

@ -97,4 +97,10 @@ public interface MenuDishesMapper extends BaseMapper<MenuDishes> {
List<MapBean> getDishesType(MapBean mapBean); List<MapBean> getDishesType(MapBean mapBean);
List<MapBean> getDishesTypeByList(@Param("key")String key,@Param("keyList")List<String> keyList); List<MapBean> getDishesTypeByList(@Param("key")String key,@Param("keyList")List<String> keyList);
List<Long> getDishesIds(@Param("ids") Long[] ids);
List<Long> getDetailsIds(@Param("dishesIds") List<Long> dishesIds);
int checkIsExistRelation(@Param("ids") List<Long> detailsIds,@Param("type") int i,@Param("nowDate") String nowDate);
} }

View File

@ -27,4 +27,6 @@ public interface MenuDishesTypeMapper extends BaseMapper<MenuDishesType> {
int updateMenuDishesType(MenuDishesTypeEditDTO content); int updateMenuDishesType(MenuDishesTypeEditDTO content);
int delMenuDishesType(MenuDishesTypeEditDTO content); int delMenuDishesType(MenuDishesTypeEditDTO content);
int checkIsExistRelation(Long typeId);
} }

View File

@ -74,4 +74,6 @@ public interface MenuMaterialCategoryMapper extends BaseMapper<MenuMaterialCateg
String getCategoryChildMaxNum(@Param("parentId") Long parentId, @Param("categoryType") Integer categoryType, @Param("delFlag") Integer delFlag); String getCategoryChildMaxNum(@Param("parentId") Long parentId, @Param("categoryType") Integer categoryType, @Param("delFlag") Integer delFlag);
MenuMaterialCategory getOne(MenuMaterialCategory menuMaterialCategory); MenuMaterialCategory getOne(MenuMaterialCategory menuMaterialCategory);
int checkIsExistRelation(String id);
} }

View File

@ -66,4 +66,7 @@ public interface MenuMaterialMapper {
MenuMaterial getOne(MenuMaterial menuMaterial); MenuMaterial getOne(MenuMaterial menuMaterial);
List<Long> selectMaterialIds(Integer[] ids);
int checkIsExistRelation(Long id);
} }

View File

@ -71,4 +71,6 @@ public interface MenuNutritionMapper {
MenuNutrition getOneByCode(MenuNutrition menuNutrition); MenuNutrition getOneByCode(MenuNutrition menuNutrition);
MenuNutrition getOneByName(MenuNutrition menuNutrition); MenuNutrition getOneByName(MenuNutrition menuNutrition);
int checkIsExistRelation(String id);
} }

View File

@ -70,4 +70,5 @@ public interface MenuNutritionTypeMapper {
MenuNutritionType getParentOne(MenuNutritionType menuNutritionType); MenuNutritionType getParentOne(MenuNutritionType menuNutritionType);
int checkIsExistRelation(Integer id);
} }

View File

@ -4,6 +4,7 @@ import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -162,65 +163,92 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
@Override @Override
public int updateMenuDishes(MenuDishesDTO menuDishesDTO) { public int updateMenuDishes(MenuDishesDTO menuDishesDTO) {
// try { // try {
if(menuDishesDTO.getDishesId() == null){ if (menuDishesDTO.getDishesId() == null) {
throw new ServiceException("菜品ID不能为空"); throw new ServiceException("菜品ID不能为空");
} }
if(menuDishesDTO.getBaseDishesId() == null){ if (menuDishesDTO.getBaseDishesId() == null) {
throw new ServiceException("菜品基础ID不能为空"); throw new ServiceException("菜品基础ID不能为空");
} }
MenuDishes menuDishesOne = menuDishesMapper.getOneByName(menuDishesDTO); MenuDishes menuDishesOne = menuDishesMapper.getOneByName(menuDishesDTO);
if(menuDishesOne !=null && menuDishesOne.getDishesId() != Long.parseLong(menuDishesDTO.getDishesId())){ if (menuDishesOne != null && menuDishesOne.getDishesId() != Long.parseLong(menuDishesDTO.getDishesId())) {
throw new ServiceException("菜品已存在"); throw new ServiceException("菜品已存在");
} }
if (!ObjectUtil.isEmpty(menuDishesDTO.getDishesNum())) {
menuDishesOne = menuDishesMapper.getOneByNum(menuDishesDTO); menuDishesOne = menuDishesMapper.getOneByNum(menuDishesDTO);
if(menuDishesOne !=null && menuDishesOne.getDishesId() != Long.parseLong(menuDishesDTO.getDishesId())){ if (menuDishesOne != null && menuDishesOne.getDishesId() != Long.parseLong(menuDishesDTO.getDishesId())) {
throw new ServiceException("编号已存在"); throw new ServiceException("编号已存在");
} }
}
menuDishesDTO.setUpdateBy(SecurityUtils.getUsername()); menuDishesDTO.setUpdateBy(SecurityUtils.getUsername());
int baseNum = menuDishesMapper.updateMenuDishesBase(menuDishesDTO); int baseNum = menuDishesMapper.updateMenuDishesBase(menuDishesDTO);
if(menuDishesDTO.getAreaId()==null){ if (menuDishesDTO.getAreaId() == null) {
menuDishesDTO.setAreaId(-1L); menuDishesDTO.setAreaId(-1L);
} }
if(menuDishesDTO.getCanteenId() == null){ if (menuDishesDTO.getCanteenId() == null) {
menuDishesDTO.setCanteenId(-1L); menuDishesDTO.setCanteenId(-1L);
} }
if(menuDishesDTO.getShopstallId() == null){ if (menuDishesDTO.getShopstallId() == null) {
menuDishesDTO.setShopstallId(-1L); menuDishesDTO.setShopstallId(-1L);
} }
if (ObjectUtil.isEmpty(menuDishesDTO.getTypeId())) {
menuDishesDTO.setTypeId(-1L);
}
if (menuDishesDTO.getClassifyId() == null) {
menuDishesDTO.setClassifyId(-1);
}
if (menuDishesDTO.getEffectId() == null) {
menuDishesDTO.setEffectId(-1);
}
if (menuDishesDTO.getStyleId() == null) {
menuDishesDTO.setStyleId(-1);
}
if (menuDishesDTO.getCookId() == null) {
menuDishesDTO.setCookId(-1);
}
if (menuDishesDTO.getSeason() == null) {
menuDishesDTO.setSeason(new ArrayList<>());
}
if (menuDishesDTO.getSuitIdList() == null) {
menuDishesDTO.setSuitIdList(new ArrayList<>());
}
if (menuDishesDTO.getTasteIdList() == null) {
menuDishesDTO.setTasteIdList(new ArrayList<>());
}
if (menuDishesDTO.getLabelIdList() == null) {
menuDishesDTO.setLabelIdList(new ArrayList<>());
}
addIds(menuDishesDTO);
int dishesNum = menuDishesMapper.editMenuDishes(menuDishesDTO); int dishesNum = menuDishesMapper.editMenuDishes(menuDishesDTO);
List<MenuDishesAddMaterialDTO> materialList= menuDishesDTO.getMaterialList(); List<MenuDishesAddMaterialDTO> materialList = menuDishesDTO.getMaterialList();
List<NutritionEntity> nutritionEntityList = new ArrayList<>(); List<NutritionEntity> nutritionEntityList = new ArrayList<>();
System.err.println("长度:"+materialList.size()); System.err.println("长度:" + materialList.size());
for (MenuDishesAddMaterialDTO i: materialList) { for (MenuDishesAddMaterialDTO i : materialList) {
NutritionEntity nutritionEntity = menuDishesMapper.getNutritionEntity(i); NutritionEntity nutritionEntity = menuDishesMapper.getNutritionEntity(i);
if(nutritionEntity !=null){ if (nutritionEntity != null) {
System.err.println(i.getMaterialId()+",开始值:"+nutritionEntity.getCalcium()); System.err.println(i.getMaterialId() + ",开始值:" + nutritionEntity.getCalcium());
nutritionEntity.setWeight(i.getWeight()); nutritionEntity.setWeight(i.getWeight());
nutritionEntity.setBaseWeight(100.0); nutritionEntity.setBaseWeight(100.0);
nutritionEntityList.add(nutritionEntity); nutritionEntityList.add(nutritionEntity);
} }
} }
if(materialList !=null && materialList.size() > 0){ if (materialList != null && materialList.size() > 0) {
menuDishesMapper.updateMenuMaterialDishes(Long.parseLong(menuDishesDTO.getDishesId())); menuDishesMapper.updateMenuMaterialDishes(Long.parseLong(menuDishesDTO.getDishesId()));
menuDishesMapper.addMenuMaterialDishes(Long.parseLong(menuDishesDTO.getDishesId()),materialList); menuDishesMapper.addMenuMaterialDishes(Long.parseLong(menuDishesDTO.getDishesId()), materialList);
} }
NutritionEntity nutritionEntity = NutritionEntityUtil.countNutrition(nutritionEntityList); NutritionEntity nutritionEntity = NutritionEntityUtil.countNutrition(nutritionEntityList);
if(nutritionEntityList !=null && nutritionEntityList.size() >0){ if (nutritionEntityList != null && nutritionEntityList.size() > 0) {
System.err.println("总和:"+nutritionEntity.getCalcium()); System.err.println("总和:" + nutritionEntity.getCalcium());
//计算营养成分 //计算营养成分
nutritionEntity = countNum(nutritionEntity,menuDishesDTO.getWeight()); nutritionEntity = countNum(nutritionEntity, menuDishesDTO.getWeight());
System.err.println("计算后:"+nutritionEntity.getCalcium()); System.err.println("计算后:" + nutritionEntity.getCalcium());
return menuDishesMapper.addFinalNutrition(nutritionEntity,Long.parseLong(menuDishesDTO.getDishesId())); return menuDishesMapper.addFinalNutrition(nutritionEntity, Long.parseLong(menuDishesDTO.getDishesId()));
}else{
resetBeanToZero(nutritionEntity);
menuDishesMapper.addFinalNutrition(nutritionEntity,Long.parseLong(menuDishesDTO.getDishesId()));
} }
//添加菜品和材料关系表 //添加菜品和材料关系表
if(materialList != null && materialList.size() > 0){ if (materialList != null && materialList.size() > 0) {
menuDishesMapper.updateMenuMaterialDishes(Long.parseLong(menuDishesDTO.getDishesId())); menuDishesMapper.updateMenuMaterialDishes(Long.parseLong(menuDishesDTO.getDishesId()));
menuDishesMapper.addMenuMaterialDishes(Long.parseLong(menuDishesDTO.getDishesId()),materialList); menuDishesMapper.addMenuMaterialDishes(Long.parseLong(menuDishesDTO.getDishesId()), materialList);
}else{ } else {
menuDishesMapper.updateMenuMaterialDishes(Long.parseLong(menuDishesDTO.getDishesId())); menuDishesMapper.updateMenuMaterialDishes(Long.parseLong(menuDishesDTO.getDishesId()));
} }
return menuDishesMapper.editMenuDishes(menuDishesDTO); return menuDishesMapper.editMenuDishes(menuDishesDTO);
@ -265,8 +293,23 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
*/ */
@Override @Override
public int deleteMenuDishesByIds(Long[] ids) { public int deleteMenuDishesByIds(Long[] ids) {
//查询dishesId
List<Long> dishesIds = menuDishesMapper.getDishesIds(ids);
//查询detailsId
List<Long> detailsIds = menuDishesMapper.getDetailsIds(dishesIds);
//查询是否存在关联关系
if (detailsIds != null && !detailsIds.isEmpty()){
int code = menuDishesMapper.checkIsExistRelation(detailsIds,1,null);
if (code > 0) {
throw new ServiceException("存在关联关系,无法删除!");
}
code = menuDishesMapper.checkIsExistRelation(detailsIds,2, DateUtils.getDate());
if (code > 0) {
throw new ServiceException("存在关联关系,无法删除!");
}
}
List<Long> baseDishesIds = menuDishesMapper.getBassIdByIds(ids); List<Long> baseDishesIds = menuDishesMapper.getBassIdByIds(ids);
if(baseDishesIds != null && baseDishesIds.size() >0){ if (baseDishesIds != null && baseDishesIds.size() > 0) {
menuDishesMapper.deleteBaseDishesByIds(baseDishesIds.toArray(new Long[baseDishesIds.size()])); menuDishesMapper.deleteBaseDishesByIds(baseDishesIds.toArray(new Long[baseDishesIds.size()]));
} }
@ -295,55 +338,57 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
public int addMenuDishes(MenuDishesDTO menuDishesDTO) { public int addMenuDishes(MenuDishesDTO menuDishesDTO) {
//检查菜品是否已存在 //检查菜品是否已存在
MenuDishes menuDishesOne = menuDishesMapper.getOneByName(menuDishesDTO); MenuDishes menuDishesOne = menuDishesMapper.getOneByName(menuDishesDTO);
if(menuDishesOne !=null && menuDishesOne.getDishesId() != Long.parseLong(menuDishesDTO.getDishesId())){ if (menuDishesOne != null && menuDishesOne.getDishesId() != Long.parseLong(menuDishesDTO.getDishesId())) {
throw new ServiceException("菜品已存在"); throw new ServiceException("菜品已存在");
} }
if (!ObjectUtil.isEmpty(menuDishesDTO.getDishesNum())) {
menuDishesOne = menuDishesMapper.getOneByNum(menuDishesDTO); menuDishesOne = menuDishesMapper.getOneByNum(menuDishesDTO);
if(menuDishesOne !=null && !StringHelper.isNullOrEmptyString(menuDishesDTO.getDishesNum())){ if (menuDishesOne != null && !StringHelper.isNullOrEmptyString(menuDishesDTO.getDishesNum())) {
throw new ServiceException("编号已存在"); throw new ServiceException("编号已存在");
} }
}
Long dishesId = Id.next(); Long dishesId = Id.next();
Long baseDishesId = Id.next(); Long baseDishesId = Id.next();
menuDishesDTO.setCreateBy(SecurityUtils.getUsername()); menuDishesDTO.setCreateBy(SecurityUtils.getUsername());
//添加基础主表信息 //添加基础主表信息
menuDishesDTO.setBaseDishesId(baseDishesId+""); menuDishesDTO.setBaseDishesId(baseDishesId + "");
menuDishesDTO.setDishesId(dishesId+""); menuDishesDTO.setDishesId(dishesId + "");
menuDishesDTO.setCustomId(-1); menuDishesDTO.setCustomId(-1);
addIds(menuDishesDTO); addIds(menuDishesDTO);
int baseNum = menuDishesMapper.addMenuDishesBase(menuDishesDTO); int baseNum = menuDishesMapper.addMenuDishesBase(menuDishesDTO);
//添加主要信息 //添加主要信息
int dishesNum = menuDishesMapper.addMenuDishes(menuDishesDTO); int dishesNum = menuDishesMapper.addMenuDishes(menuDishesDTO);
List<MenuDishesAddMaterialDTO> materialList= menuDishesDTO.getMaterialList(); List<MenuDishesAddMaterialDTO> materialList = menuDishesDTO.getMaterialList();
List<NutritionEntity> nutritionEntityList = new ArrayList<>(); List<NutritionEntity> nutritionEntityList = new ArrayList<>();
System.err.println("长度:"+materialList.size()); System.err.println("长度:" + materialList.size());
for (MenuDishesAddMaterialDTO i: materialList) { for (MenuDishesAddMaterialDTO i : materialList) {
NutritionEntity nutritionEntity = menuDishesMapper.getNutritionEntity(i); NutritionEntity nutritionEntity = menuDishesMapper.getNutritionEntity(i);
if(nutritionEntity !=null){ if (nutritionEntity != null) {
System.err.println(i.getMaterialId()+",开始值:"+nutritionEntity.getCalcium()); System.err.println(i.getMaterialId() + ",开始值:" + nutritionEntity.getCalcium());
nutritionEntity.setWeight(i.getWeight()); nutritionEntity.setWeight(i.getWeight());
nutritionEntity.setBaseWeight(100.0); nutritionEntity.setBaseWeight(100.0);
nutritionEntityList.add(nutritionEntity); nutritionEntityList.add(nutritionEntity);
} }
} }
if(materialList != null && materialList.size() > 0){ if (materialList != null && materialList.size() > 0) {
//添加菜品和材料关系表 //添加菜品和材料关系表
menuDishesMapper.updateMenuMaterialDishes(Long.parseLong(menuDishesDTO.getDishesId())); menuDishesMapper.updateMenuMaterialDishes(Long.parseLong(menuDishesDTO.getDishesId()));
menuDishesMapper.addMenuMaterialDishes(dishesId,materialList); menuDishesMapper.addMenuMaterialDishes(dishesId, materialList);
NutritionEntity nutritionEntity = NutritionEntityUtil.countNutrition(nutritionEntityList); NutritionEntity nutritionEntity = NutritionEntityUtil.countNutrition(nutritionEntityList);
if(nutritionEntityList !=null && nutritionEntityList.size() >0){ if (nutritionEntityList != null && nutritionEntityList.size() > 0) {
System.err.println("总和:"+nutritionEntity.getCalcium()); System.err.println("总和:" + nutritionEntity.getCalcium());
//计算营养成分 //计算营养成分
nutritionEntity = countNum(nutritionEntity,menuDishesDTO.getWeight()); nutritionEntity = countNum(nutritionEntity, menuDishesDTO.getWeight());
System.err.println("计算后:"+nutritionEntity.getCalcium()); System.err.println("计算后:" + nutritionEntity.getCalcium());
return menuDishesMapper.addFinalNutrition(nutritionEntity,dishesId); return menuDishesMapper.addFinalNutrition(nutritionEntity, dishesId);
} }
} }
return 1; return 1;
} }
private void addIds(MenuDishesDTO menuDishesDTO){ private void addIds(MenuDishesDTO menuDishesDTO) {
List<Integer> labelIdList = menuDishesDTO.getLabelIdList(); List<Integer> labelIdList = menuDishesDTO.getLabelIdList();
@ -355,43 +400,43 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
List<Integer> mealList = menuDishesDTO.getMealList(); List<Integer> mealList = menuDishesDTO.getMealList();
if(labelIdList !=null && !labelIdList.isEmpty()){ if (labelIdList != null && !labelIdList.isEmpty()) {
String result = labelIdList.stream() .map(String::valueOf).collect(Collectors.joining(",")); String result = labelIdList.stream().map(String::valueOf).collect(Collectors.joining(","));
menuDishesDTO.setLabelId(result); menuDishesDTO.setLabelId(result);
} }
if(tasteIdList !=null && !tasteIdList.isEmpty()){ if (tasteIdList != null && !tasteIdList.isEmpty()) {
String result = tasteIdList.stream() .map(String::valueOf).collect(Collectors.joining(",")); String result = tasteIdList.stream().map(String::valueOf).collect(Collectors.joining(","));
menuDishesDTO.setTasteId(result); menuDishesDTO.setTasteId(result);
} }
if(season !=null && !season.isEmpty()){ if (season != null && !season.isEmpty()) {
String result = season.stream() .map(String::valueOf).collect(Collectors.joining(",")); String result = season.stream().map(String::valueOf).collect(Collectors.joining(","));
menuDishesDTO.setSeasonId(result); menuDishesDTO.setSeasonId(result);
} }
if(suitIdList !=null && !suitIdList.isEmpty()){ if (suitIdList != null && !suitIdList.isEmpty()) {
String result = suitIdList.stream() .map(String::valueOf).collect(Collectors.joining(",")); String result = suitIdList.stream().map(String::valueOf).collect(Collectors.joining(","));
menuDishesDTO.setSuitId(result); menuDishesDTO.setSuitId(result);
} }
if(mealList !=null && !mealList.isEmpty()){ if (mealList != null && !mealList.isEmpty()) {
String result = mealList.stream() .map(String::valueOf).collect(Collectors.joining(",")); String result = mealList.stream().map(String::valueOf).collect(Collectors.joining(","));
menuDishesDTO.setMealId(result); menuDishesDTO.setMealId(result);
} }
} }
private NutritionEntity countNum(NutritionEntity nutritionEntity,Double weight) { private NutritionEntity countNum(NutritionEntity nutritionEntity, Double weight) {
Field[] fields = nutritionEntity.getClass().getDeclaredFields(); Field[] fields = nutritionEntity.getClass().getDeclaredFields();
for (Field field : fields) { for (Field field : fields) {
field.setAccessible(true); field.setAccessible(true);
try { try {
Double value = (Double) field.get(nutritionEntity); Double value = (Double) field.get(nutritionEntity);
if(value !=null){ if (value != null) {
System.err.println("先前值----"+value); System.err.println("先前值----" + value);
double proportion = Arith.div(weight , 100); double proportion = Arith.div(weight, 100);
value = Arith.mul(value, proportion); value = Arith.mul(value, proportion);
field.set(nutritionEntity, value); field.set(nutritionEntity, value);
System.err.println("后来值++++"+value); System.err.println("后来值++++" + value);
}else{ } else {
field.set(nutritionEntity, 0.00); field.set(nutritionEntity, 0.00);
} }
@ -403,16 +448,15 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
} }
//首字母转小写 //首字母转小写
public static String toLowerCaseFirstOne(String s) public static String toLowerCaseFirstOne(String s) {
{ if (Character.isLowerCase(s.charAt(0))) {
if(Character.isLowerCase(s.charAt(0))) {
return s; return s;
} else { } else {
return (new StringBuilder()).append(Character.toLowerCase(s.charAt(0))).append(s.substring(1)).toString(); return (new StringBuilder()).append(Character.toLowerCase(s.charAt(0))).append(s.substring(1)).toString();
} }
} }
//首字母转大写 //首字母转大写
public static String toUpperCaseFirstOne(String s) { public static String toUpperCaseFirstOne(String s) {
if (Character.isUpperCase(s.charAt(0))) { if (Character.isUpperCase(s.charAt(0))) {
@ -425,57 +469,57 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
@Override @Override
public MenuDishes check(MenuDishesDTO menuDishesDTO) { public MenuDishes check(MenuDishesDTO menuDishesDTO) {
if(menuDishesDTO.getDishesId() == null){ if (menuDishesDTO.getDishesId() == null) {
throw new ServiceException("菜品ID不能为空"); throw new ServiceException("菜品ID不能为空");
} }
MenuDishes menuDishesDTO1 = menuDishesMapper.getDishMessageByDishesId(menuDishesDTO.getDishesId()); MenuDishes menuDishesDTO1 = menuDishesMapper.getDishMessageByDishesId(menuDishesDTO.getDishesId());
List<MenuDishesAddMaterialDTO> menuDishesAddMaterialDTO= menuDishesMapper.getMenuMaterialDishes(menuDishesDTO.getDishesId()); List<MenuDishesAddMaterialDTO> menuDishesAddMaterialDTO = menuDishesMapper.getMenuMaterialDishes(menuDishesDTO.getDishesId());
if(menuDishesAddMaterialDTO !=null){ if (menuDishesAddMaterialDTO != null) {
menuDishesDTO1.setMaterialList(menuDishesAddMaterialDTO); menuDishesDTO1.setMaterialList(menuDishesAddMaterialDTO);
} }
List<Integer> mealList = new ArrayList<>(); List<Integer> mealList = new ArrayList<>();
if (menuDishesDTO1.getLabelId() !=null && !menuDishesDTO1.getLabelId().isEmpty()){ if (menuDishesDTO1.getLabelId() != null && !menuDishesDTO1.getLabelId().isEmpty()) {
List<Integer> list = Arrays.stream(menuDishesDTO1.getLabelId().split("\\s*,\\s*")) List<Integer> list = Arrays.stream(menuDishesDTO1.getLabelId().split("\\s*,\\s*"))
.map(Integer::parseInt) .map(Integer::parseInt)
.collect(Collectors.toList()); .collect(Collectors.toList());
menuDishesDTO1.setLabelIdList(list); menuDishesDTO1.setLabelIdList(list);
} }
if (menuDishesDTO1.getTasteId()!=null && !menuDishesDTO1.getTasteId().isEmpty()){ if (menuDishesDTO1.getTasteId() != null && !menuDishesDTO1.getTasteId().isEmpty()) {
List<Integer> list = Arrays.stream(menuDishesDTO1.getTasteId().split("\\s*,\\s*")) List<Integer> list = Arrays.stream(menuDishesDTO1.getTasteId().split("\\s*,\\s*"))
.map(Integer::parseInt) .map(Integer::parseInt)
.collect(Collectors.toList()); .collect(Collectors.toList());
menuDishesDTO1.setTasteIdList(list); menuDishesDTO1.setTasteIdList(list);
} }
if (menuDishesDTO1.getSeasonId() !=null && !menuDishesDTO1.getSeasonId().isEmpty()){ if (menuDishesDTO1.getSeasonId() != null && !menuDishesDTO1.getSeasonId().isEmpty()) {
List<Integer> list = Arrays.stream(menuDishesDTO1.getSeasonId().split("\\s*,\\s*")) List<Integer> list = Arrays.stream(menuDishesDTO1.getSeasonId().split("\\s*,\\s*"))
.map(Integer::parseInt) .map(Integer::parseInt)
.collect(Collectors.toList()); .collect(Collectors.toList());
menuDishesDTO1.setSeason(list); menuDishesDTO1.setSeason(list);
} }
if(menuDishesDTO1.getSuitId() !=null && !menuDishesDTO1.getSuitId().isEmpty()){ if (menuDishesDTO1.getSuitId() != null && !menuDishesDTO1.getSuitId().isEmpty()) {
List<Integer> list = Arrays.stream(menuDishesDTO1.getSuitId().split("\\s*,\\s*")) List<Integer> list = Arrays.stream(menuDishesDTO1.getSuitId().split("\\s*,\\s*"))
.map(Integer::parseInt) .map(Integer::parseInt)
.collect(Collectors.toList()); .collect(Collectors.toList());
menuDishesDTO1.setSuitIdList(list); menuDishesDTO1.setSuitIdList(list);
} }
if(menuDishesDTO1.getMealId() !=null && !menuDishesDTO1.getMealId().isEmpty()){ if (menuDishesDTO1.getMealId() != null && !menuDishesDTO1.getMealId().isEmpty()) {
List<Integer> list = Arrays.stream(menuDishesDTO1.getMealId().split("\\s*,\\s*")) List<Integer> list = Arrays.stream(menuDishesDTO1.getMealId().split("\\s*,\\s*"))
.map(Integer::parseInt) .map(Integer::parseInt)
.collect(Collectors.toList()); .collect(Collectors.toList());
menuDishesDTO1.setMealList(list); menuDishesDTO1.setMealList(list);
} }
if(-1 == menuDishesDTO1.getCookId()){ if (-1 == menuDishesDTO1.getCookId()) {
menuDishesDTO1.setCookId(null); menuDishesDTO1.setCookId(null);
} }
if(menuDishesDTO1.getAreaId()== -1L){ if (menuDishesDTO1.getAreaId() == -1L) {
menuDishesDTO1.setAreaId(null); menuDishesDTO1.setAreaId(null);
} }
if(menuDishesDTO1.getCanteenId() == -1L){ if (menuDishesDTO1.getCanteenId() == -1L) {
menuDishesDTO1.setCanteenId(null); menuDishesDTO1.setCanteenId(null);
} }
if(menuDishesDTO1.getShopstallId() == -1L){ if (menuDishesDTO1.getShopstallId() == -1L) {
menuDishesDTO1.setShopstallId(null); menuDishesDTO1.setShopstallId(null);
} }
return menuDishesDTO1; return menuDishesDTO1;
@ -488,7 +532,7 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
try { try {
menuDishesImportDTOS = EasyExcelUtil.readSingleExcel(excel, new MenuDishesImportDTO(), 1); menuDishesImportDTOS = EasyExcelUtil.readSingleExcel(excel, new MenuDishesImportDTO(), 1);
} catch (Exception var42) { } catch (Exception var42) {
throw new ServiceException("导入新增菜品错误"+ var42.getMessage()); throw new ServiceException("导入新增菜品错误" + var42.getMessage());
} }
if (CollectionUtils.isEmpty(menuDishesImportDTOS)) { if (CollectionUtils.isEmpty(menuDishesImportDTOS)) {
throw new ServiceException("导入新增菜品为空"); throw new ServiceException("导入新增菜品为空");
@ -510,8 +554,8 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
List<MenuDishesImportDTO> errorList = new ArrayList<>(); List<MenuDishesImportDTO> errorList = new ArrayList<>();
Iterator var19 = menuDishesImportDTOS.iterator(); Iterator var19 = menuDishesImportDTOS.iterator();
while(var19.hasNext()) { while (var19.hasNext()) {
MenuDishesImportDTO data = (MenuDishesImportDTO)var19.next(); MenuDishesImportDTO data = (MenuDishesImportDTO) var19.next();
try { try {
BigDecimal price = data.getPrice(); BigDecimal price = data.getPrice();
@ -566,7 +610,7 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
String[] var33 = materialList; String[] var33 = materialList;
int var34 = materialList.length; int var34 = materialList.length;
for(int var35 = 0; var35 < var34; ++var35) { for (int var35 = 0; var35 < var34; ++var35) {
String material = var33[var35]; String material = var33[var35];
String[] materialSplit = material.split("&"); String[] materialSplit = material.split("&");
if (materialSplit.length != 3) { if (materialSplit.length != 3) {
@ -711,7 +755,6 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
} }
public void importDishesDTO(List<MenuDishesImportDTO> importDishesList, String username) { public void importDishesDTO(List<MenuDishesImportDTO> importDishesList, String username) {
DishesImportCheckResult dishesImportCheckResult = new DishesImportCheckResult(); DishesImportCheckResult dishesImportCheckResult = new DishesImportCheckResult();
List<MenuDishesImportDTO> successList = new ArrayList<>(); List<MenuDishesImportDTO> successList = new ArrayList<>();
@ -726,8 +769,8 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
List<MenuDishesSize> dishesSizeList = Lists.newArrayList(); List<MenuDishesSize> dishesSizeList = Lists.newArrayList();
Iterator var11 = importDishesList.iterator(); Iterator var11 = importDishesList.iterator();
while(var11.hasNext()) { while (var11.hasNext()) {
MenuDishesImportDTO importDishes = (MenuDishesImportDTO)var11.next(); MenuDishesImportDTO importDishes = (MenuDishesImportDTO) var11.next();
try { try {
String sizeTypeStr; String sizeTypeStr;
@ -784,7 +827,6 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
} }
if (CollUtil.isNotEmpty(dishesAddList)) { if (CollUtil.isNotEmpty(dishesAddList)) {
// MenuDishesMapper var10001 = this.menuDishesMapper; // MenuDishesMapper var10001 = this.menuDishesMapper;
// Objects.requireNonNull(var10001); // Objects.requireNonNull(var10001);
@ -826,16 +868,16 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
// dishesAdd.setDishesNum(sequenceNo); // dishesAdd.setDishesNum(sequenceNo);
dishesAdd.setPrice(importDishes.getPrice().multiply(new BigDecimal("100")).intValue()); dishesAdd.setPrice(importDishes.getPrice().multiply(new BigDecimal("100")).intValue());
dishesAdd.setSalesMode(importDishes.getSalesMode()); dishesAdd.setSalesMode(importDishes.getSalesMode());
dishesAdd.setCookId((Long)dishesCookMap.get(importDishes.getCookName())); dishesAdd.setCookId((Long) dishesCookMap.get(importDishes.getCookName()));
// dishesAdd.setCustomId(this.menuCustomDictService.getNoRepeatCustomId(0)); // dishesAdd.setCustomId(this.menuCustomDictService.getNoRepeatCustomId(0));
dishesAdd.setTypeId((Long)Optional.ofNullable((Long)typeMap.get(importDishes.getDishesTypeName())).orElse(defaultTypeId)); dishesAdd.setTypeId((Long) Optional.ofNullable((Long) typeMap.get(importDishes.getDishesTypeName())).orElse(defaultTypeId));
dishesAdd.setPinyinInitials(PinyinUtil.getFirstLetterFromChinese(importDishes.getDishesName())); dishesAdd.setPinyinInitials(PinyinUtil.getFirstLetterFromChinese(importDishes.getDishesName()));
dishesAdd.setPinyinFull(PinyinUtil.convertChineseToPinyin(importDishes.getDishesName())); dishesAdd.setPinyinFull(PinyinUtil.convertChineseToPinyin(importDishes.getDishesName()));
Integer unitPrice = (Integer)Optional.ofNullable(importDishes.getUnitPrice()).orElse(100); Integer unitPrice = (Integer) Optional.ofNullable(importDishes.getUnitPrice()).orElse(100);
dishesAdd.setUnitPrice(unitPrice); dishesAdd.setUnitPrice(unitPrice);
this.setAllocData(importDishes, dishesAdd, importDishesContext); this.setAllocData(importDishes, dishesAdd, importDishesContext);
if (MenuSalesTypeEnum.PORTION_ON.key().equals(importDishes.getSalesMode())) { if (MenuSalesTypeEnum.PORTION_ON.key().equals(importDishes.getSalesMode())) {
Long sizeType = (Long)Optional.ofNullable(importDishes.getSizeType()).orElse(1L); Long sizeType = (Long) Optional.ofNullable(importDishes.getSizeType()).orElse(1L);
if (sizeType == 2L) { if (sizeType == 2L) {
dishesAdd.setLargePrice(importDishes.getLargePrice().multiply(new BigDecimal("100")).intValue()); dishesAdd.setLargePrice(importDishes.getLargePrice().multiply(new BigDecimal("100")).intValue());
dishesAdd.setLittlePrice(importDishes.getLittlePrice().multiply(new BigDecimal("100")).intValue()); dishesAdd.setLittlePrice(importDishes.getLittlePrice().multiply(new BigDecimal("100")).intValue());
@ -855,14 +897,14 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
String[] var18 = menuMaterials; String[] var18 = menuMaterials;
int var19 = menuMaterials.length; int var19 = menuMaterials.length;
for(int var20 = 0; var20 < var19; ++var20) { for (int var20 = 0; var20 < var19; ++var20) {
String menuMaterial = var18[var20]; String menuMaterial = var18[var20];
String[] materialSplit = menuMaterial.split("&"); String[] materialSplit = menuMaterial.split("&");
String materialName = materialSplit[0]; String materialName = materialSplit[0];
String materialType = materialSplit[1]; String materialType = materialSplit[1];
String materialWeight = materialSplit[2]; String materialWeight = materialSplit[2];
BigDecimal weight = new BigDecimal(materialWeight); BigDecimal weight = new BigDecimal(materialWeight);
Long materialId = (Long)materialMap.get(materialName); Long materialId = (Long) materialMap.get(materialName);
MenuMaterialDishes menuMaterialDishes = new MenuMaterialDishes(); MenuMaterialDishes menuMaterialDishes = new MenuMaterialDishes();
menuMaterialDishes.setMaterialType(Integer.valueOf(materialType)); menuMaterialDishes.setMaterialType(Integer.valueOf(materialType));
menuMaterialDishes.setMaterialId(materialId); menuMaterialDishes.setMaterialId(materialId);
@ -903,8 +945,8 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
List<NutritionEntity> result = new ArrayList<>(); List<NutritionEntity> result = new ArrayList<>();
Iterator var7 = menuMaterialDishes.iterator(); Iterator var7 = menuMaterialDishes.iterator();
while(var7.hasNext()) { while (var7.hasNext()) {
MenuMaterialDishes menuMaterialDish = (MenuMaterialDishes)var7.next(); MenuMaterialDishes menuMaterialDish = (MenuMaterialDishes) var7.next();
MenuMaterialNutrition menuMaterialNutrition = data.get(menuMaterialDish.getMaterialId()); MenuMaterialNutrition menuMaterialNutrition = data.get(menuMaterialDish.getMaterialId());
if (ObjectUtils.isNotEmpty(menuMaterialNutrition)) { if (ObjectUtils.isNotEmpty(menuMaterialNutrition)) {
NutritionEntity nutritionEntity = BeanUtil.copyProperties(menuMaterialNutrition, NutritionEntity.class, new String[0]); NutritionEntity nutritionEntity = BeanUtil.copyProperties(menuMaterialNutrition, NutritionEntity.class, new String[0]);
@ -919,7 +961,6 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
} }
public Map<Long, MenuMaterialNutrition> getMenuMaterialNutrition(List<Long> materialIdList) { public Map<Long, MenuMaterialNutrition> getMenuMaterialNutrition(List<Long> materialIdList) {
List<MenuMaterialNutrition> menuMaterialNutritions = this.menuMaterialNutritionMapper List<MenuMaterialNutrition> menuMaterialNutritions = this.menuMaterialNutritionMapper
.selectList(Wrappers.lambdaQuery(MenuMaterialNutrition.class) .selectList(Wrappers.lambdaQuery(MenuMaterialNutrition.class)
@ -968,13 +1009,11 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
} }
public MenuMaterial getByMaterialId(Long materialId) { public MenuMaterial getByMaterialId(Long materialId) {
return this.menuMaterialMapper.selectMenuMaterialMaterialId(materialId); return this.menuMaterialMapper.selectMenuMaterialMaterialId(materialId);
} }
public void setAllocData(MenuDishesImportDTO importDishes, MenuDishes dishesAdd, ImportDishesContext importDishesContext) { public void setAllocData(MenuDishesImportDTO importDishes, MenuDishes dishesAdd, ImportDishesContext importDishesContext) {
Long stallId = -1L; Long stallId = -1L;
Long canteenId = -1L; Long canteenId = -1L;
@ -985,14 +1024,14 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
Map<String, Long> canteenMap = importDishesContext.getCanteenMap(); Map<String, Long> canteenMap = importDishesContext.getCanteenMap();
Map<String, AllocArea> allocAreaMap = importDishesContext.getAllocAreaMap(); Map<String, AllocArea> allocAreaMap = importDishesContext.getAllocAreaMap();
if (ObjectUtil.isNotEmpty(importDishes.getStallName())) { if (ObjectUtil.isNotEmpty(importDishes.getStallName())) {
stallId = (Long)stallMap.get(importDishes.getStallName()); stallId = (Long) stallMap.get(importDishes.getStallName());
canteenId = (Long)canteenStallMap.get(stallId); canteenId = (Long) canteenStallMap.get(stallId);
areaId = (Long)areaCanteenMap.get(canteenId); areaId = (Long) areaCanteenMap.get(canteenId);
} else if (ObjectUtil.isNotEmpty(importDishes.getCanteenName())) { } else if (ObjectUtil.isNotEmpty(importDishes.getCanteenName())) {
canteenId = (Long)canteenMap.get(importDishes.getCanteenName()); canteenId = (Long) canteenMap.get(importDishes.getCanteenName());
areaId = (Long)areaCanteenMap.get(canteenId); areaId = (Long) areaCanteenMap.get(canteenId);
} else if (ObjectUtil.isNotEmpty(importDishes.getAreaName())) { } else if (ObjectUtil.isNotEmpty(importDishes.getAreaName())) {
areaId = ((AllocArea)allocAreaMap.get(importDishes.getAreaName())).getAreaId(); areaId = ((AllocArea) allocAreaMap.get(importDishes.getAreaName())).getAreaId();
} }
dishesAdd.setCanteenId(canteenId); dishesAdd.setCanteenId(canteenId);
@ -1008,7 +1047,7 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
String[] var6 = sizeTypeStrArr; String[] var6 = sizeTypeStrArr;
int var7 = sizeTypeStrArr.length; int var7 = sizeTypeStrArr.length;
for(int var8 = 0; var8 < var7; ++var8) { for (int var8 = 0; var8 < var7; ++var8) {
String sizeTypeStr = var6[var8]; String sizeTypeStr = var6[var8];
MenuDishesSize dishesSize = new MenuDishesSize(); MenuDishesSize dishesSize = new MenuDishesSize();
dishesSize.setBaseDishesId(baseDishesId); dishesSize.setBaseDishesId(baseDishesId);

View File

@ -59,6 +59,7 @@ public class MenuDishesTypeServiceImpl extends ServiceImpl<MenuDishesTypeMapper
BeanUtil.copyProperties(content, dishesType, new String[0]); BeanUtil.copyProperties(content, dishesType, new String[0]);
dishesType.setCreateBy(username); dishesType.setCreateBy(username);
dishesType.setTypeId(Id.next()); dishesType.setTypeId(Id.next());
dishesType.setDelFlag(0);
return this.baseMapper.insert(dishesType); return this.baseMapper.insert(dishesType);
} }
} }
@ -76,7 +77,10 @@ public class MenuDishesTypeServiceImpl extends ServiceImpl<MenuDishesTypeMapper
@Override @Override
public int delMenuDishesType(MenuDishesTypeEditDTO content) { public int delMenuDishesType(MenuDishesTypeEditDTO content) {
int code = menuDishesTypeMapper.checkIsExistRelation(content.getTypeId());
if (code > 0){
throw new ServiceException("该菜品类型下有数据,不能删除");
}
return menuDishesTypeMapper.delMenuDishesType(content); return menuDishesTypeMapper.delMenuDishesType(content);
} }
} }

View File

@ -259,11 +259,19 @@ public class MenuMaterialCategoryServiceImpl extends ServiceImpl<MenuMaterialCat
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public int deleteMenuMaterialCategoryByIds(String[] ids) { public int deleteMenuMaterialCategoryByIds(String[] ids) {
try{ try{
for (String id : ids){
//判断是否有关联
int code = menuMaterialCategoryMapper.checkIsExistRelation(id);
if(code > 0){
throw new ServiceException("存在关联关系,无法删除!");
}
}
menuMaterialCategoryMapper.deleteMenuMaterialCategoryByIds(ids); menuMaterialCategoryMapper.deleteMenuMaterialCategoryByIds(ids);
List<String> childCategoryIds = menuMaterialCategoryMapper.getChildCategoryIds(ids); List<String> childCategoryIds = menuMaterialCategoryMapper.getChildCategoryIds(ids);
if(childCategoryIds !=null && childCategoryIds.size() > 0){ if(childCategoryIds !=null && childCategoryIds.size() > 0){
String[] idss = childCategoryIds.toArray(new String[childCategoryIds.size()]); // 避免数组扩容 String[] idss = childCategoryIds.toArray(new String[childCategoryIds.size()]); // 避免数组扩容
//递归删除 //递归删除
deleteMenuMaterialCategoryByIds(idss); deleteMenuMaterialCategoryByIds(idss);
} }
return 1; return 1;

View File

@ -3,6 +3,7 @@ package com.bonus.canteen.core.menu.service.impl;
import java.util.List; import java.util.List;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.bonus.canteen.core.menu.domain.MenuMaterialNutrition; import com.bonus.canteen.core.menu.domain.MenuMaterialNutrition;
@ -122,6 +123,9 @@ public class MenuMaterialServiceImpl implements IMenuMaterialService {
// menuMaterialNutrition.setCategoryId(menuMaterial.getCategoryId()); // menuMaterialNutrition.setCategoryId(menuMaterial.getCategoryId());
// this.menuMaterialNutritionMapper.update(menuMaterialNutrition,Wrappers.lambdaUpdate(MenuMaterialNutrition.class).eq(MenuMaterialNutrition::getMaterialId,menuMaterial.getMaterialId()).eq(MenuMaterialNutrition::getCategoryId, menuMaterial.getCategoryId())); // this.menuMaterialNutritionMapper.update(menuMaterialNutrition,Wrappers.lambdaUpdate(MenuMaterialNutrition.class).eq(MenuMaterialNutrition::getMaterialId,menuMaterial.getMaterialId()).eq(MenuMaterialNutrition::getCategoryId, menuMaterial.getCategoryId()));
// } // }
if (ObjectUtil.isEmpty(menuMaterial.getNutritionType())){
menuMaterial.setNutritionType("");
}
return menuMaterialMapper.updateMenuMaterial(menuMaterial); return menuMaterialMapper.updateMenuMaterial(menuMaterial);
} catch (Exception e) { } catch (Exception e) {
throw new ServiceException(e.getMessage()); throw new ServiceException(e.getMessage());
@ -136,6 +140,16 @@ public class MenuMaterialServiceImpl implements IMenuMaterialService {
*/ */
@Override @Override
public int deleteMenuMaterialByIds(Integer[] ids) { public int deleteMenuMaterialByIds(Integer[] ids) {
//查询materialId
List<Long> materialIdList = menuMaterialMapper.selectMaterialIds(ids);
// 判断是否关联了菜品
for (Long id : materialIdList){
// 判断是否关联了菜品
int count = menuMaterialMapper.checkIsExistRelation(id);
if(count > 0){
throw new ServiceException("存在关联关系,无法删除!");
}
}
return menuMaterialMapper.deleteMenuMaterialByIds(ids); return menuMaterialMapper.deleteMenuMaterialByIds(ids);
} }

View File

@ -122,6 +122,13 @@ public class MenuNutritionServiceImpl implements IMenuNutritionService {
*/ */
@Override @Override
public int deleteMenuNutritionByIds(String[] ids) { public int deleteMenuNutritionByIds(String[] ids) {
for (String id : ids){
// 判断是否关联了菜品
int count = menuNutritionMapper.checkIsExistRelation(id);
if(count > 0){
throw new ServiceException("存在关联关系,无法删除!");
}
}
return menuNutritionMapper.deleteMenuNutritionByIds(ids); return menuNutritionMapper.deleteMenuNutritionByIds(ids);
} }
@ -133,6 +140,11 @@ public class MenuNutritionServiceImpl implements IMenuNutritionService {
*/ */
@Override @Override
public int deleteMenuNutritionById(Long id) { public int deleteMenuNutritionById(Long id) {
// 判断是否关联了菜品
int count = menuNutritionMapper.checkIsExistRelation(String.valueOf(id));
if(count > 0){
throw new ServiceException("存在关联关系,无法删除!");
}
return menuNutritionMapper.deleteMenuNutritionById(id); return menuNutritionMapper.deleteMenuNutritionById(id);
} }
} }

View File

@ -115,6 +115,14 @@ public class MenuNutritionTypeServiceImpl implements IMenuNutritionTypeService {
if(ids == null || ids.length == 0){ if(ids == null || ids.length == 0){
throw new ServiceException("请选择要删除的营养基础类型"); throw new ServiceException("请选择要删除的营养基础类型");
} }
for (int i = 0; i < ids.length; i++) {
int code = menuNutritionTypeMapper.checkIsExistRelation(ids[i]);
if(code > 0){
throw new ServiceException("该营养基础类型下有数据,不能删除");
}
}
return menuNutritionTypeMapper.deleteMenuNutritionTypeByIds(ids); return menuNutritionTypeMapper.deleteMenuNutritionTypeByIds(ids);
} }

View File

@ -99,6 +99,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectMenuDishesList" parameterType="com.bonus.canteen.core.menu.domain.MenuDishes" resultMap="MenuDishesResult"> <select id="selectMenuDishesList" parameterType="com.bonus.canteen.core.menu.domain.MenuDishes" resultMap="MenuDishesResult">
<include refid="selectMenuDishesVo"/> <include refid="selectMenuDishesVo"/>
<where> <where>
b.del_flag = 0
<if test="dishesId != null "> and b.dishes_id = #{dishesId}</if> <if test="dishesId != null "> and b.dishes_id = #{dishesId}</if>
<if test="baseDishesId != null "> and b.base_dishes_id = #{baseDishesId}</if> <if test="baseDishesId != null "> and b.base_dishes_id = #{baseDishesId}</if>
<if test="canteenId != null "> and b.canteen_id = #{canteenId}</if> <if test="canteenId != null "> and b.canteen_id = #{canteenId}</if>
@ -377,7 +378,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<delete id="deleteBaseDishesByIds"> <delete id="deleteBaseDishesByIds">
delete from menu_dishes_base where base_dishes_id in update menu_dishes_base set del_flag = '2'where base_dishes_id in
<foreach collection="baseDishesIds" separator="," open="(" close=")" item="item"> <foreach collection="baseDishesIds" separator="," open="(" close=")" item="item">
#{item} #{item}
</foreach> </foreach>
@ -581,9 +582,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{item} #{item}
</foreach> </foreach>
</select> </select>
<select id="getDishesIds" resultType="java.lang.Long">
select dishes_id from menu_dishes where id in
<foreach collection="ids" separator="," open="(" close=")" item="item">
#{item}
</foreach>
</select>
<select id="getDetailsIds" resultType="java.lang.Long">
select detail_id from menu_recipe_dishes where dishes_id in
<foreach collection="dishesIds" separator="," open="(" close=")" item="item">
#{item}
</foreach>
</select>
<select id="checkIsExistRelation" resultType="java.lang.Integer">
select count(1) from menu_recipe_detail where detail_type = #{type} and detail_id in
<foreach collection="ids" separator="," open="(" close=")" item="item">
#{item}
</foreach>
<if test="nowDate != null">
and apply_date &gt;= #{nowDate}
</if>
</select>
<delete id="deleteMenuByIds" parameterType="long"> <delete id="deleteMenuByIds" parameterType="long">
delete from menu_dishes where id in update menu_dishes set del_flag = '2' where id in
<foreach collection="ids" separator="," open="(" close=")" item="item"> <foreach collection="ids" separator="," open="(" close=")" item="item">
#{item} #{item}
</foreach> </foreach>

View File

@ -47,6 +47,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by du.id desc order by du.id desc
</select> </select>
<select id="checkIsExistRelation" resultType="java.lang.Integer">
select count(1) from menu_dishes where type_id = #{typeId}
</select>
<update id="updateMenuDishesType"> <update id="updateMenuDishesType">
update menu_dishes_type set type_name = #{typeName} where type_id = #{typeId} update menu_dishes_type set type_name = #{typeName} where type_id = #{typeId}

View File

@ -131,6 +131,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getOne" resultMap="MenuMaterialCategoryResult"> <select id="getOne" resultMap="MenuMaterialCategoryResult">
select * from menu_material_category where parent_id =#{parentId} and category_name =#{categoryName} and category_type =#{categoryType} and area_id =#{areaId} select * from menu_material_category where parent_id =#{parentId} and category_name =#{categoryName} and category_type =#{categoryType} and area_id =#{areaId}
</select> </select>
<select id="checkIsExistRelation" resultType="java.lang.Integer">
SELECT count(1) from menu_material where category_id = #{id}
</select>
</mapper> </mapper>

View File

@ -227,6 +227,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectMenuMaterialVo"/> <include refid="selectMenuMaterialVo"/>
where mm.material_id = #{id} where mm.material_id = #{id}
</select> </select>
<select id="selectMaterialIds" resultType="java.lang.Long">
select material_id from menu_material
where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<select id="checkIsExistRelation" resultType="java.lang.Integer">
select count(1) from menu_material_dishes where material_id = #{materialId}
</select>
</mapper> </mapper>

View File

@ -491,5 +491,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if> </if>
limit 1 limit 1
</select> </select>
<select id="checkIsExistRelation" resultType="java.lang.Integer">
select count(1)
from menu_material
where nutrition_type = #{id}
</select>
</mapper> </mapper>

View File

@ -106,6 +106,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getParentOne" resultMap="MenuNutritionTypeResult" parameterType="com.bonus.canteen.core.menu.domain.MenuNutritionType"> <select id="getParentOne" resultMap="MenuNutritionTypeResult" parameterType="com.bonus.canteen.core.menu.domain.MenuNutritionType">
select * from menu_nutrition_type where id = #{parentId} and del_flag = 2 limit 1 select * from menu_nutrition_type where id = #{parentId} and del_flag = 2 limit 1
</select> </select>
<select id="checkIsExistRelation" resultType="java.lang.Integer">
select count(1) from menu_nutrition where category_id = #{id}
</select>
</mapper> </mapper>