LimitEventService.java 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182
  1. package com.gyee.generation.service;
  2. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  3. import com.gyee.common.contant.Contant;
  4. import com.gyee.common.contant.ContantXk;
  5. import com.gyee.common.model.DNAStatVal;
  6. import com.gyee.common.model.DNAVal;
  7. import com.gyee.common.model.PointData;
  8. import com.gyee.generation.init.CacheContext;
  9. import com.gyee.generation.model.auto.*;
  10. import com.gyee.generation.service.auto.IProEconBrownoutsEvent2Service;
  11. import com.gyee.generation.service.auto.IProEconBrownoutsEventService;
  12. import com.gyee.generation.service.auto.IProEconMainBrownouts2Service;
  13. import com.gyee.generation.service.auto.IProEconMainBrownoutsService;
  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.stream.Collectors;
  21. @Service
  22. public class LimitEventService {
  23. @Resource
  24. private IProEconBrownoutsEventService proEconBrownoutsEventService;
  25. @Resource
  26. private IProEconMainBrownoutsService proEconMainBrownoutsService;
  27. @Resource
  28. private IProEconBrownoutsEvent2Service proEconBrownoutsEvent2Service;
  29. @Resource
  30. private IProEconMainBrownouts2Service proEconMainBrownouts2Service;
  31. @Resource
  32. private IEdosUtil edosUtil;
  33. //风机保证功率
  34. private Map<String, String> bzglDictionary;
  35. //<风场编号,风场状态点编号>
  36. public Map<String, String> windPowerDictionary;
  37. //<风场编号,<风机编号,风机状态点编号>>
  38. public Map<String, Map<String, String>> windTurbineDictionary;
  39. //<风场编号/工程编号/线路编号,List<风机编号>>
  40. public Map<String, List<String>> wplDictionary;
  41. //风场限电事件
  42. public Map<String, ProEconMainBrownouts> windpowerEvent;
  43. //风机限电事件
  44. public Map<String, ProEconBrownoutsEvent> windturbineEvent;
  45. //风场限电事件 当日
  46. public Map<String, ProEconMainBrownouts2> windpowerEvent2;
  47. //风机限电事件 当日
  48. public Map<String, ProEconBrownoutsEvent2> windturbineEvent2;
  49. //风机列表
  50. public Map<String, ProBasicWindturbine> windturbines;
  51. //风机对应额定功率
  52. public Map<String, Double> windturbinePowerProduction;
  53. //风机风速
  54. public Map<String, String> speedDictionary;
  55. //风机功率
  56. public Map<String, String> powerDictionary;
  57. //风场风速
  58. public Map<String, String> wSpeedDictionary;
  59. //风场功率
  60. public Map<String, String> wPowerDictionary;
  61. //风机拟合限电损失
  62. public Map<String, String> nhxdDictionary;
  63. //风机拟合功率
  64. public Map<String, String> nhDictionary;
  65. public void Init() {
  66. windPowerDictionary = new HashMap<String, String>();
  67. windTurbineDictionary = new HashMap<String, Map<String, String>>();
  68. wplDictionary = new HashMap<String, List<String>>();
  69. windpowerEvent = new HashMap<String, ProEconMainBrownouts>();
  70. windturbineEvent = new HashMap<String, ProEconBrownoutsEvent>();
  71. windpowerEvent2 = new HashMap<String, ProEconMainBrownouts2>();
  72. windturbineEvent2 = new HashMap<String, ProEconBrownoutsEvent2>();
  73. speedDictionary = new HashMap<String, String>();
  74. powerDictionary = new HashMap<String, String>();
  75. wSpeedDictionary = new HashMap<String, String>();
  76. wPowerDictionary = new HashMap<String, String>();
  77. bzglDictionary = new HashMap<String, String>();
  78. windturbinePowerProduction = new HashMap<String, Double>();
  79. nhDictionary = new HashMap<String, String>();
  80. nhxdDictionary = new HashMap<String, String>();
  81. Map<String, ProBasicWppoint> tempWindPower = new HashMap<>();
  82. Map<String, ProBasicWppoint> tempWindPowerSpeed = new HashMap<>();
  83. Map<String, ProBasicWppoint> tempWindPowerPower = new HashMap<>();
  84. Map<String, Map<String, ProBasicWppoint>> wppointmap = CacheContext.wppointmap;
  85. CacheContext.wpls.forEach(wp -> {
  86. Map<String, ProBasicWppoint> wppmap = wppointmap.get(wp.getId());
  87. if (wp.getId().contains("FDC")) {
  88. if (wppmap.containsKey(ContantXk.SBZT)) {
  89. ProBasicWppoint point = wppmap.get(ContantXk.SBZT);
  90. tempWindPower.put(wp.getId(), point);
  91. }
  92. if (wppmap.containsKey(ContantXk.SSPJFS)) {
  93. ProBasicWppoint point = wppmap.get(ContantXk.SSPJFS);
  94. tempWindPowerSpeed.put(wp.getId(), point);
  95. }
  96. if (wppmap.containsKey(ContantXk.SSZGL)) {
  97. ProBasicWppoint point = wppmap.get(ContantXk.SSZGL);
  98. tempWindPowerPower.put(wp.getId(), point);
  99. }
  100. }
  101. });
  102. Map<String, ProBasicEquipmentPoint> tempWindTurbine = new HashMap<>();
  103. Map<String, ProBasicEquipmentPoint> tempSpeed = new HashMap<>();
  104. Map<String, ProBasicEquipmentPoint> tempPower = new HashMap<>();
  105. Map<String, ProBasicEquipmentPoint> tempnh = new HashMap<>();
  106. Map<String, ProBasicEquipmentPoint> tempxd = new HashMap<>();
  107. Map<String, ProBasicEquipmentPoint> tempbzglDictionary = new HashMap<>();
  108. List<ProBasicWindturbine> wtls = CacheContext.wtls;
  109. Map<String, Map<String, ProBasicEquipmentPoint>> wtpAimap = CacheContext.wtpAimap;
  110. wtls.stream().forEach(wt -> {
  111. if (wt.getWindpowerstationId().contains("FDC")) {
  112. //风机状态
  113. Map<String, ProBasicEquipmentPoint> windturbinetestingpointnewMap = wtpAimap.get(wt.getId());
  114. if (windturbinetestingpointnewMap.containsKey(ContantXk.SBZT)) {
  115. ProBasicEquipmentPoint point = windturbinetestingpointnewMap.get(ContantXk.SBZT);
  116. tempWindTurbine.put(wt.getId(), point);
  117. }
  118. //风速
  119. if (windturbinetestingpointnewMap.containsKey(ContantXk.CJ_SSFS)) {
  120. ProBasicEquipmentPoint point = windturbinetestingpointnewMap.get(ContantXk.CJ_SSFS);
  121. tempSpeed.put(wt.getId(), point);
  122. }
  123. //功率
  124. if (windturbinetestingpointnewMap.containsKey(ContantXk.CJ_SSGL)) {
  125. ProBasicEquipmentPoint point = windturbinetestingpointnewMap.get(ContantXk.CJ_SSGL);
  126. tempPower.put(wt.getId(), point);
  127. }
  128. if (windturbinetestingpointnewMap.containsKey(ContantXk.ZSGL)) {
  129. ProBasicEquipmentPoint point = windturbinetestingpointnewMap.get(ContantXk.ZSGL);
  130. tempnh.put(wt.getId(), point);
  131. }
  132. if (windturbinetestingpointnewMap.containsKey(ContantXk.NXDTJSSDL)) {
  133. ProBasicEquipmentPoint point = windturbinetestingpointnewMap.get(ContantXk.NXDTJSSDL);
  134. tempxd.put(wt.getId(), point);
  135. }
  136. if (windturbinetestingpointnewMap.containsKey(ContantXk.BZGL)) {
  137. ProBasicEquipmentPoint point = windturbinetestingpointnewMap.get(ContantXk.BZGL);
  138. tempbzglDictionary.put(wt.getId(), point);
  139. }
  140. }
  141. });
  142. for (String key : tempWindPowerSpeed.keySet()) {
  143. wSpeedDictionary.put(key, tempWindPowerSpeed.get(key).getNemCode());
  144. if (tempWindPowerPower.containsKey(key)) {
  145. wPowerDictionary.put(key, tempWindPowerPower.get(key).getNemCode());
  146. }
  147. }
  148. for (String key : tempSpeed.keySet()) {
  149. speedDictionary.put(key, tempSpeed.get(key).getNemCode());
  150. if (tempPower.containsKey(key)) {
  151. powerDictionary.put(key, tempPower.get(key).getNemCode());
  152. }
  153. if (tempbzglDictionary.containsKey(key)) {
  154. bzglDictionary.put(key, tempbzglDictionary.get(key).getNemCode());
  155. }
  156. if (tempnh.containsKey(key)) {
  157. nhDictionary.put(key, tempnh.get(key).getNemCode());
  158. }
  159. if (tempxd.containsKey(key)) {
  160. nhxdDictionary.put(key, tempxd.get(key).getNemCode());
  161. }
  162. }
  163. windturbines = CacheContext.wtmap;
  164. Map<String, ProEconEquipmentmodel> modelMap = CacheContext.modelMap;
  165. for (String key : tempWindPower.keySet()) {
  166. windPowerDictionary.put(key, tempWindPower.get(key).getNemCode());
  167. List<ProEconMainBrownouts> tempMain = proEconMainBrownoutsService.list().stream().filter(i -> StringUtils.empty(i.getStartTime())
  168. && i.getWindpowerstationId().equals(key))
  169. .sorted(Comparator.comparing(ProEconMainBrownouts::getStopTime)).collect(Collectors.toList());
  170. if (tempMain != null && tempMain.size() > 0) {
  171. for (int i = 1; i < tempMain.size(); i++) {
  172. QueryWrapper<ProEconMainBrownouts> wrapper = new QueryWrapper<>();
  173. wrapper.eq("id", tempMain.get(i).getId());
  174. String mainId = tempMain.get(i).getId();
  175. proEconMainBrownoutsService.remove(wrapper);
  176. List<String> tempSub = proEconBrownoutsEventService.list().stream().filter(x -> StringUtils.empty(x.getMainId().equals(mainId)))
  177. .map(ProEconBrownoutsEvent::getId).collect(Collectors.toList());
  178. deleteSub(tempSub);
  179. }
  180. windpowerEvent.put(key, tempMain.get(0));
  181. String mainid = tempMain.get(0).getId();
  182. List<ProEconBrownoutsEvent> tempSub1 = proEconBrownoutsEventService.list().stream().filter(x -> StringUtils.empty(x.getMainId().equals(mainid)) && StringUtils.empty(x.getStartTime()))
  183. .sorted(Comparator.comparing(ProEconBrownoutsEvent::getStopTime)).collect(Collectors.toList());
  184. for (ProEconBrownoutsEvent item : tempSub1) {
  185. if (!windturbineEvent.containsKey(item.getWindturbineId()))
  186. windturbineEvent.put(item.getWindturbineId(), item);
  187. }
  188. } else {
  189. List<String> tempSub = proEconBrownoutsEventService.list().stream().filter(x -> StringUtils.empty(x.getWindpowerstationId().equals(key)) && StringUtils.empty(x.getStartTime()))
  190. .map(ProEconBrownoutsEvent::getId).collect(Collectors.toList());
  191. deleteSub(tempSub);
  192. windpowerEvent.put(key, null);
  193. }
  194. List<ProEconMainBrownouts2> tempMain2 = proEconMainBrownouts2Service.list().stream().filter(i -> StringUtils.empty(i.getStartTime())
  195. && i.getWindpowerstationId().equals(key))
  196. .sorted(Comparator.comparing(ProEconMainBrownouts2::getStopTime)).collect(Collectors.toList());
  197. if (tempMain2 != null && tempMain2.size() > 0) {
  198. for (int i = 1; i < tempMain2.size(); i++) {
  199. QueryWrapper<ProEconMainBrownouts2> wrapper = new QueryWrapper<>();
  200. wrapper.eq("id", tempMain2.get(i).getId());
  201. String mainId = tempMain2.get(i).getId();
  202. proEconMainBrownouts2Service.remove(wrapper);
  203. List<String> tempSub2 = proEconBrownoutsEvent2Service.list().stream().filter(x -> StringUtils.empty(x.getMainId().equals(mainId)))
  204. .map(ProEconBrownoutsEvent2::getId).collect(Collectors.toList());
  205. deleteSub2(tempSub2);
  206. }
  207. windpowerEvent2.put(key, tempMain2.get(0));
  208. String mainid = tempMain2.get(0).getId();
  209. List<ProEconBrownoutsEvent2> tempSub1 = proEconBrownoutsEvent2Service.list().stream().filter(x -> StringUtils.empty(x.getMainId().equals(mainid)) && StringUtils.empty(x.getStartTime()))
  210. .sorted(Comparator.comparing(ProEconBrownoutsEvent2::getStopTime)).collect(Collectors.toList());
  211. for (ProEconBrownoutsEvent2 item : tempSub1) {
  212. if (!windturbineEvent2.containsKey(item.getWindturbineId()))
  213. windturbineEvent2.put(item.getWindturbineId(), item);
  214. }
  215. } else {
  216. List<String> tempSub2 = proEconBrownoutsEvent2Service.list().stream().filter(x -> StringUtils.empty(x.getWindpowerstationId().equals(key)) && StringUtils.empty(x.getStartTime()))
  217. .map(ProEconBrownoutsEvent2::getId).collect(Collectors.toList());
  218. deleteSub(tempSub2);
  219. windpowerEvent2.put(key, null);
  220. }
  221. }
  222. for (ProBasicWindturbine item : windturbines.values()) {
  223. if (modelMap.containsKey(item.getModelId()))
  224. windturbinePowerProduction.put(item.getId(), modelMap.get(item.getModelId()).getPowerProduction());
  225. else
  226. windturbinePowerProduction.put(item.getId(), 2100.0);
  227. newMethod(item.getWindpowerstationId(), item.getId());
  228. newMethod(item.getProjectId(), item.getId());
  229. newMethod(item.getLineId(), item.getId());
  230. if (tempWindTurbine.containsKey(item.getId())) {
  231. if (!windTurbineDictionary.containsKey(item.getWindpowerstationId())) {
  232. windTurbineDictionary.put(item.getWindpowerstationId(), new HashMap<String, String>());
  233. }
  234. windTurbineDictionary.get(item.getWindpowerstationId()).put(item.getId(), tempWindTurbine.get(item.getId()).getId());
  235. }
  236. if (!windturbineEvent.containsKey(item.getId())) {
  237. windpowerEvent.put(item.getId(), null);
  238. }
  239. }
  240. }
  241. private void deleteSub(List<String> tempSub) {
  242. if (tempSub != null && tempSub.size() > 0) {
  243. proEconBrownoutsEventService.removeByIds(tempSub);
  244. }
  245. }
  246. private void deleteSub(ProEconBrownoutsEvent tempSub) {
  247. QueryWrapper<ProEconBrownoutsEvent> wrapper = new QueryWrapper<>();
  248. wrapper.eq("id", tempSub.getId());
  249. proEconBrownoutsEventService.remove(wrapper);
  250. }
  251. private void deleteSub2(List<String> tempSub) {
  252. proEconBrownoutsEvent2Service.removeByIds(tempSub);
  253. }
  254. private void deleteSub2(ProEconBrownoutsEvent2 tempSub) {
  255. QueryWrapper<ProEconBrownoutsEvent2> wrapper = new QueryWrapper<>();
  256. wrapper.eq("id", tempSub.getId());
  257. proEconBrownoutsEvent2Service.remove(wrapper);
  258. }
  259. private void newMethod(String key, String windtubineId) {
  260. if (!wplDictionary.containsKey(key)) {
  261. wplDictionary.put(key, new ArrayList<String>());
  262. }
  263. wplDictionary.get(key).add(windtubineId);
  264. }
  265. public void Exec() throws Exception {
  266. //风场限电事件
  267. windpowerEvent.clear();
  268. //风机限电事件
  269. windturbineEvent.clear();
  270. Date dt = new Date();
  271. List<ProEconMainBrownouts> tempMain = proEconMainBrownoutsService.list().stream().filter(i -> StringUtils.empty(i.getStartTime()))
  272. .sorted(Comparator.comparing(ProEconMainBrownouts::getStopTime)).collect(Collectors.toList());
  273. for (ProEconMainBrownouts item : tempMain) {
  274. if (!windpowerEvent.containsKey(item.getWindpowerstationId())) {
  275. windpowerEvent.put(item.getWindpowerstationId(), item);
  276. } else {
  277. QueryWrapper<ProEconMainBrownouts> wrapper = new QueryWrapper<>();
  278. wrapper.eq("id", item.getId());
  279. proEconMainBrownoutsService.remove(wrapper);
  280. }
  281. }
  282. List<ProEconBrownoutsEvent> tempSub = proEconBrownoutsEventService.list().stream().filter(x -> StringUtils.empty(x.getStartTime()))
  283. .sorted(Comparator.comparing(ProEconBrownoutsEvent::getStopTime)).collect(Collectors.toList());
  284. for (ProEconBrownoutsEvent item : tempSub) {
  285. if (!windturbineEvent.containsKey(item.getWindturbineId())) {
  286. windturbineEvent.put(item.getWindturbineId(), item);
  287. } else {
  288. QueryWrapper<ProEconBrownoutsEvent> wrapper = new QueryWrapper<>();
  289. wrapper.eq("id", item.getId());
  290. proEconBrownoutsEventService.remove(wrapper);
  291. }
  292. }
  293. for (String key : windPowerDictionary.keySet()) {
  294. if (!windpowerEvent.containsKey(key)) {
  295. windpowerEvent.put(key, null);
  296. }
  297. if (windTurbineDictionary.containsKey(key)) {
  298. for (String wkey : windTurbineDictionary.get(key).keySet()) {
  299. if (!windturbineEvent.containsKey(wkey)) {
  300. windturbineEvent.put(wkey, null);
  301. }
  302. }
  303. }
  304. }
  305. for (String key : windPowerDictionary.keySet()) {
  306. double wpstate = edosUtil.getRealData(windPowerDictionary.get(key)).getPointValueInDouble();
  307. if (wpstate == 5 || wpstate == 6)
  308. {
  309. //限电起始
  310. if (windpowerEvent.get(key) == null) {
  311. //新增风机限电事件
  312. ProEconMainBrownouts main = addMainBrownouts(dt, key);
  313. if (windTurbineDictionary.containsKey(key)) {
  314. Map<String, String> windDic = windTurbineDictionary.get(key);
  315. for (String wkey : windDic.keySet()) {
  316. //新增风机限电事件
  317. double windstate = edosUtil.getRealData(windDic.get(wkey)).getPointValueInDouble();
  318. if (windstate == 5 || windstate == 6) {
  319. if (windturbineEvent.get(wkey) == null) {
  320. addBrownoutsEvent(dt, key, main, wkey, windstate);
  321. }
  322. }
  323. }
  324. }
  325. }
  326. //限电进行时
  327. else
  328. {
  329. ProEconMainBrownouts main = windpowerEvent.get(key);
  330. if (windTurbineDictionary.containsKey(key)) {
  331. Map<String, String> windDic = windTurbineDictionary.get(key);
  332. for (String wkey : windDic.keySet()) {
  333. double windstate = edosUtil.getRealData(windDic.get(wkey)).getPointValueInDouble();
  334. if (windstate == 5 || windstate == 6) {
  335. if (windturbineEvent.get(wkey) == null) {
  336. //新增风机限电事件
  337. addBrownoutsEvent(dt, key, main, wkey, windstate);
  338. } else {
  339. // 风机限电进行时
  340. if (windturbineEvent.get(wkey).getMainId().equals(main.getId())) {
  341. double temp = main.getLossPower();
  342. double tempvulue = buildBrownoutsEvent(new Date(0), key, wkey, dt);
  343. main.setLossPower(StringUtils.round(temp + tempvulue, 2));
  344. } else {
  345. deleteSub(windturbineEvent.get(wkey));
  346. }
  347. }
  348. } else {
  349. if (windturbineEvent.get(wkey) != null) {
  350. //风机限电结束时
  351. if (windturbineEvent.get(wkey).getMainId().equals(main.getId())) {
  352. double temp = main.getLossPower();
  353. double tempvulue = buildBrownoutsEvent(dt, key, wkey, dt);
  354. main.setLossPower(StringUtils.round(temp + tempvulue, 2));
  355. windturbineEvent.put(wkey, null);
  356. } else {
  357. deleteSub(windturbineEvent.get(wkey));
  358. }
  359. }
  360. }
  361. }
  362. }
  363. updateMainDateBase(new Date(0), main, dt);//需要修改
  364. }
  365. }
  366. //限电结束时
  367. else
  368. {
  369. if (windpowerEvent.get(key) != null) {
  370. ProEconMainBrownouts main = windpowerEvent.get(key);
  371. if (windTurbineDictionary.containsKey(key)) {
  372. Map<String, String> windDic = windTurbineDictionary.get(key);
  373. for (String wkey : windDic.keySet()) {
  374. if (windturbineEvent.get(wkey) != null) {
  375. //风机限电结束时
  376. if (windturbineEvent.get(wkey).getMainId().equals(main.getId())) {
  377. double temp = main.getLossPower();
  378. double tempvulue = buildBrownoutsEvent(dt, key, wkey, dt);
  379. main.setLossPower(StringUtils.round(temp + tempvulue, 2));
  380. windturbineEvent.put(wkey, null);
  381. } else {
  382. deleteSub(windturbineEvent.get(wkey));
  383. }
  384. }
  385. }
  386. }
  387. updateMainDateBase(dt, main, dt);//需要修改
  388. main.setStartTime(dt);
  389. }
  390. }
  391. }
  392. }
  393. //限电事件当天
  394. public void Exec2() throws Exception {
  395. //风场限电事件
  396. windpowerEvent2.clear();
  397. //风机限电事件
  398. windturbineEvent2.clear();
  399. Date dt = new Date();
  400. List<ProEconMainBrownouts2> tempMain = proEconMainBrownouts2Service.list().stream().filter(i -> StringUtils.empty(i.getStartTime()))
  401. .sorted(Comparator.comparing(ProEconMainBrownouts2::getStopTime)).collect(Collectors.toList());
  402. for (ProEconMainBrownouts2 item : tempMain) {
  403. if (!windpowerEvent2.containsKey(item.getWindpowerstationId())) {
  404. windpowerEvent2.put(item.getWindpowerstationId(), item);
  405. } else {
  406. QueryWrapper<ProEconMainBrownouts2> wrapper = new QueryWrapper<>();
  407. wrapper.eq("id", item.getId());
  408. proEconMainBrownouts2Service.remove(wrapper);
  409. }
  410. }
  411. List<ProEconBrownoutsEvent2> tempSub = proEconBrownoutsEvent2Service.list().stream().filter(x -> StringUtils.empty(x.getStartTime()))
  412. .sorted(Comparator.comparing(ProEconBrownoutsEvent2::getStopTime)).collect(Collectors.toList());
  413. for (ProEconBrownoutsEvent2 item : tempSub) {
  414. if (!windturbineEvent2.containsKey(item.getWindturbineId())) {
  415. windturbineEvent2.put(item.getWindturbineId(), item);
  416. } else {
  417. QueryWrapper<ProEconBrownoutsEvent2> wrapper = new QueryWrapper<>();
  418. wrapper.eq("id", item.getId());
  419. proEconBrownoutsEvent2Service.remove(wrapper);
  420. }
  421. }
  422. for (String key : windPowerDictionary.keySet()) {
  423. if (!windpowerEvent2.containsKey(key)) {
  424. windpowerEvent2.put(key, null);
  425. }
  426. if (windTurbineDictionary.containsKey(key)) {
  427. for (String wkey : windTurbineDictionary.get(key).keySet()) {
  428. if (!windturbineEvent2.containsKey(wkey)) {
  429. windturbineEvent2.put(wkey, null);
  430. }
  431. }
  432. }
  433. }
  434. for (String key : windPowerDictionary.keySet()) {
  435. double wpstate = edosUtil.getRealData(windPowerDictionary.get(key)).getPointValueInDouble();
  436. if (wpstate == 5 || wpstate == 6)
  437. {
  438. //限电起始
  439. if (windpowerEvent2.get(key) == null) {
  440. //新增风机限电事件
  441. ProEconMainBrownouts2 main = addMainBrownouts2(dt, key);
  442. if (windTurbineDictionary.containsKey(key)) {
  443. Map<String, String> windDic = windTurbineDictionary.get(key);
  444. for (String wkey : windDic.keySet()) {
  445. //新增风机限电事件
  446. double windstate = edosUtil.getRealData(windDic.get(wkey)).getPointValueInDouble();
  447. if (windstate == 5 || windstate == 6) {
  448. if (windturbineEvent2.get(wkey) == null) {
  449. addBrownoutsEvent2(dt, key, main, wkey, windstate);
  450. }
  451. }
  452. }
  453. }
  454. }
  455. //限电进行时
  456. else
  457. {
  458. ProEconMainBrownouts2 main = windpowerEvent2.get(key);
  459. if (DateUtils.getDay(dt) != DateUtils.getDay(main.getStopTime()))
  460. {
  461. dt = DateUtils.truncate(dt);
  462. //region 跨天
  463. //egion 前一天
  464. if (windTurbineDictionary.containsKey(key)) {
  465. Map<String, String> windDic = windTurbineDictionary.get(key);
  466. for (String wkey : windDic.keySet()) {
  467. if (windturbineEvent2.get(wkey) != null)
  468. {
  469. //风机限电结束时
  470. if (windturbineEvent2.get(wkey).getMainId().equals(main.getId())) {
  471. double temp = main.getLossPower();
  472. double tempvulue = buildBrownoutsEvent2(new Date(0), key, wkey, dt);
  473. main.setLossPower(StringUtils.round(temp + tempvulue, 2));
  474. windturbineEvent2.put(wkey, null);
  475. } else {
  476. deleteSub2(windturbineEvent2.get(wkey));
  477. }
  478. }
  479. }
  480. }
  481. updateMainDateBase2(dt, main, dt);//需要修改
  482. main.setStartTime(dt);
  483. //
  484. windpowerEvent2.put(key, null);
  485. //后一天
  486. ProEconMainBrownouts2 mainnow = addMainBrownouts2(dt, key);
  487. if (windTurbineDictionary.containsKey(key)) {
  488. Map<String, String> windDic = windTurbineDictionary.get(key);
  489. for (String wkey : windDic.keySet())
  490. {
  491. //新增风机限电事件
  492. double windstate = edosUtil.getRealData(windDic.get(wkey)).getPointValueInDouble();
  493. if (windstate == 5 || windstate == 6) {
  494. if (windturbineEvent2.get(wkey) == null) {
  495. addBrownoutsEvent2(dt, key, mainnow, wkey, windstate);
  496. }
  497. }
  498. }
  499. }
  500. }
  501. else
  502. {
  503. //当天
  504. if (windTurbineDictionary.containsKey(key)) {
  505. Map<String, String> windDic = windTurbineDictionary.get(key);
  506. for (String wkey : windDic.keySet()) {
  507. double windstate = edosUtil.getRealData((windDic.get(wkey))).getPointValueInDouble();
  508. if (windstate == 5 || windstate == 6) {
  509. if (windturbineEvent2.get(wkey) == null) {
  510. //新增风机限电事件
  511. addBrownoutsEvent2(dt, key, main, wkey, windstate);
  512. } else {
  513. if (windturbineEvent2.get(wkey).getMainId().equals(main.getId())) {
  514. double temp = main.getLossPower();
  515. double tempvulue = buildBrownoutsEvent2(new Date(0), key, wkey, dt);
  516. main.setLossPower(StringUtils.round(temp + tempvulue, 2));
  517. windturbineEvent2.put(wkey, null);
  518. } else {
  519. deleteSub2(windturbineEvent2.get(wkey));
  520. }
  521. }
  522. }
  523. else
  524. {
  525. if (windturbineEvent2.get(wkey) != null) {
  526. //风机限电结束时
  527. if (windturbineEvent2.get(wkey).getMainId().equals(main.getId())) {
  528. double temp = main.getLossPower();
  529. double tempvulue = buildBrownoutsEvent2(dt, key, wkey, dt);
  530. main.setLossPower(StringUtils.round(temp + tempvulue, 2));
  531. windturbineEvent2.put(wkey, null);
  532. } else {
  533. deleteSub2(windturbineEvent2.get(wkey));
  534. }
  535. }
  536. }
  537. }
  538. }
  539. updateMainDateBase2(new Date(0), main, dt);//需要修改
  540. }
  541. }
  542. }
  543. //限电结束时
  544. else
  545. {
  546. if (windpowerEvent2.get(key) != null) {
  547. ProEconMainBrownouts2 main = windpowerEvent2.get(key);
  548. if (windTurbineDictionary.containsKey(key)) {
  549. Map<String, String> windDic = windTurbineDictionary.get(key);
  550. for (String wkey : windDic.keySet()) {
  551. if (windturbineEvent2.get(wkey) != null) {
  552. //风机限电结束时
  553. if (windturbineEvent2.get(wkey).getMainId().equals(main.getId())) {
  554. double temp = main.getLossPower();
  555. double tempvulue = buildBrownoutsEvent2(dt, key, wkey, dt);
  556. main.setLossPower(StringUtils.round(temp + tempvulue, 2));
  557. windturbineEvent2.put(wkey, null);
  558. } else {
  559. deleteSub2(windturbineEvent2.get(wkey));
  560. }
  561. }
  562. }
  563. }
  564. updateMainDateBase2(dt, main, dt);//需要修改
  565. main.setStartTime(dt);
  566. }
  567. }
  568. }
  569. }
  570. private Double buildBrownoutsEvent(Date dt, String key, String wkey, Date nowdt) throws Exception {
  571. ProEconBrownoutsEvent sub = windturbineEvent.get(wkey);
  572. if (!(dt.compareTo(new Date(0)) == 0)) {
  573. sub.setStartTime(dt);
  574. }
  575. DNAStatVal[] hsls = edosUtil.getHistStat(powerDictionary.get(wkey), sub.getStopTime().getTime() / 1000, dt.getTime() / 1000, 1);
  576. if (StringUtils.notEmp(hsls) && hsls.length > 0) {
  577. sub.setLimitLoad(hsls[0].avg.DValue);
  578. }
  579. sub.setStopHours(DateUtils.hoursDiff1(nowdt, sub.getStopTime()));
  580. double losspower = calcLossPower(wkey, sub.getStopTime(), nowdt, (double) sub.getStopHours(), windturbinePowerProduction.get(wkey));//需要修改
  581. sub.setLossPower(losspower);
  582. if (nhxdDictionary.containsKey(wkey)) {
  583. hsls = edosUtil.getHistStat(nhxdDictionary.get(wkey), sub.getStopTime().getTime() / 1000, nowdt.getTime() / 1000, 1);
  584. if (StringUtils.notEmp(hsls) && hsls.length >0) {
  585. double max = hsls[0].max.DValue;
  586. double min = hsls[0].min.DValue;
  587. sub.setLossPower(StringUtils.round(max - min, 2));
  588. }
  589. }
  590. return sub.getLossPower();
  591. }
  592. private Double buildBrownoutsEvent2(Date dt, String key, String wkey, Date nowdt) throws Exception {
  593. ProEconBrownoutsEvent2 sub = windturbineEvent2.get(wkey);
  594. if (!(dt.compareTo(new Date(0)) == 0)) {
  595. sub.setStartTime(dt);
  596. }
  597. DNAStatVal[] hsls = edosUtil.getHistStat(powerDictionary.get(wkey), sub.getStopTime().getTime() / 1000, dt.getTime() / 1000, 1);
  598. if (StringUtils.notEmp(hsls) && hsls.length > 0) {
  599. sub.setLimitLoad(hsls[0].avg.DValue);
  600. }
  601. sub.setStopHours(DateUtils.hoursDiff1(nowdt, sub.getStopTime()));
  602. double losspower = calcLossPower(wkey, sub.getStopTime(), nowdt, (double) sub.getStopHours(), windturbinePowerProduction.get(wkey));//需要修改
  603. sub.setLossPower(losspower);
  604. if (nhxdDictionary.containsKey(wkey)) {
  605. hsls = edosUtil.getHistStat(nhxdDictionary.get(wkey), sub.getStopTime().getTime() / 1000, nowdt.getTime() / 1000, 1);
  606. if (StringUtils.notEmp(hsls) && hsls.length >0) {
  607. double max = hsls[0].max.DValue;
  608. double min = hsls[0].min.DValue;
  609. sub.setLossPower(StringUtils.round(max - min, 2));
  610. }
  611. }
  612. return sub.getLossPower();
  613. }
  614. private void addBrownoutsEvent(Date dt, String key, ProEconMainBrownouts main, String wkey, double windstate) throws Exception {
  615. ProEconBrownoutsEvent sub = new ProEconBrownoutsEvent();
  616. sub.setWindpowerstationId(key);
  617. sub.setWindturbineId(wkey);
  618. sub.setProjectId(windturbines.get(wkey).getProjectId());
  619. sub.setLineId(windturbines.get(wkey).getLineId());
  620. sub.setStopTime(dt);
  621. sub.setStartTime(null);
  622. sub.setStopHours(0.0);
  623. sub.setLossPower(0.0);
  624. if (windstate == 5) {
  625. sub.setStopTypeId("非停机限电");
  626. } else {
  627. sub.setStopTypeId("停机限电");
  628. }
  629. sub.setMainId(main.getId());
  630. sub.setLimitLoad(edosUtil.getRealData(powerDictionary.get(wkey)).getPointValueInDouble());
  631. sub.setWindSpeed(edosUtil.getRealData(speedDictionary.get(wkey)).getPointValueInDouble());
  632. DNAStatVal[] hsls = edosUtil.getHistStat(powerDictionary.get(wkey), DateUtils.addMinutes(dt, -5).getTime() / 1000, dt.getTime() / 1000, 1);
  633. if (StringUtils.notEmp(hsls) && hsls.length > 0 && hsls.length >0) {
  634. sub.setThisLoad(hsls[0].max.DValue);
  635. }
  636. windturbineEvent.put(wkey, sub);
  637. proEconBrownoutsEventService.save(sub);
  638. }
  639. private void addBrownoutsEvent2(Date dt, String key, ProEconMainBrownouts2 main, String wkey, double windstate) throws Exception {
  640. ProEconBrownoutsEvent2 sub = new ProEconBrownoutsEvent2();
  641. sub.setWindpowerstationId(key);
  642. sub.setWindturbineId(wkey);
  643. sub.setProjectId(windturbines.get(wkey).getProjectId());
  644. sub.setLineId(windturbines.get(wkey).getLineId());
  645. sub.setStopTime(dt);
  646. sub.setStartTime(null);
  647. sub.setStopHours(0.0);
  648. sub.setLossPower(0.0);
  649. if (windstate == 5) {
  650. sub.setStopTypeId("非停机限电");
  651. } else {
  652. sub.setStopTypeId("停机限电");
  653. }
  654. sub.setMainId(main.getId());
  655. sub.setLimitLoad(edosUtil.getRealData(powerDictionary.get(wkey)).getPointValueInDouble());
  656. sub.setWindSpeed(edosUtil.getRealData(speedDictionary.get(wkey)).getPointValueInDouble());
  657. DNAStatVal[] hsls = edosUtil.getHistStat(powerDictionary.get(wkey), DateUtils.addMinutes(dt, -5).getTime() / 1000, dt.getTime() / 1000, 1);
  658. if (StringUtils.notEmp(hsls) && hsls.length > 0 && hsls.length >0) {
  659. sub.setThisLoad(hsls[0].max.DValue);
  660. }
  661. windturbineEvent2.put(wkey, sub);
  662. proEconBrownoutsEvent2Service.save(sub);
  663. }
  664. //修改后的限电损失统计,通过时序数据库历史切面计算
  665. private Double calcLossPower(String windturbineId, Date startDate, Date endDate, double hours, Double maxPower) throws Exception {
  666. Double result = 0.0;
  667. Map<String, Map<String, ProBasicEquipmentPoint>> wtpAimap = CacheContext.wtpAimap;
  668. Map<String, ProBasicEquipmentPoint> wtpointmap=wtpAimap.get(windturbineId);
  669. Calendar c1=Calendar.getInstance();
  670. c1.setTime(startDate);
  671. Calendar c2=Calendar.getInstance();
  672. c2.setTime(endDate);
  673. //判定限电是否跨年
  674. if(endDate.after(startDate) && c1.get(Calendar.YEAR)==c2.get(Calendar.YEAR))
  675. {
  676. //年限电欠发损失电量
  677. if(wtpointmap.containsKey(ContantXk.NXDTJSSDL) )
  678. {
  679. double beginvalue=0.0;
  680. double endvalue=0.0;
  681. List<String> pointid=new ArrayList<>();
  682. pointid.add(wtpointmap.get(ContantXk.NXDTJSSDL).getNemCode());
  683. List<PointData> xdbegin=edosUtil.getHistMatrix(pointid,startDate.getTime()/1000);
  684. List<PointData> xdend=edosUtil.getHistMatrix(pointid,endDate.getTime()/1000);
  685. if(xdbegin.size()==1 && xdend.size()==1)
  686. {
  687. beginvalue=xdbegin.get(0).getPointValueInDouble();
  688. endvalue=xdend.get(0).getPointValueInDouble();
  689. if (endvalue > beginvalue) {
  690. result =result+(endvalue - beginvalue);
  691. }
  692. }
  693. }
  694. //年限电损失电量
  695. if(wtpointmap.containsKey(ContantXk.NXDJCLSSDL) )
  696. {
  697. double beginvalue=0.0;
  698. double endvalue=0.0;
  699. List<String> pointid=new ArrayList<>();
  700. pointid.add(wtpointmap.get(ContantXk.NXDJCLSSDL).getNemCode());
  701. List<PointData> xdbegin=edosUtil.getHistMatrix(pointid,startDate.getTime()/1000);
  702. List<PointData> xdend=edosUtil.getHistMatrix(pointid,endDate.getTime()/1000);
  703. if(xdbegin.size()==1 && xdend.size()==1)
  704. {
  705. beginvalue=xdbegin.get(0).getPointValueInDouble();
  706. endvalue=xdend.get(0).getPointValueInDouble();
  707. if (endvalue > beginvalue) {
  708. result =result+(endvalue - beginvalue);
  709. }
  710. }
  711. }
  712. }else
  713. {
  714. Calendar c=Calendar.getInstance();
  715. c.setTime(DateUtils.truncDay(startDate));
  716. c.add(Calendar.DAY_OF_MONTH,1);
  717. //获得1月1日零点值
  718. Date endtime=c.getTime();
  719. //年限电欠发损失电量
  720. if(wtpointmap.containsKey(ContantXk.NXDTJSSDL) )
  721. {
  722. double beginvalue=0.0;
  723. double endvalue=0.0;
  724. List<String> pointid=new ArrayList<>();
  725. pointid.add(wtpointmap.get(ContantXk.NXDTJSSDL).getNemCode());
  726. List<PointData> xdbegin=edosUtil.getHistMatrix(pointid,startDate.getTime()/1000);
  727. List<PointData> xdend=edosUtil.getHistMatrix(pointid,endDate.getTime()/1000);
  728. if(xdbegin.size()==1 && xdend.size()==1)
  729. {
  730. beginvalue=xdbegin.get(0).getPointValueInDouble();
  731. endvalue=xdend.get(0).getPointValueInDouble();
  732. if (endvalue > beginvalue) {
  733. result =result+(endvalue - beginvalue);
  734. }
  735. }
  736. }
  737. //年限电损失电量
  738. if(wtpointmap.containsKey(ContantXk.NXDJCLSSDL) )
  739. {
  740. double beginvalue=0.0;
  741. double endvalue=0.0;
  742. List<String> pointid=new ArrayList<>();
  743. pointid.add(wtpointmap.get(ContantXk.NXDJCLSSDL).getNemCode());
  744. List<PointData> xdbegin=edosUtil.getHistMatrix(pointid,startDate.getTime()/1000);
  745. List<PointData> xdend=edosUtil.getHistMatrix(pointid,endDate.getTime()/1000);
  746. if(xdbegin.size()==1 && xdend.size()==1)
  747. {
  748. beginvalue=xdbegin.get(0).getPointValueInDouble();
  749. endvalue=xdend.get(0).getPointValueInDouble();
  750. if (endvalue > beginvalue) {
  751. result =result+(endvalue - beginvalue);
  752. }
  753. }
  754. }
  755. //日限电欠发损失电量
  756. if(wtpointmap.containsKey(ContantXk.NXDTJSSDL) )
  757. {
  758. double endvalue=0.0;
  759. List<String> pointid=new ArrayList<>();
  760. pointid.add(wtpointmap.get(ContantXk.NXDTJSSDL).getNemCode());
  761. List<PointData> xdend=edosUtil.getHistMatrix(pointid,endDate.getTime()/1000);
  762. if( xdend.size()==1)
  763. {
  764. endvalue=xdend.get(0).getPointValueInDouble();
  765. if (endvalue > 0) {
  766. result =result+endvalue;
  767. }
  768. }
  769. }
  770. //日限电损失电量
  771. if(wtpointmap.containsKey(ContantXk.NXDJCLSSDL) )
  772. {
  773. double beginvalue=0.0;
  774. double endvalue=0.0;
  775. List<String> pointid=new ArrayList<>();
  776. pointid.add(wtpointmap.get(ContantXk.NXDJCLSSDL).getNemCode());
  777. List<PointData> xdend=edosUtil.getHistMatrix(pointid,endDate.getTime()/1000);
  778. if( xdend.size()==1)
  779. {
  780. endvalue=xdend.get(0).getPointValueInDouble();
  781. if (endvalue > 0) {
  782. result =result+endvalue;
  783. }
  784. }
  785. }
  786. }
  787. return result;
  788. }
  789. //读取历史数据
  790. public List<PointData> getHisData(String szPoint, Date startTime, Date endTime) throws Exception {
  791. List<PointData> result = edosUtil.getHistoryDatasSnap(szPoint, startTime.getTime() / 1000, endTime.getTime() / 1000);
  792. if (result.size() == 0) {
  793. //logger.ErrorFormat(" getHisData(String szPoint={0}, Date startTime={1}, Date endTime={2})", szPoint, startTime, endTime);
  794. PointData pa = new PointData();
  795. pa.setPointValueInDouble(0.0);
  796. result.add(pa);
  797. }
  798. return result;
  799. }
  800. // //电量分析主要针对省公司和各风场的每月实际发电量与计划的对比分析,可以查看省公司及各风场每月计划的完成情况和总体的计划完成情况,可以同比和环比进行比较;
  801. // //对省公司和各风场的实际发电量与理论发电量的对比分析,利用标准功率曲线中的风速,理论功率,和固定时间段的风频进行统计,设计统计分析公式为:
  802. // //理论发电量=(T*f1/f)*P1+(T*f2/f)*P2+…………(T*fn/f)*Pn
  803. // //T是选取的时间段;
  804. // //f是所有风频的和;
  805. // //f1、f2、fn是某风速对应的风频;
  806. // //P1、Pn是某风速对应理论曲线上的功率。
  807. // //必要性:如果理论电量能够实现计算的准确,调峰电量就可以用理论电量来减去实际电量得出。
  808. // //b、可选一段时间内的实际功率和理论功率能够形成曲线形式展示对比,理论功率根据实际风速利用理论功率曲线得出。
  809. // //c、风频数据取值时间段需要统一。
  810. // private Double updateTheoryGeneration(List<PointData> powerDataList, double hours, Double maxPower) {
  811. // //maxPower = maxPower * 1.2m;
  812. // Double result = 0.0;
  813. // Double T = (Double) hours;
  814. // Double f = Double.valueOf(powerDataList.size());
  815. //
  816. // if (f != 0) {
  817. // for (int i = 0; i < f; i++) {
  818. // Double P = powerDataList.get(i).getPointValueInDouble();
  819. // if (P >= 0 && P <= maxPower)
  820. // result += (T * 1 / f) * P;
  821. // }
  822. // }
  823. // return result;
  824. // }
  825. //需要修改
  826. private void updateMainDateBase(Date dt, ProEconMainBrownouts main, Date nowdt) {
  827. if (!(dt.compareTo(new Date(0)) == 0)) {
  828. main.setStartTime(dt);
  829. }
  830. //main.LOSSPOWER=entities.ProEconBrownoutsEvent.Where(it => it.MAINID == main.ID).Sum(it => it.LOSSPOWER);
  831. main.setStopHours(DateUtils.hoursDiff1(nowdt, main.getStopTime()));
  832. }
  833. private void updateMainDateBase2(Date dt, ProEconMainBrownouts2 main, Date nowdt) {
  834. if (!(dt.compareTo(new Date(0)) == 0)) {
  835. main.setStartTime(dt);
  836. }
  837. //main.LOSSPOWER = entities.ProEconBrownoutsEvent2.Where(it => it.MAINID == main.ID).Sum(it => it.LOSSPOWER).Value;
  838. main.setStopHours(DateUtils.hoursDiff1(nowdt, main.getStopTime()));
  839. }
  840. private ProEconMainBrownouts addMainBrownouts(Date dt, String key) throws Exception {
  841. ProEconMainBrownouts main = new ProEconMainBrownouts();
  842. main.setStopTime(dt);
  843. main.setStartTime(null);
  844. main.setStopTypeId("非停机限电");
  845. main.setLimitLoad(edosUtil.getRealData(wPowerDictionary.get(key)).getPointValueInDouble());
  846. main.setWindSpeed(edosUtil.getRealData(wSpeedDictionary.get(key)).getPointValueInDouble());
  847. DNAStatVal[] hsls = edosUtil.getHistStat(wPowerDictionary.get(key), DateUtils.addMinutes(dt, -5).getTime() / 1000, dt.getTime() / 1000, 1);
  848. if (StringUtils.notEmp(hsls) && hsls.length > 0 && hsls.length >0) {
  849. main.setThisLoad(hsls[0].max.DValue);
  850. }
  851. main.setWindpowerstationId(key);
  852. main.setLossPower(0.0);
  853. main.setWindpowerstationId(key);
  854. windpowerEvent.put(key, main);
  855. proEconMainBrownoutsService.save(main);
  856. return main;
  857. }
  858. private ProEconMainBrownouts2 addMainBrownouts2(Date dt, String key) throws Exception {
  859. ProEconMainBrownouts2 main = new ProEconMainBrownouts2();
  860. main.setStopTime(dt);
  861. main.setStartTime(null);
  862. main.setStopTypeId("非停机限电");
  863. main.setLimitLoad(edosUtil.getRealData(wPowerDictionary.get(key)).getPointValueInDouble());
  864. main.setWindSpeed(edosUtil.getRealData(wSpeedDictionary.get(key)).getPointValueInDouble());
  865. DNAStatVal[] hsls = edosUtil.getHistStat(wPowerDictionary.get(key), DateUtils.addMinutes(dt, -5).getTime() / 1000, dt.getTime() / 1000, 1);
  866. if (StringUtils.notEmp(hsls) && hsls.length > 0 && hsls.length >0) {
  867. main.setThisLoad(hsls[0].max.DValue);
  868. }
  869. main.setWindpowerstationId(key);
  870. main.setLossPower(0.0);
  871. main.setWindpowerstationId(key);
  872. windpowerEvent2.put(key, main);
  873. proEconMainBrownouts2Service.save(main);
  874. return main;
  875. }
  876. }