浏览代码

增加设备厂商树及缓存

wangb 2 年之前
父节点
当前提交
f49feae6cb

+ 66 - 0
web/backmanagerconfig-xktj/src/main/java/com/gyee/backconfig/config/CacheContext.java

@@ -53,6 +53,15 @@ public class CacheContext implements CommandLineRunner {
     @Autowired
     private IProBasicWeatherStationService proBasicWeatherStationService;//气象站
 
+    @Autowired
+    private IProEconManufacturerService proEconManufacturerService; //设备厂商
+
+    @Autowired
+    private IProEconEquipmentmodelService proEconEquipmentmodelService; //设备型号
+
+    @Autowired
+    private IProBasicModelPowerService proBasicModelPowerService; //设备类型
+
     //集团
     public static Map<String, ProBasicEnergyGroup> energymap = new HashMap<>();
     public static List<ProBasicEnergyGroup> groups = new ArrayList<>();
@@ -104,8 +113,20 @@ public class CacheContext implements CommandLineRunner {
     public static Map<String, ProBasicSquare> squareMap = new HashMap<>();
     public static Map<String, List<ProBasicSquare>> poSquareMap = new HashMap<>();
 
+    //设备厂商
+    public static List<ProEconManufacturer> Manufacturers = new ArrayList<>();
+    public static Map<String, ProEconManufacturer> ManufacturerMap = new HashMap<>();
+    public static Map<String, List<ProEconManufacturer>> poManufacturerMap = new HashMap<>();
 
+    //设备型号
+    public static List<ProEconEquipmentmodel> Equipments = new ArrayList<>();
+    public static Map<String, ProEconEquipmentmodel> EquipmentMap = new HashMap<>();
+    public static Map<String, List<ProEconEquipmentmodel>> poEquipmentMap = new HashMap<>();
 
+    //设备类型
+    public static List<ProBasicModelPower> models = new ArrayList<>();
+    public static Map<String, ProBasicModelPower> modelMap = new HashMap<>();
+    public static Map<String, List<ProBasicModelPower>> pomodelMap = new HashMap<>();
 
     @Override
     public void run(String... args) throws Exception {
@@ -139,6 +160,15 @@ public class CacheContext implements CommandLineRunner {
         //气象站
         initWsStationList();
 
+        //设备厂商
+        initManufacturerList();
+
+        //设备型号
+        initEquipmentmodelList();
+
+        //设备类型
+        initModelPowerList();
+
         System.out.println(">>>>>>>>>>>>>>>数据缓存完成<<<<<<<<<<<<<<");
 
     }
@@ -313,4 +343,40 @@ public class CacheContext implements CommandLineRunner {
     }
 
 
+
+    /**
+     * 初始化设备厂商数据
+     */
+    public void initManufacturerList(){
+        Manufacturers.clear();
+        ManufacturerMap.clear();
+        Manufacturers = proEconManufacturerService.list();
+        Manufacturers.stream().forEach(Manufacturer -> {
+            ManufacturerMap.put(Manufacturer.getId(), Manufacturer);
+        });
+    }
+
+
+    /**
+     * 初始化设备型号数据
+     */
+    public void initEquipmentmodelList(){
+        Equipments.clear();
+        EquipmentMap.clear();
+        Equipments = proEconEquipmentmodelService.list();
+        Equipments.stream().forEach(Equipment -> {
+            EquipmentMap.put(Equipment.getId(), Equipment);
+        });
+    }
+    /**
+     * 初始化设备类型数据
+     */
+    public void initModelPowerList(){
+        models.clear();
+        modelMap.clear();
+        models = proBasicModelPowerService.list();
+        models.stream().forEach(model -> {
+            modelMap.put(model.getId(), model);
+        });
+    }
 }

+ 1 - 1
web/backmanagerconfig-xktj/src/main/java/com/gyee/backconfig/controller/ProEconEquipmentmodelController.java

@@ -30,7 +30,7 @@ public class ProEconEquipmentmodelController {
     /**
      * 查询
      * @param id
-     * @param nem_code
+     * @param nemCode
      * @param name
      * @param pageNum
      * @param pageSize

+ 19 - 0
web/backmanagerconfig-xktj/src/main/java/com/gyee/backconfig/controller/SttreeControllel.java

@@ -4,6 +4,7 @@ import com.gyee.backconfig.config.R;
 import com.gyee.backconfig.model.auto.ProBasicEnergyGroup;
 import com.gyee.backconfig.model.auto.ProBasicPowerstation;
 import com.gyee.backconfig.model.auto.ProBasicRegion;
+import com.gyee.backconfig.model.auto.ProEconManufacturer;
 import com.gyee.backconfig.service.auto.SttreeService;
 import com.gyee.common.model.StringUtils;
 import io.swagger.annotations.Api;
@@ -76,4 +77,22 @@ public class SttreeControllel {
             return R.error().message("访问失败");
         }
     }
+
+    /**
+     * 设备厂商层级树
+     *
+     * @return
+     */
+    @GetMapping(value = "/mantreels")
+    @ResponseBody
+    @CrossOrigin(origins = "*", maxAge = 3600)
+    @ApiOperation(value = "设备厂商结构树-设备厂商层级树", notes = "设备厂商构树-设备厂商层级树")
+    public R Manls(String tag) {
+        List<ProEconManufacturer> resultList = sttreeService.Mantree(tag);
+        if (StringUtils.isNotNull(resultList)) {
+            return com.gyee.backconfig.config.R.ok((int) resultList.size()).data(resultList);
+        } else {
+            return R.error().message("访问失败");
+        }
+    }
 }

+ 10 - 0
web/backmanagerconfig-xktj/src/main/java/com/gyee/backconfig/model/auto/ProEconEquipmentmodel.java

@@ -1,10 +1,14 @@
 package com.gyee.backconfig.model.auto;
 
 import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
 
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.fasterxml.jackson.annotation.JsonInclude;
 import io.swagger.annotations.ApiModel;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
@@ -95,5 +99,11 @@ public class ProEconEquipmentmodel extends Model {
      */
     private Integer equipmentCategory;
 
+    @TableField(exist = false)
+    private List<ProBasicModelPower> Children = new ArrayList<>();
+    @JsonInclude(JsonInclude.Include.NON_DEFAULT )
+    public List<ProBasicModelPower> getChildren() {
+        return Children;
+    }
 
 }

+ 16 - 1
web/backmanagerconfig-xktj/src/main/java/com/gyee/backconfig/model/auto/ProEconManufacturer.java

@@ -1,12 +1,17 @@
 package com.gyee.backconfig.model.auto;
 
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.fasterxml.jackson.annotation.JsonInclude;
 import io.swagger.annotations.ApiModel;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * <p>
  * 设备厂商
@@ -29,6 +34,11 @@ public class ProEconManufacturer extends Model {
     private String id;
 
     /**
+     * 编码
+     */
+    private String nemCode;
+
+    /**
      * 名称
      */
     private String name;
@@ -48,5 +58,10 @@ public class ProEconManufacturer extends Model {
      */
     private String telephone;
 
-
+    @TableField(exist = false)
+    private List<ProEconEquipmentmodel> Children = new ArrayList<>();
+    @JsonInclude(JsonInclude.Include.NON_DEFAULT )
+    public List<ProEconEquipmentmodel> getChildren() {
+        return Children;
+    }
 }

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

@@ -153,6 +153,7 @@ public class SttreeService {
         return regionsls;
     }
 
+    //期次树
     public List<ProBasicPowerstation> Projecttree() {
         List<ProBasicPowerstation> wpls = CacheContext.wpls;//场站
         List<ProBasicProject> prols = CacheContext.prols;//期次
@@ -169,4 +170,41 @@ public class SttreeService {
         });
         return wpls;
     }
+
+    //设备厂商树
+    public List<ProEconManufacturer> Mantree(String tag) {
+
+        List<ProEconManufacturer> manufacturers = CacheContext.Manufacturers; //厂商
+
+        List<ProEconEquipmentmodel> equipments = CacheContext.Equipments;//型号
+
+        List<ProBasicModelPower> models = CacheContext.models;//类型
+
+        //厂商-型号
+        manufacturers.forEach(cp -> {
+            List<ProEconEquipmentmodel> equipment = equipments.stream().filter(c -> null != c.getWindturbineManufacturerId() && c.getWindturbineManufacturerId().equals(cp.getId())).collect(Collectors.toList());
+            if (null != cp.getChildren()) {
+                cp.getChildren().clear();
+            }
+            equipment.stream().forEach(r -> {
+                r.getChildren().clear();
+            });
+            cp.getChildren().addAll(equipment);
+        });
+        if ("1".equals(tag)) {
+            return manufacturers;
+        }
+
+        //型号-类型
+        equipments.forEach(wp -> {
+            List<ProBasicModelPower> co = models.stream().filter(w -> null != w.getModelId() && w.getModelId().equals(wp.getId())).collect(Collectors.toList());
+            wp.getChildren().addAll(co);
+        });
+        if ("2".equals(tag)) {
+            return manufacturers;
+        }
+
+        return manufacturers;
+    }
+
 }