CacheContext.java 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. package com.gyee.alarm.init;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.alibaba.fastjson.TypeReference;
  4. import com.gyee.alarm.init.redis.RedisService;
  5. import com.gyee.alarm.model.vo.AlarmCustomTag;
  6. import com.gyee.alarm.model.vo.AlarmTypeValue;
  7. import com.gyee.alarm.model.vo.AlarmVo;
  8. import com.gyee.common.model.PointData;
  9. import com.gyee.common.model.StringUtils;
  10. import com.gyee.alarm.model.auto.*;
  11. import com.gyee.alarm.service.auto.*;
  12. import com.gyee.alarm.service.realtimelibrary.TheoreticalPowerService;
  13. import org.slf4j.Logger;
  14. import org.slf4j.LoggerFactory;
  15. import org.springframework.beans.factory.annotation.Value;
  16. import org.springframework.boot.CommandLineRunner;
  17. import org.springframework.stereotype.Component;
  18. import javax.annotation.Resource;
  19. import java.util.*;
  20. import java.util.concurrent.ConcurrentHashMap;
  21. import java.util.concurrent.CopyOnWriteArrayList;
  22. import java.util.stream.Collectors;
  23. /**
  24. * @ClassName : CacheContext
  25. * @Author : xieshengjie
  26. * @Date: 2021/5/18 9:35
  27. * @Description : 缓存
  28. */
  29. @Component
  30. public class CacheContext implements CommandLineRunner {
  31. Logger logger = LoggerFactory.getLogger(CacheContext.class);
  32. @Value("${initialcode}")
  33. private String initialcode;
  34. @Resource
  35. private IProBasicEquipmentService proBasicEquipmentService;
  36. @Resource
  37. private IProBasicLineService proBasicLineService;
  38. @Resource
  39. private IProBasicProjectService proBasicProjectService;
  40. @Resource
  41. private IProBasicPowerstationService proBasicWindpowerstationService;
  42. @Resource
  43. private IProBasicMeterPointService proBasicMeterPointService;
  44. @Resource
  45. private IProEconEquipmentmodelService proEconEquipmentmodelService;
  46. @Resource
  47. private IProEconWtPowerCurveFittingService proEconWtPowerCurveFittingService;
  48. @Resource
  49. private IProBasicWindturbinePowerService proBasicWindturbinePowerService;
  50. @Resource
  51. private RedisService redisService;
  52. @Resource
  53. private IProBasicModelPowerService proBasicModelPowerService;
  54. @Resource
  55. private IProBasicSubStationService proBasicSubStationService;
  56. @Resource
  57. private IProBasicSquareService proBasicSquareService;
  58. @Resource
  59. private IProBasicCompanyService proBasicCompanyService;
  60. @Resource
  61. private IProBasicRegionService proBasicRegionService;
  62. @Resource
  63. private TheoreticalPowerService theoreticalPowerService;
  64. @Resource
  65. private IProBasicModelPowerRdService proBasicModelPowerRdService;
  66. @Resource
  67. private IProBasicWeatherStationService proBasicWeatherStationService;
  68. @Resource
  69. private IProBasicBranchService proBasicBranchService;
  70. @Resource
  71. private IProBasicEnergyGroupService proBasicEnergyGroupService;
  72. @Resource
  73. private IProEconStateAiService proEconStateAiService;
  74. @Resource
  75. private IProBasicStatusPointService proBasicStatusPointService;
  76. @Value("${runWindpowerstation}")
  77. private String runWindpowerstation;
  78. public static List<AlarmVo> alarmVoList = new ArrayList<>();
  79. public static List<ProBasicEquipment> wtls = new ArrayList<>();
  80. public static List<ProBasicEquipment> wt_fjls = new ArrayList<>();
  81. public static List<ProBasicProject> pjls = new ArrayList<>();
  82. public static List<ProBasicLine> lnls = new ArrayList<>();
  83. public static List<ProBasicSubStation> subwpls = new ArrayList<>();
  84. public static List<ProBasicWeatherStation> wswpls = new ArrayList<>();
  85. public static List<ProBasicSquare> sqls = new ArrayList<>();
  86. public static List<ProBasicPowerstation> wpls = new ArrayList<>();
  87. public static List<ProBasicPowerstation> zwpls = new ArrayList<>();
  88. public static List<ProBasicCompany> cpls = new ArrayList<>();
  89. public static List<ProBasicRegion> rgls = new ArrayList<>();
  90. public static List<ProBasicEnergyGroup> egls = new ArrayList<>();
  91. public static Map<String,ProBasicProject> pjmap = new HashMap<>();
  92. public static Map<String,ProBasicLine> lnmap = new HashMap<>();
  93. public static Map<String,ProBasicRegion> rgmap = new HashMap<>();
  94. public static Map<String,ProBasicEnergyGroup> egmap = new HashMap<>();
  95. public static Map<String,ProBasicCompany> cpmap = new HashMap<>();
  96. public static Map<String,List<ProBasicPowerstation>> cpwpmap = new HashMap<>();
  97. public static Map<String,List<ProBasicCompany>> rgcpmap = new HashMap<>();
  98. public static Map<String,ProBasicSquare> sqmap = new HashMap<>();
  99. public static Map<String, ProBasicPowerstation> wpmap = new HashMap<>();
  100. public static List<ProBasicMeterPoint> meterpoints = new ArrayList<>();
  101. public static Map<String,ProBasicMeterPoint> meterpointMap = new HashMap<>();
  102. public static Map<String,List<ProBasicProject>> wppromap = new HashMap<>();
  103. public static Map<String,List<ProBasicLine>> prolinemap = new HashMap<>();
  104. public static Map<String,List<ProBasicEquipment>> wpwtmap = new HashMap<>();
  105. public static Map<String,List<ProBasicEquipment>> pjwtmap = new HashMap<>();
  106. public static Map<String,List<ProBasicEquipment>> lnwtmap = new HashMap<>();
  107. public static List<ProBasicWeatherStation> wsls=new ArrayList<>();
  108. public static Map<String,List<ProBasicWeatherStation>> poWsStationMap = new HashMap<>();
  109. public static Map<String,List<ProBasicEquipment>> sqwtmap = new HashMap<>();
  110. public static Map<String, Map<String, ProBasicEquipmentPoint>> wtpAimap = new HashMap<>();// 风电机测点AI表
  111. public static Map<String,Map<String, ProBasicPowerstationPoint>> linepointmap =new HashMap<>();
  112. public static Map<String,Map<String, ProBasicPowerstationPoint>> propointmap =new HashMap<>();
  113. public static Map<String,Map<String, ProBasicPowerstationPoint>> wppointmap =new HashMap<>();
  114. public static Map<String,Map<String, ProBasicPowerstationPoint>> subwppointmap =new HashMap<>();
  115. public static Map<String,Map<String, ProBasicPowerstationPoint>> wswppointmap =new HashMap<>();
  116. public static Map<String,Map<String, ProBasicPowerstationPoint>> companypointmap =new HashMap<>();
  117. public static Map<String,Map<String, ProBasicPowerstationPoint>> regionpointmap =new HashMap<>();
  118. public static Map<String,Map<String, ProBasicPowerstationPoint>> grouppointmap =new HashMap<>();
  119. public static Map<String,Map<Double,Double>> zbzglMap = new HashMap<>();
  120. public static Map<String,ProEconEquipmentmodel> modelMap = new HashMap<>();
  121. public static Map<String,Map<Double,Double>> zzsglMap = new HashMap<>();
  122. public static Map<String,Double> modelpower = new HashMap<>();
  123. public static Map<String,String> wtstandardmap = new HashMap<>();
  124. public static Map<String, ProBasicEquipment> wtmap = new HashMap<>();
  125. public static Map<String,Map<Double,ProBasicModelPower>> modelpowermap = new TreeMap<>();
  126. public static List<ProBasicModelPower> mpls=new ArrayList<>();
  127. public static List<ProEconEquipmentmodel> equipmentmodels=new ArrayList<>();
  128. public static Map<String,List<ProBasicEquipment>> subWtsMap = new HashMap<>();
  129. public static List<ProBasicModelPowerRd> theoreticalPowerList=new ArrayList<>();
  130. public static Map<String, Map<Double,ProBasicModelPowerRd>> theoreticalPowerMap = new HashMap<>(); //理论,保证功率
  131. public static Map<String, Map<Double,ProEconWtPowerCurveFitting>> curveFittingPowerMap = new HashMap<>(); //自算,最优功率
  132. public static Map<String,List<ProBasicStatusPoint>> statusMap = new HashMap<>();
  133. public static Map<String,Map<String, ProBasicPowerstationPoint>> wspointmap =new HashMap<>();
  134. public static Map<String,Map<String, ProBasicEquipmentPoint>> zlpointmap =new HashMap<>();
  135. public static Map<String,Map<Integer,Integer>> aistateMap = new HashMap<>();
  136. public static Map<String, Integer> redisDbMap = new HashMap<>();
  137. public static List<ProBasicStatusPoint> pointdis = new ArrayList<>();
  138. public static Map< String,Map<String, ProBasicStatusPoint>> pointdismap = new HashMap<>();
  139. public static Map<String, Map<String, PointData>> wtDataValueMap = new ConcurrentHashMap<>();// 设备实时数据
  140. public static Map<String,Map<String, PointData>> wpDataValueMap =new ConcurrentHashMap<>();// 场站实时数据
  141. public static Map<String,Map<String, PointData>> wsDataValueMap =new ConcurrentHashMap<>();// 升压站实时数据
  142. public static List<ProBasicEquipmentPoint> wtPointList = new ArrayList<>();// 设备测点集合
  143. public static List<ProBasicPowerstationPoint> wpPointList =new ArrayList<>(); //场站测点集合
  144. public static List<ProBasicPowerstationPoint> wsPointList =new ArrayList<>(); //升压站测点集合
  145. public static Map<String, List<ProEconAlarmRule>> alarmRulesMap = new HashMap<>();
  146. public static List<AlarmVo> alarmCtList=new ArrayList<>();
  147. public static Map<String,AlarmVo> alarmCtMap=new HashMap<>();
  148. public static Map<String, List<AlarmVo>> alarmCtLsMap = new HashMap<>();
  149. public static List<AlarmCustomTag> alarmTags = new CopyOnWriteArrayList<>();
  150. @Override
  151. public void run(String... args) throws Exception {
  152. logger.info("缓存开始------------------------------------------------------------");
  153. // if(redisService.hasKey(("alarmVoList")))
  154. // {
  155. // String alarmVoListStr = redisService.get("alarmVoList");
  156. // alarmVoList = JSONObject.parseObject(alarmVoListStr, new TypeReference<List<AlarmVo>>() {
  157. // });
  158. //
  159. // }
  160. List<String> runWpids = Arrays.asList(runWindpowerstation.split(","));
  161. logger.info(runWpids.get(0)+"------------------"+runWpids.size());
  162. wsls= proBasicWeatherStationService.list().stream().filter(i->runWpids.contains(i.getWindpowerstationId()) && i.getIsAble()==1).collect(Collectors.toList());
  163. if(!wsls.isEmpty())
  164. {
  165. for(ProBasicWeatherStation ws:wsls)
  166. {
  167. if(poWsStationMap.containsKey(ws.getWindpowerstationId()))
  168. {
  169. List<ProBasicWeatherStation> ls=poWsStationMap.get(ws.getWindpowerstationId());
  170. ls.add(ws);
  171. poWsStationMap.put(ws.getWindpowerstationId(),ls);
  172. }else {
  173. List<ProBasicWeatherStation> ls=new ArrayList<>();
  174. ls.add(ws);
  175. poWsStationMap.put(ws.getWindpowerstationId(),ls);
  176. }
  177. }
  178. }
  179. theoreticalPowerList= proBasicModelPowerRdService.list();
  180. equipmentmodels = proEconEquipmentmodelService.list();
  181. equipmentmodels.stream().forEach(e->{
  182. modelMap.put(e.getId(),e);
  183. });
  184. mpls=proBasicModelPowerService.list();
  185. mpls.sort(Comparator.comparing(ProBasicModelPower::getSpeed));
  186. if(!mpls.isEmpty())
  187. {
  188. for(ProBasicModelPower mp:mpls)
  189. {
  190. if(modelpowermap.containsKey(mp.getModelId()))
  191. {
  192. Map<Double,ProBasicModelPower> tempmap=modelpowermap.get(mp.getModelId());
  193. tempmap.put(mp.getSpeed(),mp);
  194. }else {
  195. Map<Double,ProBasicModelPower> tempmap=new HashMap<>();
  196. tempmap.put(mp.getSpeed(),mp);
  197. modelpowermap.put(mp.getModelId(),tempmap);
  198. }
  199. }
  200. }
  201. sqls=proBasicSquareService.list().stream().filter(i->runWpids.contains(i.getWindpowerstationId()) && i.getIsAble()==1).collect(Collectors.toList());
  202. if (!sqls.isEmpty())
  203. {
  204. for(ProBasicSquare sq:sqls)
  205. {
  206. sqmap.put(sq.getId(),sq);
  207. }
  208. }
  209. cpls=proBasicCompanyService.list().stream().filter(i->i.getIsAble().equals(1)).collect(Collectors.toList());
  210. if (!cpls.isEmpty())
  211. {
  212. for(ProBasicCompany sq:cpls)
  213. {
  214. cpmap.put(sq.getId(),sq);
  215. if (redisService.hasKey(sq.getId()+"0")){
  216. String cp0String = redisService.get(sq.getId()+"0");
  217. Map<String, ProBasicPowerstationPoint> stringWindpowerstationpointnewMap = JSONObject.parseObject(cp0String, new TypeReference<Map<String, ProBasicPowerstationPoint>>() {
  218. });
  219. companypointmap.put(sq.getId()+"0",stringWindpowerstationpointnewMap);
  220. }
  221. if (redisService.hasKey(sq.getId()+"-1")){
  222. String cp1String = redisService.get(sq.getId()+"-1");
  223. Map<String, ProBasicPowerstationPoint> stringWindpowerstationpointnewMap = JSONObject.parseObject(cp1String, new TypeReference<Map<String, ProBasicPowerstationPoint>>() {
  224. });
  225. companypointmap.put(sq.getId()+"-1",stringWindpowerstationpointnewMap);
  226. }
  227. if (redisService.hasKey(sq.getId()+"-2")){
  228. String cp2String = redisService.get(sq.getId()+"-2");
  229. Map<String, ProBasicPowerstationPoint> stringWindpowerstationpointnewMap = JSONObject.parseObject(cp2String, new TypeReference<Map<String, ProBasicPowerstationPoint>>() {
  230. });
  231. companypointmap.put(sq.getId()+"-2",stringWindpowerstationpointnewMap);
  232. }
  233. }
  234. }
  235. rgls=proBasicRegionService.list().stream().filter(i->i.getIsAble()==1).collect(Collectors.toList());
  236. if (!rgls.isEmpty())
  237. {
  238. for(ProBasicRegion sq:rgls)
  239. {
  240. rgmap.put(sq.getId(),sq);
  241. if (redisService.hasKey(sq.getId()+"0")){
  242. String cp0String = redisService.get(sq.getId()+"0");
  243. Map<String, ProBasicPowerstationPoint> stringWindpowerstationpointnewMap = JSONObject.parseObject(cp0String, new TypeReference<Map<String, ProBasicPowerstationPoint>>() {
  244. });
  245. regionpointmap.put(sq.getId()+"0",stringWindpowerstationpointnewMap);
  246. }
  247. if (redisService.hasKey(sq.getId()+"-1")){
  248. String cp1String = redisService.get(sq.getId()+"-1");
  249. Map<String, ProBasicPowerstationPoint> stringWindpowerstationpointnewMap = JSONObject.parseObject(cp1String, new TypeReference<Map<String, ProBasicPowerstationPoint>>() {
  250. });
  251. regionpointmap.put(sq.getId()+"-1",stringWindpowerstationpointnewMap);
  252. }
  253. if (redisService.hasKey(sq.getId()+"-2")){
  254. String cp2String = redisService.get(sq.getId()+"-2");
  255. Map<String, ProBasicPowerstationPoint> stringWindpowerstationpointnewMap = JSONObject.parseObject(cp2String, new TypeReference<Map<String, ProBasicPowerstationPoint>>() {
  256. });
  257. regionpointmap.put(sq.getId()+"-2",stringWindpowerstationpointnewMap);
  258. }
  259. }
  260. }
  261. egls=proBasicEnergyGroupService.list().stream().filter(i->i.getIsAble()==1 && !i.getParentid().equals("0")).collect(Collectors.toList());
  262. if (!egls.isEmpty())
  263. {
  264. for(ProBasicEnergyGroup sq:egls)
  265. {
  266. egmap.put(sq.getId(),sq);
  267. if (redisService.hasKey(sq.getId()+"0")){
  268. String eg0String = redisService.get(sq.getId()+"0");
  269. Map<String, ProBasicPowerstationPoint> stringWindpowerstationpointnewMap = JSONObject.parseObject(eg0String, new TypeReference<Map<String, ProBasicPowerstationPoint>>() {
  270. });
  271. grouppointmap.put(sq.getId()+"0",stringWindpowerstationpointnewMap);
  272. }
  273. if (redisService.hasKey(sq.getId()+"-1")){
  274. String eg1String = redisService.get(sq.getId()+"-1");
  275. Map<String, ProBasicPowerstationPoint> stringWindpowerstationpointnewMap = JSONObject.parseObject(eg1String, new TypeReference<Map<String, ProBasicPowerstationPoint>>() {
  276. });
  277. grouppointmap.put(sq.getId()+"-1",stringWindpowerstationpointnewMap);
  278. }
  279. if (redisService.hasKey(sq.getId()+"-2")){
  280. String eg2String = redisService.get(sq.getId()+"-2");
  281. Map<String, ProBasicPowerstationPoint> stringWindpowerstationpointnewMap = JSONObject.parseObject(eg2String, new TypeReference<Map<String, ProBasicPowerstationPoint>>() {
  282. });
  283. grouppointmap.put(sq.getId()+"-2",stringWindpowerstationpointnewMap);
  284. }
  285. }
  286. }
  287. for(ProBasicCompany cp:cpls)
  288. {
  289. if (rgcpmap.containsKey(cp.getRegionId())){
  290. rgcpmap.get(cp.getRegionId()).add(cp);
  291. }else {
  292. List<ProBasicCompany> wps = new ArrayList<>();
  293. wps.add(cp);
  294. rgcpmap.put(cp.getRegionId(),wps);
  295. }
  296. }
  297. for(ProBasicPowerstation wp:wpls)
  298. {
  299. if (cpwpmap.containsKey(wp.getCompanyId())){
  300. cpwpmap.get(wp.getCompanyId()).add(wp);
  301. }else {
  302. List<ProBasicPowerstation> wps = new ArrayList<>();
  303. wps.add(wp);
  304. cpwpmap.put(wp.getCompanyId(),wps);
  305. }
  306. }
  307. wsls.stream().forEach(p->{
  308. String wsString = redisService.get(p.getId());
  309. Map<String, ProBasicPowerstationPoint> stringWindpowerstationpointnewMap = JSONObject.parseObject(wsString, new TypeReference<Map<String, ProBasicPowerstationPoint>>() {
  310. });
  311. if(null !=stringWindpowerstationpointnewMap)
  312. {
  313. for(Map.Entry<String,ProBasicPowerstationPoint> entry : stringWindpowerstationpointnewMap.entrySet()){
  314. wsPointList.add(entry.getValue());
  315. }
  316. }
  317. wspointmap.put(p.getId(),stringWindpowerstationpointnewMap);
  318. });
  319. // //支路
  320. // List<ProBasicBranch> basicBranches = proBasicBranchService.list();
  321. // if (basicBranches!=null && basicBranches.size()>0){
  322. // basicBranches.stream().forEach(b->{
  323. // String wsString = redisService.get(b.getId());
  324. // Map<String, ProBasicEquipmentPoint> stringWindpowerstationpointnewMap = JSONObject.parseObject(wsString, new TypeReference<Map<String, ProBasicEquipmentPoint>>() {
  325. // });
  326. // zlpointmap.put(b.getId(),stringWindpowerstationpointnewMap);
  327. // });
  328. // }
  329. wtls = proBasicEquipmentService.list().stream().filter(i->runWpids.contains(i.getWindpowerstationId()) && i.getIsable()==1).collect(Collectors.toList());
  330. logger.info(wtls.size()+"");
  331. wtls.forEach(wt->{
  332. if(modelMap.containsKey(wt.getModelId()))
  333. {
  334. ProEconEquipmentmodel equipmentmodel = modelMap.get(wt.getModelId());
  335. modelpower.put(wt.getModelId(),equipmentmodel.getPowerProduction().doubleValue());
  336. }
  337. if(wt.getId().contains("_F_"))
  338. {
  339. wt_fjls.add(wt);
  340. }
  341. wtmap.put(wt.getId(),wt);
  342. //标杆风机初始化
  343. wtstandardmap.put(wt.getId(),wt.getId());
  344. String wtString = redisService.get(wt.getId());
  345. Map<String, ProBasicEquipmentPoint> stringWindturbinetestingpointnewMap = JSONObject.parseObject(wtString, new TypeReference<Map<String, ProBasicEquipmentPoint>>() {
  346. });
  347. if(null !=stringWindturbinetestingpointnewMap)
  348. {
  349. for(Map.Entry<String,ProBasicEquipmentPoint> entry : stringWindturbinetestingpointnewMap.entrySet()){
  350. if (com.gyee.alarm.util.StringUtils.notEmp(initialcode) &&
  351. com.gyee.alarm.util.StringUtils.notEmp(entry.getValue().getNemCode()) &&
  352. !entry.getValue().getNemCode().equals(initialcode)
  353. )
  354. {
  355. wtPointList.add(entry.getValue());
  356. }
  357. }
  358. }
  359. wtpAimap.put(wt.getId(),stringWindturbinetestingpointnewMap);
  360. if (wpwtmap.containsKey(wt.getWindpowerstationId())){
  361. wpwtmap.get(wt.getWindpowerstationId()).add(wt);
  362. }else {
  363. List<ProBasicEquipment> wps = new ArrayList<>();
  364. wps.add(wt);
  365. wpwtmap.put(wt.getWindpowerstationId(),wps);
  366. }
  367. if (pjwtmap.containsKey(wt.getProjectId())){
  368. pjwtmap.get(wt.getProjectId()).add(wt);
  369. }else {
  370. List<ProBasicEquipment> pjs = new ArrayList<>();
  371. pjs.add(wt);
  372. pjwtmap.put(wt.getProjectId(),pjs);
  373. }
  374. if (lnwtmap.containsKey(wt.getLineId())){
  375. lnwtmap.get(wt.getLineId()).add(wt);
  376. }else {
  377. List<ProBasicEquipment> lnls = new ArrayList<>();
  378. lnls.add(wt);
  379. lnwtmap.put(wt.getLineId(),lnls);
  380. }
  381. if (sqwtmap.containsKey(wt.getSquareId())){
  382. sqwtmap.get(wt.getSquareId()).add(wt);
  383. }else {
  384. List<ProBasicEquipment> lnls = new ArrayList<>();
  385. lnls.add(wt);
  386. sqwtmap.put(wt.getSquareId(),lnls);
  387. }
  388. });
  389. //初始化标杆风机
  390. for(ProBasicEquipment wt:wtls)
  391. {
  392. if(wpwtmap.containsKey(wt.getLineId()))
  393. {
  394. List<ProBasicEquipment> wts=wpwtmap.get(wt.getLineId());
  395. for(ProBasicEquipment w:wts)
  396. {
  397. if(StringUtils.notEmp(w.getIsStandard()) && w.getIsStandard()!=0)
  398. {
  399. wtstandardmap.put(wt.getId(),w.getId());
  400. break;
  401. }
  402. }
  403. }
  404. if(pjwtmap.containsKey(wt.getLineId()))
  405. {
  406. List<ProBasicEquipment> wts=pjwtmap.get(wt.getLineId());
  407. for(ProBasicEquipment w:wts)
  408. {
  409. if(StringUtils.notEmp(w.getIsStandard()) && w.getIsStandard()!=0)
  410. {
  411. wtstandardmap.put(wt.getId(),w.getId());
  412. break;
  413. }
  414. }
  415. }
  416. if(lnwtmap.containsKey(wt.getLineId()))
  417. {
  418. List<ProBasicEquipment> wts=lnwtmap.get(wt.getLineId());
  419. for(ProBasicEquipment w:wts)
  420. {
  421. if(StringUtils.notEmp(w.getIsStandard()) && w.getIsStandard()!=0)
  422. {
  423. wtstandardmap.put(wt.getId(),w.getId());
  424. break;
  425. }
  426. }
  427. }
  428. }
  429. pjls = proBasicProjectService.list().stream().filter(i->runWpids.contains(i.getWindpowerstationId()) && i.getIsAble()==1).collect(Collectors.toList());
  430. pjls.stream().forEach(p->{
  431. pjmap.put(p.getId(),p);
  432. if (wppromap.containsKey(p.getWindpowerstationId())){
  433. wppromap.get(p.getWindpowerstationId()).add(p);
  434. }else {
  435. List<ProBasicProject> prolist = new ArrayList<>();
  436. prolist.add(p);
  437. wppromap.put(p.getWindpowerstationId(),prolist);
  438. }
  439. String pjString = redisService.get(p.getId());
  440. Map<String, ProBasicPowerstationPoint> stringWindpowerstationpointnewMap = JSONObject.parseObject(pjString, new TypeReference<Map<String, ProBasicPowerstationPoint>>() {
  441. });
  442. propointmap.put(p.getId(),stringWindpowerstationpointnewMap);
  443. });
  444. subwpls = proBasicSubStationService.list().stream().filter(i->runWpids.contains(i.getWindpowerstationId()) && i.getIsAble()==1).collect(Collectors.toList());
  445. subwpls.stream().forEach(sub->{
  446. String subString = redisService.get(sub.getId());
  447. Map<String, ProBasicPowerstationPoint> stringWindpowerstationpointnewMap = JSONObject.parseObject(subString, new TypeReference<Map<String, ProBasicPowerstationPoint>>() {
  448. });
  449. subwppointmap.put(sub.getId(),stringWindpowerstationpointnewMap);
  450. List<ProBasicEquipment> collect = wtls.stream().filter(wt -> wt.getSubstationId().equals(sub.getId())).collect(Collectors.toList());
  451. subWtsMap.put(sub.getId(),collect);
  452. });
  453. wswpls = proBasicWeatherStationService.list().stream().filter(i->runWpids.contains(i.getWindpowerstationId()) && i.getIsAble()==1).collect(Collectors.toList());
  454. wswpls.stream().forEach(ws->{
  455. String subString = redisService.get(ws.getId());
  456. Map<String, ProBasicPowerstationPoint> stringWindpowerstationpointnewMap = JSONObject.parseObject(subString, new TypeReference<Map<String, ProBasicPowerstationPoint>>() {
  457. });
  458. wswppointmap.put(ws.getId(),stringWindpowerstationpointnewMap);
  459. // List<ProBasicEquipment> collect = wtls.stream().filter(wt -> wt.getSubstationId().equals(sub.getId())).collect(Collectors.toList());
  460. // subWtsMap.put(sub.getId(),collect);
  461. });
  462. List<ProEconStateAi> proEconStateAis = proEconStateAiService.list();
  463. proEconStateAis.stream().forEach(ai->{
  464. if (aistateMap.containsKey(ai.getModelid())){
  465. aistateMap.get(ai.getModelid()).put(ai.getOriginalState(),ai.getMappingState());
  466. }else {
  467. Map<Integer,Integer> stateMap = new HashMap<>();
  468. stateMap.put(ai.getOriginalState(),ai.getMappingState());
  469. aistateMap.put(ai.getModelid(),stateMap);
  470. }
  471. });
  472. lnls = proBasicLineService.list().stream().filter(i-> StringUtils.isNotNull(pjmap.get(i.getProjectId())) && runWpids.contains(pjmap.get(i.getProjectId()).getWindpowerstationId()) && i.getIsAble()==1).collect(Collectors.toList());
  473. lnls.stream().forEach(l->{
  474. lnmap.put(l.getId(),l);
  475. if (prolinemap.containsKey(l.getProjectId())){
  476. prolinemap.get(l.getProjectId()).add(l);
  477. }else {
  478. List<ProBasicLine> lineList = new ArrayList<>();
  479. lineList.add(l);
  480. prolinemap.put(l.getProjectId(),lineList);
  481. }
  482. String lnString = redisService.get(l.getId());
  483. Map<String, ProBasicPowerstationPoint> stringWindpowerstationpointnewMap = JSONObject.parseObject(lnString, new TypeReference<Map<String, ProBasicPowerstationPoint>>() {
  484. });
  485. linepointmap.put(l.getId(),stringWindpowerstationpointnewMap);
  486. });
  487. zwpls = proBasicWindpowerstationService.list().stream().filter(i->runWpids.contains(i.getId())&& i.getIsAble()==1).collect(Collectors.toList());
  488. wpls = proBasicWindpowerstationService.list().stream().filter(i->runWpids.contains(i.getId()) && i.getIsAble()==1).collect(Collectors.toList());;
  489. meterpoints = proBasicMeterPointService.list().stream().filter(i->runWpids.contains(i.getWindpowerstationId()) && i.getIsAble()==1).collect(Collectors.toList());
  490. if(null !=meterpoints)
  491. {
  492. meterpoints.stream().forEach(meterpoint -> {
  493. meterpointMap.put(meterpoint.getNemCode(),meterpoint);
  494. });
  495. }
  496. wpls.stream().forEach(wp->{
  497. wpmap.put(wp.getId(),wp);
  498. String wpString = redisService.get(wp.getId());
  499. Map<String, ProBasicPowerstationPoint> stringMapMap = JSONObject.parseObject(wpString, new TypeReference<Map<String, ProBasicPowerstationPoint>>() {
  500. });
  501. if(null !=stringMapMap)
  502. {
  503. for(Map.Entry<String,ProBasicPowerstationPoint> entry : stringMapMap.entrySet()){
  504. wpPointList.add(entry.getValue());
  505. }
  506. }
  507. wppointmap.put(wp.getId(),stringMapMap);
  508. });
  509. // String llglString = redisService.get("ZLLGL");
  510. // theoreticalPowerMap = JSONObject.parseObject(llglString, new TypeReference<Map<String, Map<Double,ProBasicModelPowerRd>>>() {
  511. // });
  512. String sszzt = redisService.get("SSZZT");
  513. statusMap = JSONObject.parseObject(sszzt, new TypeReference<Map<String,List<ProBasicStatusPoint>>>() {
  514. });
  515. // List<ProEconWtPowerCurveFitting> econWtPowerCurveFittings = proEconWtPowerCurveFittingService.list();
  516. // if (StringUtils.isNotNull(econWtPowerCurveFittings)){
  517. // econWtPowerCurveFittings.stream().forEach(curveFitting->{
  518. // if (curveFittingPowerMap.containsKey(curveFitting.getWindturbineId())){
  519. // curveFittingPowerMap.get(curveFitting.getWindturbineId()).put(curveFitting.getSpeed(),curveFitting);
  520. // }else {
  521. // Map<Double,ProEconWtPowerCurveFitting> powerMap = new HashMap<>();
  522. // powerMap.put(curveFitting.getSpeed(),curveFitting);
  523. // curveFittingPowerMap.put(curveFitting.getWindturbineId(),powerMap);
  524. // }
  525. // });
  526. // }
  527. // for (int i = 0; i < 9; i++) {
  528. // Set<String> keys = redisService.keys(i);
  529. //
  530. // for (String key : keys) {
  531. // redisDbMap.put(key, i);
  532. // }
  533. // }
  534. //
  535. // pointdis = proBasicStatusPointService.list();
  536. //
  537. // Map<String, ProBasicStatusPoint> items = null;
  538. // if (pointdis != null && !pointdis.isEmpty()) {
  539. // for (int i = 0; i < pointdis.size(); i++) {
  540. // ProBasicStatusPoint point = pointdis.get(i);
  541. // if (pointdismap.containsKey(point.getWindturbineId())) {
  542. // items = pointdismap.get(point.getWindturbineId());
  543. // items.put(point.getUniformCode(), point);
  544. // } else {
  545. // items = new HashMap<String, ProBasicStatusPoint>();
  546. // pointdismap.put(point.getWindturbineId(), items);
  547. // items.put(point.getUniformCode(), point);
  548. // }
  549. //
  550. // }
  551. // }
  552. logger.info("缓存结束------------------------------------------------------------");
  553. }
  554. }