123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119 |
- 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<String> 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<String, ProEconInOrOutSpeedTotal> peioomap = new HashMap<>();
- List<ProEconInOrOutSpeedTotal> 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<String,ProEconWindturbineGoodness> wgmap=new HashMap<>();
- List<ProEconWindturbineGoodness> 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<String, Map<String, Double>> glqxyizxMap = coefficientService.coefficient(begin);
- // //拟合优度接口调用
- // Map<String, Map<String, Double>> nhydMap = goodnessOfFitService.goodnessOfFit(begin);
- List<ProEconEquipmentInfoDay4> 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<ProEconEquipmentInfoDay4> 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<ProEconEquipmentInfoDay2> 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<ProEconEquipmentInfoDay3> 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<String, ProEconInOrOutSpeedTotal> peioomap, ProEconEquipmentInfoDay4 pewp, Date end, Date begin,
- ProBasicEquipment wt, List<ProEconEquipmentInfoDay4> pepidls, ProEconEquipmentInfoDay2 pepid2, ProEconEquipmentInfoDay3 pepid3,
- Map<String,ProEconWindturbineGoodness> wgmap) throws Exception {
- //*****************************************日信息统计*********************************************************/
- Map<String, ProBasicEquipmentPoint> 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<PointData> 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<PointData> 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<PointData> 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<ProEconCurveFittingMain> 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<ProEconStateTransitionRates> 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<ProEconFaultLiminatedefects> 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<ProEconCurveFittingSub> 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<ProEconCurveFittMonthMain> 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<ProEconCurveFittMonthSub> 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<ProEconCurveFittYearMain> 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<ProEconCurveFittYearSub> 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());
- }
- }
|