lxy_01 2 hafta önce
ebeveyn
işleme
e473254ed1

+ 1 - 1
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/controller/MealTypesController.java

@@ -85,7 +85,7 @@ public class MealTypesController {
     }
 
     @RequestMapping("/getMealTypeList")
-    private HttpRespMsg getMealTypeList() {
+    public HttpRespMsg getMealTypeList() {
         return mealTypesService.getMealTypeList();
     }
 

+ 52 - 16
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/service/impl/MealApplicationsServiceImpl.java

@@ -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;
@@ -233,6 +234,25 @@ 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 :
+                    case  3:
+                        mealMap.put("statusString","缺餐");
+                        break;
+                    case 1:
+                        mealMap.put("statusString","已就餐");
+                        break;
+                    case 2:
+                    default:
+                        mealMap.put("statusString","未报餐");
+                        break;
+                }
+            }
+
         }
 
         //
@@ -250,6 +270,7 @@ public class MealApplicationsServiceImpl extends ServiceImpl<MealApplicationsMap
                     switch (status) {
                         case 0 :
                             ApplyAmount += 1;
+                            overLine += 1;
                             break;
                         case 1:
                             ApplyAmount += 1;
@@ -259,7 +280,7 @@ public class MealApplicationsServiceImpl extends ServiceImpl<MealApplicationsMap
                             cancel += 1;
                         case  3:
                             ApplyAmount += 1;
-                            cancel += 1;
+                            overLine += 1;
                             break;
                         default:
                             break;
@@ -278,32 +299,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){
@@ -343,4 +355,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();
+    }
 }