Merge branch 'master' into report

This commit is contained in:
gaowdong 2025-06-03 09:43:20 +08:00
commit 17b299bd75
18 changed files with 972 additions and 59 deletions

View File

@ -4,6 +4,7 @@ import java.util.List;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import cn.hutool.core.util.ObjectUtil;
import com.bonus.canteen.core.cook.dto.CookRecipeBindDTO;
import com.bonus.canteen.core.cook.dto.CookRecipeDTO;
import com.bonus.canteen.core.cook.dto.CookRecipeDetailDTO;
@ -14,12 +15,8 @@ import com.bonus.common.log.enums.OperaType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import com.bonus.common.log.annotation.SysLog;
import com.bonus.canteen.core.cook.domain.CookRecipe;
import com.bonus.canteen.core.cook.service.ICookRecipeService;
@ -27,6 +24,7 @@ import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.core.utils.poi.ExcelUtil;
import com.bonus.common.core.web.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;
/**
* 菜品计划信息Controller
@ -148,6 +146,23 @@ public class CookRecipeController extends BaseController {
return AjaxResult.success();
}
@PostMapping({"/recipe/import/dishes"})
@ApiOperation("批量导入菜谱中的菜品信息")
@Transactional
public AjaxResult recipeImportDishes(@RequestParam("file") MultipartFile excel, @RequestParam("recipeId") Long recipeId) {
try{
return ObjectUtil.isNull(excel) ? AjaxResult.error("请选择导入文件 ^_^") :
AjaxResult.success(this.cookRecipeService.recipeImportDishes(excel, recipeId));
}catch (Exception e){
String message = e.toString();
//取倒数第二个之后的信息
String finalMessage = message.substring(message.lastIndexOf(":") - 7);
String errorMes = finalMessage.replace("Error:", "");
System.err.println("errorMes="+errorMes);
return error("导入失败:"+errorMes);
}
}
/**
* 删除菜品计划信息
*/

View File

@ -1,7 +1,9 @@
package com.bonus.canteen.core.cook.domain;
import java.math.BigDecimal;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.bonus.canteen.core.common.utils.FileUrlUtil;
import com.bonus.common.core.annotation.Excel;
@ -367,6 +369,8 @@ public class CookDishes extends BaseEntity {
@ApiModelProperty(value = "菜品类型id集合")
private List<Long> typeIds;
private Set<String> dishesNames = new HashSet();
public String getImageUrl() {
return FileUrlUtil.getFileUrl(this.imageUrl);
}

View File

@ -0,0 +1,92 @@
package com.bonus.canteen.core.cook.dto;
import io.swagger.annotations.ApiModelProperty;
public class ImportRecipeDishesDTO {
private Integer index;
private String dishesName;
@ApiModelProperty("菜品单价")
private Integer price;
@ApiModelProperty("供应数量")
private Integer supplyNum;
@ApiModelProperty("销售数量")
private Integer saleNum;
@ApiModelProperty("剩余数量")
private Integer surplusNum;
@ApiModelProperty("个人限购数量")
private Integer restrictNum;
@ApiModelProperty("菜品价格(优惠价)")
private Integer salePrice;
public Integer getIndex() {
return this.index;
}
public String getDishesName() {
return this.dishesName;
}
public Integer getPrice() {
return this.price;
}
public Integer getSupplyNum() {
return this.supplyNum;
}
public Integer getSaleNum() {
return this.saleNum;
}
public Integer getSurplusNum() {
return this.surplusNum;
}
public Integer getRestrictNum() {
return this.restrictNum;
}
public Integer getSalePrice() {
return this.salePrice;
}
public ImportRecipeDishesDTO setIndex(final Integer index) {
this.index = index;
return this;
}
public ImportRecipeDishesDTO setDishesName(final String dishesName) {
this.dishesName = dishesName;
return this;
}
public ImportRecipeDishesDTO setPrice(final Integer price) {
this.price = price;
return this;
}
public ImportRecipeDishesDTO setSupplyNum(final Integer supplyNum) {
this.supplyNum = supplyNum;
return this;
}
public ImportRecipeDishesDTO setSaleNum(final Integer saleNum) {
this.saleNum = saleNum;
return this;
}
public ImportRecipeDishesDTO setSurplusNum(final Integer surplusNum) {
this.surplusNum = surplusNum;
return this;
}
public ImportRecipeDishesDTO setRestrictNum(final Integer restrictNum) {
this.restrictNum = restrictNum;
return this;
}
public ImportRecipeDishesDTO setSalePrice(final Integer salePrice) {
this.salePrice = salePrice;
return this;
}
}

View File

@ -2,6 +2,8 @@ package com.bonus.canteen.core.cook.mapper;
import java.time.LocalDate;
import java.util.List;
import java.util.Set;
import com.bonus.canteen.core.cook.domain.CookRecipeDetail;
import org.apache.ibatis.annotations.Param;
@ -73,4 +75,6 @@ public interface CookRecipeDetailMapper {
List<CookRecipeDetail> getCookRecipeDetailLTemplate(@Param("recipeId") Long recipeId, @Param("detailType") String detailType);
List<CookRecipeDetail> getByRecipeIdAndDatesAndIntervalId(@Param("recipeId") Long recipeId, @Param("dateList") Set<LocalDate> dateList, @Param("mealtimeType") Long mealtimeType);
}

View File

@ -70,7 +70,7 @@ public interface CookRecipeMapper {
*/
public int updateCookRecipe(CookRecipeDTO cookRecipeDTO);
List<Integer> getDeviceIdByDevivce(@Param("canteenId")String canteenId, @Param("stallId")String stallId);
List<Integer> getDeviceIdByDevice(@Param("canteenId")String canteenId, @Param("stallId")String stallId);
List<String> getDeviceSnByIds(@Param("list") List<Integer> deviceInfoList);
@ -82,7 +82,8 @@ public interface CookRecipeMapper {
int insertBind(CookAppRecipe appRecipe);
void updateRecipeByCanteenStallMeal(@Param("recipeId")String recipeId, @Param("canteenId")String canteenId, @Param("stallId")String stallId, @Param("deviceIds")List<Integer> deviceIds);
void updateRecipeByCanteenStallMeal(@Param("recipeId")Long recipeId, @Param("canteenId")Long canteenId,
@Param("stallId")Long stallId, @Param("deviceIds")List<Integer> deviceIds);
/**
* 删除菜品计划信息

View File

@ -1,12 +1,15 @@
package com.bonus.canteen.core.cook.service;
import java.util.List;
import java.util.Set;
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;
import com.bonus.canteen.core.cook.vo.CookRecipeVO;
import org.springframework.web.multipart.MultipartFile;
/**
* 菜品计划信息Service接口
@ -57,6 +60,8 @@ public interface ICookRecipeService {
public void bindCookRecipe(CookRecipeBindDTO cookRecipeDTO);
public Set<String> recipeImportDishes(MultipartFile excel, Long recipeId);
/**
* 批量删除菜品计划信息
*

View File

@ -9,19 +9,24 @@ import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelReader;
import com.alibaba.excel.read.metadata.ReadSheet;
import com.bonus.canteen.core.android.vo.CookMealtimeTypeEnum;
import com.bonus.canteen.core.common.utils.DateUtil;
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.*;
import com.bonus.canteen.core.cook.enums.CookBindTypeEnum;
import com.bonus.canteen.core.cook.enums.CookRecipeSortEnum;
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.utils.CookRecipeImportListener;
import com.bonus.canteen.core.cook.vo.*;
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;
@ -37,6 +42,7 @@ import com.bonus.canteen.core.cook.domain.CookRecipe;
import com.bonus.canteen.core.cook.service.ICookRecipeService;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;
/**
* 菜品计划信息Service业务层处理
@ -118,14 +124,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 +161,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();
@ -363,68 +369,99 @@ public class CookRecipeServiceImpl implements ICookRecipeService {
}
}
public void bindCookRecipe(CookRecipeBindDTO cookRecipeDTO) {
CookRecipe menuRecipe = this.cookRecipeMapper.selectCookRecipeByRecipeId(cookRecipeDTO.getRecipeId());
List<Integer> deviceInfoList = new ArrayList<>();
List<String> deviceSnList = 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("该食堂档口下没有设备信息");
}
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值异常");
@Transactional(rollbackFor = {Exception.class})
public void bindCookRecipe(CookRecipeBindDTO content) {
CookRecipe cookRecipe = this.cookRecipeMapper.selectCookRecipeByRecipeId(content.getRecipeId());
CookRecipeSortEnum sortEnum = CookRecipeSortEnum.getBindTypeMap().get(content.getBindType());
if (Objects.isNull(sortEnum)) {
throw new ServiceException("菜谱绑定类型错误");
} 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());
List<Integer> deviceIds = new ArrayList<>();
if (CookBindTypeEnum.TABLE.key().equals(content.getBindType())) { //TABLE(7, "智慧餐台/消费机")
if (content.getStallId() != null) {
deviceIds = this.cookRecipeMapper.getDeviceIdByDevice(null, String.valueOf(content.getStallId()));
if (deviceIds == null || deviceIds.isEmpty() || deviceIds.size() == 0) {
throw new ServiceException("该食堂档口下没有设备信息");
}
}
}
CookAppRecipe appRecipe = new CookAppRecipe();
appRecipe.setRecipeId(content.getRecipeId());
appRecipe.setMealLineId(content.getMealLineId());
appRecipe.setBindType(content.getBindType());
appRecipe.setBindTime(LocalDateTime.now());
if (content.getHandleType().equals(1)) {
// if (CookBindTypeEnum.RESERVE.key().equals(content.getBindType())) {
// exists = this.allocCanteenApi.checkCanteenIfReserve(cookRecipe.getCanteenId(), cookRecipe.getStallId());
// if (!exists) {
// throw new ServiceException("不支持预订餐");
// }
// }
exists = this.cookRecipeMapper.checkIfAlreadyBind(mar);
boolean exists = this.cookRecipeMapper.checkIfAlreadyBind(appRecipe);
if (exists) {
throw new ServiceException("菜谱已被使用,请勿重复绑定");
}
List<Long> sourceRecipeList = this.cookRecipeMapper.selectRecipeInSameShop(menuRecipe.getStallId(), cookRecipeDTO.getBindType(), cookRecipeDTO.getMealLineId());
if (ObjectUtil.isNotEmpty(sourceRecipeList)) {
mar.setRecipeIds(sourceRecipeList);
this.cookRecipeMapper.deleteBind(mar);
List<Long> sourceRecipeList = this.cookRecipeMapper.selectRecipeInSameShop(cookRecipe.getStallId(), content.getBindType(), content.getMealLineId());
if (!CollectionUtils.isEmpty(sourceRecipeList)) {
appRecipe.setRecipeIds(sourceRecipeList);
this.cookRecipeMapper.deleteBind(appRecipe);
}
CookAppRecipe appRecipe = new CookAppRecipe();
appRecipe.setRecipeId(cookRecipeDTO.getRecipeId());
appRecipe.setBindType(cookRecipeDTO.getBindType());
appRecipe.setMealLineId(cookRecipeDTO.getMealLineId());
appRecipe.setBindTime(LocalDateTime.now());
this.cookRecipeMapper.insertBind(appRecipe);
if (ObjectUtil.isNotEmpty(deviceTypes) && deviceTypeList!= null && !deviceTypeList.isEmpty()) {
this.cookRecipeMapper.updateRecipeByCanteenStallMeal(String.valueOf(cookRecipeDTO.getRecipeId()), String.valueOf(menuRecipe.getCanteenId()), String.valueOf(menuRecipe.getStallId()),deviceTypeList);
if (!CollectionUtils.isEmpty(deviceIds)) {
this.cookRecipeMapper.updateRecipeByCanteenStallMeal(content.getRecipeId(), cookRecipe.getCanteenId(), cookRecipe.getStallId(), deviceIds);
}
MqUtil.sendDataChange(menuRecipe, LeMqConstant.DataChangeType.ADD, LeMqConstant.Topic.DATA_CHANGE_RECIPE_RELEASE);
MqUtil.sendDataChange(cookRecipe, LeMqConstant.DataChangeType.ADD, LeMqConstant.Topic.DATA_CHANGE_RECIPE_RELEASE);
} else {
mar.setRecipeIds(Collections.singletonList(mar.getRecipeId()));
this.cookRecipeMapper.deleteBind(mar);
if (ObjectUtil.isNotEmpty(deviceTypes) && deviceTypeList!= null && !deviceTypeList.isEmpty()) {
this.cookRecipeMapper.updateRecipeByCanteenStallMeal("-1", String.valueOf(menuRecipe.getCanteenId()), String.valueOf(menuRecipe.getStallId()), deviceTypeList);
appRecipe.setRecipeIds(Collections.singletonList(appRecipe.getRecipeId()));
this.cookRecipeMapper.deleteBind(appRecipe);
if (!CollectionUtils.isEmpty(deviceIds)) {
this.cookRecipeMapper.updateRecipeByCanteenStallMeal(-1L, cookRecipe.getCanteenId(), cookRecipe.getStallId(), deviceIds);
}
}
//发送mq
if (!CollectionUtils.isEmpty(deviceSnList)) {
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);
// if (CookBindTypeEnum.TABLE.key().equals(content.getBindType())) { //TABLE(7, "智慧餐台/消费机")
// List<String> deviceSnList = this.cookRecipeMapper.getDeviceSnByIds(deviceInfoList);
// for (String deviceSn : deviceSnList) {
// DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePerson(0, content.getHandleType().equals(1) ? "update" : "del");
// MqUtil.pushToSingleDevice(bean, LeMqConstant.Topic.DEVICE_UPDATE_MENU_CONFIG_V4, deviceSn);
// }
// }
}
}
@Override
public Set<String> recipeImportDishes(MultipartFile excel, Long recipeId) {
ExcelReader excelReader = null;
try {
Set<String> notImportDishesNames = new HashSet();
List<CookRecipeImportListener> listeners = new ArrayList();
excelReader = EasyExcel.read(excel.getInputStream()).build();
List<ReadSheet> readSheets = excelReader.excelExecutor().sheetList();
for (ReadSheet readSheet : readSheets) {
String sheetName = readSheet.getSheetName();
Integer mealtimeType = CookMealtimeTypeEnum.getKeyByDesc(sheetName);
if (!Objects.isNull(mealtimeType)) {
CookRecipeImportListener cookRecipeImportListener = new CookRecipeImportListener(sheetName, recipeId, mealtimeType.longValue());
listeners.add(cookRecipeImportListener);
readSheet.getCustomReadListenerList().add(cookRecipeImportListener);
}
}
excelReader.read(readSheets);
notImportDishesNames.addAll(
listeners.stream()
.flatMap(listener -> listener.getNotImportDishesNames().stream())
.collect(Collectors.toList())
);
return notImportDishesNames;
}catch (Exception e) {
throw new ServiceException(e.toString());
} finally {
if (excelReader != null) {
excelReader.finish();
}
}
}

View File

@ -0,0 +1,188 @@
package com.bonus.canteen.core.cook.utils;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.bonus.canteen.core.common.utils.SpringContextHolder;
import com.bonus.canteen.core.cook.domain.CookDishes;
import com.bonus.canteen.core.cook.domain.CookRecipeDetail;
import com.bonus.canteen.core.cook.domain.CookRecipeDishes;
import com.bonus.canteen.core.cook.dto.ImportRecipeDishesDTO;
import com.bonus.canteen.core.cook.mapper.CookDishesMapper;
import com.bonus.canteen.core.cook.mapper.CookRecipeDetailMapper;
import com.bonus.canteen.core.cook.mapper.CookRecipeDishesMapper;
import com.bonus.common.core.exception.ServiceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;
public class CookRecipeImportListener extends AnalysisEventListener<Map<Integer, String>> {
private static final Logger log = LoggerFactory.getLogger(CookRecipeImportListener.class);
private final String sheetName;
private final Long recipeId;
private final Long mealtimeType;
private final Map<Integer, LocalDate> dateMap = new HashMap();
private final Set<String> dishesNames = new HashSet();
private final Set<String> notImportDishesNames = new HashSet();
private final Map<LocalDate, List<ImportRecipeDishesDTO>> datas = new HashMap();
private final BigDecimal decimal = new BigDecimal(100);
public Set<String> getNotImportDishesNames() {
return this.notImportDishesNames;
}
public CookRecipeImportListener(String sheetName, Long recipeId, Long mealtimeType) {
this.sheetName = sheetName;
this.recipeId = recipeId;
this.mealtimeType = mealtimeType;
}
@Override
public void invoke(Map<Integer, String> integerStringMap, AnalysisContext analysisContext) {
Integer rowIndex = analysisContext.readRowHolder().getRowIndex();
String no;
if (rowIndex == 1) {
no = (String)integerStringMap.get(1);
log.info("餐次名称:{}", no);
}
if (rowIndex == 2) {
for(int i = 1; i < integerStringMap.size(); i += 3) {
String date = (String)integerStringMap.get(i);
if (date != null && !date.isEmpty()) {
Date parse = DateUtil.parse(date);
String format = DateUtil.format(parse, "yyyy/MM/dd");
String[] split = format.split("/");
LocalDate localDate = LocalDate.of(Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2]));
this.dateMap.put(i, localDate);
}
}
log.info("导入的日期:{}", this.dateMap.values());
}
if (rowIndex > 2) {
try {
no = (String)integerStringMap.get(0);
if (no != null && !no.isEmpty()) {
for(int i = 1; i < integerStringMap.size(); i += 3) {
String dishesName = (String)integerStringMap.get(i);
if (!ObjectUtil.isEmpty(dishesName)) {
ImportRecipeDishesDTO importRecipeDishesDto = new ImportRecipeDishesDTO();
this.dishesNames.add(dishesName);
BigDecimal price = (new BigDecimal((String)integerStringMap.get(i + 1))).multiply(this.decimal);
BigDecimal salePrice = (new BigDecimal((String)integerStringMap.get(i + 2))).multiply(this.decimal);
importRecipeDishesDto.setSurplusNum(9999).setIndex(i).setDishesName(dishesName).setSaleNum(0).setSupplyNum(9999).setRestrictNum(9999).setPrice(price.intValue()).setSalePrice(salePrice.intValue());
if (this.datas.containsKey(this.dateMap.get(i))) {
((List)this.datas.get(this.dateMap.get(i))).add(importRecipeDishesDto);
} else {
List<ImportRecipeDishesDTO> list = new ArrayList();
list.add(importRecipeDishesDto);
this.datas.put((LocalDate)this.dateMap.get(i), list);
}
}
}
}
} catch (Exception var11) {
log.info("解析excel失败DATA:{}", integerStringMap);
}
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
try {
HashSet<LocalDate> dates = new HashSet(this.dateMap.values());
if (!dates.isEmpty()) {
//ICookRecipeDetailService menuRecipeDetailService = SpringContextHolder.getBean(ICookRecipeDetailService.class);
CookRecipeDetailMapper cookRecipeDetailMapper = SpringContextHolder.getBean(CookRecipeDetailMapper.class);
CookRecipeDishesMapper cookRecipeDishesMapper = SpringContextHolder.getBean(CookRecipeDishesMapper.class);
//List<CookRecipeDetail> byRecipeIdAndDates = menuRecipeDetailService.getByRecipeIdAndDatesAndIntervalId(this.recipeId, dates, this.mealtimeType);
List<CookRecipeDetail> byRecipeIdAndDates = cookRecipeDetailMapper.getByRecipeIdAndDatesAndIntervalId(this.recipeId, dates, this.mealtimeType);
Map<LocalDate, CookRecipeDetail> dateDetailMap = byRecipeIdAndDates.stream().collect(Collectors.groupingBy(CookRecipeDetail::getApplyDate, Collectors.collectingAndThen(Collectors.toList(), (list) -> {
return list.get(0);
})));
if (!this.dishesNames.isEmpty()) {
//ICookDishesService menuDishesService = SpringContextHolder.getBean(ICookDishesService.class);
//List<CookDishes> menuDishesList = menuDishesService.getByNames(this.dishesNames);
CookDishesMapper cookDishesMapper = SpringContextHolder.getBean(CookDishesMapper.class);
CookDishes cookDishes = new CookDishes();
cookDishes.setDishesNames(this.dishesNames);
List<CookDishes> cookDishesList = cookDishesMapper.selectCookDishesList(cookDishes);
Set<String> difference = DifferenceCalculator.calculateDifference(this.dishesNames, cookDishesList);
System.out.println("差集结果: " + difference);
if (difference != null && difference.size() > 0) {
throw new ServiceException("以下菜品不存在:" + difference);
}
Map<String, CookDishes> nameMap = cookDishesList.stream().collect(Collectors.groupingBy(CookDishes::getDishesName, Collectors.collectingAndThen(Collectors.toList(), (list) -> {
return list.get(0);
})));
//ICookRecipeDishesService menuRecipeDishesService = SpringContextHolder.getBean(ICookRecipeDishesService.class);
List<CookRecipeDishes> inserData = new ArrayList<>();
for (LocalDate date : dates) {
CookRecipeDetail cookRecipeDetail = dateDetailMap.get(date);
if (cookRecipeDetail == null) {
cookRecipeDetail = new CookRecipeDetail();
cookRecipeDetail.setRecipeId(this.recipeId);
cookRecipeDetail.setApplyDate(date);
cookRecipeDetail.setMealtimeType(this.mealtimeType);
//menuRecipeDetail.setDetailId(Id.next());
//menuRecipeDetailService.save(menuRecipeDetail);
cookRecipeDetailMapper.insertCookRecipeDetail(cookRecipeDetail);
} else {
//menuRecipeDishesService.deleteByDetailId(menuRecipeDetail.getDetailId());
Long[] recipeDetailIds = {cookRecipeDetail.getRecipeDetailId()};
cookRecipeDishesMapper.deleteCookRecipeDishesByCookRecipeDetailIds(recipeDetailIds);
}
List<ImportRecipeDishesDTO> importRecipeDishesDtos = this.datas.get(date);
CookRecipeDetail finalCookRecipeDetail = cookRecipeDetail;
List<CookRecipeDishes> saveDatas = importRecipeDishesDtos.stream().filter(distinctByKey(ImportRecipeDishesDTO::getDishesName)).map((importRecipeDishesDto) -> {
CookRecipeDishes cookRecipeDishes = null;
CookDishes cookDishesValue = nameMap.get(importRecipeDishesDto.getDishesName());
if (cookDishesValue != null) {
cookRecipeDishes = BeanUtil.copyProperties(importRecipeDishesDto, CookRecipeDishes.class, new String[0]);
cookRecipeDishes.setRecipeDetailId(finalCookRecipeDetail.getRecipeDetailId());
cookRecipeDishes.setSizeType(cookDishesValue.getSizeType());
cookRecipeDishes.setDishesId(cookDishesValue.getDishesId());
} else {
this.notImportDishesNames.add(importRecipeDishesDto.getDishesName());
}
return cookRecipeDishes;
}).filter(Objects::nonNull).collect(Collectors.toList());
inserData.addAll(saveDatas);
}
//menuRecipeDishesService.saveBatch(inserData);
for (CookRecipeDishes cookRecipeDishes : inserData) {
cookRecipeDishesMapper.insertCookRecipeDishes(cookRecipeDishes);
}
}
}
}catch (Exception e){
throw new ServiceException(e.getMessage());
}
}
static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {
Map<Object, Boolean> seen = new ConcurrentHashMap<>();
return (t) -> {
return seen.putIfAbsent(keyExtractor.apply(t), Boolean.TRUE) == null;
};
}
}

View File

@ -0,0 +1,22 @@
package com.bonus.canteen.core.cook.utils;
import com.bonus.canteen.core.cook.domain.CookDishes;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
public class DifferenceCalculator {
public static Set<String> calculateDifference(Set<String> stringSet, List<CookDishes> menuDishesList) {
// 从menuDishesList中提取所有dishesName的集合
Set<String> menuDishesNames = menuDishesList.stream()
.map(CookDishes::getDishesName)
.collect(Collectors.toSet());
// 计算差集stringSet中有而menuDishesNames中没有的元素
Set<String> difference = new HashSet<>(stringSet);
difference.removeAll(menuDishesNames);
return difference;
}
}

View File

@ -0,0 +1,119 @@
package com.bonus.canteen.core.supermarket.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.bonus.common.log.enums.OperaType;
//import com.bonus.canteen.core.supermarket.common.annotation.PreventRepeatSubmit;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bonus.common.log.annotation.SysLog;
import com.bonus.common.security.annotation.RequiresPermissions;
import com.bonus.canteen.core.supermarket.domain.SupermarketProduct;
import com.bonus.canteen.core.supermarket.service.ISupermarketProductService;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.core.utils.poi.ExcelUtil;
import com.bonus.common.core.web.page.TableDataInfo;
/**
* 超市商城商品Controller
*
* @author xsheng
* @date 2025-06-03
*/
@Api(tags = "超市商城商品接口")
@RestController
@RequestMapping("/supermarket_product")
public class SupermarketProductController extends BaseController {
@Autowired
private ISupermarketProductService supermarketProductService;
/**
* 查询超市商城商品列表
*/
@ApiOperation(value = "查询超市商城商品列表")
//@RequiresPermissions("supermarket:product:list")
@GetMapping("/list")
public TableDataInfo list(SupermarketProduct supermarketProduct) {
startPage();
List<SupermarketProduct> list = supermarketProductService.selectSupermarketProductList(supermarketProduct);
return getDataTable(list);
}
/**
* 导出超市商城商品列表
*/
@ApiOperation(value = "导出超市商城商品列表")
//@PreventRepeatSubmit
//@RequiresPermissions("supermarket:product:export")
@SysLog(title = "超市商城商品", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出超市商城商品")
@PostMapping("/export")
public void export(HttpServletResponse response, SupermarketProduct supermarketProduct) {
List<SupermarketProduct> list = supermarketProductService.selectSupermarketProductList(supermarketProduct);
ExcelUtil<SupermarketProduct> util = new ExcelUtil<SupermarketProduct>(SupermarketProduct.class);
util.exportExcel(response, list, "超市商城商品数据");
}
/**
* 获取超市商城商品详细信息
*/
@ApiOperation(value = "获取超市商城商品详细信息")
//@RequiresPermissions("supermarket:product:query")
@GetMapping(value = "/{productId}")
public AjaxResult getInfo(@PathVariable("productId") Long productId) {
return success(supermarketProductService.selectSupermarketProductByProductId(productId));
}
/**
* 新增超市商城商品
*/
@ApiOperation(value = "新增超市商城商品")
//@PreventRepeatSubmit
//@RequiresPermissions("supermarket:product:add")
@SysLog(title = "超市商城商品", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增超市商城商品")
@PostMapping
public AjaxResult add(@RequestBody SupermarketProduct supermarketProduct) {
try {
return toAjax(supermarketProductService.insertSupermarketProduct(supermarketProduct));
} catch (Exception e) {
return error(e.getMessage());
}
}
/**
* 修改超市商城商品
*/
@ApiOperation(value = "修改超市商城商品")
//@PreventRepeatSubmit
//@RequiresPermissions("supermarket:product:edit")
@SysLog(title = "超市商城商品", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->修改超市商城商品")
@PostMapping("/edit")
public AjaxResult edit(@RequestBody SupermarketProduct supermarketProduct) {
try {
return toAjax(supermarketProductService.updateSupermarketProduct(supermarketProduct));
} catch (Exception e) {
return error(e.getMessage());
}
}
/**
* 删除超市商城商品
*/
@ApiOperation(value = "删除超市商城商品")
//@PreventRepeatSubmit
//@RequiresPermissions("supermarket:product:remove")
@SysLog(title = "超市商城商品", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除超市商城商品")
@PostMapping("/del/{productIds}")
public AjaxResult remove(@PathVariable Long[] productIds) {
return toAjax(supermarketProductService.deleteSupermarketProductByProductIds(productIds));
}
}

View File

@ -0,0 +1,77 @@
package com.bonus.canteen.core.supermarket.domain;
import java.math.BigDecimal;
import com.bonus.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import com.bonus.common.core.web.domain.BaseEntity;
/**
* 超市商城商品对象 supermarket_product
*
* @author xsheng
* @date 2025-06-03
*/
@Data
@ToString
public class SupermarketProduct extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 商城商品明细id */
private Long productId;
/** 超市id */
@Excel(name = "超市id")
@ApiModelProperty(value = "超市id")
private Long supermarketId;
/** 商品id */
@Excel(name = "商品id")
@ApiModelProperty(value = "商品id")
private Long materialId;
/** 上架状态(1-上架,2-下架) */
@Excel(name = "上架状态(1-上架,2-下架)")
@ApiModelProperty(value = "上架状态(1-上架,2-下架)")
private Long putawayState;
/** 是否线上销售(1是2否) */
@Excel(name = "是否线上销售(1是2否)")
@ApiModelProperty(value = "是否线上销售(1是2否)")
private Long ifOnline;
/** 销售价 */
@Excel(name = "销售价")
@ApiModelProperty(value = "销售价")
private Long salePrice;
/** 优惠价 */
@Excel(name = "优惠价")
@ApiModelProperty(value = "优惠价")
private Long prefPrice;
/** 个人限购数量 */
@Excel(name = "个人限购数量")
@ApiModelProperty(value = "个人限购数量")
private Long personLimit;
/** 每日限购数量 */
@Excel(name = "每日限购数量")
@ApiModelProperty(value = "每日限购数量")
private Long oneDayLimit;
/** 图片 */
@Excel(name = "图片")
@ApiModelProperty(value = "图片")
private String imgUrl;
/** 库存数 */
@Excel(name = "库存数")
@ApiModelProperty(value = "库存数")
private BigDecimal inventoryNum;
}

View File

@ -0,0 +1,60 @@
package com.bonus.canteen.core.supermarket.mapper;
import java.util.List;
import com.bonus.canteen.core.supermarket.domain.SupermarketProduct;
/**
* 超市商城商品Mapper接口
*
* @author xsheng
* @date 2025-06-03
*/
public interface SupermarketProductMapper {
/**
* 查询超市商城商品
*
* @param productId 超市商城商品主键
* @return 超市商城商品
*/
public SupermarketProduct selectSupermarketProductByProductId(Long productId);
/**
* 查询超市商城商品列表
*
* @param supermarketProduct 超市商城商品
* @return 超市商城商品集合
*/
public List<SupermarketProduct> selectSupermarketProductList(SupermarketProduct supermarketProduct);
/**
* 新增超市商城商品
*
* @param supermarketProduct 超市商城商品
* @return 结果
*/
public int insertSupermarketProduct(SupermarketProduct supermarketProduct);
/**
* 修改超市商城商品
*
* @param supermarketProduct 超市商城商品
* @return 结果
*/
public int updateSupermarketProduct(SupermarketProduct supermarketProduct);
/**
* 删除超市商城商品
*
* @param productId 超市商城商品主键
* @return 结果
*/
public int deleteSupermarketProductByProductId(Long productId);
/**
* 批量删除超市商城商品
*
* @param productIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteSupermarketProductByProductIds(Long[] productIds);
}

View File

@ -0,0 +1,60 @@
package com.bonus.canteen.core.supermarket.service;
import java.util.List;
import com.bonus.canteen.core.supermarket.domain.SupermarketProduct;
/**
* 超市商城商品Service接口
*
* @author xsheng
* @date 2025-06-03
*/
public interface ISupermarketProductService {
/**
* 查询超市商城商品
*
* @param productId 超市商城商品主键
* @return 超市商城商品
*/
public SupermarketProduct selectSupermarketProductByProductId(Long productId);
/**
* 查询超市商城商品列表
*
* @param supermarketProduct 超市商城商品
* @return 超市商城商品集合
*/
public List<SupermarketProduct> selectSupermarketProductList(SupermarketProduct supermarketProduct);
/**
* 新增超市商城商品
*
* @param supermarketProduct 超市商城商品
* @return 结果
*/
public int insertSupermarketProduct(SupermarketProduct supermarketProduct);
/**
* 修改超市商城商品
*
* @param supermarketProduct 超市商城商品
* @return 结果
*/
public int updateSupermarketProduct(SupermarketProduct supermarketProduct);
/**
* 批量删除超市商城商品
*
* @param productIds 需要删除的超市商城商品主键集合
* @return 结果
*/
public int deleteSupermarketProductByProductIds(Long[] productIds);
/**
* 删除超市商城商品信息
*
* @param productId 超市商城商品主键
* @return 结果
*/
public int deleteSupermarketProductByProductId(Long productId);
}

View File

@ -0,0 +1,98 @@
package com.bonus.canteen.core.supermarket.service.impl;
import java.util.List;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bonus.canteen.core.supermarket.mapper.SupermarketProductMapper;
import com.bonus.canteen.core.supermarket.domain.SupermarketProduct;
import com.bonus.canteen.core.supermarket.service.ISupermarketProductService;
/**
* 超市商城商品Service业务层处理
*
* @author xsheng
* @date 2025-06-03
*/
@Service
public class SupermarketProductServiceImpl implements ISupermarketProductService {
@Autowired
private SupermarketProductMapper supermarketProductMapper;
/**
* 查询超市商城商品
*
* @param productId 超市商城商品主键
* @return 超市商城商品
*/
@Override
public SupermarketProduct selectSupermarketProductByProductId(Long productId) {
return supermarketProductMapper.selectSupermarketProductByProductId(productId);
}
/**
* 查询超市商城商品列表
*
* @param supermarketProduct 超市商城商品
* @return 超市商城商品
*/
@Override
public List<SupermarketProduct> selectSupermarketProductList(SupermarketProduct supermarketProduct) {
return supermarketProductMapper.selectSupermarketProductList(supermarketProduct);
}
/**
* 新增超市商城商品
*
* @param supermarketProduct 超市商城商品
* @return 结果
*/
@Override
public int insertSupermarketProduct(SupermarketProduct supermarketProduct) {
supermarketProduct.setCreateTime(DateUtils.getNowDate());
try {
return supermarketProductMapper.insertSupermarketProduct(supermarketProduct);
} catch (Exception e) {
throw new ServiceException(e.getMessage());
}
}
/**
* 修改超市商城商品
*
* @param supermarketProduct 超市商城商品
* @return 结果
*/
@Override
public int updateSupermarketProduct(SupermarketProduct supermarketProduct) {
supermarketProduct.setUpdateTime(DateUtils.getNowDate());
try {
return supermarketProductMapper.updateSupermarketProduct(supermarketProduct);
} catch (Exception e) {
throw new ServiceException(e.getMessage());
}
}
/**
* 批量删除超市商城商品
*
* @param productIds 需要删除的超市商城商品主键
* @return 结果
*/
@Override
public int deleteSupermarketProductByProductIds(Long[] productIds) {
return supermarketProductMapper.deleteSupermarketProductByProductIds(productIds);
}
/**
* 删除超市商城商品信息
*
* @param productId 超市商城商品主键
* @return 结果
*/
@Override
public int deleteSupermarketProductByProductId(Long productId) {
return supermarketProductMapper.deleteSupermarketProductByProductId(productId);
}
}

View File

@ -105,6 +105,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{typeId}
</foreach>
</if>
<if test="dishesNames != null and dishesNames.size() > 0">
<foreach item="dishesName" collection="dishesNames" open="(" separator="," close=")">
#{dishesName}
</foreach>
</if>
<if test="mealType != null "> and cd.meal_type = #{mealType}</if>
<if test="customId != null "> and cd.custom_id = #{customId}</if>
<if test="inventoryId != null and inventoryId != ''"> and cd.inventory_id = #{inventoryId}</if>

View File

@ -157,4 +157,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and detail_type = #{detailType}
group by mealtime_type
</select>
<select id="getByRecipeIdAndDatesAndIntervalId" resultMap="CookRecipeDetailResult">
select * from cook_recipe_detail
where recipe_id = #{recipeId}
and mealtime_type = #{mealtimeType}
and apply_date in
<foreach item="applyDate" collection="dateList" open="(" separator="," close=")">
#{applyDate}
</foreach>
</select>
</mapper>

View File

@ -294,7 +294,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where recipe_id = #{recipeId}
</update>
<select id="getDeviceIdByDevivce" parameterType="string" resultType="integer">
<select id="getDeviceIdByDevice" parameterType="string" resultType="integer">
select a.device_id
from device_info a
LEFT JOIN cook_recipe_bind_device b on a.device_id = b.device_id

View File

@ -0,0 +1,116 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.canteen.core.supermarket.mapper.SupermarketProductMapper">
<resultMap type="com.bonus.canteen.core.supermarket.domain.SupermarketProduct" id="SupermarketProductResult">
<result property="productId" column="product_id" />
<result property="supermarketId" column="supermarket_id" />
<result property="materialId" column="material_id" />
<result property="putawayState" column="putaway_state" />
<result property="ifOnline" column="if_online" />
<result property="salePrice" column="sale_price" />
<result property="prefPrice" column="pref_price" />
<result property="personLimit" column="person_limit" />
<result property="oneDayLimit" column="one_day_limit" />
<result property="imgUrl" column="img_url" />
<result property="inventoryNum" column="inventory_num" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectSupermarketProductVo">
select product_id, supermarket_id, material_id, putaway_state, if_online, sale_price, pref_price, person_limit, one_day_limit, img_url, inventory_num, create_by, create_time, update_by, update_time from supermarket_product
</sql>
<select id="selectSupermarketProductList" parameterType="com.bonus.canteen.core.supermarket.domain.SupermarketProduct" resultMap="SupermarketProductResult">
<include refid="selectSupermarketProductVo"/>
<where>
<if test="supermarketId != null "> and supermarket_id = #{supermarketId}</if>
<if test="materialId != null "> and material_id = #{materialId}</if>
<if test="putawayState != null "> and putaway_state = #{putawayState}</if>
<if test="ifOnline != null "> and if_online = #{ifOnline}</if>
<if test="salePrice != null "> and sale_price = #{salePrice}</if>
<if test="prefPrice != null "> and pref_price = #{prefPrice}</if>
<if test="personLimit != null "> and person_limit = #{personLimit}</if>
<if test="oneDayLimit != null "> and one_day_limit = #{oneDayLimit}</if>
<if test="imgUrl != null and imgUrl != ''"> and img_url = #{imgUrl}</if>
<if test="inventoryNum != null "> and inventory_num = #{inventoryNum}</if>
</where>
</select>
<select id="selectSupermarketProductByProductId" parameterType="Long" resultMap="SupermarketProductResult">
<include refid="selectSupermarketProductVo"/>
where product_id = #{productId}
</select>
<insert id="insertSupermarketProduct" parameterType="com.bonus.canteen.core.supermarket.domain.SupermarketProduct" useGeneratedKeys="true" keyProperty="productId">
insert into supermarket_product
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="supermarketId != null">supermarket_id,</if>
<if test="materialId != null">material_id,</if>
<if test="putawayState != null">putaway_state,</if>
<if test="ifOnline != null">if_online,</if>
<if test="salePrice != null">sale_price,</if>
<if test="prefPrice != null">pref_price,</if>
<if test="personLimit != null">person_limit,</if>
<if test="oneDayLimit != null">one_day_limit,</if>
<if test="imgUrl != null">img_url,</if>
<if test="inventoryNum != null">inventory_num,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="supermarketId != null">#{supermarketId},</if>
<if test="materialId != null">#{materialId},</if>
<if test="putawayState != null">#{putawayState},</if>
<if test="ifOnline != null">#{ifOnline},</if>
<if test="salePrice != null">#{salePrice},</if>
<if test="prefPrice != null">#{prefPrice},</if>
<if test="personLimit != null">#{personLimit},</if>
<if test="oneDayLimit != null">#{oneDayLimit},</if>
<if test="imgUrl != null">#{imgUrl},</if>
<if test="inventoryNum != null">#{inventoryNum},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateSupermarketProduct" parameterType="com.bonus.canteen.core.supermarket.domain.SupermarketProduct">
update supermarket_product
<trim prefix="SET" suffixOverrides=",">
<if test="supermarketId != null">supermarket_id = #{supermarketId},</if>
<if test="materialId != null">material_id = #{materialId},</if>
<if test="putawayState != null">putaway_state = #{putawayState},</if>
<if test="ifOnline != null">if_online = #{ifOnline},</if>
<if test="salePrice != null">sale_price = #{salePrice},</if>
<if test="prefPrice != null">pref_price = #{prefPrice},</if>
<if test="personLimit != null">person_limit = #{personLimit},</if>
<if test="oneDayLimit != null">one_day_limit = #{oneDayLimit},</if>
<if test="imgUrl != null">img_url = #{imgUrl},</if>
<if test="inventoryNum != null">inventory_num = #{inventoryNum},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where product_id = #{productId}
</update>
<delete id="deleteSupermarketProductByProductId" parameterType="Long">
delete from supermarket_product where product_id = #{productId}
</delete>
<delete id="deleteSupermarketProductByProductIds" parameterType="String">
delete from supermarket_product where product_id in
<foreach item="productId" collection="array" open="(" separator="," close=")">
#{productId}
</foreach>
</delete>
</mapper>