|
|
@@ -48,15 +48,9 @@ public class MealApplicationsServiceImpl extends ServiceImpl<MealApplicationsMap
|
|
|
private DepartmentMapper departmentMapper;
|
|
|
|
|
|
|
|
|
- @Override
|
|
|
- public HttpRespMsg getDinnerBookingList(String date) {
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
//获取当天订餐列表
|
|
|
@Override
|
|
|
- public HttpRespMsg getDinnerBookingList(String date, Integer status) {
|
|
|
+ public HttpRespMsg getDinnerBookingList(String date, Integer status, Integer mealTypeId) {
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
String factoryCode = request.getHeader("factoryCode");
|
|
|
if (factoryCode == null) {
|
|
|
@@ -72,10 +66,11 @@ public class MealApplicationsServiceImpl extends ServiceImpl<MealApplicationsMap
|
|
|
List<MealTypes> mealTypesList = mealTypesMapper.selectList(new QueryWrapper<MealTypes>());
|
|
|
//按收银机所在厂区查看
|
|
|
QueryWrapper<MealApplications> queryWrapper = new QueryWrapper<MealApplications>()
|
|
|
- .eq("factory_id", factoryItem.getId()).eq("application_date", date).orderByDesc("id");
|
|
|
+ .eq("factory_id", factoryItem.getId()).eq("meal_type_id", mealTypeId).eq("application_date", date).orderByDesc("id");
|
|
|
if (status != null && status != -1) {
|
|
|
queryWrapper.eq("status", status);
|
|
|
}
|
|
|
+ queryWrapper.orderByAsc("status");//让待使用的在上面,已核销的在下面
|
|
|
List<MealApplications> mealApplicationsList = mealApplicationsMapper.selectList(queryWrapper);
|
|
|
//绑定数据
|
|
|
for (MealApplications mealApplications : mealApplicationsList) {
|
|
|
@@ -147,10 +142,10 @@ public class MealApplicationsServiceImpl extends ServiceImpl<MealApplicationsMap
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public HttpRespMsg getTodayStatistics() {
|
|
|
+ public HttpRespMsg getStatistics(String date, Integer mealTypeId) {
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
String factoryCode = request.getHeader("factoryCode");
|
|
|
- System.out.println("getTodayStatistics, factoryCode:"+factoryCode);
|
|
|
+ System.out.println("getStatistics, factoryCode:"+factoryCode);
|
|
|
if (factoryCode == null) {
|
|
|
msg.setError("factory is null");
|
|
|
return msg;
|
|
|
@@ -160,23 +155,22 @@ public class MealApplicationsServiceImpl extends ServiceImpl<MealApplicationsMap
|
|
|
msg.setError("factory not exists");
|
|
|
return msg;
|
|
|
}
|
|
|
- //取今天的
|
|
|
- String date = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
-
|
|
|
- QueryWrapper<MealApplications> queryWrapper = new QueryWrapper<MealApplications>().eq("factory_id", factoryItem.getId()).eq("application_date", date).ne("status", 2);
|
|
|
- List<MealApplications> mealApplicationsList = mealApplicationsMapper.selectList(queryWrapper);
|
|
|
- //按用餐类型统计人数
|
|
|
- List<MealTypes> mealTypesList = mealTypesMapper.selectList(new QueryWrapper<MealTypes>().eq("is_active", 1));
|
|
|
- for (MealTypes mealTypes : mealTypesList) {
|
|
|
- int count = 0;
|
|
|
- for (MealApplications mealApplications : mealApplicationsList) {
|
|
|
- if (mealTypes.getId().equals(mealApplications.getMealTypeId())) {
|
|
|
- count++;
|
|
|
- }
|
|
|
- }
|
|
|
- mealTypes.setCount(count);
|
|
|
+ //默认取今天的
|
|
|
+ if (StringUtils.isEmpty(date)) {
|
|
|
+ date = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
}
|
|
|
- msg.setData(mealTypesList);
|
|
|
+ System.out.println("mealTypeId=="+mealTypeId+", date=" + date);
|
|
|
+ QueryWrapper<MealApplications> queryWrapper = new QueryWrapper<MealApplications>().eq("factory_id", factoryItem.getId()).eq("meal_type_id", mealTypeId).eq("application_date", date).ne("status", 2);
|
|
|
+ List<MealApplications> mealApplicationsList = mealApplicationsMapper.selectList(queryWrapper);
|
|
|
+ //按状态统计
|
|
|
+ HashMap map = new HashMap();
|
|
|
+ map.put("total", mealApplicationsList.size());
|
|
|
+ long used = mealApplicationsList.stream().filter(mealApplications -> mealApplications.getStatus().equals(1)).count();
|
|
|
+ map.put("used", used);
|
|
|
+ long expired = mealApplicationsList.stream().filter(mealApplications -> mealApplications.getStatus().equals(3)).count();
|
|
|
+ map.put("expired", expired);
|
|
|
+ map.put("left", mealApplicationsList.size() - expired - used);
|
|
|
+ msg.setData(map);
|
|
|
return msg;
|
|
|
}
|
|
|
|