降低双屏机菜谱获取数据复杂度
This commit is contained in:
parent
19ec96e0dc
commit
411e376d79
|
|
@ -10,7 +10,6 @@ import com.bonus.common.core.web.domain.AjaxResult;
|
|||
import com.bonus.common.houqin.constant.GlobalConstants;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
|
@ -162,6 +161,27 @@ public class DeviceServiceImpl implements DeviceService {
|
|||
//查询所有的餐次
|
||||
List<CookMealTimeVO> mealTimeList = mapper.getMealTimeList(menuRecipe.getStallId());
|
||||
List<CookRecipeDateCompressVO> dateList = new ArrayList<>();
|
||||
setMealDataByDate(applyDateList, mealTimeList, menuRecipeDetailList, recipeDishList, dateList);
|
||||
logger.info("menuRecipe : {} ", menuRecipe);
|
||||
|
||||
if(menuRecipe.getRecipeType() !=null){
|
||||
issueRecipe.setRecipeType(Integer.valueOf(menuRecipe.getRecipeType()+""));
|
||||
}
|
||||
issueRecipe.setRecipeId(menuRecipe.getRecipeId());
|
||||
if(menuRecipe.getUpdateTime() !=null) {
|
||||
issueRecipe.setUptime(menuRecipe.getUpdateTime().toInstant()
|
||||
.atZone(ZoneId.systemDefault())
|
||||
.toLocalDateTime());
|
||||
} else {
|
||||
issueRecipe.setUptime(LocalDateTime.now());
|
||||
|
||||
}
|
||||
issueRecipe.setDateList(dateList);
|
||||
issueRecipe.setMealList(menuList);
|
||||
return issueRecipe;
|
||||
}
|
||||
|
||||
private static void setMealDataByDate(List<LocalDate> applyDateList, List<CookMealTimeVO> mealTimeList, List<CookMenuAndroidRecipeDetailVO> menuRecipeDetailList, List<CookRecipeDetailCompressVO> recipeDishList, List<CookRecipeDateCompressVO> dateList) {
|
||||
for (LocalDate date : applyDateList){
|
||||
CookRecipeDateCompressVO dateCompressVO = new CookRecipeDateCompressVO();
|
||||
List<CookRecipeIntervalCompressVO> intervalList = new ArrayList<>();
|
||||
|
|
@ -184,23 +204,6 @@ public class DeviceServiceImpl implements DeviceService {
|
|||
dateCompressVO.setIntervalList(intervalList);
|
||||
dateList.add(dateCompressVO);
|
||||
}
|
||||
logger.info("menuRecipe : {} ", menuRecipe);
|
||||
|
||||
if(menuRecipe.getRecipeType() !=null){
|
||||
issueRecipe.setRecipeType(Integer.valueOf(menuRecipe.getRecipeType()+""));
|
||||
}
|
||||
issueRecipe.setRecipeId(menuRecipe.getRecipeId());
|
||||
if(menuRecipe.getUpdateTime() !=null) {
|
||||
issueRecipe.setUptime(menuRecipe.getUpdateTime().toInstant()
|
||||
.atZone(ZoneId.systemDefault())
|
||||
.toLocalDateTime());
|
||||
} else {
|
||||
issueRecipe.setUptime(LocalDateTime.now());
|
||||
|
||||
}
|
||||
issueRecipe.setDateList(dateList);
|
||||
issueRecipe.setMealList(menuList);
|
||||
return issueRecipe;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import com.bonus.common.core.exception.ServiceException;
|
|||
import com.bonus.common.core.utils.DateUtils;
|
||||
import com.bonus.common.core.utils.StringUtils;
|
||||
import com.bonus.common.houqin.constant.GlobalConstants;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.bonus.canteen.core.device.mapper.DeviceInfoMapper;
|
||||
import com.bonus.canteen.core.device.domain.DeviceInfo;
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ public class DataScreeningServiceImpl implements DataScreeningService {
|
|||
private static final String DISH = "Dish";
|
||||
private static final int MAX_LAST_DAY = -29;
|
||||
|
||||
private static final String YYYY_MM_DD = "yyyy-MM-dd";
|
||||
|
||||
/**
|
||||
* 获取数据总览
|
||||
*
|
||||
|
|
@ -175,7 +177,7 @@ public class DataScreeningServiceImpl implements DataScreeningService {
|
|||
? mapper.getCanteenOrdersAndSalesTrends(date, DateUtils.getDate())
|
||||
: mapper.getSupermarketOrderAndSalesTrend(date, DateUtils.getDate());
|
||||
|
||||
List<String> dateList = getDatesBetween(date, DateUtils.getDate(), "yyyy-MM-dd");
|
||||
List<String> dateList = getDatesBetween(date, DateUtils.getDate(), YYYY_MM_DD);
|
||||
// 将list中的数据放入map中,key为orderDate,value为EchartsVO 提升查询效率
|
||||
Map<String, EchartsVO> dataMap = list.stream()
|
||||
.collect(Collectors.toMap(EchartsVO::getOrderDate, vo -> vo, (a, b) -> a));
|
||||
|
|
@ -253,7 +255,7 @@ public class DataScreeningServiceImpl implements DataScreeningService {
|
|||
Calendar calendar = Calendar.getInstance();
|
||||
// 日期减去一天
|
||||
calendar.add(Calendar.DATE, day);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(YYYY_MM_DD);
|
||||
return sdf.format(calendar.getTime());
|
||||
}
|
||||
|
||||
|
|
@ -291,13 +293,15 @@ public class DataScreeningServiceImpl implements DataScreeningService {
|
|||
*/
|
||||
private String getWeekday(String dateStr) {
|
||||
try {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(YYYY_MM_DD);
|
||||
Date date = sdf.parse(dateStr);
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
String[] weekDays = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
|
||||
int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK) - 1;
|
||||
if (dayOfWeek < 0) dayOfWeek = 0;
|
||||
if (dayOfWeek < 0){
|
||||
dayOfWeek = 0;
|
||||
}
|
||||
return weekDays[dayOfWeek];
|
||||
} catch (Exception e) {
|
||||
log.error("日期转换异常", e);
|
||||
|
|
|
|||
Loading…
Reference in New Issue