package com.gyee.generation.service;//package com.gyee.generation.service; import com.gyee.common.contant.ContantXk; import com.gyee.common.model.PointData; import com.gyee.common.model.StringUtils; import com.gyee.generation.init.CacheContext; import com.gyee.generation.model.auto.*; import com.gyee.generation.service.auto.*; import com.gyee.generation.util.DateUtils; import com.gyee.generation.util.realtimesource.IEdosUtil; import com.gyee.generation.util.statisticcs.Initial; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.*; import java.util.stream.Collectors; @Service public class EquipmentInfo4Service { // private static final Logger logger = LoggerFactory.getLogger(EquipmentInfo4Service.class); @Resource private IEdosUtil edosUtil; @Resource private IProEconEquipmentInfoDay4Service proEconEquipmentInfoDay4Service; @Resource private IProEconEquipmentInfoDay2Service proEconEquipmentInfoDay2Service; @Resource private IProEconEquipmentInfoDay3Service proEconEquipmentInfoDay3Service; @Resource private IProEconInOrOutSpeedTotalService proEconInOrOutSpeedTotalService; @Resource private IProEconCurveFittingSubService proEconCurveFittingSubService; @Resource private IProEconCurveFittMonthSubService proEconCurveFittMonthSubService; @Resource private IProEconCurveFittYearSubService proEconCurveFittYearSubService; @Resource private IProEconCurveFittingMainService proEconCurveFittingMainService; @Resource private IProEconCurveFittMonthMainService proEconCurveFittMonthMainService; @Resource private IProEconCurveFittYearMainService proEconCurveFittYearMainService; @Resource private IProEconStateTransitionRatesService proEconStateTransitionRatesService; @Resource private IProEconFaultLiminatedefectsService proEconFaultLiminatedefectsService; @Resource private IProEconWindturbineGoodnessService proEconWindturbineGoodnessService; public void calEquipmentInfoDay(Date recordDate) throws Exception { Calendar c = Calendar.getInstance(); c.setTime(recordDate); Date end = c.getTime(); Date begin = DateUtils.truncate(c.getTime()); //判断是否有重复记录,先删除重复记录 List idls = proEconEquipmentInfoDay4Service.list().stream() .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate)) == 0 && CacheContext.wtmap.containsKey(i.getWindturbineId()) ).map(ProEconEquipmentInfoDay4::getId) .collect(Collectors.toList()); if (idls.size() > 0) { proEconEquipmentInfoDay4Service.removeByIds(idls); } //获取曲线风机切入风速 Map peioomap = new HashMap<>(); List peioostls = proEconInOrOutSpeedTotalService.list().stream().filter(i -> (i.getRecordDate().compareTo(begin) == 0 || i.getRecordDate().after(begin)) && (i.getRecordDate().compareTo(end) == 0 || i.getRecordDate().before(end)) ).collect(Collectors.toList()); if (!peioostls.isEmpty()) { for (ProEconInOrOutSpeedTotal peioo : peioostls) { peioomap.put(peioo.getWindturbineId(), peioo); } } Map wgmap=new HashMap<>(); List wgls = proEconWindturbineGoodnessService.list().stream() .filter(i -> i.getRecorddate().compareTo(DateUtils.truncate(begin))==0 && CacheContext.wtmap.containsKey(i.getWindturbineid())) .collect(Collectors.toList()); if(!wgls.isEmpty()) { for(ProEconWindturbineGoodness wg:wgls) { wgmap.put(wg.getWindturbineid(),wg); } } // //功率一致性接口调用 // Map> glqxyizxMap = coefficientService.coefficient(begin); // //拟合优度接口调用 // Map> nhydMap = goodnessOfFitService.goodnessOfFit(begin); List dayls=new ArrayList<>(); for (ProBasicEquipment wt : CacheContext.wtls) { if (CacheContext.wtpAimap.containsKey(wt.getId())) { ProEconEquipmentInfoDay4 pewp = new ProEconEquipmentInfoDay4(); Initial.initial(pewp); pewp.setCompanyId(wt.getCompanyId()); pewp.setWindpowerstationId(wt.getWindpowerstationId()); pewp.setLineId(wt.getLineId()); pewp.setProjectId(wt.getProjectId()); pewp.setRegionId(wt.getRegionId()); pewp.setRecordDate(DateUtils.truncate(recordDate)); pewp.setWindturbineId(wt.getId()); //昨日的统计结果 List pepidls = new ArrayList<>(); Calendar cl = Calendar.getInstance(); cl.setTime(recordDate); cl.add(Calendar.DAY_OF_MONTH,-1); if (cl.get(Calendar.DAY_OF_MONTH) != 1) { pepidls = proEconEquipmentInfoDay4Service.list().stream() .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(cl.getTime())) == 0 && i.getWindturbineId().equals(wt.getId()) ) .collect(Collectors.toList()); } //获得当日设备统计2表数据 ProEconEquipmentInfoDay2 pepid2 = null; List pepid2ls; pepid2ls = proEconEquipmentInfoDay2Service.list().stream() .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(cl.getTime())) == 0 && i.getWindturbineId().equals(wt.getId()) ).collect(Collectors.toList()); if (!pepid2ls.isEmpty()) { pepid2 = pepid2ls.get(0); } //获得当日设备统计3表数据 ProEconEquipmentInfoDay3 pepid3 = null; List pepid3ls; pepid3ls = proEconEquipmentInfoDay3Service.list().stream() .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(cl.getTime())) == 0 && i.getWindturbineId().equals(wt.getId()) ).collect(Collectors.toList()); if (!pepid3ls.isEmpty()) { pepid3 = pepid3ls.get(0); } calDetiall(peioomap, pewp, end, begin, wt, pepidls, pepid2, pepid3, wgmap); dayls.add(pewp); // proEconEquipmentInfoDay1Service.save(pewp); } } proEconEquipmentInfoDay4Service.saveBatch(dayls); } private void calDetiall(Map peioomap, ProEconEquipmentInfoDay4 pewp, Date end, Date begin, ProBasicEquipment wt, List pepidls, ProEconEquipmentInfoDay2 pepid2, ProEconEquipmentInfoDay3 pepid3, Map wgmap) throws Exception { //*****************************************日信息统计*********************************************************/ Map wtpointmap = CacheContext.wtpAimap.get(wt.getId()); ProEconInOrOutSpeedTotal peiost; //获得功率一致性系数 if (wgmap.containsKey(wt.getId())) { ProEconWindturbineGoodness wg = wgmap.get(wt.getId()); pewp.setRglyzxxs(wg.getDaycoefficient()); } //获得拟合优度 if (wgmap.containsKey(wt.getId())) { ProEconWindturbineGoodness wg = wgmap.get(wt.getId()); pewp.setRnhyd(wg.getDaygoodness()); } if (StringUtils.notEmp(pepid2)) { //获得日有效风时数 pewp.setRyxfss(StringUtils.round(24 - pepid2.getRgzxsmx() - pepid2.getRjxxsmx(), 2)); } if (StringUtils.notEmp(pepid2) && StringUtils.notEmp(pepid3)) { //故障小时 double rgzxsmx = pepid2.getRgzxsmx(); //故障次数 double rgzcsmx = pepid3.getRgzcsmx(); if (rgzcsmx != 0) { double mtbf = new BigDecimal(24).divide(new BigDecimal(rgzcsmx), 2, RoundingMode.HALF_EVEN).doubleValue(); double mttr = new BigDecimal(rgzxsmx).divide(new BigDecimal(rgzcsmx), 2, RoundingMode.HALF_EVEN).doubleValue(); double mttf = mtbf - mttr; pewp.setRmtbf(mtbf); pewp.setRmttr(mttr); pewp.setRmttf(mttf); } else { double mtbf = 24.0; double mttr = 0.0; double mttf = mtbf - mttr; pewp.setRmtbf(mtbf); pewp.setRmttr(mttr); pewp.setRmttf(mttf); } } if (peioomap.containsKey(wt.getId())) { //切入切出统计 peiost = peioomap.get(wt.getId()); //日小风切入风速 pewp.setRxfqrfs(peiost.getDayInputSmall()); //日小风切出风速 pewp.setRxfqcfs(peiost.getDayOutputSmall()); //日大风切入风速 pewp.setRdfqrfs(peiost.getDayInputBig()); //日大风切出风速 pewp.setRdfqcfs(peiost.getDayOutputBig()); if (StringUtils.notEmp(peiost)) { ProBasicEquipmentPoint point = wtpointmap.get(ContantXk.CJ_SSFS); //风速历史查询,每分钟一个点 List fsls = edosUtil.getHistoryDatasSnap(point.getNemCode(), begin.getTime() / 1000, end.getTime() / 1000); if (StringUtils.notEmp(peiost) && !fsls.isEmpty()) { double dayjfsc = 0.0; for (PointData po : fsls) { //小风切入风速 double xfqr = peiost.getDayInputSmall(); //小于小风切入算静风时长累计 if (po.getPointValueInDouble() < xfqr) { dayjfsc++; } } //将分钟转化为小时 dayjfsc = new BigDecimal(dayjfsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue(); pewp.setRjfsc(dayjfsc); } if (CacheContext.modelMap.containsKey(wt.getModelId())) { ProEconEquipmentmodel model = CacheContext.modelMap.get(wt.getModelId()); point = wtpointmap.get(ContantXk.CJ_SSGL); List glls = edosUtil.getHistoryDatasSnap(point.getNemCode(), begin.getTime() / 1000, end.getTime() / 1000); double powerProduction = model.getPowerProduction(); if (!glls.isEmpty() && glls.size() == fsls.size()) { for (int i = 0; i < glls.size(); i++) { //如果功率达到装机容量 if (glls.get(i).getPointValueInDouble() >= powerProduction) { if (pewp.getRedfs() == 0) { //额定风速赋值 pewp.setRedfs(fsls.get(i).getPointValueInDouble()); } else if (pewp.getRedfs() > fsls.get(i).getPointValueInDouble()) { //额定风速赋值,比较风速大小,取最小值 pewp.setRedfs(fsls.get(i).getPointValueInDouble()); } } } } if (pewp.getRedfs() == 0) { //如果没有满发,额定风速赋值保证功率达到满发的对应风速 pewp.setRedfs(11.0); } point = wtpointmap.get(ContantXk.BZGL); List bzglls = edosUtil.getHistoryDatasSnap(point.getNemCode(), begin.getTime() / 1000, end.getTime() / 1000); if (!bzglls.isEmpty() && glls.size() == bzglls.size()) { double number = 0.0; for (int i = 0; i < bzglls.size(); i++) { double bzgl = bzglls.get(i).getPointValueInDouble(); double sjgl = glls.get(i).getPointValueInDouble(); //日对风偏差次数(-50 +50之间) if (Math.abs(bzgl - sjgl) < 50) { number++; } } pewp.setRdfpcl(number); } } } } List pecfmls = proEconCurveFittingMainService.list().stream().filter(i -> i.getRecordDate().compareTo(begin) == 0 && i.getWindturbineId().equals(wt.getId()) ).collect(Collectors.toList()); if (!pecfmls.isEmpty()) { ProEconCurveFittingMain pecfm = pecfmls.get(0); pewp.setRqxpcbzysj(pecfm.getDeviationRate1()); pewp.setRqxpcbbzsj(pecfm.getDeviationRate2()); pewp.setRqxpcbzybz(pecfm.getDeviationRate3()); pewp.setRqxpcbbg(pecfm.getStandardDeviationRate()); pewp.setRqxpcbtb(pecfm.getYearDeviationRate()); pewp.setRqxpcbhb(pecfm.getMonthDeviationRate()); } //**************************************************日三率统计****************************************************************/ List pestrls = proEconStateTransitionRatesService.list().stream() .filter(i -> i.getRecordDate().compareTo(begin) == 0 && i.getWindturbineId().equals(wt.getId()) ).collect(Collectors.toList()); //大于3米20分钟转换及时次数 DoubleSummaryStatistics timerate8_summary = pestrls.stream().mapToDouble(ProEconStateTransitionRates::getTimerate8).summaryStatistics(); //大于3米20分钟转换及时次数合计 double timerate8_sum = timerate8_summary.getSum(); //大于3米状态转换总次数次数 DoubleSummaryStatistics timerate14_summary = pestrls.stream().mapToDouble(ProEconStateTransitionRates::getTimerate14).summaryStatistics(); //大于3米状态转换总次数合计 double timerate14_sum = timerate14_summary.getSum(); if (timerate14_sum != 0) { //日状态转换及时率 double temp = new BigDecimal(timerate8_sum).divide(new BigDecimal(timerate14_sum), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue(); pewp.setRztzhjsl(temp); } else { pewp.setRztzhjsl(100.0); } //20分钟复位及时次数 DoubleSummaryStatistics timerate19_summary = pestrls.stream().mapToDouble(ProEconStateTransitionRates::getTimerate19).summaryStatistics(); //20分钟复位及时次数合计 double timerate19_sum = timerate19_summary.getSum(); //总复位次数 DoubleSummaryStatistics timerate20_summary = pestrls.stream().mapToDouble(ProEconStateTransitionRates::getTimerate20).summaryStatistics(); //总复位次数合计 double timerate20_sum = timerate20_summary.getSum(); if (timerate20_sum != 0) { //日复位及时率 double temp = new BigDecimal(timerate19_sum).divide(new BigDecimal(timerate20_sum), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue(); pewp.setRfwjsl(temp); } else { pewp.setRfwjsl(100.0); } List peflls=proEconFaultLiminatedefectsService.list().stream() .filter(i -> i.getDateTime().compareTo(begin) == 0 && i.getWindturbineId().equals(wt.getId()) ).collect(Collectors.toList()); //消缺及时次数 DoubleSummaryStatistics right_summary = peflls.stream().mapToDouble(ProEconFaultLiminatedefects::getRightCount).summaryStatistics(); //消缺及时次数合计 double right_sum = right_summary.getSum(); //故障次数次数 DoubleSummaryStatistics fault_summary = peflls.stream().mapToDouble(ProEconFaultLiminatedefects::getFaultCount).summaryStatistics(); //故障次数次数合计 double fault_sum = fault_summary.getSum(); if (fault_sum != 0) { //日消缺及时率 double temp = new BigDecimal(right_sum).divide(new BigDecimal(fault_sum), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue(); pewp.setRgzxqjsl(temp); } else { pewp.setRgzxqjsl(100.0); } //**************************************************日三率统计****************************************************************/ List pointls=proEconCurveFittingSubService.list().stream().filter(x-> x.getSpeed() !=null && Double.valueOf(x.getSpeed())>=3.0 && Double.valueOf(x.getSpeed())<5.0 && x.getRecordDate().compareTo(begin) == 0 && x.getWindturbineId().equals(wt.getId()) ).collect(Collectors.toList()); DoubleSummaryStatistics summaryStatistics=pointls.stream().mapToDouble(ProEconCurveFittingSub::getDeviationRate1).summaryStatistics(); pewp.setR35mqxpcl(summaryStatistics.getAverage()); pointls=proEconCurveFittingSubService.list().stream().filter(x-> x.getSpeed() !=null && Double.valueOf(x.getSpeed())>=5.0 && Double.valueOf(x.getSpeed())<11.0 && x.getRecordDate().compareTo(begin) == 0 && x.getWindturbineId().equals(wt.getId()) ).collect(Collectors.toList()); summaryStatistics=pointls.stream().mapToDouble(ProEconCurveFittingSub::getDeviationRate1).summaryStatistics(); pewp.setR511mqxpcl(summaryStatistics.getAverage()); pointls=proEconCurveFittingSubService.list().stream().filter(x-> x.getSpeed() !=null && Double.valueOf(x.getSpeed())>=11.0 && x.getRecordDate().compareTo(begin) == 0 && x.getWindturbineId().equals(wt.getId()) ).collect(Collectors.toList()); summaryStatistics=pointls.stream().mapToDouble(ProEconCurveFittingSub::getDeviationRate1).summaryStatistics(); pewp.setR11mycqxpcl(summaryStatistics.getAverage()); //*******************************************日信息统计*********************************************************/ //*******************************************月信息统计*********************************************************/ Calendar c = Calendar.getInstance(); c.setTime(begin); String year = String.valueOf(c.get(Calendar.YEAR)); String month = String.valueOf(c.get(Calendar.MONTH) + 1); if (pepidls.isEmpty()) { setEquipmentInfoDay4Month(pewp); } else { ProEconEquipmentInfoDay4 pepid = pepidls.get(0); //获得功率一致性系数 if (wgmap.containsKey(wt.getId())) { ProEconWindturbineGoodness wg = wgmap.get(wt.getId()); pewp.setYglyzxxs(wg.getMonthcoefficient()); } //获得拟合优度 if (wgmap.containsKey(wt.getId())) { ProEconWindturbineGoodness wg = wgmap.get(wt.getId()); pewp.setYnhyd(wg.getMonthgoodness()); } if (StringUtils.notEmp(pepid2)) { //获得日有效风时数 pewp.setYyxfss(StringUtils.round(c.get(Calendar.DAY_OF_MONTH) * 24 - pepid2.getYgzxsmx() - pepid2.getYjxxsmx(), 2)); } if (StringUtils.notEmp(pepid2) && StringUtils.notEmp(pepid3)) { //故障小时 double ygzxsmx = pepid2.getYgzxsmx(); //故障次数 double ygzcsmx = pepid3.getYgzcsmx(); if (ygzcsmx != 0) { double mtbf = new BigDecimal(c.get(Calendar.DAY_OF_MONTH) * 24).divide(new BigDecimal(ygzcsmx), 2, RoundingMode.HALF_EVEN).doubleValue(); double mttr = new BigDecimal(ygzxsmx).divide(new BigDecimal(ygzcsmx), 2, RoundingMode.HALF_EVEN).doubleValue(); double mttf = mtbf - mttr; pewp.setYmtbf(mtbf); pewp.setYmttr(mttr); pewp.setYmttf(mttf); } else { double mtbf = c.get(Calendar.DAY_OF_MONTH) * 24; double mttr = 0.0; double mttf = mtbf - mttr; pewp.setYmtbf(mtbf); pewp.setYmttr(mttr); pewp.setYmttf(mttf); } } if (peioomap.containsKey(wt.getId())) { //切入切出统计 peiost = peioomap.get(wt.getId()); //月小风切入风速 pewp.setYxfqrfs(peiost.getMonthInputSmall()); //月小风切出风速 pewp.setYxfqcfs(peiost.getMonthOutputSmall()); //月大风切入风速 pewp.setYdfqrfs(peiost.getMonthInputBig()); //月大风切出风速 pewp.setYdfqcfs(peiost.getMonthOutputBig()); if (StringUtils.notEmp(peiost)) { //静风时长累计 pewp.setYjfsc(pewp.getYjfsc() + pepid.getRjfsc()); if (pewp.getYedfs() == 0) { //如果没有满发,额定风速赋值保证功率达到满发的对应风速 pewp.setYedfs(11.0); } if (pewp.getRedfs() < pepid.getYedfs()) { pewp.setYedfs(pewp.getRedfs()); } else { pewp.setYedfs(pepid.getYedfs()); } //月对风偏差次数(-50 +50之间) pewp.setYdfpcl(pepid.getYdfpcl() + pewp.getRdfpcl()); } } List pecfmmls = proEconCurveFittMonthMainService.list().stream().filter(i -> i.getYear().equals(year) && i.getMonth().equals(month) && i.getWindturbineId().equals(wt.getId()) ).collect(Collectors.toList()); if (!pecfmmls.isEmpty()) { ProEconCurveFittMonthMain pecfm = pecfmmls.get(0); pewp.setYqxpcbzysj(pecfm.getDeviationRate1()); pewp.setYqxpcbbzsj(pecfm.getDeviationRate2()); pewp.setYqxpcbzybz(pecfm.getDeviationRate3()); pewp.setYqxpcbbg(pecfm.getStandardDeviationRate()); pewp.setYqxpcbtb(pecfm.getYearDeviationRate()); pewp.setYqxpcbhb(pecfm.getMonthDeviationRate()); } //************************************************月三率统计****************************************************************/ Calendar cal = Calendar.getInstance(); cal.setTime(begin); cal.set(Calendar.DAY_OF_MONTH, 1); Date monthbiegin = c.getTime(); pestrls =proEconStateTransitionRatesService.list().stream() .filter(i -> (i.getRecordDate().compareTo(monthbiegin) == 0 || i.getRecordDate().after(monthbiegin)) && (i.getRecordDate().compareTo(end) == 0 || i.getRecordDate().before(end)) && i.getWindturbineId().equals(wt.getId()) ).collect(Collectors.toList()); //大于3米20分钟转换及时次数 timerate8_summary = pestrls.stream().mapToDouble(ProEconStateTransitionRates::getTimerate8).summaryStatistics(); //大于3米20分钟转换及时次数合计 timerate8_sum = timerate8_summary.getSum(); //大于3米状态转换总次数次数 timerate14_summary = pestrls.stream().mapToDouble(ProEconStateTransitionRates::getTimerate14).summaryStatistics(); //大于3米状态转换总次数合计 timerate14_sum = timerate14_summary.getSum(); if (timerate14_sum != 0) { //月状态转换及时率 double temp = new BigDecimal(timerate8_sum).divide(new BigDecimal(timerate14_sum), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue(); pewp.setYztzhjsl(temp); } else { pewp.setYztzhjsl(100.0); } //20分钟复位及时次数 timerate19_summary = pestrls.stream().mapToDouble(ProEconStateTransitionRates::getTimerate19).summaryStatistics(); //20分钟复位及时次数合计 timerate19_sum = timerate19_summary.getSum(); //总复位次数 timerate20_summary = pestrls.stream().mapToDouble(ProEconStateTransitionRates::getTimerate20).summaryStatistics(); //总复位次数合计 timerate20_sum = timerate20_summary.getSum(); if (timerate20_sum != 0) { //月复位及时率 double temp = new BigDecimal(timerate19_sum).divide(new BigDecimal(timerate20_sum), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue(); pewp.setYfwjsl(temp); } else { pewp.setYfwjsl(100.0); } peflls=proEconFaultLiminatedefectsService.list().stream() .filter(i -> (i.getDateTime().compareTo(monthbiegin) == 0 || i.getDateTime().after(monthbiegin)) && (i.getDateTime().compareTo(end) == 0 || i.getDateTime().before(end)) && i.getWindturbineId().equals(wt.getId()) ).collect(Collectors.toList()); //消缺及时次数 right_summary = peflls.stream().mapToDouble(ProEconFaultLiminatedefects::getRightCount).summaryStatistics(); //消缺及时次数合计 right_sum = right_summary.getSum(); //故障次数次数 fault_summary = peflls.stream().mapToDouble(ProEconFaultLiminatedefects::getFaultCount).summaryStatistics(); //故障次数次数合计 fault_sum = fault_summary.getSum(); if (fault_sum != 0) { //月消缺及时率 double temp = new BigDecimal(right_sum).divide(new BigDecimal(fault_sum), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue(); pewp.setYgzxqjsl(temp); } else { pewp.setYgzxqjsl(100.0); } //**************************************************月三率统计****************************************************************/ List monthpointls=proEconCurveFittMonthSubService.list().stream().filter(x-> x.getSpeed() !=null && Double.valueOf(x.getSpeed())>=3.0 && Double.valueOf(x.getSpeed())<5.0 && x.getYear().equals(year) && x.getMonth().equals(month) && x.getWindturbineId().equals(wt.getId()) ).collect(Collectors.toList()); summaryStatistics=monthpointls.stream().mapToDouble(ProEconCurveFittMonthSub::getDeviationRate1).summaryStatistics(); pewp.setY35mqxpcl(summaryStatistics.getAverage()); monthpointls=proEconCurveFittMonthSubService.list().stream().filter(x-> x.getSpeed() !=null && Double.valueOf(x.getSpeed())>=5.0 && Double.valueOf(x.getSpeed())<11.0 && x.getYear().equals(year) && x.getMonth().equals(month) && x.getWindturbineId().equals(wt.getId()) ).collect(Collectors.toList()); summaryStatistics=monthpointls.stream().mapToDouble(ProEconCurveFittMonthSub::getDeviationRate1).summaryStatistics(); pewp.setY511mqxpcl(summaryStatistics.getAverage()); monthpointls=proEconCurveFittMonthSubService.list().stream().filter(x-> x.getSpeed() !=null && Double.valueOf(x.getSpeed())>=11.0 && x.getYear().equals(year) && x.getMonth().equals(month) && x.getWindturbineId().equals(wt.getId()) ).collect(Collectors.toList()); summaryStatistics=monthpointls.stream().mapToDouble(ProEconCurveFittMonthSub::getDeviationRate1).summaryStatistics(); pewp.setY11mycqxpcl(summaryStatistics.getAverage()); } //*******************************************月信息统计*********************************************************/ //*******************************************年信息统计*********************************************************/ if (pepidls.isEmpty()) { setEquipmentInfoDay4Year(pewp); } else { ProEconEquipmentInfoDay4 pepid = pepidls.get(0); //获得功率一致性系数 if (wgmap.containsKey(wt.getId())) { ProEconWindturbineGoodness wg = wgmap.get(wt.getId()); pewp.setNglyzxxs(wg.getYearcoefficient()); } //获得拟合优度 if (wgmap.containsKey(wt.getId())) { ProEconWindturbineGoodness wg = wgmap.get(wt.getId()); pewp.setNnhyd(wg.getYeargoodness()); } if (StringUtils.notEmp(pepid2)) { //获得日有效风时数 pewp.setNyxfss(StringUtils.round(c.get(Calendar.DAY_OF_YEAR) * 24 - pepid2.getNgzxsmx() - pepid2.getNjxxsmx(), 2)); } if (StringUtils.notEmp(pepid2) && StringUtils.notEmp(pepid3)) { //故障小时 double ngzxsmx = pepid2.getYgzxsmx(); //故障次数 double ngzcsmx = pepid3.getYgzcsmx(); if (ngzcsmx != 0) { double mtbf = new BigDecimal(c.get(Calendar.DAY_OF_YEAR) * 24).divide(new BigDecimal(ngzcsmx), 2, RoundingMode.HALF_EVEN).doubleValue(); double mttr = new BigDecimal(ngzxsmx).divide(new BigDecimal(ngzcsmx), 2, RoundingMode.HALF_EVEN).doubleValue(); double mttf = mtbf - mttr; pewp.setNmtbf(mtbf); pewp.setNmttr(mttr); pewp.setNmttf(mttf); } else { double mtbf = c.get(Calendar.DAY_OF_YEAR) * 24; double mttr = 0.0; double mttf = mtbf - mttr; pewp.setNmtbf(mtbf); pewp.setNmttr(mttr); pewp.setNmttf(mttf); } } if (peioomap.containsKey(wt.getId())) { //切入切出统计 peiost = peioomap.get(wt.getId()); //年小风切入风速 pewp.setNxfqrfs(peiost.getYearInputSmall()); //年小风切出风速 pewp.setNxfqcfs(peiost.getYearOutputSmall()); //年大风切入风速 pewp.setNdfqrfs(peiost.getYearInputBig()); //年大风切出风速 pewp.setNdfqcfs(peiost.getYearOutputBig()); if (StringUtils.notEmp(peiost)) { //静风时长累计 pewp.setNjfsc(pewp.getNjfsc() + pepid.getRjfsc()); if (pewp.getNedfs() == 0) { //如果没有满发,额定风速赋值保证功率达到满发的对应风速 pewp.setNedfs(11.0); } if (pewp.getRedfs() < pepid.getNedfs()) { pewp.setNedfs(pewp.getRedfs()); } else { pewp.setNedfs(pepid.getNedfs()); } //月对风偏差次数(-50 +50之间) pewp.setNdfpcl(pepid.getNdfpcl() + pewp.getRdfpcl()); } } List pecfYmls = proEconCurveFittYearMainService.list().stream().filter(i -> i.getYear().equals(year) && i.getWindturbineId().equals(wt.getId()) ).collect(Collectors.toList()); if (!pecfYmls.isEmpty()) { ProEconCurveFittYearMain pecfm = pecfYmls.get(0); pewp.setNqxpcbzysj(pecfm.getDeviationRate1()); pewp.setNqxpcbbzsj(pecfm.getDeviationRate2()); pewp.setNqxpcbzybz(pecfm.getDeviationRate3()); pewp.setNqxpcbbg(pecfm.getStandardDeviationRate()); pewp.setNqxpcbtb(pecfm.getYearDeviationRate()); pewp.setNqxpcbhb(pecfm.getMonthDeviationRate()); } //************************************************年三率统计****************************************************************/ Calendar cal = Calendar.getInstance(); cal.setTime(begin); cal.set(Calendar.DAY_OF_YEAR, 1); Date yearbiegin = c.getTime(); pestrls =proEconStateTransitionRatesService.list().stream() .filter(i -> (i.getRecordDate().compareTo(yearbiegin) == 0 || i.getRecordDate().after(yearbiegin)) && (i.getRecordDate().compareTo(end) == 0 || i.getRecordDate().before(end)) && i.getWindturbineId().equals(wt.getId()) ).collect(Collectors.toList()); //大于3米20分钟转换及时次数 timerate8_summary =pestrls.stream().mapToDouble(ProEconStateTransitionRates::getTimerate8).summaryStatistics(); //大于3米20分钟转换及时次数合计 timerate8_sum = timerate8_summary.getSum(); //大于3米状态转换总次数次数 timerate14_summary = pestrls.stream().mapToDouble(ProEconStateTransitionRates::getTimerate14).summaryStatistics(); //大于3米状态转换总次数合计 timerate14_sum = timerate14_summary.getSum(); if (timerate14_sum != 0) { //年状态转换及时率 double temp = new BigDecimal(timerate8_sum).divide(new BigDecimal(timerate14_sum), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue(); pewp.setNztzhjsl(temp); } else { pewp.setNztzhjsl(100.0); } //20分钟复位及时次数 timerate19_summary = pestrls.stream().mapToDouble(ProEconStateTransitionRates::getTimerate19).summaryStatistics(); //20分钟复位及时次数合计 timerate19_sum = timerate19_summary.getSum(); //总复位次数 timerate20_summary = pestrls.stream().mapToDouble(ProEconStateTransitionRates::getTimerate20).summaryStatistics(); //总复位次数合计 timerate20_sum = timerate20_summary.getSum(); if (timerate20_sum != 0) { //年复位及时率 double temp = new BigDecimal(timerate19_sum).divide(new BigDecimal(timerate20_sum), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue(); pewp.setNfwjsl(temp); } else { pewp.setNfwjsl(100.0); } peflls=proEconFaultLiminatedefectsService.list().stream() .filter(i -> (i.getDateTime().compareTo(yearbiegin) == 0 || i.getDateTime().after(yearbiegin)) && (i.getDateTime().compareTo(end) == 0 || i.getDateTime().before(end)) && i.getWindturbineId().equals(wt.getId()) ).collect(Collectors.toList()); //消缺及时次数 right_summary = peflls.stream().mapToDouble(ProEconFaultLiminatedefects::getRightCount).summaryStatistics(); //消缺及时次数合计 right_sum = right_summary.getSum(); //故障次数次数 fault_summary = peflls.stream().mapToDouble(ProEconFaultLiminatedefects::getFaultCount).summaryStatistics(); //故障次数次数合计 fault_sum = fault_summary.getSum(); if (fault_sum != 0) { //年消缺及时率 double temp = new BigDecimal(right_sum).divide(new BigDecimal(fault_sum), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue(); pewp.setNgzxqjsl(temp); } else { pewp.setNgzxqjsl(100.0); } //**************************************************年三率统计****************************************************************/ List yearpointls=proEconCurveFittYearSubService.list().stream().filter(x-> x.getSpeed() !=null && Double.valueOf(x.getSpeed())>=3.0 && Double.valueOf(x.getSpeed())<5.0 && x.getYear().equals(year) && x.getWindturbineId().equals(wt.getId()) ).collect(Collectors.toList()); summaryStatistics=yearpointls.stream().mapToDouble(ProEconCurveFittYearSub::getDeviationRate1).summaryStatistics(); pewp.setN35mqxpcl(summaryStatistics.getAverage()); yearpointls=proEconCurveFittYearSubService.list().stream().filter(x-> x.getSpeed() !=null && Double.valueOf(x.getSpeed())>=5.0 && Double.valueOf(x.getSpeed())<11.0 && x.getYear().equals(year) && x.getWindturbineId().equals(wt.getId()) ).collect(Collectors.toList()); summaryStatistics=yearpointls.stream().mapToDouble(ProEconCurveFittYearSub::getDeviationRate1).summaryStatistics(); pewp.setN511mqxpcl(summaryStatistics.getAverage()); yearpointls=proEconCurveFittYearSubService.list().stream().filter(x-> x.getSpeed() !=null && Double.valueOf(x.getSpeed())>=11.0 && x.getYear().equals(year) && x.getWindturbineId().equals(wt.getId()) ).collect(Collectors.toList()); summaryStatistics=yearpointls.stream().mapToDouble(ProEconCurveFittYearSub::getDeviationRate1).summaryStatistics(); pewp.setN11mycqxpcl(summaryStatistics.getAverage()); } } private static void setEquipmentInfoDay4Year(ProEconEquipmentInfoDay4 pewp) { //* 年静风时长 pewp.setNjfsc(pewp.getRjfsc()); //* 年有效风时数 pewp.setNyxfss(pewp.getRyxfss()); //* 年小风切入风速 pewp.setNxfqrfs(pewp.getRxfqrfs()); //* 年大风切入风速 pewp.setNdfqrfs(pewp.getRdfqrfs()); //* 年小风切出风速 pewp.setNxfqcfs(pewp.getRxfqcfs()); //* 年大风切出风速 pewp.setNdfqcfs(pewp.getRdfqcfs()); //* 年额定风速 pewp.setNedfs(pewp.getRedfs()); //* 年功率一致性系数 pewp.setNglyzxxs(pewp.getRglyzxxs()); //* 年拟合优度 pewp.setNnhyd(pewp.getRnhyd()); //* 年曲线偏差率最优保证 pewp.setNqxpcbzybz(pewp.getRqxpcbzybz()); //* 年曲线偏差率最优实际 pewp.setNqxpcbzysj(pewp.getRqxpcbzysj()); //* 年曲线偏差率保证实际 pewp.setNqxpcbbzsj(pewp.getRqxpcbbzsj()); //* 年曲线偏差率同比 pewp.setNqxpcbtb(pewp.getRqxpcbtb()); //* 年曲线偏差率环比 pewp.setNqxpcbhb(pewp.getRqxpcbhb()); //* 年曲线偏差率标杆 pewp.setNqxpcbbg(pewp.getRqxpcbbg()); //* 年3-5米曲线偏差率 pewp.setN35mqxpcl(pewp.getR35mqxpcl()); //* 年5-11米曲线偏差率 pewp.setN511mqxpcl(pewp.getR511mqxpcl()); //* 年11米以上曲线偏差率 pewp.setN11mycqxpcl(pewp.getR11mycqxpcl()); //* 年对风偏差率(-50 +50之间) pewp.setNdfpcl(pewp.getRdfpcl()); //* 年MTBF pewp.setNmtbf(pewp.getRmtbf()); //* 年MTTR pewp.setNmttr(pewp.getRmttr()); //* 年MTTF pewp.setNmttf(pewp.getRmttf()); //* 年复位及时率 pewp.setNfwjsl(pewp.getRfwjsl()); //* 年状态转换及时率 pewp.setNztzhjsl(pewp.getRztzhjsl()); //* 年故障消缺及时率 pewp.setNgzxqjsl(pewp.getRgzxqjsl()); } private static void setEquipmentInfoDay4Month(ProEconEquipmentInfoDay4 pewp) { //* 月静风时长 pewp.setYjfsc(pewp.getRjfsc()); //* 月有效风时数 pewp.setYyxfss(pewp.getRyxfss()); //* 月小风切入风速 pewp.setYxfqrfs(pewp.getRxfqrfs()); //* 月大风切入风速 pewp.setYdfqrfs(pewp.getRdfqrfs()); //* 月小风切出风速 pewp.setYxfqcfs(pewp.getRxfqcfs()); //* 月大风切出风速 pewp.setYdfqcfs(pewp.getRdfqcfs()); //* 月额定风速 pewp.setYedfs(pewp.getRedfs()); //* 月功率一致性系数 pewp.setYglyzxxs(pewp.getRglyzxxs()); //* 月拟合优度 pewp.setYnhyd(pewp.getRnhyd()); //* 月曲线偏差率最优保证 pewp.setYqxpcbzybz(pewp.getRqxpcbzybz()); //* 月曲线偏差率最优实际 pewp.setYqxpcbzysj(pewp.getRqxpcbzysj()); //* 月曲线偏差率保证实际 pewp.setYqxpcbbzsj(pewp.getRqxpcbbzsj()); //* 月曲线偏差率同比 pewp.setYqxpcbtb(pewp.getRqxpcbtb()); //* 月曲线偏差率环比 pewp.setYqxpcbhb(pewp.getRqxpcbhb()); //* 月曲线偏差率标杆 pewp.setYqxpcbbg(pewp.getRqxpcbbg()); //* 月3-5米曲线偏差率 pewp.setY35mqxpcl(pewp.getR35mqxpcl()); //* 月5-11米曲线偏差率 pewp.setY511mqxpcl(pewp.getR511mqxpcl()); //* 月11米以上曲线偏差率 pewp.setY11mycqxpcl(pewp.getR11mycqxpcl()); //* 月对风偏差率(-50 +50之间) pewp.setYdfpcl(pewp.getRdfpcl()); //* 月MTBF pewp.setYmtbf(pewp.getRmtbf()); //* 月MTTR pewp.setYmttr(pewp.getRmttr()); //* 月MTTF pewp.setYmttf(pewp.getRmttf()); //* 月复位及时率 pewp.setYfwjsl(pewp.getRfwjsl()); //* 月状态转换及时率 pewp.setYztzhjsl(pewp.getRztzhjsl()); // //* 月故障消缺及时率 pewp.setYgzxqjsl(pewp.getRgzxqjsl()); } }