Browse Source

晋能树添加

wangb 2 years ago
parent
commit
4cea5d2e59

+ 0 - 21
web/backmanagerconfig-xktj/src/main/java/com/gyee/backconfig/service/auto/SttreeService.java

@@ -80,27 +80,6 @@ public class SttreeService {
             ll.getChildren().addAll(lis);
         });
 
-//        List<List> xh = new ArrayList();
-//        xh.add(energyls);
-//        xh.add(regionsls);
-//        xh.add(cpls);
-//        xh.add(wpls);
-//        xh.add(prols);
-//
-//        Scanner sc = new Scanner(System.in);
-//        int ls = sc.nextInt();
-//
-//        switch (ls) {
-//            case 1:
-//                xh.get(0);
-//                break;
-//            case 2:
-//                xh.get(1);
-//                break;
-//            case 3:
-//                xh.get(2);
-//                break;
-//        }
         return energyls;
     }
 }

+ 34 - 0
web/backmanagerconfig/src/main/java/com/gyee/backconfig/controller/NewtreeController.java

@@ -0,0 +1,34 @@
+package com.gyee.backconfig.controller;
+
+import com.gyee.backconfig.config.R;
+import com.gyee.backconfig.model.auto.Companys;
+import com.gyee.backconfig.service.NewtreeService;
+import com.gyee.common.model.StringUtils;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.List;
+@RestController
+@RequestMapping("//newtree")
+public class NewtreeController {
+    @Resource
+    private NewtreeService newtreeService;
+
+
+    /**
+     * 层级树
+     *
+     * @return
+     */
+    @GetMapping(value = "/treels")
+    @ResponseBody
+    @CrossOrigin(origins = "*", maxAge = 3600)
+    public R wtls(String tag) {
+        List<Companys> resultList = newtreeService.cpls(tag);
+        if (StringUtils.isNotNull(resultList)) {
+            return com.gyee.backconfig.config.R.ok((int) resultList.size()).data(resultList);
+        } else {
+            return R.error().message("访问失败");
+        }
+    }
+}

+ 2 - 1
web/backmanagerconfig/src/main/java/com/gyee/backconfig/controller/WindturbineController.java

@@ -44,9 +44,10 @@ public class WindturbineController {
                       @RequestParam(value = "windpowerstationid", required = false) String windpowerstationid,
                       @RequestParam(value = "projectid", required = false) String projectid,
                       @RequestParam(value = "lineid", required = false) String lineid,
+                      @RequestParam(value = "name", required = false) String name,
                       @RequestParam(value = "pageNum", required = true) String pageNum,
                       @RequestParam(value = "pageSize", required = true) String pageSize) {
-        IPage<Windturbine> list = windturbineService.list(id, code, windpowerstationid, projectid, lineid, pageNum, pageSize);
+        IPage<Windturbine> list = windturbineService.list(id, code, windpowerstationid,name,projectid, lineid, pageNum, pageSize);
         if (null != list) {
             return R.ok().data(list);
         } else {

+ 3 - 2
web/backmanagerconfig/src/main/java/com/gyee/backconfig/model/auto/Companys.java

@@ -69,6 +69,7 @@ public class Companys extends Model {
     private Integer  jrnumber;
 
     @TableField(exist = false)
-    private List<Windpowerstation> Children = new ArrayList<>();
-
+    private List<Region> Children = new ArrayList<>();
+    @TableField(exist = false)
+    private List<Windpowerstation> Children1 = new ArrayList<>();
 }

+ 6 - 0
web/backmanagerconfig/src/main/java/com/gyee/backconfig/model/auto/Region.java

@@ -1,9 +1,13 @@
 package com.gyee.backconfig.model.auto;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * <p>
  * 
@@ -64,6 +68,8 @@ public class Region extends Model {
 
     private Integer  jrnumber;
 
+    @TableField(exist = false)
+    private List<Windpowerstation> Children = new ArrayList<>();
 
 
 

+ 3 - 0
web/backmanagerconfig/src/main/java/com/gyee/backconfig/model/auto/Windpowerstation.java

@@ -67,4 +67,7 @@ public class Windpowerstation extends Model {
 
     @TableField(exist = false)
     private List<Project> Children = new ArrayList<>();
+
+    @TableField(exist = false)
+    private List<Project> Children1= new ArrayList<>();
 }

+ 3 - 3
web/backmanagerconfig/src/main/java/com/gyee/backconfig/service/BackConfigService.java

@@ -394,19 +394,19 @@ public class BackConfigService {
 
         List<Companys> cpls = CacheContext.cpls;
 
-        if(cpls.get(0).getChildren().size()>0) return cpls;
+        if(cpls.get(0).getChildren1().size()>0) return cpls;
 
         List<Windpowerstation> wpls = CacheContext.wpls;
         List<Project> prols= CacheContext.prols;
 
             cpls.forEach(cpl -> {
                 List<Windpowerstation> collect = wpls.stream().filter(w -> w.getCompanyid().equals(cpl.getId())).collect(Collectors.toList());
-                cpl.getChildren().addAll(collect);
+                cpl.getChildren1().addAll(collect);
             });
 
             wpls.forEach(wpl -> {
                 List<Project> projects = prols.stream().filter(l -> l.getWindpowerstationid().equals(wpl.getId())).collect(Collectors.toList());
-                wpl.getChildren().addAll(projects);
+                wpl.getChildren1().addAll(projects);
             });
         return cpls;
     }

+ 76 - 0
web/backmanagerconfig/src/main/java/com/gyee/backconfig/service/NewtreeService.java

@@ -0,0 +1,76 @@
+package com.gyee.backconfig.service;
+
+import com.gyee.backconfig.config.CacheContext;
+import com.gyee.backconfig.model.auto.*;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Service
+public class NewtreeService {
+    public List<Companys> cpls(String tag) {
+
+        List<Companys> cpls = CacheContext.cpls;//公司
+        List<Region> rels = CacheContext.regions;//区域
+        List<Windpowerstation> wpls = CacheContext.wpls;//场站
+        List<Project> prols = CacheContext.prols;//期次
+        List<Line> lines = CacheContext.lines;//线路
+        //公司-区域
+        cpls.forEach(regls -> {
+            List<Region> collect = rels.stream().filter(r -> r.getCompanyid().equals(regls.getId())).collect(Collectors.toList());
+            if (null != regls.getChildren()) {
+                regls.getChildren().clear();
+            }
+            collect.stream().forEach(c -> {
+                c.getChildren().clear();
+            });
+            regls.getChildren().addAll(collect);
+        });
+
+        if ("1".equals(tag)) {
+            return cpls;
+        }
+
+        //区域-场站
+        rels.forEach(czls -> {
+            List<Windpowerstation> collect = wpls.stream().filter(w -> null != w.getRegionid() && w.getRegionid().equals(czls.getId())).collect(Collectors.toList());
+            if (null != czls.getChildren()) {
+                czls.getChildren().clear();
+            }
+            collect.stream().forEach(d -> {
+                d.getChildren().clear();
+            });
+            czls.getChildren().addAll(collect);
+        });
+
+        if ("2".equals(tag)) {
+            return cpls;
+        }
+
+        //场站-期次
+        wpls.forEach(qcls -> {
+            List<Project> collect = prols.stream().filter(w -> null != w.getWindpowerstationid() && w.getWindpowerstationid().equals(qcls.getId())).collect(Collectors.toList());
+            if (null != qcls.getChildren()) {
+                qcls.getChildren().clear();
+            }
+            collect.stream().forEach(e -> {
+                e.getChildren().clear();
+            });
+            qcls.getChildren().addAll(collect);
+        });
+
+        if ("3".equals(tag)) {
+            return cpls;
+        }
+
+        //期次-线路
+        prols.forEach(xlls -> {
+            List<Line> collect = lines.stream().filter(w -> null != w.getProjectid() && w.getProjectid().equals(xlls.getId())).collect(Collectors.toList());
+            xlls.getChildren().addAll(collect);
+        });
+
+
+        return cpls;
+    }
+}

+ 1 - 1
web/backmanagerconfig/src/main/java/com/gyee/backconfig/service/auto/IWindturbineService.java

@@ -17,7 +17,7 @@ import java.util.List;
 public interface IWindturbineService extends IService<Windturbine> {
 
 
-    IPage<Windturbine> list(String id, String code, String windpowerstationid, String projectid, String lineid, String pageNum, String pageSize);
+    IPage<Windturbine> list(String id, String code, String windpowerstationid,String name, String projectid, String lineid, String pageNum, String pageSize);
 
     Windturbine getOne(String id);
 

+ 4 - 2
web/backmanagerconfig/src/main/java/com/gyee/backconfig/service/auto/impl/WindturbineServiceImpl.java

@@ -25,7 +25,7 @@ import java.util.List;
 public class WindturbineServiceImpl extends ServiceImpl<WindturbineMapper, Windturbine> implements IWindturbineService {
 
     @Override
-    public IPage<Windturbine> list(String id, String code, String windpowerstationid, String projectid, String lineid, String pageNum, String pageSize) {
+    public IPage<Windturbine> list(String id, String code, String windpowerstationid, String name,String projectid, String lineid, String pageNum, String pageSize) {
         QueryWrapper<Windturbine> qw = new QueryWrapper<>();
         if (StringUtils.isNotEmpty(id)){
             qw.eq("id",id);
@@ -33,10 +33,12 @@ public class WindturbineServiceImpl extends ServiceImpl<WindturbineMapper, Windt
         if (StringUtils.isNotEmpty(code)){
             qw.like("code",code);
         }
-
         if (StringUtils.isNotEmpty(windpowerstationid)){
             qw.like("windpowerstationid",windpowerstationid);
         }
+        if (StringUtils.isNotEmpty(name)){
+            qw.like("name",name);
+        }
 
         if (StringUtils.isNotEmpty(projectid)){
             qw.eq("projectid",projectid);