EquipmentInfo3Service.java 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  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.ProBasicEquipment;
  7. import com.gyee.generation.model.auto.ProBasicEquipmentPoint;
  8. import com.gyee.generation.model.auto.ProEconEquipmentInfoDay3;
  9. import com.gyee.generation.service.auto.IProEconEquipmentInfoDay3Service;
  10. import com.gyee.generation.util.DateUtils;
  11. import com.gyee.generation.util.realtimesource.IEdosUtil;
  12. import com.gyee.generation.util.statisticcs.Initial;
  13. import org.springframework.stereotype.Service;
  14. import javax.annotation.Resource;
  15. import java.util.*;
  16. import java.util.stream.Collectors;
  17. @Service
  18. public class EquipmentInfo3Service {
  19. // private static final Logger logger = LoggerFactory.getLogger(WindPowerInfo2Service.class);
  20. @Resource
  21. private IEdosUtil edosUtil;
  22. @Resource
  23. private IProEconEquipmentInfoDay3Service proEconEquipmentInfoDay3Service;
  24. /**
  25. * 计算设备日信息
  26. */
  27. public void calEquipmentInfoDay(Date recordDate) throws Exception {
  28. Calendar c=Calendar.getInstance();
  29. c.setTime(recordDate);
  30. Date end=c.getTime();
  31. Date begin= DateUtils.truncDay(c.getTime());
  32. //判断是否有重复记录,先删除重复记录
  33. List<String> idls = proEconEquipmentInfoDay3Service.list().stream()
  34. .filter(i -> i.getRecordDate().compareTo(DateUtils.truncDay(recordDate))==0
  35. && CacheContext.wtmap.containsKey(i.getWindturbineId())
  36. ).map(ProEconEquipmentInfoDay3::getId)
  37. .collect(Collectors.toList());
  38. if (idls.size() > 0) {
  39. proEconEquipmentInfoDay3Service.removeByIds(idls);
  40. }
  41. for(ProBasicEquipment wt:CacheContext.wtls)
  42. {
  43. if(CacheContext.wtpAimap.containsKey(wt.getId()))
  44. {
  45. ProEconEquipmentInfoDay3 pewp=new ProEconEquipmentInfoDay3();
  46. Initial.initial(pewp);
  47. pewp.setCompanyId(wt.getCompanyId());
  48. pewp.setWindpowerstationId(wt.getWindpowerstationId());
  49. pewp.setLineId(wt.getLineId());
  50. pewp.setProjectId(wt.getProjectId());
  51. pewp.setRegionId(wt.getRegionId());
  52. pewp.setRecordDate(DateUtils.truncDay(recordDate));
  53. //昨日的统计结果
  54. List<ProEconEquipmentInfoDay3> pepidls =new ArrayList<>();
  55. Calendar cl=Calendar.getInstance();
  56. cl.setTime(recordDate);
  57. cl.add(Calendar.DAY_OF_MONTH,-1);
  58. if(cl.get(Calendar.DAY_OF_MONTH)!=1)
  59. {
  60. pepidls = proEconEquipmentInfoDay3Service.list().stream()
  61. .filter(i -> i.getRecordDate().compareTo(DateUtils.truncDay(cl.getTime())) == 0
  62. && i.getWindturbineId().equals(wt.getId())
  63. )
  64. .collect(Collectors.toList());
  65. }
  66. calDetiall( pewp, end, begin,wt,pepidls);
  67. calSimple( pewp, end, begin, wt,pepidls);
  68. proEconEquipmentInfoDay3Service.save(pewp);
  69. }
  70. }
  71. }
  72. private void calDetiall(ProEconEquipmentInfoDay3 pewp, Date end, Date begin, ProBasicEquipment wt, List<ProEconEquipmentInfoDay3> pepidls) throws Exception {
  73. // // 0 待机
  74. // 1 手动停机
  75. // 2 正常发电
  76. // 3 发电降出力
  77. // 4 故障
  78. // 5 故障受累
  79. // 6 检修
  80. // 7 检修受累
  81. // 8 限电降出力
  82. // 9 限电停机
  83. // 10 电网受累
  84. // 11 环境受累
  85. // 12 通讯中断
  86. // 13 设备离线
  87. double lastState;//上一分钟状态
  88. double djcs=0;//待机时长
  89. double sdtjcs=0;//手动停机时长
  90. double zcfdcs=0;//正常发电时长
  91. double fdjclcs=0;//发电降出力时长
  92. double gzcs=0;//故障时长
  93. double gzslcs=0;//故障受累时长
  94. double jxcs=0;//检修时长
  95. double jxslcs=0;//检修受累时长
  96. double xdjclcs=0;//限电降出力时长
  97. double xdtjcs=0;//限电停机时长
  98. double dwslcs=0;//电网受累时长
  99. double hjslcs=0;//环境受累时长
  100. double txzdcs=0;//通讯中断时长
  101. double sblxcs=0;//设备离线时长
  102. Map<String, Map<String, ProBasicEquipmentPoint>> wtpAimap = CacheContext.wtpAimap;
  103. lastState=-1;//上一分钟状态
  104. Map<String, ProBasicEquipmentPoint> aimap=wtpAimap.get(wt.getId());
  105. if(aimap.containsKey(ContantXk.MXZT))
  106. {
  107. ProBasicEquipmentPoint point=aimap.get(ContantXk.MXZT);
  108. //按照分钟时间进行统计状态快照值
  109. List<PointData> pointls=edosUtil.getHistoryDatasSnap(point.getNemCode(), begin.getTime()/1000, end.getTime()/1000);
  110. if(!pointls.isEmpty())
  111. {
  112. for(PointData po :pointls)
  113. {
  114. if(po.getPointValueInDouble()==0)
  115. {
  116. if(lastState!=po.getPointValueInDouble())
  117. {
  118. //将当前状态保存到上一分钟状态
  119. lastState=po.getPointValueInDouble();
  120. //待机时长加1
  121. djcs++;
  122. }
  123. }else if(po.getPointValueInDouble()==1)
  124. {
  125. if(lastState!=po.getPointValueInDouble())
  126. {
  127. //将当前状态保存到上一分钟状态
  128. lastState=po.getPointValueInDouble();
  129. //手动停机时长加1
  130. sdtjcs++;
  131. }
  132. }else if(po.getPointValueInDouble()==2)
  133. {
  134. if(lastState!=po.getPointValueInDouble())
  135. {
  136. //将当前状态保存到上一分钟状态
  137. lastState=po.getPointValueInDouble();
  138. //正常发电时长加1
  139. zcfdcs++;
  140. }
  141. }else if(po.getPointValueInDouble()==3)
  142. {
  143. if(lastState!=po.getPointValueInDouble())
  144. {
  145. //将当前状态保存到上一分钟状态
  146. lastState=po.getPointValueInDouble();
  147. //发电降出力时长加1
  148. fdjclcs++;
  149. }
  150. }else if(po.getPointValueInDouble()==4)
  151. {
  152. if(lastState!=po.getPointValueInDouble())
  153. {
  154. //将当前状态保存到上一分钟状态
  155. lastState=po.getPointValueInDouble();
  156. //故障时长加1
  157. gzcs++;
  158. }
  159. }else if(po.getPointValueInDouble()==5)
  160. {
  161. if(lastState!=po.getPointValueInDouble())
  162. {
  163. //将当前状态保存到上一分钟状态
  164. lastState=po.getPointValueInDouble();
  165. //故障受累时长加1
  166. gzslcs++;
  167. }
  168. }else if(po.getPointValueInDouble()==6)
  169. {
  170. if(lastState!=po.getPointValueInDouble())
  171. {
  172. //将当前状态保存到上一分钟状态
  173. lastState=po.getPointValueInDouble();
  174. //检修时长加1
  175. jxcs++;
  176. }
  177. }else if(po.getPointValueInDouble()==7)
  178. {
  179. if(lastState!=po.getPointValueInDouble())
  180. {
  181. //将当前状态保存到上一分钟状态
  182. lastState=po.getPointValueInDouble();
  183. //检修受累时长加1
  184. jxslcs++;
  185. }
  186. }else if(po.getPointValueInDouble()==8)
  187. {
  188. if(lastState!=po.getPointValueInDouble())
  189. {
  190. //将当前状态保存到上一分钟状态
  191. lastState=po.getPointValueInDouble();
  192. //限电降出力时长加1
  193. xdjclcs++;
  194. }
  195. }else if(po.getPointValueInDouble()==9)
  196. {
  197. if(lastState!=po.getPointValueInDouble())
  198. {
  199. //将当前状态保存到上一分钟状态
  200. lastState=po.getPointValueInDouble();
  201. //限电停机时长加1
  202. xdtjcs++;
  203. }
  204. //限电停机时长加1
  205. xdtjcs++;
  206. }else if(po.getPointValueInDouble()==10)
  207. {
  208. if(lastState!=po.getPointValueInDouble())
  209. {
  210. //将当前状态保存到上一分钟状态
  211. lastState=po.getPointValueInDouble();
  212. //电网受累时长加1
  213. dwslcs++;
  214. }
  215. }else if(po.getPointValueInDouble()==11)
  216. {
  217. if(lastState!=po.getPointValueInDouble())
  218. {
  219. //将当前状态保存到上一分钟状态
  220. lastState=po.getPointValueInDouble();
  221. //环境受累时长加1
  222. hjslcs++;
  223. }
  224. }else if(po.getPointValueInDouble()==12)
  225. {
  226. if(lastState!=po.getPointValueInDouble())
  227. {
  228. //将当前状态保存到上一分钟状态
  229. lastState=po.getPointValueInDouble();
  230. //通讯中断时长加1
  231. txzdcs++;
  232. }
  233. }else if(po.getPointValueInDouble()==13)
  234. {
  235. if(lastState!=po.getPointValueInDouble())
  236. {
  237. //将当前状态保存到上一分钟状态
  238. lastState=po.getPointValueInDouble();
  239. //设备离线时长加1
  240. sblxcs++;
  241. }
  242. }
  243. }
  244. }
  245. }
  246. //日合计故障次数(明细)
  247. pewp.setRgzcsmx(gzcs);
  248. //日合计场内受累故障次数(明细)
  249. pewp.setRcnslgzcsmx(gzslcs);
  250. //日合计检修次数(明细)
  251. pewp.setRjxcsmx(jxcs);
  252. //日合计场内受累检修次数(明细)
  253. pewp.setRcnsljxcsmx(jxslcs);
  254. //日合计待机次数(明细)
  255. pewp.setRdjcsmx(djcs);
  256. //日合计缺陷降出力次数(明细)
  257. pewp.setRqxjclcsmx(fdjclcs);
  258. //日合计手动停机次数(明细)
  259. pewp.setRsdtjcsmx(sdtjcs);
  260. //日合计性能次数(明细)
  261. pewp.setRbwcsmx(zcfdcs);
  262. //日合计限电停机次数(明细)
  263. pewp.setRxdtjcsmx(xdtjcs);
  264. //日合计限电降出力次数(明细)
  265. pewp.setRxdjclcsmx(xdjclcs);
  266. //日合计场外受累电网次数(明细)
  267. pewp.setRcwsldwcsmx(dwslcs);
  268. //日合计场外受累电网次数(明细)
  269. pewp.setRcwsltqcsmx(hjslcs);
  270. //日合计通讯中断次数(明细)
  271. pewp.setRtxzdcsmx(txzdcs);
  272. //日合计离线次数(明细)
  273. pewp.setRlxcsmx(sblxcs);
  274. //*******************************************日信息统计*********************************************************/
  275. //*******************************************月信息统计*********************************************************/
  276. if(pepidls.isEmpty())
  277. {
  278. setLossHoursMonth(pewp);
  279. }else
  280. {
  281. ProEconEquipmentInfoDay3 pepid=pepidls.get(0);
  282. //月合计故障次数(明细)
  283. pewp.setYgzcsmx(StringUtils.round(pepid.getYgzcsmx()+pewp.getRgzcsmx(),2));
  284. //月合计场内受累故障次数(明细)
  285. pewp.setYcnslgzcsmx(StringUtils.round(pepid.getYcnslgzcsmx()+pewp.getRcnslgzcsmx(),2));
  286. //月合计检修次数(明细)
  287. pewp.setYjxcsmx(StringUtils.round(pepid.getYjxcsmx()+pewp.getRjxcsmx(),2));
  288. //月合计场内受累检修次数(明细)
  289. pewp.setYcnsljxcsmx(StringUtils.round( pepid.getYcnsljxcsmx()+pewp.getRcnsljxcsmx(),2));
  290. //月合计待机次数(明细)
  291. pewp.setYdjcsmx(StringUtils.round(pepid.getYdjcsmx()+pewp.getRdjcsmx(),2));
  292. //月合计缺陷降出力次数(明细)
  293. pewp.setYqxjclcsmx(StringUtils.round(pepid.getYqxjclcsmx()+pewp.getRqxjclcsmx(),2));
  294. //月合计手动停机次数(明细)
  295. pewp.setYsdtjcsmx(StringUtils.round(pepid.getYsdtjcsmx()+pewp.getRsdtjcsmx(),2));
  296. //月合计性能次数(明细)
  297. pewp.setYbwcsmx(StringUtils.round(pepid.getYbwcsmx()+pewp.getRbwcsmx(),2));
  298. //月合计限电停机次数(明细)
  299. pewp.setYxdtjcsmx(StringUtils.round(pepid.getYxdtjcsmx()+pewp.getRxdtjcsmx(),2));
  300. //月合计限电降出力次数(明细)
  301. pewp.setYxdjclcsmx(StringUtils.round(pepid.getYxdjclcsmx()+pewp.getRxdjclcsmx(),2));
  302. //月合计场外受累电网次数(明细)
  303. pewp.setYcwsldwcsmx(StringUtils.round(pepid.getYcwsldwcsmx()+pewp.getRcwsldwcsmx(),2));
  304. //月合计场外受累电网次数(明细)
  305. pewp.setYcwsltqcsmx(StringUtils.round(pepid.getYcwsltqcsmx()+pewp.getRcwsltqcsmx(),2));
  306. //月合计通讯中断次数(明细)
  307. pewp.setYtxzdcsmx(StringUtils.round(pepid.getYtxzdcsmx()+pewp.getRtxzdcsmx(),2));
  308. //月合计离线次数(明细)
  309. pewp.setYlxcsmx(StringUtils.round(pepid.getYlxcsmx()+pewp.getRlxcsmx(),2));
  310. }
  311. //*******************************************月信息统计*********************************************************/
  312. //*******************************************年信息统计*********************************************************/
  313. if(pepidls.isEmpty())
  314. {
  315. setLossHoursYear(pewp);
  316. }else
  317. {
  318. ProEconEquipmentInfoDay3 pepid=pepidls.get(0);
  319. //年合计故障次数(明细)
  320. pewp.setNgzcsmx(StringUtils.round(pepid.getNgzcsmx()+pewp.getRgzcsmx(),2));
  321. //年合计场内受累故障次数(明细)
  322. pewp.setNcnslgzcsmx(StringUtils.round(pepid.getNcnslgzcsmx()+pewp.getRcnslgzcsmx(),2));
  323. //年合计检修次数(明细)
  324. pewp.setNjxcsmx(StringUtils.round(pepid.getNjxcsmx()+pewp.getRjxcsmx(),2));
  325. //年合计场内受累检修次数(明细)
  326. pewp.setNcnsljxcsmx(StringUtils.round( pepid.getNcnsljxcsmx()+pewp.getRcnsljxcsmx(),2));
  327. //年合计待机次数(明细)
  328. pewp.setNdjcsmx(StringUtils.round(pepid.getNdjcsmx()+pewp.getRdjcsmx(),2));
  329. //年合计缺陷降出力次数(明细)
  330. pewp.setNqxjclcsmx(StringUtils.round(pepid.getNqxjclcsmx()+pewp.getRqxjclcsmx(),2));
  331. //年合计手动停机次数(明细)
  332. pewp.setNsdtjcsmx(StringUtils.round(pepid.getNsdtjcsmx()+pewp.getRsdtjcsmx(),2));
  333. //年合计性能次数(明细)
  334. pewp.setNbwcsmx(StringUtils.round(pepid.getNbwcsmx()+pewp.getRbwcsmx(),2));
  335. //年合计限电停机次数(明细)
  336. pewp.setNxdtjcsmx(StringUtils.round(pepid.getNxdtjcsmx()+pewp.getRxdtjcsmx(),2));
  337. //年合计限电降出力次数(明细)
  338. pewp.setNxdjclcsmx(StringUtils.round(pepid.getNxdjclcsmx()+pewp.getRxdjclcsmx(),2));
  339. //年合计场外受累电网次数(明细)
  340. pewp.setNcwsldwcsmx(StringUtils.round(pepid.getNcwsldwcsmx()+pewp.getRcwsldwcsmx(),2));
  341. //年合计场外受累电网次数(明细)
  342. pewp.setNcwsltqcsmx(StringUtils.round(pepid.getNcwsltqcsmx()+pewp.getRcwsltqcsmx(),2));
  343. //年合计通讯中断次数(明细)
  344. pewp.setNtxzdcsmx(StringUtils.round(pepid.getNtxzdcsmx()+pewp.getRtxzdcsmx(),2));
  345. //年合计离线次数(明细)
  346. pewp.setNlxcsmx(StringUtils.round(pepid.getNlxcsmx()+pewp.getRlxcsmx(),2));
  347. }
  348. }
  349. private static void setLossHoursYear(ProEconEquipmentInfoDay3 pewp) {
  350. //年合计故障次数(明细)
  351. pewp.setNgzcsmx(pewp.getRgzcsmx());
  352. //年合计场内受累故障次数(明细)
  353. pewp.setNcnslgzcsmx(pewp.getRcnslgzcsmx());
  354. //年合计检修次数(明细)
  355. pewp.setNjxcsmx(pewp.getRjxcsmx());
  356. //年合计场内受累检修次数(明细)
  357. pewp.setNcnsljxcsmx(pewp.getRcnsljxcsmx());
  358. //年合计待机次数(明细)
  359. pewp.setNdjcsmx(pewp.getRdjcsmx());
  360. //年合计缺陷降出力次数(明细)
  361. pewp.setNqxjclcsmx(pewp.getRqxjclcsmx());
  362. //年合计手动停机次数(明细)
  363. pewp.setNsdtjcsmx(pewp.getRsdtjcsmx());
  364. //年合计性能次数(明细)
  365. pewp.setNbwcsmx(pewp.getRbwcsmx());
  366. //年合计限电停机次数(明细)
  367. pewp.setNxdtjcsmx(pewp.getRxdtjcsmx());
  368. //年合计限电降出力次数(明细)
  369. pewp.setNxdjclcsmx(pewp.getRxdjclcsmx());
  370. //年合计场外受累电网次数(明细)
  371. pewp.setNcwsldwcsmx(pewp.getRcwsldwcsmx());
  372. //年合计场外受累电网次数(明细)
  373. pewp.setNcwsltqcsmx(pewp.getRcwsltqcsmx());
  374. //年合计通讯中断次数(明细)
  375. pewp.setNtxzdcsmx(pewp.getRtxzdcsmx());
  376. //年合计离线次数(明细)
  377. pewp.setNlxcsmx(pewp.getRlxcsmx());
  378. }
  379. private static void setLossHoursMonth(ProEconEquipmentInfoDay3 pewp) {
  380. //月合计故障次数(明细)
  381. pewp.setYgzcsmx(pewp.getRgzcsmx());
  382. //月合计场内受累故障次数(明细)
  383. pewp.setYcnslgzcsmx(pewp.getRcnslgzcsmx());
  384. //月合计检修次数(明细)
  385. pewp.setYjxcsmx(pewp.getRjxcsmx());
  386. //月合计场内受累检修次数(明细)
  387. pewp.setYcnsljxcsmx(pewp.getRcnsljxcsmx());
  388. //月合计待机次数(明细)
  389. pewp.setYdjcsmx(pewp.getRdjcsmx());
  390. //月合计缺陷降出力次数(明细)
  391. pewp.setYqxjclcsmx(pewp.getRqxjclcsmx());
  392. //月合计手动停机次数(明细)
  393. pewp.setYsdtjcsmx(pewp.getRsdtjcsmx());
  394. //月合计性能次数(明细)
  395. pewp.setYbwcsmx(pewp.getRbwcsmx());
  396. //月合计限电停机次数(明细)
  397. pewp.setYxdtjcsmx(pewp.getRxdtjcsmx());
  398. //月合计限电降出力次数(明细)
  399. pewp.setYxdjclcsmx(pewp.getRxdjclcsmx());
  400. //月合计场外受累电网次数(明细)
  401. pewp.setYcwsldwcsmx(pewp.getRcwsldwcsmx());
  402. //月合计场外受累电网次数(明细)
  403. pewp.setYcwsltqcsmx(pewp.getRcwsltqcsmx());
  404. //月合计通讯中断次数(明细)
  405. pewp.setYtxzdcsmx(pewp.getRtxzdcsmx());
  406. //月合计离线次数(明细)
  407. pewp.setYlxcsmx(pewp.getRlxcsmx());
  408. }
  409. private static void setLossHoursMonthSimple(ProEconEquipmentInfoDay3 pewp) {
  410. //月合计待机次数
  411. pewp.setYdjcs(pewp.getRdjcs());
  412. //月合计维护停机次数
  413. pewp.setYjxtjcs(pewp.getRjxtjcs());
  414. // 月合计故障停机次数
  415. pewp.setYgztjcs(pewp.getRgztjcs());
  416. //月合计运行次数
  417. pewp.setYyxcs(pewp.getRyxcs());
  418. //月合计限电次数
  419. pewp.setYxdcs(pewp.getRxdcs());
  420. //月合计通讯中断次数
  421. pewp.setYtxzdcs(pewp.getRtxzdcs());
  422. //月合计受累次数
  423. pewp.setYslcs(pewp.getRslcs());
  424. }
  425. private static void setLossHoursYearSimple(ProEconEquipmentInfoDay3 pewp) {
  426. //年合计待机次数
  427. pewp.setNdjcs(pewp.getRdjcs());
  428. //年合计维护停机次数
  429. pewp.setNjxtjcs(pewp.getRjxtjcs());
  430. // 年合计故障次数
  431. pewp.setNgztjcs(pewp.getRgztjcs());
  432. //年合计运行次数
  433. pewp.setNyxcs(pewp.getRyxcs());
  434. //年合计限电次数
  435. pewp.setNxdcs(pewp.getRxdcs());
  436. //年合计通讯中断次数
  437. pewp.setNtxzdcs(pewp.getRtxzdcs());
  438. //年合计受累次数
  439. pewp.setNslcs(pewp.getRslcs());
  440. }
  441. private void calSimple(ProEconEquipmentInfoDay3 pewp, Date end, Date begin, ProBasicEquipment wt, List<ProEconEquipmentInfoDay3> pepidls) throws Exception {
  442. // 0 待机
  443. // 1 运行
  444. // 2 故障
  445. // 3 检修
  446. // 4 限电
  447. // 5 受累
  448. // 6 离线
  449. //*******************************************日信息统计*********************************************************/
  450. double lastState=-1;//上一分钟状态
  451. double djcs=0;//待机时长
  452. double zcfdcs=0;//正常发电时长
  453. double gzcs=0;//故障时长
  454. double jxcs=0;//检修时长
  455. double xdtjcs=0;//限电停机时长
  456. double slsc=0;//受累时长
  457. double txzdcs=0;//通讯中断时长
  458. Map<String, Map<String, ProBasicEquipmentPoint>> wtpAimap = CacheContext.wtpAimap;
  459. Map<String, ProBasicEquipmentPoint> aimap=wtpAimap.get(wt.getId());
  460. if(aimap.containsKey(ContantXk.SBZT))
  461. {
  462. ProBasicEquipmentPoint point=aimap.get(ContantXk.SBZT);
  463. //按照分钟时间进行统计状态快照值
  464. List<PointData> pointls=edosUtil.getHistoryDatasSnap(point.getNemCode(), begin.getTime()/1000, end.getTime()/1000);
  465. if(!pointls.isEmpty()) {
  466. for (PointData po : pointls) {
  467. if (po.getPointValueInDouble() == 0) {
  468. if (lastState != po.getPointValueInDouble()) {
  469. //将当前状态保存到上一分钟状态
  470. lastState = po.getPointValueInDouble();
  471. //待机时长加1
  472. djcs++;
  473. }
  474. } else if (po.getPointValueInDouble() == 1) {
  475. if (lastState != po.getPointValueInDouble()) {
  476. //将当前状态保存到上一分钟状态
  477. lastState = po.getPointValueInDouble();
  478. //正常发电时长加1
  479. zcfdcs++;
  480. }
  481. } else if (po.getPointValueInDouble() == 2) {
  482. if (lastState != po.getPointValueInDouble()) {
  483. //将当前状态保存到上一分钟状态
  484. lastState = po.getPointValueInDouble();
  485. //故障时长加1
  486. gzcs++;
  487. }
  488. } else if (po.getPointValueInDouble() == 3) {
  489. if (lastState != po.getPointValueInDouble()) {
  490. //将当前状态保存到上一分钟状态
  491. lastState = po.getPointValueInDouble();
  492. //检修时长加1
  493. jxcs++;
  494. }
  495. } else if (po.getPointValueInDouble() == 4) {
  496. if (lastState != po.getPointValueInDouble()) {
  497. //将当前状态保存到上一分钟状态
  498. lastState = po.getPointValueInDouble();
  499. //限电停机时长加1
  500. xdtjcs++;
  501. }
  502. } else if (po.getPointValueInDouble() == 5) {
  503. if (lastState != po.getPointValueInDouble()) {
  504. //将当前状态保存到上一分钟状态
  505. lastState = po.getPointValueInDouble();
  506. //受累时长加1
  507. slsc++;
  508. }
  509. } else if (po.getPointValueInDouble() == 6) {
  510. if (lastState != po.getPointValueInDouble()) {
  511. //将当前状态保存到上一分钟状态
  512. lastState = po.getPointValueInDouble();
  513. //通讯中断时长加1
  514. txzdcs++;
  515. }
  516. }
  517. }
  518. }
  519. }
  520. //日合计待机次数
  521. pewp.setRdjcs(gzcs);
  522. //日合计维护停机次数
  523. pewp.setRjxtjcs(jxcs);
  524. // 日合计待机次数
  525. pewp.setRdjcs(djcs);
  526. //日合计运行次数
  527. pewp.setRyxcs(zcfdcs);
  528. //日合计限电次数
  529. pewp.setRxdcs(xdtjcs);
  530. //日合计通讯中断次数
  531. pewp.setRtxzdcs(txzdcs);
  532. //日合计受累次数
  533. pewp.setRslcs(slsc);
  534. //*******************************************日信息统计*********************************************************/
  535. //*******************************************月信息统计*********************************************************/
  536. if(pepidls.isEmpty())
  537. {
  538. setLossHoursMonthSimple(pewp);
  539. }else
  540. {
  541. ProEconEquipmentInfoDay3 pepid=pepidls.get(0);
  542. //月合计待机次数
  543. pewp.setYdjcs(StringUtils.round(pepid.getYdjcs()+pewp.getRdjcs(),2));
  544. //月合计维护停机次数
  545. pewp.setYjxtjcs(StringUtils.round(pepid.getYjxtjcs()+pewp.getRjxtjcs(),2));
  546. // 月合计故障次数
  547. pewp.setYgztjcs(StringUtils.round(pepid.getYgztjcs()+pewp.getRgztjcs(),2));
  548. //月合计运行次数
  549. pewp.setYyxcs(StringUtils.round(pepid.getYyxcs()+pewp.getRyxcs(),2));
  550. //月合计限电次数
  551. pewp.setYxdcs(StringUtils.round(pepid.getYxdcs()+pewp.getRxdcs(),2));
  552. //月合计通讯中断次数
  553. pewp.setYtxzdcs(StringUtils.round(pepid.getYtxzdcs()+pewp.getRtxzdcs(),2));
  554. //月合计受累次数
  555. pewp.setYslcs(StringUtils.round(pepid.getYslcs()+pewp.getRslcs(),2));
  556. }
  557. //*******************************************月信息统计*********************************************************/
  558. //*******************************************年信息统计*********************************************************/
  559. if(pepidls.isEmpty())
  560. {
  561. setLossHoursYearSimple(pewp);
  562. }else
  563. {
  564. ProEconEquipmentInfoDay3 pepid=pepidls.get(0);
  565. //年合计待机次数
  566. pewp.setNdjcs(StringUtils.round(pepid.getNdjcs()+pewp.getRdjcs(),2));
  567. //年合计维护停机次数
  568. pewp.setNjxtjcs(StringUtils.round(pepid.getNjxtjcs()+pewp.getRjxtjcs(),2));
  569. // 年合计故障次数
  570. pewp.setNgztjcs(StringUtils.round(pepid.getNgztjcs()+pewp.getRgztjcs(),2));
  571. //年合计运行次数
  572. pewp.setNyxcs(StringUtils.round(pepid.getNyxcs()+pewp.getRyxcs(),2));
  573. //年合计限电次数
  574. pewp.setNxdcs(StringUtils.round(pepid.getNxdcs()+pewp.getRxdcs(),2));
  575. //年合计通讯中断次数
  576. pewp.setNtxzdcs(StringUtils.round(pepid.getNtxzdcs()+pewp.getRtxzdcs(),2));
  577. //年合计受累次数
  578. pewp.setNslcs(StringUtils.round(pepid.getNslcs()+pewp.getRslcs(),2));
  579. }
  580. //*******************************************年信息统计*********************************************************/
  581. }
  582. }