|
@@ -0,0 +1,314 @@
|
|
|
+package com.gyee.power.fitting.common.spring;
|
|
|
+
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.alibaba.fastjson.TypeReference;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.gyee.power.fitting.common.config.StringUtils;
|
|
|
+import com.gyee.power.fitting.common.redis.RedisService;
|
|
|
+import com.gyee.power.fitting.model.*;
|
|
|
+import com.gyee.power.fitting.service.*;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.boot.CommandLineRunner;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @ClassName : CacheContext
|
|
|
+ * @Author : xieshengjie
|
|
|
+ * @Date: 2021/5/18 9:35
|
|
|
+ * @Description : 缓存
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class CacheContext implements CommandLineRunner {
|
|
|
+ Logger logger = LoggerFactory.getLogger(CacheContext.class);
|
|
|
+
|
|
|
+ private final String QS = "0";
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ProBasicEquipmentService proBasicEquipmentService;
|
|
|
+
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ProBasicPowerstationService proBasicWindpowerstationService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ProEconEquipmentmodelService proEconEquipmentmodelService;
|
|
|
+
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private RedisService redisService;
|
|
|
+ @Resource
|
|
|
+ private ProBasicModelPowerService proBasicModelPowerService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ProBasicWeatherStationService proBasicWeatherStationService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ProBasicPowerstationService windpowerstationService;
|
|
|
+
|
|
|
+ public static List<ProBasicEquipment> wtls = new ArrayList<>();
|
|
|
+
|
|
|
+ public static List<ProBasicWeatherStation> weawpls = new ArrayList<>();
|
|
|
+ public static List<ProBasicPowerstation> wpls = new ArrayList<>();
|
|
|
+ public static List<ProBasicPowerstation> wplsf = new ArrayList<>();
|
|
|
+ public static List<ProBasicPowerstation> wplsG = new ArrayList<>(); //光电集合
|
|
|
+ public static List<ProBasicPowerstation> zwpls = new ArrayList<>();
|
|
|
+
|
|
|
+ public static Map<String, List<ProBasicPowerstation>> cpwpmap = new HashMap<>();
|
|
|
+ public static Map<String, List<ProBasicPowerstation>> wpmapls = new HashMap<>();
|
|
|
+ public static Map<String, ProBasicPowerstation> wpmap = new HashMap<>();
|
|
|
+ public static Map<String, List<ProBasicEquipment>> wpwtmap = new HashMap<>();
|
|
|
+ public static Map<String, List<ProBasicEquipment>> pjwtmap = new HashMap<>();
|
|
|
+ public static Map<String, List<ProBasicEquipment>> lnwtmap = new HashMap<>();
|
|
|
+ public static Map<String, List<ProBasicEquipment>> cmwtlsmap = new HashMap<>();
|
|
|
+ public static Map<String, List<ProBasicEquipment>> rgwtlsmap = new HashMap<>();
|
|
|
+ public static Map<String, Map<String, ProBasicEquipment>> cmwtmap = new HashMap<>();
|
|
|
+ public static Map<String, List<ProBasicEquipment>> sqwtmap = new HashMap<>();
|
|
|
+ public static Map<String, Map<String, ProBasicEquipmentPoint>> wtpAimap = new HashMap<>();// 风电机测点AI表
|
|
|
+ public static Map<String, Map<String, ProBasicPowerstationPoint>> wppointmap = new HashMap<>();
|
|
|
+ public static Map<String, Map<String, ProBasicPowerstationPoint>> weatherwppointmap = new HashMap<>();
|
|
|
+
|
|
|
+ public static Map<String, ProEconEquipmentmodel> modelMap = new HashMap<>();
|
|
|
+ public static Map<String, Double> modelpower = new HashMap<>();
|
|
|
+
|
|
|
+ public static Map<String, String> wtstandardmap = new HashMap<>();
|
|
|
+ public static Map<String, ProBasicEquipment> wtmap = new HashMap<>();
|
|
|
+
|
|
|
+ public static Map<String, Map<Double, ProBasicModelPower>> modelpowermap = new TreeMap<>();
|
|
|
+
|
|
|
+ public static List<ProBasicModelPower> mpls = new ArrayList<>();
|
|
|
+
|
|
|
+ public static List<ProEconEquipmentmodel> equipmentmodels = new ArrayList<>();
|
|
|
+
|
|
|
+ public static Map<String, List<ProBasicEquipment>> subWtsMap = new HashMap<>();
|
|
|
+
|
|
|
+
|
|
|
+ public static List<ProBasicPowerstation> stations = new ArrayList<>();
|
|
|
+ public static Map<String,ProBasicPowerstation> wpmaps = new HashMap<>();
|
|
|
+ public static Map<String,String> wppmap = new HashMap<>();
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void run(String... args) throws Exception {
|
|
|
+ logger.info("缓存开始------------------------------------------------------------");
|
|
|
+
|
|
|
+ equipmentmodels = proEconEquipmentmodelService.list();
|
|
|
+ equipmentmodels.stream().forEach(e -> {
|
|
|
+ modelMap.put(e.getId(), e);
|
|
|
+ });
|
|
|
+ mpls = proBasicModelPowerService.list();
|
|
|
+ mpls.sort(Comparator.comparing(ProBasicModelPower::getSpeed));
|
|
|
+ if (!mpls.isEmpty()) {
|
|
|
+
|
|
|
+ for (ProBasicModelPower mp : mpls) {
|
|
|
+ if (modelpowermap.containsKey(mp.getModelId())) {
|
|
|
+ Map<Double, ProBasicModelPower> tempmap = modelpowermap.get(mp.getModelId());
|
|
|
+ tempmap.put(mp.getSpeed(), mp);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ Map<Double, ProBasicModelPower> tempmap = new HashMap<>();
|
|
|
+ tempmap.put(mp.getSpeed(), mp);
|
|
|
+ modelpowermap.put(mp.getModelId(), tempmap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ for (ProBasicPowerstation wp : wpls) {
|
|
|
+ if (cpwpmap.containsKey(wp.getCompanyId())) {
|
|
|
+ cpwpmap.get(wp.getCompanyId()).add(wp);
|
|
|
+ } else {
|
|
|
+ List<ProBasicPowerstation> wps = new ArrayList<>();
|
|
|
+ wps.add(wp);
|
|
|
+ cpwpmap.put(wp.getCompanyId(), wps);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ QueryWrapper<ProBasicEquipment> queryWtWrapper = new QueryWrapper<>();
|
|
|
+ queryWtWrapper.orderByAsc("order_num");
|
|
|
+ wtls = proBasicEquipmentService.list(queryWtWrapper).stream().filter(i -> i.getIsable() == 1).collect(Collectors.toList());
|
|
|
+ logger.info(wtls.size() + "");
|
|
|
+ wtls.forEach(wt -> {
|
|
|
+ if (modelMap.containsKey(wt.getModelId())) {
|
|
|
+ ProEconEquipmentmodel equipmentmodel = modelMap.get(wt.getModelId());
|
|
|
+ modelpower.put(wt.getId(), equipmentmodel.getPowerProduction());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ wtmap.put(wt.getId(), wt);
|
|
|
+ //标杆风机初始化
|
|
|
+ wtstandardmap.put(wt.getId(), wt.getId());
|
|
|
+ String wtString = redisService.get(wt.getId());
|
|
|
+ Map<String, ProBasicEquipmentPoint> stringWindturbinetestingpointnewMap = JSONObject.parseObject(wtString, new TypeReference<Map<String, ProBasicEquipmentPoint>>() {
|
|
|
+ });
|
|
|
+ wtpAimap.put(wt.getId(), stringWindturbinetestingpointnewMap);
|
|
|
+
|
|
|
+
|
|
|
+ if (wpwtmap.containsKey(wt.getWindpowerstationId())) {
|
|
|
+ wpwtmap.get(wt.getWindpowerstationId()).add(wt);
|
|
|
+ } else {
|
|
|
+ List<ProBasicEquipment> wps = new ArrayList<>();
|
|
|
+ wps.add(wt);
|
|
|
+ wpwtmap.put(wt.getWindpowerstationId(), wps);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pjwtmap.containsKey(wt.getProjectId())) {
|
|
|
+ pjwtmap.get(wt.getProjectId()).add(wt);
|
|
|
+ } else {
|
|
|
+ List<ProBasicEquipment> pjs = new ArrayList<>();
|
|
|
+ pjs.add(wt);
|
|
|
+ pjwtmap.put(wt.getProjectId(), pjs);
|
|
|
+ }
|
|
|
+ if (lnwtmap.containsKey(wt.getLineId())) {
|
|
|
+ lnwtmap.get(wt.getLineId()).add(wt);
|
|
|
+ } else {
|
|
|
+ List<ProBasicEquipment> lnls = new ArrayList<>();
|
|
|
+ lnls.add(wt);
|
|
|
+ lnwtmap.put(wt.getLineId(), lnls);
|
|
|
+ }
|
|
|
+ if (cmwtlsmap.containsKey(wt.getCompanyId())) {
|
|
|
+ cmwtlsmap.get(wt.getCompanyId()).add(wt);
|
|
|
+ } else {
|
|
|
+ List<ProBasicEquipment> cmls = new ArrayList<>();
|
|
|
+ cmls.add(wt);
|
|
|
+ cmwtlsmap.put(wt.getCompanyId(), cmls);
|
|
|
+ }
|
|
|
+ if (rgwtlsmap.containsKey(wt.getRegionId())) {
|
|
|
+ rgwtlsmap.get(wt.getRegionId()).add(wt);
|
|
|
+ } else {
|
|
|
+ List<ProBasicEquipment> rgls = new ArrayList<>();
|
|
|
+ rgls.add(wt);
|
|
|
+ rgwtlsmap.put(wt.getRegionId(), rgls);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (sqwtmap.containsKey(wt.getSquareId())) {
|
|
|
+ sqwtmap.get(wt.getSquareId()).add(wt);
|
|
|
+ } else {
|
|
|
+ List<ProBasicEquipment> lnls = new ArrayList<>();
|
|
|
+ lnls.add(wt);
|
|
|
+ sqwtmap.put(wt.getSquareId(), lnls);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (cmwtmap.containsKey(wt.getCompanyId())) {
|
|
|
+ cmwtmap.get(wt.getCompanyId()).put(wt.getId(), wt);
|
|
|
+ } else {
|
|
|
+ Map<String, ProBasicEquipment> map = new HashMap<>();
|
|
|
+ map.put(wt.getId(), wt);
|
|
|
+ cmwtmap.put(wt.getCompanyId(), map);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (subWtsMap.containsKey(wt.getSubstationId())) {
|
|
|
+ subWtsMap.get(wt.getSubstationId()).add(wt);
|
|
|
+ } else {
|
|
|
+ List<ProBasicEquipment> subls = new ArrayList<>();
|
|
|
+ subls.add(wt);
|
|
|
+ subWtsMap.put(wt.getSubstationId(), subls);
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ //初始化标杆风机
|
|
|
+ for (ProBasicEquipment wt : wtls) {
|
|
|
+ if (wpwtmap.containsKey(wt.getLineId())) {
|
|
|
+ List<ProBasicEquipment> wts = wpwtmap.get(wt.getLineId());
|
|
|
+ for (ProBasicEquipment w : wts) {
|
|
|
+ if (StringUtils.notEmp(w.getIsStandard()) && w.getIsStandard() != 0) {
|
|
|
+ wtstandardmap.put(wt.getId(), w.getId());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (pjwtmap.containsKey(wt.getLineId())) {
|
|
|
+ List<ProBasicEquipment> wts = pjwtmap.get(wt.getLineId());
|
|
|
+ for (ProBasicEquipment w : wts) {
|
|
|
+ if (StringUtils.notEmp(w.getIsStandard()) && w.getIsStandard() != 0) {
|
|
|
+ wtstandardmap.put(wt.getId(), w.getId());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (lnwtmap.containsKey(wt.getLineId())) {
|
|
|
+ List<ProBasicEquipment> wts = lnwtmap.get(wt.getLineId());
|
|
|
+ for (ProBasicEquipment w : wts) {
|
|
|
+ if (StringUtils.notEmp(w.getIsStandard()) && w.getIsStandard() != 0) {
|
|
|
+ wtstandardmap.put(wt.getId(), w.getId());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ weawpls = proBasicWeatherStationService.list().stream().filter(i -> i.getIsAble() == 1).collect(Collectors.toList());
|
|
|
+ weawpls.stream().forEach(weather -> {
|
|
|
+
|
|
|
+ String subString = redisService.get(weather.getId());
|
|
|
+ Map<String, ProBasicPowerstationPoint> stringWindpowerstationpointnewMap = JSONObject.parseObject(subString, new TypeReference<Map<String, ProBasicPowerstationPoint>>() {
|
|
|
+ });
|
|
|
+ weatherwppointmap.put(weather.getId(), stringWindpowerstationpointnewMap);
|
|
|
+
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ zwpls = proBasicWindpowerstationService.list().stream().filter(i -> i.getIsAble() == 1).collect(Collectors.toList());
|
|
|
+ QueryWrapper<ProBasicPowerstation> queryWpWrapper = new QueryWrapper<>();
|
|
|
+ queryWpWrapper.orderByAsc("order_num");
|
|
|
+ wpls = proBasicWindpowerstationService.list(queryWpWrapper).stream().filter(i -> i.getIsAble() == 1).collect(Collectors.toList());
|
|
|
+
|
|
|
+ for (ProBasicPowerstation wp : wpls) {
|
|
|
+ if (cpwpmap.containsKey(wp.getCompanyId())) {
|
|
|
+ cpwpmap.get(wp.getCompanyId()).add(wp);
|
|
|
+ } else {
|
|
|
+ List<ProBasicPowerstation> wps = new ArrayList<>();
|
|
|
+ wps.add(wp);
|
|
|
+ cpwpmap.put(wp.getCompanyId(), wps);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ wpls.stream().forEach(wp -> {
|
|
|
+
|
|
|
+ wpmap.put(wp.getId(), wp);
|
|
|
+ String wpString = redisService.get(wp.getId());
|
|
|
+ Map<String, ProBasicPowerstationPoint> stringMapMap = JSONObject.parseObject(wpString, new TypeReference<Map<String, ProBasicPowerstationPoint>>() {
|
|
|
+ });
|
|
|
+ wppointmap.put(wp.getId(), stringMapMap);
|
|
|
+ });
|
|
|
+
|
|
|
+ if (!wpls.isEmpty()) {
|
|
|
+ for (ProBasicPowerstation wp : wpls) {
|
|
|
+ if (wp.getId().endsWith("FDC_STA")) {
|
|
|
+ wplsf.add(wp);
|
|
|
+ }
|
|
|
+ if (wp.getId().endsWith("GDC_STA")) {
|
|
|
+ wplsG.add(wp);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (wpmapls.containsKey(wp.getId())) {
|
|
|
+ List<ProBasicPowerstation> ls = wpmapls.get(wp.getId());
|
|
|
+ ls.add(wp);
|
|
|
+ wpmapls.put(wp.getId(), ls);
|
|
|
+ } else {
|
|
|
+ List<ProBasicPowerstation> ls = new ArrayList<>();
|
|
|
+ ls.add(wp);
|
|
|
+ wpmapls.put(wp.getId(), ls);
|
|
|
+ }
|
|
|
+
|
|
|
+ wpmap.put(wp.getId(), wp);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ stations = windpowerstationService.list();
|
|
|
+ for (ProBasicPowerstation station : stations) {
|
|
|
+ wppmap.put(station.getId(),station.getName());
|
|
|
+ wpmaps.put(station.getId(),station);
|
|
|
+ }
|
|
|
+ logger.info("缓存结束------------------------------------------------------------");
|
|
|
+ }
|
|
|
+}
|