WindPowerInfo3Service.java 55 KB

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