123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- package com.gyee.impala.common.spring;
- import com.gyee.impala.model.master.*;
- import com.gyee.impala.model.master.diagnose.Diagnosepoint;
- import com.gyee.impala.model.master.diagnose.Diagnosetrainhistory;
- import com.gyee.impala.service.master.*;
- import com.gyee.impala.service.master.diagnose.DiagnosepointService;
- import com.gyee.impala.service.master.diagnose.DiagnosetrainhistoryService;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.boot.CommandLineRunner;
- import org.springframework.core.annotation.Order;
- import org.springframework.stereotype.Component;
- import javax.annotation.Resource;
- import java.util.*;
- import java.util.stream.Collectors;
- /**
- * 服务启动前执行,进行全局变量初始化
- */
- @Component
- @Order(2)
- public class InitialRunner implements CommandLineRunner {
- @Resource
- private WindturbineService windturbineService;
- @Resource
- private WindpowerstationService windpowerstationService;
- @Autowired
- private KnowcategoryService faulttypeService;
- @Autowired
- private EquipmentmodelService modelService;
- @Autowired
- private DiagnosepointService diagnosepointService;
- @Autowired
- private DiagnosetrainhistoryService diagnosetrainhistoryService;
- /**场站所有信息**/
- public static List<Windpowerstation> wpList = new ArrayList<>();
- /**场站的风机**/
- public static Map<String, List<Windturbine>> wpMap = new HashMap<>();
- /** <MHS_FDC, 麻黄山风电场> **/
- public static Map<String, String> stationMap = new HashMap<>();
- /**所有的风机**/
- public static List<Windturbine> wtList = new ArrayList<>();
- /** <NG01_01, Windturbine> **/
- public static Map<String, Windturbine> wtMap = new HashMap<>();
- /**功率曲线预处理数据表格数据 key:time+wtId value:当前风机的总条数 **/
- public static Map<String, Integer> scatterMap = new HashMap<>();
- /***故障 <FDJ,发电机故障> 类型*/
- public static Map<String, String> faultTypeMap = new HashMap<>();
- public static List<Knowcategory> faultTypeList = new ArrayList<>();
- /***scada预警 <FDJ,发电机> 类型*/
- public static Map<String, String> scadaWarnMap = new HashMap<>();
- public static List<Knowcategory> scadaWarnList = new ArrayList<>();
- /***自定义预警 <FDJ,发电机> 类型*/
- public static Map<String, String> customWarnMap = new HashMap<>();
- public static List<Knowcategory> customWarnList = new ArrayList<>();
- /** 设备型号配置 <UP82, Equipmentmodel> **/
- public static Map<String, Equipmentmodel> modelMap = new HashMap<>();
- /** 故障诊断 训练需要的测点**/
- public static Map<String, Map<String, List<Diagnosepoint>>> mapPoint = new HashMap<>();
- /*** 故障训练历史模型 */
- public static Map<String, List<Diagnosetrainhistory>> historyModelMap = new HashMap<>();
- public static List<Diagnosetrainhistory> historyList = new ArrayList<>();
- @Override
- public void run(String... args){
- System.out.println(">>>>>>>>>>>>>>>服务启动,正在缓存数据<<<<<<<<<<<<<<");
- cacheStation();
- cacheKnowCategory();
- cacheEquipmentModel();
- cacheDiagnosePoint();
- cacheHistory();
- System.out.println(">>>>>>>>>>>>>>>数据缓存完成<<<<<<<<<<<<<<");
- }
- /**
- * 缓存场站数据
- * 数据新增或删除后需要更新,故每次清空
- */
- public void cacheStation(){
- wpList.clear();
- wtList.clear();
- stationMap.clear();
- wpMap.clear();
- wtMap.clear();
- List<Windpowerstation> stations = windpowerstationService.getAll();
- wpList = stations;
- stations.stream().forEach(obj -> {
- List<Windturbine> wts = windturbineService.getWindTurbineId(obj.getId());
- stationMap.put(obj.getId(), obj.getName());
- wpMap.put(obj.getId(), wts);
- wtList.addAll(wts);
- wts.stream().forEach(o -> wtMap.put(o.getId(), o));
- });
- }
- /**
- * 缓存故障知识数据
- */
- public void cacheKnowCategory() {
- faultTypeList.clear();
- scadaWarnList.clear();
- customWarnList.clear();
- faultTypeMap.clear();
- scadaWarnMap.clear();
- customWarnMap.clear();
- List<Knowcategory> faultType = faulttypeService.getAll();
- faultType.stream().forEach(obj -> {
- if (obj.getCategory().equals("GZ")) {
- faultTypeList.add(obj);
- faultTypeMap.put(obj.getCode(), obj.getName().toUpperCase());
- }
- else if (obj.getCategory().equals("SCADABJ")) {
- scadaWarnList.add(obj);
- scadaWarnMap.put(obj.getCode(), obj.getName().toUpperCase());
- }
- else if (obj.getCategory().equals("CUSTOMBJ")) {
- customWarnList.add(obj);
- customWarnMap.put(obj.getCode(), obj.getName().toUpperCase());
- }
- });
- }
- public void cacheEquipmentModel() {
- modelMap.clear();
- List<Equipmentmodel> models = modelService.getAll();
- models.stream().forEach(obj -> modelMap.put(obj.getId(), obj));
- }
- public void cacheDiagnosePoint(){
- mapPoint.clear();
- List<Diagnosepoint> points = diagnosepointService.getDiagnosepointList();
- mapPoint = points.stream().collect(Collectors.groupingBy(Diagnosepoint::getStationen, Collectors.groupingBy(Diagnosepoint::getModel)));
- }
- public void cacheHistory(){
- historyModelMap.clear();
- historyList.clear();
- historyList = diagnosetrainhistoryService.getListAll();
- historyModelMap = historyList.stream().collect(Collectors.groupingBy(Diagnosetrainhistory::getModel));
- }
- }
|