Просмотр исходного кода

2023-10-24 实验室危险源统计数轴。

chaiyunlong лет назад: 2
Родитель
Сommit
d22b416448

+ 36 - 22
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabHazardController.java

@@ -38,10 +38,7 @@ import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import java.text.DecimalFormat;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -343,33 +340,50 @@ public class LabHazardController extends BaseController {
 
         //Map<String, List<LabHazardSubjectRelation>> backMap = new HashMap<>();
 
-        List<LabHazardSubjectRelation> backtList = new ArrayList<>();
+        Map<String,Object> allMap = new HashMap <>();
+
+        List<Map<String,Object>> backtList = new ArrayList<>();
+        Set <String> deptNames = new HashSet <>();
 
         if(!bottleConfigMap.isEmpty()){
-            for (Map.Entry entry : bottleConfigMap.entrySet()) {
-                LabHazardSubjectRelation relation1 = new LabHazardSubjectRelation();
-                List<LabHazardSubjectRelation> hazardtList = new ArrayList<>();
-                Object Key = entry.getKey();
-                //Object value = entry.getValue();
-                relation1.setDeptName(Key+"");
-                // 循环字典
-                for (SysDictData dicData:dictDataList) {
-                    LabHazardSubjectRelation re = new LabHazardSubjectRelation();
-                    re.setTotalNum(0);
-                    re.setHazardTypeModeName(dicData.getDictLabel());
-                    // 循环数据源
+            for (SysDictData dicData:dictDataList) {
+                Map<String,Object> hazardMap = new HashMap <>();
+//                LabHazardSubjectRelation re = new LabHazardSubjectRelation();
+//                re.setTotalNum(0);
+//                re.setHazardTypeModeName(dicData.getDictLabel());
+                hazardMap.put("name",dicData.getDictLabel());
+                List<Integer> hazardtList = new ArrayList<>();
+                for (Map.Entry entry : bottleConfigMap.entrySet()) {
+//                    LabHazardSubjectRelation relation1 = new LabHazardSubjectRelation();
+//                    hazardtList.add(entry.getKey()+"");
+//
+                    Object Key = entry.getKey();
+                    deptNames.add(Key+"");
+//                    //Object value = entry.getValue();
+//                    relation1.setDeptName(Key+"");
+                    // 循环字典
+                    Integer deptCount = 0;
+
+//                    // 循环数据源
                     for (LabHazardSubjectRelation lsr:list) {
+
                         if(Key.toString().equals(lsr.getDeptName()) && dicData.getDictLabel().equals(lsr.getHazardTypeModeName())){
-                            re.setTotalNum(lsr.getTotalNum());
+                            deptCount = lsr.getTotalNum();
+//                            hazardtList.add(lsr.getTotalNum());
+//                            re.setTotalNum(lsr.getTotalNum());
                         }
                     }
-                    hazardtList.add(re);
+                    hazardtList.add(deptCount);
+//                    hazardtList.add(re);
+//                    relation1.setRelationList(hazardtList);
                 }
-                relation1.setRelationList(hazardtList);
-                backtList.add(relation1);
+                hazardMap.put("data",hazardtList);
+                backtList.add(hazardMap);
             }
         }
 
+        allMap.put("list",backtList);
+        allMap.put("deptNames",deptNames);
         //map.put("hazard",dictDataList);
         //map.put("backMap",backMap);
 
@@ -395,7 +409,7 @@ public class LabHazardController extends BaseController {
         }
         map.put("hazard",dictDataList);
         map.put("list",backList);*/
-        return ResultData.success(backtList);
+        return ResultData.success(allMap);
     }
 
     /**