WindPowerInfo2Service.java 60 KB

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