diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/android/service/impl/DeviceServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/android/service/impl/DeviceServiceImpl.java index d6d2a09..9be9105 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/android/service/impl/DeviceServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/android/service/impl/DeviceServiceImpl.java @@ -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 mealTimeList = mapper.getMealTimeList(menuRecipe.getStallId()); List 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 applyDateList, List mealTimeList, List menuRecipeDetailList, List recipeDishList, List dateList) { for (LocalDate date : applyDateList){ CookRecipeDateCompressVO dateCompressVO = new CookRecipeDateCompressVO(); List 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; } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/service/impl/DeviceInfoServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/service/impl/DeviceInfoServiceImpl.java index 0991de1..1af696e 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/service/impl/DeviceInfoServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/service/impl/DeviceInfoServiceImpl.java @@ -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; diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/screening/service/DataScreeningServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/screening/service/DataScreeningServiceImpl.java index b77ae6d..46fd720 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/screening/service/DataScreeningServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/screening/service/DataScreeningServiceImpl.java @@ -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 dateList = getDatesBetween(date, DateUtils.getDate(), "yyyy-MM-dd"); + List dateList = getDatesBetween(date, DateUtils.getDate(), YYYY_MM_DD); // 将list中的数据放入map中,key为orderDate,value为EchartsVO 提升查询效率 Map 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);