营养、原料、菜品、菜谱相关优化
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> 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 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);
|
||||
|
||||
MenuMaterialCategory getOne(MenuMaterialCategory menuMaterialCategory);
|
||||
|
||||
int checkIsExistRelation(String id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,4 +66,7 @@ public interface MenuMaterialMapper {
|
|||
|
||||
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 getOneByName(MenuNutrition menuNutrition);
|
||||
|
||||
int checkIsExistRelation(String id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,4 +70,5 @@ public interface MenuNutritionTypeMapper {
|
|||
|
||||
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.Method;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
@ -71,7 +72,7 @@ import javax.validation.constraints.Size;
|
|||
* @date 2025-04-03
|
||||
*/
|
||||
@Service
|
||||
public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDishes> implements IMenuDishesService {
|
||||
public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDishes> implements IMenuDishesService {
|
||||
@Resource
|
||||
private MenuDishesMapper menuDishesMapper;
|
||||
|
||||
|
|
@ -161,69 +162,96 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
|
|||
*/
|
||||
@Override
|
||||
public int updateMenuDishes(MenuDishesDTO menuDishesDTO) {
|
||||
// try {
|
||||
if(menuDishesDTO.getDishesId() == null){
|
||||
throw new ServiceException("菜品ID不能为空");
|
||||
}
|
||||
if(menuDishesDTO.getBaseDishesId() == null){
|
||||
throw new ServiceException("菜品基础ID不能为空");
|
||||
}
|
||||
MenuDishes menuDishesOne = menuDishesMapper.getOneByName(menuDishesDTO);
|
||||
if(menuDishesOne !=null && menuDishesOne.getDishesId() != Long.parseLong(menuDishesDTO.getDishesId())){
|
||||
throw new ServiceException("菜品已存在");
|
||||
}
|
||||
// try {
|
||||
if (menuDishesDTO.getDishesId() == null) {
|
||||
throw new ServiceException("菜品ID不能为空");
|
||||
}
|
||||
if (menuDishesDTO.getBaseDishesId() == null) {
|
||||
throw new ServiceException("菜品基础ID不能为空");
|
||||
}
|
||||
MenuDishes menuDishesOne = menuDishesMapper.getOneByName(menuDishesDTO);
|
||||
if (menuDishesOne != null && menuDishesOne.getDishesId() != Long.parseLong(menuDishesDTO.getDishesId())) {
|
||||
throw new ServiceException("菜品已存在");
|
||||
}
|
||||
if (!ObjectUtil.isEmpty(menuDishesDTO.getDishesNum())) {
|
||||
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("编号已存在");
|
||||
}
|
||||
}
|
||||
menuDishesDTO.setUpdateBy(SecurityUtils.getUsername());
|
||||
int baseNum = menuDishesMapper.updateMenuDishesBase(menuDishesDTO);
|
||||
if(menuDishesDTO.getAreaId()==null){
|
||||
menuDishesDTO.setAreaId(-1L);
|
||||
}
|
||||
if(menuDishesDTO.getCanteenId() == null){
|
||||
menuDishesDTO.setCanteenId(-1L);
|
||||
}
|
||||
if(menuDishesDTO.getShopstallId() == null){
|
||||
menuDishesDTO.setShopstallId(-1L);
|
||||
}
|
||||
int dishesNum = menuDishesMapper.editMenuDishes(menuDishesDTO);
|
||||
List<MenuDishesAddMaterialDTO> materialList= menuDishesDTO.getMaterialList();
|
||||
List<NutritionEntity> nutritionEntityList = new ArrayList<>();
|
||||
System.err.println("长度:"+materialList.size());
|
||||
for (MenuDishesAddMaterialDTO i: materialList) {
|
||||
NutritionEntity nutritionEntity = menuDishesMapper.getNutritionEntity(i);
|
||||
if(nutritionEntity !=null){
|
||||
System.err.println(i.getMaterialId()+",开始值:"+nutritionEntity.getCalcium());
|
||||
nutritionEntity.setWeight(i.getWeight());
|
||||
nutritionEntity.setBaseWeight(100.0);
|
||||
nutritionEntityList.add(nutritionEntity);
|
||||
}
|
||||
}
|
||||
if(materialList !=null && materialList.size() > 0){
|
||||
menuDishesMapper.updateMenuMaterialDishes(Long.parseLong(menuDishesDTO.getDishesId()));
|
||||
menuDishesMapper.addMenuMaterialDishes(Long.parseLong(menuDishesDTO.getDishesId()),materialList);
|
||||
}
|
||||
NutritionEntity nutritionEntity = NutritionEntityUtil.countNutrition(nutritionEntityList);
|
||||
if(nutritionEntityList !=null && nutritionEntityList.size() >0){
|
||||
System.err.println("总和:"+nutritionEntity.getCalcium());
|
||||
//计算营养成分
|
||||
nutritionEntity = countNum(nutritionEntity,menuDishesDTO.getWeight());
|
||||
System.err.println("计算后:"+nutritionEntity.getCalcium());
|
||||
return menuDishesMapper.addFinalNutrition(nutritionEntity,Long.parseLong(menuDishesDTO.getDishesId()));
|
||||
}else{
|
||||
resetBeanToZero(nutritionEntity);
|
||||
menuDishesMapper.addFinalNutrition(nutritionEntity,Long.parseLong(menuDishesDTO.getDishesId()));
|
||||
int baseNum = menuDishesMapper.updateMenuDishesBase(menuDishesDTO);
|
||||
if (menuDishesDTO.getAreaId() == null) {
|
||||
menuDishesDTO.setAreaId(-1L);
|
||||
}
|
||||
if (menuDishesDTO.getCanteenId() == null) {
|
||||
menuDishesDTO.setCanteenId(-1L);
|
||||
}
|
||||
if (menuDishesDTO.getShopstallId() == null) {
|
||||
menuDishesDTO.setShopstallId(-1L);
|
||||
}
|
||||
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);
|
||||
List<MenuDishesAddMaterialDTO> materialList = menuDishesDTO.getMaterialList();
|
||||
List<NutritionEntity> nutritionEntityList = new ArrayList<>();
|
||||
System.err.println("长度:" + materialList.size());
|
||||
for (MenuDishesAddMaterialDTO i : materialList) {
|
||||
NutritionEntity nutritionEntity = menuDishesMapper.getNutritionEntity(i);
|
||||
if (nutritionEntity != null) {
|
||||
System.err.println(i.getMaterialId() + ",开始值:" + nutritionEntity.getCalcium());
|
||||
nutritionEntity.setWeight(i.getWeight());
|
||||
nutritionEntity.setBaseWeight(100.0);
|
||||
nutritionEntityList.add(nutritionEntity);
|
||||
}
|
||||
}
|
||||
if (materialList != null && materialList.size() > 0) {
|
||||
menuDishesMapper.updateMenuMaterialDishes(Long.parseLong(menuDishesDTO.getDishesId()));
|
||||
menuDishesMapper.addMenuMaterialDishes(Long.parseLong(menuDishesDTO.getDishesId()), materialList);
|
||||
}
|
||||
NutritionEntity nutritionEntity = NutritionEntityUtil.countNutrition(nutritionEntityList);
|
||||
if (nutritionEntityList != null && nutritionEntityList.size() > 0) {
|
||||
System.err.println("总和:" + nutritionEntity.getCalcium());
|
||||
//计算营养成分
|
||||
nutritionEntity = countNum(nutritionEntity, menuDishesDTO.getWeight());
|
||||
System.err.println("计算后:" + nutritionEntity.getCalcium());
|
||||
return menuDishesMapper.addFinalNutrition(nutritionEntity, Long.parseLong(menuDishesDTO.getDishesId()));
|
||||
}
|
||||
|
||||
//添加菜品和材料关系表
|
||||
if(materialList != null && materialList.size() > 0){
|
||||
menuDishesMapper.updateMenuMaterialDishes(Long.parseLong(menuDishesDTO.getDishesId()));
|
||||
menuDishesMapper.addMenuMaterialDishes(Long.parseLong(menuDishesDTO.getDishesId()),materialList);
|
||||
}else{
|
||||
menuDishesMapper.updateMenuMaterialDishes(Long.parseLong(menuDishesDTO.getDishesId()));
|
||||
}
|
||||
return menuDishesMapper.editMenuDishes(menuDishesDTO);
|
||||
//添加菜品和材料关系表
|
||||
if (materialList != null && materialList.size() > 0) {
|
||||
menuDishesMapper.updateMenuMaterialDishes(Long.parseLong(menuDishesDTO.getDishesId()));
|
||||
menuDishesMapper.addMenuMaterialDishes(Long.parseLong(menuDishesDTO.getDishesId()), materialList);
|
||||
} else {
|
||||
menuDishesMapper.updateMenuMaterialDishes(Long.parseLong(menuDishesDTO.getDishesId()));
|
||||
}
|
||||
return menuDishesMapper.editMenuDishes(menuDishesDTO);
|
||||
// } catch (Exception e) {
|
||||
// throw new ServiceException(e.toString());
|
||||
// }
|
||||
|
|
@ -265,8 +293,23 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
|
|||
*/
|
||||
@Override
|
||||
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);
|
||||
if(baseDishesIds != null && baseDishesIds.size() >0){
|
||||
if (baseDishesIds != null && baseDishesIds.size() > 0) {
|
||||
menuDishesMapper.deleteBaseDishesByIds(baseDishesIds.toArray(new Long[baseDishesIds.size()]));
|
||||
}
|
||||
|
||||
|
|
@ -295,103 +338,105 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
|
|||
public int addMenuDishes(MenuDishesDTO 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("菜品已存在");
|
||||
}
|
||||
menuDishesOne = menuDishesMapper.getOneByNum(menuDishesDTO);
|
||||
if(menuDishesOne !=null && !StringHelper.isNullOrEmptyString(menuDishesDTO.getDishesNum())){
|
||||
throw new ServiceException("编号已存在");
|
||||
if (!ObjectUtil.isEmpty(menuDishesDTO.getDishesNum())) {
|
||||
menuDishesOne = menuDishesMapper.getOneByNum(menuDishesDTO);
|
||||
if (menuDishesOne != null && !StringHelper.isNullOrEmptyString(menuDishesDTO.getDishesNum())) {
|
||||
throw new ServiceException("编号已存在");
|
||||
}
|
||||
}
|
||||
Long dishesId = Id.next();
|
||||
Long baseDishesId = Id.next();
|
||||
menuDishesDTO.setCreateBy(SecurityUtils.getUsername());
|
||||
//添加基础主表信息
|
||||
menuDishesDTO.setBaseDishesId(baseDishesId+"");
|
||||
menuDishesDTO.setDishesId(dishesId+"");
|
||||
menuDishesDTO.setBaseDishesId(baseDishesId + "");
|
||||
menuDishesDTO.setDishesId(dishesId + "");
|
||||
menuDishesDTO.setCustomId(-1);
|
||||
addIds(menuDishesDTO);
|
||||
int baseNum = menuDishesMapper.addMenuDishesBase(menuDishesDTO);
|
||||
//添加主要信息
|
||||
int dishesNum = menuDishesMapper.addMenuDishes(menuDishesDTO);
|
||||
int baseNum = menuDishesMapper.addMenuDishesBase(menuDishesDTO);
|
||||
//添加主要信息
|
||||
int dishesNum = menuDishesMapper.addMenuDishes(menuDishesDTO);
|
||||
|
||||
List<MenuDishesAddMaterialDTO> materialList= menuDishesDTO.getMaterialList();
|
||||
List<MenuDishesAddMaterialDTO> materialList = menuDishesDTO.getMaterialList();
|
||||
List<NutritionEntity> nutritionEntityList = new ArrayList<>();
|
||||
System.err.println("长度:"+materialList.size());
|
||||
for (MenuDishesAddMaterialDTO i: materialList) {
|
||||
System.err.println("长度:" + materialList.size());
|
||||
for (MenuDishesAddMaterialDTO i : materialList) {
|
||||
NutritionEntity nutritionEntity = menuDishesMapper.getNutritionEntity(i);
|
||||
if(nutritionEntity !=null){
|
||||
System.err.println(i.getMaterialId()+",开始值:"+nutritionEntity.getCalcium());
|
||||
if (nutritionEntity != null) {
|
||||
System.err.println(i.getMaterialId() + ",开始值:" + nutritionEntity.getCalcium());
|
||||
nutritionEntity.setWeight(i.getWeight());
|
||||
nutritionEntity.setBaseWeight(100.0);
|
||||
nutritionEntityList.add(nutritionEntity);
|
||||
}
|
||||
}
|
||||
if(materialList != null && materialList.size() > 0){
|
||||
if (materialList != null && materialList.size() > 0) {
|
||||
//添加菜品和材料关系表
|
||||
menuDishesMapper.updateMenuMaterialDishes(Long.parseLong(menuDishesDTO.getDishesId()));
|
||||
menuDishesMapper.addMenuMaterialDishes(dishesId,materialList);
|
||||
menuDishesMapper.addMenuMaterialDishes(dishesId, materialList);
|
||||
NutritionEntity nutritionEntity = NutritionEntityUtil.countNutrition(nutritionEntityList);
|
||||
if(nutritionEntityList !=null && nutritionEntityList.size() >0){
|
||||
System.err.println("总和:"+nutritionEntity.getCalcium());
|
||||
if (nutritionEntityList != null && nutritionEntityList.size() > 0) {
|
||||
System.err.println("总和:" + nutritionEntity.getCalcium());
|
||||
//计算营养成分
|
||||
nutritionEntity = countNum(nutritionEntity,menuDishesDTO.getWeight());
|
||||
System.err.println("计算后:"+nutritionEntity.getCalcium());
|
||||
return menuDishesMapper.addFinalNutrition(nutritionEntity,dishesId);
|
||||
nutritionEntity = countNum(nutritionEntity, menuDishesDTO.getWeight());
|
||||
System.err.println("计算后:" + nutritionEntity.getCalcium());
|
||||
return menuDishesMapper.addFinalNutrition(nutritionEntity, dishesId);
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
private void addIds(MenuDishesDTO menuDishesDTO){
|
||||
private void addIds(MenuDishesDTO menuDishesDTO) {
|
||||
|
||||
List<Integer> labelIdList = menuDishesDTO.getLabelIdList();
|
||||
|
||||
List<Integer> tasteIdList = menuDishesDTO.getTasteIdList();
|
||||
|
||||
List<Integer> season = menuDishesDTO.getSeason();
|
||||
List<Integer> season = menuDishesDTO.getSeason();
|
||||
|
||||
List<Integer> suitIdList = menuDishesDTO.getSuitIdList();
|
||||
|
||||
List<Integer> mealList = menuDishesDTO.getMealList();
|
||||
List<Integer> mealList = menuDishesDTO.getMealList();
|
||||
|
||||
if(labelIdList !=null && !labelIdList.isEmpty()){
|
||||
String result = labelIdList.stream() .map(String::valueOf).collect(Collectors.joining(","));
|
||||
if (labelIdList != null && !labelIdList.isEmpty()) {
|
||||
String result = labelIdList.stream().map(String::valueOf).collect(Collectors.joining(","));
|
||||
menuDishesDTO.setLabelId(result);
|
||||
}
|
||||
if(tasteIdList !=null && !tasteIdList.isEmpty()){
|
||||
String result = tasteIdList.stream() .map(String::valueOf).collect(Collectors.joining(","));
|
||||
if (tasteIdList != null && !tasteIdList.isEmpty()) {
|
||||
String result = tasteIdList.stream().map(String::valueOf).collect(Collectors.joining(","));
|
||||
menuDishesDTO.setTasteId(result);
|
||||
}
|
||||
if(season !=null && !season.isEmpty()){
|
||||
String result = season.stream() .map(String::valueOf).collect(Collectors.joining(","));
|
||||
if (season != null && !season.isEmpty()) {
|
||||
String result = season.stream().map(String::valueOf).collect(Collectors.joining(","));
|
||||
menuDishesDTO.setSeasonId(result);
|
||||
}
|
||||
if(suitIdList !=null && !suitIdList.isEmpty()){
|
||||
String result = suitIdList.stream() .map(String::valueOf).collect(Collectors.joining(","));
|
||||
if (suitIdList != null && !suitIdList.isEmpty()) {
|
||||
String result = suitIdList.stream().map(String::valueOf).collect(Collectors.joining(","));
|
||||
menuDishesDTO.setSuitId(result);
|
||||
}
|
||||
if(mealList !=null && !mealList.isEmpty()){
|
||||
String result = mealList.stream() .map(String::valueOf).collect(Collectors.joining(","));
|
||||
if (mealList != null && !mealList.isEmpty()) {
|
||||
String result = mealList.stream().map(String::valueOf).collect(Collectors.joining(","));
|
||||
menuDishesDTO.setMealId(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private NutritionEntity countNum(NutritionEntity nutritionEntity,Double weight) {
|
||||
private NutritionEntity countNum(NutritionEntity nutritionEntity, Double weight) {
|
||||
Field[] fields = nutritionEntity.getClass().getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
field.setAccessible(true);
|
||||
try {
|
||||
Double value = (Double) field.get(nutritionEntity);
|
||||
if(value !=null){
|
||||
System.err.println("先前值----:"+value);
|
||||
double proportion = Arith.div(weight , 100);
|
||||
if (value != null) {
|
||||
System.err.println("先前值----:" + value);
|
||||
double proportion = Arith.div(weight, 100);
|
||||
value = Arith.mul(value, proportion);
|
||||
field.set(nutritionEntity, value);
|
||||
System.err.println("后来值++++:"+value);
|
||||
}else{
|
||||
System.err.println("后来值++++:" + value);
|
||||
} else {
|
||||
field.set(nutritionEntity, 0.00);
|
||||
}
|
||||
|
||||
|
|
@ -403,16 +448,15 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
|
|||
}
|
||||
|
||||
|
||||
|
||||
//首字母转小写
|
||||
public static String toLowerCaseFirstOne(String s)
|
||||
{
|
||||
if(Character.isLowerCase(s.charAt(0))) {
|
||||
public static String toLowerCaseFirstOne(String s) {
|
||||
if (Character.isLowerCase(s.charAt(0))) {
|
||||
return s;
|
||||
} else {
|
||||
return (new StringBuilder()).append(Character.toLowerCase(s.charAt(0))).append(s.substring(1)).toString();
|
||||
}
|
||||
}
|
||||
|
||||
//首字母转大写
|
||||
public static String toUpperCaseFirstOne(String s) {
|
||||
if (Character.isUpperCase(s.charAt(0))) {
|
||||
|
|
@ -425,57 +469,57 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
|
|||
|
||||
@Override
|
||||
public MenuDishes check(MenuDishesDTO menuDishesDTO) {
|
||||
if(menuDishesDTO.getDishesId() == null){
|
||||
if (menuDishesDTO.getDishesId() == null) {
|
||||
throw new ServiceException("菜品ID不能为空");
|
||||
}
|
||||
MenuDishes menuDishesDTO1 = menuDishesMapper.getDishMessageByDishesId(menuDishesDTO.getDishesId());
|
||||
List<MenuDishesAddMaterialDTO> menuDishesAddMaterialDTO= menuDishesMapper.getMenuMaterialDishes(menuDishesDTO.getDishesId());
|
||||
if(menuDishesAddMaterialDTO !=null){
|
||||
List<MenuDishesAddMaterialDTO> menuDishesAddMaterialDTO = menuDishesMapper.getMenuMaterialDishes(menuDishesDTO.getDishesId());
|
||||
if (menuDishesAddMaterialDTO != null) {
|
||||
menuDishesDTO1.setMaterialList(menuDishesAddMaterialDTO);
|
||||
}
|
||||
List<Integer> mealList = new ArrayList<>();
|
||||
if (menuDishesDTO1.getLabelId() !=null && !menuDishesDTO1.getLabelId().isEmpty()){
|
||||
List<Integer> mealList = new ArrayList<>();
|
||||
if (menuDishesDTO1.getLabelId() != null && !menuDishesDTO1.getLabelId().isEmpty()) {
|
||||
List<Integer> list = Arrays.stream(menuDishesDTO1.getLabelId().split("\\s*,\\s*"))
|
||||
.map(Integer::parseInt)
|
||||
.collect(Collectors.toList());
|
||||
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*"))
|
||||
.map(Integer::parseInt)
|
||||
.collect(Collectors.toList());
|
||||
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*"))
|
||||
.map(Integer::parseInt)
|
||||
.collect(Collectors.toList());
|
||||
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*"))
|
||||
.map(Integer::parseInt)
|
||||
.collect(Collectors.toList());
|
||||
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*"))
|
||||
.map(Integer::parseInt)
|
||||
.collect(Collectors.toList());
|
||||
menuDishesDTO1.setMealList(list);
|
||||
}
|
||||
if(-1 == menuDishesDTO1.getCookId()){
|
||||
if (-1 == menuDishesDTO1.getCookId()) {
|
||||
menuDishesDTO1.setCookId(null);
|
||||
}
|
||||
if(menuDishesDTO1.getAreaId()== -1L){
|
||||
if (menuDishesDTO1.getAreaId() == -1L) {
|
||||
menuDishesDTO1.setAreaId(null);
|
||||
}
|
||||
if(menuDishesDTO1.getCanteenId() == -1L){
|
||||
if (menuDishesDTO1.getCanteenId() == -1L) {
|
||||
menuDishesDTO1.setCanteenId(null);
|
||||
}
|
||||
if(menuDishesDTO1.getShopstallId() == -1L){
|
||||
if (menuDishesDTO1.getShopstallId() == -1L) {
|
||||
menuDishesDTO1.setShopstallId(null);
|
||||
}
|
||||
return menuDishesDTO1;
|
||||
|
|
@ -488,7 +532,7 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
|
|||
try {
|
||||
menuDishesImportDTOS = EasyExcelUtil.readSingleExcel(excel, new MenuDishesImportDTO(), 1);
|
||||
} catch (Exception var42) {
|
||||
throw new ServiceException("导入新增菜品错误"+ var42.getMessage());
|
||||
throw new ServiceException("导入新增菜品错误" + var42.getMessage());
|
||||
}
|
||||
if (CollectionUtils.isEmpty(menuDishesImportDTOS)) {
|
||||
throw new ServiceException("导入新增菜品为空");
|
||||
|
|
@ -510,8 +554,8 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
|
|||
List<MenuDishesImportDTO> errorList = new ArrayList<>();
|
||||
Iterator var19 = menuDishesImportDTOS.iterator();
|
||||
|
||||
while(var19.hasNext()) {
|
||||
MenuDishesImportDTO data = (MenuDishesImportDTO)var19.next();
|
||||
while (var19.hasNext()) {
|
||||
MenuDishesImportDTO data = (MenuDishesImportDTO) var19.next();
|
||||
|
||||
try {
|
||||
BigDecimal price = data.getPrice();
|
||||
|
|
@ -566,7 +610,7 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
|
|||
String[] var33 = materialList;
|
||||
int var34 = materialList.length;
|
||||
|
||||
for(int var35 = 0; var35 < var34; ++var35) {
|
||||
for (int var35 = 0; var35 < var34; ++var35) {
|
||||
String material = var33[var35];
|
||||
String[] materialSplit = material.split("&");
|
||||
if (materialSplit.length != 3) {
|
||||
|
|
@ -711,7 +755,6 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
|
|||
}
|
||||
|
||||
|
||||
|
||||
public void importDishesDTO(List<MenuDishesImportDTO> importDishesList, String username) {
|
||||
DishesImportCheckResult dishesImportCheckResult = new DishesImportCheckResult();
|
||||
List<MenuDishesImportDTO> successList = new ArrayList<>();
|
||||
|
|
@ -726,8 +769,8 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
|
|||
List<MenuDishesSize> dishesSizeList = Lists.newArrayList();
|
||||
Iterator var11 = importDishesList.iterator();
|
||||
|
||||
while(var11.hasNext()) {
|
||||
MenuDishesImportDTO importDishes = (MenuDishesImportDTO)var11.next();
|
||||
while (var11.hasNext()) {
|
||||
MenuDishesImportDTO importDishes = (MenuDishesImportDTO) var11.next();
|
||||
|
||||
try {
|
||||
String sizeTypeStr;
|
||||
|
|
@ -784,7 +827,6 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
|
|||
}
|
||||
|
||||
|
||||
|
||||
if (CollUtil.isNotEmpty(dishesAddList)) {
|
||||
// MenuDishesMapper var10001 = this.menuDishesMapper;
|
||||
// Objects.requireNonNull(var10001);
|
||||
|
|
@ -826,16 +868,16 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
|
|||
// dishesAdd.setDishesNum(sequenceNo);
|
||||
dishesAdd.setPrice(importDishes.getPrice().multiply(new BigDecimal("100")).intValue());
|
||||
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.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.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);
|
||||
this.setAllocData(importDishes, dishesAdd, importDishesContext);
|
||||
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) {
|
||||
dishesAdd.setLargePrice(importDishes.getLargePrice().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;
|
||||
int var19 = menuMaterials.length;
|
||||
|
||||
for(int var20 = 0; var20 < var19; ++var20) {
|
||||
for (int var20 = 0; var20 < var19; ++var20) {
|
||||
String menuMaterial = var18[var20];
|
||||
String[] materialSplit = menuMaterial.split("&");
|
||||
String materialName = materialSplit[0];
|
||||
String materialType = materialSplit[1];
|
||||
String materialWeight = materialSplit[2];
|
||||
BigDecimal weight = new BigDecimal(materialWeight);
|
||||
Long materialId = (Long)materialMap.get(materialName);
|
||||
Long materialId = (Long) materialMap.get(materialName);
|
||||
MenuMaterialDishes menuMaterialDishes = new MenuMaterialDishes();
|
||||
menuMaterialDishes.setMaterialType(Integer.valueOf(materialType));
|
||||
menuMaterialDishes.setMaterialId(materialId);
|
||||
|
|
@ -903,8 +945,8 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
|
|||
List<NutritionEntity> result = new ArrayList<>();
|
||||
Iterator var7 = menuMaterialDishes.iterator();
|
||||
|
||||
while(var7.hasNext()) {
|
||||
MenuMaterialDishes menuMaterialDish = (MenuMaterialDishes)var7.next();
|
||||
while (var7.hasNext()) {
|
||||
MenuMaterialDishes menuMaterialDish = (MenuMaterialDishes) var7.next();
|
||||
MenuMaterialNutrition menuMaterialNutrition = data.get(menuMaterialDish.getMaterialId());
|
||||
if (ObjectUtils.isNotEmpty(menuMaterialNutrition)) {
|
||||
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) {
|
||||
List<MenuMaterialNutrition> menuMaterialNutritions = this.menuMaterialNutritionMapper
|
||||
.selectList(Wrappers.lambdaQuery(MenuMaterialNutrition.class)
|
||||
|
|
@ -968,13 +1009,11 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
|
|||
}
|
||||
|
||||
|
||||
|
||||
public MenuMaterial getByMaterialId(Long materialId) {
|
||||
return this.menuMaterialMapper.selectMenuMaterialMaterialId(materialId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setAllocData(MenuDishesImportDTO importDishes, MenuDishes dishesAdd, ImportDishesContext importDishesContext) {
|
||||
Long stallId = -1L;
|
||||
Long canteenId = -1L;
|
||||
|
|
@ -985,14 +1024,14 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
|
|||
Map<String, Long> canteenMap = importDishesContext.getCanteenMap();
|
||||
Map<String, AllocArea> allocAreaMap = importDishesContext.getAllocAreaMap();
|
||||
if (ObjectUtil.isNotEmpty(importDishes.getStallName())) {
|
||||
stallId = (Long)stallMap.get(importDishes.getStallName());
|
||||
canteenId = (Long)canteenStallMap.get(stallId);
|
||||
areaId = (Long)areaCanteenMap.get(canteenId);
|
||||
stallId = (Long) stallMap.get(importDishes.getStallName());
|
||||
canteenId = (Long) canteenStallMap.get(stallId);
|
||||
areaId = (Long) areaCanteenMap.get(canteenId);
|
||||
} else if (ObjectUtil.isNotEmpty(importDishes.getCanteenName())) {
|
||||
canteenId = (Long)canteenMap.get(importDishes.getCanteenName());
|
||||
areaId = (Long)areaCanteenMap.get(canteenId);
|
||||
canteenId = (Long) canteenMap.get(importDishes.getCanteenName());
|
||||
areaId = (Long) areaCanteenMap.get(canteenId);
|
||||
} else if (ObjectUtil.isNotEmpty(importDishes.getAreaName())) {
|
||||
areaId = ((AllocArea)allocAreaMap.get(importDishes.getAreaName())).getAreaId();
|
||||
areaId = ((AllocArea) allocAreaMap.get(importDishes.getAreaName())).getAreaId();
|
||||
}
|
||||
|
||||
dishesAdd.setCanteenId(canteenId);
|
||||
|
|
@ -1008,7 +1047,7 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
|
|||
String[] var6 = sizeTypeStrArr;
|
||||
int var7 = sizeTypeStrArr.length;
|
||||
|
||||
for(int var8 = 0; var8 < var7; ++var8) {
|
||||
for (int var8 = 0; var8 < var7; ++var8) {
|
||||
String sizeTypeStr = var6[var8];
|
||||
MenuDishesSize dishesSize = new MenuDishesSize();
|
||||
dishesSize.setBaseDishesId(baseDishesId);
|
||||
|
|
@ -1058,15 +1097,15 @@ public class MenuDishesServiceImpl extends ServiceImpl<MenuDishesMapper, MenuDis
|
|||
}
|
||||
});
|
||||
|
||||
List<MapBean> typeMapList = this.menuRecipeMapper.getMenuMaterialTypeMap();
|
||||
Map<String, Long> typeMap = new HashMap<>();
|
||||
List<MapBean> typeMapList = this.menuRecipeMapper.getMenuMaterialTypeMap();
|
||||
Map<String, Long> typeMap = new HashMap<>();
|
||||
typeMapList.forEach(map -> {
|
||||
typeMap.put(map.getKey(), toLong(map.getValue()));
|
||||
});
|
||||
|
||||
|
||||
List<MapBean> dishesCookMList = this.menuRecipeMapper.getDishesCookMap();
|
||||
Map<String, Long> dishesCookMap = new HashMap<>();
|
||||
Map<String, Long> dishesCookMap = new HashMap<>();
|
||||
dishesCookMList.forEach(map -> {
|
||||
dishesCookMap.put(map.getKey(), toLong(map.getValue()));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ public class MenuDishesTypeServiceImpl extends ServiceImpl<MenuDishesTypeMapper
|
|||
BeanUtil.copyProperties(content, dishesType, new String[0]);
|
||||
dishesType.setCreateBy(username);
|
||||
dishesType.setTypeId(Id.next());
|
||||
dishesType.setDelFlag(0);
|
||||
return this.baseMapper.insert(dishesType);
|
||||
}
|
||||
}
|
||||
|
|
@ -76,7 +77,10 @@ public class MenuDishesTypeServiceImpl extends ServiceImpl<MenuDishesTypeMapper
|
|||
|
||||
@Override
|
||||
public int delMenuDishesType(MenuDishesTypeEditDTO content) {
|
||||
|
||||
int code = menuDishesTypeMapper.checkIsExistRelation(content.getTypeId());
|
||||
if (code > 0){
|
||||
throw new ServiceException("该菜品类型下有数据,不能删除");
|
||||
}
|
||||
return menuDishesTypeMapper.delMenuDishesType(content);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -259,11 +259,19 @@ public class MenuMaterialCategoryServiceImpl extends ServiceImpl<MenuMaterialCat
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public int deleteMenuMaterialCategoryByIds(String[] ids) {
|
||||
try{
|
||||
for (String id : ids){
|
||||
//判断是否有关联
|
||||
int code = menuMaterialCategoryMapper.checkIsExistRelation(id);
|
||||
if(code > 0){
|
||||
throw new ServiceException("存在关联关系,无法删除!");
|
||||
}
|
||||
}
|
||||
menuMaterialCategoryMapper.deleteMenuMaterialCategoryByIds(ids);
|
||||
List<String> childCategoryIds = menuMaterialCategoryMapper.getChildCategoryIds(ids);
|
||||
if(childCategoryIds !=null && childCategoryIds.size() > 0){
|
||||
String[] idss = childCategoryIds.toArray(new String[childCategoryIds.size()]); // 避免数组扩容
|
||||
//递归删除
|
||||
|
||||
deleteMenuMaterialCategoryByIds(idss);
|
||||
}
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.bonus.canteen.core.menu.service.impl;
|
|||
import java.util.List;
|
||||
|
||||
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.toolkit.Wrappers;
|
||||
import com.bonus.canteen.core.menu.domain.MenuMaterialNutrition;
|
||||
|
|
@ -122,6 +123,9 @@ public class MenuMaterialServiceImpl implements IMenuMaterialService {
|
|||
// menuMaterialNutrition.setCategoryId(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);
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException(e.getMessage());
|
||||
|
|
@ -136,6 +140,16 @@ public class MenuMaterialServiceImpl implements IMenuMaterialService {
|
|||
*/
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -122,6 +122,13 @@ public class MenuNutritionServiceImpl implements IMenuNutritionService {
|
|||
*/
|
||||
@Override
|
||||
public int deleteMenuNutritionByIds(String[] ids) {
|
||||
for (String id : ids){
|
||||
// 判断是否关联了菜品
|
||||
int count = menuNutritionMapper.checkIsExistRelation(id);
|
||||
if(count > 0){
|
||||
throw new ServiceException("存在关联关系,无法删除!");
|
||||
}
|
||||
}
|
||||
return menuNutritionMapper.deleteMenuNutritionByIds(ids);
|
||||
}
|
||||
|
||||
|
|
@ -133,6 +140,11 @@ public class MenuNutritionServiceImpl implements IMenuNutritionService {
|
|||
*/
|
||||
@Override
|
||||
public int deleteMenuNutritionById(Long id) {
|
||||
// 判断是否关联了菜品
|
||||
int count = menuNutritionMapper.checkIsExistRelation(String.valueOf(id));
|
||||
if(count > 0){
|
||||
throw new ServiceException("存在关联关系,无法删除!");
|
||||
}
|
||||
return menuNutritionMapper.deleteMenuNutritionById(id);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,6 +115,14 @@ public class MenuNutritionTypeServiceImpl implements IMenuNutritionTypeService {
|
|||
if(ids == null || ids.length == 0){
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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">
|
||||
<include refid="selectMenuDishesVo"/>
|
||||
<where>
|
||||
b.del_flag = 0
|
||||
<if test="dishesId != null "> and b.dishes_id = #{dishesId}</if>
|
||||
<if test="baseDishesId != null "> and b.base_dishes_id = #{baseDishesId}</if>
|
||||
<if test="canteenId != null "> and b.canteen_id = #{canteenId}</if>
|
||||
|
|
@ -377,7 +378,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</select>
|
||||
|
||||
<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">
|
||||
#{item}
|
||||
</foreach>
|
||||
|
|
@ -581,9 +582,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
#{item}
|
||||
</foreach>
|
||||
</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 from menu_dishes where id in
|
||||
update menu_dishes set del_flag = '2' where id in
|
||||
<foreach collection="ids" separator="," open="(" close=")" item="item">
|
||||
#{item}
|
||||
</foreach>
|
||||
|
|
|
|||
|
|
@ -47,8 +47,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
order by du.id desc
|
||||
|
||||
</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>
|
||||
|
||||
|
|
|
|||
|
|
@ -131,6 +131,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<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>
|
||||
<select id="checkIsExistRelation" resultType="java.lang.Integer">
|
||||
SELECT count(1) from menu_material where category_id = #{id}
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -227,6 +227,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<include refid="selectMenuMaterialVo"/>
|
||||
where mm.material_id = #{id}
|
||||
</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>
|
||||
|
|
|
|||
|
|
@ -491,5 +491,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</if>
|
||||
limit 1
|
||||
</select>
|
||||
<select id="checkIsExistRelation" resultType="java.lang.Integer">
|
||||
select count(1)
|
||||
from menu_material
|
||||
where nutrition_type = #{id}
|
||||
</select>
|
||||
|
||||
</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 * from menu_nutrition_type where id = #{parentId} and del_flag = 2 limit 1
|
||||
</select>
|
||||
<select id="checkIsExistRelation" resultType="java.lang.Integer">
|
||||
select count(1) from menu_nutrition where category_id = #{id}
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue