添加h5历史记录周菜谱

This commit is contained in:
liux 2025-04-29 17:46:13 +08:00
parent f5ec7117a5
commit 85fd6a7868
3 changed files with 70 additions and 1 deletions

View File

@ -4,6 +4,8 @@ import com.bonus.canteen.core.menu.vo.AppletReserveCanteenVO;
import com.bonus.canteen.core.menu.vo.AppletWeekCanteenVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.time.LocalDate;
import java.util.List;
import java.util.Set;
@ -15,4 +17,10 @@ public interface MenuAppRecipeMapper {
List<AppletReserveCanteenVO> selectReserveMealCanteenList(@Param("effIdSet") Set<Long> effIdSet);
List<Long> selectWeekRecipeIdHistory(@Param("recipeIdList") List<Long> recipeId, @Param("effIdSet") Set<Long> effIdSet, @Param("applyDate") LocalDate applyDate);
List<Long> getRecipeIdListByRecipeId(@Param("recipeId") Long recipeId);
String getBingTimeByRecipeId(@Param("recipeId") Long recipeId);
}

View File

@ -165,7 +165,41 @@ public class MenuRecipeServiceImpl extends ServiceImpl<MenuRecipeMapper, MenuRec
return Lists.newArrayList();
}
} else {
((List) recipeIdList).add(content.getRecipeId());
LocalDate applyDate = content.getApplyDate();
LocalDate now = LocalDate.now();
if (applyDate.isBefore(now)) {
System.out.println("applyDate 早于当前日期");
//获取当前菜谱绑定的日期
String bindTime = this.menuAppRecipeMapper.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.menuAppRecipeMapper.selectWeekRecipeId(content.getRecipeId(), null);
}else{
System.out.println("绑定日期迟于查询历史信息日期");
List<Long> repeIdList = this.menuAppRecipeMapper.getRecipeIdListByRecipeId(content.getRecipeId());
recipeIdList = this.menuAppRecipeMapper.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.menuAppRecipeMapper.selectWeekRecipeId(content.getRecipeId(), null);
} else {
System.out.println("applyDate 等于当前日期");
recipeIdList = this.menuAppRecipeMapper.selectWeekRecipeId(content.getRecipeId(), null);
}
if(recipeIdList == null || recipeIdList.size() == 0){
throw new ServiceException("本档口没有更早的历史菜谱记录");
// recipeIdList.add(content.getRecipeId());
}
// ((List) recipeIdList).add(content.getRecipeId());
}
this.generateRecipe((List) recipeIdList, content.getApplyDate());

View File

@ -335,4 +335,31 @@
<!-- #{effId}-->
<!-- </foreach>-->
<!-- </select>-->
<select id="selectWeekRecipeIdHistory" resultType="java.lang.Long">
select
mar.recipe_id
from
menu_app_recipe_history mar
left join menu_recipe mr on mar.recipe_id = mr.recipe_id
where
bind_type = 3
and mar.recipe_id in
<foreach collection="recipeIdList" item="repiceId" separator="," open="(" close=")">
#{repiceId}
</foreach>
and #{applyDate} >= DATE(mar.bind_time)
ORDER BY bind_time desc limit 1
</select>
<select id="getRecipeIdListByRecipeId" resultType="java.lang.Long">
select recipe_id from menu_recipe where stall_id = (select stall_id from menu_recipe where recipe_id = #{recipeId})
</select>
<select id="getBingTimeByRecipeId" resultType="java.lang.String">
select bind_time from menu_app_recipe where recipe_id = #{recipeId}
</select>
</mapper>