WindPowerInfo1Service.java 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445
  1. package com.gyee.generation.service;//package com.gyee.generation.service;
  2. import com.gyee.common.contant.ContantXk;
  3. import com.gyee.common.model.PointData;
  4. import com.gyee.common.model.StringUtils;
  5. import com.gyee.generation.init.CacheContext;
  6. import com.gyee.generation.model.auto.*;
  7. import com.gyee.generation.model.vo.Location;
  8. import com.gyee.generation.service.auto.*;
  9. import com.gyee.generation.util.DateUtils;
  10. import com.gyee.generation.util.realtimesource.IEdosUtil;
  11. import com.gyee.generation.util.statisticcs.Initial;
  12. import org.slf4j.Logger;
  13. import org.slf4j.LoggerFactory;
  14. import org.springframework.stereotype.Service;
  15. import javax.annotation.Resource;
  16. import java.math.BigDecimal;
  17. import java.math.RoundingMode;
  18. import java.util.*;
  19. import java.util.stream.Collectors;
  20. @Service
  21. public class WindPowerInfo1Service {
  22. private static final Logger logger = LoggerFactory.getLogger(WindPowerInfo1Service.class);
  23. @Resource
  24. private IEdosUtil edosUtil;
  25. @Resource
  26. private IProEconPowerstationInfoDay1Service proEconPowerstationInfoDay1Service;
  27. /**
  28. * 计算区域日信息
  29. * @param recordDate
  30. * @throws Exception
  31. */
  32. public void calRegionInfoDay(Date recordDate) throws Exception {
  33. List<ProEconPowerstationInfoDay1> wpinfodayls = proEconPowerstationInfoDay1Service.list().stream()
  34. .filter(i -> i.getRecordDate().compareTo(DateUtils.truncDay(recordDate))==0
  35. // && CacheContext.wpmap.containsKey(i.getWindpowerstationId())
  36. && i.getLocation().equals(Location.cp.getValue()))
  37. .collect(Collectors.toList());
  38. if(!wpinfodayls.isEmpty())
  39. {
  40. Map<String, Map<String, List<ProEconPowerstationInfoDay1>>>rgmap=new HashMap<>();
  41. for(ProEconPowerstationInfoDay1 wpinfo:wpinfodayls)
  42. {
  43. if(rgmap.containsKey(wpinfo.getCompanyId()))
  44. {
  45. Map<String, List<ProEconPowerstationInfoDay1>> map=rgmap.get(wpinfo.getCompanyId());
  46. List<ProEconPowerstationInfoDay1> qbls=map.get("qb");
  47. List<ProEconPowerstationInfoDay1> gfls=map.get("fd");
  48. List<ProEconPowerstationInfoDay1> fdls=map.get("gf");
  49. if(wpinfo.getForeignKeyId().equals("-1"))
  50. {
  51. fdls.add(wpinfo);
  52. }else if(wpinfo.getForeignKeyId().equals("-2")){
  53. gfls.add(wpinfo);
  54. }
  55. qbls.add(wpinfo);
  56. }else
  57. {
  58. Map<String, List<ProEconPowerstationInfoDay1>> map=new HashMap<>();
  59. List<ProEconPowerstationInfoDay1> qbls=new ArrayList<>();
  60. List<ProEconPowerstationInfoDay1> gfls=new ArrayList<>();
  61. List<ProEconPowerstationInfoDay1> fdls=new ArrayList<>();
  62. if(wpinfo.getForeignKeyId().equals("-1"))
  63. {
  64. fdls.add(wpinfo);
  65. }else if(wpinfo.getForeignKeyId().equals("-2")){
  66. gfls.add(wpinfo);
  67. }
  68. qbls.add(wpinfo);
  69. map.put("qb",qbls);
  70. map.put("fd",fdls);
  71. map.put("gf",gfls);
  72. }
  73. }
  74. //判断是否有重复记录,先删除重复记录
  75. List<String> idls = proEconPowerstationInfoDay1Service.list().stream()
  76. .filter(i -> i.getRecordDate().compareTo(DateUtils.truncDay(recordDate))==0
  77. // && CacheContext.wpmap.containsKey(i.getWindpowerstationId())
  78. && i.getLocation().equals(Location.rg.getValue())).map(ProEconPowerstationInfoDay1::getId)
  79. .collect(Collectors.toList());
  80. if (idls != null && idls.size() > 0) {
  81. proEconPowerstationInfoDay1Service.removeByIds(idls);
  82. }
  83. for(Map.Entry<String, Map<String, List<ProEconPowerstationInfoDay1>>> entry:rgmap.entrySet()){
  84. Map<String, List<ProEconPowerstationInfoDay1>> map=entry.getValue();
  85. List<ProEconPowerstationInfoDay1> qbls=map.get("qb");
  86. List<ProEconPowerstationInfoDay1> gfls=map.get("fd");
  87. List<ProEconPowerstationInfoDay1> fdls=map.get("gf");
  88. // if(CacheContext.cpwpmap.size()==qbls.size())
  89. // {
  90. ProEconPowerstationInfoDay1 qb=new ProEconPowerstationInfoDay1();
  91. ProEconPowerstationInfoDay1 fd=new ProEconPowerstationInfoDay1();
  92. ProEconPowerstationInfoDay1 gf=new ProEconPowerstationInfoDay1();
  93. if(CacheContext.rgmap.containsKey(entry.getKey()))
  94. {
  95. ProBasicRegion cp=CacheContext.rgmap.get(entry.getKey());
  96. gf.setRegionId(cp.getId());
  97. gf.setRecordDate(DateUtils.truncDay(recordDate));
  98. gf.setForeignKeyId("-2");
  99. gf.setLocation(Location.rg.getValue());
  100. fd.setRegionId(cp.getId());
  101. fd.setRecordDate(DateUtils.truncDay(recordDate));
  102. fd.setForeignKeyId("-1");
  103. fd.setLocation(Location.rg.getValue());
  104. qb.setRegionId(cp.getId());
  105. qb.setRecordDate(DateUtils.truncDay(recordDate));
  106. qb.setForeignKeyId("0");
  107. qb.setLocation(Location.rg.getValue());
  108. //计算区域级全部
  109. calCp(qb,qbls);
  110. //计算公司级风电场站
  111. calCp(fd,fdls);
  112. //计算公司级光电场站
  113. calCp(gf,gfls);
  114. proEconPowerstationInfoDay1Service.save(qb);
  115. proEconPowerstationInfoDay1Service.save(fd);
  116. proEconPowerstationInfoDay1Service.save(gf);
  117. }
  118. // }else
  119. // {
  120. // logger.debug("公司所属场站数量与保存的场站日信息数量不一致,未进行{0}统计-------结束", entry.getKey());
  121. //
  122. // }
  123. };
  124. }
  125. }
  126. /**
  127. * 计算公司日信息
  128. * @param recordDate
  129. * @throws Exception
  130. */
  131. public void calCompanyInfoDay(Date recordDate) throws Exception {
  132. List<ProEconPowerstationInfoDay1> wpinfodayls = proEconPowerstationInfoDay1Service.list().stream()
  133. .filter(i -> i.getRecordDate().compareTo(DateUtils.truncDay(recordDate))==0
  134. // && CacheContext.wpmap.containsKey(i.getWindpowerstationId())
  135. && i.getLocation().equals(Location.wp.getValue()))
  136. .collect(Collectors.toList());
  137. if(!wpinfodayls.isEmpty())
  138. {
  139. Map<String, Map<String, List<ProEconPowerstationInfoDay1>>>cpmap=new HashMap<>();
  140. for(ProEconPowerstationInfoDay1 wpinfo:wpinfodayls)
  141. {
  142. if(cpmap.containsKey(wpinfo.getCompanyId()))
  143. {
  144. Map<String, List<ProEconPowerstationInfoDay1>> map=cpmap.get(wpinfo.getCompanyId());
  145. List<ProEconPowerstationInfoDay1> qbls=map.get("qb");
  146. List<ProEconPowerstationInfoDay1> gfls=map.get("fd");
  147. List<ProEconPowerstationInfoDay1> fdls=map.get("gf");
  148. if(wpinfo.getWindpowerstationId().contains("FDC"))
  149. {
  150. fdls.add(wpinfo);
  151. }else {
  152. gfls.add(wpinfo);
  153. }
  154. qbls.add(wpinfo);
  155. }else
  156. {
  157. Map<String, List<ProEconPowerstationInfoDay1>> map=new HashMap<>();
  158. List<ProEconPowerstationInfoDay1> qbls=new ArrayList<>();
  159. List<ProEconPowerstationInfoDay1> gfls=new ArrayList<>();
  160. List<ProEconPowerstationInfoDay1> fdls=new ArrayList<>();
  161. if(wpinfo.getWindpowerstationId().contains("FDC"))
  162. {
  163. fdls.add(wpinfo);
  164. }else {
  165. gfls.add(wpinfo);
  166. }
  167. qbls.add(wpinfo);
  168. map.put("qb",qbls);
  169. map.put("fd",fdls);
  170. map.put("gf",gfls);
  171. }
  172. }
  173. //判断是否有重复记录,先删除重复记录
  174. List<String> idls = proEconPowerstationInfoDay1Service.list().stream()
  175. .filter(i -> i.getRecordDate().compareTo(DateUtils.truncDay(recordDate))==0
  176. // && CacheContext.wpmap.containsKey(i.getWindpowerstationId())
  177. && i.getLocation().equals(Location.cp.getValue())).map(ProEconPowerstationInfoDay1::getId)
  178. .collect(Collectors.toList());
  179. if (idls != null && idls.size() > 0) {
  180. proEconPowerstationInfoDay1Service.removeByIds(idls);
  181. }
  182. for(Map.Entry<String, Map<String, List<ProEconPowerstationInfoDay1>>> entry:cpmap.entrySet()){
  183. Map<String, List<ProEconPowerstationInfoDay1>> map=entry.getValue();
  184. List<ProEconPowerstationInfoDay1> qbls=map.get("qb");
  185. List<ProEconPowerstationInfoDay1> gfls=map.get("fd");
  186. List<ProEconPowerstationInfoDay1> fdls=map.get("gf");
  187. // if(CacheContext.cpwpmap.size()==qbls.size())
  188. // {
  189. ProEconPowerstationInfoDay1 qb=new ProEconPowerstationInfoDay1();
  190. ProEconPowerstationInfoDay1 fd=new ProEconPowerstationInfoDay1();
  191. ProEconPowerstationInfoDay1 gf=new ProEconPowerstationInfoDay1();
  192. if(CacheContext.cpmap.containsKey(entry.getKey()))
  193. {
  194. ProBasicCompany cp=CacheContext.cpmap.get(entry.getKey());
  195. gf.setRegionId(cp.getRegionId());
  196. gf.setCompanyId(cp.getId());
  197. gf.setRecordDate(DateUtils.truncDay(recordDate));
  198. gf.setForeignKeyId("-2");
  199. gf.setLocation(Location.cp.getValue());
  200. fd.setRegionId(cp.getRegionId());
  201. fd.setCompanyId(cp.getId());
  202. fd.setRecordDate(DateUtils.truncDay(recordDate));
  203. fd.setForeignKeyId("-1");
  204. fd.setLocation(Location.cp.getValue());
  205. qb.setRegionId(cp.getRegionId());
  206. qb.setCompanyId(cp.getId());
  207. qb.setRecordDate(DateUtils.truncDay(recordDate));
  208. qb.setForeignKeyId("0");
  209. qb.setLocation(Location.cp.getValue());
  210. //计算公司级全部场站
  211. calCp(qb,qbls);
  212. //计算公司级风电场站
  213. calCp(fd,fdls);
  214. //计算公司级光电场站
  215. calCp(gf,gfls);
  216. proEconPowerstationInfoDay1Service.save(qb);
  217. proEconPowerstationInfoDay1Service.save(fd);
  218. proEconPowerstationInfoDay1Service.save(gf);
  219. }
  220. // }else
  221. // {
  222. // logger.debug("公司所属场站数量与保存的场站日信息数量不一致,未进行{0}统计-------结束", entry.getKey());
  223. //
  224. // }
  225. };
  226. }
  227. }
  228. private void calCp(ProEconPowerstationInfoDay1 pewp,List<ProEconPowerstationInfoDay1> ls) throws Exception {
  229. if(!ls.isEmpty())
  230. {
  231. // DoubleSummaryStatistics summaryStatistics=ls.stream().mapToDouble(n -> n.getRzdfs()).summaryStatistics();
  232. // //日最大风速
  233. // pewp.setRzdfs(summaryStatistics.getMax());
  234. // //日最小风速
  235. // summaryStatistics=ls.stream().mapToDouble(n -> n.getRzxfs()).summaryStatistics();
  236. // pewp.setRzxfs(summaryStatistics.getMin());
  237. // //日平均风速
  238. // summaryStatistics=ls.stream().mapToDouble(n -> n.getRpjfs()).summaryStatistics();
  239. // pewp.setRpjfs(summaryStatistics.getAverage());
  240. //
  241. // summaryStatistics=ls.stream().mapToDouble(n -> n.getRzdgl()).summaryStatistics();
  242. // //日最大功率
  243. // pewp.setRzdgl(summaryStatistics.getMax());
  244. // //日最小功率
  245. // summaryStatistics=ls.stream().mapToDouble(n -> n.getRzxgl()).summaryStatistics();
  246. // pewp.setRzxgl(summaryStatistics.getMin());
  247. // //日平均功率
  248. // summaryStatistics=ls.stream().mapToDouble(n -> n.getRpjgl()).summaryStatistics();
  249. // pewp.setRpjgl(summaryStatistics.getAverage());
  250. //日发电量
  251. DoubleSummaryStatistics summaryStatistics=ls.stream().mapToDouble(n -> n.getRfdl()).summaryStatistics();
  252. pewp.setRfdl(StringUtils.round(summaryStatistics.getSum(),2));
  253. //日可用电量
  254. summaryStatistics=ls.stream().mapToDouble(n -> n.getRkydl()).summaryStatistics();
  255. pewp.setRkydl(StringUtils.round(summaryStatistics.getSum(),2));
  256. //日理论发电量
  257. summaryStatistics=ls.stream().mapToDouble(n -> n.getRllfdl()).summaryStatistics();
  258. pewp.setRllfdl(StringUtils.round(summaryStatistics.getSum(),2));
  259. //日故障损失电量
  260. summaryStatistics=ls.stream().mapToDouble(n -> n.getRgzssdl()).summaryStatistics();
  261. pewp.setRgzssdl(StringUtils.round(summaryStatistics.getSum(),2));
  262. //日场内受累故障损失电量
  263. pewp.setRcnslgzssdl(StringUtils.round(summaryStatistics.getSum(),2));
  264. //日检修损失电量
  265. summaryStatistics=ls.stream().mapToDouble(n -> n.getRjxssdl()).summaryStatistics();
  266. pewp.setRjxssdl(StringUtils.round(summaryStatistics.getSum(),2));
  267. //日场内受累检修损失电量
  268. summaryStatistics=ls.stream().mapToDouble(n -> n.getRcnsljxssdl()).summaryStatistics();
  269. pewp.setRcnsljxssdl(StringUtils.round(summaryStatistics.getSum(),2));
  270. //日待机损失电量
  271. summaryStatistics=ls.stream().mapToDouble(n -> n.getRdjssdl()).summaryStatistics();
  272. pewp.setRdjssdl(StringUtils.round(summaryStatistics.getSum(),2));
  273. //日缺陷降出力损失电量
  274. summaryStatistics=ls.stream().mapToDouble(n -> n.getRqxjclssdl()).summaryStatistics();
  275. pewp.setRqxjclssdl(StringUtils.round(summaryStatistics.getSum(),2));
  276. //日手动停机损失电量
  277. summaryStatistics=ls.stream().mapToDouble(n -> n.getRsdtjssdl()).summaryStatistics();
  278. pewp.setRsdtjssdl(StringUtils.round(summaryStatistics.getSum(),2));
  279. //日性能损失电量
  280. summaryStatistics=ls.stream().mapToDouble(n -> n.getRxnssdl()).summaryStatistics();
  281. pewp.setRxnssdl(StringUtils.round(summaryStatistics.getSum(),2));
  282. //日限电停机损失电量
  283. summaryStatistics=ls.stream().mapToDouble(n -> n.getRxdtjssdl()).summaryStatistics();
  284. pewp.setRxdtjssdl(StringUtils.round(summaryStatistics.getSum(),2));
  285. //日限电降出力损失电量
  286. summaryStatistics=ls.stream().mapToDouble(n -> n.getRxdjclssdl()).summaryStatistics();
  287. pewp.setRxdjclssdl(StringUtils.round(summaryStatistics.getSum(),2));
  288. //日场外受累电网损失电量
  289. summaryStatistics=ls.stream().mapToDouble(n -> n.getRcwsldwssdl()).summaryStatistics();
  290. pewp.setRcwsldwssdl(StringUtils.round(summaryStatistics.getSum(),2));
  291. //日场外受累天气损失电量
  292. summaryStatistics=ls.stream().mapToDouble(n -> n.getRcwsltqssdl()).summaryStatistics();
  293. pewp.setRcwsltqssdl(StringUtils.round(summaryStatistics.getSum(),2));
  294. //日增发电量
  295. summaryStatistics=ls.stream().mapToDouble(n -> n.getRzfdl()).summaryStatistics();
  296. pewp.setRzfdl(StringUtils.round(summaryStatistics.getSum(),2));
  297. //日欠发电量
  298. summaryStatistics=ls.stream().mapToDouble(n -> n.getRqfdl()).summaryStatistics();
  299. pewp.setRqfdl(StringUtils.round(summaryStatistics.getSum(),2));
  300. //日自耗电
  301. summaryStatistics=ls.stream().mapToDouble(n -> n.getRzhd()).summaryStatistics();
  302. pewp.setRzhd(StringUtils.round(summaryStatistics.getSum(),2));
  303. }
  304. }
  305. /**
  306. * 计算场站日信息
  307. * @param recordDate
  308. * @throws Exception
  309. */
  310. public void calWindpowerInfoDay(Date recordDate) throws Exception {
  311. Calendar c=Calendar.getInstance();
  312. c.setTime(recordDate);
  313. Date end=c.getTime();
  314. Date begin= DateUtils.truncDay(c.getTime());
  315. List<ProEconPowerstationInfoDay1> wpinfodayls=new ArrayList<>();
  316. //判断是否有重复记录,先删除重复记录
  317. List<String> idls = proEconPowerstationInfoDay1Service.list().stream()
  318. .filter(i -> i.getRecordDate().compareTo(DateUtils.truncDay(recordDate))==0
  319. && CacheContext.wpmap.containsKey(i.getWindpowerstationId())
  320. && i.getLocation().equals(Location.wp.getValue())).map(ProEconPowerstationInfoDay1::getId)
  321. .collect(Collectors.toList());
  322. if (idls != null && idls.size() > 0) {
  323. proEconPowerstationInfoDay1Service.removeByIds(idls);
  324. }
  325. for(ProBasicWindpowerstation wp:CacheContext.wpls)
  326. {
  327. if(CacheContext.wppointmap.containsKey(wp.getId()))
  328. {
  329. Map<String, ProBasicWppoint> pointmap=CacheContext.wppointmap.get(wp.getId());
  330. ProEconPowerstationInfoDay1 pewp=new ProEconPowerstationInfoDay1();
  331. Initial.initial(pewp);
  332. pewp.setRegionId(wp.getRegionId());
  333. pewp.setCompanyId(wp.getCompanyId());
  334. pewp.setRecordDate(DateUtils.truncDay(recordDate));
  335. pewp.setForeignKeyId("0");
  336. pewp.setWindpowerstationId(wp.getId());
  337. pewp.setLocation(Location.wp.getValue());
  338. //昨日的统计结果
  339. List<ProEconPowerstationInfoDay1> pepid1ls =new ArrayList<>();
  340. Calendar cl=Calendar.getInstance();
  341. cl.setTime(recordDate);
  342. if(cl.get(Calendar.DAY_OF_MONTH)!=1)
  343. {
  344. pepid1ls = proEconPowerstationInfoDay1Service.list().stream()
  345. .filter(i -> i.getRecordDate().compareTo(DateUtils.truncDay(cl.getTime())) == 0
  346. && i.getWindpowerstationId().equals(wp.getId())
  347. && i.getLocation().equals(Location.wp.getValue()))
  348. .collect(Collectors.toList());
  349. }
  350. extracted(recordDate, end, begin, pointmap, pewp,pepid1ls);
  351. /*******************************************年信息统计*********************************************************/
  352. // wpinfodayls.add(pewp);
  353. proEconPowerstationInfoDay1Service.save(pewp);
  354. }
  355. }
  356. }
  357. /**
  358. * 计算项目日信息
  359. * @param recordDate
  360. * @throws Exception
  361. */
  362. public void calProjectInfoDay(Date recordDate) throws Exception {
  363. Calendar c=Calendar.getInstance();
  364. c.setTime(recordDate);
  365. Date end=c.getTime();
  366. Date begin= DateUtils.truncDay(c.getTime());
  367. //判断是否有重复记录,先删除重复记录
  368. List<String> idls = proEconPowerstationInfoDay1Service.list().stream()
  369. .filter(i -> i.getRecordDate().compareTo(DateUtils.truncDay(recordDate))==0
  370. && CacheContext.pjmap.containsKey(i.getProjectId())
  371. && i.getLocation().equals(Location.pj.getValue())).map(ProEconPowerstationInfoDay1::getId)
  372. .collect(Collectors.toList());
  373. if (idls != null && idls.size() > 0) {
  374. proEconPowerstationInfoDay1Service.removeByIds(idls);
  375. }
  376. for(ProBasicProject pj:CacheContext.pjls)
  377. {
  378. if(CacheContext.wppointmap.containsKey(pj.getId()))
  379. {
  380. Map<String, ProBasicWppoint> pointmap=CacheContext.wppointmap.get(pj.getId());
  381. ProEconPowerstationInfoDay1 pewp=new ProEconPowerstationInfoDay1();
  382. Initial.initial(pewp);
  383. pewp.setForeignKeyId("0");
  384. pewp.setWindpowerstationId(pj.getWindpowerstationId());
  385. pewp.setProjectId(pj.getId());
  386. pewp.setLocation(Location.pj.getValue());
  387. pewp.setRecordDate(DateUtils.truncDay(recordDate));
  388. //昨日的统计结果
  389. List<ProEconPowerstationInfoDay1> pepid1ls =new ArrayList<>();
  390. Calendar cl=Calendar.getInstance();
  391. cl.setTime(recordDate);
  392. if(cl.get(Calendar.DAY_OF_MONTH)!=1)
  393. {
  394. pepid1ls = proEconPowerstationInfoDay1Service.list().stream()
  395. .filter(i -> i.getRecordDate().compareTo(DateUtils.truncDay(cl.getTime())) == 0
  396. && i.getProjectId().equals(pj.getId())
  397. && i.getLocation().equals(Location.pj.getValue()))
  398. .collect(Collectors.toList());
  399. }
  400. extracted(recordDate, end, begin, pointmap, pewp,pepid1ls);
  401. proEconPowerstationInfoDay1Service.save(pewp);
  402. }
  403. }
  404. }
  405. /**
  406. * 计算线路日信息
  407. * @param recordDate
  408. * @throws Exception
  409. */
  410. public void calLineInfoDay(Date recordDate) throws Exception {
  411. Calendar c=Calendar.getInstance();
  412. c.setTime(recordDate);
  413. Date end=c.getTime();
  414. Date begin= DateUtils.truncDay(c.getTime());
  415. //判断是否有重复记录,先删除重复记录
  416. List<String> idls = proEconPowerstationInfoDay1Service.list().stream()
  417. .filter(i -> i.getRecordDate().compareTo(DateUtils.truncDay(recordDate))==0
  418. && CacheContext.lnmap.containsKey(i.getLineId())
  419. && i.getLocation().equals(Location.ln.getValue()) ).map(ProEconPowerstationInfoDay1::getId)
  420. .collect(Collectors.toList());
  421. if (idls != null && idls.size() > 0) {
  422. proEconPowerstationInfoDay1Service.removeByIds(idls);
  423. }
  424. for(ProBasicLine ln:CacheContext.lnls)
  425. {
  426. if(CacheContext.wppointmap.containsKey(ln.getId()))
  427. {
  428. Map<String, ProBasicWppoint> pointmap=CacheContext.wppointmap.get(ln.getId());
  429. ProEconPowerstationInfoDay1 pewp=new ProEconPowerstationInfoDay1();
  430. Initial.initial(pewp);
  431. pewp.setForeignKeyId("0");
  432. pewp.setLineId(ln.getId());
  433. pewp.setLocation(Location.ln.getValue());
  434. pewp.setProjectId(ln.getProjectId());
  435. pewp.setRecordDate(DateUtils.truncDay(recordDate));
  436. //昨日的统计结果
  437. List<ProEconPowerstationInfoDay1> pepid1ls =new ArrayList<>();
  438. Calendar cl=Calendar.getInstance();
  439. cl.setTime(recordDate);
  440. if(cl.get(Calendar.DAY_OF_MONTH)!=1)
  441. {
  442. pepid1ls = proEconPowerstationInfoDay1Service.list().stream()
  443. .filter(i -> i.getRecordDate().compareTo(DateUtils.truncDay(cl.getTime())) == 0
  444. && i.getLineId().equals(ln.getId())
  445. && i.getLocation().equals(Location.ln.getValue()))
  446. .collect(Collectors.toList());
  447. }
  448. extracted(recordDate, end, begin, pointmap, pewp,pepid1ls);
  449. proEconPowerstationInfoDay1Service.save(pewp);
  450. }
  451. }
  452. }
  453. private void extracted(Date recordDate, Date end, Date begin,Map<String, ProBasicWppoint> pointmap, ProEconPowerstationInfoDay1 pewp,List<ProEconPowerstationInfoDay1> pepid1ls) throws Exception {
  454. /*******************************************日信息统计*********************************************************/
  455. if(pointmap.containsKey(ContantXk.SSPJFS))
  456. {
  457. ProBasicWppoint point= pointmap.get(ContantXk.SSPJFS);
  458. List<PointData> pointls=edosUtil.getHistoryDatasSnap(point.getNemCode(), begin.getTime()/1000, end.getTime()/1000);
  459. if(!pointls.isEmpty())
  460. {
  461. DoubleSummaryStatistics summaryStatistics=pointls.stream().mapToDouble(n -> n.getPointValueInDouble()).summaryStatistics();
  462. //日最大风速
  463. pewp.setRzdfs(summaryStatistics.getMax());
  464. //日最小风速
  465. pewp.setRzxfs(summaryStatistics.getMin());
  466. //日平均风速
  467. pewp.setRpjfs(summaryStatistics.getAverage());
  468. }
  469. }
  470. if(pointmap.containsKey(ContantXk.SSZGL))
  471. {
  472. ProBasicWppoint point= pointmap.get(ContantXk.SSZGL);
  473. List<PointData> pointls=edosUtil.getHistoryDatasSnap(point.getNemCode(), begin.getTime()/1000, end.getTime()/1000);
  474. if(!pointls.isEmpty())
  475. {
  476. DoubleSummaryStatistics summaryStatistics=pointls.stream().mapToDouble(n -> n.getPointValueInDouble()).summaryStatistics();
  477. //日最大功率
  478. pewp.setRzdgl(summaryStatistics.getMax());
  479. //日最小功率
  480. pewp.setRzxgl(summaryStatistics.getMin());
  481. //日平均功率
  482. pewp.setRpjgl(summaryStatistics.getAverage());
  483. }
  484. }
  485. if(pointmap.containsKey(ContantXk.RFDL))
  486. {
  487. ProBasicWppoint point= pointmap.get(ContantXk.RFDL);
  488. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  489. if(StringUtils.notEmp(pointValue))
  490. {
  491. //日发电量
  492. pewp.setRfdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  493. }
  494. }
  495. if(pointmap.containsKey(ContantXk.RKYDL))
  496. {
  497. ProBasicWppoint point= pointmap.get(ContantXk.RKYDL);
  498. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  499. if(StringUtils.notEmp(pointValue))
  500. {
  501. //日可用电量
  502. pewp.setRkydl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  503. }
  504. }
  505. if(pointmap.containsKey(ContantXk.RLLFDL))
  506. {
  507. ProBasicWppoint point= pointmap.get(ContantXk.RLLFDL);
  508. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  509. if(StringUtils.notEmp(pointValue))
  510. {
  511. //日理论发电量
  512. pewp.setRllfdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  513. }
  514. }
  515. if(pointmap.containsKey(ContantXk.RGZSSDL))
  516. {
  517. ProBasicWppoint point= pointmap.get(ContantXk.RGZSSDL);
  518. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  519. if(StringUtils.notEmp(pointValue))
  520. {
  521. //日故障损失电量
  522. pewp.setRgzssdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  523. }
  524. }
  525. if(pointmap.containsKey(ContantXk.RCNSLGZSSDL))
  526. {
  527. ProBasicWppoint point= pointmap.get(ContantXk.RCNSLGZSSDL);
  528. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  529. if(StringUtils.notEmp(pointValue))
  530. {
  531. //日场内受累故障损失电量
  532. pewp.setRcnslgzssdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  533. }
  534. }
  535. if(pointmap.containsKey(ContantXk.RJXSSDL))
  536. {
  537. ProBasicWppoint point= pointmap.get(ContantXk.RJXSSDL);
  538. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  539. if(StringUtils.notEmp(pointValue))
  540. {
  541. //日检修损失电量
  542. pewp.setRjxssdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  543. }
  544. }
  545. if(pointmap.containsKey(ContantXk.RCNSLJXSSDL))
  546. {
  547. ProBasicWppoint point= pointmap.get(ContantXk.RCNSLJXSSDL);
  548. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  549. if(StringUtils.notEmp(pointValue))
  550. {
  551. //日场内受累检修损失电量
  552. pewp.setRcnsljxssdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  553. }
  554. }
  555. if(pointmap.containsKey(ContantXk.RDJSSDL))
  556. {
  557. ProBasicWppoint point= pointmap.get(ContantXk.RDJSSDL);
  558. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  559. if(StringUtils.notEmp(pointValue))
  560. {
  561. //日待机损失电量
  562. pewp.setRdjssdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  563. }
  564. }
  565. if(pointmap.containsKey(ContantXk.RQXJCLSSDL))
  566. {
  567. ProBasicWppoint point= pointmap.get(ContantXk.RQXJCLSSDL);
  568. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  569. if(StringUtils.notEmp(pointValue))
  570. {
  571. //日缺陷降出力损失电量
  572. pewp.setRqxjclssdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  573. }
  574. }
  575. if(pointmap.containsKey(ContantXk.RSDTJSSDL))
  576. {
  577. ProBasicWppoint point= pointmap.get(ContantXk.RSDTJSSDL);
  578. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  579. if(StringUtils.notEmp(pointValue))
  580. {
  581. //日手动停机损失电量
  582. pewp.setRsdtjssdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  583. }
  584. }
  585. if(pointmap.containsKey(ContantXk.RXNSSDL))
  586. {
  587. ProBasicWppoint point= pointmap.get(ContantXk.RXNSSDL);
  588. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  589. if(StringUtils.notEmp(pointValue))
  590. {
  591. //日性能损失电量
  592. pewp.setRxnssdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  593. }
  594. }
  595. if(pointmap.containsKey(ContantXk.RXDTJSSDL))
  596. {
  597. ProBasicWppoint point= pointmap.get(ContantXk.RXDTJSSDL);
  598. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  599. if(StringUtils.notEmp(pointValue))
  600. {
  601. //日限电停机损失电量
  602. pewp.setRxdtjssdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  603. }
  604. }
  605. if(pointmap.containsKey(ContantXk.RXDJCLSSDL))
  606. {
  607. ProBasicWppoint point= pointmap.get(ContantXk.RXDJCLSSDL);
  608. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  609. if(StringUtils.notEmp(pointValue))
  610. {
  611. //日限电降出力损失电量
  612. pewp.setRxdjclssdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  613. }
  614. }
  615. if(pointmap.containsKey(ContantXk.RCWSLDWSSDL))
  616. {
  617. ProBasicWppoint point= pointmap.get(ContantXk.RCWSLDWSSDL);
  618. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  619. if(StringUtils.notEmp(pointValue))
  620. {
  621. //日场外受累电网损失电量
  622. pewp.setRcwsldwssdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  623. }
  624. }
  625. if(pointmap.containsKey(ContantXk.RCWSLTQSSDL))
  626. {
  627. ProBasicWppoint point= pointmap.get(ContantXk.RCWSLTQSSDL);
  628. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  629. if(StringUtils.notEmp(pointValue))
  630. {
  631. //日场外受累天气损失电量
  632. pewp.setRcwsltqssdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  633. }
  634. }
  635. if(pointmap.containsKey(ContantXk.RZFDL))
  636. {
  637. ProBasicWppoint point= pointmap.get(ContantXk.RZFDL);
  638. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  639. if(StringUtils.notEmp(pointValue))
  640. {
  641. //日增发电量
  642. pewp.setRzfdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  643. }
  644. }
  645. if(pointmap.containsKey(ContantXk.RQFDL))
  646. {
  647. ProBasicWppoint point= pointmap.get(ContantXk.RQFDL);
  648. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  649. if(StringUtils.notEmp(pointValue))
  650. {
  651. //日欠发电量
  652. pewp.setRqfdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  653. }
  654. }
  655. if(pointmap.containsKey(ContantXk.RZHD))
  656. {
  657. ProBasicWppoint point= pointmap.get(ContantXk.RZHD);
  658. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  659. if(StringUtils.notEmp(pointValue))
  660. {
  661. //日自耗电
  662. pewp.setRzhd(StringUtils.round(pointValue.getPointValueInDouble(),2));
  663. }
  664. }
  665. /*******************************************日信息统计*********************************************************/
  666. /*******************************************月信息统计*********************************************************/
  667. if(pepid1ls.isEmpty())
  668. {
  669. setPowerandSpeedMonth(end, begin, pointmap, pewp);
  670. }else
  671. {
  672. if(!pepid1ls.isEmpty())
  673. {
  674. ProEconPowerstationInfoDay1 pepid=pepid1ls.get(0);
  675. //如果昨日大于今日最大功率
  676. if(pepid.getYzdgl()> pewp.getRzdgl())
  677. {
  678. pewp.setYzdgl(pepid.getRzdgl());
  679. }else {
  680. pewp.setYzdgl(pewp.getRzdgl());
  681. }
  682. //如果昨日大于今日最大风速
  683. if(pepid.getYzdfs()> pewp.getRzdfs())
  684. {
  685. pewp.setYzdfs(pepid.getRzdfs());
  686. }else
  687. {
  688. pewp.setYzdfs(pewp.getRzdfs());
  689. }
  690. //如果昨日小于今日最小功率
  691. if(pepid.getYzxgl()< pewp.getRzxgl())
  692. {
  693. pewp.setYzxgl(pepid.getRzxgl());
  694. }else
  695. {
  696. pewp.setYzxgl(pewp.getRzxgl());
  697. }
  698. //如果昨日小于今日最小风速
  699. if(pepid.getYzxfs()< pewp.getRzxfs())
  700. {
  701. pewp.setYzxfs(pepid.getRzxfs());
  702. }else
  703. {
  704. pewp.setYzxfs(pewp.getRzxfs());
  705. }
  706. double pjfs = new BigDecimal(pewp.getYpjfs()+pepid.getRpjfs()).divide(new BigDecimal(2), 4, RoundingMode.HALF_EVEN).doubleValue();
  707. pewp.setYzxfs(pjfs);
  708. double pjgl = new BigDecimal(pewp.getYpjgl()+pepid.getRpjgl()).divide(new BigDecimal(2), 4, RoundingMode.HALF_EVEN).doubleValue();
  709. pewp.setYzxgl(pjgl);
  710. }else
  711. {
  712. setPowerandSpeedMonth(end, begin, pointmap, pewp);
  713. }
  714. }
  715. if(pointmap.containsKey(ContantXk.YFDL))
  716. {
  717. ProBasicWppoint point= pointmap.get(ContantXk.YFDL);
  718. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  719. if(StringUtils.notEmp(pointValue))
  720. {
  721. //月发电量
  722. pewp.setYfdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  723. }
  724. }
  725. if(pointmap.containsKey(ContantXk.YKYDL))
  726. {
  727. ProBasicWppoint point= pointmap.get(ContantXk.YKYDL);
  728. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  729. if(StringUtils.notEmp(pointValue))
  730. {
  731. //月可用电量
  732. pewp.setYkydl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  733. }
  734. }
  735. if(pointmap.containsKey(ContantXk.YLLFDL))
  736. {
  737. ProBasicWppoint point= pointmap.get(ContantXk.YLLFDL);
  738. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  739. if(StringUtils.notEmp(pointValue))
  740. {
  741. //月理论发电量
  742. pewp.setYllfdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  743. }
  744. }
  745. if(pointmap.containsKey(ContantXk.YGZSSDL))
  746. {
  747. ProBasicWppoint point= pointmap.get(ContantXk.YGZSSDL);
  748. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  749. if(StringUtils.notEmp(pointValue))
  750. {
  751. //月故障损失电量
  752. pewp.setYgzssdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  753. }
  754. }
  755. if(pointmap.containsKey(ContantXk.YCNSLGZSSDL))
  756. {
  757. ProBasicWppoint point= pointmap.get(ContantXk.YCNSLGZSSDL);
  758. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  759. if(StringUtils.notEmp(pointValue))
  760. {
  761. //月场内受累故障损失电量
  762. pewp.setYcnslgzssdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  763. }
  764. }
  765. if(pointmap.containsKey(ContantXk.YJXSSDL))
  766. {
  767. ProBasicWppoint point= pointmap.get(ContantXk.YJXSSDL);
  768. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  769. if(StringUtils.notEmp(pointValue))
  770. {
  771. //月检修损失电量
  772. pewp.setYjxssdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  773. }
  774. }
  775. if(pointmap.containsKey(ContantXk.YCNSLJXSSDL))
  776. {
  777. ProBasicWppoint point= pointmap.get(ContantXk.YCNSLJXSSDL);
  778. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  779. if(StringUtils.notEmp(pointValue))
  780. {
  781. //月场内受累检修损失电量
  782. pewp.setYcnsljxssdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  783. }
  784. }
  785. if(pointmap.containsKey(ContantXk.YDJSSDL))
  786. {
  787. ProBasicWppoint point= pointmap.get(ContantXk.YDJSSDL);
  788. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  789. if(StringUtils.notEmp(pointValue))
  790. {
  791. //月待机损失电量
  792. pewp.setYdjssdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  793. }
  794. }
  795. if(pointmap.containsKey(ContantXk.YQXJCLSSDL))
  796. {
  797. ProBasicWppoint point= pointmap.get(ContantXk.YQXJCLSSDL);
  798. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  799. if(StringUtils.notEmp(pointValue))
  800. {
  801. //月缺陷降出力损失电量
  802. pewp.setYqxjclssdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  803. }
  804. }
  805. if(pointmap.containsKey(ContantXk.YSDTJSSDL))
  806. {
  807. ProBasicWppoint point= pointmap.get(ContantXk.YSDTJSSDL);
  808. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  809. if(StringUtils.notEmp(pointValue))
  810. {
  811. //月手动停机损失电量
  812. pewp.setYsdtjssdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  813. }
  814. }
  815. if(pointmap.containsKey(ContantXk.YXNSSDL))
  816. {
  817. ProBasicWppoint point= pointmap.get(ContantXk.YXNSSDL);
  818. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  819. if(StringUtils.notEmp(pointValue))
  820. {
  821. //月性能损失电量
  822. pewp.setYxnssdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  823. }
  824. }
  825. if(pointmap.containsKey(ContantXk.YXDTJSSDL))
  826. {
  827. ProBasicWppoint point= pointmap.get(ContantXk.YXDTJSSDL);
  828. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  829. if(StringUtils.notEmp(pointValue))
  830. {
  831. //月限电停机损失电量
  832. pewp.setYxdtjssdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  833. }
  834. }
  835. if(pointmap.containsKey(ContantXk.YXDJCLSSDL))
  836. {
  837. ProBasicWppoint point= pointmap.get(ContantXk.YXDJCLSSDL);
  838. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  839. if(StringUtils.notEmp(pointValue))
  840. {
  841. //月限电降出力损失电量
  842. pewp.setYxdjclssdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  843. }
  844. }
  845. if(pointmap.containsKey(ContantXk.YCWSLDWSSDL))
  846. {
  847. ProBasicWppoint point= pointmap.get(ContantXk.YCWSLDWSSDL);
  848. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  849. if(StringUtils.notEmp(pointValue))
  850. {
  851. //月场外受累电网损失电量
  852. pewp.setYcwsldwssdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  853. }
  854. }
  855. if(pointmap.containsKey(ContantXk.YCWSLTQSSDL))
  856. {
  857. ProBasicWppoint point= pointmap.get(ContantXk.YCWSLTQSSDL);
  858. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  859. if(StringUtils.notEmp(pointValue))
  860. {
  861. //月场外受累天气损失电量
  862. pewp.setYcwsltqssdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  863. }
  864. }
  865. if(pointmap.containsKey(ContantXk.YZFDL))
  866. {
  867. ProBasicWppoint point= pointmap.get(ContantXk.YZFDL);
  868. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  869. if(StringUtils.notEmp(pointValue))
  870. {
  871. //月增发电量
  872. pewp.setYzfdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  873. }
  874. }
  875. if(pointmap.containsKey(ContantXk.YQFDL))
  876. {
  877. ProBasicWppoint point= pointmap.get(ContantXk.YQFDL);
  878. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  879. if(StringUtils.notEmp(pointValue))
  880. {
  881. //月欠发电量
  882. pewp.setYqfdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  883. }
  884. }
  885. if(pointmap.containsKey(ContantXk.YZHD))
  886. {
  887. ProBasicWppoint point= pointmap.get(ContantXk.YZHD);
  888. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  889. if(StringUtils.notEmp(pointValue))
  890. {
  891. //月自耗电
  892. pewp.setYzhd(StringUtils.round(pointValue.getPointValueInDouble(),2));
  893. }
  894. }
  895. /*******************************************月信息统计*********************************************************/
  896. /*******************************************年信息统计*********************************************************/
  897. if(pepid1ls.isEmpty())
  898. {
  899. setPowerandSpeedYear(end, begin, pointmap, pewp);
  900. }else
  901. {
  902. if(!pepid1ls.isEmpty())
  903. {
  904. ProEconPowerstationInfoDay1 pepid=pepid1ls.get(0);
  905. //如果昨日大于今日最大功率
  906. if(pepid.getNzdgl()> pewp.getRzdgl())
  907. {
  908. pewp.setNzdgl(pepid.getRzdgl());
  909. }else {
  910. pewp.setNzdgl(pewp.getRzdgl());
  911. }
  912. //如果昨日大于今日最大风速
  913. if(pepid.getNzdfs()> pewp.getRzdfs())
  914. {
  915. pewp.setNzdfs(pepid.getRzdfs());
  916. }else
  917. {
  918. pewp.setNzdfs(pewp.getRzdfs());
  919. }
  920. //如果昨日小于今日最小功率
  921. if(pepid.getNzxgl()< pewp.getRzxgl())
  922. {
  923. pewp.setNzxgl(pepid.getRzxgl());
  924. }else
  925. {
  926. pewp.setNzxgl(pewp.getRzxgl());
  927. }
  928. //如果昨日小于今日最小风速
  929. if(pepid.getNzxfs()< pewp.getRzxfs())
  930. {
  931. pewp.setNzxfs(pepid.getRzxfs());
  932. }else
  933. {
  934. pewp.setNzxfs(pewp.getRzxfs());
  935. }
  936. double pjfs = new BigDecimal(pewp.getNpjfs()+pepid.getRpjfs()).divide(new BigDecimal(2), 4, RoundingMode.HALF_EVEN).doubleValue();
  937. pewp.setNzxfs(pjfs);
  938. double pjgl = new BigDecimal(pewp.getNpjgl()+pepid.getRpjgl()).divide(new BigDecimal(2), 4, RoundingMode.HALF_EVEN).doubleValue();
  939. pewp.setNzxgl(pjgl);
  940. }else
  941. {
  942. setPowerandSpeedYear(end, begin, pointmap, pewp);
  943. }
  944. }
  945. if(pointmap.containsKey(ContantXk.NFDL))
  946. {
  947. ProBasicWppoint point= pointmap.get(ContantXk.NFDL);
  948. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  949. if(StringUtils.notEmp(pointValue))
  950. {
  951. //年发电量
  952. pewp.setNfdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  953. }
  954. }
  955. if(pointmap.containsKey(ContantXk.NKYDL))
  956. {
  957. ProBasicWppoint point= pointmap.get(ContantXk.NKYDL);
  958. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  959. if(StringUtils.notEmp(pointValue))
  960. {
  961. //年可用电量
  962. pewp.setNkydl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  963. }
  964. }
  965. if(pointmap.containsKey(ContantXk.NLLFDL))
  966. {
  967. ProBasicWppoint point= pointmap.get(ContantXk.NLLFDL);
  968. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  969. if(StringUtils.notEmp(pointValue))
  970. {
  971. //年理论发电量
  972. pewp.setNllfdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  973. }
  974. }
  975. if(pointmap.containsKey(ContantXk.NGZSSDL))
  976. {
  977. ProBasicWppoint point= pointmap.get(ContantXk.NGZSSDL);
  978. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  979. if(StringUtils.notEmp(pointValue))
  980. {
  981. //年故障损失电量
  982. pewp.setNgzssdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  983. }
  984. }
  985. if(pointmap.containsKey(ContantXk.NCNSLGZSSDL))
  986. {
  987. ProBasicWppoint point= pointmap.get(ContantXk.NCNSLGZSSDL);
  988. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  989. if(StringUtils.notEmp(pointValue))
  990. {
  991. //年场内受累故障损失电量
  992. pewp.setNcnslgzssdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  993. }
  994. }
  995. if(pointmap.containsKey(ContantXk.NJXSSDL))
  996. {
  997. ProBasicWppoint point= pointmap.get(ContantXk.NJXSSDL);
  998. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  999. if(StringUtils.notEmp(pointValue))
  1000. {
  1001. //年检修损失电量
  1002. pewp.setNjxssdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  1003. }
  1004. }
  1005. if(pointmap.containsKey(ContantXk.NCNSLJXSSDL))
  1006. {
  1007. ProBasicWppoint point= pointmap.get(ContantXk.NCNSLJXSSDL);
  1008. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  1009. if(StringUtils.notEmp(pointValue))
  1010. {
  1011. //年场内受累检修损失电量
  1012. pewp.setNcnsljxssdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  1013. }
  1014. }
  1015. if(pointmap.containsKey(ContantXk.NDJSSDL))
  1016. {
  1017. ProBasicWppoint point= pointmap.get(ContantXk.NDJSSDL);
  1018. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  1019. if(StringUtils.notEmp(pointValue))
  1020. {
  1021. //年待机损失电量
  1022. pewp.setNdjssdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  1023. }
  1024. }
  1025. if(pointmap.containsKey(ContantXk.NQXJCLSSDL))
  1026. {
  1027. ProBasicWppoint point= pointmap.get(ContantXk.NQXJCLSSDL);
  1028. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  1029. if(StringUtils.notEmp(pointValue))
  1030. {
  1031. //年缺陷降出力损失电量
  1032. pewp.setNqxjclssdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  1033. }
  1034. }
  1035. if(pointmap.containsKey(ContantXk.NSDTJSSDL))
  1036. {
  1037. ProBasicWppoint point= pointmap.get(ContantXk.NSDTJSSDL);
  1038. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  1039. if(StringUtils.notEmp(pointValue))
  1040. {
  1041. //年手动停机损失电量
  1042. pewp.setNsdtjssdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  1043. }
  1044. }
  1045. if(pointmap.containsKey(ContantXk.NXNSSDL))
  1046. {
  1047. ProBasicWppoint point= pointmap.get(ContantXk.NXNSSDL);
  1048. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  1049. if(StringUtils.notEmp(pointValue))
  1050. {
  1051. //年性能损失电量
  1052. pewp.setNxnssdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  1053. }
  1054. }
  1055. if(pointmap.containsKey(ContantXk.NXDTJSSDL))
  1056. {
  1057. ProBasicWppoint point= pointmap.get(ContantXk.NXDTJSSDL);
  1058. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  1059. if(StringUtils.notEmp(pointValue))
  1060. {
  1061. //年限电停机损失电量
  1062. pewp.setNxdtjssdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  1063. }
  1064. }
  1065. if(pointmap.containsKey(ContantXk.NXDJCLSSDL))
  1066. {
  1067. ProBasicWppoint point= pointmap.get(ContantXk.NXDJCLSSDL);
  1068. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  1069. if(StringUtils.notEmp(pointValue))
  1070. {
  1071. //年限电降出力损失电量
  1072. pewp.setNxdjclssdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  1073. }
  1074. }
  1075. if(pointmap.containsKey(ContantXk.NCWSLDWSSDL))
  1076. {
  1077. ProBasicWppoint point= pointmap.get(ContantXk.NCWSLDWSSDL);
  1078. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  1079. if(StringUtils.notEmp(pointValue))
  1080. {
  1081. //年场外受累电网损失电量
  1082. pewp.setNcwsldwssdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  1083. }
  1084. }
  1085. if(pointmap.containsKey(ContantXk.NCWSLTQSSDL))
  1086. {
  1087. ProBasicWppoint point= pointmap.get(ContantXk.NCWSLTQSSDL);
  1088. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  1089. if(StringUtils.notEmp(pointValue))
  1090. {
  1091. //年场外受累天气损失电量
  1092. pewp.setNcwsltqssdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  1093. }
  1094. }
  1095. if(pointmap.containsKey(ContantXk.NZFDL))
  1096. {
  1097. ProBasicWppoint point= pointmap.get(ContantXk.NZFDL);
  1098. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  1099. if(StringUtils.notEmp(pointValue))
  1100. {
  1101. //年增发电量
  1102. pewp.setNzfdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  1103. }
  1104. }
  1105. if(pointmap.containsKey(ContantXk.NQFDL))
  1106. {
  1107. ProBasicWppoint point= pointmap.get(ContantXk.NQFDL);
  1108. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  1109. if(StringUtils.notEmp(pointValue))
  1110. {
  1111. //年欠发电量
  1112. pewp.setNqfdl(StringUtils.round(pointValue.getPointValueInDouble(),2));
  1113. }
  1114. }
  1115. if(pointmap.containsKey(ContantXk.NZHD))
  1116. {
  1117. ProBasicWppoint point= pointmap.get(ContantXk.NZHD);
  1118. PointData pointValue=edosUtil.getHistMatrix(point.getNemCode(), recordDate.getTime()/1000);
  1119. if(StringUtils.notEmp(pointValue))
  1120. {
  1121. //年自耗电
  1122. pewp.setNzhd(StringUtils.round(pointValue.getPointValueInDouble(),2));
  1123. }
  1124. }
  1125. }
  1126. private void setPowerandSpeedYear(Date end, Date begin, Map<String, ProBasicWppoint> pointmap, ProEconPowerstationInfoDay1 pewp) throws Exception {
  1127. //年最大风速
  1128. pewp.setNzdfs(pewp.getRzdfs());
  1129. //年最小风速
  1130. pewp.setNzxfs(pewp.getRzxfs());
  1131. //年平均风速
  1132. pewp.setNpjfs(pewp.getRpjfs());
  1133. //年最大功率
  1134. pewp.setNzdgl(pewp.getRzdgl());
  1135. //年最小功率
  1136. pewp.setNzxgl(pewp.getRzxgl());
  1137. //年平均功率
  1138. pewp.setNpjgl(pewp.getRpjgl());
  1139. }
  1140. private void setPowerandSpeedMonth(Date end, Date begin, Map<String, ProBasicWppoint> pointmap, ProEconPowerstationInfoDay1 pewp) throws Exception {
  1141. //月最大风速
  1142. pewp.setYzdfs(pewp.getRzdfs());
  1143. //月最小风速
  1144. pewp.setYzxfs(pewp.getRzxfs());
  1145. //月平均风速
  1146. pewp.setYpjfs(pewp.getRpjfs());
  1147. //月最大功率
  1148. pewp.setYzdgl(pewp.getRzdgl());
  1149. //月最小功率
  1150. pewp.setYzxgl(pewp.getRzxgl());
  1151. //月平均功率
  1152. pewp.setYpjgl(pewp.getRpjgl());
  1153. }
  1154. }