This commit is contained in:
sxu 2025-05-29 09:08:57 +08:00
parent 0d11c63bf1
commit 9dcb1973ca
7 changed files with 278 additions and 8 deletions

View File

@ -2,6 +2,9 @@ package com.bonus.canteen.core.cook.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import com.bonus.canteen.core.cook.dto.CookRecipeBindDTO;
import com.bonus.canteen.core.cook.dto.CookRecipeDTO;
import com.bonus.canteen.core.cook.dto.CookRecipeDetailDTO;
import com.bonus.canteen.core.cook.vo.CookRecipeDetailVO;
@ -58,7 +61,7 @@ public class CookRecipeController extends BaseController {
@ApiOperation(value = "导出菜品计划信息列表")
//@PreventRepeatSubmit
//@RequiresPermissions("cook:recipe:export")
@SysLog(title = "菜品计划信息", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出菜品计划信息")
@SysLog(title = "菜品计划信息", businessType = OperaType.EXPORT, logType = 1,module = "菜谱管理->导出菜品计划信息")
@PostMapping("/export")
public void export(HttpServletResponse response, CookRecipe cookRecipe) {
List<CookRecipe> list = cookRecipeService.selectCookRecipeList(cookRecipe);
@ -97,7 +100,7 @@ public class CookRecipeController extends BaseController {
@ApiOperation(value = "新增菜品计划信息")
//@PreventRepeatSubmit
//@RequiresPermissions("cook:recipe:add")
@SysLog(title = "菜品计划信息", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增菜品计划信息")
@SysLog(title = "菜品计划信息", businessType = OperaType.INSERT, logType = 1,module = "菜谱管理->新增菜品计划信息")
@PostMapping
public AjaxResult add(@RequestBody CookRecipeDTO cookRecipeDTO) {
try {
@ -113,7 +116,7 @@ public class CookRecipeController extends BaseController {
@ApiOperation(value = "修改菜品计划信息")
//@PreventRepeatSubmit
//@RequiresPermissions("cook:recipe:edit")
@SysLog(title = "菜品计划信息", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->修改菜品计划信息")
@SysLog(title = "菜品计划信息", businessType = OperaType.UPDATE, logType = 1,module = "菜谱管理->修改菜品计划信息")
@PostMapping("/edit")
public AjaxResult edit(@RequestBody CookRecipeDTO cookRecipeDTO) {
try {
@ -123,13 +126,21 @@ public class CookRecipeController extends BaseController {
}
}
@ApiOperation(value = "菜谱绑定")
@SysLog(title = "菜谱绑定", businessType = OperaType.DELETE, logType = 1,module = "菜谱管理->菜谱绑定")
@PostMapping("/app/bind")
public AjaxResult bindAppRecipe(@RequestBody @Valid CookRecipeBindDTO dto) {
this.cookRecipeService.bindCookRecipe(dto);
return AjaxResult.success();
}
/**
* 删除菜品计划信息
*/
@ApiOperation(value = "删除菜品计划信息")
//@PreventRepeatSubmit
//@RequiresPermissions("cook:recipe:remove")
@SysLog(title = "菜品计划信息", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除菜品计划信息")
@SysLog(title = "菜品计划信息", businessType = OperaType.DELETE, logType = 1,module = "菜谱管理->删除菜品计划信息")
@PostMapping("/del/{recipeIds}")
public AjaxResult remove(@PathVariable Long[] recipeIds) {
return toAjax(cookRecipeService.deleteCookRecipeByRecipeIds(recipeIds));

View File

@ -0,0 +1,35 @@
package com.bonus.canteen.core.cook.domain;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.bonus.common.core.annotation.Excel;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import java.time.LocalDateTime;
import java.util.List;
@Data
@ToString
@TableName("cook_recipe_bind_app")
public class CookAppRecipe extends Model<CookAppRecipe> {
private static final long serialVersionUID = 1L;
private Long recipeId;
private Integer bindType;
private List<Long> recipeIds;
/** 绑定时间 */
@ApiModelProperty(value = "绑定时间")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "绑定时间", width = 30, dateFormat = "yyyy-MM-dd")
private LocalDateTime bindTime;
/** 餐线id */
@Excel(name = "餐线id")
@ApiModelProperty(value = "餐线id")
private Long mealLineId;
private LocalDateTime createTime;
private LocalDateTime updateTime;
}

View File

@ -0,0 +1,30 @@
package com.bonus.canteen.core.cook.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
@Data
public class CookRecipeBindDTO implements Serializable {
@ApiModelProperty("菜谱id")
private @NotNull(message = "菜谱id不能为空")
Long recipeId;
@ApiModelProperty("绑定类型(1-当餐点餐,2-预订餐,3-一周菜谱,4-扫码点餐,5-自助终端,6-自助餐线/小碗菜餐线,7-智慧餐台/消费机,8-点餐机/手持机/平板,9-信息发布屏,10-菜品识别)")
private @NotNull(message = "绑定类型不能为空")
Integer bindType;
@ApiModelProperty("操作类型(1-发布,2-解绑)")
private @NotNull(message = "操作类型不能为空")
Integer handleType;
@ApiModelProperty("餐线id")
private Long mealLineId;
@ApiModelProperty("档口id")
private Long stallId;
@ApiModelProperty("食堂id")
private Long canteenId;
}

View File

@ -0,0 +1,62 @@
package com.bonus.canteen.core.cook.enums;
public enum CookBindTypeEnum {
CURRENT(1, "当餐点餐"),
RESERVE(2, "预订餐"),
WEEK(3, "一周菜谱"),
QR_CODE(4, "扫码点餐"),
SELF_MACHINE(5, "自助终端"),
MEAL_LINE(6, "自助餐线/小碗菜餐线"),
TABLE(7, "智慧餐台/消费机"),
PAD(8, "点餐机/手持机/平板"),
SCREEN(9, "信息发布屏"),
DISHES_IDENTIFY(10, "菜品识别"),
NUTRITIONAL_PRICE_TAG(11, "营养价签");
private final Integer key;
private final String value;
private CookBindTypeEnum(Integer key, String value) {
this.key = key;
this.value = value;
}
public static Integer getKey(String value) {
CookBindTypeEnum[] enums = values();
CookBindTypeEnum[] var2 = enums;
int var3 = enums.length;
for(int var4 = 0; var4 < var3; ++var4) {
CookBindTypeEnum temp = var2[var4];
if (temp.value().equals(value)) {
return temp.key();
}
}
return null;
}
public static String getValue(Integer key) {
CookBindTypeEnum[] enums = values();
CookBindTypeEnum[] var2 = enums;
int var3 = enums.length;
for(int var4 = 0; var4 < var3; ++var4) {
CookBindTypeEnum temp = var2[var4];
if (temp.key().equals(key)) {
return temp.value();
}
}
return null;
}
public Integer key() {
return this.key;
}
public String value() {
return this.value;
}
}

View File

@ -0,0 +1,62 @@
package com.bonus.canteen.core.cook.enums;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
public enum CookRecipeSortEnum {
MEALLINE(1, "自助餐线/小碗菜餐线", CookBindTypeEnum.MEAL_LINE.key(), Arrays.asList(35, 32, 44, 30, 55, 58)),
TABLE(2, "智慧餐台/消费机", CookBindTypeEnum.TABLE.key(), Arrays.asList(20, 23, 41, 47, 21, 34)),
BUFFET(3, "点餐机/手持机/平板", CookBindTypeEnum.PAD.key(), Arrays.asList(41, 22, 36, 46, 63)),
ISSUE(4, "信息发布屏", CookBindTypeEnum.SCREEN.key(), Arrays.asList(40, 45)),
ANDROID_SELF_RECHARGE(5, "自助终端菜谱公示", CookBindTypeEnum.SELF_MACHINE.key(), Collections.singletonList(25)),
MOBILE_CURRENT(6, "移动端当餐点餐", CookBindTypeEnum.CURRENT.key(), new ArrayList()),
MOBILE_RESERVE(7, "移动端预订餐", CookBindTypeEnum.RESERVE.key(), new ArrayList()),
MOBILE_WEEK(8, "移动端一周菜谱", CookBindTypeEnum.WEEK.key(), new ArrayList()),
DISHES_IDENTIFY(9, "菜品识别", CookBindTypeEnum.DISHES_IDENTIFY.key(), Arrays.asList(50, 51)),
NUTRITIONAL_PRICE_TAG(10, "营养价签", CookBindTypeEnum.NUTRITIONAL_PRICE_TAG.key(), Collections.singletonList(57));
private final Integer key;
private final String name;
private final Integer bindType;
private final List<Integer> deviceType;
private CookRecipeSortEnum(Integer key, String name, Integer bindType, List deviceType) {
this.key = key;
this.name = name;
this.bindType = bindType;
this.deviceType = deviceType;
}
public static Map<Integer, CookRecipeSortEnum> getKeyMap() {
return Arrays.stream(values()).collect(Collectors.toMap(CookRecipeSortEnum::getKey, Function.identity()));
}
public static Map<Integer, CookRecipeSortEnum> getBindTypeMap() {
return Arrays.stream(values()).collect(Collectors.toMap(CookRecipeSortEnum::getBindType, Function.identity()));
}
public static CookRecipeSortEnum getByKey(Integer key) {
return (CookRecipeSortEnum)getKeyMap().get(key);
}
public Integer getKey() {
return this.key;
}
public String getName() {
return this.name;
}
public Integer getBindType() {
return this.bindType;
}
public List<Integer> getDeviceType() {
return this.deviceType;
}
public static List<Integer> getDeviceBindTypes() {
return Arrays.asList(MEALLINE.getBindType(), TABLE.getBindType(), BUFFET.getBindType(), ISSUE.getBindType(), ANDROID_SELF_RECHARGE.getBindType(), NUTRITIONAL_PRICE_TAG.getBindType());
}
}

View File

@ -2,6 +2,7 @@ package com.bonus.canteen.core.cook.service;
import java.util.List;
import com.bonus.canteen.core.cook.domain.CookRecipe;
import com.bonus.canteen.core.cook.dto.CookRecipeBindDTO;
import com.bonus.canteen.core.cook.dto.CookRecipeDTO;
import com.bonus.canteen.core.cook.dto.CookRecipeDetailDTO;
import com.bonus.canteen.core.cook.vo.CookRecipeDetailVO;
@ -49,6 +50,8 @@ public interface ICookRecipeService {
*/
public int updateCookRecipe(CookRecipeDTO cookRecipeDTO);
public void bindCookRecipe(CookRecipeBindDTO cookRecipeDTO);
/**
* 批量删除菜品计划信息
*

View File

@ -1,23 +1,28 @@
package com.bonus.canteen.core.cook.service.impl;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
import cn.hutool.core.util.ObjectUtil;
import com.bonus.canteen.core.common.utils.MqUtil;
import com.bonus.canteen.core.cook.domain.CookAppRecipe;
import com.bonus.canteen.core.cook.domain.CookRecipeDetail;
import com.bonus.canteen.core.cook.domain.CookRecipeDishes;
import com.bonus.canteen.core.cook.dto.CookRecipeDTO;
import com.bonus.canteen.core.cook.dto.CookRecipeDateDTO;
import com.bonus.canteen.core.cook.dto.CookRecipeDetailDTO;
import com.bonus.canteen.core.cook.dto.CookRecipeDishesDTO;
import com.bonus.canteen.core.cook.dto.*;
import com.bonus.canteen.core.cook.enums.CookRecipeSortEnum;
import com.bonus.canteen.core.cook.enums.CookBindTypeEnum;
import com.bonus.canteen.core.cook.enums.RecipeDetailTypeEnum;
import com.bonus.canteen.core.cook.enums.RecipeTypeEnum;
import com.bonus.canteen.core.cook.mapper.CookRecipeDetailMapper;
import com.bonus.canteen.core.cook.mapper.CookRecipeDishesMapper;
import com.bonus.canteen.core.cook.vo.CookRecipeDetailVO;
import com.bonus.canteen.core.user.domain.DeviceMqPersonalUpdateMessageDTO;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.houqin.constant.GlobalConstants;
import com.bonus.common.houqin.mq.constant.LeMqConstant;
import com.bonus.common.security.utils.SecurityUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -244,6 +249,68 @@ public class CookRecipeServiceImpl implements ICookRecipeService {
}
}
public void bindCookRecipe(CookRecipeBindDTO cookRecipeDTO) {
// CookRecipe menuRecipe = this.cookRecipeMapper.selectCookRecipeByRecipeId(cookRecipeDTO.getRecipeId());
// List<Integer> deviceInfoList = new ArrayList<>();
// if(cookRecipeDTO.getStallId() !=null){
// deviceInfoList = this.cookRecipeMapper.getDeviceIdByDevivce(null, String.valueOf(cookRecipeDTO.getStallId()));
// if(deviceInfoList == null || deviceInfoList.isEmpty() || deviceInfoList.size() == 0){
// throw new ServiceException("该食堂档口下没有设备信息");
// }
// }
// List<String> deviceSnList = this.cookRecipeMapper.getDeviceSnByIds(deviceInfoList);
// CookRecipeSortEnum sortEnum = CookRecipeSortEnum.getBindTypeMap().get(cookRecipeDTO.getBindType());
// CookAppRecipe mar = new CookAppRecipe();
// mar.setRecipeId(cookRecipeDTO.getRecipeId());
// mar.setMealLineId(cookRecipeDTO.getMealLineId());
// mar.setBindType(cookRecipeDTO.getBindType());
// List<Integer> deviceTypeList = cookRecipeMapper.getDeviceIdByDevivce(null, String.valueOf(menuRecipe.getStallId()));
// if (ObjectUtil.isEmpty(sortEnum)) {
// throw new ServiceException("bingType值异常");
// } else {
// List<Integer> deviceTypes = sortEnum.getDeviceType();
// if (cookRecipeDTO.getHandleType().equals(1)) {
// boolean exists;
// if (CookBindTypeEnum.RESERVE.key().equals(cookRecipeDTO.getBindType())) {
// exists = this.checkCanteenIfReserve(menuRecipe.getCanteenId(), menuRecipe.getStallId());
// if (!exists) {
// throw new ServiceException("不支持预订餐");
// }
// }
// exists = this.cookRecipeMapper.exists(mar);
// if (exists) {
// throw new ServiceException("菜谱已被使用,请勿重复绑定");
// }
// List<Long> sourceRecipeList = this.cookRecipeMapper.selectRecipeInSameShop(menuRecipe.getStallId(), null, cookRecipeDTO.getBindType(), content.getMealLineId());
// if (ObjectUtil.isNotEmpty(sourceRecipeList)) {
// mar.setRecipeIds(sourceRecipeList);
// this.cookRecipeMapper.delete(mar);
// }
// CookAppRecipe appRecipe = new CookAppRecipe();
// appRecipe.setRecipeId(cookRecipeDTO.getRecipeId());
// appRecipe.setBindType(cookRecipeDTO.getBindType());
// appRecipe.setMealLineId(cookRecipeDTO.getMealLineId());
// appRecipe.setBindTime(LocalDateTime.now());
// this.cookRecipeMapper.insert(appRecipe);
// if (ObjectUtil.isNotEmpty(deviceTypes) && deviceTypeList!= null && !deviceTypeList.isEmpty()) {
// this.cookRecipeMapper.updateRecipeByCanteeStallMeal(String.valueOf(cookRecipeDTO.getRecipeId()), String.valueOf(menuRecipe.getCanteenId()), String.valueOf(menuRecipe.getStallId()),deviceTypeList);
// }
// MqUtil.sendDataChange(menuRecipe, LeMqConstant.DataChangeType.ADD, LeMqConstant.Topic.DATA_CHANGE_RECIPE_RELEASE);
// } else {
// mar.setRecipeIds(Collections.singletonList(mar.getRecipeId()));
// this.cookRecipeMapper.delete(mar);
// if (ObjectUtil.isNotEmpty(deviceTypes) && deviceTypeList!= null && !deviceTypeList.isEmpty()) {
// this.cookRecipeMapper.updateRecipeByCanteeStallMeal("-1", String.valueOf(menuRecipe.getCanteenId()), String.valueOf(menuRecipe.getStallId()), deviceTypeList);
// }
// }
// //发送mq
// for (String deviceSn : deviceSnList){
// DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePerson(0,cookRecipeDTO.getHandleType().equals(1) ? "update" : "del");
// MqUtil.pushToSingleDevice(bean, LeMqConstant.Topic.DEVICE_UPDATE_MENU_CONFIG_V4, deviceSn);
// }
// }
}
/**
* 批量删除菜品计划信息
*