营养、原料、菜品、菜谱相关优化
This commit is contained in:
parent
3350f26b4d
commit
41e65e2a01
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,4 +66,7 @@ public interface MenuMaterialMapper {
|
||||||
|
|
||||||
MenuMaterial getOne(MenuMaterial menuMaterial);
|
MenuMaterial getOne(MenuMaterial menuMaterial);
|
||||||
|
|
||||||
|
List<Long> selectMaterialIds(Integer[] ids);
|
||||||
|
|
||||||
|
int checkIsExistRelation(Long id);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,4 +70,5 @@ public interface MenuNutritionTypeMapper {
|
||||||
|
|
||||||
MenuNutritionType getParentOne(MenuNutritionType menuNutritionType);
|
MenuNutritionType getParentOne(MenuNutritionType menuNutritionType);
|
||||||
|
|
||||||
|
int checkIsExistRelation(Integer id);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
@ -172,10 +173,12 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
|
||||||
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) {
|
||||||
|
|
@ -187,6 +190,34 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
|
||||||
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<>();
|
||||||
|
|
@ -211,9 +242,6 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
|
||||||
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()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//添加菜品和材料关系表
|
//添加菜品和材料关系表
|
||||||
|
|
@ -265,6 +293,21 @@ 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()]));
|
||||||
|
|
@ -298,10 +341,12 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
|
||||||
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());
|
||||||
|
|
@ -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))) {
|
||||||
|
|
@ -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<>();
|
||||||
|
|
@ -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);
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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 >= #{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>
|
||||||
|
|
|
||||||
|
|
@ -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}
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue