From 9a43e3aecfe477dfeae2a32ab758a2f5739614fb Mon Sep 17 00:00:00 2001
From: aijinhui <aijinhui>
Date: 星期二, 19 九月 2023 16:58:33 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 ard-work/src/main/java/com/ruoyi/health/controller/HealthController.java |  110 +++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 87 insertions(+), 23 deletions(-)

diff --git a/ard-work/src/main/java/com/ruoyi/health/controller/HealthController.java b/ard-work/src/main/java/com/ruoyi/health/controller/HealthController.java
index f2bc7f7..ff86ec3 100644
--- a/ard-work/src/main/java/com/ruoyi/health/controller/HealthController.java
+++ b/ard-work/src/main/java/com/ruoyi/health/controller/HealthController.java
@@ -3,9 +3,11 @@
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.ruoyi.alarmpoints.well.domain.ArdAlarmpointsWell;
 import com.ruoyi.alarmpoints.well.domain.ArdAlarmpointsWellDeptVo;
+import com.ruoyi.common.core.domain.HealthVo;
 import com.ruoyi.alarmpoints.well.service.IArdAlarmpointsWellService;
+import com.ruoyi.common.core.domain.TreeSelectWell;
+import com.ruoyi.common.core.domain.TreeSelectWellJson;
 import com.ruoyi.common.core.domain.entity.SysConfig;
 import com.ruoyi.common.core.domain.entity.SysDept;
 import com.ruoyi.common.core.domain.entity.SysUser;
@@ -55,6 +57,8 @@
     @Autowired
     private ISysDeptService sysDeptService;
 
+
+
     @PreAuthorize("@ss.hasPermi('sy:syCar:getEquipmentListByUser')")
     @ApiOperation("鏍规嵁鏉冮檺鑾峰彇璁惧鍒楄〃")
     @GetMapping("getEquipmentListByUser")
@@ -80,8 +84,11 @@
         String longest = "";
         //绛夌骇
         int count0 = 0,count1 = 0,count2 = 0;
+        //瑁呮暟鎹�
+        List<HealthVo> healthVos = new ArrayList<>();
         if ((int) mapResult.get("code") == 200) {
             List<Map<String, Object>> listResult = (List<Map<String, Object>>) JSON.parse((String) mapResult.get("resdata"));
+            //寰幆寰楀埌鏉冮檺涓嬪尮閰嶆暟鎹�
             for (int i = 0; i < listResult.size(); i++) {
                 JSONObject jsonObject = new JSONObject();
                 String equipNumber = (String) listResult.get(i).get("EquipNumber");
@@ -94,23 +101,19 @@
                         String wellId = list.get(j).getWellId();
                         if(wellId!=null){
                             if(wellId.equals(equipNumber)){
-                                String[] ancestorsArray = ancestors.split(",");
-                                int max = ancestorsArray.length;
-                                jsonObject.put("id",listResult.get(i).get("id"));
-                                jsonObject.put("EquipName",listResult.get(i).get("EquipName"));
-                                jsonObject.put("EquipNumber",listResult.get(i).get("EquipNumber"));
-                                jsonObject.put("EquipLevel",listResult.get(i).get("EquipLevel"));
-                                jsonObject.put("MeasureDate",listResult.get(i).get("MeasureDate"));
-                                jsonObject.put("EquipKey",listResult.get(i).get("EquipKey"));
-                                jsonObject.put("longitude",list.get(j).getLongitude());
-                                jsonObject.put("latitude",list.get(j).getLatitude());
-                                jsonObject.put("altitude",list.get(j).getAltitude());
-                                jsonObject.put("deptId",list.get(j).getDeptId());
-                                jsonObject.put("deptName",list.get(j).getDeptName());
-                                jsonObject.put("parentId",list.get(j).getParentId());
-                                jsonObject.put("ancestors",list.get(j).getAncestors());
-                                jsonObject.put("tier",max);
-                                jsonArray.add(jsonObject);
+                                //杩斿洖璁惧鏁版嵁
+                                HealthVo healthVo = new HealthVo();
+                                healthVo.setId((Integer) listResult.get(i).get("id"));
+                                healthVo.setEquipName((String) listResult.get(i).get("EquipName"));
+                                healthVo.setEquipNumber((String) listResult.get(i).get("EquipNumber"));
+                                healthVo.setEquipLevel((String) listResult.get(i).get("EquipLevel"));
+                                healthVo.setEquipKey((String) listResult.get(i).get("EquipKey"));
+                                healthVo.setMeasureDate((String) listResult.get(i).get("MeasureDate"));
+                                healthVo.setLongitude(list.get(j).getLongitude());
+                                healthVo.setLatitude(list.get(j).getLatitude());
+                                healthVo.setAltitude(list.get(j).getAltitude());
+                                healthVo.setDeptId(list.get(j).getDeptId());
+                                healthVos.add(healthVo);
                                 if(listResult.get(i).get("EquipLevel").equals("0")){
                                     count0++;
                                 }else if(listResult.get(i).get("EquipLevel").equals("1")){
@@ -127,11 +130,72 @@
             //鐢ㄩ�楀彿鍒嗛殧瀛楃鍚庣殑size涓烘渶澶х殑缁撴瀯灞傛暟
             String[] ancestorsArray = longest.split(",");
             int max = ancestorsArray.length;
-            JSONObject j = new JSONObject();
-            j.put("count0",count0);
-            j.put("count1",count1);
-            j.put("count2",count2);
-            return Results.succeed(jsonArray);
+            //鑾峰彇閮ㄩ棬灞傜骇
+            List<SysDept> sysDepts = sysDeptService.all();
+            List<TreeSelectWell> tree = sysDeptService.wellTree(sysDepts);
+            //寰幆鏁版嵁鎸傚湪鍒伴儴闂ㄥ眰绾т笅
+            for (int i = 0; i < healthVos.size(); i++) {
+                HealthVo healthVo = healthVos.get(i);
+                Long deptId = healthVo.getDeptId();
+                //寰幆鏍戠粨鏋�
+                for (int j = 0; j < tree.size(); j++) {
+                    //濡傛灉绗竴灞傚尮閰嶈祴鍊�
+                    if(deptId.equals(tree.get(j).getId())){
+                        tree.get(j).getWell().add(healthVo);
+                        break;
+                    }else {
+                        //涓嶅尮閰嶄笖children澶т簬0鏌ヨ绗簩灞�
+                        if(tree.get(j).getChildren().size()>0){
+                            for (int k = 0; k < tree.get(j).getChildren().size(); k++) {
+                                //濡傛灉绗簩灞傚尮閰�
+                                if(deptId.equals(tree.get(j).getChildren().get(k).getId())){
+                                    tree.get(j).getChildren().get(k).getWell().add(healthVo);
+                                    break;
+                                }else {
+                                    //涓嶅尮閰嶄笖children澶т簬0鏌ヨ绗笁灞�
+                                    if(tree.get(j).getChildren().get(k).getChildren().size()>0){
+                                        for (int l = 0; l < tree.get(j).getChildren().get(k).getChildren().size(); l++) {
+                                            //濡傛灉绗笁灞傚尮閰�
+                                            if(deptId.equals(tree.get(j).getChildren().get(k).getChildren().get(l).getId())){
+                                                tree.get(j).getChildren().get(k).getChildren().get(l).getWell().add(healthVo);
+                                                break;
+                                            }else {
+                                                //涓嶅尮閰嶄笖children澶т簬0鏌ヨ绗洓灞�
+                                                if(tree.get(j).getChildren().get(k).getChildren().get(l).getChildren().size()>0){
+                                                    for (int m = 0; m < tree.get(j).getChildren().get(k).getChildren().get(l).getChildren().size(); m++) {
+                                                        //濡傛灉绗洓灞傚尮閰�
+                                                        if(deptId.equals(tree.get(j).getChildren().get(k).getChildren().get(l).getChildren().get(m).getId())){
+                                                            tree.get(j).getChildren().get(k).getChildren().get(l).getChildren().get(m).getWell().add(healthVo);
+                                                            break;
+                                                        }else {
+                                                            //涓嶅尮閰嶄笖children澶т簬0鏌ヨ绗簲灞�
+                                                            if(tree.get(j).getChildren().get(k).getChildren().get(l).getChildren().get(m).getChildren().size()>0){
+                                                                for (int n = 0; n < tree.get(j).getChildren().get(k).getChildren().get(l).getChildren().get(m).getChildren().size(); n++) {
+                                                                    //濡傛灉绗簲灞傚尮閰�
+                                                                    if(deptId.equals(tree.get(j).getChildren().get(k).getChildren().get(l).getChildren().get(m).getChildren().get(n).getId())){
+                                                                        tree.get(j).getChildren().get(k).getChildren().get(l).getChildren().get(m).getChildren().get(n).getWell().add(healthVo);
+                                                                        break;
+                                                                    }
+                                                                }
+                                                            }
+                                                        }
+                                                    }
+                                                }
+                                            }
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            TreeSelectWellJson treeSelectWellJson = new TreeSelectWellJson();
+            treeSelectWellJson.setWellList(tree);
+            treeSelectWellJson.setCount0(count0);
+            treeSelectWellJson.setCount1(count1);
+            treeSelectWellJson.setCount2(count2);
+            return Results.succeed(treeSelectWellJson);
         } else {
             //閿欒鎻愮ず
             return Results.error((String) mapResult.get("errmsg"));

--
Gitblit v1.9.3