From e6c0c785131ca06eb20fe2423c6e21bf9ddea6e8 Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Fri, 6 Jun 2025 17:06:12 +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 --- .../core/cook/mapper/CookRecipeH5Mapper.java | 10 ++ .../service/impl/CookRecipeServiceH5Impl.java | 96 ++++++++------- .../mapper/cook/CookRecipeH5Mapper.xml | 113 ++++++++++++++++++ 3 files changed, 170 insertions(+), 49 deletions(-) diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/mapper/CookRecipeH5Mapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/mapper/CookRecipeH5Mapper.java index ab4af9e..c3b5fed 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/mapper/CookRecipeH5Mapper.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/mapper/CookRecipeH5Mapper.java @@ -15,6 +15,7 @@ import org.apache.ibatis.annotations.Select; import java.time.LocalDate; import java.util.List; +import java.util.Set; /** * 菜品计划信息Mapper接口 @@ -31,4 +32,13 @@ public interface CookRecipeH5Mapper { Long selectStallIdByRecipeId(@Param("recipeId") Long recipeId); + List selectWeekRecipeId(@Param("recipeId") Long recipeId); + + String getBingTimeByRecipeId(@Param("recipeId") Long recipeId); + + List getRecipeIdListByRecipeId(@Param("recipeId") Long recipeId); + + List selectWeekRecipeIdHistory(@Param("recipeIdList") List recipeId, @Param("effIdSet") Set effIdSet, @Param("applyDate") LocalDate applyDate); + + List selectWeekRecipe(@Param("applyDate") LocalDate applyDate, @Param("recipeId") Long recipeId, @Param("recipeIdList") List recipeIdList); } 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 e77187e..8029827 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 @@ -126,55 +126,53 @@ 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; + 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(); - return null; + 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; } } diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookRecipeH5Mapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookRecipeH5Mapper.xml index e80a9fd..3e33c21 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookRecipeH5Mapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookRecipeH5Mapper.xml @@ -56,6 +56,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +