菜谱管理

This commit is contained in:
sxu 2025-06-01 07:02:14 +08:00
parent 868b02929e
commit a23ba1664e
1 changed files with 8 additions and 8 deletions

View File

@ -118,14 +118,14 @@ public class CookRecipeServiceImpl implements ICookRecipeService {
Map<Integer, CookRecipeSortEnum> bindTypeMap = CookRecipeSortEnum.getKeyMap();
CookRecipeSortEnum sortEnum = bindTypeMap.get(content.getKey());
List<CookRecipeVO> records = new ArrayList<>();
if (ObjectUtil.isEmpty(sortEnum)) {
if (Objects.isNull(sortEnum)) {
throw new ServiceException("参数错误");
}else{
content.setDeviceTypeList(sortEnum.getDeviceType());
content.setBindType(sortEnum.getBindType());
content.setRecipeName(LeBeanUtil.fieldLikeHandle(content.getRecipeName()));
records = cookRecipeMapper.selectCookRecipeListV2(content);
if (ObjectUtil.isNotEmpty(records)) {
if (!CollectionUtils.isEmpty(records)) {
List<Long> recipeIds;
Map<Long ,Long> maping;
List<Long> stallIds = records.stream().map(CookRecipeVO::getStallId).collect(Collectors.toList());
@ -155,9 +155,9 @@ public class CookRecipeServiceImpl implements ICookRecipeService {
item.setRecipeDateList(Arrays.asList(cookRecipeDateVO));
item.setRecipeName(Optional.ofNullable(recipeMap.get(recipeId)).map(CookRecipe::getRecipeName).orElse(null));
count = 0L;
if (ObjectUtil.isNotEmpty(item.getRecipeDateDetail()) && ObjectUtil.isNotEmpty(item.getRecipeDateList().get(0).getDetailList())) {
if (Objects.nonNull(item.getRecipeDateDetail()) && !CollectionUtils.isEmpty(item.getRecipeDateList().get(0).getDetailList())) {
count = item.getRecipeDateList().get(0).getDetailList().stream().filter((x) -> {
return ObjectUtil.isNotEmpty(x.getDishesList());
return !CollectionUtils.isEmpty(x.getDishesList());
}).flatMap((x) -> {
return x.getDishesList().stream();
}).map(CookRecipeDishesVO::getDishesId).distinct().count();
@ -367,7 +367,7 @@ public class CookRecipeServiceImpl implements ICookRecipeService {
public void bindCookRecipe(CookRecipeBindDTO content) {
CookRecipe cookRecipe = this.cookRecipeMapper.selectCookRecipeByRecipeId(content.getRecipeId());
CookRecipeSortEnum sortEnum = CookRecipeSortEnum.getBindTypeMap().get(content.getBindType());
if (ObjectUtil.isEmpty(sortEnum)) {
if (Objects.isNull(sortEnum)) {
throw new ServiceException("菜谱绑定类型错误");
} else {
List<Integer> deviceIds = new ArrayList<>();
@ -396,19 +396,19 @@ public class CookRecipeServiceImpl implements ICookRecipeService {
throw new ServiceException("菜谱已被使用,请勿重复绑定");
}
List<Long> sourceRecipeList = this.cookRecipeMapper.selectRecipeInSameShop(cookRecipe.getStallId(), content.getBindType(), content.getMealLineId());
if (ObjectUtil.isNotEmpty(sourceRecipeList)) {
if (!CollectionUtils.isEmpty(sourceRecipeList)) {
appRecipe.setRecipeIds(sourceRecipeList);
this.cookRecipeMapper.deleteBind(appRecipe);
}
this.cookRecipeMapper.insertBind(appRecipe);
if (ObjectUtil.isNotEmpty(deviceIds)) {
if (!CollectionUtils.isEmpty(deviceIds)) {
this.cookRecipeMapper.updateRecipeByCanteenStallMeal(content.getRecipeId(), cookRecipe.getCanteenId(), cookRecipe.getStallId(), deviceIds);
}
MqUtil.sendDataChange(cookRecipe, LeMqConstant.DataChangeType.ADD, LeMqConstant.Topic.DATA_CHANGE_RECIPE_RELEASE);
} else {
appRecipe.setRecipeIds(Collections.singletonList(appRecipe.getRecipeId()));
this.cookRecipeMapper.deleteBind(appRecipe);
if (ObjectUtil.isNotEmpty(deviceIds)) {
if (!CollectionUtils.isEmpty(deviceIds)) {
this.cookRecipeMapper.updateRecipeByCanteenStallMeal(-1L, cookRecipe.getCanteenId(), cookRecipe.getStallId(), deviceIds);
}
}