Compare commits

..

18 Commits

Author SHA1 Message Date
gaowdong 91e0226993 订单管理 2025-06-03 10:27:04 +08:00
gaowdong 43dd9f2392 Merge branch 'master' into order 2025-06-03 09:42:24 +08:00
gaowdong 92681d878f Merge branch 'master' into order 2025-06-03 09:41:43 +08:00
sxu 70aa1c50fa 商品上架管理 2025-06-03 09:29:51 +08:00
sxu b1cd6849e9 菜谱管理 2025-06-01 23:29:20 +08:00
sxu 45bdb1d8c4 菜谱管理 2025-06-01 23:19:12 +08:00
sxu a23ba1664e 菜谱管理 2025-06-01 07:02:14 +08:00
sxu 868b02929e 菜谱管理 2025-06-01 06:56:32 +08:00
sxu 988d3bb4a6 菜谱管理 2025-06-01 06:20:04 +08:00
sxu 070bf9c495 菜谱管理 2025-05-31 10:51:27 +08:00
sxu 596c7d16fd 菜谱管理 2025-05-31 10:08:03 +08:00
sxu 33373d50f9 菜谱管理 2025-05-30 18:26:40 +08:00
sxu 8f1dc34334 菜谱管理 2025-05-30 16:46:33 +08:00
sxu 02fdba8d35 菜谱管理 2025-05-30 16:37:56 +08:00
sxu ea5ee5ee42 test 2025-05-30 16:11:45 +08:00
sxu d65cfe2156 fix conflict 2025-05-30 15:23:24 +08:00
sxu 1ab1ead903 Merge branch 'master' into test0530 2025-05-30 15:05:08 +08:00
sxu edde32e8e2 test 2025-05-30 14:57:28 +08:00
33 changed files with 1142 additions and 171 deletions

View File

@ -1,9 +1,12 @@
package com.bonus.canteen.core.common.utils;
import com.bonus.common.houqin.constant.GlobalConstants;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.temporal.TemporalAdjusters;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class DateUtil {
@ -27,4 +30,14 @@ public class DateUtil {
return dates;
}
public static HashMap<Integer, LocalDate> getDaysInWeekMap() {
LocalDate now = LocalDate.now();
HashMap<Integer, LocalDate> dateHashMap = new HashMap<>();
for (int i = 0; i < GlobalConstants.WEEK_DAYS; ++i) {
LocalDate applyWeek = now.plusDays((long) i);
dateHashMap.put(applyWeek.getDayOfWeek().getValue(), applyWeek);
}
return dateHashMap;
}
}

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

@ -1,6 +1,9 @@
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;
@ -61,7 +64,17 @@ public interface CookRecipeDetailMapper {
public List<Long> getAllCookRecipeDetailIds(Long[] recipeIds);
public List<Long> getToDeleteCookRecipeDetailIds(Long recipeId);
public List<Long> getToDeleteCookRecipeDetailIds4PointDays(@Param("recipeId") Long recipeId, @Param("dateList") List<LocalDate> dateList);
public List<Long> getToDeleteCookRecipeDetailIds4Daily(@Param("recipeId") Long recipeId);
public List<Long> getToDeleteCookRecipeDetailIds4WeeklyTemplate(@Param("recipeId") Long recipeId, @Param("applyWeeks") List<Long> applyWeeks);
public List<Long> getToDeleteCookRecipeDetailIds4WeeklyDetail(@Param("recipeId")Long recipeId, @Param("dateList") List<LocalDate> dateList);
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();
@ -201,35 +207,53 @@ public class CookRecipeServiceImpl implements ICookRecipeService {
throw new ServiceException("该菜谱名称已存在,请重新输入");
}
int count = cookRecipeMapper.insertCookRecipe(cookRecipeDTO); //插入菜谱
createRecipeDetails(cookRecipeDTO, true);
createRecipeDetails(cookRecipeDTO); //创建详情+菜品数据
return count;
} catch (Exception e) {
throw new ServiceException(e.getMessage());
}
}
private void createRecipeDetails(CookRecipeDTO cookRecipeDTO, boolean isCreate) {
// 更新菜谱时
// 指定日期菜谱删掉指定日期的菜谱
// 循环菜谱删掉模板数据 + 今日开始的详情数据
if (!isCreate) {
List<Long> cookRecipeDetailIds = cookRecipeDetailMapper.getToDeleteCookRecipeDetailIds(cookRecipeDTO.getRecipeId());
if (!CollectionUtils.isEmpty(cookRecipeDetailIds)) {
Long[] cookRecipeDetailArray = cookRecipeDetailIds.stream().toArray(Long[]::new);
cookRecipeDishesMapper.deleteCookRecipeDishesByCookRecipeDetailIds(cookRecipeDetailArray);
cookRecipeDetailMapper.deleteCookRecipeDetailByRecipeDetailIds(cookRecipeDetailArray);
/**
* 修改菜品计划信息
*
* @param cookRecipeDTO 菜品计划信息
* @return 结果
*/
@Override
public int updateCookRecipe(CookRecipeDTO cookRecipeDTO) {
cookRecipeDTO.setUpdateTime(DateUtils.getNowDate());
cookRecipeDTO.setUpdateBy(SecurityUtils.getUsername());
try {
List<CookRecipe> cookRecipes = cookRecipeMapper.selectCookRecipeList(new CookRecipe());
List<String> otherCookRecipes = cookRecipes.stream().filter(item -> !item.getRecipeId().equals(cookRecipeDTO.getRecipeId()))
.map(CookRecipe::getRecipeName).collect(Collectors.toList());
if (otherCookRecipes.contains(cookRecipeDTO.getRecipeName())) {
throw new ServiceException("该菜谱名称已存在,请重新输入");
}
int count = cookRecipeMapper.updateCookRecipe(cookRecipeDTO);
// 删除旧的详情+菜品数据
deleteOldCookRecipeDetailsAndDishes(cookRecipeDTO);
// 重新创建详情+菜品数据
createRecipeDetails(cookRecipeDTO);
return count;
} catch (Exception e) {
throw new ServiceException(e.getMessage());
}
}
private void createRecipeDetails(CookRecipeDTO cookRecipeDTO) {
// 插入指定日期日循环摸板周循环模板
if (!CollectionUtils.isEmpty(cookRecipeDTO.getRecipeDateList())) {
for (CookRecipeDateDTO recipeDateDTO : cookRecipeDTO.getRecipeDateList()) {
List<CookRecipeDetailDTO> detailList = recipeDateDTO.getDetailList();
for (CookRecipeDetailDTO detailDTO : detailList) {
if (RecipeTypeEnum.POINT_DATE.key().equals(cookRecipeDTO.getRecipeType())
&& CollectionUtils.isEmpty(detailDTO.getDishesList())) { //指定日期不插入空数据
continue;
if (!CollectionUtils.isEmpty(detailList)) {
for (CookRecipeDetailDTO detailDTO : detailList) {
if (CollectionUtils.isEmpty(detailDTO.getDishesList())) { //不插入空数据
continue;
}
insertDetailAndDishes(cookRecipeDTO, recipeDateDTO, detailDTO);
}
insertDetailAndDishes(cookRecipeDTO, recipeDateDTO, detailDTO);
}
}
}
@ -238,8 +262,13 @@ public class CookRecipeServiceImpl implements ICookRecipeService {
if (!CollectionUtils.isEmpty(generatedRecipeDateList)) {
for (CookRecipeDateDTO recipeDateDTO : generatedRecipeDateList) {
List<CookRecipeDetailDTO> detailList = recipeDateDTO.getDetailList();
for (CookRecipeDetailDTO detailDTO : detailList) {
insertDetailAndDishes(cookRecipeDTO, recipeDateDTO, detailDTO);
if (!CollectionUtils.isEmpty(detailList)) {
for (CookRecipeDetailDTO detailDTO : detailList) {
if (CollectionUtils.isEmpty(detailDTO.getDishesList())) { //不插入空数据
continue;
}
insertDetailAndDishes(cookRecipeDTO, recipeDateDTO, detailDTO);
}
}
}
}
@ -253,7 +282,6 @@ public class CookRecipeServiceImpl implements ICookRecipeService {
List<CookRecipeDateDTO> recipeDateListNew = new ArrayList<>();
if (RecipeTypeEnum.DAILY.key().equals(cookRecipeDTO.getRecipeType()) && Objects.nonNull(recipeDateList.get(0))) { //每日循环
List<CookRecipeDetailDTO> recipeDetailList = recipeDateList.get(0).getDetailList();
//新增详情
LocalDate now = LocalDate.now();
for (int i = 0; i < GlobalConstants.WEEK_DAYS; ++i) {
CookRecipeDateDTO cookRecipeDateDTO = new CookRecipeDateDTO();
@ -262,13 +290,7 @@ public class CookRecipeServiceImpl implements ICookRecipeService {
recipeDateListNew.add(cookRecipeDateDTO);
}
} else if (RecipeTypeEnum.WEEKLY.key().equals(cookRecipeDTO.getRecipeType())) { //每周循环
LocalDate now = LocalDate.now();
HashMap<Integer, LocalDate> dateHashMap = new HashMap<>();
for (int i = 0; i < GlobalConstants.WEEK_DAYS; ++i) {
LocalDate applyWeek = now.plusDays((long) i);
dateHashMap.put(applyWeek.getDayOfWeek().getValue(), applyWeek);
}
//新增详情
HashMap<Integer, LocalDate> dateHashMap = DateUtil.getDaysInWeekMap();
Iterator<Map.Entry<Integer, LocalDate>> iterator = dateHashMap.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<Integer, LocalDate> entry = iterator.next();
@ -316,93 +338,130 @@ public class CookRecipeServiceImpl implements ICookRecipeService {
}
}
/**
* 修改菜品计划信息
*
* @param cookRecipeDTO 菜品计划信息
* @return 结果
*/
@Override
public int updateCookRecipe(CookRecipeDTO cookRecipeDTO) {
cookRecipeDTO.setUpdateTime(DateUtils.getNowDate());
cookRecipeDTO.setUpdateBy(SecurityUtils.getUsername());
try {
List<CookRecipe> cookRecipes = cookRecipeMapper.selectCookRecipeList(new CookRecipe());
List<String> otherCookRecipes = cookRecipes.stream().filter(item -> !item.getRecipeId().equals(cookRecipeDTO.getRecipeId()))
.map(CookRecipe::getRecipeName).collect(Collectors.toList());
if (otherCookRecipes.contains(cookRecipeDTO.getRecipeName())) {
throw new ServiceException("该菜谱名称已存在,请重新输入");
private void deleteOldCookRecipeDetailsAndDishes(CookRecipeDTO cookRecipeDTO) {
List<Long> cookRecipeDetailIds = new ArrayList<>();
// 更新菜谱时指定日期菜谱删掉指定日期的菜谱
if (RecipeTypeEnum.POINT_DATE.key().equals(cookRecipeDTO.getRecipeType())) {
List<LocalDate> dateList = cookRecipeDTO.getRecipeDateList().stream().map(CookRecipeDateDTO::getApplyDate).collect(Collectors.toList());
cookRecipeDetailIds = cookRecipeDetailMapper.getToDeleteCookRecipeDetailIds4PointDays(cookRecipeDTO.getRecipeId(), dateList);
}
// 循环日菜谱删掉模板数据 + 今日开始的详情数据
if (RecipeTypeEnum.DAILY.key().equals(cookRecipeDTO.getRecipeType())) {
cookRecipeDetailIds = cookRecipeDetailMapper.getToDeleteCookRecipeDetailIds4Daily(cookRecipeDTO.getRecipeId());
}
// 循环周菜谱删掉指定周x模板数据 + 今日开始的周x的详情数据
if (RecipeTypeEnum.WEEKLY.key().equals(cookRecipeDTO.getRecipeType())) {
List<Long> applyWeeks = cookRecipeDTO.getRecipeDateList().stream().map(CookRecipeDateDTO::getApplyWeek).collect(Collectors.toList());
HashMap<Integer, LocalDate> dateHashMap = DateUtil.getDaysInWeekMap();
List<LocalDate> dateList = new ArrayList<>();
for (Long applyWeek : applyWeeks) {
dateList.add(dateHashMap.get(applyWeek.intValue()));
}
int count = cookRecipeMapper.updateCookRecipe(cookRecipeDTO);
createRecipeDetails(cookRecipeDTO, false);
return count;
} catch (Exception e) {
throw new ServiceException(e.getMessage());
//模板数据
cookRecipeDetailIds.addAll(cookRecipeDetailMapper.getToDeleteCookRecipeDetailIds4WeeklyTemplate(cookRecipeDTO.getRecipeId(), applyWeeks));
//详情数据
cookRecipeDetailIds.addAll(cookRecipeDetailMapper.getToDeleteCookRecipeDetailIds4WeeklyDetail(cookRecipeDTO.getRecipeId(), dateList));
}
if (!CollectionUtils.isEmpty(cookRecipeDetailIds)) {
Long[] cookRecipeDetailArray = cookRecipeDetailIds.stream().toArray(Long[]::new);
cookRecipeDishesMapper.deleteCookRecipeDishesByCookRecipeDetailIds(cookRecipeDetailArray);
cookRecipeDetailMapper.deleteCookRecipeDetailByRecipeDetailIds(cookRecipeDetailArray);
}
}
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

@ -89,7 +89,8 @@ public class OrderCartController extends BaseController
public AjaxResult editSave(@RequestBody OrderCart orderCart)
{
OrderCartParamChecker.editCheck(orderCart);
return toAjax(iOrderCartService.updateOrderCart(orderCart));
iOrderCartService.updateOrderCart(orderCart);
return AjaxResult.success();
}
/**
@ -100,9 +101,9 @@ public class OrderCartController extends BaseController
@ResponseBody
public AjaxResult remove(@RequestBody OrderCartDelParam param)
{
if(Objects.isNull(param) || CollUtil.isEmpty(param.getShoppingCartIds())) {
if(Objects.isNull(param) || CollUtil.isEmpty(param.getCartIds())) {
throw new ServiceException("购物车餐品ID为空");
}
return toAjax(iOrderCartService.deleteOrderCartByCartIds(param.getShoppingCartIds()));
return toAjax(iOrderCartService.deleteOrderCartByCartIds(param.getCartIds()));
}
}

View File

@ -203,7 +203,7 @@ public class OrderCart extends BaseEntity
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("shoppingCartId", getCartId())
.append("cartId", getCartId())
.append("userId", getUserId())
.append("menuId", getMenuId())
.append("canteenId", getCanteenId())

View File

@ -41,6 +41,6 @@ public class DeviceOrderDetailInfoAddParam {
message = "计算价格不能小于0"
) BigDecimal finalPrice;
private Integer salesMode;
private String shoppingCartId;
private String cartId;
}

View File

@ -7,5 +7,5 @@ import java.util.List;
@Data
public class OrderCartDelParam extends BaseEntity {
private List<Long> shoppingCartIds;
private List<Long> cartIds;
}

View File

@ -41,6 +41,6 @@ public class OrderDetailInfoAddParam {
message = "计算价格不能小于0"
) BigDecimal finalPrice;
private Integer salesMode;
private String shoppingCartId;
private String cartId;
}

View File

@ -18,7 +18,7 @@ public class OrderCartVO extends BaseEntity
{
/** 主键 */
private Long shoppingCartId;
private Long cartId;
/** 人员id */
@Excel(name = "人员id")

View File

@ -19,7 +19,7 @@ public interface OrderCartMapper
* @param cartId 订单购物车主键
* @return 订单购物车
*/
public OrderCart selectOrderCartByShoppingCartId(Long cartId);
public OrderCart selectOrderCartByCartId(Long cartId);
/**
* 查询订单购物车列表
@ -51,7 +51,7 @@ public interface OrderCartMapper
* @param cartId 订单购物车主键
* @return 结果
*/
public int deleteOrderCartByShoppingCartId(Long cartId);
public int deleteOrderCartByCartId(Long cartId);
/**
* 批量删除订单购物车
@ -59,5 +59,5 @@ public interface OrderCartMapper
* @param cartIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteOrderCartByShoppingCartIds(@Param("cartIds") List<Long> cartIds);
public int deleteOrderCartByCartIds(@Param("cartIds") List<Long> cartIds);
}

View File

@ -47,7 +47,7 @@ public class OrderCartServiceImpl implements IOrderCartService
@Override
public OrderCart selectOrderCartByCartId(Long cartId)
{
return orderCartMapper.selectOrderCartByShoppingCartId(cartId);
return orderCartMapper.selectOrderCartByCartId(cartId);
}
/**
@ -104,23 +104,23 @@ public class OrderCartServiceImpl implements IOrderCartService
return orderCartVOList;
}
private OrderCartVO convertToOrderCartVO(OrderCart shoppingCart,
private OrderCartVO convertToOrderCartVO(OrderCart orderCart,
Map<Long, List<CookRecipeDishesVO>> cookRecipeDishMap) {
OrderCartVO shoppingCartVO = new OrderCartVO();
BeanUtils.copyProperties(shoppingCart, shoppingCartVO);
shoppingCartVO.setIsValid(0);
OrderCartVO orderCartVO = new OrderCartVO();
BeanUtils.copyProperties(orderCart, orderCartVO);
orderCartVO.setIsValid(0);
List<CookRecipeDishesVO> cookRecipeDishes = cookRecipeDishMap.get(shoppingCart.getMealtimeType().longValue());
List<CookRecipeDishesVO> cookRecipeDishes = cookRecipeDishMap.get(orderCart.getMealtimeType().longValue());
if (CollUtil.isNotEmpty(cookRecipeDishes)) {
for (CookRecipeDishesVO cookRecipeDishesVO : cookRecipeDishes) {
if (shoppingCart.getGoodsId().equals(cookRecipeDishesVO.getDishesId())) {
shoppingCartVO.setIsValid(1);
if (orderCart.getGoodsId().equals(cookRecipeDishesVO.getDishesId())) {
orderCartVO.setIsValid(1);
break;
}
}
}
return shoppingCartVO;
return orderCartVO;
}
@ -165,7 +165,7 @@ public class OrderCartServiceImpl implements IOrderCartService
@Override
public int deleteOrderCartByCartIds(List<Long> cartIds)
{
return orderCartMapper.deleteOrderCartByShoppingCartIds(cartIds);
return orderCartMapper.deleteOrderCartByCartIds(cartIds);
}
/**
@ -177,6 +177,6 @@ public class OrderCartServiceImpl implements IOrderCartService
@Override
public int deleteOrderCartByCartId(Long cartId)
{
return orderCartMapper.deleteOrderCartByShoppingCartId(cartId);
return orderCartMapper.deleteOrderCartByCartId(cartId);
}
}

View File

@ -32,7 +32,7 @@ public class OrderCartParamChecker {
public static void editCheck(OrderCart orderCart) {
checkOrderShoppingCart(orderCart);
checkShoppingCartId(orderCart);
checkCartId(orderCart);
checkQuantity(orderCart);
}
@ -41,7 +41,7 @@ public class OrderCartParamChecker {
throw new ServiceException("订单购物车对象为空");
}
}
private static void checkShoppingCartId(OrderCart orderCart) {
private static void checkCartId(OrderCart orderCart) {
if (orderCart.getCartId() == null) {
throw new ServiceException("购物车ID为空");
}

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

@ -25,7 +25,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectBasicAreaList" parameterType="com.bonus.canteen.core.basic.domain.BasicArea" resultMap="BasicAreaResult">
<include refid="selectBasicAreaVo"/>
<where>
<where>
del_flag = '0'
<if test="areaName != null and areaName != ''"> and area_name like concat('%', #{areaName}, '%')</if>
<if test="parentId != null "> and parent_id = #{parentId}</if>
<if test="manager != null and manager != ''"> and manager = #{manager}</if>
@ -37,12 +38,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectBasicAreaByAreaName" parameterType="String" resultMap="BasicAreaResult">
<include refid="selectBasicAreaVo"/>
where del_flag = 0 and area_name = #{areaName}
where del_flag = '0' and area_name = #{areaName}
</select>
<select id="selectBasicAreaByAreaId" parameterType="Long" resultMap="BasicAreaResult">
<include refid="selectBasicAreaVo"/>
where del_flag = 0 and area_id = #{areaId}
where del_flag = '0' and area_id = #{areaId}
</select>
<insert id="insertBasicArea" parameterType="com.bonus.canteen.core.basic.domain.BasicArea" useGeneratedKeys="true" keyProperty="areaId">

View File

@ -40,7 +40,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectBasicCanteenList" parameterType="com.bonus.canteen.core.basic.domain.BasicCanteen" resultMap="BasicCanteenResult">
<include refid="selectBasicCanteenVo"/>
<where>
<where>
bc.del_flag = '0'
<if test="canteenName != null and canteenName != ''"> and bc.canteen_name like concat('%', #{canteenName}, '%')</if>
<if test="areaId != null "> and bc.area_id = #{areaId}</if>
<if test="manager != null and manager != ''"> and bc.manager = #{manager}</if>
@ -63,18 +64,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectBasicCanteenByCanteenId" parameterType="Long" resultMap="BasicCanteenResult">
<include refid="selectBasicCanteenVo"/>
where bc.canteen_id = #{canteenId} and bc.del_flag = 0
where bc.canteen_id = #{canteenId} and bc.del_flag = '0'
</select>
<select id="selectBasicCanteenByCanteenName" parameterType="com.bonus.canteen.core.basic.domain.BasicCanteen" resultMap="BasicCanteenResult">
<include refid="selectBasicCanteenVo"/>
where bc.canteen_name = #{canteenName} and bc.area_id = #{areaId} and bc.del_flag = 0
where bc.canteen_name = #{canteenName} and bc.area_id = #{areaId} and bc.del_flag = '0'
</select>
<select id="getBasicCanteenCountByAreaIds" resultType="Integer">
select count(1)
from basic_canteen
where del_flag = 0 and area_id in
where del_flag = '0' and area_id in
<foreach item="areaId" collection="array" open="(" separator="," close=")">
#{areaId}
</foreach>

View File

@ -42,7 +42,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectBasicStallList" parameterType="com.bonus.canteen.core.basic.domain.BasicStall" resultMap="BasicStallResult">
<include refid="selectBasicStallVo"/>
<where>
<where>
bs.del_flag = '0'
<if test="stallName != null and stallName != ''"> and bs.stall_name like concat('%', #{stallName}, '%')</if>
<if test="areaId != null "> and bs.area_id = #{areaId}</if>
<if test="canteenId != null "> and bs.canteen_id = #{canteenId}</if>
@ -65,12 +66,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectBasicStallByStallId" parameterType="Long" resultMap="BasicStallResult">
<include refid="selectBasicStallVo"/>
where bs.stall_id = #{stallId} and bs.del_flag = 0
where bs.stall_id = #{stallId} and bs.del_flag = '0'
</select>
<select id="selectBasicStallByStallName" parameterType="com.bonus.canteen.core.basic.domain.BasicStall" resultMap="BasicStallResult">
<include refid="selectBasicStallVo"/>
where bs.stall_name = #{stallName} and bs.canteen_id = #{canteenId} and bs.del_flag = 0
where bs.stall_name = #{stallName} and bs.canteen_id = #{canteenId} and bs.del_flag = '0'
</select>
<select id="selectBasicStallCountByCanteenIds" resultType="Integer">

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

@ -107,14 +107,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</select>
<select id="getToDeleteCookRecipeDetailIds" parameterType="Long" resultType="Long">
<select id="getToDeleteCookRecipeDetailIds4PointDays" resultType="Long">
SELECT distinct(crd.recipe_detail_id)
FROM cook_recipe_detail crd
left join cook_recipe cr ON cr.recipe_id = crd.recipe_id
where cr.recipe_id = #{recipeId} and cr.recipe_type = 1 and crd.apply_date >= NOW()-1
UNION
left join cook_recipe cr ON cr.recipe_id = crd.recipe_id
where cr.recipe_id = #{recipeId} and cr.recipe_type = 1 and crd.apply_date in
<foreach item="applyDate" collection="dateList" open="(" separator="," close=")">
#{applyDate}
</foreach>
</select>
<select id="getToDeleteCookRecipeDetailIds4Daily" resultType="Long">
SELECT distinct(crd.recipe_detail_id)
FROM cook_recipe_detail crd
left join cook_recipe cr ON cr.recipe_id = crd.recipe_id
@ -126,20 +129,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
FROM cook_recipe_detail crd
left join cook_recipe cr ON cr.recipe_id = crd.recipe_id
where cr.recipe_id = #{recipeId} and cr.recipe_type = 2 and crd.detail_type = 2 and crd.apply_date >= NOW()-1
</select>
UNION
<select id="getToDeleteCookRecipeDetailIds4WeeklyTemplate" parameterType="Long" resultType="Long">
SELECT distinct(crd.recipe_detail_id)
FROM cook_recipe_detail crd
left join cook_recipe cr ON cr.recipe_id = crd.recipe_id
where cr.recipe_id = #{recipeId} and cr.recipe_type = 3 and crd.detail_type = 1
UNION
where cr.recipe_id = #{recipeId} and cr.recipe_type = 3 and crd.detail_type = 1 and crd.apply_week in
<foreach item="applyWeek" collection="applyWeeks" open="(" separator="," close=")">
#{applyWeek}
</foreach>
</select>
<select id="getToDeleteCookRecipeDetailIds4WeeklyDetail" resultType="Long">
SELECT distinct(crd.recipe_detail_id)
FROM cook_recipe_detail crd
left join cook_recipe cr ON cr.recipe_id = crd.recipe_id
where cr.recipe_id = #{recipeId} and cr.recipe_type = 3 and crd.detail_type = 2 and crd.apply_date >= NOW()-1
where cr.recipe_id = #{recipeId} and cr.recipe_type = 3 and crd.detail_type = 2 and crd.apply_date in
<foreach item="applyDate" collection="dateList" open="(" separator="," close=")">
#{applyDate}
</foreach>
</select>
<select id="getCookRecipeDetailLTemplate" resultMap="CookRecipeDetailResult">
@ -148,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

@ -57,7 +57,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="salePrice != null">sale_price,</if>
<if test="sizeType != null">size_type,</if>
<if test="supplyNum != null">supply_num,</if>
<if test="saleNum != null">sale_num,</if>
<!--<if test="saleNum != null">sale_num,</if>-->
<if test="remanentNum != null">remanent_num,</if>
<if test="limitNum != null">limit_num,</if>
<if test="chefId != null">chef_id,</if>
@ -74,7 +74,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="salePrice != null">#{salePrice},</if>
<if test="sizeType != null">#{sizeType},</if>
<if test="supplyNum != null">#{supplyNum},</if>
<if test="saleNum != null">#{saleNum},</if>
<!--<if test="saleNum != null">#{saleNum},</if>-->
<if test="remanentNum != null">#{remanentNum},</if>
<if test="limitNum != null">#{limitNum},</if>
<if test="chefId != null">#{chefId},</if>

View File

@ -62,6 +62,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectCookRecipeList" parameterType="com.bonus.canteen.core.cook.domain.CookRecipe" resultMap="CookRecipeResult">
<include refid="selectCookRecipeVo"/>
<where>
ba.del_flag = '0' and bc.del_flag = '0' and bs.del_flag = '0' and cr.del_flag = '0'
<if test="recipeName != null and recipeName != ''"> and cr.recipe_name like concat('%', #{recipeName}, '%')</if>
<if test="recipeType != null "> and cr.recipe_type = #{recipeType}</if>
<if test="stallId != null "> and cr.stall_id = #{stallId}</if>
@ -78,7 +79,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectCookRecipeVo"/>
<where>
<if test="recipeIds !=null and recipeIds.size()>0">
AND recipe_id in
AND cr.recipe_id in
<foreach collection="recipeIds" open="(" close=")" item="item" separator=",">
#{item}
</foreach>
@ -236,12 +237,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectCookRecipeByRecipeId" parameterType="Long" resultMap="CookRecipeResult">
<include refid="selectCookRecipeVo"/>
where cr.recipe_id = #{recipeId} and cr.del_flag = 0
where cr.recipe_id = #{recipeId} and ba.del_flag = '0' and bc.del_flag = '0' and bs.del_flag = '0' and cr.del_flag = '0'
</select>
<select id="selectCookRecipeByRecipeName" parameterType="String" resultMap="CookRecipeResult">
<include refid="selectCookRecipeVo"/>
where cr.recipe_name = #{recipeName} and cr.del_flag = 0
where cr.recipe_name = #{recipeName} and ba.del_flag = '0' and bc.del_flag = '0' and bs.del_flag = '0' and cr.del_flag = '0'
</select>
<insert id="insertCookRecipe" parameterType="com.bonus.canteen.core.cook.domain.CookRecipe" useGeneratedKeys="true" keyProperty="recipeId">
@ -293,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
@ -381,12 +382,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
basic_stall t1
LEFT JOIN basic_canteen t2 ON t1.canteen_id = t2.canteen_id
LEFT JOIN basic_area t3 ON t2.area_id = t3.area_id
where 1=1
where t1.del_flag = '0' and t2.del_flag = '0' and t3.del_flag = '0'
<if test="recipeName !=null and recipeName !=''">
AND EXISTS (
select null
from cook_recipe_bind_app t4 INNER JOIN cook_recipe t5 on t4.recipe_id = t5.recipe_id
where t5.stall_id = t1.stall_id AND t4.bind_type = #{bindType}
where t5.del_flag = '0' and t5.stall_id = t1.stall_id AND t4.bind_type = #{bindType}
and t5.recipe_name like #{recipeName}
)
</if>
@ -419,14 +420,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectRecipeByStallIdsAndBindType"
resultType="com.bonus.canteen.core.cook.vo.StallAndRecipeBindVO">
select
mar.recipe_id,
mr.stall_id,
mar.bind_type
from cook_recipe_bind_app mar
left join cook_recipe mr on mar.recipe_id = mr.recipe_id
where bind_type = #{bindType}
crba.recipe_id,
cr.stall_id,
crba.bind_type
from cook_recipe_bind_app crba
left join cook_recipe cr on crba.recipe_id = cr.recipe_id
where bind_type = #{bindType} and cr.del_flag = '0'
<if test="stallIds !=null and stallIds.size() > 0 ">
and mr.stall_id IN
and cr.stall_id IN
<foreach collection="stallIds" item="stallId" separator="," open="(" close=")">
#{stallId}
</foreach>

View File

@ -49,7 +49,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
</select>
<select id="selectOrderCartByShoppingCartId" parameterType="Long" resultMap="OrderCartResult">
<select id="selectOrderCartByCartId" parameterType="Long" resultMap="OrderCartResult">
<include refid="selectOrderShoppingCartVo"/>
where cart_id = #{cartId}
</select>
@ -119,14 +119,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where cart_id = #{cartId}
</update>
<delete id="deleteOrderCartByShoppingCartId" parameterType="Long">
<delete id="deleteOrderCartByCartId" parameterType="Long">
delete from order_cart where cart_id = #{cartId}
</delete>
<delete id="deleteOrderCartByShoppingCartIds" parameterType="String">
<delete id="deleteOrderCartByCartIds" parameterType="String">
delete from order_cart where cart_id in
<foreach item="shoppingCartId" collection="cartIds" open="(" separator="," close=")">
#{shoppingCartId}
<foreach item="cartId" collection="cartIds" open="(" separator="," close=")">
#{cartId}
</foreach>
</delete>

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>