EquipmentInfo4Service.java 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364
  1. package com.gyee.generation.service;//package com.gyee.generation.service;
  2. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  3. import com.gyee.common.contant.ContantXk;
  4. import com.gyee.common.model.PointData;
  5. import com.gyee.common.model.StringUtils;
  6. import com.gyee.generation.init.CacheContext;
  7. import com.gyee.generation.model.auto.*;
  8. import com.gyee.generation.service.auto.*;
  9. import com.gyee.generation.task.thread.EquipmentInfo4Thread;
  10. import com.gyee.generation.util.DateUtils;
  11. import com.gyee.generation.util.realtimesource.IEdosUtil;
  12. import org.springframework.stereotype.Service;
  13. import javax.annotation.Resource;
  14. import java.math.BigDecimal;
  15. import java.math.RoundingMode;
  16. import java.util.*;
  17. import java.util.concurrent.CountDownLatch;
  18. import java.util.concurrent.Executor;
  19. import java.util.stream.Collectors;
  20. @Service
  21. public class EquipmentInfo4Service {
  22. // private static final Logger logger = LoggerFactory.getLogger(EquipmentInfo4Service.class);
  23. @Resource
  24. private IEdosUtil edosUtil;
  25. @Resource
  26. private IProEconEquipmentInfoDay4Service proEconEquipmentInfoDay4Service;
  27. @Resource
  28. private IProEconEquipmentInfoDay2Service proEconEquipmentInfoDay2Service;
  29. @Resource
  30. private IProEconEquipmentInfoDay3Service proEconEquipmentInfoDay3Service;
  31. @Resource
  32. private IProEconInOrOutSpeedTotalService proEconInOrOutSpeedTotalService;
  33. @Resource
  34. private IProEconCurveFittingSubService proEconCurveFittingSubService;
  35. @Resource
  36. private IProEconCurveFittMonthSubService proEconCurveFittMonthSubService;
  37. @Resource
  38. private IProEconCurveFittYearSubService proEconCurveFittYearSubService;
  39. @Resource
  40. private IProEconCurveFittingMainService proEconCurveFittingMainService;
  41. @Resource
  42. private IProEconCurveFittMonthMainService proEconCurveFittMonthMainService;
  43. @Resource
  44. private IProEconCurveFittYearMainService proEconCurveFittYearMainService;
  45. @Resource
  46. private IProEconEquipmentInfoDay5Service proEconEquipmentInfoDay5Service;
  47. @Resource
  48. private IProEconFaultLiminatedefectsService proEconFaultLiminatedefectsService;
  49. @Resource
  50. private IProEconWindturbineGoodnessService proEconWindturbineGoodnessService;
  51. @Resource
  52. private Executor executor;
  53. public void calEquipmentInfoDay(Date recordDate) throws Exception {
  54. Calendar c = Calendar.getInstance();
  55. c.setTime(recordDate);
  56. if(c.get(Calendar.MINUTE)==0)
  57. {
  58. c.add(Calendar.DAY_OF_MONTH,-1);
  59. }
  60. c.set(Calendar.HOUR_OF_DAY, 23);
  61. c.set(Calendar.MINUTE, 59);
  62. c.set(Calendar.SECOND, 59);
  63. Date end = c.getTime();
  64. Date begin = DateUtils.truncate(c.getTime());
  65. Date lastDay=DateUtils.addDays(begin,-1);
  66. // //判断是否有重复记录,先删除重复记录
  67. // QueryWrapper<ProEconEquipmentInfoDay4> queryWrapper = new QueryWrapper<>();
  68. // queryWrapper.eq("record_date",begin);
  69. // List<String> idls = proEconEquipmentInfoDay4Service.list(queryWrapper).stream()
  70. // .map(ProEconEquipmentInfoDay4::getId)
  71. // .collect(Collectors.toList());
  72. //
  73. //// if (idls.size() > 0) {
  74. ////
  75. //// proEconEquipmentInfoDay4Service.removeByIds(idls);
  76. ////
  77. //// }
  78. // List<String> tempids=new ArrayList<>();
  79. //
  80. // for(int i=0;i<idls.size();i++)
  81. // {
  82. // tempids.add(idls.get(i));
  83. // if(tempids.size()==1000)
  84. // {
  85. // proEconEquipmentInfoDay4Service.removeByIds(tempids);
  86. // tempids=new ArrayList<>();
  87. // }
  88. // }
  89. //
  90. // if(!tempids.isEmpty())
  91. // {
  92. // proEconEquipmentInfoDay4Service.removeByIds(tempids);
  93. // }
  94. Map<String,ProEconEquipmentInfoDay2> pep2map=new HashMap<>();
  95. Map<String,ProEconEquipmentInfoDay3> pep3map=new HashMap<>();
  96. Map<String,ProEconEquipmentInfoDay4> pep4map=new HashMap<>();
  97. Calendar cl=Calendar.getInstance();
  98. cl.setTime(recordDate);
  99. if(cl.get(Calendar.DAY_OF_MONTH)!=1)
  100. {
  101. cl.add(Calendar.DAY_OF_MONTH,-1);
  102. QueryWrapper<ProEconEquipmentInfoDay2> queryWrapper2 = new QueryWrapper<>();
  103. queryWrapper2.eq("record_date",cl.getTime());
  104. List<ProEconEquipmentInfoDay2> pep2ls = proEconEquipmentInfoDay2Service.list(queryWrapper2);
  105. if(!pep2ls.isEmpty())
  106. {
  107. for(ProEconEquipmentInfoDay2 pep:pep2ls)
  108. {
  109. pep2map.put(pep.getWindturbineId(),pep);
  110. }
  111. }
  112. QueryWrapper<ProEconEquipmentInfoDay3> queryWrapper3 = new QueryWrapper<>();
  113. queryWrapper3.eq("record_date",cl.getTime());
  114. List<ProEconEquipmentInfoDay3> pep3ls = proEconEquipmentInfoDay3Service.list(queryWrapper3);
  115. if(!pep3ls.isEmpty())
  116. {
  117. for(ProEconEquipmentInfoDay3 pep:pep3ls)
  118. {
  119. pep3map.put(pep.getWindturbineId(),pep);
  120. }
  121. }
  122. QueryWrapper<ProEconEquipmentInfoDay4> queryWrapper4 = new QueryWrapper<>();
  123. queryWrapper4.eq("record_date",cl.getTime());
  124. List<ProEconEquipmentInfoDay4> pep4ls = proEconEquipmentInfoDay4Service.list(queryWrapper4);
  125. if(!pep4ls.isEmpty())
  126. {
  127. for(ProEconEquipmentInfoDay4 pep:pep4ls)
  128. {
  129. pep4map.put(pep.getWindturbineId(),pep);
  130. }
  131. }
  132. }
  133. //获取曲线风机切入风速
  134. Map<String, ProEconInOrOutSpeedTotal> peioomap = new HashMap<>();
  135. QueryWrapper<ProEconInOrOutSpeedTotal> queryWrapper2 = new QueryWrapper<>();
  136. queryWrapper2.eq("record_date",lastDay);
  137. List<ProEconInOrOutSpeedTotal> peioostls = proEconInOrOutSpeedTotalService.list(queryWrapper2);
  138. // .stream().filter(i ->
  139. // i.getRecordDate().compareTo(begin) == 0
  140. // ).collect(Collectors.toList());
  141. if (!peioostls.isEmpty()) {
  142. for (ProEconInOrOutSpeedTotal peioo : peioostls) {
  143. peioomap.put(peioo.getWindturbineId(), peioo);
  144. }
  145. }
  146. Map<String,ProEconWindturbineGoodness> wgmap=new HashMap<>();
  147. QueryWrapper<ProEconWindturbineGoodness> queryWrapper3 = new QueryWrapper<>();
  148. queryWrapper3.eq("record_date",lastDay);
  149. List<ProEconWindturbineGoodness> wgls = proEconWindturbineGoodnessService.list(queryWrapper3);
  150. // .stream()
  151. // .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(begin))==0
  152. // && CacheContext.wtmap.containsKey(i.getWindturbineId()))
  153. // .collect(Collectors.toList());
  154. if(!wgls.isEmpty())
  155. {
  156. for(ProEconWindturbineGoodness wg:wgls)
  157. {
  158. wgmap.put(wg.getWindturbineId(),wg);
  159. }
  160. }
  161. // //功率一致性接口调用
  162. // Map<String, Map<String, Double>> glqxyizxMap = coefficientService.coefficient(begin);
  163. // //拟合优度接口调用
  164. // Map<String, Map<String, Double>> nhydMap = goodnessOfFitService.goodnessOfFit(begin);
  165. List<ProEconEquipmentInfoDay4> dayls=new ArrayList<>();
  166. List<String> wpls=new ArrayList<>();
  167. // final CountDownLatch latch = new CountDownLatch(CacheContext.wt_fjls.size());
  168. // for (ProBasicEquipment wt : CacheContext.wt_fjls) {
  169. // if(!wpls.contains(wt.getWindpowerstationId()))
  170. // {
  171. // wpls.add(wt.getWindpowerstationId());
  172. // }
  173. //
  174. // new Thread(new EquipmentInfo4Thread(executor,wt, pep2map,
  175. // pep3map,
  176. // pep4map,
  177. // recordDate, end, begin, dayls,
  178. // edosUtil, peioomap,
  179. // wgmap,
  180. // proEconCurveFittingMainService,
  181. // proEconEquipmentInfoDay5Service,
  182. // proEconFaultLiminatedefectsService,
  183. // proEconCurveFittingSubService,
  184. // proEconCurveFittMonthMainService,
  185. // proEconCurveFittMonthSubService,
  186. // proEconCurveFittYearMainService,
  187. // proEconCurveFittYearSubService,latch)).start();
  188. // }
  189. //
  190. // latch.await();
  191. for (Map.Entry<String, List<ProBasicEquipment>> entry : CacheContext.wpwtmap.entrySet()) {
  192. if(entry.getKey().contains("FDC"))
  193. {
  194. final CountDownLatch latch = new CountDownLatch(entry.getValue().size());
  195. for (ProBasicEquipment wt : entry.getValue()) {
  196. if (!wpls.contains(wt.getWindpowerstationId())) {
  197. wpls.add(wt.getWindpowerstationId());
  198. }
  199. new Thread(new EquipmentInfo4Thread(executor,wt, pep2map,
  200. pep3map,
  201. pep4map,
  202. recordDate, end, begin, dayls,
  203. edosUtil, peioomap,
  204. wgmap,
  205. proEconCurveFittingMainService,
  206. proEconEquipmentInfoDay5Service,
  207. proEconFaultLiminatedefectsService,
  208. proEconCurveFittingSubService,
  209. proEconCurveFittMonthMainService,
  210. proEconCurveFittMonthSubService,
  211. proEconCurveFittYearMainService,
  212. proEconCurveFittYearSubService,latch)).start();
  213. }
  214. latch.await();
  215. }
  216. }
  217. c = Calendar.getInstance();
  218. c.setTime(recordDate);
  219. begin = DateUtils.truncate(c.getTime());
  220. //判断是否有重复记录,先删除重复记录
  221. QueryWrapper<ProEconEquipmentInfoDay4> queryWrapper = new QueryWrapper<>();
  222. queryWrapper.eq("record_date",begin);
  223. queryWrapper.in("windpowerstation_id",wpls);
  224. List<String> idls = proEconEquipmentInfoDay4Service.list(queryWrapper).stream()
  225. .map(ProEconEquipmentInfoDay4::getId)
  226. .collect(Collectors.toList());
  227. List<String> tempids=new ArrayList<>();
  228. for(int i=0;i<idls.size();i++)
  229. {
  230. tempids.add(idls.get(i));
  231. if(tempids.size()==1000)
  232. {
  233. proEconEquipmentInfoDay4Service.removeByIds(tempids);
  234. tempids=new ArrayList<>();
  235. }
  236. }
  237. if(!tempids.isEmpty())
  238. {
  239. proEconEquipmentInfoDay4Service.removeByIds(tempids);
  240. }
  241. List<ProEconEquipmentInfoDay4> templs=new ArrayList<>();
  242. for(ProEconEquipmentInfoDay4 vo:dayls)
  243. {
  244. if(StringUtils.notEmp(vo) && StringUtils.notEmp(vo.getWindturbineId()))
  245. {
  246. templs.add(vo);
  247. if(templs.size()==1000)
  248. {
  249. proEconEquipmentInfoDay4Service.saveBatch(templs);
  250. templs=new ArrayList<>();
  251. }
  252. }
  253. }
  254. if(!templs.isEmpty())
  255. {
  256. proEconEquipmentInfoDay4Service.saveBatch(templs);
  257. }
  258. // proEconEquipmentInfoDay4Service.saveBatch(dayls);
  259. }
  260. private void calDetiall(Map<String, ProEconInOrOutSpeedTotal> peioomap, ProEconEquipmentInfoDay4 pewp, Date end, Date begin,
  261. ProBasicEquipment wt, List<ProEconEquipmentInfoDay4> pepidls, ProEconEquipmentInfoDay2 pepid2, ProEconEquipmentInfoDay3 pepid3,
  262. Map<String,ProEconWindturbineGoodness> wgmap) throws Exception {
  263. //*****************************************日信息统计*********************************************************/
  264. Map<String, ProBasicEquipmentPoint> wtpointmap = CacheContext.wtpAimap.get(wt.getId());
  265. ProEconInOrOutSpeedTotal peiost;
  266. //获得功率一致性系数
  267. if (wgmap.containsKey(wt.getId())) {
  268. ProEconWindturbineGoodness wg = wgmap.get(wt.getId());
  269. pewp.setRglyzxxs(wg.getDayCoefficient());
  270. }
  271. //获得拟合优度
  272. if (wgmap.containsKey(wt.getId())) {
  273. ProEconWindturbineGoodness wg = wgmap.get(wt.getId());
  274. pewp.setRnhyd(wg.getDayGoodness());
  275. }
  276. if (StringUtils.notEmp(pepid2)) {
  277. //获得日有效风时数
  278. pewp.setRyxfss(StringUtils.round(24 - pepid2.getRgzxsmx() - pepid2.getRjxxsmx(), 2));
  279. }
  280. if (StringUtils.notEmp(pepid2) && StringUtils.notEmp(pepid3)) {
  281. //故障小时
  282. double rgzxsmx = pepid2.getRgzxsmx();
  283. //故障次数
  284. double rgzcsmx = pepid3.getRgzcsmx();
  285. if (rgzcsmx != 0) {
  286. double mtbf = new BigDecimal(24).divide(new BigDecimal(rgzcsmx), 2, RoundingMode.HALF_EVEN).doubleValue();
  287. double mttr = new BigDecimal(rgzxsmx).divide(new BigDecimal(rgzcsmx), 2, RoundingMode.HALF_EVEN).doubleValue();
  288. double mttf = mtbf - mttr;
  289. pewp.setRmtbf(mtbf);
  290. pewp.setRmttr(mttr);
  291. pewp.setRmttf(mttf);
  292. } else {
  293. double mtbf = 24.0;
  294. double mttr = 0.0;
  295. double mttf = mtbf - mttr;
  296. pewp.setRmtbf(mtbf);
  297. pewp.setRmttr(mttr);
  298. pewp.setRmttf(mttf);
  299. }
  300. }
  301. if (peioomap.containsKey(wt.getId())) {
  302. //切入切出统计
  303. peiost = peioomap.get(wt.getId());
  304. //日小风切入风速
  305. pewp.setRxfqrfs(peiost.getDayInputSmall());
  306. //日小风切出风速
  307. pewp.setRxfqcfs(peiost.getDayOutputSmall());
  308. //日大风切入风速
  309. pewp.setRdfqrfs(peiost.getDayInputBig());
  310. //日大风切出风速
  311. pewp.setRdfqcfs(peiost.getDayOutputBig());
  312. if (StringUtils.notEmp(peiost)) {
  313. ProBasicEquipmentPoint point = wtpointmap.get(ContantXk.CJ_SSFS);
  314. //风速历史查询,每分钟一个点
  315. List<PointData> fsls = edosUtil.getHistoryDatasSnap(point.getNemCode(), begin.getTime() / 1000, end.getTime() / 1000);
  316. if (StringUtils.notEmp(peiost) && !fsls.isEmpty()) {
  317. double dayjfsc = 0.0;
  318. for (PointData po : fsls) {
  319. // //小风切入风速
  320. // double xfqr = peiost.getDayInputSmall();
  321. // //小于小风切入算静风时长累计
  322. if (po.getPointValueInDouble() < 3) {
  323. dayjfsc++;
  324. }
  325. }
  326. //将分钟转化为小时
  327. dayjfsc = new BigDecimal(dayjfsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue();
  328. pewp.setRjfsc(dayjfsc);
  329. }
  330. if (CacheContext.modelMap.containsKey(wt.getModelId())) {
  331. ProEconEquipmentmodel model = CacheContext.modelMap.get(wt.getModelId());
  332. point = wtpointmap.get(ContantXk.CJ_SSGL);
  333. List<PointData> glls = edosUtil.getHistoryDatasSnap(point.getNemCode(), begin.getTime() / 1000, end.getTime() / 1000);
  334. double powerProduction = model.getPowerProduction();
  335. if (!glls.isEmpty() && glls.size() == fsls.size()) {
  336. for (int i = 0; i < glls.size(); i++) {
  337. //如果功率达到装机容量
  338. if (glls.get(i).getPointValueInDouble() >= powerProduction) {
  339. if (pewp.getRedfs() == 0) {
  340. //额定风速赋值
  341. pewp.setRedfs(fsls.get(i).getPointValueInDouble());
  342. } else if (pewp.getRedfs() > fsls.get(i).getPointValueInDouble()) {
  343. //额定风速赋值,比较风速大小,取最小值
  344. pewp.setRedfs(fsls.get(i).getPointValueInDouble());
  345. }
  346. }
  347. }
  348. }
  349. if (pewp.getRedfs() == 0) {
  350. //如果没有满发,额定风速赋值保证功率达到满发的对应风速
  351. pewp.setRedfs(11.0);
  352. }
  353. point = wtpointmap.get(ContantXk.BZGL);
  354. List<PointData> bzglls = edosUtil.getHistoryDatasSnap(point.getNemCode(), begin.getTime() / 1000, end.getTime() / 1000);
  355. point = wtpointmap.get(ContantXk.CJ_FX);
  356. List<PointData> fxls = edosUtil.getHistoryDatasSnap(point.getNemCode(), begin.getTime() / 1000, end.getTime() / 1000);
  357. if (!bzglls.isEmpty() && !fsls.isEmpty() && glls.size() == bzglls.size() && fsls.size() == bzglls.size()) {
  358. double number = 0.0;
  359. double totalnumbere=0.0;
  360. double lastvalue=-1;
  361. for (int i = 0; i < fxls.size(); i++) {
  362. double bzgl = bzglls.get(i).getPointValueInDouble();
  363. double sjgl = glls.get(i).getPointValueInDouble();
  364. double fx = fxls.get(i).getPointValueInDouble();
  365. if(lastvalue!=fx)
  366. {
  367. //日对风偏差大于(-50 +50之间)
  368. if (Math.abs(bzgl - sjgl) > 50) {
  369. //日对风偏差次数
  370. number++;
  371. }
  372. //对风次数
  373. totalnumbere++;
  374. }
  375. }
  376. if(totalnumbere!=0)
  377. {
  378. double dfpcl = new BigDecimal(number).divide(new BigDecimal(totalnumbere), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();
  379. pewp.setRdfpcl(dfpcl);
  380. }else
  381. {
  382. pewp.setRdfpcl(0.0);
  383. }
  384. }
  385. }
  386. }
  387. }
  388. QueryWrapper<ProEconCurveFittingMain> queryWrapper = new QueryWrapper<>();
  389. queryWrapper.eq("record_date",begin).eq("windturbine_id",wt.getId());
  390. List<ProEconCurveFittingMain> pecfmls = proEconCurveFittingMainService.list(queryWrapper);
  391. // .stream().filter(i -> i.getRecordDate().compareTo(begin) == 0
  392. // && i.getWindturbineId().equals(wt.getId())
  393. // ).collect(Collectors.toList());
  394. if (!pecfmls.isEmpty()) {
  395. ProEconCurveFittingMain pecfm = pecfmls.get(0);
  396. pewp.setRqxpcbzysj(pecfm.getDeviationRate1());
  397. pewp.setRqxpcbbzsj(pecfm.getDeviationRate2());
  398. pewp.setRqxpcbzybz(pecfm.getDeviationRate3());
  399. pewp.setRqxpcbbg(pecfm.getStandardDeviationRate());
  400. pewp.setRqxpcbtb(pecfm.getYearDeviationRate());
  401. pewp.setRqxpcbhb(pecfm.getMonthDeviationRate());
  402. }
  403. //**************************************************日三率统计****************************************************************/
  404. QueryWrapper<ProEconEquipmentInfoDay5> queryWrapper2 = new QueryWrapper<>();
  405. queryWrapper2.eq("record_date",begin).eq("windturbine_id",wt.getId());
  406. List<ProEconEquipmentInfoDay5> pestrls = proEconEquipmentInfoDay5Service.list(queryWrapper2);
  407. // .stream()
  408. // .filter(i -> i.getRecordDate().compareTo(begin) == 0 && i.getWindturbineId().equals(wt.getId())
  409. // ).collect(Collectors.toList());
  410. //大于3米20分钟转换及时次数
  411. DoubleSummaryStatistics timerate8_summary = pestrls.stream().mapToDouble(ProEconEquipmentInfoDay5::getTimerate8).summaryStatistics();
  412. //大于3米20分钟转换及时次数合计
  413. double timerate8_sum = timerate8_summary.getSum();
  414. //大于3米状态转换总次数次数
  415. DoubleSummaryStatistics timerate14_summary = pestrls.stream().mapToDouble(ProEconEquipmentInfoDay5::getTimerate14).summaryStatistics();
  416. //大于3米状态转换总次数合计
  417. double timerate14_sum = timerate14_summary.getSum();
  418. if (timerate14_sum != 0) {
  419. //日状态转换及时率
  420. double temp = new BigDecimal(timerate8_sum).divide(new BigDecimal(timerate14_sum), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();
  421. pewp.setRztzhjsl(temp);
  422. } else {
  423. pewp.setRztzhjsl(100.0);
  424. }
  425. //20分钟复位及时次数
  426. DoubleSummaryStatistics timerate19_summary = pestrls.stream().mapToDouble(ProEconEquipmentInfoDay5::getTimerate19).summaryStatistics();
  427. //20分钟复位及时次数合计
  428. double timerate19_sum = timerate19_summary.getSum();
  429. //总复位次数
  430. DoubleSummaryStatistics timerate20_summary = pestrls.stream().mapToDouble(ProEconEquipmentInfoDay5::getTimerate20).summaryStatistics();
  431. //总复位次数合计
  432. double timerate20_sum = timerate20_summary.getSum();
  433. if (timerate20_sum != 0) {
  434. //日复位及时率
  435. double temp = new BigDecimal(timerate19_sum).divide(new BigDecimal(timerate20_sum), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();
  436. pewp.setRfwjsl(temp);
  437. } else {
  438. pewp.setRfwjsl(100.0);
  439. }
  440. QueryWrapper<ProEconFaultLiminatedefects> queryWrapper3 = new QueryWrapper<>();
  441. queryWrapper3.ge("date_time",begin).le("date_time",end).eq("windturbine_id",wt.getId());
  442. List<ProEconFaultLiminatedefects> peflls=proEconFaultLiminatedefectsService.list(queryWrapper3);
  443. // .stream()
  444. // .filter(i -> i.getDateTime().compareTo(begin) == 0 && i.getWindturbineId().equals(wt.getId())
  445. // ).collect(Collectors.toList());
  446. //消缺及时次数
  447. DoubleSummaryStatistics right_summary = peflls.stream().mapToDouble(ProEconFaultLiminatedefects::getRightCount).summaryStatistics();
  448. //消缺及时次数合计
  449. double right_sum = right_summary.getSum();
  450. //故障次数次数
  451. DoubleSummaryStatistics fault_summary = peflls.stream().mapToDouble(ProEconFaultLiminatedefects::getFaultCount).summaryStatistics();
  452. //故障次数次数合计
  453. double fault_sum = fault_summary.getSum();
  454. if (fault_sum != 0) {
  455. //日消缺及时率
  456. double temp = new BigDecimal(right_sum).divide(new BigDecimal(fault_sum), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();
  457. pewp.setRgzxqjsl(temp);
  458. } else {
  459. pewp.setRgzxqjsl(100.0);
  460. }
  461. //**************************************************日三率统计****************************************************************/
  462. QueryWrapper<ProEconCurveFittingSub> queryWrapper6 = new QueryWrapper<>();
  463. queryWrapper6.eq("record_date",begin).isNotNull("speed")
  464. .lt("speed",5.0)
  465. .ge("speed",3.0)
  466. .eq("windturbine_id",wt.getId());
  467. List<ProEconCurveFittingSub> pointls=proEconCurveFittingSubService.list(queryWrapper6);
  468. // .stream().filter(x-> x.getSpeed() !=null
  469. // && Double.valueOf(x.getSpeed())>=3.0
  470. // && Double.valueOf(x.getSpeed())<5.0
  471. // && x.getRecordDate().compareTo(begin) == 0
  472. // && x.getWindturbineId().equals(wt.getId())
  473. // ).collect(Collectors.toList());
  474. DoubleSummaryStatistics summaryStatistics=pointls.stream().mapToDouble(ProEconCurveFittingSub::getDeviationRate1).summaryStatistics();
  475. pewp.setR35mqxpcl(summaryStatistics.getAverage());
  476. queryWrapper6 = new QueryWrapper<>();
  477. queryWrapper6.eq("record_date",begin).isNotNull("speed")
  478. .lt("speed",11.0)
  479. .ge("speed",5.0)
  480. .eq("windturbine_id",wt.getId());
  481. pointls=proEconCurveFittingSubService.list(queryWrapper6);
  482. // .stream().filter(x-> x.getSpeed() !=null
  483. // && Double.valueOf(x.getSpeed())>=5.0
  484. // && Double.valueOf(x.getSpeed())<11.0
  485. // && x.getRecordDate().compareTo(begin) == 0
  486. // && x.getWindturbineId().equals(wt.getId())
  487. // ).collect(Collectors.toList());
  488. summaryStatistics=pointls.stream().mapToDouble(ProEconCurveFittingSub::getDeviationRate1).summaryStatistics();
  489. pewp.setR511mqxpcl(summaryStatistics.getAverage());
  490. queryWrapper6 = new QueryWrapper<>();
  491. queryWrapper6.eq("record_date",begin).isNotNull("speed")
  492. .ge("speed",11.0)
  493. .eq("windturbine_id",wt.getId());
  494. pointls=proEconCurveFittingSubService.list(queryWrapper6);
  495. // .stream().filter(x-> x.getSpeed() !=null
  496. // && Double.valueOf(x.getSpeed())>=11.0
  497. // && x.getRecordDate().compareTo(begin) == 0
  498. // && x.getWindturbineId().equals(wt.getId())
  499. // ).collect(Collectors.toList());
  500. summaryStatistics=pointls.stream().mapToDouble(ProEconCurveFittingSub::getDeviationRate1).summaryStatistics();
  501. pewp.setR11mycqxpcl(summaryStatistics.getAverage());
  502. //*******************************************日信息统计*********************************************************/
  503. //*******************************************月信息统计*********************************************************/
  504. Calendar c = Calendar.getInstance();
  505. c.setTime(begin);
  506. String year = String.valueOf(c.get(Calendar.YEAR));
  507. String month = String.valueOf(c.get(Calendar.MONTH) + 1);
  508. if (pepidls.isEmpty()) {
  509. setEquipmentInfoDay4Month(pewp);
  510. } else {
  511. ProEconEquipmentInfoDay4 pepid = pepidls.get(0);
  512. //获得功率一致性系数
  513. if (wgmap.containsKey(wt.getId())) {
  514. ProEconWindturbineGoodness wg = wgmap.get(wt.getId());
  515. pewp.setYglyzxxs(wg.getMonthCoefficient());
  516. }
  517. //获得拟合优度
  518. if (wgmap.containsKey(wt.getId())) {
  519. ProEconWindturbineGoodness wg = wgmap.get(wt.getId());
  520. pewp.setYnhyd(wg.getMonthGoodness());
  521. }
  522. if (StringUtils.notEmp(pepid2)) {
  523. //获得日有效风时数
  524. pewp.setYyxfss(StringUtils.round(c.get(Calendar.DAY_OF_MONTH) * 24 - pepid2.getYgzxsmx() - pepid2.getYjxxsmx(), 2));
  525. }
  526. if (StringUtils.notEmp(pepid2) && StringUtils.notEmp(pepid3)) {
  527. //故障小时
  528. double ygzxsmx = pepid2.getYgzxsmx();
  529. //故障次数
  530. double ygzcsmx = pepid3.getYgzcsmx();
  531. if (ygzcsmx != 0) {
  532. double mtbf = new BigDecimal(c.get(Calendar.DAY_OF_MONTH) * 24).divide(new BigDecimal(ygzcsmx), 2, RoundingMode.HALF_EVEN).doubleValue();
  533. double mttr = new BigDecimal(ygzxsmx).divide(new BigDecimal(ygzcsmx), 2, RoundingMode.HALF_EVEN).doubleValue();
  534. double mttf = mtbf - mttr;
  535. pewp.setYmtbf(mtbf);
  536. pewp.setYmttr(mttr);
  537. pewp.setYmttf(mttf);
  538. } else {
  539. double mtbf = c.get(Calendar.DAY_OF_MONTH) * 24;
  540. double mttr = 0.0;
  541. double mttf = mtbf - mttr;
  542. pewp.setYmtbf(mtbf);
  543. pewp.setYmttr(mttr);
  544. pewp.setYmttf(mttf);
  545. }
  546. }
  547. if (peioomap.containsKey(wt.getId())) {
  548. //切入切出统计
  549. peiost = peioomap.get(wt.getId());
  550. //月小风切入风速
  551. pewp.setYxfqrfs(peiost.getMonthInputSmall());
  552. //月小风切出风速
  553. pewp.setYxfqcfs(peiost.getMonthOutputSmall());
  554. //月大风切入风速
  555. pewp.setYdfqrfs(peiost.getMonthInputBig());
  556. //月大风切出风速
  557. pewp.setYdfqcfs(peiost.getMonthOutputBig());
  558. if (StringUtils.notEmp(peiost)) {
  559. //静风时长累计
  560. pewp.setYjfsc(pewp.getYjfsc() + pepid.getRjfsc());
  561. if (pewp.getYedfs() == 0) {
  562. //如果没有满发,额定风速赋值保证功率达到满发的对应风速
  563. pewp.setYedfs(11.0);
  564. }
  565. if (pewp.getRedfs() < pepid.getYedfs()) {
  566. pewp.setYedfs(pewp.getRedfs());
  567. } else {
  568. pewp.setYedfs(pepid.getYedfs());
  569. }
  570. //月对风偏差次数(-50 +50之间)
  571. pewp.setYdfpcl(pepid.getYdfpcl() + pewp.getRdfpcl());
  572. }
  573. }
  574. QueryWrapper<ProEconCurveFittMonthMain> queryWrapper4 = new QueryWrapper<>();
  575. queryWrapper4.eq("year",year).eq("month",month).eq("windturbine_id",wt.getId());
  576. List<ProEconCurveFittMonthMain> pecfmmls = proEconCurveFittMonthMainService.list(queryWrapper4);
  577. // .stream().filter(i -> i.getYear().equals(year) && i.getMonth().equals(month)
  578. // && i.getWindturbineId().equals(wt.getId())
  579. // ).collect(Collectors.toList());
  580. if (!pecfmmls.isEmpty()) {
  581. ProEconCurveFittMonthMain pecfm = pecfmmls.get(0);
  582. pewp.setYqxpcbzysj(pecfm.getDeviationRate1());
  583. pewp.setYqxpcbbzsj(pecfm.getDeviationRate2());
  584. pewp.setYqxpcbzybz(pecfm.getDeviationRate3());
  585. pewp.setYqxpcbbg(pecfm.getStandardDeviationRate());
  586. pewp.setYqxpcbtb(pecfm.getYearDeviationRate());
  587. pewp.setYqxpcbhb(pecfm.getMonthDeviationRate());
  588. }
  589. //************************************************月三率统计****************************************************************/
  590. Calendar cal = Calendar.getInstance();
  591. cal.setTime(begin);
  592. cal.set(Calendar.DAY_OF_MONTH, 1);
  593. Date monthbiegin = c.getTime();
  594. queryWrapper2 = new QueryWrapper<>();
  595. queryWrapper2.ge("record_date",monthbiegin).le("record_date",end).eq("windturbine_id",wt.getId());
  596. pestrls =proEconEquipmentInfoDay5Service.list(queryWrapper2);
  597. // .stream()
  598. // .filter(i ->
  599. // (i.getRecordDate().compareTo(monthbiegin) == 0 || i.getRecordDate().after(monthbiegin))
  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(ProEconEquipmentInfoDay5::getTimerate8).summaryStatistics();
  605. //大于3米20分钟转换及时次数合计
  606. timerate8_sum = timerate8_summary.getSum();
  607. //大于3米状态转换总次数次数
  608. timerate14_summary = pestrls.stream().mapToDouble(ProEconEquipmentInfoDay5::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.setYztzhjsl(temp);
  615. } else {
  616. pewp.setYztzhjsl(100.0);
  617. }
  618. //20分钟复位及时次数
  619. timerate19_summary = pestrls.stream().mapToDouble(ProEconEquipmentInfoDay5::getTimerate19).summaryStatistics();
  620. //20分钟复位及时次数合计
  621. timerate19_sum = timerate19_summary.getSum();
  622. //总复位次数
  623. timerate20_summary = pestrls.stream().mapToDouble(ProEconEquipmentInfoDay5::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.setYfwjsl(temp);
  630. } else {
  631. pewp.setYfwjsl(100.0);
  632. }
  633. queryWrapper3 = new QueryWrapper<>();
  634. queryWrapper3.ge("date_time",monthbiegin).le("date_time",end).eq("windturbine_id",wt.getId());
  635. peflls=proEconFaultLiminatedefectsService.list(queryWrapper3);
  636. // .stream()
  637. // .filter(i ->
  638. // (i.getDateTime().compareTo(monthbiegin) == 0 || i.getDateTime().after(monthbiegin))
  639. // && (i.getDateTime().compareTo(end) == 0 || i.getDateTime().before(end))
  640. // && i.getWindturbineId().equals(wt.getId())
  641. // ).collect(Collectors.toList());
  642. //消缺及时次数
  643. right_summary = peflls.stream().mapToDouble(ProEconFaultLiminatedefects::getRightCount).summaryStatistics();
  644. //消缺及时次数合计
  645. right_sum = right_summary.getSum();
  646. //故障次数次数
  647. fault_summary = peflls.stream().mapToDouble(ProEconFaultLiminatedefects::getFaultCount).summaryStatistics();
  648. //故障次数次数合计
  649. fault_sum = fault_summary.getSum();
  650. if (fault_sum != 0) {
  651. //月消缺及时率
  652. double temp = new BigDecimal(right_sum).divide(new BigDecimal(fault_sum), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();
  653. pewp.setYgzxqjsl(temp);
  654. } else {
  655. pewp.setYgzxqjsl(100.0);
  656. }
  657. //**************************************************月三率统计****************************************************************/
  658. QueryWrapper<ProEconCurveFittMonthSub> queryWrapper7 = new QueryWrapper<>();
  659. queryWrapper7.isNotNull("speed")
  660. .lt("speed",5.0)
  661. .ge("speed",3.0)
  662. .eq("year",year)
  663. .eq("month",month)
  664. .eq("windturbine_id",wt.getId());
  665. List<ProEconCurveFittMonthSub> monthpointls=proEconCurveFittMonthSubService.list(queryWrapper7);
  666. // .stream().filter(x-> x.getSpeed() !=null
  667. // && Double.valueOf(x.getSpeed())>=3.0
  668. // && Double.valueOf(x.getSpeed())<5.0
  669. // && x.getYear().equals(year)
  670. // && x.getMonth().equals(month)
  671. // && x.getWindturbineId().equals(wt.getId())
  672. // ).collect(Collectors.toList());
  673. summaryStatistics=monthpointls.stream().mapToDouble(ProEconCurveFittMonthSub::getDeviationRate1).summaryStatistics();
  674. pewp.setY35mqxpcl(summaryStatistics.getAverage());
  675. queryWrapper7 = new QueryWrapper<>();
  676. queryWrapper7.isNotNull("speed")
  677. .lt("speed",11.0)
  678. .ge("speed",5.0)
  679. .eq("year",year)
  680. .eq("month",month)
  681. .eq("windturbine_id",wt.getId());
  682. monthpointls=proEconCurveFittMonthSubService.list(queryWrapper7);
  683. // monthpointls=proEconCurveFittMonthSubService.list().stream().filter(x-> x.getSpeed() !=null
  684. // && Double.valueOf(x.getSpeed())>=5.0
  685. // && Double.valueOf(x.getSpeed())<11.0
  686. // && x.getYear().equals(year)
  687. // && x.getMonth().equals(month)
  688. // && x.getWindturbineId().equals(wt.getId())
  689. // ).collect(Collectors.toList());
  690. summaryStatistics=monthpointls.stream().mapToDouble(ProEconCurveFittMonthSub::getDeviationRate1).summaryStatistics();
  691. pewp.setY511mqxpcl(summaryStatistics.getAverage());
  692. queryWrapper7 = new QueryWrapper<>();
  693. queryWrapper7.isNotNull("speed")
  694. // .lt("speed",11.0)
  695. .ge("speed",11.0)
  696. .eq("year",year)
  697. .eq("month",month)
  698. .eq("windturbine_id",wt.getId());
  699. monthpointls=proEconCurveFittMonthSubService.list(queryWrapper7);
  700. // monthpointls=proEconCurveFittMonthSubService.list().stream().filter(x-> x.getSpeed() !=null
  701. // && Double.valueOf(x.getSpeed())>=11.0
  702. // && x.getYear().equals(year)
  703. // && x.getMonth().equals(month)
  704. // && x.getWindturbineId().equals(wt.getId())
  705. // ).collect(Collectors.toList());
  706. summaryStatistics=monthpointls.stream().mapToDouble(ProEconCurveFittMonthSub::getDeviationRate1).summaryStatistics();
  707. pewp.setY11mycqxpcl(summaryStatistics.getAverage());
  708. }
  709. //*******************************************月信息统计*********************************************************/
  710. //*******************************************年信息统计*********************************************************/
  711. if (pepidls.isEmpty()) {
  712. setEquipmentInfoDay4Year(pewp);
  713. } else {
  714. ProEconEquipmentInfoDay4 pepid = pepidls.get(0);
  715. //获得功率一致性系数
  716. if (wgmap.containsKey(wt.getId())) {
  717. ProEconWindturbineGoodness wg = wgmap.get(wt.getId());
  718. pewp.setNglyzxxs(wg.getYearCoefficient());
  719. }
  720. //获得拟合优度
  721. if (wgmap.containsKey(wt.getId())) {
  722. ProEconWindturbineGoodness wg = wgmap.get(wt.getId());
  723. pewp.setNnhyd(wg.getYearGoodness());
  724. }
  725. if (StringUtils.notEmp(pepid2)) {
  726. //获得日有效风时数
  727. pewp.setNyxfss(StringUtils.round(c.get(Calendar.DAY_OF_YEAR) * 24 - pepid2.getNgzxsmx() - pepid2.getNjxxsmx(), 2));
  728. }
  729. if (StringUtils.notEmp(pepid2) && StringUtils.notEmp(pepid3)) {
  730. //故障小时
  731. double ngzxsmx = pepid2.getYgzxsmx();
  732. //故障次数
  733. double ngzcsmx = pepid3.getYgzcsmx();
  734. if (ngzcsmx != 0) {
  735. double mtbf = new BigDecimal(c.get(Calendar.DAY_OF_YEAR) * 24).divide(new BigDecimal(ngzcsmx), 2, RoundingMode.HALF_EVEN).doubleValue();
  736. double mttr = new BigDecimal(ngzxsmx).divide(new BigDecimal(ngzcsmx), 2, RoundingMode.HALF_EVEN).doubleValue();
  737. double mttf = mtbf - mttr;
  738. pewp.setNmtbf(mtbf);
  739. pewp.setNmttr(mttr);
  740. pewp.setNmttf(mttf);
  741. } else {
  742. double mtbf = c.get(Calendar.DAY_OF_YEAR) * 24;
  743. double mttr = 0.0;
  744. double mttf = mtbf - mttr;
  745. pewp.setNmtbf(mtbf);
  746. pewp.setNmttr(mttr);
  747. pewp.setNmttf(mttf);
  748. }
  749. }
  750. if (peioomap.containsKey(wt.getId())) {
  751. //切入切出统计
  752. peiost = peioomap.get(wt.getId());
  753. //年小风切入风速
  754. pewp.setNxfqrfs(peiost.getYearInputSmall());
  755. //年小风切出风速
  756. pewp.setNxfqcfs(peiost.getYearOutputSmall());
  757. //年大风切入风速
  758. pewp.setNdfqrfs(peiost.getYearInputBig());
  759. //年大风切出风速
  760. pewp.setNdfqcfs(peiost.getYearOutputBig());
  761. if (StringUtils.notEmp(peiost)) {
  762. //静风时长累计
  763. pewp.setNjfsc(pewp.getNjfsc() + pepid.getRjfsc());
  764. if (pewp.getNedfs() == 0) {
  765. //如果没有满发,额定风速赋值保证功率达到满发的对应风速
  766. pewp.setNedfs(11.0);
  767. }
  768. if (pewp.getRedfs() < pepid.getNedfs()) {
  769. pewp.setNedfs(pewp.getRedfs());
  770. } else {
  771. pewp.setNedfs(pepid.getNedfs());
  772. }
  773. //月对风偏差次数(-50 +50之间)
  774. pewp.setNdfpcl(pepid.getNdfpcl() + pewp.getRdfpcl());
  775. }
  776. }
  777. QueryWrapper<ProEconCurveFittYearMain> queryWrapper8 = new QueryWrapper<>();
  778. queryWrapper8.eq("year",year).eq("windturbine_id",wt.getId());
  779. List<ProEconCurveFittYearMain> pecfYmls = proEconCurveFittYearMainService.list(queryWrapper8);
  780. // .stream().filter(i -> i.getYear().equals(year)
  781. // && i.getWindturbineId().equals(wt.getId())
  782. // ).collect(Collectors.toList());
  783. if (!pecfYmls.isEmpty()) {
  784. ProEconCurveFittYearMain pecfm = pecfYmls.get(0);
  785. pewp.setNqxpcbzysj(pecfm.getDeviationRate1());
  786. pewp.setNqxpcbbzsj(pecfm.getDeviationRate2());
  787. pewp.setNqxpcbzybz(pecfm.getDeviationRate3());
  788. pewp.setNqxpcbbg(pecfm.getStandardDeviationRate());
  789. pewp.setNqxpcbtb(pecfm.getYearDeviationRate());
  790. pewp.setNqxpcbhb(pecfm.getMonthDeviationRate());
  791. }
  792. //************************************************年三率统计****************************************************************/
  793. Calendar cal = Calendar.getInstance();
  794. cal.setTime(begin);
  795. cal.set(Calendar.DAY_OF_YEAR, 1);
  796. Date yearbiegin = c.getTime();
  797. queryWrapper2 = new QueryWrapper<>();
  798. queryWrapper2.ge("record_date",yearbiegin).le("record_date",end).eq("windturbine_id",wt.getId());
  799. pestrls =proEconEquipmentInfoDay5Service.list(queryWrapper2);
  800. // .stream()
  801. // .filter(i ->
  802. // (i.getRecordDate().compareTo(yearbiegin) == 0 || i.getRecordDate().after(yearbiegin))
  803. // && (i.getRecordDate().compareTo(end) == 0 || i.getRecordDate().before(end))
  804. // && i.getWindturbineId().equals(wt.getId())
  805. // ).collect(Collectors.toList());
  806. //大于3米20分钟转换及时次数
  807. timerate8_summary =pestrls.stream().mapToDouble(ProEconEquipmentInfoDay5::getTimerate8).summaryStatistics();
  808. //大于3米20分钟转换及时次数合计
  809. timerate8_sum = timerate8_summary.getSum();
  810. //大于3米状态转换总次数次数
  811. timerate14_summary = pestrls.stream().mapToDouble(ProEconEquipmentInfoDay5::getTimerate14).summaryStatistics();
  812. //大于3米状态转换总次数合计
  813. timerate14_sum = timerate14_summary.getSum();
  814. if (timerate14_sum != 0) {
  815. //年状态转换及时率
  816. double temp = new BigDecimal(timerate8_sum).divide(new BigDecimal(timerate14_sum), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();
  817. pewp.setNztzhjsl(temp);
  818. } else {
  819. pewp.setNztzhjsl(100.0);
  820. }
  821. //20分钟复位及时次数
  822. timerate19_summary = pestrls.stream().mapToDouble(ProEconEquipmentInfoDay5::getTimerate19).summaryStatistics();
  823. //20分钟复位及时次数合计
  824. timerate19_sum = timerate19_summary.getSum();
  825. //总复位次数
  826. timerate20_summary = pestrls.stream().mapToDouble(ProEconEquipmentInfoDay5::getTimerate20).summaryStatistics();
  827. //总复位次数合计
  828. timerate20_sum = timerate20_summary.getSum();
  829. if (timerate20_sum != 0) {
  830. //年复位及时率
  831. double temp = new BigDecimal(timerate19_sum).divide(new BigDecimal(timerate20_sum), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();
  832. pewp.setNfwjsl(temp);
  833. } else {
  834. pewp.setNfwjsl(100.0);
  835. }
  836. queryWrapper3 = new QueryWrapper<>();
  837. queryWrapper3.ge("date_time",yearbiegin).le("date_time",end).eq("windturbine_id",wt.getId());
  838. peflls=proEconFaultLiminatedefectsService.list(queryWrapper3);
  839. // .stream()
  840. // .filter(i ->
  841. // (i.getDateTime().compareTo(yearbiegin) == 0 || i.getDateTime().after(yearbiegin))
  842. // && (i.getDateTime().compareTo(end) == 0 || i.getDateTime().before(end))
  843. // && i.getWindturbineId().equals(wt.getId())
  844. // ).collect(Collectors.toList());
  845. //消缺及时次数
  846. right_summary = peflls.stream().mapToDouble(ProEconFaultLiminatedefects::getRightCount).summaryStatistics();
  847. //消缺及时次数合计
  848. right_sum = right_summary.getSum();
  849. //故障次数次数
  850. fault_summary = peflls.stream().mapToDouble(ProEconFaultLiminatedefects::getFaultCount).summaryStatistics();
  851. //故障次数次数合计
  852. fault_sum = fault_summary.getSum();
  853. if (fault_sum != 0) {
  854. //年消缺及时率
  855. double temp = new BigDecimal(right_sum).divide(new BigDecimal(fault_sum), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();
  856. pewp.setNgzxqjsl(temp);
  857. } else {
  858. pewp.setNgzxqjsl(100.0);
  859. }
  860. //**************************************************年三率统计****************************************************************/
  861. QueryWrapper<ProEconCurveFittYearSub> queryWrapper7 = new QueryWrapper<>();
  862. queryWrapper.isNotNull("speed")
  863. .lt("speed",5.0)
  864. .ge("speed",3.0)
  865. .eq("year",year)
  866. .eq("windturbine_id",wt.getId());
  867. List<ProEconCurveFittYearSub> yearpointls=proEconCurveFittYearSubService.list(queryWrapper7);
  868. // .stream().filter(x-> x.getSpeed() !=null
  869. // && Double.valueOf(x.getSpeed())>=3.0
  870. // && Double.valueOf(x.getSpeed())<5.0
  871. // && x.getYear().equals(year)
  872. // && x.getWindturbineId().equals(wt.getId())
  873. // ).collect(Collectors.toList());
  874. summaryStatistics=yearpointls.stream().mapToDouble(ProEconCurveFittYearSub::getDeviationRate1).summaryStatistics();
  875. pewp.setN35mqxpcl(summaryStatistics.getAverage());
  876. queryWrapper7 = new QueryWrapper<>();
  877. queryWrapper7.isNotNull("speed")
  878. .lt("speed",11.0)
  879. .ge("speed",5.0)
  880. .eq("year",year)
  881. .eq("windturbine_id",wt.getId());
  882. yearpointls=proEconCurveFittYearSubService.list(queryWrapper7);
  883. // .stream().filter(x-> x.getSpeed() !=null
  884. // && Double.valueOf(x.getSpeed())>=5.0
  885. // && Double.valueOf(x.getSpeed())<11.0
  886. // && x.getYear().equals(year)
  887. // && x.getWindturbineId().equals(wt.getId())
  888. // ).collect(Collectors.toList());
  889. summaryStatistics=yearpointls.stream().mapToDouble(ProEconCurveFittYearSub::getDeviationRate1).summaryStatistics();
  890. pewp.setN511mqxpcl(summaryStatistics.getAverage());
  891. queryWrapper7 = new QueryWrapper<>();
  892. queryWrapper.isNotNull("speed")
  893. .ge("speed",11.0)
  894. .eq("year",year)
  895. .eq("windturbine_id",wt.getId());
  896. yearpointls=proEconCurveFittYearSubService.list(queryWrapper7);
  897. // yearpointls=proEconCurveFittYearSubService.list().stream().filter(x-> x.getSpeed() !=null
  898. // && Double.valueOf(x.getSpeed())>=11.0
  899. // && x.getYear().equals(year)
  900. // && x.getWindturbineId().equals(wt.getId())
  901. // ).collect(Collectors.toList());
  902. summaryStatistics=yearpointls.stream().mapToDouble(ProEconCurveFittYearSub::getDeviationRate1).summaryStatistics();
  903. pewp.setN11mycqxpcl(summaryStatistics.getAverage());
  904. }
  905. }
  906. private static void setEquipmentInfoDay4Year(ProEconEquipmentInfoDay4 pewp) {
  907. //* 年静风时长
  908. pewp.setNjfsc(pewp.getRjfsc());
  909. //* 年有效风时数
  910. pewp.setNyxfss(pewp.getRyxfss());
  911. //* 年小风切入风速
  912. pewp.setNxfqrfs(pewp.getRxfqrfs());
  913. //* 年大风切入风速
  914. pewp.setNdfqrfs(pewp.getRdfqrfs());
  915. //* 年小风切出风速
  916. pewp.setNxfqcfs(pewp.getRxfqcfs());
  917. //* 年大风切出风速
  918. pewp.setNdfqcfs(pewp.getRdfqcfs());
  919. //* 年额定风速
  920. pewp.setNedfs(pewp.getRedfs());
  921. //* 年功率一致性系数
  922. pewp.setNglyzxxs(pewp.getRglyzxxs());
  923. //* 年拟合优度
  924. pewp.setNnhyd(pewp.getRnhyd());
  925. //* 年曲线偏差率最优保证
  926. pewp.setNqxpcbzybz(pewp.getRqxpcbzybz());
  927. //* 年曲线偏差率最优实际
  928. pewp.setNqxpcbzysj(pewp.getRqxpcbzysj());
  929. //* 年曲线偏差率保证实际
  930. pewp.setNqxpcbbzsj(pewp.getRqxpcbbzsj());
  931. //* 年曲线偏差率同比
  932. pewp.setNqxpcbtb(pewp.getRqxpcbtb());
  933. //* 年曲线偏差率环比
  934. pewp.setNqxpcbhb(pewp.getRqxpcbhb());
  935. //* 年曲线偏差率标杆
  936. pewp.setNqxpcbbg(pewp.getRqxpcbbg());
  937. //* 年3-5米曲线偏差率
  938. pewp.setN35mqxpcl(pewp.getR35mqxpcl());
  939. //* 年5-11米曲线偏差率
  940. pewp.setN511mqxpcl(pewp.getR511mqxpcl());
  941. //* 年11米以上曲线偏差率
  942. pewp.setN11mycqxpcl(pewp.getR11mycqxpcl());
  943. //* 年对风偏差率(-50 +50之间)
  944. pewp.setNdfpcl(pewp.getRdfpcl());
  945. //* 年MTBF
  946. pewp.setNmtbf(pewp.getRmtbf());
  947. //* 年MTTR
  948. pewp.setNmttr(pewp.getRmttr());
  949. //* 年MTTF
  950. pewp.setNmttf(pewp.getRmttf());
  951. //* 年复位及时率
  952. pewp.setNfwjsl(pewp.getRfwjsl());
  953. //* 年状态转换及时率
  954. pewp.setNztzhjsl(pewp.getRztzhjsl());
  955. //* 年故障消缺及时率
  956. pewp.setNgzxqjsl(pewp.getRgzxqjsl());
  957. }
  958. private static void setEquipmentInfoDay4Month(ProEconEquipmentInfoDay4 pewp) {
  959. //* 月静风时长
  960. pewp.setYjfsc(pewp.getRjfsc());
  961. //* 月有效风时数
  962. pewp.setYyxfss(pewp.getRyxfss());
  963. //* 月小风切入风速
  964. pewp.setYxfqrfs(pewp.getRxfqrfs());
  965. //* 月大风切入风速
  966. pewp.setYdfqrfs(pewp.getRdfqrfs());
  967. //* 月小风切出风速
  968. pewp.setYxfqcfs(pewp.getRxfqcfs());
  969. //* 月大风切出风速
  970. pewp.setYdfqcfs(pewp.getRdfqcfs());
  971. //* 月额定风速
  972. pewp.setYedfs(pewp.getRedfs());
  973. //* 月功率一致性系数
  974. pewp.setYglyzxxs(pewp.getRglyzxxs());
  975. //* 月拟合优度
  976. pewp.setYnhyd(pewp.getRnhyd());
  977. //* 月曲线偏差率最优保证
  978. pewp.setYqxpcbzybz(pewp.getRqxpcbzybz());
  979. //* 月曲线偏差率最优实际
  980. pewp.setYqxpcbzysj(pewp.getRqxpcbzysj());
  981. //* 月曲线偏差率保证实际
  982. pewp.setYqxpcbbzsj(pewp.getRqxpcbbzsj());
  983. //* 月曲线偏差率同比
  984. pewp.setYqxpcbtb(pewp.getRqxpcbtb());
  985. //* 月曲线偏差率环比
  986. pewp.setYqxpcbhb(pewp.getRqxpcbhb());
  987. //* 月曲线偏差率标杆
  988. pewp.setYqxpcbbg(pewp.getRqxpcbbg());
  989. //* 月3-5米曲线偏差率
  990. pewp.setY35mqxpcl(pewp.getR35mqxpcl());
  991. //* 月5-11米曲线偏差率
  992. pewp.setY511mqxpcl(pewp.getR511mqxpcl());
  993. //* 月11米以上曲线偏差率
  994. pewp.setY11mycqxpcl(pewp.getR11mycqxpcl());
  995. //* 月对风偏差率(-50 +50之间)
  996. pewp.setYdfpcl(pewp.getRdfpcl());
  997. //* 月MTBF
  998. pewp.setYmtbf(pewp.getRmtbf());
  999. //* 月MTTR
  1000. pewp.setYmttr(pewp.getRmttr());
  1001. //* 月MTTF
  1002. pewp.setYmttf(pewp.getRmttf());
  1003. //* 月复位及时率
  1004. pewp.setYfwjsl(pewp.getRfwjsl());
  1005. //* 月状态转换及时率
  1006. pewp.setYztzhjsl(pewp.getRztzhjsl());
  1007. // //* 月故障消缺及时率
  1008. pewp.setYgzxqjsl(pewp.getRgzxqjsl());
  1009. }
  1010. }