|
@@ -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;
|
|
|
+ }
|
|
|
+}
|