From 3144a21a8dd45cf8f3bef045c08901a4262dbbd1 Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Fri, 6 Jun 2025 15:48:14 +0800 Subject: [PATCH] =?UTF-8?q?h5=E5=91=A8=E8=8F=9C=E8=B0=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CookRecipeH5Controller.java | 14 ++- .../core/cook/dto/AppletWeekRecipeDTO.java | 18 ++++ .../cook/enums/BasicMealtimeTypeEnum.java | 76 +++++++++++++ .../cook/service/ICookRecipeH5Service.java | 3 + .../service/impl/CookRecipeServiceH5Impl.java | 56 ++++++++++ .../cook/vo/AppletWeekRecipeDishesVO.java | 100 ++++++++++++++++++ .../core/cook/vo/AppletWeekRecipeTypeVO.java | 41 +++++++ .../core/cook/vo/AppletWeekRecipeVO.java | 40 +++++++ 8 files changed, 347 insertions(+), 1 deletion(-) create mode 100644 bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/dto/AppletWeekRecipeDTO.java create mode 100644 bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/enums/BasicMealtimeTypeEnum.java create mode 100644 bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/vo/AppletWeekRecipeDishesVO.java create mode 100644 bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/vo/AppletWeekRecipeTypeVO.java create mode 100644 bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/vo/AppletWeekRecipeVO.java diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/controller/CookRecipeH5Controller.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/controller/CookRecipeH5Controller.java index 10488d7..1cab33c 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/controller/CookRecipeH5Controller.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/controller/CookRecipeH5Controller.java @@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; +import java.time.LocalDate; import java.util.List; /** @@ -69,5 +70,16 @@ public class CookRecipeH5Controller extends BaseController { } } - + @ApiOperation("获取一周菜谱详情") + @GetMapping({"/week/recipe/detail"}) + public TableDataInfo getWeekRecipeDetailList(@Valid AppletWeekRecipeDTO content) { + try { + startPage(); + content.setApplyDate(LocalDate.parse(content.getDate())); + return getDataTable(this.cookRecipeH5Service.getWeekRecipeDetailList(content)); + } catch (Exception e) { + log.error(e.toString(), e); + return getDataTable(null); + } + } } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/dto/AppletWeekRecipeDTO.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/dto/AppletWeekRecipeDTO.java new file mode 100644 index 0000000..8ce6973 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/dto/AppletWeekRecipeDTO.java @@ -0,0 +1,18 @@ +package com.bonus.canteen.core.cook.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.time.LocalDate; + +@Data +public class AppletWeekRecipeDTO { + @ApiModelProperty("菜谱日期") + private LocalDate applyDate; + @ApiModelProperty("人员id") + private Long userId; + @ApiModelProperty("菜谱id") + private Long recipeId; + private String date; + +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/enums/BasicMealtimeTypeEnum.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/enums/BasicMealtimeTypeEnum.java new file mode 100644 index 0000000..9a06dd3 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/enums/BasicMealtimeTypeEnum.java @@ -0,0 +1,76 @@ +package com.bonus.canteen.core.cook.enums; + +import cn.hutool.core.collection.ListUtil; +import java.util.List; + +public enum BasicMealtimeTypeEnum { + MEALTIME_BREAKFAST(1, "早餐"), + MEALTIME_LUNCH(2, "午餐"), + MEALTIME_AFTERNOON_TEA(3, "下午茶"), + MEALTIME_DINNER(4, "晚餐"), + MEALTIME_MIDNIGHT_SNACK(5, "夜宵"); + + private final Integer key; + private final String desc; + + private BasicMealtimeTypeEnum(Integer key, String desc) { + this.key = key; + this.desc = desc; + } + + public static BasicMealtimeTypeEnum getTypeEnum(Integer key) { + BasicMealtimeTypeEnum[] var1 = values(); + int var2 = var1.length; + + for(int var3 = 0; var3 < var2; ++var3) { + BasicMealtimeTypeEnum typeEnum = var1[var3]; + if (typeEnum.getKey().equals(key)) { + return typeEnum; + } + } + + return null; + } + + public static String getDescByKey(Integer key) { + BasicMealtimeTypeEnum[] enums = values(); + BasicMealtimeTypeEnum[] var2 = enums; + int var3 = enums.length; + + for(int var4 = 0; var4 < var3; ++var4) { + BasicMealtimeTypeEnum anEnum = var2[var4]; + if (anEnum.getKey().equals(key)) { + return anEnum.getDesc(); + } + } + + return ""; + } + + public static Integer getKeyByDesc(String desc) { + BasicMealtimeTypeEnum[] enums = values(); + BasicMealtimeTypeEnum[] var2 = enums; + int var3 = enums.length; + + for(int var4 = 0; var4 < var3; ++var4) { + BasicMealtimeTypeEnum anEnum = var2[var4]; + if (anEnum.getDesc().equals(desc)) { + return anEnum.getKey(); + } + } + + return null; + } + + public static List allTypeList() { + return ListUtil.toList(new Integer[]{MEALTIME_BREAKFAST.getKey(), MEALTIME_LUNCH.getKey(), MEALTIME_AFTERNOON_TEA.getKey(), MEALTIME_DINNER.getKey(), MEALTIME_MIDNIGHT_SNACK.getKey()}); + } + + public Integer getKey() { + return this.key; + } + + public String getDesc() { + return this.desc; + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/ICookRecipeH5Service.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/ICookRecipeH5Service.java index 40621e8..5293976 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/ICookRecipeH5Service.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/ICookRecipeH5Service.java @@ -6,6 +6,7 @@ import com.bonus.canteen.core.cook.domain.CookRecipe; import com.bonus.canteen.core.cook.dto.*; import com.bonus.canteen.core.cook.vo.AllocRecipeStallVO; import com.bonus.canteen.core.cook.vo.AppletReserveRecipeVO; +import com.bonus.canteen.core.cook.vo.AppletWeekRecipeVO; import com.bonus.canteen.core.cook.vo.CookRecipeDetailVO; import org.springframework.web.multipart.MultipartFile; @@ -25,4 +26,6 @@ public interface ICookRecipeH5Service { public List listReserveDate(AllocMobileCanteenQueryDTO queryDTO); public List getReserveRecipeDetailList(AppletReserveRecipeDTO content); + + public List getWeekRecipeDetailList(AppletWeekRecipeDTO content); } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookRecipeServiceH5Impl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookRecipeServiceH5Impl.java index 524d8ac..e77187e 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookRecipeServiceH5Impl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/service/impl/CookRecipeServiceH5Impl.java @@ -11,7 +11,9 @@ import com.bonus.canteen.core.cook.mapper.CookRecipeH5Mapper; import com.bonus.canteen.core.cook.service.ICookRecipeH5Service; import com.bonus.canteen.core.cook.vo.*; import com.bonus.canteen.core.utils.BnsConstants; +import com.bonus.common.core.exception.ServiceException; import com.google.common.collect.Lists; +import com.google.common.collect.Sets; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -121,4 +123,58 @@ public class CookRecipeServiceH5Impl implements ICookRecipeH5Service { } } } + + @Override + public List getWeekRecipeDetailList(AppletWeekRecipeDTO content) { +// List recipeIdList = Lists.newArrayList(); +// if (ObjectUtil.isNull(content.getRecipeId())) { +// recipeIdList = this.cookRecipeH5Mapper.selectWeekRecipeId(content.getRecipeId()); +// if (ObjectUtil.isEmpty(recipeIdList)) { +// return Lists.newArrayList(); +// } +// } else { +// LocalDate applyDate = LocalDate.parse(content.getDate()); +// LocalDate now = LocalDate.now(); +// +// if (applyDate.isBefore(now)) { +// System.out.println("applyDate 早于当前日期"); +// //获取当前菜谱绑定的日期 +// String bindTime = this.cookRecipeH5Mapper.getBingTimeByRecipeId(content.getRecipeId()); +// if(bindTime !=null){ +// bindTime = bindTime.substring(0,10); +// LocalDate bindDate = LocalDate.parse(bindTime); +// System.out.println("Parsed date and time: " + bindDate); +// if(bindDate.isBefore(applyDate)){ +// System.out.println("绑定日期早于查询历史信息日期"); +// recipeIdList = this.cookRecipeH5Mapper.selectWeekRecipeId(content.getRecipeId()); +// }else{ +// System.out.println("绑定日期迟于查询历史信息日期"); +// List repeIdList = this.cookRecipeH5Mapper.getRecipeIdListByRecipeId(content.getRecipeId()); +// recipeIdList = this.cookRecipeH5Mapper.selectWeekRecipeIdHistory(repeIdList, null,applyDate); +// if(recipeIdList == null || recipeIdList.size() == 0){ +// ((List) recipeIdList).add(content.getRecipeId()); +// } +// } +// } +// } else if (applyDate.isAfter(now)) { +// System.out.println("applyDate 晚于当前日期"); +// recipeIdList = this.cookRecipeH5Mapper.selectWeekRecipeId(content.getRecipeId()); +// } else { +// System.out.println("applyDate 等于当前日期"); +// recipeIdList = this.cookRecipeH5Mapper.selectWeekRecipeId(content.getRecipeId()); +// } +// if(recipeIdList == null || recipeIdList.size() == 0){ +// throw new ServiceException("本档口没有更早的历史菜谱记录"); +// } +// } +// +// this.generateRecipe((List) recipeIdList, content.getApplyDate()); +// List resultList = cookRecipeH5Mapper.selectWeekRecipe(content.getApplyDate(), content.getRecipeId(), (List) recipeIdList); +// resultList.sort(Collections.reverseOrder((s1, s2) -> { +// return s2.getMealtimeType() - s1.getMealtimeType(); +// })); +// return resultList; + + return null; + } } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/vo/AppletWeekRecipeDishesVO.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/vo/AppletWeekRecipeDishesVO.java new file mode 100644 index 0000000..4e1fce9 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/vo/AppletWeekRecipeDishesVO.java @@ -0,0 +1,100 @@ +package com.bonus.canteen.core.cook.vo; + +import com.bonus.canteen.core.common.utils.FileUrlUtil; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.List; + +@ApiModel("菜品详情") +public class AppletWeekRecipeDishesVO { + @ApiModelProperty("菜品id") + private Long baseDishesId; + @ApiModelProperty("菜品名称") + private String dishesName; + @ApiModelProperty("菜品图片") + private String dishesImgUrl; + @ApiModelProperty("菜谱详情id") + private Long detailId; + @ApiModelProperty("食堂id") + private Long canteenId; + @ApiModelProperty("食堂名称") + private String canteenName; + @ApiModelProperty("档口id") + private Long stallId; + @ApiModelProperty("档口名称") + private String stallName; + @ApiModelProperty("大小份详情") + private List dishesDetailList; + + public String getDishesImgUrl() { + return FileUrlUtil.getFileUrl(dishesImgUrl); + } + + public Long getBaseDishesId() { + return this.baseDishesId; + } + + public String getDishesName() { + return this.dishesName; + } + + public Long getDetailId() { + return this.detailId; + } + + public Long getCanteenId() { + return this.canteenId; + } + + public String getCanteenName() { + return this.canteenName; + } + + public Long getStallId() { + return this.stallId; + } + + public String getStallName() { + return this.stallName; + } + + public List getDishesDetailList() { + return this.dishesDetailList; + } + + public void setBaseDishesId(final Long baseDishesId) { + this.baseDishesId = baseDishesId; + } + + public void setDishesName(final String dishesName) { + this.dishesName = dishesName; + } + + public void setDishesImgUrl(final String dishesImgUrl) { + this.dishesImgUrl = dishesImgUrl; + } + + public void setDetailId(final Long detailId) { + this.detailId = detailId; + } + + public void setCanteenId(final Long canteenId) { + this.canteenId = canteenId; + } + + public void setCanteenName(final String canteenName) { + this.canteenName = canteenName; + } + + public void setStallId(final Long stallId) { + this.stallId = stallId; + } + + public void setStallName(final String stallName) { + this.stallName = stallName; + } + + public void setDishesDetailList(final List dishesDetailList) { + this.dishesDetailList = dishesDetailList; + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/vo/AppletWeekRecipeTypeVO.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/vo/AppletWeekRecipeTypeVO.java new file mode 100644 index 0000000..e01f5d3 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/vo/AppletWeekRecipeTypeVO.java @@ -0,0 +1,41 @@ +package com.bonus.canteen.core.cook.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.List; + +@ApiModel("分类详情") +public class AppletWeekRecipeTypeVO { + @ApiModelProperty("菜品类别id") + private Long typeId; + @ApiModelProperty("菜品类别名称") + private String typeName; + @ApiModelProperty("菜品详情") + private List dishesList; + + public Long getTypeId() { + return this.typeId; + } + + public String getTypeName() { + return this.typeName; + } + + public List getDishesList() { + return this.dishesList; + } + + public void setTypeId(final Long typeId) { + this.typeId = typeId; + } + + public void setTypeName(final String typeName) { + this.typeName = typeName; + } + + public void setDishesList(final List dishesList) { + this.dishesList = dishesList; + } + +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/vo/AppletWeekRecipeVO.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/vo/AppletWeekRecipeVO.java new file mode 100644 index 0000000..5e98ee0 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/vo/AppletWeekRecipeVO.java @@ -0,0 +1,40 @@ +package com.bonus.canteen.core.cook.vo; + +import com.bonus.canteen.core.cook.enums.BasicMealtimeTypeEnum; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.List; + +@ApiModel("获取一周菜谱详情") +public class AppletWeekRecipeVO { + @ApiModelProperty("餐次类型") + private Integer mealtimeType; + @ApiModelProperty("餐次名称") + private String mealtimeName; + @ApiModelProperty("分类详情") + private List typeList; + + public String getMealtimeName() { + return BasicMealtimeTypeEnum.getDescByKey(this.mealtimeType); + } + + public Integer getMealtimeType() { + return this.mealtimeType; + } + + public List getTypeList() { + return this.typeList; + } + + public void setMealtimeType(final Integer mealtimeType) { + this.mealtimeType = mealtimeType; + } + + public void setMealtimeName(final String mealtimeName) { + this.mealtimeName = mealtimeName; + } + + public void setTypeList(final List typeList) { + this.typeList = typeList; + } +}