循环菜谱详情
This commit is contained in:
parent
98b84d2fd2
commit
5347588130
|
|
@ -16,14 +16,11 @@ 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.cook.domain.CookRecipe;
|
||||
import com.bonus.canteen.core.cook.service.ICookRecipeService;
|
||||
import com.bonus.common.core.web.controller.BaseController;
|
||||
|
|
@ -44,15 +41,6 @@ public class CookRecipeController extends BaseController {
|
|||
@Autowired
|
||||
private ICookRecipeService cookRecipeService;
|
||||
|
||||
@ApiOperation(value = "当前菜谱")
|
||||
//@RequiresPermissions("menu:recipe:list")
|
||||
@GetMapping("/currentList")
|
||||
public TableDataInfo currentList(CookRecipeDTO content) {
|
||||
startPage();
|
||||
List<CookRecipeVO> list = cookRecipeService.selectCookRecipeListV2(content);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询菜品计划信息列表
|
||||
*/
|
||||
|
|
@ -65,6 +53,15 @@ public class CookRecipeController extends BaseController {
|
|||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "当前菜谱")
|
||||
//@RequiresPermissions("menu:recipe:list")
|
||||
@GetMapping("/currentList")
|
||||
public TableDataInfo currentList(CookRecipeDTO content) {
|
||||
startPage();
|
||||
List<CookRecipeVO> list = cookRecipeService.selectCookRecipeList4Current(content);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出菜品计划信息列表
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@ public class CookRecipe extends BaseEntity {
|
|||
|
||||
private String canteenName;
|
||||
|
||||
private Long areaId;
|
||||
|
||||
private String areaName;
|
||||
|
||||
/** 菜品计划id(数据同步) */
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@ public interface ICookRecipeService {
|
|||
*/
|
||||
public CookRecipe selectCookRecipeByRecipeId(Long recipeId);
|
||||
|
||||
public List<CookRecipeVO> selectCookRecipeListV2(CookRecipeDTO dto);
|
||||
|
||||
/**
|
||||
* 查询菜品计划信息列表
|
||||
*
|
||||
|
|
@ -33,6 +31,8 @@ public interface ICookRecipeService {
|
|||
*/
|
||||
public List<CookRecipe> selectCookRecipeList(CookRecipe cookRecipe);
|
||||
|
||||
public List<CookRecipeVO> selectCookRecipeList4Current(CookRecipeDTO dto);
|
||||
|
||||
public List<CookRecipeDetailVO> getRecipeDetailByDate(CookRecipeDetailDTO dto);
|
||||
|
||||
public List<CookRecipeDetailVO> getRecipeDetail(CookRecipeDetailDTO dto);
|
||||
|
|
|
|||
|
|
@ -67,16 +67,60 @@ public class CookRecipeServiceImpl implements ICookRecipeService {
|
|||
*/
|
||||
@Override
|
||||
public CookRecipe selectCookRecipeByRecipeId(Long recipeId) {
|
||||
//TODO 构造菜谱之菜品详情VO
|
||||
|
||||
//TODO 狗仔菜谱之执行计划VO
|
||||
|
||||
//TODO 狗仔菜谱VO
|
||||
|
||||
return cookRecipeMapper.selectCookRecipeByRecipeId(recipeId);
|
||||
}
|
||||
|
||||
public List<CookRecipeVO> selectCookRecipeListV2(CookRecipeDTO content) {
|
||||
/**
|
||||
* 查询菜品计划信息列表
|
||||
*
|
||||
* @param cookRecipe 菜品计划信息
|
||||
* @return 菜品计划信息
|
||||
*/
|
||||
@Override
|
||||
public List<CookRecipe> selectCookRecipeList(CookRecipe cookRecipe) {
|
||||
List<CookRecipe> list = cookRecipeMapper.selectCookRecipeList(cookRecipe);
|
||||
// for (CookRecipe recipe : list) {
|
||||
// if (1 == recipe.getRecipeType()) {
|
||||
// recipe.setDishesCount(cookRecipeMapper.getDishesCount4PointDates(recipe.getRecipeId()));
|
||||
// } else {
|
||||
// recipe.setDishesCount(cookRecipeMapper.getDishesCount4Recycle(recipe.getRecipeId()));
|
||||
// }
|
||||
// }
|
||||
List<LocalDate> lastWeekDate = DateUtil.getLastWeekDate();
|
||||
List<Long> recipeIds = list.stream().map(CookRecipe::getRecipeId).collect(Collectors.toList());
|
||||
List<CookRecipeDishesCountVO> dishesCountByRecipeIdsList = cookRecipeMapper.getDishesCountByRecipeIds(recipeIds);
|
||||
Map<Long, Integer> dishesCountByRecipeIds = dishesCountByRecipeIdsList.stream().collect(Collectors.toMap(CookRecipeDishesCountVO::getRecipeId, CookRecipeDishesCountVO::getCount));
|
||||
List<CookRecipeDetailVO> recipeDatesList = this.cookRecipeMapper.selectApplyDateListByRecipeId(LocalDate.now(), recipeIds);
|
||||
Map<Long, TreeSet<LocalDate>> recipeDates = recipeDatesList.stream().collect(Collectors.groupingBy(CookRecipeDetailVO::getRecipeId, Collectors.mapping(CookRecipeDetailVO::getApplyDate, Collectors.toCollection(TreeSet::new))));
|
||||
if (list.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
list.forEach(r -> {
|
||||
Long recipeId = r.getRecipeId();
|
||||
r.setDishesCount(dishesCountByRecipeIds.getOrDefault(recipeId, 0));
|
||||
Set<LocalDate> applyDateList = recipeDates.getOrDefault(recipeId, new TreeSet<>());
|
||||
Object finalDate;
|
||||
if (ObjectUtil.equal(r.getRecipeType(), 3)) {
|
||||
Stream<LocalDate> localDateStream = lastWeekDate.stream();
|
||||
Objects.requireNonNull(applyDateList);
|
||||
finalDate = localDateStream.filter(applyDateList::contains).collect(Collectors.toList());
|
||||
} else if (ObjectUtil.equal(r.getRecipeType(), 2)) {
|
||||
finalDate = DateUtil.getLastWeek();
|
||||
} else {
|
||||
finalDate = new ArrayList<>(applyDateList);
|
||||
}
|
||||
List<String> applyDateStringList = Lists.newArrayList();
|
||||
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("MM-dd");
|
||||
((List) finalDate).forEach(d -> {
|
||||
applyDateStringList.add(dateTimeFormatter.format((TemporalAccessor) d));
|
||||
});
|
||||
r.setApplyDateList((List) finalDate);
|
||||
r.setApplyDateStringList(applyDateStringList);
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<CookRecipeVO> selectCookRecipeList4Current(CookRecipeDTO content) {
|
||||
Map<Integer, CookRecipeSortEnum> bindTypeMap = CookRecipeSortEnum.getKeyMap();
|
||||
CookRecipeSortEnum sortEnum = bindTypeMap.get(content.getKey());
|
||||
List<CookRecipeVO> records = new ArrayList<>();
|
||||
|
|
@ -131,56 +175,6 @@ public class CookRecipeServiceImpl implements ICookRecipeService {
|
|||
return records;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询菜品计划信息列表
|
||||
*
|
||||
* @param cookRecipe 菜品计划信息
|
||||
* @return 菜品计划信息
|
||||
*/
|
||||
@Override
|
||||
public List<CookRecipe> selectCookRecipeList(CookRecipe cookRecipe) {
|
||||
List<CookRecipe> list = cookRecipeMapper.selectCookRecipeList(cookRecipe);
|
||||
// for (CookRecipe recipe : list) {
|
||||
// if (1 == recipe.getRecipeType()) {
|
||||
// recipe.setDishesCount(cookRecipeMapper.getDishesCount4PointDates(recipe.getRecipeId()));
|
||||
// } else {
|
||||
// recipe.setDishesCount(cookRecipeMapper.getDishesCount4Recycle(recipe.getRecipeId()));
|
||||
// }
|
||||
// }
|
||||
List<LocalDate> lastWeekDate = DateUtil.getLastWeekDate();
|
||||
List<Long> recipeIds = list.stream().map(CookRecipe::getRecipeId).collect(Collectors.toList());
|
||||
List<CookRecipeDishesCountVO> dishesCountByRecipeIdsList = cookRecipeMapper.getDishesCountByRecipeIds(recipeIds);
|
||||
Map<Long, Integer> dishesCountByRecipeIds = dishesCountByRecipeIdsList.stream().collect(Collectors.toMap(CookRecipeDishesCountVO::getRecipeId, CookRecipeDishesCountVO::getCount));
|
||||
List<CookRecipeDetailVO> recipeDatesList = this.cookRecipeMapper.selectApplyDateListByRecipeId(LocalDate.now(), recipeIds);
|
||||
Map<Long, TreeSet<LocalDate>> recipeDates = recipeDatesList.stream().collect(Collectors.groupingBy(CookRecipeDetailVO::getRecipeId, Collectors.mapping(CookRecipeDetailVO::getApplyDate, Collectors.toCollection(TreeSet::new))));
|
||||
if (list.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
list.forEach(r -> {
|
||||
Long recipeId = r.getRecipeId();
|
||||
r.setDishesCount(dishesCountByRecipeIds.getOrDefault(recipeId, 0));
|
||||
Set<LocalDate> applyDateList = recipeDates.getOrDefault(recipeId, new TreeSet<>());
|
||||
Object finalDate;
|
||||
if (ObjectUtil.equal(r.getRecipeType(), 3)) {
|
||||
Stream<LocalDate> localDateStream = lastWeekDate.stream();
|
||||
Objects.requireNonNull(applyDateList);
|
||||
finalDate = localDateStream.filter(applyDateList::contains).collect(Collectors.toList());
|
||||
} else if (ObjectUtil.equal(r.getRecipeType(), 2)) {
|
||||
finalDate = DateUtil.getLastWeek();
|
||||
} else {
|
||||
finalDate = new ArrayList<>(applyDateList);
|
||||
}
|
||||
List<String> applyDateStringList = Lists.newArrayList();
|
||||
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("MM-dd");
|
||||
((List) finalDate).forEach(d -> {
|
||||
applyDateStringList.add(dateTimeFormatter.format((TemporalAccessor) d));
|
||||
});
|
||||
r.setApplyDateList((List) finalDate);
|
||||
r.setApplyDateStringList(applyDateStringList);
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CookRecipeDetailVO> getRecipeDetailByDate(CookRecipeDetailDTO dto) {
|
||||
List<CookRecipeDetailVO> menuRecipeDetails = cookRecipeMapper.selectRecipeDetailList(dto.getRecipeId(), dto.getApplyDate());
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="stallName" column="stall_name" />
|
||||
<result property="canteenId" column="canteen_id" />
|
||||
<result property="canteenName" column="canteen_name" />
|
||||
<result property="areaId" column="area_id" />
|
||||
<result property="areaName" column="area_name" />
|
||||
<result property="planId" column="plan_id" />
|
||||
<result property="effectDate" column="effect_date" />
|
||||
|
|
@ -51,7 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<sql id="selectCookRecipeVo">
|
||||
select cr.recipe_id, cr.recipe_name, cr.recipe_type, cr.stall_id, cr.canteen_id, cr.plan_id, cr.effect_date,
|
||||
cr.expire_date, cr.create_by, cr.create_time, cr.update_by, cr.update_time, cr.del_flag,
|
||||
bs.stall_name, bc.canteen_name, ba.area_name
|
||||
bs.stall_name, bc.canteen_name, ba.area_name, ba.area_id
|
||||
from cook_recipe cr
|
||||
left join basic_stall bs on bs.stall_id = cr.stall_id
|
||||
left join basic_canteen bc on bc.canteen_id = bs.canteen_id
|
||||
|
|
|
|||
Loading…
Reference in New Issue