WindPowerInfo2Service.java 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220
  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.IProEconPowerstationInfoDay2Service;
  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.springframework.stereotype.Service;
  13. import javax.annotation.Resource;
  14. import java.math.BigDecimal;
  15. import java.math.RoundingMode;
  16. import java.util.*;
  17. import java.util.stream.Collectors;
  18. @Service
  19. public class WindPowerInfo2Service {
  20. // private static final Logger logger = LoggerFactory.getLogger(WindPowerInfo2Service.class);
  21. @Resource
  22. private IEdosUtil edosUtil;
  23. @Resource
  24. private IProEconPowerstationInfoDay2Service proEconPowerstationInfoDay2Service;
  25. /**
  26. * 计算区域日信息
  27. */
  28. public void calRegionInfoDay(Date recordDate) {
  29. List<ProEconPowerstationInfoDay2> wpinfodayls = proEconPowerstationInfoDay2Service.list().stream()
  30. .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate))==0
  31. // && CacheContext.wpmap.containsKey(i.getWindpowerstationId())
  32. && i.getLocation().equals(Location.cp.getValue()))
  33. .collect(Collectors.toList());
  34. if(!wpinfodayls.isEmpty())
  35. {
  36. Map<String, Map<String, List<ProEconPowerstationInfoDay2>>>rgmap=new HashMap<>();
  37. for(ProEconPowerstationInfoDay2 wpinfo:wpinfodayls)
  38. {
  39. if(rgmap.containsKey(wpinfo.getRegionId()))
  40. {
  41. Map<String, List<ProEconPowerstationInfoDay2>> map=rgmap.get(wpinfo.getRegionId());
  42. List<ProEconPowerstationInfoDay2> qbls=map.get("qb");
  43. List<ProEconPowerstationInfoDay2> gfls=map.get("fd");
  44. List<ProEconPowerstationInfoDay2> fdls=map.get("gf");
  45. if(wpinfo.getForeignKeyId().equals("-1"))
  46. {
  47. fdls.add(wpinfo);
  48. }else if(wpinfo.getForeignKeyId().equals("-2")){
  49. gfls.add(wpinfo);
  50. }
  51. qbls.add(wpinfo);
  52. }else
  53. {
  54. Map<String, List<ProEconPowerstationInfoDay2>> map=new HashMap<>();
  55. List<ProEconPowerstationInfoDay2> qbls=new ArrayList<>();
  56. List<ProEconPowerstationInfoDay2> gfls=new ArrayList<>();
  57. List<ProEconPowerstationInfoDay2> fdls=new ArrayList<>();
  58. if(wpinfo.getForeignKeyId().equals("-1"))
  59. {
  60. fdls.add(wpinfo);
  61. }else if(wpinfo.getForeignKeyId().equals("-2")){
  62. gfls.add(wpinfo);
  63. }
  64. qbls.add(wpinfo);
  65. map.put("qb",qbls);
  66. map.put("fd",fdls);
  67. map.put("gf",gfls);
  68. rgmap.put(wpinfo.getRegionId(),map);
  69. }
  70. }
  71. //判断是否有重复记录,先删除重复记录
  72. List<String> idls = proEconPowerstationInfoDay2Service.list().stream()
  73. .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate))==0
  74. // && CacheContext.wpmap.containsKey(i.getWindpowerstationId())
  75. && i.getLocation().equals(Location.rg.getValue())).map(ProEconPowerstationInfoDay2::getId)
  76. .collect(Collectors.toList());
  77. if (idls.size() > 0) {
  78. proEconPowerstationInfoDay2Service.removeByIds(idls);
  79. }
  80. for(Map.Entry<String, Map<String, List<ProEconPowerstationInfoDay2>>> entry:rgmap.entrySet()){
  81. Map<String, List<ProEconPowerstationInfoDay2>> map=entry.getValue();
  82. List<ProEconPowerstationInfoDay2> qbls=map.get("qb");
  83. List<ProEconPowerstationInfoDay2> gfls=map.get("fd");
  84. List<ProEconPowerstationInfoDay2> fdls=map.get("gf");
  85. // if(CacheContext.cpwpmap.size()==qbls.size())
  86. // {
  87. ProEconPowerstationInfoDay2 qb=new ProEconPowerstationInfoDay2();
  88. ProEconPowerstationInfoDay2 fd=new ProEconPowerstationInfoDay2();
  89. ProEconPowerstationInfoDay2 gf=new ProEconPowerstationInfoDay2();
  90. if(CacheContext.rgmap.containsKey(entry.getKey()))
  91. {
  92. ProBasicRegion cp=CacheContext.rgmap.get(entry.getKey());
  93. gf.setRegionId(cp.getId());
  94. gf.setRecordDate(DateUtils.truncate(recordDate));
  95. gf.setForeignKeyId("-2");
  96. gf.setLocation(Location.rg.getValue());
  97. fd.setRegionId(cp.getId());
  98. fd.setRecordDate(DateUtils.truncate(recordDate));
  99. fd.setForeignKeyId("-1");
  100. fd.setLocation(Location.rg.getValue());
  101. qb.setRegionId(cp.getId());
  102. qb.setRecordDate(DateUtils.truncate(recordDate));
  103. qb.setForeignKeyId("0");
  104. qb.setLocation(Location.rg.getValue());
  105. //计算区域级全部
  106. calCp(qb,qbls);
  107. //计算公司级风电场站
  108. calCp(fd,fdls);
  109. //计算公司级光电场站
  110. calCp(gf,gfls);
  111. proEconPowerstationInfoDay2Service.save(qb);
  112. proEconPowerstationInfoDay2Service.save(fd);
  113. proEconPowerstationInfoDay2Service.save(gf);
  114. }
  115. // }else
  116. // {
  117. // logger.debug("公司所属场站数量与保存的场站日信息数量不一致,未进行{0}统计-------结束", entry.getKey());
  118. //
  119. // }
  120. }
  121. }
  122. }
  123. /**
  124. * 计算公司日信息
  125. */
  126. public void calCompanyInfoDay(Date recordDate) {
  127. List<ProEconPowerstationInfoDay2> wpinfodayls = proEconPowerstationInfoDay2Service.list().stream()
  128. .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate))==0
  129. // && CacheContext.wpmap.containsKey(i.getWindpowerstationId())
  130. && i.getLocation().equals(Location.wp.getValue()))
  131. .collect(Collectors.toList());
  132. if(!wpinfodayls.isEmpty())
  133. {
  134. Map<String, Map<String, List<ProEconPowerstationInfoDay2>>>cpmap=new HashMap<>();
  135. for(ProEconPowerstationInfoDay2 wpinfo:wpinfodayls)
  136. {
  137. if(cpmap.containsKey(wpinfo.getCompanyId()))
  138. {
  139. Map<String, List<ProEconPowerstationInfoDay2>> map=cpmap.get(wpinfo.getCompanyId());
  140. List<ProEconPowerstationInfoDay2> qbls=map.get("qb");
  141. List<ProEconPowerstationInfoDay2> gfls=map.get("fd");
  142. List<ProEconPowerstationInfoDay2> fdls=map.get("gf");
  143. if(wpinfo.getWindpowerstationId().contains("FDC"))
  144. {
  145. fdls.add(wpinfo);
  146. }else {
  147. gfls.add(wpinfo);
  148. }
  149. qbls.add(wpinfo);
  150. }else
  151. {
  152. Map<String, List<ProEconPowerstationInfoDay2>> map=new HashMap<>();
  153. List<ProEconPowerstationInfoDay2> qbls=new ArrayList<>();
  154. List<ProEconPowerstationInfoDay2> gfls=new ArrayList<>();
  155. List<ProEconPowerstationInfoDay2> fdls=new ArrayList<>();
  156. if(wpinfo.getWindpowerstationId().contains("FDC"))
  157. {
  158. fdls.add(wpinfo);
  159. }else {
  160. gfls.add(wpinfo);
  161. }
  162. qbls.add(wpinfo);
  163. map.put("qb",qbls);
  164. map.put("fd",fdls);
  165. map.put("gf",gfls);
  166. cpmap.put(wpinfo.getCompanyId(),map);
  167. }
  168. }
  169. //判断是否有重复记录,先删除重复记录
  170. List<String> idls = proEconPowerstationInfoDay2Service.list().stream()
  171. .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate))==0
  172. // && CacheContext.wpmap.containsKey(i.getWindpowerstationId())
  173. && i.getLocation().equals(Location.cp.getValue())).map(ProEconPowerstationInfoDay2::getId)
  174. .collect(Collectors.toList());
  175. if (idls.size() > 0) {
  176. proEconPowerstationInfoDay2Service.removeByIds(idls);
  177. }
  178. for(Map.Entry<String, Map<String, List<ProEconPowerstationInfoDay2>>> entry:cpmap.entrySet()){
  179. Map<String, List<ProEconPowerstationInfoDay2>> map=entry.getValue();
  180. List<ProEconPowerstationInfoDay2> qbls=map.get("qb");
  181. List<ProEconPowerstationInfoDay2> gfls=map.get("fd");
  182. List<ProEconPowerstationInfoDay2> fdls=map.get("gf");
  183. // if(CacheContext.cpwpmap.size()==qbls.size())
  184. // {
  185. ProEconPowerstationInfoDay2 qb=new ProEconPowerstationInfoDay2();
  186. ProEconPowerstationInfoDay2 fd=new ProEconPowerstationInfoDay2();
  187. ProEconPowerstationInfoDay2 gf=new ProEconPowerstationInfoDay2();
  188. if(CacheContext.cpmap.containsKey(entry.getKey()))
  189. {
  190. ProBasicCompany cp=CacheContext.cpmap.get(entry.getKey());
  191. gf.setRegionId(cp.getRegionId());
  192. gf.setCompanyId(cp.getId());
  193. gf.setRecordDate(DateUtils.truncate(recordDate));
  194. gf.setForeignKeyId("-2");
  195. gf.setLocation(Location.cp.getValue());
  196. fd.setRegionId(cp.getRegionId());
  197. fd.setCompanyId(cp.getId());
  198. fd.setRecordDate(DateUtils.truncate(recordDate));
  199. fd.setForeignKeyId("-1");
  200. fd.setLocation(Location.cp.getValue());
  201. qb.setRegionId(cp.getRegionId());
  202. qb.setCompanyId(cp.getId());
  203. qb.setRecordDate(DateUtils.truncate(recordDate));
  204. qb.setForeignKeyId("0");
  205. qb.setLocation(Location.cp.getValue());
  206. //计算公司级全部场站
  207. calCp(qb,qbls);
  208. //计算公司级风电场站
  209. calCp(fd,fdls);
  210. //计算公司级光电场站
  211. calCp(gf,gfls);
  212. proEconPowerstationInfoDay2Service.save(qb);
  213. proEconPowerstationInfoDay2Service.save(fd);
  214. proEconPowerstationInfoDay2Service.save(gf);
  215. }
  216. // }else
  217. // {
  218. // logger.debug("公司所属场站数量与保存的场站日信息数量不一致,未进行{0}统计-------结束", entry.getKey());
  219. //
  220. // }
  221. }
  222. }
  223. }
  224. private void calCp(ProEconPowerstationInfoDay2 pewp,List<ProEconPowerstationInfoDay2> ls) {
  225. if(!ls.isEmpty())
  226. {
  227. for(ProEconPowerstationInfoDay2 pepid:ls)
  228. {
  229. //日合计故障小时(明细)
  230. pewp.setRhjgzxsmx(StringUtils.round(pewp.getRhjgzxsmx()+pepid.getRhjgzxsmx(),2));
  231. //日合计场内受累故障小时(明细)
  232. pewp.setRhjcnslgzxsmx(StringUtils.round(pewp.getRhjcnslgzxsmx()+pepid.getRhjcnslgzxsmx(),2));
  233. //日合计检修小时(明细)
  234. pewp.setRhjjxxsmx(StringUtils.round(pewp.getRhjjxxsmx()+pepid.getRhjjxxsmx(),2));
  235. //日合计场内受累检修小时(明细)
  236. pewp.setRhjcnsljxxsmx(StringUtils.round(pewp.getRhjcnsljxxsmx()+pepid.getRhjcnsljxxsmx(),2));
  237. //日合计待机小时(明细)
  238. pewp.setRhjdjxsmx(StringUtils.round(pewp.getRhjdjxsmx()+pepid.getRhjdjxsmx(),2));
  239. //日合计缺陷降出力小时(明细)
  240. pewp.setRhjqxjclxsmx(StringUtils.round(pewp.getRhjqxjclxsmx()+pepid.getRhjqxjclxsmx(),2));
  241. //日合计手动停机小时(明细)
  242. pewp.setRhjsdtjxsmx(StringUtils.round(pewp.getRhjsdtjxsmx()+pepid.getRhjsdtjxsmx(),2));
  243. //日合计性能小时(明细)
  244. pewp.setRhjbwxsmx(StringUtils.round(pewp.getRhjbwxsmx()+pepid.getRhjbwxsmx(),2));
  245. //日合计限电停机小时(明细)
  246. pewp.setRhjxdtjxsmx(StringUtils.round(pewp.getRhjxdtjxsmx()+pepid.getRhjxdtjxsmx(),2));
  247. //日合计限电降出力小时(明细)
  248. pewp.setRhjxdjclxsmx(StringUtils.round(pewp.getRhjxdjclxsmx()+pepid.getRhjxdjclxsmx(),2));
  249. //日合计场外受累电网小时(明细)
  250. pewp.setRhjcwsldwxsmx(StringUtils.round(pewp.getRhjcwsldwxsmx()+pepid.getRhjcwsldwxsmx(),2));
  251. //日合计场外受累电网小时(明细)
  252. pewp.setRhjcwsltqxsmx(StringUtils.round(pewp.getRhjcwsltqxsmx()+pepid.getRhjcwsltqxsmx(),2));
  253. //日合计通讯中断小时(明细)
  254. pewp.setRhjtxzdxsmx(StringUtils.round(pewp.getRhjtxzdxsmx()+pepid.getRhjtxzdxsmx(),2));
  255. //日合计离线小时(明细)
  256. pewp.setRhjlxxsmx(StringUtils.round(pewp.getRhjlxxsmx()+pepid.getRhjlxxsmx(),2));
  257. //月合计故障小时(明细)
  258. pewp.setYhjgzxsmx(StringUtils.round(pewp.getYhjgzxsmx()+pepid.getYhjgzxsmx(),2));
  259. //月合计场内受累故障小时(明细)
  260. pewp.setYhjcnslgzxsmx(StringUtils.round(pewp.getYhjcnslgzxsmx()+pepid.getYhjcnslgzxsmx(),2));
  261. //月合计检修小时(明细)
  262. pewp.setYhjjxxsmx(StringUtils.round(pewp.getYhjjxxsmx()+pepid.getYhjjxxsmx(),2));
  263. //月合计场内受累检修小时(明细)
  264. pewp.setYhjcnsljxxsmx(StringUtils.round(pewp.getYhjcnsljxxsmx()+pepid.getYhjcnsljxxsmx(),2));
  265. //月合计待机小时(明细)
  266. pewp.setYhjdjxsmx(StringUtils.round(pewp.getYhjdjxsmx()+pepid.getYhjdjxsmx(),2));
  267. //月合计缺陷降出力小时(明细)
  268. pewp.setYhjqxjclxsmx(StringUtils.round(pewp.getYhjqxjclxsmx()+pepid.getYhjqxjclxsmx(),2));
  269. //月合计手动停机小时(明细)
  270. pewp.setYhjsdtjxsmx(StringUtils.round(pewp.getYhjsdtjxsmx()+pepid.getYhjsdtjxsmx(),2));
  271. //月合计性能小时(明细)
  272. pewp.setYhjbwxsmx(StringUtils.round(pewp.getYhjbwxsmx()+pepid.getYhjbwxsmx(),2));
  273. //月合计限电停机小时(明细)
  274. pewp.setYhjxdtjxsmx(StringUtils.round(pewp.getYhjxdtjxsmx()+pepid.getYhjxdtjxsmx(),2));
  275. //月合计限电降出力小时(明细)
  276. pewp.setYhjxdjclxsmx(StringUtils.round(pewp.getYhjxdjclxsmx()+pepid.getYhjxdjclxsmx(),2));
  277. //月合计场外受累电网小时(明细)
  278. pewp.setYhjcwsldwxsmx(StringUtils.round(pewp.getYhjcwsldwxsmx()+pepid.getYhjcwsldwxsmx(),2));
  279. //月合计场外受累电网小时(明细)
  280. pewp.setYhjcwsltqxsmx(StringUtils.round(pewp.getYhjcwsltqxsmx()+pepid.getYhjcwsltqxsmx(),2));
  281. //月合计通讯中断小时(明细)
  282. pewp.setYhjtxzdxsmx(StringUtils.round(pewp.getYhjtxzdxsmx()+pepid.getYhjtxzdxsmx(),2));
  283. //月合计离线小时(明细)
  284. pewp.setYhjlxxsmx(StringUtils.round(pewp.getYhjlxxsmx()+pepid.getYhjlxxsmx(),2));
  285. //年合计故障小时(明细)
  286. pewp.setNhjgzxsmx(StringUtils.round(pewp.getNhjgzxsmx()+pepid.getNhjgzxsmx(),2));
  287. //年合计场内受累故障小时(明细)
  288. pewp.setNhjcnslgzxsmx(StringUtils.round(pewp.getNhjcnslgzxsmx()+pepid.getNhjcnslgzxsmx(),2));
  289. //年合计检修小时(明细)
  290. pewp.setNhjjxxsmx(StringUtils.round(pewp.getNhjjxxsmx()+pepid.getNhjjxxsmx(),2));
  291. //年合计场内受累检修小时(明细)
  292. pewp.setNhjcnsljxxsmx(StringUtils.round(pewp.getNhjcnsljxxsmx()+pepid.getNhjcnsljxxsmx(),2));
  293. //年合计待机小时(明细)
  294. pewp.setNhjdjxsmx(StringUtils.round(pewp.getNhjdjxsmx()+pepid.getNhjdjxsmx(),2));
  295. //年合计缺陷降出力小时(明细)
  296. pewp.setNhjqxjclxsmx(StringUtils.round(pewp.getNhjqxjclxsmx()+pepid.getNhjqxjclxsmx(),2));
  297. //年合计手动停机小时(明细)
  298. pewp.setNhjsdtjxsmx(StringUtils.round(pewp.getNhjsdtjxsmx()+pepid.getNhjsdtjxsmx(),2));
  299. //年合计性能小时(明细)
  300. pewp.setNhjbwxsmx(StringUtils.round(pewp.getNhjbwxsmx()+pepid.getNhjbwxsmx(),2));
  301. //年合计限电停机小时(明细)
  302. pewp.setNhjxdtjxsmx(StringUtils.round(pewp.getNhjxdtjxsmx()+pepid.getNhjxdtjxsmx(),2));
  303. //年合计限电降出力小时(明细)
  304. pewp.setNhjxdjclxsmx(StringUtils.round(pewp.getNhjxdjclxsmx()+pepid.getNhjxdjclxsmx(),2));
  305. //年合计场外受累电网小时(明细)
  306. pewp.setNhjcwsldwxsmx(StringUtils.round(pewp.getNhjcwsldwxsmx()+pepid.getNhjcwsldwxsmx(),2));
  307. //年合计场外受累电网小时(明细)
  308. pewp.setNhjcwsltqxsmx(StringUtils.round(pewp.getNhjcwsltqxsmx()+pepid.getNhjcwsltqxsmx(),2));
  309. //年合计通讯中断小时(明细)
  310. pewp.setNhjtxzdxsmx(StringUtils.round(pewp.getNhjtxzdxsmx()+pepid.getNhjtxzdxsmx(),2));
  311. //年合计离线小时(明细)
  312. pewp.setNhjlxxsmx(StringUtils.round(pewp.getNhjlxxsmx()+pepid.getNhjlxxsmx(),2));
  313. }
  314. }
  315. }
  316. /**
  317. * 计算场站日信息
  318. */
  319. public void calWindpowerInfoDay(Date recordDate) throws Exception {
  320. Calendar c=Calendar.getInstance();
  321. c.setTime(recordDate);
  322. Date end=c.getTime();
  323. Date begin= DateUtils.truncate(c.getTime());
  324. //判断是否有重复记录,先删除重复记录
  325. List<String> idls = proEconPowerstationInfoDay2Service.list().stream()
  326. .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate))==0
  327. && CacheContext.wpmap.containsKey(i.getWindpowerstationId())
  328. && i.getLocation().equals(Location.wp.getValue())).map(ProEconPowerstationInfoDay2::getId)
  329. .collect(Collectors.toList());
  330. if (idls.size() > 0) {
  331. proEconPowerstationInfoDay2Service.removeByIds(idls);
  332. }
  333. for(ProBasicPowerstation wp:CacheContext.wpls)
  334. {
  335. if(CacheContext.wppointmap.containsKey(wp.getId()))
  336. {
  337. // Map<String, ProBasicPowerstationPoint> pointmap=CacheContext.wppointmap.get(wp.getId());
  338. ProEconPowerstationInfoDay2 pewp=new ProEconPowerstationInfoDay2();
  339. Initial.initial(pewp);
  340. pewp.setRegionId(wp.getRegionId());
  341. pewp.setCompanyId(wp.getCompanyId());
  342. pewp.setRecordDate(DateUtils.truncate(recordDate));
  343. pewp.setForeignKeyId("0");
  344. pewp.setWindpowerstationId(wp.getId());
  345. pewp.setLocation(Location.wp.getValue());
  346. //昨日的统计结果
  347. List<ProEconPowerstationInfoDay2> pepidls =new ArrayList<>();
  348. Calendar cl=Calendar.getInstance();
  349. cl.setTime(recordDate);
  350. //昨日的统计结果
  351. cl.add(Calendar.DAY_OF_MONTH,-1);
  352. if(cl.get(Calendar.DAY_OF_MONTH)!=1)
  353. {
  354. pepidls = proEconPowerstationInfoDay2Service.list().stream()
  355. .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(cl.getTime())) == 0
  356. && i.getWindpowerstationId().equals(wp.getId())
  357. && i.getLocation().equals(Location.wp.getValue()))
  358. .collect(Collectors.toList());
  359. }
  360. calDetiall(pewp, end, begin, CacheContext.wpwtmap.get(wp.getId()), pepidls);
  361. calSimple( pewp, end, begin, CacheContext.wpwtmap.get(wp.getId()),pepidls);
  362. //*******************************************年信息统计*********************************************************/
  363. // wpinfodayls.add(pewp);
  364. proEconPowerstationInfoDay2Service.save(pewp);
  365. }
  366. }
  367. }
  368. /**
  369. * 计算项目日信息
  370. */
  371. public void calProjectInfoDay(Date recordDate) throws Exception {
  372. Calendar c=Calendar.getInstance();
  373. c.setTime(recordDate);
  374. Date end=c.getTime();
  375. Date begin= DateUtils.truncate(c.getTime());
  376. //判断是否有重复记录,先删除重复记录
  377. List<String> idls = proEconPowerstationInfoDay2Service.list().stream()
  378. .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate))==0
  379. && CacheContext.pjmap.containsKey(i.getProjectId())
  380. && i.getLocation().equals(Location.pj.getValue())).map(ProEconPowerstationInfoDay2::getId)
  381. .collect(Collectors.toList());
  382. if (idls.size() > 0) {
  383. proEconPowerstationInfoDay2Service.removeByIds(idls);
  384. }
  385. for(ProBasicProject pj:CacheContext.pjls)
  386. {
  387. if(CacheContext.wppointmap.containsKey(pj.getId()))
  388. {
  389. // Map<String, ProBasicPowerstationPoint> pointmap=CacheContext.wppointmap.get(pj.getId());
  390. ProEconPowerstationInfoDay2 pewp=new ProEconPowerstationInfoDay2();
  391. Initial.initial(pewp);
  392. pewp.setForeignKeyId("0");
  393. pewp.setWindpowerstationId(pj.getWindpowerstationId());
  394. pewp.setProjectId(pj.getId());
  395. pewp.setLocation(Location.pj.getValue());
  396. pewp.setRecordDate(DateUtils.truncate(recordDate));
  397. //昨日的统计结果
  398. List<ProEconPowerstationInfoDay2> pepidls =new ArrayList<>();
  399. Calendar cl=Calendar.getInstance();
  400. cl.setTime(recordDate);
  401. //昨日的统计结果
  402. cl.add(Calendar.DAY_OF_MONTH,-1);
  403. if(cl.get(Calendar.DAY_OF_MONTH)!=1)
  404. {
  405. pepidls = proEconPowerstationInfoDay2Service.list().stream()
  406. .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(cl.getTime())) == 0
  407. && i.getProjectId().equals(pj.getId())
  408. && i.getLocation().equals(Location.pj.getValue()))
  409. .collect(Collectors.toList());
  410. }
  411. calDetiall(pewp, end, begin, CacheContext.pjwtmap.get(pj.getId()), pepidls);
  412. calSimple( pewp, end, begin, CacheContext.pjwtmap.get(pj.getId()),pepidls);
  413. proEconPowerstationInfoDay2Service.save(pewp);
  414. }
  415. }
  416. }
  417. /**
  418. * 计算线路日信息
  419. */
  420. public void calLineInfoDay(Date recordDate) throws Exception {
  421. Calendar c=Calendar.getInstance();
  422. c.setTime(recordDate);
  423. Date end=c.getTime();
  424. Date begin= DateUtils.truncate(c.getTime());
  425. //判断是否有重复记录,先删除重复记录
  426. List<String> idls = proEconPowerstationInfoDay2Service.list().stream()
  427. .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate))==0
  428. && CacheContext.lnmap.containsKey(i.getLineId())
  429. && i.getLocation().equals(Location.ln.getValue()) ).map(ProEconPowerstationInfoDay2::getId)
  430. .collect(Collectors.toList());
  431. if (idls.size() > 0) {
  432. proEconPowerstationInfoDay2Service.removeByIds(idls);
  433. }
  434. for(ProBasicLine ln:CacheContext.lnls)
  435. {
  436. if(CacheContext.wppointmap.containsKey(ln.getId()))
  437. {
  438. // Map<String, ProBasicPowerstationPoint> pointmap=CacheContext.wppointmap.get(ln.getId());
  439. ProEconPowerstationInfoDay2 pewp=new ProEconPowerstationInfoDay2();
  440. Initial.initial(pewp);
  441. pewp.setForeignKeyId("0");
  442. pewp.setLineId(ln.getId());
  443. pewp.setLocation(Location.ln.getValue());
  444. pewp.setProjectId(ln.getProjectId());
  445. pewp.setRecordDate(DateUtils.truncate(recordDate));
  446. //昨日的统计结果
  447. List<ProEconPowerstationInfoDay2> pepidls =new ArrayList<>();
  448. Calendar cl=Calendar.getInstance();
  449. cl.setTime(recordDate);
  450. //昨日的统计结果
  451. cl.add(Calendar.DAY_OF_MONTH,-1);
  452. if(cl.get(Calendar.DAY_OF_MONTH)!=1)
  453. {
  454. pepidls = proEconPowerstationInfoDay2Service.list().stream()
  455. .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(cl.getTime())) == 0
  456. && i.getLineId().equals(ln.getId())
  457. && i.getLocation().equals(Location.ln.getValue()))
  458. .collect(Collectors.toList());
  459. }
  460. calDetiall( pewp, end, begin, CacheContext.lnwtmap.get(ln.getId()),pepidls);
  461. calSimple( pewp, end, begin, CacheContext.lnwtmap.get(ln.getId()),pepidls);
  462. proEconPowerstationInfoDay2Service.save(pewp);
  463. }
  464. }
  465. }
  466. private void calDetiall(ProEconPowerstationInfoDay2 pewp, Date end, Date begin, List<ProBasicEquipment> wtls, List<ProEconPowerstationInfoDay2> pepidls) throws Exception {
  467. // // 0 待机
  468. // 1 手动停机
  469. // 2 正常发电
  470. // 3 发电降出力
  471. // 4 故障
  472. // 5 故障受累
  473. // 6 检修
  474. // 7 检修受累
  475. // 8 限电降出力
  476. // 9 限电停机
  477. // 10 电网受累
  478. // 11 环境受累
  479. // 12 通讯中断
  480. // 13 设备离线
  481. double lastState;//上一分钟状态
  482. double djsc=0;//待机时长
  483. double sdtjsc=0;//手动停机时长
  484. double zcfdsc=0;//正常发电时长
  485. double fdjclsc=0;//发电降出力时长
  486. double gzsc=0;//故障时长
  487. double gzslsc=0;//故障受累时长
  488. double jxsc=0;//检修时长
  489. double jxslsc=0;//检修受累时长
  490. double xdjclsc=0;//限电降出力时长
  491. double xdtjsc=0;//限电停机时长
  492. double dwslsc=0;//电网受累时长
  493. double hjslsc=0;//环境受累时长
  494. double txzdsc=0;//通讯中断时长
  495. double sblxsc=0;//设备离线时长
  496. Map<String, Map<String, ProBasicEquipmentPoint>> wtpAimap = CacheContext.wtpAimap;
  497. for(ProBasicEquipment wt:wtls)
  498. {
  499. lastState=-1;//上一分钟状态
  500. Map<String, ProBasicEquipmentPoint> aimap=wtpAimap.get(wt.getId());
  501. if(aimap.containsKey(ContantXk.MXZT))
  502. {
  503. ProBasicEquipmentPoint point=aimap.get(ContantXk.MXZT);
  504. //按照分钟时间进行统计状态快照值
  505. List<PointData> pointls=edosUtil.getHistoryDatasSnap(point.getNemCode(), begin.getTime()/1000, end.getTime()/1000);
  506. if(!pointls.isEmpty())
  507. {
  508. for(PointData po :pointls)
  509. {
  510. if(po.getPointValueInDouble()==0)
  511. {
  512. if(lastState!=po.getPointValueInDouble())
  513. {
  514. //将当前状态保存到上一分钟状态
  515. lastState=po.getPointValueInDouble();
  516. }
  517. //待机时长加1分钟
  518. djsc++;
  519. }else if(po.getPointValueInDouble()==1)
  520. {
  521. if(lastState!=po.getPointValueInDouble())
  522. {
  523. //将当前状态保存到上一分钟状态
  524. lastState=po.getPointValueInDouble();
  525. }
  526. //手动停机时长加1分钟
  527. sdtjsc++;
  528. }else if(po.getPointValueInDouble()==2)
  529. {
  530. if(lastState!=po.getPointValueInDouble())
  531. {
  532. //将当前状态保存到上一分钟状态
  533. lastState=po.getPointValueInDouble();
  534. }
  535. //正常发电时长加1分钟
  536. zcfdsc++;
  537. }else if(po.getPointValueInDouble()==3)
  538. {
  539. if(lastState!=po.getPointValueInDouble())
  540. {
  541. //将当前状态保存到上一分钟状态
  542. lastState=po.getPointValueInDouble();
  543. }
  544. //发电降出力时长加1分钟
  545. fdjclsc++;
  546. }else if(po.getPointValueInDouble()==4)
  547. {
  548. if(lastState!=po.getPointValueInDouble())
  549. {
  550. //将当前状态保存到上一分钟状态
  551. lastState=po.getPointValueInDouble();
  552. }
  553. //故障时长加1分钟
  554. gzsc++;
  555. }else if(po.getPointValueInDouble()==5)
  556. {
  557. if(lastState!=po.getPointValueInDouble())
  558. {
  559. //将当前状态保存到上一分钟状态
  560. lastState=po.getPointValueInDouble();
  561. }
  562. //故障受累时长加1分钟
  563. gzslsc++;
  564. }else if(po.getPointValueInDouble()==6)
  565. {
  566. if(lastState!=po.getPointValueInDouble())
  567. {
  568. //将当前状态保存到上一分钟状态
  569. lastState=po.getPointValueInDouble();
  570. }
  571. //检修时长加1分钟
  572. jxsc++;
  573. }else if(po.getPointValueInDouble()==7)
  574. {
  575. if(lastState!=po.getPointValueInDouble())
  576. {
  577. //将当前状态保存到上一分钟状态
  578. lastState=po.getPointValueInDouble();
  579. }
  580. //检修受累时长加1分钟
  581. jxslsc++;
  582. }else if(po.getPointValueInDouble()==8)
  583. {
  584. if(lastState!=po.getPointValueInDouble())
  585. {
  586. //将当前状态保存到上一分钟状态
  587. lastState=po.getPointValueInDouble();
  588. }
  589. //限电降出力时长加1分钟
  590. xdjclsc++;
  591. }else if(po.getPointValueInDouble()==9)
  592. {
  593. if(lastState!=po.getPointValueInDouble())
  594. {
  595. //将当前状态保存到上一分钟状态
  596. lastState=po.getPointValueInDouble();
  597. }
  598. //限电停机时长加1分钟
  599. xdtjsc++;
  600. }else if(po.getPointValueInDouble()==10)
  601. {
  602. if(lastState!=po.getPointValueInDouble())
  603. {
  604. //将当前状态保存到上一分钟状态
  605. lastState=po.getPointValueInDouble();
  606. }
  607. //电网受累时长加1分钟
  608. dwslsc++;
  609. }else if(po.getPointValueInDouble()==11)
  610. {
  611. if(lastState!=po.getPointValueInDouble())
  612. {
  613. //将当前状态保存到上一分钟状态
  614. lastState=po.getPointValueInDouble();
  615. }
  616. //环境受累时长加1分钟
  617. hjslsc++;
  618. }else if(po.getPointValueInDouble()==12)
  619. {
  620. if(lastState!=po.getPointValueInDouble())
  621. {
  622. //将当前状态保存到上一分钟状态
  623. lastState=po.getPointValueInDouble();
  624. }
  625. //通讯中断时长加1分钟
  626. txzdsc++;
  627. }else if(po.getPointValueInDouble()==13)
  628. {
  629. if(lastState!=po.getPointValueInDouble())
  630. {
  631. //将当前状态保存到上一分钟状态
  632. lastState=po.getPointValueInDouble();
  633. }
  634. //设备离线时长加1分钟
  635. sblxsc++;
  636. }
  637. }
  638. }
  639. }
  640. }
  641. //日合计故障小时(明细)
  642. pewp.setRhjgzxsmx(new BigDecimal(gzsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
  643. //日合计场内受累故障小时(明细)
  644. pewp.setRhjcnslgzxsmx(new BigDecimal(gzslsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
  645. //日合计检修小时(明细)
  646. pewp.setRhjjxxsmx(new BigDecimal(jxsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
  647. //日合计场内受累检修小时(明细)
  648. pewp.setRhjcnsljxxsmx(new BigDecimal(jxslsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
  649. //日合计待机小时(明细)
  650. pewp.setRhjdjxsmx(new BigDecimal(djsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
  651. //日合计缺陷降出力小时(明细)
  652. pewp.setRhjqxjclxsmx(new BigDecimal(fdjclsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
  653. //日合计手动停机小时(明细)
  654. pewp.setRhjsdtjxsmx(new BigDecimal(sdtjsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
  655. //日合计性能小时(明细)
  656. pewp.setRhjbwxsmx(new BigDecimal(zcfdsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
  657. //日合计限电停机小时(明细)
  658. pewp.setRhjxdtjxsmx(new BigDecimal(xdtjsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
  659. //日合计限电降出力小时(明细)
  660. pewp.setRhjxdjclxsmx(new BigDecimal(xdjclsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
  661. //日合计场外受累电网小时(明细)
  662. pewp.setRhjcwsldwxsmx(new BigDecimal(dwslsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
  663. //日合计场外受累电网小时(明细)
  664. pewp.setRhjcwsltqxsmx(new BigDecimal(hjslsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
  665. //日合计通讯中断小时(明细)
  666. pewp.setRhjtxzdxsmx(new BigDecimal(txzdsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
  667. //日合计离线小时(明细)
  668. pewp.setRhjlxxsmx(new BigDecimal(sblxsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
  669. //*******************************************日信息统计*********************************************************/
  670. //*******************************************月信息统计*********************************************************/
  671. if(pepidls.isEmpty())
  672. {
  673. setLossHoursMonth(pewp);
  674. }else
  675. {
  676. ProEconPowerstationInfoDay2 pepid=pepidls.get(0);
  677. //月合计故障小时(明细)
  678. pewp.setYhjgzxsmx(StringUtils.round(pepid.getYhjgzxsmx()+pewp.getRhjgzxsmx(),2));
  679. //月合计场内受累故障小时(明细)
  680. pewp.setYhjcnslgzxsmx(StringUtils.round(pepid.getYhjcnslgzxsmx()+pewp.getRhjcnslgzxsmx(),2));
  681. //月合计检修小时(明细)
  682. pewp.setYhjjxxsmx(StringUtils.round(pepid.getYhjjxxsmx()+pewp.getRhjjxxsmx(),2));
  683. //月合计场内受累检修小时(明细)
  684. pewp.setYhjcnsljxxsmx(StringUtils.round( pepid.getYhjcnsljxxsmx()+pewp.getRhjcnsljxxsmx(),2));
  685. //月合计待机小时(明细)
  686. pewp.setYhjdjxsmx(StringUtils.round(pepid.getYhjdjxsmx()+pewp.getRhjdjxsmx(),2));
  687. //月合计缺陷降出力小时(明细)
  688. pewp.setYhjqxjclxsmx(StringUtils.round(pepid.getYhjqxjclxsmx()+pewp.getRhjqxjclxsmx(),2));
  689. //月合计手动停机小时(明细)
  690. pewp.setYhjsdtjxsmx(StringUtils.round(pepid.getYhjsdtjxsmx()+pewp.getRhjsdtjxsmx(),2));
  691. //月合计性能小时(明细)
  692. pewp.setYhjbwxsmx(StringUtils.round(pepid.getYhjbwxsmx()+pewp.getRhjbwxsmx(),2));
  693. //月合计限电停机小时(明细)
  694. pewp.setYhjxdtjxsmx(StringUtils.round(pepid.getYhjxdtjxsmx()+pewp.getRhjxdtjxsmx(),2));
  695. //月合计限电降出力小时(明细)
  696. pewp.setYhjxdjclxsmx(StringUtils.round(pepid.getYhjxdjclxsmx()+pewp.getRhjxdjclxsmx(),2));
  697. //月合计场外受累电网小时(明细)
  698. pewp.setYhjcwsldwxsmx(StringUtils.round(pepid.getYhjcwsldwxsmx()+pewp.getRhjcwsldwxsmx(),2));
  699. //月合计场外受累电网小时(明细)
  700. pewp.setYhjcwsltqxsmx(StringUtils.round(pepid.getYhjcwsltqxsmx()+pewp.getRhjcwsltqxsmx(),2));
  701. //月合计通讯中断小时(明细)
  702. pewp.setYhjtxzdxsmx(StringUtils.round(pepid.getYhjtxzdxsmx()+pewp.getRhjtxzdxsmx(),2));
  703. //月合计离线小时(明细)
  704. pewp.setYhjlxxsmx(StringUtils.round(pepid.getYhjlxxsmx()+pewp.getRhjlxxsmx(),2));
  705. }
  706. //*******************************************月信息统计*********************************************************/
  707. //*******************************************年信息统计*********************************************************/
  708. if(pepidls.isEmpty())
  709. {
  710. setLossHoursYear(pewp);
  711. }else
  712. {
  713. ProEconPowerstationInfoDay2 pepid=pepidls.get(0);
  714. //年合计故障小时(明细)
  715. pewp.setNhjgzxsmx(StringUtils.round(pepid.getNhjgzxsmx()+pewp.getRhjgzxsmx(),2));
  716. //年合计场内受累故障小时(明细)
  717. pewp.setNhjcnslgzxsmx(StringUtils.round(pepid.getNhjcnslgzxsmx()+pewp.getRhjcnslgzxsmx(),2));
  718. //年合计检修小时(明细)
  719. pewp.setNhjjxxsmx(StringUtils.round(pepid.getNhjjxxsmx()+pewp.getRhjjxxsmx(),2));
  720. //年合计场内受累检修小时(明细)
  721. pewp.setNhjcnsljxxsmx(StringUtils.round( pepid.getNhjcnsljxxsmx()+pewp.getRhjcnsljxxsmx(),2));
  722. //年合计待机小时(明细)
  723. pewp.setNhjdjxsmx(StringUtils.round(pepid.getNhjdjxsmx()+pewp.getRhjdjxsmx(),2));
  724. //年合计缺陷降出力小时(明细)
  725. pewp.setNhjqxjclxsmx(StringUtils.round(pepid.getNhjqxjclxsmx()+pewp.getRhjqxjclxsmx(),2));
  726. //年合计手动停机小时(明细)
  727. pewp.setNhjsdtjxsmx(StringUtils.round(pepid.getNhjsdtjxsmx()+pewp.getRhjsdtjxsmx(),2));
  728. //年合计性能小时(明细)
  729. pewp.setNhjbwxsmx(StringUtils.round(pepid.getNhjbwxsmx()+pewp.getRhjbwxsmx(),2));
  730. //年合计限电停机小时(明细)
  731. pewp.setNhjxdtjxsmx(StringUtils.round(pepid.getNhjxdtjxsmx()+pewp.getRhjxdtjxsmx(),2));
  732. //年合计限电降出力小时(明细)
  733. pewp.setNhjxdjclxsmx(StringUtils.round(pepid.getNhjxdjclxsmx()+pewp.getRhjxdjclxsmx(),2));
  734. //年合计场外受累电网小时(明细)
  735. pewp.setNhjcwsldwxsmx(StringUtils.round(pepid.getNhjcwsldwxsmx()+pewp.getRhjcwsldwxsmx(),2));
  736. //年合计场外受累电网小时(明细)
  737. pewp.setNhjcwsltqxsmx(StringUtils.round(pepid.getNhjcwsltqxsmx()+pewp.getRhjcwsltqxsmx(),2));
  738. //年合计通讯中断小时(明细)
  739. pewp.setNhjtxzdxsmx(StringUtils.round(pepid.getNhjtxzdxsmx()+pewp.getRhjtxzdxsmx(),2));
  740. //年合计离线小时(明细)
  741. pewp.setNhjlxxsmx(StringUtils.round(pepid.getNhjlxxsmx()+pewp.getRhjlxxsmx(),2));
  742. }
  743. }
  744. private static void setLossHoursYear(ProEconPowerstationInfoDay2 pewp) {
  745. //年合计故障小时(明细)
  746. pewp.setNhjgzxsmx(pewp.getRhjgzxsmx());
  747. //年合计场内受累故障小时(明细)
  748. pewp.setNhjcnslgzxsmx(pewp.getRhjcnslgzxsmx());
  749. //年合计检修小时(明细)
  750. pewp.setNhjjxxsmx(pewp.getRhjjxxsmx());
  751. //年合计场内受累检修小时(明细)
  752. pewp.setNhjcnsljxxsmx(pewp.getRhjcnsljxxsmx());
  753. //年合计待机小时(明细)
  754. pewp.setNhjdjxsmx(pewp.getRhjdjxsmx());
  755. //年合计缺陷降出力小时(明细)
  756. pewp.setNhjqxjclxsmx(pewp.getRhjqxjclxsmx());
  757. //年合计手动停机小时(明细)
  758. pewp.setNhjsdtjxsmx(pewp.getRhjsdtjxsmx());
  759. //年合计性能小时(明细)
  760. pewp.setNhjbwxsmx(pewp.getRhjbwxsmx());
  761. //年合计限电停机小时(明细)
  762. pewp.setNhjxdtjxsmx(pewp.getRhjxdtjxsmx());
  763. //年合计限电降出力小时(明细)
  764. pewp.setNhjxdjclxsmx(pewp.getRhjxdjclxsmx());
  765. //年合计场外受累电网小时(明细)
  766. pewp.setNhjcwsldwxsmx(pewp.getRhjcwsldwxsmx());
  767. //年合计场外受累电网小时(明细)
  768. pewp.setNhjcwsltqxsmx(pewp.getRhjcwsltqxsmx());
  769. //年合计通讯中断小时(明细)
  770. pewp.setNhjtxzdxsmx(pewp.getRhjtxzdxsmx());
  771. //年合计离线小时(明细)
  772. pewp.setNhjlxxsmx(pewp.getRhjlxxsmx());
  773. }
  774. private static void setLossHoursMonth(ProEconPowerstationInfoDay2 pewp) {
  775. //月合计故障小时(明细)
  776. pewp.setYhjgzxsmx(pewp.getRhjgzxsmx());
  777. //月合计场内受累故障小时(明细)
  778. pewp.setYhjcnslgzxsmx(pewp.getRhjcnslgzxsmx());
  779. //月合计检修小时(明细)
  780. pewp.setYhjjxxsmx(pewp.getRhjjxxsmx());
  781. //月合计场内受累检修小时(明细)
  782. pewp.setYhjcnsljxxsmx(pewp.getRhjcnsljxxsmx());
  783. //月合计待机小时(明细)
  784. pewp.setYhjdjxsmx(pewp.getRhjdjxsmx());
  785. //月合计缺陷降出力小时(明细)
  786. pewp.setYhjqxjclxsmx(pewp.getRhjqxjclxsmx());
  787. //月合计手动停机小时(明细)
  788. pewp.setYhjsdtjxsmx(pewp.getRhjsdtjxsmx());
  789. //月合计性能小时(明细)
  790. pewp.setYhjbwxsmx(pewp.getRhjbwxsmx());
  791. //月合计限电停机小时(明细)
  792. pewp.setYhjxdtjxsmx(pewp.getRhjxdtjxsmx());
  793. //月合计限电降出力小时(明细)
  794. pewp.setYhjxdjclxsmx(pewp.getRhjxdjclxsmx());
  795. //月合计场外受累电网小时(明细)
  796. pewp.setYhjcwsldwxsmx(pewp.getRhjcwsldwxsmx());
  797. //月合计场外受累电网小时(明细)
  798. pewp.setYhjcwsltqxsmx(pewp.getRhjcwsltqxsmx());
  799. //月合计通讯中断小时(明细)
  800. pewp.setYhjtxzdxsmx(pewp.getRhjtxzdxsmx());
  801. //月合计离线小时(明细)
  802. pewp.setYhjlxxsmx(pewp.getRhjlxxsmx());
  803. }
  804. private static void setLossHoursMonthSimple(ProEconPowerstationInfoDay2 pewp) {
  805. //月合计待机小时
  806. pewp.setYhjdjxs(pewp.getRhjdjxs());
  807. //月合计维护停机小时
  808. pewp.setYhjjxtjxs(pewp.getRhjjxtjxs());
  809. // 月合计故障停机小时
  810. pewp.setYhjgztjxs(pewp.getRhjgztjxs());
  811. //月合计运行小时
  812. pewp.setYhjyxxs(pewp.getRhjyxxs());
  813. //月合计限电小时
  814. pewp.setYhjxdxs(pewp.getRhjxdxs());
  815. //月合计通讯中断小时
  816. pewp.setYhjtxzdxs(pewp.getRhjtxzdxs());
  817. //月合计受累小时
  818. pewp.setYhjslxs(pewp.getRhjslxs());
  819. }
  820. private static void setLossHoursYearSimple(ProEconPowerstationInfoDay2 pewp) {
  821. //年合计待机小时
  822. pewp.setNhjdjxs(pewp.getRhjdjxs());
  823. //年合计维护停机小时
  824. pewp.setNhjjxtjxs(pewp.getRhjjxtjxs());
  825. // 年合计故障小时
  826. pewp.setNhjgztjxs(pewp.getRhjgztjxs());
  827. //年合计运行小时
  828. pewp.setNhjyxxs(pewp.getRhjyxxs());
  829. //年合计限电小时
  830. pewp.setNhjxdxs(pewp.getRhjxdxs());
  831. //年合计通讯中断小时
  832. pewp.setNhjtxzdxs(pewp.getRhjtxzdxs());
  833. //年合计受累小时
  834. pewp.setNhjslxs(pewp.getRhjslxs());
  835. }
  836. private void calSimple(ProEconPowerstationInfoDay2 pewp, Date end, Date begin, List<ProBasicEquipment> wtls, List<ProEconPowerstationInfoDay2> pepidls) throws Exception {
  837. // 0 待机
  838. // 1 运行
  839. // 2 故障
  840. // 3 检修
  841. // 4 限电
  842. // 5 受累
  843. // 6 离线
  844. //*******************************************日信息统计*********************************************************/
  845. double lastState=-1;//上一分钟状态
  846. double djsc=0;//待机时长
  847. double zcfdsc=0;//正常发电时长
  848. double gzsc=0;//故障时长
  849. double jxsc=0;//检修时长
  850. double xdtjsc=0;//限电停机时长
  851. double slsc=0;//受累时长
  852. double txzdsc=0;//通讯中断时长
  853. Map<String, Map<String, ProBasicEquipmentPoint>> wtpAimap = CacheContext.wtpAimap;
  854. for(ProBasicEquipment wt:wtls)
  855. {
  856. Map<String, ProBasicEquipmentPoint> aimap=wtpAimap.get(wt.getId());
  857. if(aimap.containsKey(ContantXk.SBZT))
  858. {
  859. ProBasicEquipmentPoint point=aimap.get(ContantXk.SBZT);
  860. //按照分钟时间进行统计状态快照值
  861. List<PointData> pointls=edosUtil.getHistoryDatasSnap(point.getNemCode(), begin.getTime()/1000, end.getTime()/1000);
  862. if(!pointls.isEmpty()) {
  863. for (PointData po : pointls) {
  864. if (po.getPointValueInDouble() == 0) {
  865. if (lastState != po.getPointValueInDouble()) {
  866. //将当前状态保存到上一分钟状态
  867. lastState = po.getPointValueInDouble();
  868. }
  869. //待机时长加1分钟
  870. djsc++;
  871. } else if (po.getPointValueInDouble() == 1) {
  872. if (lastState != po.getPointValueInDouble()) {
  873. //将当前状态保存到上一分钟状态
  874. lastState = po.getPointValueInDouble();
  875. }
  876. //正常发电时长加1分钟
  877. zcfdsc++;
  878. } else if (po.getPointValueInDouble() == 2) {
  879. if (lastState != po.getPointValueInDouble()) {
  880. //将当前状态保存到上一分钟状态
  881. lastState = po.getPointValueInDouble();
  882. }
  883. //故障时长加1分钟
  884. gzsc++;
  885. } else if (po.getPointValueInDouble() == 3) {
  886. if (lastState != po.getPointValueInDouble()) {
  887. //将当前状态保存到上一分钟状态
  888. lastState = po.getPointValueInDouble();
  889. }
  890. //检修时长加1分钟
  891. jxsc++;
  892. } else if (po.getPointValueInDouble() == 4) {
  893. if (lastState != po.getPointValueInDouble()) {
  894. //将当前状态保存到上一分钟状态
  895. lastState = po.getPointValueInDouble();
  896. }
  897. //限电停机时长加1分钟
  898. xdtjsc++;
  899. } else if (po.getPointValueInDouble() == 5) {
  900. if (lastState != po.getPointValueInDouble()) {
  901. //将当前状态保存到上一分钟状态
  902. lastState = po.getPointValueInDouble();
  903. }
  904. //受累时长加1分钟
  905. slsc++;
  906. } else if (po.getPointValueInDouble() == 6) {
  907. if (lastState != po.getPointValueInDouble()) {
  908. //将当前状态保存到上一分钟状态
  909. lastState = po.getPointValueInDouble();
  910. }
  911. //通讯中断时长加1分钟
  912. txzdsc++;
  913. }
  914. }
  915. }
  916. }
  917. }
  918. //日合计待机小时
  919. pewp.setRhjdjxs(new BigDecimal(gzsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
  920. //日合计维护停机小时
  921. pewp.setRhjjxtjxs(new BigDecimal(jxsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
  922. // 日合计待机小时
  923. pewp.setRhjdjxs(new BigDecimal(djsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
  924. //日合计运行小时
  925. pewp.setRhjyxxs(new BigDecimal(zcfdsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
  926. //日合计限电小时
  927. pewp.setRhjxdxs(new BigDecimal(xdtjsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
  928. //日合计通讯中断小时
  929. pewp.setRhjtxzdxs(new BigDecimal(txzdsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
  930. //日合计受累小时
  931. pewp.setRhjslxs(new BigDecimal(slsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
  932. //*******************************************日信息统计*********************************************************/
  933. //*******************************************月信息统计*********************************************************/
  934. if(pepidls.isEmpty())
  935. {
  936. setLossHoursMonthSimple(pewp);
  937. }else
  938. {
  939. ProEconPowerstationInfoDay2 pepid=pepidls.get(0);
  940. //月合计待机小时
  941. pewp.setYhjdjxs(StringUtils.round(pepid.getYhjdjxs()+pewp.getRhjdjxs(),2));
  942. //月合计维护停机小时
  943. pewp.setYhjjxtjxs(StringUtils.round(pepid.getYhjjxtjxs()+pewp.getRhjjxtjxs(),2));
  944. // 月合计故障小时
  945. pewp.setYhjgztjxs(StringUtils.round(pepid.getYhjgztjxs()+pewp.getRhjgztjxs(),2));
  946. //月合计运行小时
  947. pewp.setYhjyxxs(StringUtils.round(pepid.getYhjyxxs()+pewp.getRhjyxxs(),2));
  948. //月合计限电小时
  949. pewp.setYhjxdxs(StringUtils.round(pepid.getYhjxdxs()+pewp.getRhjxdxs(),2));
  950. //月合计通讯中断小时
  951. pewp.setYhjtxzdxs(StringUtils.round(pepid.getYhjtxzdxs()+pewp.getRhjtxzdxs(),2));
  952. //月合计受累小时
  953. pewp.setYhjslxs(StringUtils.round(pepid.getYhjslxs()+pewp.getRhjslxs(),2));
  954. }
  955. //*******************************************月信息统计*********************************************************/
  956. //*******************************************年信息统计*********************************************************/
  957. if(pepidls.isEmpty())
  958. {
  959. setLossHoursYearSimple(pewp);
  960. }else
  961. {
  962. ProEconPowerstationInfoDay2 pepid=pepidls.get(0);
  963. //年合计待机小时
  964. pewp.setNhjdjxs(StringUtils.round(pepid.getNhjdjxs()+pewp.getRhjdjxs(),2));
  965. //年合计维护停机小时
  966. pewp.setNhjjxtjxs(StringUtils.round(pepid.getNhjjxtjxs()+pewp.getRhjjxtjxs(),2));
  967. // 年合计故障小时
  968. pewp.setNhjgztjxs(StringUtils.round(pepid.getNhjgztjxs()+pewp.getRhjgztjxs(),2));
  969. //年合计运行小时
  970. pewp.setNhjyxxs(StringUtils.round(pepid.getNhjyxxs()+pewp.getRhjyxxs(),2));
  971. //年合计限电小时
  972. pewp.setNhjxdxs(StringUtils.round(pepid.getNhjxdxs()+pewp.getRhjxdxs(),2));
  973. //年合计通讯中断小时
  974. pewp.setNhjtxzdxs(StringUtils.round(pepid.getNhjtxzdxs()+pewp.getRhjtxzdxs(),2));
  975. //年合计受累小时
  976. pewp.setNhjslxs(StringUtils.round(pepid.getNhjslxs()+pewp.getRhjslxs(),2));
  977. }
  978. //*******************************************年信息统计*********************************************************/
  979. }
  980. }