EquipmentInfo4Service.java 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119
  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.service.auto.*;
  8. import com.gyee.generation.util.DateUtils;
  9. import com.gyee.generation.util.realtimesource.IEdosUtil;
  10. import com.gyee.generation.util.statisticcs.Initial;
  11. import org.springframework.stereotype.Service;
  12. import javax.annotation.Resource;
  13. import java.math.BigDecimal;
  14. import java.math.RoundingMode;
  15. import java.util.*;
  16. import java.util.stream.Collectors;
  17. @Service
  18. public class EquipmentInfo4Service {
  19. // private static final Logger logger = LoggerFactory.getLogger(EquipmentInfo4Service.class);
  20. @Resource
  21. private IEdosUtil edosUtil;
  22. @Resource
  23. private IProEconEquipmentInfoDay4Service proEconEquipmentInfoDay4Service;
  24. @Resource
  25. private IProEconEquipmentInfoDay2Service proEconEquipmentInfoDay2Service;
  26. @Resource
  27. private IProEconEquipmentInfoDay3Service proEconEquipmentInfoDay3Service;
  28. @Resource
  29. private IProEconInOrOutSpeedTotalService proEconInOrOutSpeedTotalService;
  30. @Resource
  31. private IProEconCurveFittingSubService proEconCurveFittingSubService;
  32. @Resource
  33. private IProEconCurveFittMonthSubService proEconCurveFittMonthSubService;
  34. @Resource
  35. private IProEconCurveFittYearSubService proEconCurveFittYearSubService;
  36. @Resource
  37. private IProEconCurveFittingMainService proEconCurveFittingMainService;
  38. @Resource
  39. private IProEconCurveFittMonthMainService proEconCurveFittMonthMainService;
  40. @Resource
  41. private IProEconCurveFittYearMainService proEconCurveFittYearMainService;
  42. @Resource
  43. private IProEconStateTransitionRatesService proEconStateTransitionRatesService;
  44. @Resource
  45. private IProEconFaultLiminatedefectsService proEconFaultLiminatedefectsService;
  46. @Resource
  47. private IProEconWindturbineGoodnessService proEconWindturbineGoodnessService;
  48. public void calEquipmentInfoDay(Date recordDate) throws Exception {
  49. Calendar c = Calendar.getInstance();
  50. c.setTime(recordDate);
  51. Date end = c.getTime();
  52. Date begin = DateUtils.truncate(c.getTime());
  53. //判断是否有重复记录,先删除重复记录
  54. List<String> idls = proEconEquipmentInfoDay4Service.list().stream()
  55. .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate)) == 0
  56. && CacheContext.wtmap.containsKey(i.getWindturbineId())
  57. ).map(ProEconEquipmentInfoDay4::getId)
  58. .collect(Collectors.toList());
  59. if (idls.size() > 0) {
  60. proEconEquipmentInfoDay4Service.removeByIds(idls);
  61. }
  62. //获取曲线风机切入风速
  63. Map<String, ProEconInOrOutSpeedTotal> peioomap = new HashMap<>();
  64. List<ProEconInOrOutSpeedTotal> peioostls = proEconInOrOutSpeedTotalService.list().stream().filter(i ->
  65. (i.getRecordDate().compareTo(begin) == 0 || i.getRecordDate().after(begin))
  66. && (i.getRecordDate().compareTo(end) == 0 || i.getRecordDate().before(end))
  67. ).collect(Collectors.toList());
  68. if (!peioostls.isEmpty()) {
  69. for (ProEconInOrOutSpeedTotal peioo : peioostls) {
  70. peioomap.put(peioo.getWindturbineId(), peioo);
  71. }
  72. }
  73. Map<String,ProEconWindturbineGoodness> wgmap=new HashMap<>();
  74. List<ProEconWindturbineGoodness> wgls = proEconWindturbineGoodnessService.list().stream()
  75. .filter(i -> i.getRecorddate().compareTo(DateUtils.truncate(begin))==0
  76. && CacheContext.wtmap.containsKey(i.getWindturbineid()))
  77. .collect(Collectors.toList());
  78. if(!wgls.isEmpty())
  79. {
  80. for(ProEconWindturbineGoodness wg:wgls)
  81. {
  82. wgmap.put(wg.getWindturbineid(),wg);
  83. }
  84. }
  85. // //功率一致性接口调用
  86. // Map<String, Map<String, Double>> glqxyizxMap = coefficientService.coefficient(begin);
  87. // //拟合优度接口调用
  88. // Map<String, Map<String, Double>> nhydMap = goodnessOfFitService.goodnessOfFit(begin);
  89. List<ProEconEquipmentInfoDay4> dayls=new ArrayList<>();
  90. for (ProBasicEquipment wt : CacheContext.wtls) {
  91. if (CacheContext.wtpAimap.containsKey(wt.getId())) {
  92. ProEconEquipmentInfoDay4 pewp = new ProEconEquipmentInfoDay4();
  93. Initial.initial(pewp);
  94. pewp.setCompanyId(wt.getCompanyId());
  95. pewp.setWindpowerstationId(wt.getWindpowerstationId());
  96. pewp.setLineId(wt.getLineId());
  97. pewp.setProjectId(wt.getProjectId());
  98. pewp.setRegionId(wt.getRegionId());
  99. pewp.setRecordDate(DateUtils.truncate(recordDate));
  100. pewp.setWindturbineId(wt.getId());
  101. //昨日的统计结果
  102. List<ProEconEquipmentInfoDay4> pepidls = new ArrayList<>();
  103. Calendar cl = Calendar.getInstance();
  104. cl.setTime(recordDate);
  105. cl.add(Calendar.DAY_OF_MONTH,-1);
  106. if (cl.get(Calendar.DAY_OF_MONTH) != 1) {
  107. pepidls = proEconEquipmentInfoDay4Service.list().stream()
  108. .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(cl.getTime())) == 0
  109. && i.getWindturbineId().equals(wt.getId())
  110. )
  111. .collect(Collectors.toList());
  112. }
  113. //获得当日设备统计2表数据
  114. ProEconEquipmentInfoDay2 pepid2 = null;
  115. List<ProEconEquipmentInfoDay2> pepid2ls;
  116. pepid2ls = proEconEquipmentInfoDay2Service.list().stream()
  117. .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(cl.getTime())) == 0
  118. && i.getWindturbineId().equals(wt.getId())
  119. ).collect(Collectors.toList());
  120. if (!pepid2ls.isEmpty()) {
  121. pepid2 = pepid2ls.get(0);
  122. }
  123. //获得当日设备统计3表数据
  124. ProEconEquipmentInfoDay3 pepid3 = null;
  125. List<ProEconEquipmentInfoDay3> pepid3ls;
  126. pepid3ls = proEconEquipmentInfoDay3Service.list().stream()
  127. .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(cl.getTime())) == 0
  128. && i.getWindturbineId().equals(wt.getId())
  129. ).collect(Collectors.toList());
  130. if (!pepid3ls.isEmpty()) {
  131. pepid3 = pepid3ls.get(0);
  132. }
  133. calDetiall(peioomap, pewp, end, begin, wt, pepidls, pepid2, pepid3, wgmap);
  134. dayls.add(pewp);
  135. // proEconEquipmentInfoDay1Service.save(pewp);
  136. }
  137. }
  138. proEconEquipmentInfoDay4Service.saveBatch(dayls);
  139. }
  140. private void calDetiall(Map<String, ProEconInOrOutSpeedTotal> peioomap, ProEconEquipmentInfoDay4 pewp, Date end, Date begin,
  141. ProBasicEquipment wt, List<ProEconEquipmentInfoDay4> pepidls, ProEconEquipmentInfoDay2 pepid2, ProEconEquipmentInfoDay3 pepid3,
  142. Map<String,ProEconWindturbineGoodness> wgmap) throws Exception {
  143. //*****************************************日信息统计*********************************************************/
  144. Map<String, ProBasicEquipmentPoint> wtpointmap = CacheContext.wtpAimap.get(wt.getId());
  145. ProEconInOrOutSpeedTotal peiost;
  146. //获得功率一致性系数
  147. if (wgmap.containsKey(wt.getId())) {
  148. ProEconWindturbineGoodness wg = wgmap.get(wt.getId());
  149. pewp.setRglyzxxs(wg.getDaycoefficient());
  150. }
  151. //获得拟合优度
  152. if (wgmap.containsKey(wt.getId())) {
  153. ProEconWindturbineGoodness wg = wgmap.get(wt.getId());
  154. pewp.setRnhyd(wg.getDaygoodness());
  155. }
  156. if (StringUtils.notEmp(pepid2)) {
  157. //获得日有效风时数
  158. pewp.setRyxfss(StringUtils.round(24 - pepid2.getRgzxsmx() - pepid2.getRjxxsmx(), 2));
  159. }
  160. if (StringUtils.notEmp(pepid2) && StringUtils.notEmp(pepid3)) {
  161. //故障小时
  162. double rgzxsmx = pepid2.getRgzxsmx();
  163. //故障次数
  164. double rgzcsmx = pepid3.getRgzcsmx();
  165. if (rgzcsmx != 0) {
  166. double mtbf = new BigDecimal(24).divide(new BigDecimal(rgzcsmx), 2, RoundingMode.HALF_EVEN).doubleValue();
  167. double mttr = new BigDecimal(rgzxsmx).divide(new BigDecimal(rgzcsmx), 2, RoundingMode.HALF_EVEN).doubleValue();
  168. double mttf = mtbf - mttr;
  169. pewp.setRmtbf(mtbf);
  170. pewp.setRmttr(mttr);
  171. pewp.setRmttf(mttf);
  172. } else {
  173. double mtbf = 24.0;
  174. double mttr = 0.0;
  175. double mttf = mtbf - mttr;
  176. pewp.setRmtbf(mtbf);
  177. pewp.setRmttr(mttr);
  178. pewp.setRmttf(mttf);
  179. }
  180. }
  181. if (peioomap.containsKey(wt.getId())) {
  182. //切入切出统计
  183. peiost = peioomap.get(wt.getId());
  184. //日小风切入风速
  185. pewp.setRxfqrfs(peiost.getDayInputSmall());
  186. //日小风切出风速
  187. pewp.setRxfqcfs(peiost.getDayOutputSmall());
  188. //日大风切入风速
  189. pewp.setRdfqrfs(peiost.getDayInputBig());
  190. //日大风切出风速
  191. pewp.setRdfqcfs(peiost.getDayOutputBig());
  192. if (StringUtils.notEmp(peiost)) {
  193. ProBasicEquipmentPoint point = wtpointmap.get(ContantXk.CJ_SSFS);
  194. //风速历史查询,每分钟一个点
  195. List<PointData> fsls = edosUtil.getHistoryDatasSnap(point.getNemCode(), begin.getTime() / 1000, end.getTime() / 1000);
  196. if (StringUtils.notEmp(peiost) && !fsls.isEmpty()) {
  197. double dayjfsc = 0.0;
  198. for (PointData po : fsls) {
  199. //小风切入风速
  200. double xfqr = peiost.getDayInputSmall();
  201. //小于小风切入算静风时长累计
  202. if (po.getPointValueInDouble() < xfqr) {
  203. dayjfsc++;
  204. }
  205. }
  206. //将分钟转化为小时
  207. dayjfsc = new BigDecimal(dayjfsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue();
  208. pewp.setRjfsc(dayjfsc);
  209. }
  210. if (CacheContext.modelMap.containsKey(wt.getModelId())) {
  211. ProEconEquipmentmodel model = CacheContext.modelMap.get(wt.getModelId());
  212. point = wtpointmap.get(ContantXk.CJ_SSGL);
  213. List<PointData> glls = edosUtil.getHistoryDatasSnap(point.getNemCode(), begin.getTime() / 1000, end.getTime() / 1000);
  214. double powerProduction = model.getPowerProduction();
  215. if (!glls.isEmpty() && glls.size() == fsls.size()) {
  216. for (int i = 0; i < glls.size(); i++) {
  217. //如果功率达到装机容量
  218. if (glls.get(i).getPointValueInDouble() >= powerProduction) {
  219. if (pewp.getRedfs() == 0) {
  220. //额定风速赋值
  221. pewp.setRedfs(fsls.get(i).getPointValueInDouble());
  222. } else if (pewp.getRedfs() > fsls.get(i).getPointValueInDouble()) {
  223. //额定风速赋值,比较风速大小,取最小值
  224. pewp.setRedfs(fsls.get(i).getPointValueInDouble());
  225. }
  226. }
  227. }
  228. }
  229. if (pewp.getRedfs() == 0) {
  230. //如果没有满发,额定风速赋值保证功率达到满发的对应风速
  231. pewp.setRedfs(11.0);
  232. }
  233. point = wtpointmap.get(ContantXk.BZGL);
  234. List<PointData> bzglls = edosUtil.getHistoryDatasSnap(point.getNemCode(), begin.getTime() / 1000, end.getTime() / 1000);
  235. if (!bzglls.isEmpty() && glls.size() == bzglls.size()) {
  236. double number = 0.0;
  237. for (int i = 0; i < bzglls.size(); i++) {
  238. double bzgl = bzglls.get(i).getPointValueInDouble();
  239. double sjgl = glls.get(i).getPointValueInDouble();
  240. //日对风偏差次数(-50 +50之间)
  241. if (Math.abs(bzgl - sjgl) < 50) {
  242. number++;
  243. }
  244. }
  245. pewp.setRdfpcl(number);
  246. }
  247. }
  248. }
  249. }
  250. List<ProEconCurveFittingMain> pecfmls = proEconCurveFittingMainService.list().stream().filter(i -> i.getRecordDate().compareTo(begin) == 0
  251. && i.getWindturbineId().equals(wt.getId())
  252. ).collect(Collectors.toList());
  253. if (!pecfmls.isEmpty()) {
  254. ProEconCurveFittingMain pecfm = pecfmls.get(0);
  255. pewp.setRqxpcbzysj(pecfm.getDeviationRate1());
  256. pewp.setRqxpcbbzsj(pecfm.getDeviationRate2());
  257. pewp.setRqxpcbzybz(pecfm.getDeviationRate3());
  258. pewp.setRqxpcbbg(pecfm.getStandardDeviationRate());
  259. pewp.setRqxpcbtb(pecfm.getYearDeviationRate());
  260. pewp.setRqxpcbhb(pecfm.getMonthDeviationRate());
  261. }
  262. //**************************************************日三率统计****************************************************************/
  263. List<ProEconStateTransitionRates> pestrls = proEconStateTransitionRatesService.list().stream()
  264. .filter(i -> i.getRecordDate().compareTo(begin) == 0 && i.getWindturbineId().equals(wt.getId())
  265. ).collect(Collectors.toList());
  266. //大于3米20分钟转换及时次数
  267. DoubleSummaryStatistics timerate8_summary = pestrls.stream().mapToDouble(ProEconStateTransitionRates::getTimerate8).summaryStatistics();
  268. //大于3米20分钟转换及时次数合计
  269. double timerate8_sum = timerate8_summary.getSum();
  270. //大于3米状态转换总次数次数
  271. DoubleSummaryStatistics timerate14_summary = pestrls.stream().mapToDouble(ProEconStateTransitionRates::getTimerate14).summaryStatistics();
  272. //大于3米状态转换总次数合计
  273. double timerate14_sum = timerate14_summary.getSum();
  274. if (timerate14_sum != 0) {
  275. //日状态转换及时率
  276. double temp = new BigDecimal(timerate8_sum).divide(new BigDecimal(timerate14_sum), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();
  277. pewp.setRztzhjsl(temp);
  278. } else {
  279. pewp.setRztzhjsl(100.0);
  280. }
  281. //20分钟复位及时次数
  282. DoubleSummaryStatistics timerate19_summary = pestrls.stream().mapToDouble(ProEconStateTransitionRates::getTimerate19).summaryStatistics();
  283. //20分钟复位及时次数合计
  284. double timerate19_sum = timerate19_summary.getSum();
  285. //总复位次数
  286. DoubleSummaryStatistics timerate20_summary = pestrls.stream().mapToDouble(ProEconStateTransitionRates::getTimerate20).summaryStatistics();
  287. //总复位次数合计
  288. double timerate20_sum = timerate20_summary.getSum();
  289. if (timerate20_sum != 0) {
  290. //日复位及时率
  291. double temp = new BigDecimal(timerate19_sum).divide(new BigDecimal(timerate20_sum), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();
  292. pewp.setRfwjsl(temp);
  293. } else {
  294. pewp.setRfwjsl(100.0);
  295. }
  296. List<ProEconFaultLiminatedefects> peflls=proEconFaultLiminatedefectsService.list().stream()
  297. .filter(i -> i.getDateTime().compareTo(begin) == 0 && i.getWindturbineId().equals(wt.getId())
  298. ).collect(Collectors.toList());
  299. //消缺及时次数
  300. DoubleSummaryStatistics right_summary = peflls.stream().mapToDouble(ProEconFaultLiminatedefects::getRightCount).summaryStatistics();
  301. //消缺及时次数合计
  302. double right_sum = right_summary.getSum();
  303. //故障次数次数
  304. DoubleSummaryStatistics fault_summary = peflls.stream().mapToDouble(ProEconFaultLiminatedefects::getFaultCount).summaryStatistics();
  305. //故障次数次数合计
  306. double fault_sum = fault_summary.getSum();
  307. if (fault_sum != 0) {
  308. //日消缺及时率
  309. double temp = new BigDecimal(right_sum).divide(new BigDecimal(fault_sum), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();
  310. pewp.setRgzxqjsl(temp);
  311. } else {
  312. pewp.setRgzxqjsl(100.0);
  313. }
  314. //**************************************************日三率统计****************************************************************/
  315. List<ProEconCurveFittingSub> pointls=proEconCurveFittingSubService.list().stream().filter(x-> x.getSpeed() !=null
  316. && Double.valueOf(x.getSpeed())>=3.0
  317. && Double.valueOf(x.getSpeed())<5.0
  318. && x.getRecordDate().compareTo(begin) == 0
  319. && x.getWindturbineId().equals(wt.getId())
  320. ).collect(Collectors.toList());
  321. DoubleSummaryStatistics summaryStatistics=pointls.stream().mapToDouble(ProEconCurveFittingSub::getDeviationRate1).summaryStatistics();
  322. pewp.setR35mqxpcl(summaryStatistics.getAverage());
  323. pointls=proEconCurveFittingSubService.list().stream().filter(x-> x.getSpeed() !=null
  324. && Double.valueOf(x.getSpeed())>=5.0
  325. && Double.valueOf(x.getSpeed())<11.0
  326. && x.getRecordDate().compareTo(begin) == 0
  327. && x.getWindturbineId().equals(wt.getId())
  328. ).collect(Collectors.toList());
  329. summaryStatistics=pointls.stream().mapToDouble(ProEconCurveFittingSub::getDeviationRate1).summaryStatistics();
  330. pewp.setR511mqxpcl(summaryStatistics.getAverage());
  331. pointls=proEconCurveFittingSubService.list().stream().filter(x-> x.getSpeed() !=null
  332. && Double.valueOf(x.getSpeed())>=11.0
  333. && x.getRecordDate().compareTo(begin) == 0
  334. && x.getWindturbineId().equals(wt.getId())
  335. ).collect(Collectors.toList());
  336. summaryStatistics=pointls.stream().mapToDouble(ProEconCurveFittingSub::getDeviationRate1).summaryStatistics();
  337. pewp.setR11mycqxpcl(summaryStatistics.getAverage());
  338. //*******************************************日信息统计*********************************************************/
  339. //*******************************************月信息统计*********************************************************/
  340. Calendar c = Calendar.getInstance();
  341. c.setTime(begin);
  342. String year = String.valueOf(c.get(Calendar.YEAR));
  343. String month = String.valueOf(c.get(Calendar.MONTH) + 1);
  344. if (pepidls.isEmpty()) {
  345. setEquipmentInfoDay4Month(pewp);
  346. } else {
  347. ProEconEquipmentInfoDay4 pepid = pepidls.get(0);
  348. //获得功率一致性系数
  349. if (wgmap.containsKey(wt.getId())) {
  350. ProEconWindturbineGoodness wg = wgmap.get(wt.getId());
  351. pewp.setYglyzxxs(wg.getMonthcoefficient());
  352. }
  353. //获得拟合优度
  354. if (wgmap.containsKey(wt.getId())) {
  355. ProEconWindturbineGoodness wg = wgmap.get(wt.getId());
  356. pewp.setYnhyd(wg.getMonthgoodness());
  357. }
  358. if (StringUtils.notEmp(pepid2)) {
  359. //获得日有效风时数
  360. pewp.setYyxfss(StringUtils.round(c.get(Calendar.DAY_OF_MONTH) * 24 - pepid2.getYgzxsmx() - pepid2.getYjxxsmx(), 2));
  361. }
  362. if (StringUtils.notEmp(pepid2) && StringUtils.notEmp(pepid3)) {
  363. //故障小时
  364. double ygzxsmx = pepid2.getYgzxsmx();
  365. //故障次数
  366. double ygzcsmx = pepid3.getYgzcsmx();
  367. if (ygzcsmx != 0) {
  368. double mtbf = new BigDecimal(c.get(Calendar.DAY_OF_MONTH) * 24).divide(new BigDecimal(ygzcsmx), 2, RoundingMode.HALF_EVEN).doubleValue();
  369. double mttr = new BigDecimal(ygzxsmx).divide(new BigDecimal(ygzcsmx), 2, RoundingMode.HALF_EVEN).doubleValue();
  370. double mttf = mtbf - mttr;
  371. pewp.setYmtbf(mtbf);
  372. pewp.setYmttr(mttr);
  373. pewp.setYmttf(mttf);
  374. } else {
  375. double mtbf = c.get(Calendar.DAY_OF_MONTH) * 24;
  376. double mttr = 0.0;
  377. double mttf = mtbf - mttr;
  378. pewp.setYmtbf(mtbf);
  379. pewp.setYmttr(mttr);
  380. pewp.setYmttf(mttf);
  381. }
  382. }
  383. if (peioomap.containsKey(wt.getId())) {
  384. //切入切出统计
  385. peiost = peioomap.get(wt.getId());
  386. //月小风切入风速
  387. pewp.setYxfqrfs(peiost.getMonthInputSmall());
  388. //月小风切出风速
  389. pewp.setYxfqcfs(peiost.getMonthOutputSmall());
  390. //月大风切入风速
  391. pewp.setYdfqrfs(peiost.getMonthInputBig());
  392. //月大风切出风速
  393. pewp.setYdfqcfs(peiost.getMonthOutputBig());
  394. if (StringUtils.notEmp(peiost)) {
  395. //静风时长累计
  396. pewp.setYjfsc(pewp.getYjfsc() + pepid.getRjfsc());
  397. if (pewp.getYedfs() == 0) {
  398. //如果没有满发,额定风速赋值保证功率达到满发的对应风速
  399. pewp.setYedfs(11.0);
  400. }
  401. if (pewp.getRedfs() < pepid.getYedfs()) {
  402. pewp.setYedfs(pewp.getRedfs());
  403. } else {
  404. pewp.setYedfs(pepid.getYedfs());
  405. }
  406. //月对风偏差次数(-50 +50之间)
  407. pewp.setYdfpcl(pepid.getYdfpcl() + pewp.getRdfpcl());
  408. }
  409. }
  410. List<ProEconCurveFittMonthMain> pecfmmls = proEconCurveFittMonthMainService.list().stream().filter(i -> i.getYear().equals(year) && i.getMonth().equals(month)
  411. && i.getWindturbineId().equals(wt.getId())
  412. ).collect(Collectors.toList());
  413. if (!pecfmmls.isEmpty()) {
  414. ProEconCurveFittMonthMain pecfm = pecfmmls.get(0);
  415. pewp.setYqxpcbzysj(pecfm.getDeviationRate1());
  416. pewp.setYqxpcbbzsj(pecfm.getDeviationRate2());
  417. pewp.setYqxpcbzybz(pecfm.getDeviationRate3());
  418. pewp.setYqxpcbbg(pecfm.getStandardDeviationRate());
  419. pewp.setYqxpcbtb(pecfm.getYearDeviationRate());
  420. pewp.setYqxpcbhb(pecfm.getMonthDeviationRate());
  421. }
  422. //************************************************月三率统计****************************************************************/
  423. Calendar cal = Calendar.getInstance();
  424. cal.setTime(begin);
  425. cal.set(Calendar.DAY_OF_MONTH, 1);
  426. Date monthbiegin = c.getTime();
  427. pestrls =proEconStateTransitionRatesService.list().stream()
  428. .filter(i ->
  429. (i.getRecordDate().compareTo(monthbiegin) == 0 || i.getRecordDate().after(monthbiegin))
  430. && (i.getRecordDate().compareTo(end) == 0 || i.getRecordDate().before(end))
  431. && i.getWindturbineId().equals(wt.getId())
  432. ).collect(Collectors.toList());
  433. //大于3米20分钟转换及时次数
  434. timerate8_summary = pestrls.stream().mapToDouble(ProEconStateTransitionRates::getTimerate8).summaryStatistics();
  435. //大于3米20分钟转换及时次数合计
  436. timerate8_sum = timerate8_summary.getSum();
  437. //大于3米状态转换总次数次数
  438. timerate14_summary = pestrls.stream().mapToDouble(ProEconStateTransitionRates::getTimerate14).summaryStatistics();
  439. //大于3米状态转换总次数合计
  440. timerate14_sum = timerate14_summary.getSum();
  441. if (timerate14_sum != 0) {
  442. //月状态转换及时率
  443. double temp = new BigDecimal(timerate8_sum).divide(new BigDecimal(timerate14_sum), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();
  444. pewp.setYztzhjsl(temp);
  445. } else {
  446. pewp.setYztzhjsl(100.0);
  447. }
  448. //20分钟复位及时次数
  449. timerate19_summary = pestrls.stream().mapToDouble(ProEconStateTransitionRates::getTimerate19).summaryStatistics();
  450. //20分钟复位及时次数合计
  451. timerate19_sum = timerate19_summary.getSum();
  452. //总复位次数
  453. timerate20_summary = pestrls.stream().mapToDouble(ProEconStateTransitionRates::getTimerate20).summaryStatistics();
  454. //总复位次数合计
  455. timerate20_sum = timerate20_summary.getSum();
  456. if (timerate20_sum != 0) {
  457. //月复位及时率
  458. double temp = new BigDecimal(timerate19_sum).divide(new BigDecimal(timerate20_sum), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();
  459. pewp.setYfwjsl(temp);
  460. } else {
  461. pewp.setYfwjsl(100.0);
  462. }
  463. peflls=proEconFaultLiminatedefectsService.list().stream()
  464. .filter(i ->
  465. (i.getDateTime().compareTo(monthbiegin) == 0 || i.getDateTime().after(monthbiegin))
  466. && (i.getDateTime().compareTo(end) == 0 || i.getDateTime().before(end))
  467. && i.getWindturbineId().equals(wt.getId())
  468. ).collect(Collectors.toList());
  469. //消缺及时次数
  470. right_summary = peflls.stream().mapToDouble(ProEconFaultLiminatedefects::getRightCount).summaryStatistics();
  471. //消缺及时次数合计
  472. right_sum = right_summary.getSum();
  473. //故障次数次数
  474. fault_summary = peflls.stream().mapToDouble(ProEconFaultLiminatedefects::getFaultCount).summaryStatistics();
  475. //故障次数次数合计
  476. fault_sum = fault_summary.getSum();
  477. if (fault_sum != 0) {
  478. //月消缺及时率
  479. double temp = new BigDecimal(right_sum).divide(new BigDecimal(fault_sum), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();
  480. pewp.setYgzxqjsl(temp);
  481. } else {
  482. pewp.setYgzxqjsl(100.0);
  483. }
  484. //**************************************************月三率统计****************************************************************/
  485. List<ProEconCurveFittMonthSub> monthpointls=proEconCurveFittMonthSubService.list().stream().filter(x-> x.getSpeed() !=null
  486. && Double.valueOf(x.getSpeed())>=3.0
  487. && Double.valueOf(x.getSpeed())<5.0
  488. && x.getYear().equals(year)
  489. && x.getMonth().equals(month)
  490. && x.getWindturbineId().equals(wt.getId())
  491. ).collect(Collectors.toList());
  492. summaryStatistics=monthpointls.stream().mapToDouble(ProEconCurveFittMonthSub::getDeviationRate1).summaryStatistics();
  493. pewp.setY35mqxpcl(summaryStatistics.getAverage());
  494. monthpointls=proEconCurveFittMonthSubService.list().stream().filter(x-> x.getSpeed() !=null
  495. && Double.valueOf(x.getSpeed())>=5.0
  496. && Double.valueOf(x.getSpeed())<11.0
  497. && x.getYear().equals(year)
  498. && x.getMonth().equals(month)
  499. && x.getWindturbineId().equals(wt.getId())
  500. ).collect(Collectors.toList());
  501. summaryStatistics=monthpointls.stream().mapToDouble(ProEconCurveFittMonthSub::getDeviationRate1).summaryStatistics();
  502. pewp.setY511mqxpcl(summaryStatistics.getAverage());
  503. monthpointls=proEconCurveFittMonthSubService.list().stream().filter(x-> x.getSpeed() !=null
  504. && Double.valueOf(x.getSpeed())>=11.0
  505. && x.getYear().equals(year)
  506. && x.getMonth().equals(month)
  507. && x.getWindturbineId().equals(wt.getId())
  508. ).collect(Collectors.toList());
  509. summaryStatistics=monthpointls.stream().mapToDouble(ProEconCurveFittMonthSub::getDeviationRate1).summaryStatistics();
  510. pewp.setY11mycqxpcl(summaryStatistics.getAverage());
  511. }
  512. //*******************************************月信息统计*********************************************************/
  513. //*******************************************年信息统计*********************************************************/
  514. if (pepidls.isEmpty()) {
  515. setEquipmentInfoDay4Year(pewp);
  516. } else {
  517. ProEconEquipmentInfoDay4 pepid = pepidls.get(0);
  518. //获得功率一致性系数
  519. if (wgmap.containsKey(wt.getId())) {
  520. ProEconWindturbineGoodness wg = wgmap.get(wt.getId());
  521. pewp.setNglyzxxs(wg.getYearcoefficient());
  522. }
  523. //获得拟合优度
  524. if (wgmap.containsKey(wt.getId())) {
  525. ProEconWindturbineGoodness wg = wgmap.get(wt.getId());
  526. pewp.setNnhyd(wg.getYeargoodness());
  527. }
  528. if (StringUtils.notEmp(pepid2)) {
  529. //获得日有效风时数
  530. pewp.setNyxfss(StringUtils.round(c.get(Calendar.DAY_OF_YEAR) * 24 - pepid2.getNgzxsmx() - pepid2.getNjxxsmx(), 2));
  531. }
  532. if (StringUtils.notEmp(pepid2) && StringUtils.notEmp(pepid3)) {
  533. //故障小时
  534. double ngzxsmx = pepid2.getYgzxsmx();
  535. //故障次数
  536. double ngzcsmx = pepid3.getYgzcsmx();
  537. if (ngzcsmx != 0) {
  538. double mtbf = new BigDecimal(c.get(Calendar.DAY_OF_YEAR) * 24).divide(new BigDecimal(ngzcsmx), 2, RoundingMode.HALF_EVEN).doubleValue();
  539. double mttr = new BigDecimal(ngzxsmx).divide(new BigDecimal(ngzcsmx), 2, RoundingMode.HALF_EVEN).doubleValue();
  540. double mttf = mtbf - mttr;
  541. pewp.setNmtbf(mtbf);
  542. pewp.setNmttr(mttr);
  543. pewp.setNmttf(mttf);
  544. } else {
  545. double mtbf = c.get(Calendar.DAY_OF_YEAR) * 24;
  546. double mttr = 0.0;
  547. double mttf = mtbf - mttr;
  548. pewp.setNmtbf(mtbf);
  549. pewp.setNmttr(mttr);
  550. pewp.setNmttf(mttf);
  551. }
  552. }
  553. if (peioomap.containsKey(wt.getId())) {
  554. //切入切出统计
  555. peiost = peioomap.get(wt.getId());
  556. //年小风切入风速
  557. pewp.setNxfqrfs(peiost.getYearInputSmall());
  558. //年小风切出风速
  559. pewp.setNxfqcfs(peiost.getYearOutputSmall());
  560. //年大风切入风速
  561. pewp.setNdfqrfs(peiost.getYearInputBig());
  562. //年大风切出风速
  563. pewp.setNdfqcfs(peiost.getYearOutputBig());
  564. if (StringUtils.notEmp(peiost)) {
  565. //静风时长累计
  566. pewp.setNjfsc(pewp.getNjfsc() + pepid.getRjfsc());
  567. if (pewp.getNedfs() == 0) {
  568. //如果没有满发,额定风速赋值保证功率达到满发的对应风速
  569. pewp.setNedfs(11.0);
  570. }
  571. if (pewp.getRedfs() < pepid.getNedfs()) {
  572. pewp.setNedfs(pewp.getRedfs());
  573. } else {
  574. pewp.setNedfs(pepid.getNedfs());
  575. }
  576. //月对风偏差次数(-50 +50之间)
  577. pewp.setNdfpcl(pepid.getNdfpcl() + pewp.getRdfpcl());
  578. }
  579. }
  580. List<ProEconCurveFittYearMain> pecfYmls = proEconCurveFittYearMainService.list().stream().filter(i -> i.getYear().equals(year)
  581. && i.getWindturbineId().equals(wt.getId())
  582. ).collect(Collectors.toList());
  583. if (!pecfYmls.isEmpty()) {
  584. ProEconCurveFittYearMain pecfm = pecfYmls.get(0);
  585. pewp.setNqxpcbzysj(pecfm.getDeviationRate1());
  586. pewp.setNqxpcbbzsj(pecfm.getDeviationRate2());
  587. pewp.setNqxpcbzybz(pecfm.getDeviationRate3());
  588. pewp.setNqxpcbbg(pecfm.getStandardDeviationRate());
  589. pewp.setNqxpcbtb(pecfm.getYearDeviationRate());
  590. pewp.setNqxpcbhb(pecfm.getMonthDeviationRate());
  591. }
  592. //************************************************年三率统计****************************************************************/
  593. Calendar cal = Calendar.getInstance();
  594. cal.setTime(begin);
  595. cal.set(Calendar.DAY_OF_YEAR, 1);
  596. Date yearbiegin = c.getTime();
  597. pestrls =proEconStateTransitionRatesService.list().stream()
  598. .filter(i ->
  599. (i.getRecordDate().compareTo(yearbiegin) == 0 || i.getRecordDate().after(yearbiegin))
  600. && (i.getRecordDate().compareTo(end) == 0 || i.getRecordDate().before(end))
  601. && i.getWindturbineId().equals(wt.getId())
  602. ).collect(Collectors.toList());
  603. //大于3米20分钟转换及时次数
  604. timerate8_summary =pestrls.stream().mapToDouble(ProEconStateTransitionRates::getTimerate8).summaryStatistics();
  605. //大于3米20分钟转换及时次数合计
  606. timerate8_sum = timerate8_summary.getSum();
  607. //大于3米状态转换总次数次数
  608. timerate14_summary = pestrls.stream().mapToDouble(ProEconStateTransitionRates::getTimerate14).summaryStatistics();
  609. //大于3米状态转换总次数合计
  610. timerate14_sum = timerate14_summary.getSum();
  611. if (timerate14_sum != 0) {
  612. //年状态转换及时率
  613. double temp = new BigDecimal(timerate8_sum).divide(new BigDecimal(timerate14_sum), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();
  614. pewp.setNztzhjsl(temp);
  615. } else {
  616. pewp.setNztzhjsl(100.0);
  617. }
  618. //20分钟复位及时次数
  619. timerate19_summary = pestrls.stream().mapToDouble(ProEconStateTransitionRates::getTimerate19).summaryStatistics();
  620. //20分钟复位及时次数合计
  621. timerate19_sum = timerate19_summary.getSum();
  622. //总复位次数
  623. timerate20_summary = pestrls.stream().mapToDouble(ProEconStateTransitionRates::getTimerate20).summaryStatistics();
  624. //总复位次数合计
  625. timerate20_sum = timerate20_summary.getSum();
  626. if (timerate20_sum != 0) {
  627. //年复位及时率
  628. double temp = new BigDecimal(timerate19_sum).divide(new BigDecimal(timerate20_sum), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();
  629. pewp.setNfwjsl(temp);
  630. } else {
  631. pewp.setNfwjsl(100.0);
  632. }
  633. peflls=proEconFaultLiminatedefectsService.list().stream()
  634. .filter(i ->
  635. (i.getDateTime().compareTo(yearbiegin) == 0 || i.getDateTime().after(yearbiegin))
  636. && (i.getDateTime().compareTo(end) == 0 || i.getDateTime().before(end))
  637. && i.getWindturbineId().equals(wt.getId())
  638. ).collect(Collectors.toList());
  639. //消缺及时次数
  640. right_summary = peflls.stream().mapToDouble(ProEconFaultLiminatedefects::getRightCount).summaryStatistics();
  641. //消缺及时次数合计
  642. right_sum = right_summary.getSum();
  643. //故障次数次数
  644. fault_summary = peflls.stream().mapToDouble(ProEconFaultLiminatedefects::getFaultCount).summaryStatistics();
  645. //故障次数次数合计
  646. fault_sum = fault_summary.getSum();
  647. if (fault_sum != 0) {
  648. //年消缺及时率
  649. double temp = new BigDecimal(right_sum).divide(new BigDecimal(fault_sum), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();
  650. pewp.setNgzxqjsl(temp);
  651. } else {
  652. pewp.setNgzxqjsl(100.0);
  653. }
  654. //**************************************************年三率统计****************************************************************/
  655. List<ProEconCurveFittYearSub> yearpointls=proEconCurveFittYearSubService.list().stream().filter(x-> x.getSpeed() !=null
  656. && Double.valueOf(x.getSpeed())>=3.0
  657. && Double.valueOf(x.getSpeed())<5.0
  658. && x.getYear().equals(year)
  659. && x.getWindturbineId().equals(wt.getId())
  660. ).collect(Collectors.toList());
  661. summaryStatistics=yearpointls.stream().mapToDouble(ProEconCurveFittYearSub::getDeviationRate1).summaryStatistics();
  662. pewp.setN35mqxpcl(summaryStatistics.getAverage());
  663. yearpointls=proEconCurveFittYearSubService.list().stream().filter(x-> x.getSpeed() !=null
  664. && Double.valueOf(x.getSpeed())>=5.0
  665. && Double.valueOf(x.getSpeed())<11.0
  666. && x.getYear().equals(year)
  667. && x.getWindturbineId().equals(wt.getId())
  668. ).collect(Collectors.toList());
  669. summaryStatistics=yearpointls.stream().mapToDouble(ProEconCurveFittYearSub::getDeviationRate1).summaryStatistics();
  670. pewp.setN511mqxpcl(summaryStatistics.getAverage());
  671. yearpointls=proEconCurveFittYearSubService.list().stream().filter(x-> x.getSpeed() !=null
  672. && Double.valueOf(x.getSpeed())>=11.0
  673. && x.getYear().equals(year)
  674. && x.getWindturbineId().equals(wt.getId())
  675. ).collect(Collectors.toList());
  676. summaryStatistics=yearpointls.stream().mapToDouble(ProEconCurveFittYearSub::getDeviationRate1).summaryStatistics();
  677. pewp.setN11mycqxpcl(summaryStatistics.getAverage());
  678. }
  679. }
  680. private static void setEquipmentInfoDay4Year(ProEconEquipmentInfoDay4 pewp) {
  681. //* 年静风时长
  682. pewp.setNjfsc(pewp.getRjfsc());
  683. //* 年有效风时数
  684. pewp.setNyxfss(pewp.getRyxfss());
  685. //* 年小风切入风速
  686. pewp.setNxfqrfs(pewp.getRxfqrfs());
  687. //* 年大风切入风速
  688. pewp.setNdfqrfs(pewp.getRdfqrfs());
  689. //* 年小风切出风速
  690. pewp.setNxfqcfs(pewp.getRxfqcfs());
  691. //* 年大风切出风速
  692. pewp.setNdfqcfs(pewp.getRdfqcfs());
  693. //* 年额定风速
  694. pewp.setNedfs(pewp.getRedfs());
  695. //* 年功率一致性系数
  696. pewp.setNglyzxxs(pewp.getRglyzxxs());
  697. //* 年拟合优度
  698. pewp.setNnhyd(pewp.getRnhyd());
  699. //* 年曲线偏差率最优保证
  700. pewp.setNqxpcbzybz(pewp.getRqxpcbzybz());
  701. //* 年曲线偏差率最优实际
  702. pewp.setNqxpcbzysj(pewp.getRqxpcbzysj());
  703. //* 年曲线偏差率保证实际
  704. pewp.setNqxpcbbzsj(pewp.getRqxpcbbzsj());
  705. //* 年曲线偏差率同比
  706. pewp.setNqxpcbtb(pewp.getRqxpcbtb());
  707. //* 年曲线偏差率环比
  708. pewp.setNqxpcbhb(pewp.getRqxpcbhb());
  709. //* 年曲线偏差率标杆
  710. pewp.setNqxpcbbg(pewp.getRqxpcbbg());
  711. //* 年3-5米曲线偏差率
  712. pewp.setN35mqxpcl(pewp.getR35mqxpcl());
  713. //* 年5-11米曲线偏差率
  714. pewp.setN511mqxpcl(pewp.getR511mqxpcl());
  715. //* 年11米以上曲线偏差率
  716. pewp.setN11mycqxpcl(pewp.getR11mycqxpcl());
  717. //* 年对风偏差率(-50 +50之间)
  718. pewp.setNdfpcl(pewp.getRdfpcl());
  719. //* 年MTBF
  720. pewp.setNmtbf(pewp.getRmtbf());
  721. //* 年MTTR
  722. pewp.setNmttr(pewp.getRmttr());
  723. //* 年MTTF
  724. pewp.setNmttf(pewp.getRmttf());
  725. //* 年复位及时率
  726. pewp.setNfwjsl(pewp.getRfwjsl());
  727. //* 年状态转换及时率
  728. pewp.setNztzhjsl(pewp.getRztzhjsl());
  729. //* 年故障消缺及时率
  730. pewp.setNgzxqjsl(pewp.getRgzxqjsl());
  731. }
  732. private static void setEquipmentInfoDay4Month(ProEconEquipmentInfoDay4 pewp) {
  733. //* 月静风时长
  734. pewp.setYjfsc(pewp.getRjfsc());
  735. //* 月有效风时数
  736. pewp.setYyxfss(pewp.getRyxfss());
  737. //* 月小风切入风速
  738. pewp.setYxfqrfs(pewp.getRxfqrfs());
  739. //* 月大风切入风速
  740. pewp.setYdfqrfs(pewp.getRdfqrfs());
  741. //* 月小风切出风速
  742. pewp.setYxfqcfs(pewp.getRxfqcfs());
  743. //* 月大风切出风速
  744. pewp.setYdfqcfs(pewp.getRdfqcfs());
  745. //* 月额定风速
  746. pewp.setYedfs(pewp.getRedfs());
  747. //* 月功率一致性系数
  748. pewp.setYglyzxxs(pewp.getRglyzxxs());
  749. //* 月拟合优度
  750. pewp.setYnhyd(pewp.getRnhyd());
  751. //* 月曲线偏差率最优保证
  752. pewp.setYqxpcbzybz(pewp.getRqxpcbzybz());
  753. //* 月曲线偏差率最优实际
  754. pewp.setYqxpcbzysj(pewp.getRqxpcbzysj());
  755. //* 月曲线偏差率保证实际
  756. pewp.setYqxpcbbzsj(pewp.getRqxpcbbzsj());
  757. //* 月曲线偏差率同比
  758. pewp.setYqxpcbtb(pewp.getRqxpcbtb());
  759. //* 月曲线偏差率环比
  760. pewp.setYqxpcbhb(pewp.getRqxpcbhb());
  761. //* 月曲线偏差率标杆
  762. pewp.setYqxpcbbg(pewp.getRqxpcbbg());
  763. //* 月3-5米曲线偏差率
  764. pewp.setY35mqxpcl(pewp.getR35mqxpcl());
  765. //* 月5-11米曲线偏差率
  766. pewp.setY511mqxpcl(pewp.getR511mqxpcl());
  767. //* 月11米以上曲线偏差率
  768. pewp.setY11mycqxpcl(pewp.getR11mycqxpcl());
  769. //* 月对风偏差率(-50 +50之间)
  770. pewp.setYdfpcl(pewp.getRdfpcl());
  771. //* 月MTBF
  772. pewp.setYmtbf(pewp.getRmtbf());
  773. //* 月MTTR
  774. pewp.setYmttr(pewp.getRmttr());
  775. //* 月MTTF
  776. pewp.setYmttf(pewp.getRmttf());
  777. //* 月复位及时率
  778. pewp.setYfwjsl(pewp.getRfwjsl());
  779. //* 月状态转换及时率
  780. pewp.setYztzhjsl(pewp.getRztzhjsl());
  781. // //* 月故障消缺及时率
  782. pewp.setYgzxqjsl(pewp.getRgzxqjsl());
  783. }
  784. }