Quellcode durchsuchen

后台管理缓存调整

wangb vor 2 Jahren
Ursprung
Commit
007865a2c3

+ 128 - 25
web/backmanagerconfig/src/main/java/com/gyee/backconfig/config/CacheContext.java

@@ -1,7 +1,6 @@
 package com.gyee.backconfig.config;
 
 
-
 import com.gyee.backconfig.model.auto.*;
 import com.gyee.backconfig.service.auto.*;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -13,6 +12,7 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 
 /**
@@ -43,60 +43,163 @@ public class CacheContext implements CommandLineRunner {
     private IWindturbineService windturbineService;//风机
 
 
-    public static   Map<String, Region> regionmap = new HashMap<>();
+    public static Map<String, Companys> cpmap = new HashMap<>();
+    public static List<Companys> cpls = new ArrayList<>();
+
+    public static Map<String, Region> regionmap = new HashMap<>();
     public static List<Region> regions = new ArrayList<>();
 
+    public static Map<String, Windpowerstation> wpmap = new HashMap<>();
+    public static List<Windpowerstation> wpls = new ArrayList<>();
+    public static Map<String, List<Windpowerstation>> wpmapGroupGCRegion = new HashMap<>();
+    public static Map<String, List<Windpowerstation>> wpmapGroupGCCompany = new HashMap<>();
+    public static Map<String, List<Windpowerstation>> wpmapGroupFCRegion = new HashMap<>();
+    public static Map<String, List<Windpowerstation>> wpmapGroupFCCompany = new HashMap<>();
 
-    public static   Map<String, Line> linemap = new HashMap<>();
+    public static Map<String, Project> promap = new HashMap<>();
+    public static List<Project> prols = new ArrayList<>();
+
+    public static Map<String, Line> linemap = new HashMap<>();
     public static List<Line> lines = new ArrayList<>();
 
 
-    public static   Map<String, Windturbine> windturbinemap = new HashMap<>();
+    public static Map<String, Windturbine> windturbinemap = new HashMap<>();
     public static List<Windturbine> windturbines = new ArrayList<>();
-
-    public static Map<String, Project> promap = new HashMap<>();
-    public static List<Project> prols = new ArrayList<>();
-    public static Map<String,Windpowerstation> wpmap = new HashMap<>();
-    public static List<Windpowerstation> wpls = new ArrayList<>();
-    public static Map<String, Companys> cpmap = new HashMap<>();
-    public static List<Companys> cpls = new ArrayList<>();
-
+    public static Map<String, List<Windturbine>> poequipmentmap = new HashMap<>();
+    public static Map<String, List<Windturbine>> pjequipmentmap = new HashMap<>();
+    public static Map<String, List<Windturbine>> liequipmentmap = new HashMap<>();
 
     @Override
     public void run(String... args) throws Exception {
 
+        System.out.println(">>>>>>>>>>>>>>>服务启动,正在缓存数据<<<<<<<<<<<<<<");
+        //公司
+        initcompanyList();
+
+        //区域
+        initSegionList();
+
+        //场站
+        initPowerstationList();
+
+        //期次
+        initProjectList();
+
+        //线路
+        initLineList();
+
+//        发电设备
+        initEquipmentList();
+
+//        //变电所
+//        initSubStationList();
+//
+//        //方阵
+//        initSquaresList();
+
+        System.out.println(">>>>>>>>>>>>>>>数据缓存完成<<<<<<<<<<<<<<");
+
+    }
+
+    /**
+     * 初始化公司表
+     */
+    public void initcompanyList() {
+        //清理集合中的数据
+        cpls.clear();
+        cpmap.clear();
+        //重新加载集合数据
         cpls = companysService.list();
         cpls.stream().forEach(Companys -> {
-            cpmap.put(Companys.getId(),Companys);
+            cpmap.put(Companys.getId(), Companys);
         });
+    }
+
+    /**
+     * 初始化区域表
+     */
+    public void initSegionList() {
+        //清理集合中的数据
+        regions.clear();
+        regionmap.clear();
+        regions = regionService.list();
+        regions.stream().forEach(region -> {
+            regionmap.put(region.getId(), region);
+        });
+    }
+
+    /**
+     * 初始化场站表
+     */
+    public void initPowerstationList() {
+        //清理集合数据
+        wpls.clear();
+        wpmap.clear();
+        wpmapGroupGCCompany.clear();
+        wpmapGroupFCCompany.clear();
+        wpmapGroupGCRegion.clear();
+        wpmapGroupFCRegion.clear();
 
         wpls = windpowerstationService.list();
         wpls.stream().forEach(windpowerstation -> {
-            wpmap.put(windpowerstation.getId(),windpowerstation);
+            wpmap.put(windpowerstation.getId(), windpowerstation);
         });
 
-        prols = projectService.list();
-        prols.stream().forEach(Project -> {
-            promap.put(Project.getWindpowerstationid(),Project);
-        });
 
+        wpmapGroupGCRegion = wpls.stream().filter(p -> p.getId().indexOf("_GDC_") >= 0).collect(Collectors.groupingBy(Windpowerstation::getRegionid));
+        wpmapGroupFCRegion = wpls.stream().filter(p -> p.getId().indexOf("_FDC_") >= 0).collect(Collectors.groupingBy(Windpowerstation::getRegionid));
 
-        //区域
-        regions = regionService.list();
-        regions.stream().forEach(region -> {
-            regionmap.put(region.getId(), region);
+
+        wpmapGroupGCCompany = wpls.stream().filter(p -> p.getId().indexOf("_GDC_") >= 0).collect(Collectors.groupingBy(Windpowerstation::getCompanyid));
+        wpmapGroupFCCompany = wpls.stream().filter(p -> p.getId().indexOf("_FDC_") >= 0).collect(Collectors.groupingBy(Windpowerstation::getCompanyid));
+
+    }
+
+
+    /**
+     * 初始化期次表
+     */
+    public void initProjectList() {
+        //清理集合数据
+        prols.clear();
+        promap.clear();
+        prols = projectService.list();
+        prols.stream().forEach(Project -> {
+            promap.put(Project.getWindpowerstationid(), Project);
         });
+    }
 
-        //线路
+    /**
+     * 初始化线路表
+     */
+    public void initLineList() {
+        //清理集合数据
+        lines.clear();
+        linemap.clear();
         lines = lineService.list();
         lines.stream().forEach(line -> {
             linemap.put(line.getId(), line);
         });
+    }
 
-        //风机
-        windturbines =  windturbineService.list();
+    /**
+     * 初始化风机表
+     */
+    public void initEquipmentList() {
+        //清理集合数据
+        //清理集合数据
+        windturbines.clear();
+        windturbinemap.clear();
+        poequipmentmap.clear();
+        pjequipmentmap.clear();
+        liequipmentmap.clear();
+
+        windturbines = windturbineService.list();
         windturbines.stream().forEach(windturbine -> {
             windturbinemap.put(windturbine.getId(), windturbine);
         });
+        poequipmentmap = windturbines.stream().collect(Collectors.groupingBy(Windturbine::getWindpowerstationid));
+        pjequipmentmap = windturbines.stream().collect(Collectors.groupingBy(Windturbine::getProjectid));
+        liequipmentmap = windturbines.stream().collect(Collectors.groupingBy(Windturbine::getLineid));
     }
 }

+ 3 - 1
web/backmanagerconfig/src/main/java/com/gyee/backconfig/controller/CompanysController.java

@@ -3,6 +3,7 @@ package com.gyee.backconfig.controller;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.gyee.backconfig.config.CacheContext;
 import com.gyee.backconfig.config.R;
 import com.gyee.backconfig.model.auto.Companys;
 import com.gyee.backconfig.service.BackConfigService;
@@ -28,7 +29,7 @@ public class CompanysController {
     @Resource
     private ICompanysService companysService;
     @Resource
-    private BackConfigService backConfigService;
+    private CacheContext context;
 
     /**
      * 查询
@@ -84,6 +85,7 @@ public class CompanysController {
 
         boolean b = companysService.saveOrUpdate(company);
         if (b) {
+            context.initcompanyList();
             return R.ok().data(b);
         } else {
             return R.error().data("保存失败!");

+ 1 - 0
web/backmanagerconfig/src/main/java/com/gyee/backconfig/controller/IndicatorsController.java

@@ -13,6 +13,7 @@ import javax.xml.crypto.Data;
 import java.util.List;
 
 /**
+ * 指标录入
  * <p>
  * 前端控制器
  * </p>

+ 4 - 0
web/backmanagerconfig/src/main/java/com/gyee/backconfig/controller/LineController.java

@@ -2,6 +2,7 @@ package com.gyee.backconfig.controller;
 
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.gyee.backconfig.config.CacheContext;
 import com.gyee.backconfig.config.R;
 import com.gyee.backconfig.model.auto.Line;
 import com.gyee.backconfig.service.BackConfigService;
@@ -28,6 +29,8 @@ public class LineController {
     private BackConfigService backConfigService;
     @Resource
     private ILineService lineService;
+    @Resource
+    private CacheContext context;
 
     @GetMapping("/listByPage")
     @ResponseBody
@@ -90,6 +93,7 @@ public class LineController {
     public R addModifyProjectPlan(@RequestBody Line Line) {
         boolean saveOrUpdate = backConfigService.saveOrUpdate(Line);
         if (saveOrUpdate) {
+            context.initLineList();
             return R.ok().data("保存或更新成功");
         } else {
             return R.error().message("保存失败");

+ 4 - 0
web/backmanagerconfig/src/main/java/com/gyee/backconfig/controller/ProjectController.java

@@ -3,6 +3,7 @@ package com.gyee.backconfig.controller;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.gyee.backconfig.config.CacheContext;
 import com.gyee.backconfig.config.R;
 import com.gyee.backconfig.model.auto.Project;
 import com.gyee.backconfig.service.BackConfigService;
@@ -32,6 +33,8 @@ public class ProjectController {
 
     @Autowired
     private IProjectService projectService;
+    @Resource
+    private CacheContext context;
 
     @GetMapping("/listByPage")
     @ResponseBody
@@ -157,6 +160,7 @@ public class ProjectController {
 
         boolean b = projectService.addOrUpdate(project);
         if (b) {
+            context.initProjectList();
             return R.ok().data(b);
         } else {
             return R.error().data("保存失败!");

+ 5 - 1
web/backmanagerconfig/src/main/java/com/gyee/backconfig/controller/RegionController.java

@@ -3,6 +3,7 @@ package com.gyee.backconfig.controller;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.gyee.backconfig.config.CacheContext;
 import com.gyee.backconfig.config.R;
 import com.gyee.backconfig.model.auto.Region;
 import com.gyee.backconfig.service.auto.IRegionService;
@@ -10,6 +11,7 @@ import com.gyee.common.model.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import javax.annotation.Resource;
 import java.util.Arrays;
 import java.util.List;
 
@@ -27,7 +29,8 @@ public class RegionController {
 
     @Autowired
     private IRegionService regionService;
-
+    @Resource
+    private CacheContext context;
 
     /**
      * 查询
@@ -87,6 +90,7 @@ public class RegionController {
 
         boolean b = regionService.saveBatch(region);
         if (b) {
+            context.initSegionList();
             return R.ok().data("保存成功");
         } else {
             return R.error().data("保存失败!");

+ 1 - 0
web/backmanagerconfig/src/main/java/com/gyee/backconfig/controller/StandardpointController.java

@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.*;
 import java.util.List;
 
 /**
+ * 测点配置
  * <p>
  * 前端控制器
  * </p>

+ 4 - 1
web/backmanagerconfig/src/main/java/com/gyee/backconfig/controller/WindpowerstationController.java

@@ -3,6 +3,7 @@ package com.gyee.backconfig.controller;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.gyee.backconfig.config.CacheContext;
 import com.gyee.backconfig.config.R;
 import com.gyee.backconfig.model.auto.Region;
 import com.gyee.backconfig.model.auto.Windpowerstation;
@@ -33,7 +34,8 @@ import java.util.Map;
 public class WindpowerstationController {
     @Resource
     private BackConfigService backConfigService;
-
+    @Resource
+    private CacheContext context;
 
     @Autowired
     private IWindpowerstationService windpowerstationService;
@@ -94,6 +96,7 @@ public class WindpowerstationController {
 
         boolean b = windpowerstationService.addOrUpdate(windpowerstation);
         if (b){
+            context.initPowerstationList();
             return R.ok().data(b);
         }else {
             return R.error().data("保存失败!");

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

@@ -2,6 +2,7 @@ package com.gyee.backconfig.controller;
 
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.gyee.backconfig.config.CacheContext;
 import com.gyee.backconfig.config.R;
 import com.gyee.backconfig.model.auto.Windturbine;
 import com.gyee.backconfig.service.auto.IWindturbineService;
@@ -9,6 +10,7 @@ import com.gyee.common.model.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import javax.annotation.Resource;
 import java.util.List;
 
 /**
@@ -25,7 +27,8 @@ public class WindturbineController {
 
     @Autowired
     private IWindturbineService windturbineService;
-
+    @Resource
+    private CacheContext context;
 
     /**
      * 查询
@@ -87,6 +90,7 @@ public class WindturbineController {
 
         boolean b = windturbineService.addOrUpdate(windturbine);
         if (b) {
+            context.initEquipmentList();
             return R.ok().data(b);
         } else {
             return R.error().data("保存失败!");