|
|
@@ -1,5 +1,6 @@
|
|
|
package com.management.platform.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
@@ -221,6 +222,9 @@ public class MealApplicationsServiceImpl extends ServiceImpl<MealApplicationsMap
|
|
|
queryWrapper.orderByAsc("department_id");
|
|
|
IPage<User> userIPage = userMapper.selectPage(new Page<>(pageIndex, pageSize), queryWrapper);
|
|
|
List<User> userList = userIPage.getRecords();
|
|
|
+ if(userList.isEmpty()){
|
|
|
+ userList = new ArrayList<>();
|
|
|
+ }
|
|
|
|
|
|
//先将数据全部取出来,再根据人员和部门进行筛选
|
|
|
List<Map<String,Object>> mealList = mealApplicationsMapper.getMealList(companyId,startDate,endDate,deptIdList,userId,mealTypeIdString);
|
|
|
@@ -233,6 +237,26 @@ public class MealApplicationsServiceImpl extends ServiceImpl<MealApplicationsMap
|
|
|
mealMap.put("date",sdf.format(date));
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ Integer status = (Integer) mealMap.get("status");
|
|
|
+ if (status != null) {
|
|
|
+ switch (status) {
|
|
|
+ case 0 :
|
|
|
+ mealMap.put("statusString","已报餐");
|
|
|
+ case 3:
|
|
|
+ mealMap.put("statusString","缺餐");
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ mealMap.put("statusString","已就餐");
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ default:
|
|
|
+ mealMap.put("statusString","未报餐");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//
|
|
|
@@ -250,6 +274,7 @@ public class MealApplicationsServiceImpl extends ServiceImpl<MealApplicationsMap
|
|
|
switch (status) {
|
|
|
case 0 :
|
|
|
ApplyAmount += 1;
|
|
|
+ overLine += 1;
|
|
|
break;
|
|
|
case 1:
|
|
|
ApplyAmount += 1;
|
|
|
@@ -259,7 +284,7 @@ public class MealApplicationsServiceImpl extends ServiceImpl<MealApplicationsMap
|
|
|
cancel += 1;
|
|
|
case 3:
|
|
|
ApplyAmount += 1;
|
|
|
- cancel += 1;
|
|
|
+ overLine += 1;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
@@ -278,32 +303,23 @@ public class MealApplicationsServiceImpl extends ServiceImpl<MealApplicationsMap
|
|
|
|
|
|
mealList.addAll(totalList);
|
|
|
|
|
|
-
|
|
|
- List<Map<String,Object>> records= new ArrayList<>();
|
|
|
- if(!StringUtils.isEmpty(deptIds)){
|
|
|
- String[] split = deptIds.split(",");
|
|
|
- for (String deptId : split) {
|
|
|
- List<Integer> branchDepartment = getBranchDepartment(Integer.valueOf(deptId), departmentList);
|
|
|
- deptIdList.addAll(branchDepartment);
|
|
|
- }
|
|
|
- }
|
|
|
User count = new User();//小计一栏
|
|
|
count.setId("0");
|
|
|
userList.add(count);
|
|
|
-
|
|
|
+ List<Map<String,Object>> records = new ArrayList<>();
|
|
|
for(User itemUser:userList){
|
|
|
Map<String,Object> map=new HashMap<>();
|
|
|
String personId = itemUser.getId();
|
|
|
map.put("userId",itemUser.getId());
|
|
|
map.put("name",itemUser.getName());
|
|
|
if (map.get("userId").equals("0")) {
|
|
|
- map.put("name","小计");
|
|
|
+ map.put("departmentName","小计");
|
|
|
}
|
|
|
map.put("departmentId",itemUser.getDepartmentId());
|
|
|
- String departmentName="未设置部门";
|
|
|
-
|
|
|
- Integer departmentId = Integer.valueOf(String.valueOf(map.get("departmentId")));
|
|
|
- map.put("departmentName", getBranchDepartment(departmentId, departmentList));
|
|
|
+ if(map.get("departmentId")!=null){
|
|
|
+ Integer departmentId = Integer.valueOf(String.valueOf(map.get("departmentId")));
|
|
|
+ map.put("departmentName", convertDepartmentIdToCascade(departmentId, departmentList));
|
|
|
+ }
|
|
|
|
|
|
List<Map<String,Object>> personList = new ArrayList<>();
|
|
|
if (personId!= null){
|
|
|
@@ -311,6 +327,37 @@ public class MealApplicationsServiceImpl extends ServiceImpl<MealApplicationsMap
|
|
|
}
|
|
|
map.put("personList",personList);
|
|
|
|
|
|
+ if(map.get("userId")!= null && !map.get("userId").equals("0")){
|
|
|
+ //非小计合计
|
|
|
+ //已申请
|
|
|
+ map.put("totalApplication",personList.stream().filter(p ->
|
|
|
+ new Integer(0).equals(p.get("status"))).count());
|
|
|
+ //已用餐
|
|
|
+ map.put("totalGetMeal",personList.stream().filter(p ->
|
|
|
+ new Integer(1).equals(p.get("status"))).count());
|
|
|
+ //已过期
|
|
|
+ map.put("totalOverLine",personList.stream().filter(p ->
|
|
|
+ new Integer(3).equals(p.get("status"))).count());
|
|
|
+ }
|
|
|
+ else if (map.get("userId")!= null && map.get("userId").equals("0")){
|
|
|
+ //小计合计
|
|
|
+ //已报餐人数
|
|
|
+ map.put("totalApplication",personList.stream()
|
|
|
+ .filter(p -> p.get("applyAmount")!=null)
|
|
|
+ .map(person -> person.get("applyAmount"))
|
|
|
+ .reduce(0,(a,b) -> (Integer)a + (Integer) b));
|
|
|
+ //已取餐
|
|
|
+ map.put("totalGetMeal",personList.stream()
|
|
|
+ .filter(p -> p.get("getMeal")!=null)
|
|
|
+ .map(person -> person.get("getMeal"))
|
|
|
+ .reduce(0,(a,b) -> (Integer)a + (Integer) b));
|
|
|
+ //已过期
|
|
|
+ map.put("totalOverLine",personList.stream()
|
|
|
+ .filter(p -> p.get("overLine")!=null)
|
|
|
+ .map(person -> person.get("overLine"))
|
|
|
+ .reduce(0,(a,b) -> (Integer)a + (Integer) b));
|
|
|
+ }
|
|
|
+
|
|
|
records.add(map);
|
|
|
}
|
|
|
resultMap.put("total",userIPage.getTotal());
|
|
|
@@ -343,4 +390,28 @@ public class MealApplicationsServiceImpl extends ServiceImpl<MealApplicationsMap
|
|
|
}
|
|
|
return list;
|
|
|
}
|
|
|
+
|
|
|
+ //将部门id转换为部门层级
|
|
|
+ private String convertDepartmentIdToCascade(Integer id, List<Department> allDeptList) {
|
|
|
+ StringBuilder cascade = new StringBuilder();
|
|
|
+ Integer finalId = id;
|
|
|
+ Optional<Department> first = allDeptList.stream().filter(al -> finalId != null && finalId.equals(al.getDepartmentId())).findFirst();
|
|
|
+ if (!first.isPresent()) {
|
|
|
+ cascade.append("未设置部门");
|
|
|
+ } else {
|
|
|
+ cascade.append(first.get().getDepartmentName());
|
|
|
+ id = findById(id, allDeptList).getSuperiorId();
|
|
|
+ while (id != null) {
|
|
|
+ Integer finalId1 = id;
|
|
|
+ Optional<Department> first1 = allDeptList.stream().filter(al -> finalId1 != null && finalId1.equals(al.getDepartmentId())).findFirst();
|
|
|
+ cascade.append("/").append(first1.get().getDepartmentName());
|
|
|
+ id = findById(id, allDeptList).getSuperiorId();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return cascade.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ private Department findById(int id, List<Department> allList) {
|
|
|
+ return allList.stream().filter(all->all.getDepartmentId().intValue() == id).findFirst().get();
|
|
|
+ }
|
|
|
}
|