Explorar el Código

场站查树形

xushili hace 1 año
padre
commit
c254b1651d

+ 13 - 0
web/runeconomy-jjyx/src/main/java/com/gyee/runeconomy/controller/bmk/BenchmarkingController.java

@@ -140,6 +140,19 @@ public class BenchmarkingController {
         }
     }
 
+    @GetMapping(value = "/treeByWpid")
+    @ApiOperation(value = "场站树形", notes = "场站树形")
+    public R treeByWpid(@RequestParam(value = "wpId", required = true) String wpId,
+                        @RequestParam(value = "treeType", required = true) String treeType)  {
+
+        ProBasicOrganizeTree resultList = benchmarkingService.treeByWpid(wpId,treeType);
+        if (StringUtils.isNotNull(resultList)) {
+            return R.data(ResultMsg.ok(resultList));
+        } else {
+            return R.error(ResultMsg.error());
+        }
+    }
+
     @GetMapping(value = "/performance")
     @ApiOperation(value = "风机绩效榜", notes = "风机绩效榜")
     public R performance(@RequestParam(value = "companyid", required = true) String companyid,

+ 3 - 4
web/runeconomy-jjyx/src/main/java/com/gyee/runeconomy/model/auto/ProBasicOrganizeTree.java

@@ -10,6 +10,8 @@ import java.time.LocalDate;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.function.Function;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -30,10 +32,7 @@ public class ProBasicOrganizeTree extends Model {
 
     public static ProBasicOrganizeTree buildTree(List<ProBasicOrganizeTree> nodes) {
         // 用一个 map 存储所有 nodes,方便快速查找某个 node
-        Map<String, ProBasicOrganizeTree> nodeMap = new HashMap<>();
-        for (ProBasicOrganizeTree node : nodes) {
-            nodeMap.put(node.getId(), node);
-        }
+        Map<String, ProBasicOrganizeTree> nodeMap = nodes.stream().collect(Collectors.toMap(ProBasicOrganizeTree::getId, Function.identity()));
 
         // 构建树形结构
         ProBasicOrganizeTree root = null;

+ 21 - 1
web/runeconomy-jjyx/src/main/java/com/gyee/runeconomy/service/bmk/BenchmarkingService.java

@@ -119,6 +119,27 @@ public class BenchmarkingService {
                 oe -> wpids.contains(oe.getWindpowerstationId())).collect(Collectors.toList());
     }
 
+    public ProBasicOrganizeTree treeByWpid(String wpId, String treeType) {
+
+        ProBasicOrganizeTree root = null;
+        List<ProBasicOrganizeTree> collect = CacheContext.proBasicOrganizeTrees.stream().filter(pbot -> {
+            if(wpId.equals(pbot.getParentCode()) || wpId.equals(pbot.getId())){
+                if("AG".equals(treeType)){
+                    if("EQ".equals(pbot.getOrgType())) return false;
+                }else if ("LN".equals(treeType)){
+                    if("EQ".equals(pbot.getOrgType()) || "AG".equals(pbot.getOrgType())) return false;
+                } else if ("EG".equals(treeType)) {
+                    if("EQ".equals(pbot.getOrgType()) || "AG".equals(pbot.getOrgType()) || "LN".equals(pbot.getOrgType())) return false;
+                }
+            }else {
+                return false;
+            }
+            return true;
+        }).collect(Collectors.toList());
+
+        return ProBasicOrganizeTree.buildTree(collect);
+    }
+
     public List<ProBasicOrganizeEquipment> wtByWplistxin(String wpids) {
         return CacheContext.organizeEquipmentList.stream().filter(
                 oe -> wpids.contains(oe.getWindpowerstationId()) || (oe.getNemName().contains("风机"))).collect(Collectors.toList());
@@ -1479,5 +1500,4 @@ public class BenchmarkingService {
         //        SortUtils.sort(resultList,"ordernum",SortUtils.ASC);
         return resultList;
     }
-
 }