i国网:一周菜谱接入
This commit is contained in:
parent
ea1649d981
commit
684ede633c
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.bonus.canteen.core.zhhq.controller;
|
||||||
|
|
||||||
|
import com.bonus.canteen.core.zhhq.domain.WeekRecipeDTO;
|
||||||
|
import com.bonus.canteen.core.zhhq.service.IZhhqCookRecipeService;
|
||||||
|
import com.bonus.common.core.web.controller.BaseController;
|
||||||
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 菜品计划信息Controller
|
||||||
|
*
|
||||||
|
* @author xsheng
|
||||||
|
* @date 2025-05-25
|
||||||
|
*/
|
||||||
|
@Api(tags = "菜谱h5接口")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/zhhq_cook_recipe")
|
||||||
|
@Slf4j
|
||||||
|
public class ZhhqCookRecipeController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private IZhhqCookRecipeService zhhqCookRecipeService;
|
||||||
|
|
||||||
|
@ApiOperation("获取一周菜谱详情")
|
||||||
|
@PostMapping({"/getWeekRecipe"})
|
||||||
|
public AjaxResult getWeekRecipeDetailList(@RequestBody @Valid WeekRecipeDTO dto) {
|
||||||
|
try {
|
||||||
|
return AjaxResult.success(this.zhhqCookRecipeService.getWeekRecipeDetailList(dto));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.toString(), e);
|
||||||
|
return AjaxResult.error(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.bonus.canteen.core.zhhq.domain;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class WeekRecipeDTO {
|
||||||
|
@ApiModelProperty(value = "食堂id")
|
||||||
|
private Long canteenId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "菜单日期")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
private LocalDate menuDate;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,59 @@
|
||||||
|
package com.bonus.canteen.core.zhhq.domain;
|
||||||
|
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.Base64;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class WeekRecipeDetailVO {
|
||||||
|
@ApiModelProperty(value = "菜单日期")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
private LocalDate menuDate;
|
||||||
|
|
||||||
|
private Long recipeId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "餐次(早中晚)")
|
||||||
|
private int mealType;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "菜品名称")
|
||||||
|
private String cookName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "分类名称")
|
||||||
|
private String typeName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否新品, 1是 2否")
|
||||||
|
private int newType;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否外卖, 1是 2否")
|
||||||
|
private int outType;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否时令推荐, 1是 2否")
|
||||||
|
private int recommendType;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "热量(千卡/100g)")
|
||||||
|
private BigDecimal calories;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "蛋白质(g/100g)")
|
||||||
|
private BigDecimal protein;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "脂肪(g/100g)")
|
||||||
|
private BigDecimal fat;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "碳水化合物(g/100g)")
|
||||||
|
private BigDecimal carbohydrate;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "菜肴单价")
|
||||||
|
private BigDecimal price;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "图片")
|
||||||
|
private String cookPic;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "配料")
|
||||||
|
private List<WeekRecipeIngredientVO> ingredients;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.bonus.canteen.core.zhhq.domain;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class WeekRecipeIngredientVO {
|
||||||
|
@ApiModelProperty(value = "食材名称")
|
||||||
|
private String materialName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "食材重量")
|
||||||
|
private BigDecimal weight;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "热量(千卡/100g)")
|
||||||
|
private BigDecimal calories;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "蛋白质(g/100g)")
|
||||||
|
private BigDecimal protein;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "脂肪(g/100g)")
|
||||||
|
private BigDecimal fat;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "碳水化合物(g/100g)")
|
||||||
|
private BigDecimal carbohydrate;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.bonus.canteen.core.zhhq.domain;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class WeekRecipeVO {
|
||||||
|
@ApiModelProperty(value = "菜谱名称")
|
||||||
|
private String recipeName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "菜谱年份")
|
||||||
|
private int recipeYear;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "开始日期")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
private LocalDate startDate;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "结束日期")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
private LocalDate endDate;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "食堂名称")
|
||||||
|
private String canteenName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "菜谱详情")
|
||||||
|
private List<WeekRecipeDetailVO> recipeDetails;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.bonus.canteen.core.zhhq.mapper;
|
||||||
|
|
||||||
|
import com.bonus.canteen.core.zhhq.domain.WeekRecipeDetailVO;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 菜品计划信息Mapper接口
|
||||||
|
*
|
||||||
|
* @author xsheng
|
||||||
|
* @date 2025-05-25
|
||||||
|
*/
|
||||||
|
public interface ZhhqCookRecipeMapper {
|
||||||
|
public List<Long> selectWeekRecipeList();
|
||||||
|
|
||||||
|
public List<WeekRecipeDetailVO> selectWeekRecipeDetail(@Param("weekDates") List<LocalDate> weekDates, @Param("recipeIds") List<Long> recipeIds);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.bonus.canteen.core.zhhq.service;
|
||||||
|
|
||||||
|
import com.bonus.canteen.core.zhhq.domain.WeekRecipeDTO;
|
||||||
|
import com.bonus.canteen.core.zhhq.domain.WeekRecipeVO;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 菜品计划信息Service接口
|
||||||
|
*
|
||||||
|
* @author xsheng
|
||||||
|
* @date 2025-05-25
|
||||||
|
*/
|
||||||
|
public interface IZhhqCookRecipeService {
|
||||||
|
public WeekRecipeVO getWeekRecipeDetailList(WeekRecipeDTO dto);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
package com.bonus.canteen.core.zhhq.service.impl;
|
||||||
|
|
||||||
|
import com.bonus.canteen.core.basic.domain.BasicCanteen;
|
||||||
|
import com.bonus.canteen.core.basic.mapper.BasicCanteenMapper;
|
||||||
|
import com.bonus.canteen.core.common.utils.DateUtil;
|
||||||
|
import com.bonus.canteen.core.zhhq.domain.WeekRecipeDTO;
|
||||||
|
import com.bonus.canteen.core.zhhq.domain.WeekRecipeDetailVO;
|
||||||
|
import com.bonus.canteen.core.zhhq.domain.WeekRecipeVO;
|
||||||
|
import com.bonus.canteen.core.zhhq.mapper.ZhhqCookRecipeMapper;
|
||||||
|
import com.bonus.canteen.core.zhhq.service.IZhhqCookRecipeService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 菜品计划信息Service业务层处理
|
||||||
|
*
|
||||||
|
* @author xsheng
|
||||||
|
* @date 2025-05-25
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class ZhhqCookRecipeServiceImpl implements IZhhqCookRecipeService {
|
||||||
|
@Autowired
|
||||||
|
private BasicCanteenMapper basicCanteenMapper;
|
||||||
|
@Autowired
|
||||||
|
private ZhhqCookRecipeMapper zhhqCookRecipeMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WeekRecipeVO getWeekRecipeDetailList(WeekRecipeDTO dto) {
|
||||||
|
WeekRecipeVO weekRecipeVO = new WeekRecipeVO();
|
||||||
|
weekRecipeVO.setRecipeName("周菜谱");
|
||||||
|
BasicCanteen basicCanteen = basicCanteenMapper.selectBasicCanteenByCanteenId(dto.getCanteenId());
|
||||||
|
weekRecipeVO.setCanteenName(basicCanteen.getCanteenName());
|
||||||
|
List<LocalDate> weekDates = DateUtil.getWeekDates(dto.getMenuDate());
|
||||||
|
weekRecipeVO.setRecipeYear(dto.getMenuDate().getYear());
|
||||||
|
weekRecipeVO.setStartDate(weekDates.get(0));
|
||||||
|
weekRecipeVO.setEndDate(weekDates.get(weekDates.lastIndexOf(weekDates)));
|
||||||
|
//查询一周菜谱详情
|
||||||
|
List<Long> recipeIds = zhhqCookRecipeMapper.selectWeekRecipeList();
|
||||||
|
List<WeekRecipeDetailVO> recipeDetails = zhhqCookRecipeMapper.selectWeekRecipeDetail(weekDates, recipeIds);
|
||||||
|
//组装原料及营养信息
|
||||||
|
weekRecipeVO.setRecipeDetails(recipeDetails);
|
||||||
|
return weekRecipeVO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,76 @@
|
||||||
|
<?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.zhhq.mapper.ZhhqCookRecipeMapper">
|
||||||
|
<resultMap id="WeekRecipeDetailVO" type="com.bonus.canteen.core.zhhq.domain.WeekRecipeDetailVO">
|
||||||
|
<result property="mealType" column="mealtime_type"/>
|
||||||
|
<result property="typeName" column="type_name"/>
|
||||||
|
<result property="cookName" column="dishes_name"/>
|
||||||
|
<result property="recommendType" column="recommend_flag"/>
|
||||||
|
<result property="price" column="dishes_price"/>
|
||||||
|
<result property="cookPic" column="dishes_img_url"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<select id="selectWeekRecipeList" resultType="Long">
|
||||||
|
select
|
||||||
|
mr.recipe_id
|
||||||
|
from
|
||||||
|
cook_recipe_bind_app mar
|
||||||
|
left join cook_recipe mr on mar.recipe_id = mr.recipe_id
|
||||||
|
left join basic_canteen bc on bc.canteen_id = mr.canteen_id
|
||||||
|
where
|
||||||
|
bind_type = 3 and mr.canteen_id = #{canteenId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectWeekRecipeDetail" resultMap="WeekRecipeDetailVO">
|
||||||
|
select
|
||||||
|
mrd.mealtime_type,
|
||||||
|
if(md.meal_type = 2, 2, mdt.dishes_type_id) as type_id,
|
||||||
|
if(md.meal_type = 2, '套餐', mdt.dishes_type_name) as type_name,
|
||||||
|
md.dishes_id as base_dishes_id,
|
||||||
|
md.dishes_id,
|
||||||
|
md.dishes_name,
|
||||||
|
md.intro,
|
||||||
|
md.image_url as dishes_img_url,
|
||||||
|
mrd.recipe_detail_id as detail_id,
|
||||||
|
m.remanent_num,
|
||||||
|
m.limit_num,
|
||||||
|
m.price as dishes_price,
|
||||||
|
m.sale_price as pref_price,
|
||||||
|
ac.canteen_id,
|
||||||
|
ac.canteen_name,
|
||||||
|
ass.stall_id,
|
||||||
|
ass.stall_name,
|
||||||
|
m.size_type,
|
||||||
|
m.recommend_flag
|
||||||
|
from
|
||||||
|
cook_recipe_detail mrd
|
||||||
|
inner join cook_recipe_dishes m on mrd.recipe_detail_id = m.recipe_detail_id
|
||||||
|
inner join cook_dishes md on m.dishes_id = md.dishes_id
|
||||||
|
inner join cook_dishes_type mdt on md.type_id = mdt.dishes_type_id
|
||||||
|
inner join cook_recipe mr on mrd.recipe_id = mr.recipe_id
|
||||||
|
left join cook_dishes_sale_record mdsr on md.dishes_id = mdsr.dishes_id
|
||||||
|
and mr.stall_id = mdsr.stall_id
|
||||||
|
and mdsr.sale_month = month(curdate())
|
||||||
|
left join basic_canteen ac on mr.canteen_id = ac.canteen_id
|
||||||
|
left join basic_stall ass on mr.stall_id = ass.stall_id
|
||||||
|
where
|
||||||
|
1 = 1
|
||||||
|
<if test="weekDates != null and weekDates.size() > 0">
|
||||||
|
and mrd.apply_date in
|
||||||
|
<foreach collection="weekDates" item="applyDate" open="(" separator="," close=")">
|
||||||
|
#{applyDate}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="recipeIds != null and recipeIds.size() > 0">
|
||||||
|
and mrd.recipe_id in
|
||||||
|
<foreach collection="recipeIds" item="recipeId" open="(" separator="," close=")">
|
||||||
|
#{recipeId}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
order by
|
||||||
|
md.dishes_id asc
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
|
|
||||||
Loading…
Reference in New Issue