InputOrOutPutService.java 82 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792
  1. 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.generation.init.CacheContext;
  6. import com.gyee.generation.model.auto.*;
  7. import com.gyee.generation.model.vo.StatusValue;
  8. import com.gyee.generation.model.vo.WpType;
  9. import com.gyee.generation.service.auto.IProEconInOrOutSpeedTotal2Service;
  10. import com.gyee.generation.service.auto.IProEconInOrOutSpeedTotalService;
  11. import com.gyee.generation.service.auto.IProEconInputOrOutputSpeedService;
  12. import com.gyee.generation.util.DateUtils;
  13. import com.gyee.generation.util.StringUtils;
  14. import com.gyee.generation.util.realtimesource.IEdosUtil;
  15. import org.springframework.beans.factory.annotation.Value;
  16. import org.springframework.stereotype.Service;
  17. import javax.annotation.Resource;
  18. import java.math.BigDecimal;
  19. import java.math.RoundingMode;
  20. import java.util.*;
  21. import java.util.concurrent.Executor;
  22. import java.util.stream.Collectors;
  23. @Service
  24. public class InputOrOutPutService {
  25. @Resource
  26. private IEdosUtil edosUtil;
  27. @Resource
  28. private IProEconInOrOutSpeedTotal2Service proEconInOrOutSpeedTotal2Service;
  29. @Resource
  30. private IProEconInOrOutSpeedTotalService proEconInOrOutSpeedTotalService;
  31. @Resource
  32. private IProEconInputOrOutputSpeedService proEconInputOrOutputSpeedService;
  33. @Resource
  34. private Executor executor;
  35. @Value("${frequency.cutinandout}")
  36. private Integer frequency;
  37. private static Map<String, Double> statusRanngMap;
  38. public void initialInputOrOutputSpeed()
  39. {
  40. statusRanngMap=new HashMap<>();
  41. List<ProBasicEquipment> wtls= new ArrayList<>();
  42. for(ProBasicPowerstation wp: CacheContext.wpls)
  43. {
  44. if(wp.getId().contains("FDC") )
  45. {
  46. wtls.addAll(CacheContext.wpwtmap.get(wp.getId()));
  47. }
  48. }
  49. List<ProEconInputOrOutputSpeed> ls=new ArrayList<>();
  50. List<String> mxztls=new ArrayList<>();
  51. List<String> ssfsls=new ArrayList<>();
  52. for (ProBasicEquipment wt: wtls)
  53. {
  54. Map<String, ProBasicEquipmentPoint> pointmap= CacheContext.wtpAimap.get(wt.getId());
  55. ProBasicEquipmentPoint mxzt= pointmap.get(ContantXk.SBZT);
  56. mxztls.add(mxzt.getNemCode());
  57. ProBasicEquipmentPoint ssfs= pointmap.get(ContantXk.CJ_SSFS);
  58. ssfsls.add(ssfs.getNemCode());
  59. }
  60. try {
  61. List<PointData> mxztvaluels = edosUtil.getRealData(mxztls);
  62. if(!mxztvaluels.isEmpty() && mxztvaluels.size()==wtls.size())
  63. {
  64. for (int i=0;i<wtls.size();i++)
  65. {
  66. ProBasicEquipment wt=wtls.get(i);
  67. statusRanngMap.put(wt.getId(),mxztvaluels.get(i).getPointValueInDouble());
  68. }
  69. }
  70. } catch (Exception e) {
  71. throw new RuntimeException(e);
  72. }
  73. }
  74. public void inputOrOutputSpeed(Date recordDate) throws Exception {
  75. // Date begin = DateUtils.addSeconds(recordDate, -60);
  76. //
  77. // Date begin = DateUtils.addHours(recordDate, -frequency);
  78. // Date end = recordDate;
  79. // Map<String, ProEconInputOrOutputSpeed> wtTimeStatusMap=new HashMap<>();
  80. // Map<String,Double> wtLastStatusMap=new HashMap<>();
  81. //
  82. // QueryWrapper<ProEconInputOrOutputSpeed> queryWrapper = new QueryWrapper<>();
  83. // queryWrapper.ge("record_date",begin).le("record_date",end);
  84. // queryWrapper.orderByAsc("record_date");
  85. // List<ProEconInputOrOutputSpeed> recordList = proEconInputOrOutputSpeedService.list(queryWrapper);
  86. //
  87. // Map<String, Map<String,ProEconInputOrOutputSpeed>> statusMap=new HashMap<>();
  88. // if(!recordList.isEmpty())
  89. // {
  90. // for(ProEconInputOrOutputSpeed po:recordList)
  91. // {
  92. // if(statusMap.containsKey(po.getWindturbineId()))
  93. // {
  94. // Map<String, ProEconInputOrOutputSpeed> map= statusMap.get(po.getWindturbineId());
  95. // map.put(String.valueOf(po.getRecordDate().getTime()),po);
  96. // }else
  97. // {
  98. // Map<String, ProEconInputOrOutputSpeed> map= new HashMap<>();
  99. // map.put(String.valueOf(po.getRecordDate().getTime()),po);
  100. // statusMap.put(po.getWindturbineId(),map);
  101. // }
  102. //
  103. // }
  104. // }
  105. List<ProBasicEquipment> wtls= new ArrayList<>();
  106. for(ProBasicPowerstation wp: CacheContext.wpls)
  107. {
  108. if(wp.getId().contains("FDC") )
  109. {
  110. wtls.addAll(CacheContext.wpwtmap.get(wp.getId()));
  111. }
  112. }
  113. List<ProEconInputOrOutputSpeed> ls=new ArrayList<>();
  114. List<String> mxztls=new ArrayList<>();
  115. List<String> ssfsls=new ArrayList<>();
  116. for (ProBasicEquipment wt: wtls)
  117. {
  118. Map<String, ProBasicEquipmentPoint> pointmap= CacheContext.wtpAimap.get(wt.getId());
  119. ProBasicEquipmentPoint mxzt= pointmap.get(ContantXk.SBZT);
  120. mxztls.add(mxzt.getNemCode());
  121. ProBasicEquipmentPoint ssfs= pointmap.get(ContantXk.CJ_SSFS);
  122. ssfsls.add(ssfs.getNemCode());
  123. }
  124. List<PointData> mxztvaluels = edosUtil.getRealData(mxztls);
  125. List<PointData> ssfsvaluels = edosUtil.getRealData(ssfsls);
  126. if(ssfsvaluels.size() == mxztvaluels.size() && ssfsvaluels.size()==wtls.size())
  127. {
  128. for (int i=0;i<wtls.size();i++)
  129. {
  130. ProBasicEquipment wt=wtls.get(i);
  131. double status=StringUtils.round(mxztvaluels.get(i).getPointValueInDouble(),0);
  132. if(null !=statusRanngMap)
  133. {
  134. double lastStatus=StringUtils.round( statusRanngMap.get(wt.getId()),0);
  135. PointData ssfspo=ssfsvaluels.get(i);
  136. // 切入切出风速
  137. if (lastStatus == StatusValue.DJ.getCode() && status == StatusValue.YX.getCode())
  138. {
  139. ProEconInputOrOutputSpeed input = new ProEconInputOrOutputSpeed();
  140. input.setWindturbineId(wt.getId());
  141. input.setWindpowerstationId(wt.getWindpowerstationId());
  142. input.setProjectId(wt.getProjectId());
  143. input.setLineId(wt.getLineId());
  144. input.setRecordDate(DateUtils.truncate(new Date()));
  145. input.setInputOrOutput(1);
  146. input.setSpeed(StringUtils.round(ssfspo.getPointValueInDouble(),2));
  147. // if(statusMap.containsKey(wt.getId()))
  148. // {
  149. // Map<String, ProEconInputOrOutputSpeed> map= statusMap.get(wt.getId());
  150. //
  151. // if(!map.containsKey(String.valueOf(ssfspo.getPointTime())) )
  152. // {
  153. // ls.add(input);
  154. // }
  155. // }else {
  156. // ls.add(input);
  157. // }
  158. ls.add(input);
  159. }
  160. else if (lastStatus == StatusValue.YX.getCode() && status== StatusValue.DJ.getCode())
  161. {
  162. ProEconInputOrOutputSpeed input = new ProEconInputOrOutputSpeed();
  163. input.setWindturbineId(wt.getId());
  164. input.setWindpowerstationId(wt.getWindpowerstationId());
  165. input.setProjectId(wt.getProjectId());
  166. input.setLineId(wt.getLineId());
  167. input.setRecordDate(DateUtils.truncate(new Date()));
  168. input.setInputOrOutput(0);
  169. input.setSpeed(StringUtils.round(ssfspo.getPointValueInDouble(),2));
  170. // if(statusMap.containsKey(wt.getId()))
  171. // {
  172. // Map<String, ProEconInputOrOutputSpeed> map= statusMap.get(wt.getId());
  173. //
  174. // if(!map.containsKey(String.valueOf(ssfspo.getPointTime())) )
  175. // {
  176. // ls.add(input);
  177. // }
  178. // }else
  179. // {
  180. // ls.add(input);
  181. // }
  182. ls.add(input);
  183. }
  184. }
  185. statusRanngMap.put(wt.getId(),status);
  186. }
  187. }
  188. // for (ProBasicEquipment wt: wtls) {
  189. // {
  190. //
  191. //// if (wt.getWindpowerstationId().contains(WpType.GDC.id)) {
  192. //// continue;
  193. //// }
  194. // Map<String, ProBasicEquipmentPoint> pointmap= CacheContext.wtpAimap.get(wt.getId());
  195. //
  196. //
  197. // if(statusMap.containsKey(wt.getId()))
  198. // {
  199. // wtTimeStatusMap=statusMap.get(wt.getId());
  200. // }
  201. //
  202. // double lastStatus=-1;
  203. //
  204. //
  205. // ProBasicEquipmentPoint mxzt= pointmap.get(ContantXk.SBZT);
  206. // ProBasicEquipmentPoint ssfs= pointmap.get(ContantXk.CJ_SSFS);
  207. //
  208. // //获取5分钟没个间隔1秒钟,保证状态与时序库保持一致
  209. // List<PointData> statusls = edosUtil.getHistoryDatasSnap(mxzt.getNemCode(), begin.getTime() / 1000, end.getTime() / 1000,null,1L);
  210. // List<PointData> ssfsls = edosUtil.getHistoryDatasSnap(ssfs.getNemCode(), begin.getTime() / 1000, end.getTime() / 1000,null,1L);
  211. //
  212. //
  213. // if(!statusls.isEmpty() && !ssfsls.isEmpty() && ssfsls.size()==statusls.size())
  214. // {
  215. //
  216. // for(int i=0;i<statusls.size();i++)
  217. // {
  218. //
  219. //
  220. // if(wtLastStatusMap.containsKey(wt.getId()))
  221. // {
  222. // lastStatus=wtLastStatusMap.get(wt.getId());
  223. // }
  224. //
  225. // PointData statuspo=statusls.get(i);
  226. // PointData ssfspo=ssfsls.get(i);
  227. // double status= StringUtils.round(statuspo.getPointValueInDouble(),0);
  228. //
  229. // if(i==0)
  230. // {
  231. // lastStatus=status;
  232. // }
  233. // if (!Objects.equals(lastStatus, status))
  234. // {
  235. //
  236. // // 切入切出风速
  237. // if (lastStatus == 0 && status == 1)
  238. // {
  239. // ProEconInputOrOutputSpeed input = new ProEconInputOrOutputSpeed();
  240. //
  241. // input.setWindturbineId(wt.getId());
  242. // input.setWindpowerstationId(wt.getWindpowerstationId());
  243. // input.setProjectId(wt.getProjectId());
  244. // input.setLineId(wt.getLineId());
  245. // input.setRecordDate(new Date());
  246. // input.setInputOrOutput(1);
  247. //
  248. //
  249. // input.setSpeed(StringUtils.round(ssfspo.getPointValueInDouble(),2));
  250. //
  251. // if(!wtTimeStatusMap.containsKey(String.valueOf(statuspo.getPointTime())) && !wtTimeStatusMap.get(String.valueOf(statuspo.getPointTime())).getWindturbineId().equals(wt.getId()))
  252. // {
  253. // //roEconInputOrOutputSpeedService.save(input);
  254. // ls.add(input);
  255. // }
  256. // lastStatus=status;
  257. //
  258. // }
  259. // else if (lastStatus == 1 && status== 0)
  260. // {
  261. // ProEconInputOrOutputSpeed input = new ProEconInputOrOutputSpeed();
  262. // input.setWindturbineId(wt.getId());
  263. // input.setWindpowerstationId(wt.getWindpowerstationId());
  264. // input.setProjectId(wt.getProjectId());
  265. // input.setLineId(wt.getLineId());
  266. // input.setRecordDate(new Date());
  267. // input.setInputOrOutput(0);
  268. //
  269. // input.setSpeed(StringUtils.round(ssfspo.getPointValueInDouble(),2));
  270. //
  271. // if(!wtTimeStatusMap.containsKey(String.valueOf(statuspo.getPointTime())) && !wtTimeStatusMap.get(String.valueOf(statuspo.getPointTime())).getWindturbineId().equals(wt.getId()))
  272. // {
  273. // //proEconInputOrOutputSpeedService.save(input);
  274. //
  275. // ls.add(input);
  276. // }
  277. // lastStatus=status;
  278. // }
  279. //
  280. // wtLastStatusMap.put(wt.getId(), status);
  281. //
  282. // }
  283. // }
  284. //
  285. //
  286. //
  287. // }
  288. //
  289. // }
  290. //
  291. // System.out.println("切入切出数量"+ls.size());
  292. List<ProEconInputOrOutputSpeed> templs = new ArrayList<>();
  293. for (ProEconInputOrOutputSpeed vo : ls) {
  294. templs.add(vo);
  295. if (templs.size() == 100) {
  296. proEconInputOrOutputSpeedService.saveBatch(templs);
  297. templs = new ArrayList<>();
  298. }
  299. }
  300. if (!templs.isEmpty()) {
  301. proEconInputOrOutputSpeedService.saveBatch(templs);
  302. }
  303. // }
  304. }
  305. public void inputOrOutput(Date currentDate) {
  306. currentDate = DateUtils.truncate(currentDate);
  307. // Date end = DateUtils.addDays(currentDate, 1);
  308. // Date daybegin =DateUtils.truncate(currentDate);
  309. Date end = currentDate;
  310. Date daybegin = DateUtils.addDays(currentDate, -1);
  311. Calendar c = Calendar.getInstance();
  312. c.setTime(daybegin);
  313. c.set(Calendar.DAY_OF_MONTH, 1);
  314. Date monthbegin = c.getTime();
  315. c.set(Calendar.MONTH, 0);
  316. Date yearbegin = c.getTime();
  317. for (ProBasicPowerstation wp : CacheContext.wpls) {
  318. if(wp.getId().contains(WpType.GDC.id))
  319. {
  320. continue;
  321. }
  322. List<ProBasicEquipment> wtls = null;
  323. if (CacheContext.wpwtmap.containsKey(wp.getId())) {
  324. wtls = CacheContext.wpwtmap.get(wp.getId());
  325. }
  326. if (null != wtls && !wtls.isEmpty()) {
  327. for (ProBasicEquipment wt : wtls) {
  328. ProEconInOrOutSpeedTotal total1 = null;
  329. ProEconInOrOutSpeedTotal2 total2 = null;
  330. QueryWrapper<ProEconInOrOutSpeedTotal> queryWrapper = new QueryWrapper<>();
  331. queryWrapper.eq("record_date",daybegin).eq("windturbine_id",wt.getId());
  332. Optional<ProEconInOrOutSpeedTotal> total1o = proEconInOrOutSpeedTotalService.list(queryWrapper)
  333. .stream()
  334. // .filter(i -> i.getWindturbineId().equals(wt.getId())
  335. // && i.getRecordDate().compareTo(daybegin) == 0)
  336. .findFirst();
  337. if (total1o.isPresent()) {
  338. total1 = total1o.get();
  339. }
  340. QueryWrapper<ProEconInOrOutSpeedTotal2> queryWrapper2 = new QueryWrapper<>();
  341. queryWrapper2.eq("record_date",daybegin).eq("windturbine_id",wt.getId());
  342. Optional<ProEconInOrOutSpeedTotal2> total2o = proEconInOrOutSpeedTotal2Service.list(queryWrapper2).stream()
  343. // .filter(i -> i.getWindturbineId().equals(wt.getId())
  344. // && i.getRecordDate().compareTo(daybegin) == 0)
  345. .findFirst();
  346. if (total2o.isPresent()) {
  347. total2 = total2o.get();
  348. }
  349. if (total1 != null) {
  350. QueryWrapper<ProEconInOrOutSpeedTotal> wrapper = new QueryWrapper<>();
  351. wrapper.eq("id", total1.getId());
  352. proEconInOrOutSpeedTotalService.remove(wrapper);
  353. }
  354. if (total2 != null) {
  355. QueryWrapper<ProEconInOrOutSpeedTotal2> wrapper = new QueryWrapper<>();
  356. wrapper.eq("id", total2.getId());
  357. proEconInOrOutSpeedTotal2Service.remove(wrapper);
  358. }
  359. total1 = new ProEconInOrOutSpeedTotal();
  360. total1.setWindturbineId(wt.getId());
  361. total1.setWindpowerstationId(wt.getWindpowerstationId());
  362. total1.setProjectId(wt.getProjectId());
  363. total1.setLineId(wt.getLineId());
  364. total1.setRecordDate(daybegin);
  365. total1.setCompanyId(wt.getCompanyId());
  366. total1.setRegionId(wt.getRegionId());
  367. if(wt.getWindpowerstationId().contains(WpType.FDC.id))
  368. {
  369. total1.setTypes("-1");
  370. }else
  371. {
  372. total1.setTypes("-2");
  373. }
  374. total2 = new ProEconInOrOutSpeedTotal2();
  375. total2.setWindturbineId(wt.getId());
  376. total2.setWindpowerstationId(wt.getWindpowerstationId());
  377. total2.setProjectId(wt.getProjectId());
  378. total2.setLineId(wt.getLineId());
  379. total2.setRecordDate(daybegin);
  380. total2.setRegionId(wt.getRegionId());
  381. total2.setCompanyId(wt.getCompanyId());
  382. if(wt.getWindpowerstationId().contains(WpType.FDC.id))
  383. {
  384. total2.setTypes("-1");
  385. }else
  386. {
  387. total2.setTypes("-2");
  388. }
  389. newMethod(end, daybegin, monthbegin, yearbegin, wt.getId(), total1, total2);
  390. verify(total1);
  391. proEconInOrOutSpeedTotalService.save(total1);
  392. proEconInOrOutSpeedTotal2Service.save(total2);
  393. }
  394. }
  395. }
  396. }
  397. private void verify(ProEconInOrOutSpeedTotal total1) {
  398. //日小风切入
  399. if (Double.isInfinite(total1.getDayInputSmall()) || Double.isNaN(total1.getDayInputSmall()))
  400. {
  401. total1.setDayInputSmall(0.0);
  402. }else
  403. {
  404. total1.setDayInputSmall(StringUtils.round(total1.getDayInputSmall(),2));
  405. }
  406. //日小风切入最小值
  407. if (Double.isInfinite(total1.getDayInputSmallMin()) || Double.isNaN(total1.getDayInputSmallMin()))
  408. {
  409. total1.setDayInputSmallMin(0.0);
  410. }else
  411. {
  412. total1.setDayInputSmallMin(StringUtils.round(total1.getDayInputSmallMin(),2));
  413. }
  414. //日小风切入最大值
  415. if (Double.isInfinite(total1.getDayInputSmallMax()) || Double.isNaN(total1.getDayInputSmallMax()))
  416. {
  417. total1.setDayInputSmallMax(0.0);
  418. }else
  419. {
  420. total1.setDayInputSmallMax(StringUtils.round(total1.getDayInputSmallMax(),2));
  421. }
  422. //日大风切入
  423. if (Double.isInfinite(total1.getDayInputBig()) || Double.isNaN(total1.getDayInputBig()))
  424. {
  425. total1.setDayInputBig(0.0);
  426. }else
  427. {
  428. total1.setDayInputBig(StringUtils.round(total1.getDayInputBig(),2));
  429. }
  430. //日大风切入最大值
  431. if (Double.isInfinite(total1.getDayInputBigMin()) || Double.isNaN(total1.getDayInputBigMin()))
  432. {
  433. total1.setDayInputBigMin(0.0);
  434. }else
  435. {
  436. total1.setDayInputBigMin(StringUtils.round(total1.getDayInputBigMin(),2));
  437. }
  438. //日大风切入最大值
  439. if (Double.isInfinite(total1.getDayInputBigMax()) || Double.isNaN(total1.getDayInputBigMax()))
  440. {
  441. total1.setDayInputBigMax(0.0);
  442. }else
  443. {
  444. total1.setDayInputBigMax(StringUtils.round(total1.getDayInputBigMax(),2));
  445. }
  446. //日小风切出
  447. if (Double.isInfinite(total1.getDayOutputSmall()) || Double.isNaN(total1.getDayOutputSmall()))
  448. {
  449. total1.setDayOutputSmall(0.0);
  450. }else
  451. {
  452. total1.setDayOutputSmall(StringUtils.round(total1.getDayOutputSmall(),2));
  453. }
  454. //日小风切出最小值
  455. if (Double.isInfinite(total1.getDayOutputSmallMin()) || Double.isNaN(total1.getDayOutputSmallMin()))
  456. {
  457. total1.setDayOutputSmallMin(0.0);
  458. }else
  459. {
  460. total1.setDayOutputSmallMin(StringUtils.round(total1.getDayOutputSmallMin(),2));
  461. }
  462. //日小风切出最大值
  463. if (Double.isInfinite(total1.getDayOutputSmallMax()) || Double.isNaN(total1.getDayOutputSmallMax()))
  464. {
  465. total1.setDayOutputSmallMax(0.0);
  466. }else
  467. {
  468. total1.setDayOutputSmallMax(StringUtils.round(total1.getDayOutputSmallMax(),2));
  469. }
  470. //日大风切出
  471. if (Double.isInfinite(total1.getDayOutputBig()) || Double.isNaN(total1.getDayOutputBig()))
  472. {
  473. total1.setDayOutputBig(0.0);
  474. }else
  475. {
  476. total1.setDayOutputBig(StringUtils.round(total1.getDayOutputBig(),2));
  477. }
  478. //日大风切出最大值
  479. if (Double.isInfinite(total1.getDayOutputBigMin()) || Double.isNaN(total1.getDayOutputBigMin()))
  480. {
  481. total1.setDayOutputBigMin(0.0);
  482. }else
  483. {
  484. total1.setDayOutputBigMin(StringUtils.round(total1.getDayOutputBigMin(),2));
  485. }
  486. //日大风切出最大值
  487. if (Double.isInfinite(total1.getDayOutputBigMax()) || Double.isNaN(total1.getDayOutputBigMax()))
  488. {
  489. total1.setDayOutputBigMax(0.0);
  490. }else
  491. {
  492. total1.setDayOutputBigMax(StringUtils.round(total1.getDayOutputBigMax(),2));
  493. }
  494. //月小风切入
  495. if (Double.isInfinite(total1.getMonthInputSmall()) || Double.isNaN(total1.getMonthInputSmall()))
  496. {
  497. total1.setMonthInputSmall(0.0);
  498. }else
  499. {
  500. total1.setMonthInputSmall(StringUtils.round(total1.getMonthInputSmall(),2));
  501. }
  502. //月小风切入最小值
  503. if (Double.isInfinite(total1.getMonthInputSmallMin()) || Double.isNaN(total1.getMonthInputSmallMin()))
  504. {
  505. total1.setMonthInputSmallMin(0.0);
  506. }else
  507. {
  508. total1.setMonthInputSmallMin(StringUtils.round(total1.getMonthInputSmallMin(),2));
  509. }
  510. //月小风切入最大值
  511. if (Double.isInfinite(total1.getMonthInputSmallMax()) || Double.isNaN(total1.getMonthInputSmallMax()))
  512. {
  513. total1.setMonthInputSmallMax(0.0);
  514. }else
  515. {
  516. total1.setMonthInputSmallMax(StringUtils.round(total1.getMonthInputSmallMax(),2));
  517. }
  518. //月大风切入
  519. if (Double.isInfinite(total1.getMonthInputBig()) || Double.isNaN(total1.getMonthInputBig()))
  520. {
  521. total1.setMonthInputBig(0.0);
  522. }else
  523. {
  524. total1.setMonthInputBig(StringUtils.round(total1.getMonthInputBig(),2));
  525. }
  526. //月大风切入最大值
  527. if (Double.isInfinite(total1.getMonthInputBigMin()) || Double.isNaN(total1.getMonthInputBigMin()))
  528. {
  529. total1.setMonthInputBigMin(0.0);
  530. }else
  531. {
  532. total1.setMonthInputBigMin(StringUtils.round(total1.getMonthInputBigMin(),2));
  533. }
  534. //月大风切入最大值
  535. if (Double.isInfinite(total1.getMonthInputBigMax()) || Double.isNaN(total1.getMonthInputBigMax()))
  536. {
  537. total1.setMonthInputBigMax(0.0);
  538. }else
  539. {
  540. total1.setMonthInputBigMax(StringUtils.round(total1.getMonthInputBigMax(),2));
  541. }
  542. //月小风切出
  543. if (Double.isInfinite(total1.getMonthOutputSmall()) || Double.isNaN(total1.getMonthOutputSmall()))
  544. {
  545. total1.setMonthOutputSmall(0.0);
  546. }else
  547. {
  548. total1.setMonthOutputSmall(StringUtils.round(total1.getMonthOutputSmall(),2));
  549. }
  550. //月小风切出最小值
  551. if (Double.isInfinite(total1.getMonthOutputSmallMin()) || Double.isNaN(total1.getMonthOutputSmallMin()))
  552. {
  553. total1.setMonthOutputSmallMin(0.0);
  554. }else
  555. {
  556. total1.setMonthOutputSmallMin(StringUtils.round(total1.getMonthOutputSmallMin(),2));
  557. }
  558. //月小风切出最大值
  559. if (Double.isInfinite(total1.getMonthOutputSmallMax()) || Double.isNaN(total1.getMonthOutputSmallMax()))
  560. {
  561. total1.setMonthOutputSmallMax(0.0);
  562. }else
  563. {
  564. total1.setMonthOutputSmallMax(StringUtils.round(total1.getMonthOutputSmallMax(),2));
  565. }
  566. //月大风切出
  567. if (Double.isInfinite(total1.getMonthOutputBig()) || Double.isNaN(total1.getMonthOutputBig()))
  568. {
  569. total1.setMonthOutputBig(0.0);
  570. }else
  571. {
  572. total1.setMonthOutputBig(StringUtils.round(total1.getMonthOutputBig(),2));
  573. }
  574. //月大风切出最大值
  575. if (Double.isInfinite(total1.getMonthOutputBigMin()) || Double.isNaN(total1.getMonthOutputBigMin()))
  576. {
  577. total1.setMonthOutputBigMin(0.0);
  578. }else
  579. {
  580. total1.setMonthOutputBigMin(StringUtils.round(total1.getMonthOutputBigMin(),2));
  581. }
  582. //月大风切出最大值
  583. if (Double.isInfinite(total1.getMonthOutputBigMax()) || Double.isNaN(total1.getMonthOutputBigMax()))
  584. {
  585. total1.setMonthOutputBigMax(0.0);
  586. }else
  587. {
  588. total1.setMonthOutputBigMax(StringUtils.round(total1.getMonthOutputBigMax(),2));
  589. }
  590. //年小风切入
  591. if (Double.isInfinite(total1.getYearInputSmall()) || Double.isNaN(total1.getYearInputSmall()))
  592. {
  593. total1.setYearInputSmall(0.0);
  594. }else
  595. {
  596. total1.setYearInputSmall(StringUtils.round(total1.getYearInputSmall(),2));
  597. }
  598. //年小风切入最小值
  599. if (Double.isInfinite(total1.getYearInputSmallMin()) || Double.isNaN(total1.getYearInputSmallMin()))
  600. {
  601. total1.setYearInputSmallMin(0.0);
  602. }else
  603. {
  604. total1.setYearInputSmallMin(StringUtils.round(total1.getYearInputSmallMin(),2));
  605. }
  606. //年小风切入最大值
  607. if (Double.isInfinite(total1.getYearInputSmallMax()) || Double.isNaN(total1.getYearInputSmallMax()))
  608. {
  609. total1.setYearInputSmallMax(0.0);
  610. }else
  611. {
  612. total1.setYearInputSmallMax(StringUtils.round(total1.getYearInputSmallMax(),2));
  613. }
  614. //年大风切入
  615. if (Double.isInfinite(total1.getYearInputBig()) || Double.isNaN(total1.getYearInputBig()))
  616. {
  617. total1.setYearInputBig(0.0);
  618. }else
  619. {
  620. total1.setYearInputBig(StringUtils.round(total1.getYearInputBig(),2));
  621. }
  622. //年大风切入最大值
  623. if (Double.isInfinite(total1.getYearInputBigMin()) || Double.isNaN(total1.getYearInputBigMin()))
  624. {
  625. total1.setYearInputBigMin(0.0);
  626. }else
  627. {
  628. total1.setYearInputBigMin(StringUtils.round(total1.getYearInputBigMin(),2));
  629. }
  630. //年大风切入最大值
  631. if (Double.isInfinite(total1.getYearInputBigMax()) || Double.isNaN(total1.getYearInputBigMax()))
  632. {
  633. total1.setYearInputBigMax(0.0);
  634. }else
  635. {
  636. total1.setYearInputBigMax(StringUtils.round(total1.getYearInputBigMax(),2));
  637. }
  638. //年小风切出
  639. if (Double.isInfinite(total1.getYearOutputSmall()) || Double.isNaN(total1.getYearOutputSmall()))
  640. {
  641. total1.setYearOutputSmall(0.0);
  642. }else
  643. {
  644. total1.setYearOutputSmall(StringUtils.round(total1.getYearOutputSmall(),2));
  645. }
  646. //年小风切出最小值
  647. if (Double.isInfinite(total1.getYearOutputSmallMin()) || Double.isNaN(total1.getYearOutputSmallMin()))
  648. {
  649. total1.setYearOutputSmallMin(0.0);
  650. }else
  651. {
  652. total1.setYearOutputSmallMin(StringUtils.round(total1.getYearOutputSmallMin(),2));
  653. }
  654. //年小风切出最大值
  655. if (Double.isInfinite(total1.getYearOutputSmallMax()) || Double.isNaN(total1.getYearOutputSmallMax()))
  656. {
  657. total1.setYearOutputSmallMax(0.0);
  658. }else
  659. {
  660. total1.setYearOutputSmallMax(StringUtils.round(total1.getYearOutputSmallMax(),2));
  661. }
  662. //年大风切出
  663. if (Double.isInfinite(total1.getYearOutputBig()) || Double.isNaN(total1.getYearOutputBig()))
  664. {
  665. total1.setYearOutputBig(0.0);
  666. }else
  667. {
  668. total1.setYearOutputBig(StringUtils.round(total1.getYearOutputBig(),2));
  669. }
  670. //年大风切出最大值
  671. if (Double.isInfinite(total1.getYearOutputBigMin()) || Double.isNaN(total1.getYearOutputBigMin()))
  672. {
  673. total1.setYearOutputBigMin(0.0);
  674. }else
  675. {
  676. total1.setYearOutputBigMin(StringUtils.round(total1.getYearOutputBigMin(),2));
  677. }
  678. //年大风切出最大值
  679. if (Double.isInfinite(total1.getYearOutputBigMax()) || Double.isNaN(total1.getYearOutputBigMax()))
  680. {
  681. total1.setYearOutputBigMax(0.0);
  682. }else
  683. {
  684. total1.setYearOutputBigMax(StringUtils.round(total1.getYearOutputBigMax(),2));
  685. }
  686. //小风切入
  687. if (Double.isInfinite(total1.getInputSmall()) || Double.isNaN(total1.getInputSmall()))
  688. {
  689. total1.setInputSmall(0.0);
  690. }else
  691. {
  692. total1.setInputSmall(StringUtils.round(total1.getInputSmall(),2));
  693. }
  694. //小风切入最小值
  695. if (Double.isInfinite(total1.getInputSmallMin()) || Double.isNaN(total1.getInputSmallMin()))
  696. {
  697. total1.setInputSmallMin(0.0);
  698. }else
  699. {
  700. total1.setInputSmallMin(StringUtils.round(total1.getInputSmallMin(),2));
  701. }
  702. //小风切入最大值
  703. if (Double.isInfinite(total1.getInputSmallMax()) || Double.isNaN(total1.getInputSmallMax()))
  704. {
  705. total1.setInputSmallMax(0.0);
  706. }else
  707. {
  708. total1.setInputSmallMax(StringUtils.round(total1.getInputSmallMax(),2));
  709. }
  710. //大风切入
  711. if (Double.isInfinite(total1.getInputBig()) || Double.isNaN(total1.getInputBig()))
  712. {
  713. total1.setInputBig(0.0);
  714. }else
  715. {
  716. total1.setInputBig(StringUtils.round(total1.getInputBig(),2));
  717. }
  718. //大风切入最大值
  719. if (Double.isInfinite(total1.getInputBigMin()) || Double.isNaN(total1.getInputBigMin()))
  720. {
  721. total1.setInputBigMin(0.0);
  722. }else
  723. {
  724. total1.setInputBigMin(StringUtils.round(total1.getInputBigMin(),2));
  725. }
  726. //大风切入最大值
  727. if (Double.isInfinite(total1.getInputBigMax()) || Double.isNaN(total1.getInputBigMax()))
  728. {
  729. total1.setInputBigMax(0.0);
  730. }else
  731. {
  732. total1.setInputBigMax(StringUtils.round(total1.getInputBigMax(),2));
  733. }
  734. //小风切出
  735. if (Double.isInfinite(total1.getOutputSmall()) || Double.isNaN(total1.getOutputSmall()))
  736. {
  737. total1.setOutputSmall(0.0);
  738. }else
  739. {
  740. total1.setOutputSmall(StringUtils.round(total1.getOutputSmall(),2));
  741. }
  742. //小风切出最小值
  743. if (Double.isInfinite(total1.getOutputSmallMin()) || Double.isNaN(total1.getOutputSmallMin()))
  744. {
  745. total1.setOutputSmallMin(0.0);
  746. }else
  747. {
  748. total1.setOutputSmallMin(StringUtils.round(total1.getOutputSmallMin(),2));
  749. }
  750. //小风切出最大值
  751. if (Double.isInfinite(total1.getOutputSmallMax()) || Double.isNaN(total1.getOutputSmallMax()))
  752. {
  753. total1.setOutputSmallMax(0.0);
  754. }else
  755. {
  756. total1.setOutputSmallMax(StringUtils.round(total1.getOutputSmallMax(),2));
  757. }
  758. //大风切出
  759. if (Double.isInfinite(total1.getOutputBig()) || Double.isNaN(total1.getOutputBig()))
  760. {
  761. total1.setOutputBig(0.0);
  762. }else
  763. {
  764. total1.setOutputBig(StringUtils.round(total1.getOutputBig(),2));
  765. }
  766. //大风切出最大值
  767. if (Double.isInfinite(total1.getOutputBigMin()) || Double.isNaN(total1.getOutputBigMin()))
  768. {
  769. total1.setOutputBigMin(0.0);
  770. }else
  771. {
  772. total1.setOutputBigMin(StringUtils.round(total1.getOutputBigMin(),2));
  773. }
  774. //大风切出最大值
  775. if (Double.isInfinite(total1.getOutputBigMax()) || Double.isNaN(total1.getOutputBigMax()))
  776. {
  777. total1.setOutputBigMax(0.0);
  778. }else
  779. {
  780. total1.setOutputBigMax(StringUtils.round(total1.getOutputBigMax(),2));
  781. }
  782. //日小风切入合格率
  783. if (Double.isInfinite(total1.getDayInputSmallRatio()) || Double.isNaN(total1.getDayInputSmallRatio()))
  784. {
  785. total1.setDayInputSmallRatio(0.0);
  786. }else
  787. {
  788. total1.setDayInputSmallRatio(StringUtils.round(total1.getDayInputSmallRatio(),2));
  789. }
  790. //日小风切出合格率
  791. if (Double.isInfinite(total1.getDayOutputSmallRatio()) || Double.isNaN(total1.getDayOutputSmallRatio()))
  792. {
  793. total1.setDayOutputSmallRatio(0.0);
  794. }else
  795. {
  796. total1.setDayOutputSmallRatio(StringUtils.round(total1.getDayOutputSmallRatio(),2));
  797. }
  798. //日大风切入合格率
  799. if (Double.isInfinite(total1.getDayInputBigRatio()) || Double.isNaN(total1.getDayInputBigRatio()))
  800. {
  801. total1.setDayInputBigRatio(0.0);
  802. }else
  803. {
  804. total1.setDayInputBigRatio(StringUtils.round(total1.getDayInputBigRatio(),2));
  805. }
  806. //日大风切出合格率
  807. if (Double.isInfinite(total1.getDayOutputBigRatio()) || Double.isNaN(total1.getDayOutputBigRatio()))
  808. {
  809. total1.setDayOutputBigRatio(0.0);
  810. }else
  811. {
  812. total1.setDayOutputBigRatio(StringUtils.round(total1.getDayOutputBigRatio(),2));
  813. }
  814. //月小风切入合格率
  815. if (Double.isInfinite(total1.getMonthInputSmallRatio()) || Double.isNaN(total1.getMonthInputSmallRatio()))
  816. {
  817. total1.setMonthInputSmallRatio(0.0);
  818. }else
  819. {
  820. total1.setMonthInputSmallRatio(StringUtils.round(total1.getMonthInputSmallRatio(),2));
  821. }
  822. //月小风切出合格率
  823. if (Double.isInfinite(total1.getMonthOutputSmallRatio()) || Double.isNaN(total1.getMonthOutputSmallRatio()))
  824. {
  825. total1.setMonthOutputSmallRatio(0.0);
  826. }else
  827. {
  828. total1.setMonthOutputSmallRatio(StringUtils.round(total1.getMonthOutputSmallRatio(),2));
  829. }
  830. //月大风切入合格率
  831. if (Double.isInfinite(total1.getMonthInputBigRatio()) || Double.isNaN(total1.getMonthInputBigRatio()))
  832. {
  833. total1.setMonthInputBigRatio(0.0);
  834. }else
  835. {
  836. total1.setMonthInputBigRatio(StringUtils.round(total1.getMonthInputBigRatio(),2));
  837. }
  838. //月大风切出合格率
  839. if (Double.isInfinite(total1.getMonthOutputBigRatio()) || Double.isNaN(total1.getMonthOutputBigRatio()))
  840. {
  841. total1.setMonthOutputBigRatio(0.0);
  842. }else
  843. {
  844. total1.setMonthOutputBigRatio(StringUtils.round(total1.getMonthOutputBigRatio(),2));
  845. }
  846. //年小风切入合格率
  847. if (Double.isInfinite(total1.getYearInputSmallRatio()) || Double.isNaN(total1.getYearInputSmallRatio()))
  848. {
  849. total1.setYearInputSmallRatio(0.0);
  850. }else
  851. {
  852. total1.setYearInputSmallRatio(StringUtils.round(total1.getYearInputSmallRatio(),2));
  853. }
  854. //年小风切出合格率
  855. if (Double.isInfinite(total1.getYearOutputSmallRatio()) || Double.isNaN(total1.getYearOutputSmallRatio()))
  856. {
  857. total1.setYearOutputSmallRatio(0.0);
  858. }else
  859. {
  860. total1.setYearOutputSmallRatio(StringUtils.round(total1.getYearOutputSmallRatio(),2));
  861. }
  862. //年大风切入合格率
  863. if (Double.isInfinite(total1.getYearInputBigRatio()) || Double.isNaN(total1.getYearInputBigRatio()))
  864. {
  865. total1.setYearInputBigRatio(0.0);
  866. }else
  867. {
  868. total1.setYearInputBigRatio(StringUtils.round(total1.getYearInputBigRatio(),2));
  869. }
  870. //年大风切出合格率
  871. if (Double.isInfinite(total1.getYearOutputBigRatio()) || Double.isNaN(total1.getYearOutputBigRatio()))
  872. {
  873. total1.setYearOutputBigRatio(0.0);
  874. }else
  875. {
  876. total1.setYearOutputBigRatio(StringUtils.round(total1.getYearOutputBigRatio(),2));
  877. }
  878. //总小风切入合格率
  879. if (Double.isInfinite(total1.getInputSmallRatio()) || Double.isNaN(total1.getInputSmallRatio()))
  880. {
  881. total1.setInputSmallRatio(0.0);
  882. }else
  883. {
  884. total1.setInputSmallRatio(StringUtils.round(total1.getInputSmallRatio(),2));
  885. }
  886. //总小风切出合格率
  887. if (Double.isInfinite(total1.getOutputSmallRatio()) || Double.isNaN(total1.getOutputSmallRatio()))
  888. {
  889. total1.setOutputSmallRatio(0.0);
  890. }else
  891. {
  892. total1.setOutputSmallRatio(StringUtils.round(total1.getOutputSmallRatio(),2));
  893. }
  894. //总大风切入合格率
  895. if (Double.isInfinite(total1.getInputBigRatio()) || Double.isNaN(total1.getInputBigRatio()))
  896. {
  897. total1.setInputBigRatio(0.0);
  898. }else
  899. {
  900. total1.setInputBigRatio(StringUtils.round(total1.getInputBigRatio(),2));
  901. }
  902. //总大风切出合格率
  903. if (Double.isInfinite(total1.getOutputBigMaxRatio()) || Double.isNaN(total1.getOutputBigMaxRatio()))
  904. {
  905. total1.setOutputBigMaxRatio(0.0);
  906. }else
  907. {
  908. total1.setOutputBigMaxRatio(StringUtils.round(total1.getOutputBigMaxRatio(),2));
  909. }
  910. }
  911. private void newMethod(Date end, Date daybegin, Date monthbegin, Date yearbegin, String windturbineId, ProEconInOrOutSpeedTotal total1, ProEconInOrOutSpeedTotal2 total2) {
  912. buildDay(end, daybegin, windturbineId, total1, total2);
  913. buildMonth(end, monthbegin, windturbineId, total1, total2);
  914. buildyear(end, yearbegin, windturbineId, total1, total2);
  915. QueryWrapper<ProEconInOrOutSpeedTotal> queryWrapper = new QueryWrapper<>();
  916. queryWrapper.eq("windturbine_id",windturbineId);
  917. List<ProEconInOrOutSpeedTotal> items = proEconInOrOutSpeedTotalService.list(queryWrapper);
  918. // .stream()
  919. // .filter(i -> i.getWindturbineId().equals(windturbineId)).collect(Collectors.toList());
  920. items.add(total1);
  921. //总小风切入
  922. DoubleSummaryStatistics summaryStatistics = items.stream()
  923. .filter(i -> StringUtils.notEmp(i.getDayInputSmall()) && i.getDayInputSmall() > 0)
  924. .mapToDouble(ProEconInOrOutSpeedTotal::getDayInputSmall).summaryStatistics();
  925. total1.setInputSmall(summaryStatistics.getAverage());
  926. //总小风切入最大值
  927. summaryStatistics = items.stream()
  928. .filter(i -> StringUtils.notEmp(i.getDayInputSmallMax()) && i.getDayInputSmallMax() > 0)
  929. .mapToDouble(ProEconInOrOutSpeedTotal::getDayInputSmallMax).summaryStatistics();
  930. total1.setInputSmallMax(summaryStatistics.getMax());
  931. //总小风切入最小值
  932. summaryStatistics = items.stream()
  933. .filter(i -> StringUtils.notEmp(i.getDayInputSmallMin()) && i.getDayInputSmallMin() > 0)
  934. .mapToDouble(ProEconInOrOutSpeedTotal::getDayInputSmallMin).summaryStatistics();
  935. total1.setInputSmallMin(summaryStatistics.getMin());
  936. //总大风切入
  937. summaryStatistics = items.stream()
  938. .filter(i -> StringUtils.notEmp(i.getDayInputBig()) && i.getDayInputBig() > 0)
  939. .mapToDouble(ProEconInOrOutSpeedTotal::getDayInputBig).summaryStatistics();
  940. total1.setInputBig(summaryStatistics.getAverage());
  941. //总大风切入最大值
  942. summaryStatistics = items.stream()
  943. .filter(i -> StringUtils.notEmp(i.getDayInputBigMax()) && i.getDayInputBigMax() > 0)
  944. .mapToDouble(ProEconInOrOutSpeedTotal::getDayInputBigMax).summaryStatistics();
  945. total1.setInputBigMax(summaryStatistics.getMax());
  946. //总大风切入最小值
  947. summaryStatistics = items.stream()
  948. .filter(i -> StringUtils.notEmp(i.getDayInputBigMin()) && i.getDayInputBigMin() > 0)
  949. .mapToDouble(ProEconInOrOutSpeedTotal::getDayInputBigMin).summaryStatistics();
  950. total1.setInputBigMin(summaryStatistics.getMin());
  951. //总小风切出
  952. summaryStatistics = items.stream()
  953. .filter(i -> StringUtils.notEmp(i.getDayOutputSmall()) && i.getDayOutputSmall() > 0)
  954. .mapToDouble(ProEconInOrOutSpeedTotal::getDayOutputSmall).summaryStatistics();
  955. total1.setOutputSmall(summaryStatistics.getAverage());
  956. //总小风切出最大值
  957. summaryStatistics = items.stream()
  958. .filter(i -> StringUtils.notEmp(i.getDayOutputSmallMax()) && i.getDayOutputSmallMax() > 0)
  959. .mapToDouble(ProEconInOrOutSpeedTotal::getDayOutputSmallMax).summaryStatistics();
  960. total1.setOutputSmallMax(summaryStatistics.getMax());
  961. //总小风切出最小值
  962. summaryStatistics = items.stream()
  963. .filter(i -> StringUtils.notEmp(i.getDayOutputSmallMin()) && i.getDayOutputSmallMin() > 0)
  964. .mapToDouble(ProEconInOrOutSpeedTotal::getDayOutputSmallMin).summaryStatistics();
  965. total1.setOutputSmallMin(summaryStatistics.getMin());
  966. //总大风切出
  967. summaryStatistics = items.stream()
  968. .filter(i -> StringUtils.notEmp(i.getDayOutputBig()) && i.getDayOutputBig() > 0)
  969. .mapToDouble(ProEconInOrOutSpeedTotal::getDayOutputBig).summaryStatistics();
  970. total1.setOutputBig(summaryStatistics.getAverage());
  971. //总大风切出最大值
  972. summaryStatistics = items.stream()
  973. .filter(i -> StringUtils.notEmp(i.getDayOutputBigMax()) && i.getDayOutputBigMax() > 0)
  974. .mapToDouble(ProEconInOrOutSpeedTotal::getDayOutputBigMax).summaryStatistics();
  975. total1.setOutputBigMax(summaryStatistics.getMax());
  976. //总大风切出最小值
  977. summaryStatistics = items.stream()
  978. .filter(i -> StringUtils.notEmp(i.getDayOutputBigMin()) && i.getDayOutputBigMin() > 0)
  979. .mapToDouble(ProEconInOrOutSpeedTotal::getDayOutputBigMin).summaryStatistics();
  980. total1.setOutputBigMin(summaryStatistics.getMin());
  981. QueryWrapper<ProEconInputOrOutputSpeed> queryWrapper2 = new QueryWrapper<>();
  982. queryWrapper2.eq("windturbine_id",windturbineId).isNotNull("speed").ne("speed",0);
  983. List<ProEconInputOrOutputSpeed> recordList = proEconInputOrOutputSpeedService.list(queryWrapper2);
  984. // .stream()
  985. // .filter(i -> i.getWindturbineId().equals(windturbineId) && StringUtils.notEmp(i.getSpeed())
  986. // && i.getSpeed() != 0).collect(Collectors.toList());
  987. List<ProEconInputOrOutputSpeed> inputrecordList = recordList.stream()
  988. .filter(i -> i.getInputOrOutput() == 1).collect(Collectors.toList());
  989. List<ProEconInputOrOutputSpeed> outputrecordList = recordList.stream()
  990. .filter(i -> i.getInputOrOutput() == 0).collect(Collectors.toList());
  991. List<ProEconInputOrOutputSpeed> AList = inputrecordList.stream().filter(i -> i.getSpeed() > 0
  992. && i.getSpeed() <= 3).collect(Collectors.toList());
  993. List<ProEconInputOrOutputSpeed> ACountList = inputrecordList.stream().filter(i -> i.getSpeed() > 0
  994. && i.getSpeed() <= 11).collect(Collectors.toList());
  995. List<ProEconInputOrOutputSpeed> BList = outputrecordList.stream().filter(i -> i.getSpeed() > 0
  996. && i.getSpeed() <= 3).collect(Collectors.toList());
  997. List<ProEconInputOrOutputSpeed> BCountList = outputrecordList.stream().filter(i -> i.getSpeed() > 0
  998. && i.getSpeed() <= 11).collect(Collectors.toList());
  999. List<ProEconInputOrOutputSpeed> CList = inputrecordList.stream().filter(i -> i.getSpeed() >= 25).collect(Collectors.toList());
  1000. List<ProEconInputOrOutputSpeed> CCountList = inputrecordList.stream().filter(i -> i.getSpeed() > 11).collect(Collectors.toList());
  1001. List<ProEconInputOrOutputSpeed> DList = outputrecordList.stream().filter(i -> i.getSpeed() >= 25).collect(Collectors.toList());
  1002. List<ProEconInputOrOutputSpeed> DCountList = outputrecordList
  1003. .stream().filter(i -> i.getSpeed() > 11).collect(Collectors.toList());
  1004. //总小风切入合格率
  1005. if (ACountList.size() != 0) {
  1006. total1.setInputSmallRatio(new BigDecimal(AList.size()).divide(new BigDecimal(ACountList.size()),
  1007. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1008. } else {
  1009. total1.setInputSmallRatio(0.0);
  1010. }
  1011. //总小风切出合格率
  1012. if (BCountList.size() != 0) {
  1013. total1.setOutputSmallRatio(new BigDecimal(BList.size()).divide(new BigDecimal(BCountList.size()),
  1014. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1015. } else {
  1016. total1.setOutputSmallRatio(0.0);
  1017. }
  1018. //总大风切入合格率
  1019. if (CCountList.size() != 0) {
  1020. total1.setInputBigRatio(new BigDecimal(CList.size()).divide(new BigDecimal(CCountList.size()),
  1021. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1022. } else {
  1023. total1.setInputBigRatio(0.0);
  1024. }
  1025. //总大风切出合格率
  1026. if (DCountList.size() != 0) {
  1027. total1.setOutputBigMaxRatio(new BigDecimal(DList.size()).divide(new BigDecimal(DCountList.size()),
  1028. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1029. } else {
  1030. total1.setOutputBigMaxRatio(0.0);
  1031. }
  1032. }
  1033. private void buildDay(Date end, Date daybegin, String windturbineId, ProEconInOrOutSpeedTotal total1, ProEconInOrOutSpeedTotal2 total2) {
  1034. int count;
  1035. QueryWrapper<ProEconInputOrOutputSpeed> queryWrapper = new QueryWrapper<>();
  1036. queryWrapper.ge("record_date",daybegin).le("record_date",end).eq("windturbine_id",windturbineId).isNotNull("speed");
  1037. List<ProEconInputOrOutputSpeed> recordList = proEconInputOrOutputSpeedService.list(queryWrapper);
  1038. // .stream()
  1039. // .filter(i -> i.getWindturbineId().equals(windturbineId) && StringUtils.notEmp(i.getSpeed())
  1040. // && (i.getRecordDate().compareTo(daybegin) == 0 || i.getRecordDate().after(daybegin))
  1041. // && (i.getRecordDate().compareTo(end) == 0 || i.getRecordDate().before(end))
  1042. // && i.getSpeed() != 0).collect(Collectors.toList());
  1043. List<ProEconInputOrOutputSpeed> inputrecordList = recordList.stream()
  1044. .filter(i -> i.getInputOrOutput() == 1).collect(Collectors.toList());
  1045. List<ProEconInputOrOutputSpeed> outputrecordList = recordList.stream()
  1046. .filter(i -> i.getInputOrOutput() == 0).collect(Collectors.toList());
  1047. List<ProEconInputOrOutputSpeed> AList = inputrecordList.stream().filter(i -> i.getSpeed() > 0
  1048. && i.getSpeed() <= 3).collect(Collectors.toList());
  1049. List<ProEconInputOrOutputSpeed> ACountList = inputrecordList.stream().filter(i -> i.getSpeed() > 0
  1050. && i.getSpeed() <= 11).collect(Collectors.toList());
  1051. List<ProEconInputOrOutputSpeed> BList = outputrecordList.stream().filter(i -> i.getSpeed() > 0
  1052. && i.getSpeed() <= 3).collect(Collectors.toList());
  1053. List<ProEconInputOrOutputSpeed> BCountList = outputrecordList.stream().filter(i -> i.getSpeed() > 0
  1054. && i.getSpeed() <= 11).collect(Collectors.toList());
  1055. List<ProEconInputOrOutputSpeed> CList = inputrecordList.stream().filter(i -> i.getSpeed() > 0
  1056. && i.getSpeed() >= 25).collect(Collectors.toList());
  1057. List<ProEconInputOrOutputSpeed> CCountList = inputrecordList.stream().filter(i -> i.getSpeed() > 0
  1058. && i.getSpeed() > 11).collect(Collectors.toList());
  1059. List<ProEconInputOrOutputSpeed> DList = outputrecordList.stream().filter(i -> i.getSpeed() >= 25).collect(Collectors.toList());
  1060. List<ProEconInputOrOutputSpeed> DCountList = outputrecordList
  1061. .stream().filter(i -> i.getSpeed() > 11).collect(Collectors.toList());
  1062. if (ACountList.size() != 0) {
  1063. total1.setDayInputSmallRatio(new BigDecimal(AList.size()).divide(new BigDecimal(ACountList.size()),
  1064. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1065. } else {
  1066. total1.setDayInputSmallRatio(0.0);
  1067. }
  1068. if (BCountList.size() != 0) {
  1069. total1.setDayOutputSmallRatio(new BigDecimal(BList.size()).divide(new BigDecimal(BCountList.size()),
  1070. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1071. } else {
  1072. total1.setDayOutputSmallRatio(0.0);
  1073. }
  1074. if (CCountList.size() != 0) {
  1075. total1.setDayInputBigRatio(new BigDecimal(CList.size()).divide(new BigDecimal(CCountList.size()),
  1076. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1077. } else {
  1078. total1.setDayInputBigRatio(0.0);
  1079. }
  1080. if (DCountList.size() != 0) {
  1081. total1.setDayOutputBigRatio(new BigDecimal(DList.size()).divide(new BigDecimal(DCountList.size()),
  1082. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1083. } else {
  1084. total1.setDayOutputBigRatio(0.0);
  1085. }
  1086. List<ProEconInputOrOutputSpeed> A1List = inputrecordList.stream().filter(i -> i.getSpeed() > 0
  1087. && i.getSpeed() < 2).collect(Collectors.toList());
  1088. List<ProEconInputOrOutputSpeed> A2List = inputrecordList.stream().filter(i -> i.getSpeed() >= 2
  1089. && i.getSpeed() < 2.5).collect(Collectors.toList());
  1090. List<ProEconInputOrOutputSpeed> A3List = inputrecordList.stream().filter(i -> i.getSpeed() >= 2.5
  1091. && i.getSpeed() < 3).collect(Collectors.toList());
  1092. List<ProEconInputOrOutputSpeed> A4List = inputrecordList.stream().filter(i -> i.getSpeed() >= 3
  1093. && i.getSpeed() < 3.5).collect(Collectors.toList());
  1094. List<ProEconInputOrOutputSpeed> A5List = inputrecordList.stream().filter(i -> i.getSpeed() >= 3.5
  1095. && i.getSpeed() < 4).collect(Collectors.toList());
  1096. List<ProEconInputOrOutputSpeed> A6List = inputrecordList.stream().filter(i -> i.getSpeed() >= 4
  1097. && i.getSpeed() < 5).collect(Collectors.toList());
  1098. List<ProEconInputOrOutputSpeed> A7List = inputrecordList.stream().filter(i -> i.getSpeed() >= 5
  1099. && i.getSpeed() <= 11).collect(Collectors.toList());
  1100. DoubleSummaryStatistics summaryStatistics = inputrecordList.stream().filter(i ->
  1101. i.getSpeed() > 0 && i.getSpeed() < 5)
  1102. .mapToDouble(ProEconInputOrOutputSpeed::getSpeed).summaryStatistics();
  1103. total1.setDayInputSmall(summaryStatistics.getAverage());
  1104. total1.setDayInputSmallMax(summaryStatistics.getMax());
  1105. total1.setDayInputSmallMin(summaryStatistics.getMin());
  1106. summaryStatistics = inputrecordList.stream().filter(i ->
  1107. i.getSpeed() > 18 && i.getSpeed() < 30)
  1108. .mapToDouble(ProEconInputOrOutputSpeed::getSpeed).summaryStatistics();
  1109. total1.setDayInputBig(summaryStatistics.getAverage());
  1110. total1.setDayInputBigMax(summaryStatistics.getMax());
  1111. total1.setDayInputBigMin(summaryStatistics.getMin());
  1112. total2.setDaya1((double) A1List.size());
  1113. total2.setDaya2((double) A2List.size());
  1114. total2.setDaya3((double) A3List.size());
  1115. total2.setDaya4((double) A4List.size());
  1116. total2.setDaya5((double) A5List.size());
  1117. total2.setDaya6((double) A6List.size());
  1118. total2.setDaya7((double) A7List.size());
  1119. count = A1List.size() + A2List.size() + A3List.size() + A4List.size() + A5List.size() + A6List.size() + A7List.size();
  1120. if (count > 0) {
  1121. total2.setDaya8(new BigDecimal(A1List.size()).divide(new BigDecimal(count),
  1122. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1123. total2.setDaya9(new BigDecimal(A2List.size()).divide(new BigDecimal(count),
  1124. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1125. total2.setDaya10(new BigDecimal(A3List.size()).divide(new BigDecimal(count),
  1126. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1127. total2.setDaya11(new BigDecimal(A4List.size()).divide(new BigDecimal(count),
  1128. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1129. total2.setDaya12(new BigDecimal(A5List.size()).divide(new BigDecimal(count),
  1130. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1131. total2.setDaya13(new BigDecimal(A6List.size()).divide(new BigDecimal(count),
  1132. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1133. total2.setDaya14(new BigDecimal(A7List.size()).divide(new BigDecimal(count),
  1134. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1135. } else {
  1136. total2.setDaya8(0.0);
  1137. total2.setDaya9(0.0);
  1138. total2.setDaya10(0.0);
  1139. total2.setDaya11(0.0);
  1140. total2.setDaya12(0.0);
  1141. total2.setDaya13(0.0);
  1142. total2.setDaya14(0.0);
  1143. }
  1144. List<ProEconInputOrOutputSpeed> B1List = outputrecordList.stream().filter(i -> i.getSpeed() > 0
  1145. && i.getSpeed() < 2).collect(Collectors.toList());
  1146. List<ProEconInputOrOutputSpeed> B2List = outputrecordList.stream().filter(i -> i.getSpeed() >= 2
  1147. && i.getSpeed() < 2.5).collect(Collectors.toList());
  1148. List<ProEconInputOrOutputSpeed> B3List = outputrecordList.stream().filter(i -> i.getSpeed() >= 2.5
  1149. && i.getSpeed() < 3).collect(Collectors.toList());
  1150. List<ProEconInputOrOutputSpeed> B4List = outputrecordList.stream().filter(i -> i.getSpeed() >= 3
  1151. && i.getSpeed() < 3.5).collect(Collectors.toList());
  1152. List<ProEconInputOrOutputSpeed> B5List = outputrecordList.stream().filter(i -> i.getSpeed() >= 3.5
  1153. && i.getSpeed() < 4).collect(Collectors.toList());
  1154. List<ProEconInputOrOutputSpeed> B6List = outputrecordList.stream().filter(i -> i.getSpeed() >= 4
  1155. && i.getSpeed() < 5).collect(Collectors.toList());
  1156. List<ProEconInputOrOutputSpeed> B7List = outputrecordList.stream().filter(i -> i.getSpeed() >= 5
  1157. && i.getSpeed() <= 11).collect(Collectors.toList());
  1158. summaryStatistics = outputrecordList.stream().filter(i ->
  1159. i.getSpeed() > 0 && i.getSpeed() < 5)
  1160. .mapToDouble(ProEconInputOrOutputSpeed::getSpeed).summaryStatistics();
  1161. total1.setDayOutputSmall(summaryStatistics.getAverage());
  1162. total1.setDayOutputSmallMax(summaryStatistics.getMax());
  1163. total1.setDayOutputSmallMin(summaryStatistics.getMin());
  1164. summaryStatistics = outputrecordList.stream().filter(i ->
  1165. i.getSpeed() > 18 && i.getSpeed() < 30)
  1166. .mapToDouble(ProEconInputOrOutputSpeed::getSpeed).summaryStatistics();
  1167. total1.setDayOutputBig(summaryStatistics.getAverage());
  1168. total1.setDayOutputBigMax(summaryStatistics.getMax());
  1169. total1.setDayOutputBigMin(summaryStatistics.getMin());
  1170. total2.setDaya1((double) B1List.size());
  1171. total2.setDaya2((double) B2List.size());
  1172. total2.setDaya3((double) B3List.size());
  1173. total2.setDaya4((double) B4List.size());
  1174. total2.setDaya5((double) B5List.size());
  1175. total2.setDaya6((double) B6List.size());
  1176. total2.setDaya7((double) B7List.size());
  1177. count = B1List.size() + B2List.size() + B3List.size() + B4List.size() + B5List.size() + B6List.size() + B7List.size();
  1178. if (count > 0) {
  1179. total2.setDaya8(new BigDecimal(B1List.size()).divide(new BigDecimal(count),
  1180. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1181. total2.setDaya9(new BigDecimal(B2List.size()).divide(new BigDecimal(count),
  1182. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1183. total2.setDaya10(new BigDecimal(B3List.size()).divide(new BigDecimal(count),
  1184. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1185. total2.setDaya11(new BigDecimal(B4List.size()).divide(new BigDecimal(count),
  1186. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1187. total2.setDaya12(new BigDecimal(B5List.size()).divide(new BigDecimal(count),
  1188. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1189. total2.setDaya13(new BigDecimal(B6List.size()).divide(new BigDecimal(count),
  1190. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1191. total2.setDaya14(new BigDecimal(B7List.size()).divide(new BigDecimal(count),
  1192. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1193. } else {
  1194. total2.setDaya8(0.0);
  1195. total2.setDaya9(0.0);
  1196. total2.setDaya10(0.0);
  1197. total2.setDaya11(0.0);
  1198. total2.setDaya12(0.0);
  1199. total2.setDaya13(0.0);
  1200. total2.setDaya14(0.0);
  1201. }
  1202. }
  1203. private void buildMonth(Date end, Date monthbegin, String windturbineId, ProEconInOrOutSpeedTotal total1, ProEconInOrOutSpeedTotal2 total2) {
  1204. int count;
  1205. QueryWrapper<ProEconInputOrOutputSpeed> queryWrapper = new QueryWrapper<>();
  1206. queryWrapper.ge("record_date",monthbegin).le("record_date",end).eq("windturbine_id",windturbineId).isNotNull("speed");
  1207. List<ProEconInputOrOutputSpeed> recordList = proEconInputOrOutputSpeedService.list(queryWrapper);
  1208. // .stream()
  1209. // .filter(i -> i.getWindturbineId().equals(windturbineId) && StringUtils.notEmp(i.getSpeed())
  1210. // && (i.getRecordDate().compareTo(monthbegin) == 0 || i.getRecordDate().after(monthbegin))
  1211. // && (i.getRecordDate().compareTo(end) == 0 || i.getRecordDate().before(end))
  1212. // && i.getSpeed() != 0).collect(Collectors.toList());
  1213. List<ProEconInputOrOutputSpeed> inputrecordList = recordList.stream()
  1214. .filter(i -> i.getInputOrOutput() == 1).collect(Collectors.toList());
  1215. List<ProEconInputOrOutputSpeed> outputrecordList = recordList.stream()
  1216. .filter(i -> i.getInputOrOutput() == 0).collect(Collectors.toList());
  1217. List<ProEconInputOrOutputSpeed> AList = inputrecordList.stream().filter(i -> i.getSpeed() > 0
  1218. && i.getSpeed() <= 3).collect(Collectors.toList());
  1219. List<ProEconInputOrOutputSpeed> ACountList = inputrecordList.stream().filter(i -> i.getSpeed() > 0
  1220. && i.getSpeed() <= 11).collect(Collectors.toList());
  1221. List<ProEconInputOrOutputSpeed> BList = outputrecordList.stream().filter(i -> i.getSpeed() > 0
  1222. && i.getSpeed() <= 3).collect(Collectors.toList());
  1223. List<ProEconInputOrOutputSpeed> BCountList = outputrecordList.stream().filter(i -> i.getSpeed() > 0
  1224. && i.getSpeed() <= 11).collect(Collectors.toList());
  1225. List<ProEconInputOrOutputSpeed> CList = inputrecordList.stream().filter(i -> i.getSpeed() > 0
  1226. && i.getSpeed() >= 25).collect(Collectors.toList());
  1227. List<ProEconInputOrOutputSpeed> CCountList = inputrecordList.stream().filter(i -> i.getSpeed() > 0
  1228. && i.getSpeed() > 11).collect(Collectors.toList());
  1229. List<ProEconInputOrOutputSpeed> DList = outputrecordList.stream().filter(i -> i.getSpeed() >= 25).collect(Collectors.toList());
  1230. List<ProEconInputOrOutputSpeed> DCountList = outputrecordList
  1231. .stream().filter(i -> i.getSpeed() > 11).collect(Collectors.toList());
  1232. if (ACountList.size() != 0) {
  1233. total1.setMonthInputSmallRatio(new BigDecimal(AList.size()).divide(new BigDecimal(ACountList.size()),
  1234. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1235. } else {
  1236. total1.setMonthInputSmallRatio(0.0);
  1237. }
  1238. if (BCountList.size() != 0) {
  1239. total1.setMonthOutputSmallRatio(new BigDecimal(BList.size()).divide(new BigDecimal(BCountList.size()),
  1240. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1241. } else {
  1242. total1.setMonthOutputSmallRatio(0.0);
  1243. }
  1244. if (CCountList.size() != 0) {
  1245. total1.setMonthInputBigRatio(new BigDecimal(CList.size()).divide(new BigDecimal(CCountList.size()),
  1246. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1247. } else {
  1248. total1.setMonthInputBigRatio(0.0);
  1249. }
  1250. if (DCountList.size() != 0) {
  1251. total1.setMonthOutputBigRatio(new BigDecimal(DList.size()).divide(new BigDecimal(DCountList.size()),
  1252. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1253. } else {
  1254. total1.setMonthOutputBigRatio(0.0);
  1255. }
  1256. List<ProEconInputOrOutputSpeed> A1List = inputrecordList.stream().filter(i -> i.getSpeed() > 0
  1257. && i.getSpeed() < 2).collect(Collectors.toList());
  1258. List<ProEconInputOrOutputSpeed> A2List = inputrecordList.stream().filter(i -> i.getSpeed() >= 2
  1259. && i.getSpeed() < 2.5).collect(Collectors.toList());
  1260. List<ProEconInputOrOutputSpeed> A3List = inputrecordList.stream().filter(i -> i.getSpeed() >= 2.5
  1261. && i.getSpeed() < 3).collect(Collectors.toList());
  1262. List<ProEconInputOrOutputSpeed> A4List = inputrecordList.stream().filter(i -> i.getSpeed() >= 3
  1263. && i.getSpeed() < 3.5).collect(Collectors.toList());
  1264. List<ProEconInputOrOutputSpeed> A5List = inputrecordList.stream().filter(i -> i.getSpeed() >= 3.5
  1265. && i.getSpeed() < 4).collect(Collectors.toList());
  1266. List<ProEconInputOrOutputSpeed> A6List = inputrecordList.stream().filter(i -> i.getSpeed() >= 4
  1267. && i.getSpeed() < 5).collect(Collectors.toList());
  1268. List<ProEconInputOrOutputSpeed> A7List = inputrecordList.stream().filter(i -> i.getSpeed() >= 5
  1269. && i.getSpeed() <= 11).collect(Collectors.toList());
  1270. DoubleSummaryStatistics summaryStatistics = inputrecordList.stream().filter(i ->
  1271. i.getSpeed() > 0 && i.getSpeed() < 5)
  1272. .mapToDouble(ProEconInputOrOutputSpeed::getSpeed).summaryStatistics();
  1273. total1.setMonthInputSmall(summaryStatistics.getAverage());
  1274. total1.setMonthInputSmallMax(summaryStatistics.getMax());
  1275. total1.setMonthInputSmallMin(summaryStatistics.getMin());
  1276. summaryStatistics = inputrecordList.stream().filter(i ->
  1277. i.getSpeed() > 18 && i.getSpeed() < 30)
  1278. .mapToDouble(ProEconInputOrOutputSpeed::getSpeed).summaryStatistics();
  1279. total1.setMonthInputBig(summaryStatistics.getAverage());
  1280. total1.setMonthInputBigMax(summaryStatistics.getMax());
  1281. total1.setMonthInputBigMin(summaryStatistics.getMin());
  1282. total2.setMontha1((double) A1List.size());
  1283. total2.setMontha2((double) A2List.size());
  1284. total2.setMontha3((double) A3List.size());
  1285. total2.setMontha4((double) A4List.size());
  1286. total2.setMontha5((double) A5List.size());
  1287. total2.setMontha6((double) A6List.size());
  1288. total2.setMontha7((double) A7List.size());
  1289. count = A1List.size() + A2List.size() + A3List.size() + A4List.size() + A5List.size() + A6List.size() + A7List.size();
  1290. if (count > 0) {
  1291. total2.setMontha8(new BigDecimal(A1List.size()).divide(new BigDecimal(count),
  1292. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1293. total2.setMontha9(new BigDecimal(A2List.size()).divide(new BigDecimal(count),
  1294. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1295. total2.setMontha10(new BigDecimal(A3List.size()).divide(new BigDecimal(count),
  1296. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1297. total2.setMontha11(new BigDecimal(A4List.size()).divide(new BigDecimal(count),
  1298. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1299. total2.setMontha12(new BigDecimal(A5List.size()).divide(new BigDecimal(count),
  1300. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1301. total2.setMontha13(new BigDecimal(A6List.size()).divide(new BigDecimal(count),
  1302. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1303. total2.setMontha14(new BigDecimal(A7List.size()).divide(new BigDecimal(count),
  1304. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1305. } else {
  1306. total2.setMontha8(0.0);
  1307. total2.setMontha9(0.0);
  1308. total2.setMontha10(0.0);
  1309. total2.setMontha11(0.0);
  1310. total2.setMontha12(0.0);
  1311. total2.setMontha13(0.0);
  1312. total2.setMontha14(0.0);
  1313. }
  1314. List<ProEconInputOrOutputSpeed> B1List = outputrecordList.stream().filter(i -> i.getSpeed() > 0
  1315. && i.getSpeed() < 2).collect(Collectors.toList());
  1316. List<ProEconInputOrOutputSpeed> B2List = outputrecordList.stream().filter(i -> i.getSpeed() >= 2
  1317. && i.getSpeed() < 2.5).collect(Collectors.toList());
  1318. List<ProEconInputOrOutputSpeed> B3List = outputrecordList.stream().filter(i -> i.getSpeed() >= 2.5
  1319. && i.getSpeed() < 3).collect(Collectors.toList());
  1320. List<ProEconInputOrOutputSpeed> B4List = outputrecordList.stream().filter(i -> i.getSpeed() >= 3
  1321. && i.getSpeed() < 3.5).collect(Collectors.toList());
  1322. List<ProEconInputOrOutputSpeed> B5List = outputrecordList.stream().filter(i -> i.getSpeed() >= 3.5
  1323. && i.getSpeed() < 4).collect(Collectors.toList());
  1324. List<ProEconInputOrOutputSpeed> B6List = outputrecordList.stream().filter(i -> i.getSpeed() >= 4
  1325. && i.getSpeed() < 5).collect(Collectors.toList());
  1326. List<ProEconInputOrOutputSpeed> B7List = outputrecordList.stream().filter(i -> i.getSpeed() >= 5
  1327. && i.getSpeed() <= 11).collect(Collectors.toList());
  1328. summaryStatistics = outputrecordList.stream().filter(i ->
  1329. i.getSpeed() > 0 && i.getSpeed() < 5)
  1330. .mapToDouble(ProEconInputOrOutputSpeed::getSpeed).summaryStatistics();
  1331. total1.setMonthOutputSmall(summaryStatistics.getAverage());
  1332. total1.setMonthOutputSmallMax(summaryStatistics.getMax());
  1333. total1.setMonthOutputSmallMin(summaryStatistics.getMin());
  1334. summaryStatistics = outputrecordList.stream().filter(i ->
  1335. i.getSpeed() > 18 && i.getSpeed() < 30)
  1336. .mapToDouble(ProEconInputOrOutputSpeed::getSpeed).summaryStatistics();
  1337. total1.setMonthOutputBig(summaryStatistics.getAverage());
  1338. total1.setMonthOutputBigMax(summaryStatistics.getMax());
  1339. total1.setMonthOutputBigMin(summaryStatistics.getMin());
  1340. total2.setMontha1((double) B1List.size());
  1341. total2.setMontha2((double) B2List.size());
  1342. total2.setMontha3((double) B3List.size());
  1343. total2.setMontha4((double) B4List.size());
  1344. total2.setMontha5((double) B5List.size());
  1345. total2.setMontha6((double) B6List.size());
  1346. total2.setMontha7((double) B7List.size());
  1347. count = B1List.size() + B2List.size() + B3List.size() + B4List.size() + B5List.size() + B6List.size() + B7List.size();
  1348. if (count > 0) {
  1349. total2.setMontha8(new BigDecimal(B1List.size()).divide(new BigDecimal(count),
  1350. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1351. total2.setMontha9(new BigDecimal(B2List.size()).divide(new BigDecimal(count),
  1352. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1353. total2.setMontha10(new BigDecimal(B3List.size()).divide(new BigDecimal(count),
  1354. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1355. total2.setMontha11(new BigDecimal(B4List.size()).divide(new BigDecimal(count),
  1356. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1357. total2.setMontha12(new BigDecimal(B5List.size()).divide(new BigDecimal(count),
  1358. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1359. total2.setMontha13(new BigDecimal(B6List.size()).divide(new BigDecimal(count),
  1360. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1361. total2.setMontha14(new BigDecimal(B7List.size()).divide(new BigDecimal(count),
  1362. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1363. } else {
  1364. total2.setMontha8(0.0);
  1365. total2.setMontha9(0.0);
  1366. total2.setMontha10(0.0);
  1367. total2.setMontha11(0.0);
  1368. total2.setMontha12(0.0);
  1369. total2.setMontha13(0.0);
  1370. total2.setMontha14(0.0);
  1371. }
  1372. }
  1373. private void buildyear(Date end, Date yearbegin, String windturbineId, ProEconInOrOutSpeedTotal total1, ProEconInOrOutSpeedTotal2 total2) {
  1374. int count;
  1375. QueryWrapper<ProEconInputOrOutputSpeed> queryWrapper = new QueryWrapper<>();
  1376. queryWrapper.ge("record_date",yearbegin).le("record_date",end).eq("windturbine_id",windturbineId).isNotNull("speed");
  1377. List<ProEconInputOrOutputSpeed> recordList = proEconInputOrOutputSpeedService.list(queryWrapper);
  1378. // .stream()
  1379. // .filter(i -> i.getWindturbineId().equals(windturbineId) && StringUtils.notEmp(i.getSpeed())
  1380. // && (i.getRecordDate().compareTo(yearbegin) == 0 || i.getRecordDate().after(yearbegin))
  1381. // && (i.getRecordDate().compareTo(end) == 0 || i.getRecordDate().before(end))
  1382. // && i.getSpeed() != 0).collect(Collectors.toList());
  1383. List<ProEconInputOrOutputSpeed> inputrecordList = recordList.stream()
  1384. .filter(i -> i.getInputOrOutput() == 1).collect(Collectors.toList());
  1385. List<ProEconInputOrOutputSpeed> outputrecordList = recordList.stream()
  1386. .filter(i -> i.getInputOrOutput() == 0).collect(Collectors.toList());
  1387. List<ProEconInputOrOutputSpeed> AList = inputrecordList.stream().filter(i -> i.getSpeed() > 0
  1388. && i.getSpeed() <= 3).collect(Collectors.toList());
  1389. List<ProEconInputOrOutputSpeed> ACountList = inputrecordList.stream().filter(i -> i.getSpeed() > 0
  1390. && i.getSpeed() <= 11).collect(Collectors.toList());
  1391. List<ProEconInputOrOutputSpeed> BList = outputrecordList.stream().filter(i -> i.getSpeed() > 0
  1392. && i.getSpeed() <= 3).collect(Collectors.toList());
  1393. List<ProEconInputOrOutputSpeed> BCountList = outputrecordList.stream().filter(i -> i.getSpeed() > 0
  1394. && i.getSpeed() <= 11).collect(Collectors.toList());
  1395. List<ProEconInputOrOutputSpeed> CList = inputrecordList.stream().filter(i -> i.getSpeed() > 0
  1396. && i.getSpeed() >= 25).collect(Collectors.toList());
  1397. List<ProEconInputOrOutputSpeed> CCountList = inputrecordList.stream().filter(i -> i.getSpeed() > 0
  1398. && i.getSpeed() > 11).collect(Collectors.toList());
  1399. List<ProEconInputOrOutputSpeed> DList = outputrecordList.stream().filter(i -> i.getSpeed() >= 25).collect(Collectors.toList());
  1400. List<ProEconInputOrOutputSpeed> DCountList = outputrecordList
  1401. .stream().filter(i -> i.getSpeed() > 11).collect(Collectors.toList());
  1402. if (ACountList.size() != 0) {
  1403. total1.setYearInputSmallRatio(new BigDecimal(AList.size()).divide(new BigDecimal(ACountList.size()),
  1404. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1405. } else {
  1406. total1.setYearInputSmallRatio(0.0);
  1407. }
  1408. if (BCountList.size() != 0) {
  1409. total1.setYearOutputSmallRatio(new BigDecimal(BList.size()).divide(new BigDecimal(BCountList.size()),
  1410. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1411. } else {
  1412. total1.setYearOutputSmallRatio(0.0);
  1413. }
  1414. if (CCountList.size() != 0) {
  1415. total1.setYearInputBigRatio(new BigDecimal(CList.size()).divide(new BigDecimal(CCountList.size()),
  1416. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1417. } else {
  1418. total1.setYearInputBigRatio(0.0);
  1419. }
  1420. if (DCountList.size() != 0) {
  1421. total1.setYearOutputBigRatio(new BigDecimal(DList.size()).divide(new BigDecimal(DCountList.size()),
  1422. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1423. } else {
  1424. total1.setYearOutputBigRatio(0.0);
  1425. }
  1426. List<ProEconInputOrOutputSpeed> A1List = inputrecordList.stream().filter(i -> i.getSpeed() > 0
  1427. && i.getSpeed() < 2).collect(Collectors.toList());
  1428. List<ProEconInputOrOutputSpeed> A2List = inputrecordList.stream().filter(i -> i.getSpeed() >= 2
  1429. && i.getSpeed() < 2.5).collect(Collectors.toList());
  1430. List<ProEconInputOrOutputSpeed> A3List = inputrecordList.stream().filter(i -> i.getSpeed() >= 2.5
  1431. && i.getSpeed() < 3).collect(Collectors.toList());
  1432. List<ProEconInputOrOutputSpeed> A4List = inputrecordList.stream().filter(i -> i.getSpeed() >= 3
  1433. && i.getSpeed() < 3.5).collect(Collectors.toList());
  1434. List<ProEconInputOrOutputSpeed> A5List = inputrecordList.stream().filter(i -> i.getSpeed() >= 3.5
  1435. && i.getSpeed() < 4).collect(Collectors.toList());
  1436. List<ProEconInputOrOutputSpeed> A6List = inputrecordList.stream().filter(i -> i.getSpeed() >= 4
  1437. && i.getSpeed() < 5).collect(Collectors.toList());
  1438. List<ProEconInputOrOutputSpeed> A7List = inputrecordList.stream().filter(i -> i.getSpeed() >= 5
  1439. && i.getSpeed() <= 11).collect(Collectors.toList());
  1440. DoubleSummaryStatistics summaryStatistics = inputrecordList.stream().filter(i ->
  1441. i.getSpeed() > 0 && i.getSpeed() < 5)
  1442. .mapToDouble(ProEconInputOrOutputSpeed::getSpeed).summaryStatistics();
  1443. total1.setYearInputSmall(summaryStatistics.getAverage());
  1444. total1.setYearInputSmallMax(summaryStatistics.getMax());
  1445. total1.setYearInputSmallMin(summaryStatistics.getMin());
  1446. summaryStatistics = inputrecordList.stream().filter(i ->
  1447. i.getSpeed() > 18 && i.getSpeed() < 30)
  1448. .mapToDouble(ProEconInputOrOutputSpeed::getSpeed).summaryStatistics();
  1449. total1.setYearInputBig(summaryStatistics.getAverage());
  1450. total1.setYearInputBigMax(summaryStatistics.getMax());
  1451. total1.setYearInputBigMin(summaryStatistics.getMin());
  1452. total2.setYeara1((double) A1List.size());
  1453. total2.setYeara2((double) A2List.size());
  1454. total2.setYeara3((double) A3List.size());
  1455. total2.setYeara4((double) A4List.size());
  1456. total2.setYeara5((double) A5List.size());
  1457. total2.setYeara6((double) A6List.size());
  1458. total2.setYeara7((double) A7List.size());
  1459. count = A1List.size() + A2List.size() + A3List.size() + A4List.size() + A5List.size() + A6List.size() + A7List.size();
  1460. if (count > 0) {
  1461. total2.setYeara8(new BigDecimal(A1List.size()).divide(new BigDecimal(count),
  1462. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1463. total2.setYeara9(new BigDecimal(A2List.size()).divide(new BigDecimal(count),
  1464. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1465. total2.setYeara10(new BigDecimal(A3List.size()).divide(new BigDecimal(count),
  1466. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1467. total2.setYeara11(new BigDecimal(A4List.size()).divide(new BigDecimal(count),
  1468. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1469. total2.setYeara12(new BigDecimal(A5List.size()).divide(new BigDecimal(count),
  1470. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1471. total2.setYeara13(new BigDecimal(A6List.size()).divide(new BigDecimal(count),
  1472. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1473. total2.setYeara14(new BigDecimal(A7List.size()).divide(new BigDecimal(count),
  1474. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1475. } else {
  1476. total2.setYeara8(0.0);
  1477. total2.setYeara9(0.0);
  1478. total2.setYeara10(0.0);
  1479. total2.setYeara11(0.0);
  1480. total2.setYeara12(0.0);
  1481. total2.setYeara13(0.0);
  1482. total2.setYeara14(0.0);
  1483. }
  1484. List<ProEconInputOrOutputSpeed> B1List = outputrecordList.stream().filter(i -> i.getSpeed() > 0
  1485. && i.getSpeed() < 2).collect(Collectors.toList());
  1486. List<ProEconInputOrOutputSpeed> B2List = outputrecordList.stream().filter(i -> i.getSpeed() >= 2
  1487. && i.getSpeed() < 2.5).collect(Collectors.toList());
  1488. List<ProEconInputOrOutputSpeed> B3List = outputrecordList.stream().filter(i -> i.getSpeed() >= 2.5
  1489. && i.getSpeed() < 3).collect(Collectors.toList());
  1490. List<ProEconInputOrOutputSpeed> B4List = outputrecordList.stream().filter(i -> i.getSpeed() >= 3
  1491. && i.getSpeed() < 3.5).collect(Collectors.toList());
  1492. List<ProEconInputOrOutputSpeed> B5List = outputrecordList.stream().filter(i -> i.getSpeed() >= 3.5
  1493. && i.getSpeed() < 4).collect(Collectors.toList());
  1494. List<ProEconInputOrOutputSpeed> B6List = outputrecordList.stream().filter(i -> i.getSpeed() >= 4
  1495. && i.getSpeed() < 5).collect(Collectors.toList());
  1496. List<ProEconInputOrOutputSpeed> B7List = outputrecordList.stream().filter(i -> i.getSpeed() >= 5
  1497. && i.getSpeed() <= 11).collect(Collectors.toList());
  1498. summaryStatistics = outputrecordList.stream().filter(i ->
  1499. i.getSpeed() > 0 && i.getSpeed() < 5)
  1500. .mapToDouble(ProEconInputOrOutputSpeed::getSpeed).summaryStatistics();
  1501. total1.setYearOutputSmall(summaryStatistics.getAverage());
  1502. total1.setYearOutputSmallMax(summaryStatistics.getMax());
  1503. total1.setYearOutputSmallMin(summaryStatistics.getMin());
  1504. summaryStatistics = outputrecordList.stream().filter(i ->
  1505. i.getSpeed() > 18 && i.getSpeed() < 30)
  1506. .mapToDouble(ProEconInputOrOutputSpeed::getSpeed).summaryStatistics();
  1507. total1.setYearOutputBig(summaryStatistics.getAverage());
  1508. total1.setYearOutputBigMax(summaryStatistics.getMax());
  1509. total1.setYearOutputBigMin(summaryStatistics.getMin());
  1510. total2.setYeara1((double) B1List.size());
  1511. total2.setYeara2((double) B2List.size());
  1512. total2.setYeara3((double) B3List.size());
  1513. total2.setYeara4((double) B4List.size());
  1514. total2.setYeara5((double) B5List.size());
  1515. total2.setYeara6((double) B6List.size());
  1516. total2.setYeara7((double) B7List.size());
  1517. count = B1List.size() + B2List.size() + B3List.size() + B4List.size() + B5List.size() + B6List.size() + B7List.size();
  1518. if (count > 0) {
  1519. total2.setYeara8(new BigDecimal(B1List.size()).divide(new BigDecimal(count),
  1520. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1521. total2.setYeara9(new BigDecimal(B2List.size()).divide(new BigDecimal(count),
  1522. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1523. total2.setYeara10(new BigDecimal(B3List.size()).divide(new BigDecimal(count),
  1524. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1525. total2.setYeara11(new BigDecimal(B4List.size()).divide(new BigDecimal(count),
  1526. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1527. total2.setYeara12(new BigDecimal(B5List.size()).divide(new BigDecimal(count),
  1528. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1529. total2.setYeara13(new BigDecimal(B6List.size()).divide(new BigDecimal(count),
  1530. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1531. total2.setYeara14(new BigDecimal(B7List.size()).divide(new BigDecimal(count),
  1532. 4, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue());
  1533. } else {
  1534. total2.setYeara8(0.0);
  1535. total2.setYeara9(0.0);
  1536. total2.setYeara10(0.0);
  1537. total2.setYeara11(0.0);
  1538. total2.setYeara12(0.0);
  1539. total2.setYeara13(0.0);
  1540. total2.setYeara14(0.0);
  1541. }
  1542. }
  1543. }