LimitService.java 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283
  1. package com.gyee.generation.service;
  2. import com.gyee.common.contant.ContantXk;
  3. import com.gyee.common.model.DNAStatVal;
  4. import com.gyee.common.model.PointData;
  5. import com.gyee.generation.init.CacheContext;
  6. import com.gyee.generation.model.auto.ProBasicEquipmentPoint;
  7. import com.gyee.generation.model.auto.ProBasicEquipment;
  8. import com.gyee.generation.model.auto.ProBasicPowerstationPoint;
  9. import com.gyee.generation.model.auto.ProEconLineElectrical;
  10. import com.gyee.generation.model.vo.RealTimeParameterVo;
  11. import com.gyee.generation.model.vo.SLWindpowerVo;
  12. import com.gyee.generation.model.vo.StatData;
  13. import com.gyee.generation.service.auto.IProEconLineElectricalService;
  14. import com.gyee.generation.util.DateUtils;
  15. import com.gyee.generation.util.StringUtils;
  16. import com.gyee.generation.util.realtimesource.IEdosUtil;
  17. import org.springframework.stereotype.Service;
  18. import javax.annotation.Resource;
  19. import java.util.*;
  20. import java.util.function.Function;
  21. import java.util.stream.Collectors;
  22. @Service
  23. public class LimitService {
  24. @Resource
  25. private IProEconLineElectricalService proEconLineElectricalService;
  26. @Resource
  27. private IEdosUtil edosUtil;
  28. // 受累
  29. Map<String, SLWindpowerVo> sl;
  30. Map<String, Integer> slvalue;
  31. Map<String, ProBasicEquipmentPoint> windSL;
  32. public void execStatuSL() throws Exception {
  33. if (sl == null)
  34. initsl();
  35. else
  36. {
  37. Map<String, Integer> slv = new HashMap<String, Integer>();
  38. Date dt =new Date();
  39. Map<String, RealTimeParameterVo> rList = new HashMap<String, RealTimeParameterVo>();
  40. for (SLWindpowerVo item : sl.values())
  41. {
  42. //事故总
  43. if (item.getACCIDENTSIGNAL().size() > 0)
  44. {
  45. for (String key : item.getACCIDENTSIGNAL().keySet())
  46. {
  47. Double cx = 0.0;
  48. cx = edosUtil.getRealData(key).getPointValueInDouble();
  49. if (cx == 1)
  50. {
  51. for (String windturbineid : item.getACCIDENTSIGNAL().get(key))
  52. {
  53. BuilderSL(dt, rList, key, windturbineid, slv, 3);
  54. }
  55. }
  56. }
  57. }
  58. //出线断路器判断
  59. if (item.getNETOUTCODE().size() > 0)
  60. {
  61. for (String key : item.getNETOUTCODE().keySet())
  62. {
  63. Double cx = 1.0;
  64. cx = edosUtil.getRealData(key).getPointValueInDouble();
  65. if (cx == 0)
  66. {
  67. for (String windturbineid : item.getNETOUTCODE().get(key))
  68. {
  69. BuilderSL(dt, rList, key, windturbineid, slv, 4);
  70. }
  71. }
  72. }
  73. }
  74. else
  75. {
  76. //主变高压侧
  77. if (item.getNETHIGHCODE().size() > 0)
  78. {
  79. for (String key : item.getNETHIGHCODE().keySet())
  80. {
  81. Double cx = 1.0;
  82. cx = edosUtil.getRealData(key).getPointValueInDouble();
  83. if (cx == 0)
  84. {
  85. for (String windturbineid : item.getNETHIGHCODE().get(key))
  86. {
  87. BuilderSL(dt, rList, key, windturbineid, slv, 4);
  88. }
  89. }
  90. else
  91. {
  92. if (item.getPTCURRENTCODE().containsKey(key) && item.getPTCURRENT().containsKey(key))
  93. {
  94. String code = item.getPTCURRENTCODE().get(key);
  95. Double max = item.getPTCURRENT().get(key);
  96. cx =edosUtil.getRealData(code).getPointValueInDouble();
  97. if (cx > max)
  98. {
  99. for (String windturbineid : item.getNETOUTCODE().get(key))
  100. {
  101. BuilderSL(dt, rList, key, windturbineid, slv, 4);
  102. }
  103. }
  104. }
  105. if (item.getPTVOLTAGECODE().containsKey(key) && item.getPTVOLTAGEHIGH().containsKey(key) && item.getPTVOLTAGELOW().containsKey(key))
  106. {
  107. String code = item.getPTVOLTAGECODE().get(key);
  108. Double max = item.getPTVOLTAGEHIGH().get(key);
  109. Double min = item.getPTVOLTAGELOW().get(key);
  110. cx =edosUtil.getRealData(code).getPointValueInDouble();
  111. if (cx > max || cx < min)
  112. {
  113. for (String windturbineid : item.getNETOUTCODE().get(key))
  114. {
  115. BuilderSL(dt, rList, key, windturbineid, slv, 4);
  116. }
  117. }
  118. }
  119. }
  120. }
  121. }
  122. }
  123. //主变高压侧断路器判断
  124. if (item.getNETHIGHCODE().size() > 0)
  125. {
  126. for (String key : item.getNETHIGHCODE().keySet())
  127. {
  128. Double cx = 1.0;
  129. cx =edosUtil.getRealData(key).getPointValueInDouble();
  130. if (cx == 0)
  131. {
  132. for (String windturbineid : item.getNETHIGHCODE().get(key))
  133. {
  134. BuilderSL(dt, rList, key, windturbineid, slv, 2);
  135. }
  136. }
  137. }
  138. }
  139. //主变低压侧断路器判断
  140. if (item.getNETLOWCODE().size() > 0)
  141. {
  142. for (String key : item.getNETLOWCODE().keySet())
  143. {
  144. Double cx = 1.0;
  145. cx =edosUtil.getRealData(key).getPointValueInDouble();
  146. if (cx == 0)
  147. {
  148. for (String windturbineid : item.getNETLOWCODE().get(key))
  149. {
  150. BuilderSL(dt, rList, key, windturbineid, slv, 2);
  151. }
  152. }
  153. }
  154. }
  155. //进线断路器判断
  156. if (item.getLINECODE().size() > 0)
  157. {
  158. for (String key : item.getLINECODE().keySet())
  159. {
  160. Double cx = 1.0;
  161. cx =edosUtil.getRealData(key).getPointValueInDouble();
  162. if (cx == 0)
  163. {
  164. for (String windturbineid : item.getLINECODE().get(key))
  165. {
  166. BuilderSL(dt, rList, key, windturbineid, slv, 2);
  167. }
  168. }
  169. }
  170. }
  171. }
  172. // List<PointData> pols=new ArrayList<>();
  173. for (String key : windSL.keySet())
  174. {
  175. double t =edosUtil.getRealData(windSL.get(key).getNemCode()).getPointValueInDouble();
  176. if (!slv.containsKey(key))
  177. {
  178. if (slvalue.get(key) != 0)
  179. {
  180. slvalue.put(key,0);
  181. if (t == 2 || t == 3 || t == 4)
  182. {
  183. RealTimeParameterVo rt = new RealTimeParameterVo();
  184. rt.setPoint(windSL.get(key).getNemCode());
  185. rt.setTime(dt);
  186. rt.setInsertValue(0.0);
  187. rList.put(key, rt);
  188. // PointData po=new PointData();
  189. // po.setEdnaId(windSL.get(key).getId());
  190. // po.setPointTime(dt.getTime());
  191. // po.setPointValueInDouble(0.0);
  192. // pols.add(po);
  193. }
  194. }
  195. }
  196. }
  197. if (rList.size() > 0)
  198. {
  199. //批量插入测点
  200. edosUtil.sendMultiRealTimeParamete(rList.values().stream().collect(Collectors.toList()));
  201. // ednaHelper.AddRealtimeEDNA(rList.Values.ToList());
  202. }
  203. }
  204. }
  205. private void BuilderSL(Date dt, Map<String, RealTimeParameterVo> rList, String key, String windturbineid, Map<String, Integer> slv, Integer i)
  206. {
  207. if (!slv.containsKey(windturbineid))
  208. {
  209. slv.put(windturbineid, i);
  210. if (i != 3)
  211. {
  212. if (windSL.containsKey(windturbineid))
  213. {
  214. if (slvalue.containsKey(windturbineid))
  215. {
  216. if (slvalue.get(windturbineid) != i)
  217. {
  218. RealTimeParameterVo rt = new RealTimeParameterVo();
  219. rt.setPoint(windSL.get(windturbineid).getNemCode());
  220. rt.setTime(dt);
  221. rt.setInsertValue(i);
  222. if (!rList.containsKey(windturbineid))
  223. {
  224. slvalue.put(windturbineid,i);
  225. rList.put(windturbineid, rt);
  226. }
  227. }
  228. }
  229. }
  230. }
  231. }
  232. else
  233. {
  234. if (slv.get(windturbineid) == 3)
  235. {
  236. i = 3;
  237. }
  238. if (windSL.containsKey(windturbineid))
  239. {
  240. if (slvalue.containsKey(windturbineid))
  241. {
  242. if (slvalue.get(windturbineid) != i)
  243. {
  244. RealTimeParameterVo rt = new RealTimeParameterVo();
  245. rt.setPoint(windSL.get(windturbineid).getNemCode());
  246. rt.setTime(dt);
  247. rt.setInsertValue(i);
  248. if (!rList.containsKey(windturbineid))
  249. {
  250. slvalue.put(windturbineid,i);
  251. rList.put(windturbineid, rt);
  252. }
  253. }
  254. }
  255. }
  256. }
  257. }
  258. private void initsl()
  259. {
  260. sl = new HashMap<String, SLWindpowerVo>();
  261. slvalue = new HashMap<String, Integer>();
  262. //var electrical = entity.ProEconLineElectrical.ToList();
  263. List<ProBasicEquipment> wtls= CacheContext.wtls;
  264. Map<String, Map<String, ProBasicEquipmentPoint>> wtpAimap=CacheContext.wtpAimap;
  265. Map<String, ProEconLineElectrical> electrical = proEconLineElectricalService.list().stream().collect(Collectors.toMap(ProEconLineElectrical::getLineId, Function.identity()));
  266. wtls.stream().forEach(wt->{
  267. if(wt.getWindpowerstationId().contains("FDC"))
  268. {
  269. Map<String, ProBasicEquipmentPoint> windturbinetestingpointnewMap = wtpAimap.get(wt.getId());
  270. if(windturbinetestingpointnewMap.containsKey(ContantXk.GPZT))
  271. {
  272. ProBasicEquipmentPoint xdslPoint = windturbinetestingpointnewMap.get(ContantXk.GPZT);
  273. windSL.put(wt.getId(),xdslPoint);
  274. }
  275. }
  276. });
  277. for (String key : windSL.keySet())
  278. {
  279. if (!CacheContext.wtmap.containsKey(key))
  280. {
  281. continue;
  282. }
  283. ProBasicEquipment item = CacheContext.wtmap.get(key);
  284. slvalue.put(item.getId(), 0);
  285. if (!electrical.containsKey(item.getLineId()))
  286. {
  287. continue;
  288. }
  289. ProEconLineElectrical line = electrical.get(item.getLineId());
  290. if (sl.containsKey(item.getWindpowerstationId()))
  291. {
  292. SLWindpowerVo s = sl.get(item.getWindpowerstationId());
  293. initialsl(item, line, s);
  294. }
  295. else
  296. {
  297. sl.put(item.getWindpowerstationId(), new SLWindpowerVo());
  298. SLWindpowerVo s = sl.get(item.getWindpowerstationId());
  299. s.setLINECODE(new HashMap<String, List<String>>());
  300. s.setNETLOWCODE(new HashMap<String, List<String>>());
  301. s.setNETHIGHCODE(new HashMap<String, List<String>>());
  302. s.setNETOUTCODE(new HashMap<String, List<String>>());
  303. s.setPTVOLTAGEHIGH(new HashMap<String, Double>());
  304. s.setPTVOLTAGELOW(new HashMap<String, Double>());
  305. s.setPTCURRENT(new HashMap<String, Double>());
  306. s.setPTCURRENTCODE(new HashMap<String, String>());
  307. s.setPTVOLTAGECODE(new HashMap<String, String>());
  308. s.setACCIDENTSIGNAL(new HashMap<String, List<String>>());
  309. initialsl(item, line, s);
  310. }
  311. }
  312. }
  313. private static void initialsl(ProBasicEquipment windturbine, ProEconLineElectrical item, SLWindpowerVo s)
  314. {
  315. //进线断路器
  316. if (s.getLINECODE().containsKey(item.getLineCode()))
  317. {
  318. List<String> t = s.getLINECODE().get(item.getLineCode());
  319. t.add(windturbine.getId());
  320. }
  321. else
  322. {
  323. List<String> t = new ArrayList<String>();
  324. t.add(windturbine.getId());
  325. s.getLINECODE().put(item.getLineCode(), t);
  326. }
  327. //主变低压测
  328. if (s.getNETLOWCODE().containsKey(item.getNetLowCode()))
  329. {
  330. List<String> t = s.getNETLOWCODE().get(item.getNetLowCode());
  331. t.add(windturbine.getId());
  332. }
  333. else
  334. {
  335. List<String> t = new ArrayList<String>();
  336. t.add(windturbine.getId());
  337. s.getNETLOWCODE().put(item.getNetLowCode(), t);
  338. }
  339. //主变高压侧
  340. if (s.getNETHIGHCODE().containsKey(item.getNetHighCode()))
  341. {
  342. List<String> t = s.getNETHIGHCODE().get(item.getNetHighCode());
  343. t.add(windturbine.getId());
  344. }
  345. else
  346. {
  347. List<String> t = new ArrayList<String>();
  348. t.add(windturbine.getId());
  349. s.getNETHIGHCODE().put(item.getNetHighCode(), t);
  350. if (!s.getPTCURRENTCODE().containsKey(item.getNetHighCode()))
  351. {
  352. if (item.getPtcurrentCode() != null)
  353. {
  354. s.getPTCURRENTCODE().put(item.getNetHighCode(), item.getPtcurrentCode());
  355. }
  356. }
  357. if (!s.getPTVOLTAGECODE().containsKey(item.getNetHighCode()))
  358. {
  359. if (item.getPtvoltageCode() != null)
  360. {
  361. s.getPTVOLTAGECODE().put(item.getNetHighCode(), item.getPtvoltageCode());
  362. }
  363. }
  364. if (!s.getPTVOLTAGEHIGH().containsKey(item.getNetHighCode()))
  365. {
  366. if (item.getPtvoltageHigh() != null)
  367. {
  368. s.getPTVOLTAGEHIGH().put(item.getNetHighCode(), item.getPtvoltageHigh().doubleValue());
  369. }
  370. }
  371. if (!s.getPTVOLTAGELOW().containsKey(item.getNetHighCode()))
  372. {
  373. if (item.getPtvoltageLow() != null)
  374. {
  375. s.getPTVOLTAGELOW().put(item.getNetHighCode(), item.getPtvoltageLow().doubleValue());
  376. }
  377. }
  378. if (!s.getPTCURRENTCODE().containsKey(item.getNetHighCode()))
  379. {
  380. if (item.getPtcurrent() != null)
  381. {
  382. s.getPTCURRENT().put(item.getNetHighCode(), item.getPtcurrent().doubleValue());
  383. }
  384. }
  385. }
  386. //出线
  387. if (s.getNETOUTCODE().containsKey(item.getNetOutCode()))
  388. {
  389. List<String> t = s.getNETOUTCODE().get(item.getNetOutCode());
  390. t.add(windturbine.getId());
  391. }
  392. else
  393. {
  394. List<String> t = new ArrayList<String>();
  395. t.add(windturbine.getId());
  396. s.getNETOUTCODE().put(item.getNetOutCode(), t);
  397. }
  398. //事故总
  399. if (s.getACCIDENTSIGNAL().containsKey(item.getAccidentSignal()))
  400. {
  401. List<String> t = s.getACCIDENTSIGNAL().get(item.getAccidentSignal());
  402. t.add(windturbine.getId());
  403. }
  404. else
  405. {
  406. List<String> t = new ArrayList<String>();
  407. t.add(windturbine.getId());
  408. s.getACCIDENTSIGNAL().put(item.getAccidentSignal(), t);
  409. }
  410. }
  411. //region AGC监视限电
  412. //限电
  413. static Map<String, ProBasicEquipmentPoint> WindTurbineE;
  414. //shishi
  415. static Map<String, ProBasicEquipmentPoint> WindturbineQXDic4;
  416. //限电状态
  417. static Map<String, Map<String, ProBasicEquipmentPoint>> WindTurbineD;
  418. //限电受累
  419. static Map<String, Map<String, ProBasicEquipmentPoint>> WindTurbineXDSL;
  420. //AGC限电指令
  421. static Map<String, ProBasicPowerstationPoint> WindPowerAGC;
  422. static Map<String, ProBasicPowerstationPoint> WindPowerCXYG;
  423. static Map<String, ProBasicPowerstationPoint> WindPowerZSGL;
  424. static Map<String, ProBasicPowerstationPoint> WindPowerXDZT;
  425. static Map<String, Double> powerCache = new HashMap<String, Double>();
  426. static Map<String, Date> timeCache = new HashMap<String, Date>();
  427. public void execStatusAGCxd() throws Exception {
  428. if (WindTurbineE == null || WindTurbineD == null || WindPowerAGC == null)
  429. {
  430. WindTurbineD = new HashMap<String, Map<String, ProBasicEquipmentPoint>>();
  431. List<ProBasicEquipment> wtls= CacheContext.wtls;
  432. Map<String, Map<String, ProBasicEquipmentPoint>> wtpAimap=CacheContext.wtpAimap;
  433. wtls.stream().forEach(wt->{
  434. Map<String, ProBasicEquipmentPoint> windturbinetestingpointnewMap = wtpAimap.get(wt.getId());
  435. if(windturbinetestingpointnewMap.containsKey(ContantXk.GPZT))
  436. {
  437. ProBasicEquipmentPoint xdslPoint = windturbinetestingpointnewMap.get(ContantXk.GPZT);
  438. WindturbineXDSL.put(wt.getId(),xdslPoint);
  439. }
  440. });
  441. Map<String,Map<String, ProBasicPowerstationPoint>> wppointmap =CacheContext.wppointmap;
  442. CacheContext.wpls.forEach(wp->{
  443. Map<String, ProBasicPowerstationPoint> wppMap = wppointmap.get(wp.getId());
  444. if(wp.getId().contains("FDC"))
  445. {
  446. if(wppMap.containsKey(ContantXk.TPOINT_WP_AGC))
  447. {
  448. ProBasicPowerstationPoint agcPoint = wppMap.get(ContantXk.TPOINT_WP_AGC);
  449. WindPowerAGC.put(wp.getId(),agcPoint);
  450. }
  451. if(wppMap.containsKey(ContantXk.TPOINT_WP_CXGL))
  452. {
  453. ProBasicPowerstationPoint cxglPoint = wppMap.get(ContantXk.TPOINT_WP_CXGL);
  454. WindPowerCXYG.put(wp.getId(),cxglPoint);
  455. }
  456. if(wppMap.containsKey(ContantXk.SSZNHGLZS))
  457. {
  458. ProBasicPowerstationPoint zsglPoint = wppMap.get(ContantXk.SSZNHGLZS);
  459. WindPowerZSGL.put(wp.getId(),zsglPoint);
  460. }
  461. if(wppMap.containsKey(ContantXk.XDZT))
  462. {
  463. ProBasicPowerstationPoint xdztPoint = wppMap.get(ContantXk.XDZT);
  464. WindPowerXDZT.put(wp.getId(),xdztPoint);
  465. }
  466. }
  467. });
  468. for (String key : WindPowerAGC.keySet())
  469. {
  470. Map<String, ProBasicEquipmentPoint> windD=new HashMap<>();
  471. Map<String, ProBasicEquipmentPoint> windturbinetestingpointnewMap = wtpAimap.get(key);
  472. if(windturbinetestingpointnewMap.containsKey(ContantXk.XDZT))
  473. {
  474. ProBasicEquipmentPoint xdztPoint = windturbinetestingpointnewMap.get(ContantXk.XDZT);
  475. windD.put(key,xdztPoint);
  476. }
  477. if (windD != null)
  478. {
  479. WindTurbineD.put(key, windD);
  480. }
  481. powerCache.put(key, -1.0);
  482. }
  483. //风机转速限值1.5MV && 有功控制给定值2MV
  484. wtls.stream().forEach(wt->{
  485. if(wt.getWindpowerstationId().contains("FDC"))
  486. {
  487. Map<String, ProBasicEquipmentPoint> windturbinetestingpointnewMap = wtpAimap.get(wt.getId());
  488. if(windturbinetestingpointnewMap.containsKey(ContantXk.XDZT))
  489. {
  490. ProBasicEquipmentPoint xdclztPoint = windturbinetestingpointnewMap.get(ContantXk.XDZT);
  491. WindTurbineE.put(wt.getId(),xdclztPoint);
  492. }
  493. if(windturbinetestingpointnewMap.containsKey(ContantXk.SSQFZT))
  494. {
  495. ProBasicEquipmentPoint rqfztPoint = windturbinetestingpointnewMap.get(ContantXk.SSQFZT);
  496. WindturbineQXDic4.put(wt.getId(),rqfztPoint);
  497. }
  498. }
  499. });
  500. }
  501. else
  502. {
  503. Date time = new Date();
  504. Date begin = DateUtils.addMinutes(time,-8);
  505. List<RealTimeParameterVo> projectRT = new ArrayList<RealTimeParameterVo>();
  506. for (String item : WindPowerAGC.keySet())
  507. {
  508. Double capacity = CacheContext.wpmap.get(item).getCapacity();
  509. //读取AGC实时数据
  510. Double windpoweragc = 0.0;
  511. if (WindPowerAGC.containsKey(item))
  512. {
  513. windpoweragc =edosUtil.getRealData(WindPowerAGC.get(item).getNemCode()).getPointValueInDouble(); ;
  514. }
  515. //读取出线有功实时数据
  516. Double windpowercxyg = 0.0;
  517. if (WindPowerCXYG.containsKey(item))
  518. {
  519. windpowercxyg = edosUtil.getRealData(WindPowerCXYG.get(item).getNemCode()).getPointValueInDouble();
  520. }
  521. // #region 读取历史数据
  522. Double windpoweragcHis = 0.0;
  523. if (WindPowerAGC.containsKey(item))
  524. {
  525. long pried= DateUtils.secondsDiff(begin,time);
  526. List<PointData> hsls= edosUtil.getHistStat(WindPowerAGC.get(item).getNemCode(), begin.getTime()/1000, time.getTime()/1000, 1l,pried, StatData.AVG.getValue());
  527. if(StringUtils.notEmp(hsls) && hsls.size()>0)
  528. {
  529. windpoweragcHis =hsls.get(0).getPointValueInDouble();
  530. }
  531. }
  532. //读取出线有功历史数据
  533. Double windpowercxygHis = 0.0;
  534. if (WindPowerCXYG.containsKey(item))
  535. {
  536. long pried= DateUtils.secondsDiff(begin,time);
  537. List<PointData> hsls= edosUtil.getHistStat(WindPowerCXYG.get(item).getNemCode(), begin.getTime()/1000, time.getTime()/1000, 1l,pried, StatData.AVG.getValue());
  538. if(StringUtils.notEmp(hsls) && hsls.size()>0)
  539. {
  540. windpowercxygHis =hsls.get(0).getPointValueInDouble();
  541. }
  542. }
  543. Double windpowerzsglHis = 0.0;
  544. if (WindPowerZSGL.containsKey(item))
  545. {
  546. long pried= DateUtils.secondsDiff(begin,time);
  547. List<PointData> hsls= edosUtil.getHistStat(WindPowerZSGL.get(item).getNemCode(), begin.getTime()/1000, time.getTime()/1000, 1l,pried, StatData.AVG.getValue());
  548. if(StringUtils.notEmp(hsls) && hsls.size()>0)
  549. {
  550. windpowerzsglHis =hsls.get(0).getPointValueInDouble();
  551. }
  552. }
  553. boolean k = false; //agc 硬限电
  554. // 判断缓存有没有这个ID点
  555. if (!powerCache.containsKey(item))
  556. {
  557. continue;
  558. }
  559. //第一次初始化复制实时数据到缓存
  560. if (powerCache.get(item) == -1)
  561. {
  562. powerCache.put(item,windpoweragc);
  563. }
  564. else if (powerCache.get(item) == windpoweragc)
  565. {
  566. //continue;
  567. k = true;
  568. }
  569. else
  570. {
  571. powerCache.put(item,windpoweragc);
  572. }
  573. //查看风场缓存中是否存在AGC信息
  574. if (!CacheContext.wpmap.containsKey(item))
  575. {
  576. continue;
  577. }
  578. if (!WindTurbineD.containsKey(item))
  579. {
  580. continue;
  581. }
  582. windpoweragc = StringUtils.round(windpoweragc, 1);
  583. windpowercxyg = StringUtils.round(windpowercxyg, 1);
  584. capacity = StringUtils.round(capacity, 1);
  585. if (windpoweragc >= capacity)
  586. {
  587. for (String key : WindTurbineD.get(item).keySet())
  588. {
  589. //String id = WindTurbineD[item][key].ID;
  590. //Double d = edosUtil.getRealData(id);
  591. //if (d == 1d)
  592. //{
  593. //限电受累
  594. String id2 = WindturbineXDSL.get(key).getNemCode();
  595. Double xdsl = edosUtil.getRealData(id2).getPointValueInDouble();
  596. Double val = 0.0;
  597. if (xdsl == 1)
  598. {
  599. val = 1.0;
  600. }
  601. RealTimeParameterVo rt = new RealTimeParameterVo();
  602. rt.setPoint(WindTurbineD.get(item).get(key).getNemCode());
  603. rt.setTime(time);
  604. rt.setInsertValue(val);
  605. projectRT.add(rt);
  606. //}
  607. }
  608. RealTimeParameterVo fcrt = new RealTimeParameterVo();
  609. fcrt.setPoint(WindPowerXDZT.get(item).getNemCode());
  610. fcrt.setTime(time);
  611. fcrt.setInsertValue(0.0);
  612. projectRT.add(fcrt);
  613. }
  614. else
  615. {
  616. boolean b = false;
  617. if (windpowerzsglHis > capacity * 0.4)
  618. {
  619. if (windpowerzsglHis / windpoweragc > 1.5)
  620. {
  621. b = true;
  622. }
  623. if (windpoweragcHis <= windpowercxygHis)
  624. {
  625. b = true;
  626. }
  627. if (windpoweragcHis <= windpowerzsglHis * 0.75 && windpowercxygHis >= windpoweragcHis * 0.85)
  628. {
  629. b = true;
  630. }
  631. if (windpoweragcHis <= windpowerzsglHis * 0.85 && windpowercxygHis >= windpoweragcHis * 0.94)
  632. {
  633. b = true;
  634. }
  635. if (windpoweragcHis <= windpowerzsglHis && windpowercxygHis >= windpoweragcHis * 0.95)
  636. {
  637. b = true;
  638. }
  639. }
  640. else
  641. {
  642. if (k)
  643. {
  644. if (windpoweragcHis <= windpowercxygHis)
  645. {
  646. b = true;
  647. }
  648. if (windpoweragcHis <= windpowerzsglHis * 0.75 && windpowercxygHis >= windpoweragcHis * 0.94)
  649. {
  650. b = true;
  651. }
  652. }
  653. }
  654. // #region 新增短时间来回变化状态
  655. if (b)
  656. {
  657. if (timeCache.containsKey(item))
  658. {
  659. timeCache.put(item,time);
  660. }
  661. else
  662. {
  663. timeCache.put(item, time);
  664. }
  665. }
  666. else
  667. {
  668. if (timeCache.containsKey(item))
  669. {
  670. Double minutes=DateUtils.minutesDiff2(time,timeCache.get(item));
  671. if (minutes < 3)
  672. {
  673. if (windpoweragc - windpowercxyg<1.5)
  674. {
  675. b = true;
  676. }
  677. }
  678. }
  679. }
  680. // #endregion
  681. if (!b)
  682. {
  683. for (String key : WindTurbineD.get(item).keySet())
  684. {
  685. //String id = WindTurbineD[item][key].ID;
  686. //Double d = edosUtil.getRealData(id);
  687. //if (d == 1d)
  688. //{
  689. //限电受累
  690. String id2 = WindturbineXDSL.get(key).getNemCode();
  691. Double xdsl = edosUtil.getRealData(id2).getPointValueInDouble();
  692. Double val = 0.0;
  693. if (xdsl == 1)
  694. {
  695. val = 1.0;
  696. }
  697. RealTimeParameterVo rt = new RealTimeParameterVo();
  698. rt.setPoint(WindTurbineD.get(item).get(key).getNemCode());
  699. rt.setTime(time);
  700. rt.setInsertValue(val);
  701. projectRT.add(rt);
  702. //}
  703. }
  704. RealTimeParameterVo fcrt = new RealTimeParameterVo();
  705. fcrt.setPoint(WindPowerXDZT.get(item).getNemCode());
  706. fcrt.setTime(time);
  707. fcrt.setInsertValue(0.0);
  708. projectRT.add(fcrt);
  709. }
  710. else
  711. {
  712. RealTimeParameterVo fcrt = new RealTimeParameterVo();
  713. fcrt.setPoint(WindPowerXDZT.get(item).getNemCode());
  714. fcrt.setTime(time);
  715. fcrt.setInsertValue(1.0);
  716. projectRT.add(fcrt);
  717. for (String key : WindTurbineD.get(item).keySet())
  718. {
  719. //限电状态
  720. //String id = WindTurbineD[item][key].ID;
  721. //Double xd = edosUtil.getRealData(id);
  722. boolean tempb = false;
  723. if (CacheContext.wtmap.containsKey(key) && WindturbineQXDic4.containsKey(key))
  724. {
  725. String modelid =CacheContext.wtmap.get(key).getModelId();
  726. Double xz = 0.0;
  727. Double xz2 = 0.0;
  728. if (modelid.contains("UP77-1500") || modelid.contains("UP82-1500"))
  729. {
  730. xz = 17.3;
  731. xz2 = 1500.0;
  732. }
  733. else if (modelid.contains("UP100-3000"))
  734. {
  735. xz = 3000.0;
  736. xz2 = 3000.0;
  737. }
  738. else
  739. {
  740. xz = 2000.0;
  741. xz2 = 2000.0;
  742. }
  743. if (WindturbineQXDic4.containsKey(key))
  744. {
  745. Double tempk = edosUtil.getRealData(WindturbineQXDic4.get(key).getNemCode()).getPointValueInDouble();
  746. if (tempk >= 3)
  747. {
  748. tempb = true;
  749. }
  750. else
  751. {
  752. tempb = false;
  753. }
  754. }
  755. // #region 新增加
  756. Map<String,Map<String, ProBasicEquipmentPoint>> wtpAimap =CacheContext.wtpAimap;
  757. Map<String, ProBasicEquipmentPoint> windturbinetestingpointnewMap = wtpAimap.get(key);
  758. if(windturbinetestingpointnewMap.containsKey(ContantXk.CJ_SSFS))
  759. {
  760. ProBasicEquipmentPoint xdztPoint = windturbinetestingpointnewMap.get(ContantXk.CJ_SSFS);
  761. Double rtbbb = edosUtil.getRealData(xdztPoint.getNemCode()).getPointValueInDouble();
  762. if (rtbbb >= xz2 * 0.9)
  763. {
  764. tempb = false;
  765. }
  766. }
  767. }
  768. //限出力状态
  769. String id1 = WindTurbineE.get(key).getNemCode();
  770. Double xcl = edosUtil.getRealData(id1).getPointValueInDouble();
  771. //限电受累
  772. String id2 = WindturbineXDSL.get(key).getNemCode();
  773. Double xdsl = edosUtil.getRealData(id2).getPointValueInDouble();
  774. Double val = 0.0;
  775. if (xdsl == 1 || xcl == 1 || tempb)
  776. {
  777. val = 1.0;
  778. }
  779. RealTimeParameterVo rt = new RealTimeParameterVo();
  780. rt.setPoint(WindTurbineD.get(item).get(key).getNemCode());
  781. rt.setTime(time);
  782. rt.setInsertValue(val);
  783. projectRT.add(rt);
  784. //if (d == 0d)
  785. //{
  786. // boolean t = false;
  787. // if (statuspointDictionary.containsKey(key))
  788. // {
  789. // Double start = edosUtil.getRealData(statuspointDictionary[key].ID);
  790. // if (start != 1)
  791. // {
  792. // t = true;
  793. // }
  794. // else
  795. // {
  796. // if (WindTurbineE.containsKey(key))
  797. // {
  798. // String ids = WindTurbineE[key].ID;
  799. // if (ids != null && ids.Length > 0)
  800. // t = BuildRetValue(new String[] { ids });
  801. // }
  802. // }
  803. // }
  804. // if (t)
  805. // {
  806. // var val = edosUtil.getRealData(WindTurbineD[item][key].ID);
  807. // if (val != 2 && val != 3 && val != 4 && val != 5)
  808. // {
  809. // RealTimeParameterVo rt = new RealTimeParameterVo();
  810. // rt.point = WindTurbineD[item][key].ID; ;
  811. // rt.time = time;
  812. // rt.InsertValue = 1.0;
  813. // projectRT.Add(rt);
  814. // }
  815. // }
  816. //}
  817. }
  818. }
  819. }
  820. }
  821. if (projectRT.size() > 0)
  822. {
  823. edosUtil.sendMultiRealTimeParamete(projectRT);
  824. }
  825. }
  826. }
  827. private boolean BuildRetValue(String[] Ids) throws Exception {
  828. boolean b = false;
  829. // Double[] values = new Double[Ids.length];
  830. List<PointData> values=edosUtil.getRealData(Ids);
  831. // ednaHelper.GetRtValueList(Ids.Length, Ids, values);
  832. for (PointData item : values)
  833. {
  834. if (item.getPointValueInDouble() != 0)
  835. {
  836. b = true;
  837. break;
  838. }
  839. }
  840. return b;
  841. }
  842. List<ProBasicEquipmentPoint> WindTurbineXD;
  843. Map<String, ProBasicEquipmentPoint> WindturbineXDSL;
  844. public void execStatus2() throws Exception {
  845. if (WindTurbineXD == null || WindturbineXDSL == null)
  846. {
  847. List<ProBasicEquipment> wtls= CacheContext.wtls;
  848. Map<String, Map<String, ProBasicEquipmentPoint>> wtpAimap=CacheContext.wtpAimap;
  849. wtls.stream().forEach(wt->{
  850. Map<String, ProBasicEquipmentPoint> windturbinetestingpointnewMap = wtpAimap.get(wt.getId());
  851. if(windturbinetestingpointnewMap.containsKey(ContantXk.GPZT))
  852. {
  853. ProBasicEquipmentPoint xdslPoint = windturbinetestingpointnewMap.get(ContantXk.GPZT);
  854. WindturbineXDSL.put(wt.getId(),xdslPoint);
  855. }
  856. if(windturbinetestingpointnewMap.containsKey(ContantXk.XDZT))
  857. {
  858. ProBasicEquipmentPoint xdztPoint = windturbinetestingpointnewMap.get(ContantXk.XDZT);
  859. WindTurbineXD.add(xdztPoint);
  860. }
  861. });
  862. }
  863. else
  864. {
  865. Date dt = new Date();
  866. List<RealTimeParameterVo> insertRt = new ArrayList<RealTimeParameterVo>();
  867. for (ProBasicEquipmentPoint xd : WindTurbineXD)
  868. {
  869. String key = xd.getWindturbineId();
  870. // if (key == "KB01_010")
  871. // {
  872. // Console.WriteLine("1");
  873. // }
  874. String point = xd.getNemCode();//重点注意!!!!
  875. Double val = 0.0;
  876. if (WindturbineXDSL.containsKey(key))
  877. {
  878. Double ret = edosUtil.getRealData(WindturbineXDSL.get(key).getNemCode()).getPointValueInDouble();
  879. if (ret == 1)
  880. {
  881. val = 1.0;
  882. }
  883. //else
  884. //{
  885. // val = 0.0;
  886. //}
  887. }
  888. RealTimeParameterVo rt = new RealTimeParameterVo();
  889. rt.setPoint(point);
  890. rt.setTime(dt);
  891. rt.setInsertValue(val);
  892. insertRt.add(rt);
  893. }
  894. edosUtil.sendMultiRealTimeParamete(insertRt);
  895. }
  896. }
  897. Map<String, List<String>> WindturbineQXDic;
  898. List<ProBasicEquipmentPoint> WindTurbineQX;
  899. Map<String, ProBasicEquipmentPoint> WindturbineQXDic2;
  900. Map<String, ProBasicEquipmentPoint> WindturbineQXDic3;
  901. //Map<String, ProBasicEquipmentPoint> WindturbineQXDic4;
  902. public void execStatus() throws Exception {
  903. if (WindTurbineQX == null || WindturbineQXDic == null)
  904. {
  905. WindturbineQXDic = new HashMap<String, List<String>>();
  906. //var disArr = entity.ProBasicEquipmentPoint.Where(it => it.UNIFORMCODE == "AI178" || it.UNIFORMCODE == "CJ_SCADA_YGSD").ToList();
  907. //叶轮转速给定 AI134 限值17.4
  908. //转矩给定 CJ_ZSGD 限值 95 (2MW 叫 变频器转矩给定 无用)
  909. //发电状态下的转速给定 AI178 限值17.4
  910. //scada有功设定值 CJ_SCADA_YGSD 2MW 限值2000 3MW 限值3000
  911. //实时欠发状态 SSQFZT
  912. List<ProBasicEquipmentPoint> wtpointls=new ArrayList<>();
  913. List<ProBasicEquipment> wtls= CacheContext.wtls;
  914. Map<String, Map<String, ProBasicEquipmentPoint>> wtpAimap=CacheContext.wtpAimap;
  915. wtls.stream().forEach(wt->{
  916. Map<String, ProBasicEquipmentPoint> windturbinetestingpointnewMap = wtpAimap.get(wt.getId());
  917. if(windturbinetestingpointnewMap.containsKey(ContantXk.CJ_YLZSGD))
  918. {
  919. ProBasicEquipmentPoint point = windturbinetestingpointnewMap.get(ContantXk.CJ_YLZSGD);
  920. wtpointls.add(point);
  921. }
  922. if(windturbinetestingpointnewMap.containsKey(ContantXk.CJ_FDZTXZSGD))
  923. {
  924. ProBasicEquipmentPoint point = windturbinetestingpointnewMap.get(ContantXk.CJ_FDZTXZSGD);
  925. wtpointls.add(point);
  926. }
  927. if(windturbinetestingpointnewMap.containsKey(ContantXk.CJ_SCADA_YGSD))
  928. {
  929. ProBasicEquipmentPoint point = windturbinetestingpointnewMap.get(ContantXk.CJ_SCADA_YGSD);
  930. wtpointls.add(point);
  931. }
  932. // if(windturbinetestingpointnewMap.containsKey(ContantXk.CJ_ZSGD))
  933. // {
  934. // ProBasicEquipmentPoint point = windturbinetestingpointnewMap.get(ContantXk.CJ_ZSGD);
  935. // WindturbineQXDic3.put(wt.getId(),point);
  936. // }
  937. //
  938. // if(windturbinetestingpointnewMap.containsKey(ContantXk.DI11139))
  939. // {
  940. // ProBasicEquipmentPoint point = windturbinetestingpointnewMap.get(ContantXk.DI11139);
  941. // WindturbineQXDic2.put(wt.getNemCode(),point);
  942. // }
  943. // if(windturbinetestingpointnewMap.containsKey(ContantXk.DI10923))
  944. // {
  945. // ProBasicEquipmentPoint point = windturbinetestingpointnewMap.get(ContantXk.DI10923);
  946. // WindturbineQXDic2.put(wt.getNemCode(),point);
  947. // }
  948. if(windturbinetestingpointnewMap.containsKey(ContantXk.XDZT))
  949. {
  950. ProBasicEquipmentPoint point = windturbinetestingpointnewMap.get(ContantXk.XDZT);
  951. WindTurbineQX.add(point);
  952. }
  953. });
  954. for (ProBasicEquipmentPoint dis : wtpointls)
  955. {
  956. if (!WindturbineQXDic.containsKey(dis.getWindturbineId()))
  957. {
  958. WindturbineQXDic.put(dis.getWindturbineId(), new ArrayList<String>());
  959. }
  960. WindturbineQXDic.get(dis.getWindturbineId()).add(dis.getNemCode());
  961. }
  962. }
  963. else
  964. {
  965. Date dt =new Date();
  966. List<RealTimeParameterVo> insertRt = new ArrayList<RealTimeParameterVo>();
  967. for (ProBasicEquipmentPoint item : WindTurbineQX)
  968. {
  969. String key = item.getWindturbineId();
  970. String windows = item.getWindpowerstationId();
  971. //if (windows == "KB_FDC" || windows == "CL_FDC")
  972. //{
  973. // Console.WriteLine(key);
  974. // continue;
  975. //}
  976. // if (key == "CL01_001" )
  977. // {
  978. // Console.WriteLine(key);
  979. //
  980. // }
  981. String point = item.getNemCode();//重点注意!!!!
  982. Double val = 0.0;
  983. if (CacheContext.wtmap.containsKey(key) && WindturbineQXDic.containsKey(key))
  984. {
  985. String modelid =CacheContext.wtmap.get(key).getModelId();
  986. Double xz = 0.0;
  987. Double xz2 = 0.0;
  988. if (modelid.contains("UP77-1500") || modelid.contains("UP82-1500"))
  989. {
  990. xz = 17.3;
  991. xz2 = 1500.0;
  992. }
  993. else if (modelid.contains("UP100-3000"))
  994. {
  995. xz = 3000.0;
  996. xz2 = 3000.0;
  997. }
  998. else
  999. {
  1000. xz = 2000.0;
  1001. xz2 = 2000.0;
  1002. }
  1003. List<String> lxIds = WindturbineQXDic.get(key);
  1004. List<Date> dts=new ArrayList<>();
  1005. List<PointData> vals1=edosUtil.getRealData(lxIds);
  1006. boolean b = true;
  1007. for (PointData va : vals1)
  1008. {
  1009. b = b && (va.getPointValueInDouble() >= xz);
  1010. }
  1011. if (WindturbineQXDic2.containsKey(key))
  1012. {
  1013. PointData k = edosUtil.getRealData(WindturbineQXDic2.get(key).getNemCode());
  1014. b = b && (k.getPointValueInDouble() == 0);
  1015. }
  1016. //if (WindturbineQXDic3.containsKey(key))
  1017. //{
  1018. // var k = edosUtil.getRealData(WindturbineQXDic3[key].ID);
  1019. // if (modelid.contains("UP77-1500") || modelid.contains("UP82-1500"))
  1020. // {
  1021. // if (k >= 90)
  1022. // {
  1023. // b = true;
  1024. // }
  1025. // else
  1026. // {
  1027. // b = false;
  1028. // }
  1029. // }
  1030. //}
  1031. val = b ? 0.0 : 1.0;
  1032. RealTimeParameterVo rt = new RealTimeParameterVo();
  1033. rt.setPoint(point);
  1034. rt.setTime(dt);
  1035. rt.setInsertValue(val);
  1036. insertRt.add(rt);
  1037. }
  1038. }
  1039. edosUtil.sendMultiRealTimeParamete(insertRt);
  1040. this.execStatusAGCxd();
  1041. //this.execStatuSL();
  1042. System.out.println(DateUtils.getFormat1().format(new Date()));
  1043. Thread.sleep(1000);
  1044. }
  1045. }
  1046. }