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.model.vo.Location; import com.gyee.generation.service.auto.IProEconPowerstationInfoDay2Service; 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 WindPowerInfo2Service { // private static final Logger logger = LoggerFactory.getLogger(WindPowerInfo2Service.class); @Resource private IEdosUtil edosUtil; @Resource private IProEconPowerstationInfoDay2Service proEconPowerstationInfoDay2Service; /** * 计算区域日信息 */ public void calRegionInfoDay(Date recordDate) { List wpinfodayls = proEconPowerstationInfoDay2Service.list().stream() .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate))==0 // && CacheContext.wpmap.containsKey(i.getWindpowerstationId()) && i.getLocation().equals(Location.cp.getValue())) .collect(Collectors.toList()); if(!wpinfodayls.isEmpty()) { Map>>rgmap=new HashMap<>(); for(ProEconPowerstationInfoDay2 wpinfo:wpinfodayls) { if(rgmap.containsKey(wpinfo.getRegionId())) { Map> map=rgmap.get(wpinfo.getRegionId()); List qbls=map.get("qb"); List gfls=map.get("fd"); List fdls=map.get("gf"); if(wpinfo.getForeignKeyId().equals("-1")) { fdls.add(wpinfo); }else if(wpinfo.getForeignKeyId().equals("-2")){ gfls.add(wpinfo); } qbls.add(wpinfo); }else { Map> map=new HashMap<>(); List qbls=new ArrayList<>(); List gfls=new ArrayList<>(); List fdls=new ArrayList<>(); if(wpinfo.getForeignKeyId().equals("-1")) { fdls.add(wpinfo); }else if(wpinfo.getForeignKeyId().equals("-2")){ gfls.add(wpinfo); } qbls.add(wpinfo); map.put("qb",qbls); map.put("fd",fdls); map.put("gf",gfls); rgmap.put(wpinfo.getRegionId(),map); } } //判断是否有重复记录,先删除重复记录 List idls = proEconPowerstationInfoDay2Service.list().stream() .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate))==0 // && CacheContext.wpmap.containsKey(i.getWindpowerstationId()) && i.getLocation().equals(Location.rg.getValue())).map(ProEconPowerstationInfoDay2::getId) .collect(Collectors.toList()); if (idls.size() > 0) { proEconPowerstationInfoDay2Service.removeByIds(idls); } for(Map.Entry>> entry:rgmap.entrySet()){ Map> map=entry.getValue(); List qbls=map.get("qb"); List gfls=map.get("fd"); List fdls=map.get("gf"); // if(CacheContext.cpwpmap.size()==qbls.size()) // { ProEconPowerstationInfoDay2 qb=new ProEconPowerstationInfoDay2(); ProEconPowerstationInfoDay2 fd=new ProEconPowerstationInfoDay2(); ProEconPowerstationInfoDay2 gf=new ProEconPowerstationInfoDay2(); if(CacheContext.rgmap.containsKey(entry.getKey())) { ProBasicRegion cp=CacheContext.rgmap.get(entry.getKey()); gf.setRegionId(cp.getId()); gf.setRecordDate(DateUtils.truncate(recordDate)); gf.setForeignKeyId("-2"); gf.setLocation(Location.rg.getValue()); fd.setRegionId(cp.getId()); fd.setRecordDate(DateUtils.truncate(recordDate)); fd.setForeignKeyId("-1"); fd.setLocation(Location.rg.getValue()); qb.setRegionId(cp.getId()); qb.setRecordDate(DateUtils.truncate(recordDate)); qb.setForeignKeyId("0"); qb.setLocation(Location.rg.getValue()); //计算区域级全部 calCp(qb,qbls); //计算公司级风电场站 calCp(fd,fdls); //计算公司级光电场站 calCp(gf,gfls); proEconPowerstationInfoDay2Service.save(qb); proEconPowerstationInfoDay2Service.save(fd); proEconPowerstationInfoDay2Service.save(gf); } // }else // { // logger.debug("公司所属场站数量与保存的场站日信息数量不一致,未进行{0}统计-------结束", entry.getKey()); // // } } } } /** * 计算公司日信息 */ public void calCompanyInfoDay(Date recordDate) { List wpinfodayls = proEconPowerstationInfoDay2Service.list().stream() .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate))==0 // && CacheContext.wpmap.containsKey(i.getWindpowerstationId()) && i.getLocation().equals(Location.wp.getValue())) .collect(Collectors.toList()); if(!wpinfodayls.isEmpty()) { Map>>cpmap=new HashMap<>(); for(ProEconPowerstationInfoDay2 wpinfo:wpinfodayls) { if(cpmap.containsKey(wpinfo.getCompanyId())) { Map> map=cpmap.get(wpinfo.getCompanyId()); List qbls=map.get("qb"); List gfls=map.get("fd"); List fdls=map.get("gf"); if(wpinfo.getWindpowerstationId().contains("FDC")) { fdls.add(wpinfo); }else { gfls.add(wpinfo); } qbls.add(wpinfo); }else { Map> map=new HashMap<>(); List qbls=new ArrayList<>(); List gfls=new ArrayList<>(); List fdls=new ArrayList<>(); if(wpinfo.getWindpowerstationId().contains("FDC")) { fdls.add(wpinfo); }else { gfls.add(wpinfo); } qbls.add(wpinfo); map.put("qb",qbls); map.put("fd",fdls); map.put("gf",gfls); cpmap.put(wpinfo.getCompanyId(),map); } } //判断是否有重复记录,先删除重复记录 List idls = proEconPowerstationInfoDay2Service.list().stream() .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate))==0 // && CacheContext.wpmap.containsKey(i.getWindpowerstationId()) && i.getLocation().equals(Location.cp.getValue())).map(ProEconPowerstationInfoDay2::getId) .collect(Collectors.toList()); if (idls.size() > 0) { proEconPowerstationInfoDay2Service.removeByIds(idls); } for(Map.Entry>> entry:cpmap.entrySet()){ Map> map=entry.getValue(); List qbls=map.get("qb"); List gfls=map.get("fd"); List fdls=map.get("gf"); // if(CacheContext.cpwpmap.size()==qbls.size()) // { ProEconPowerstationInfoDay2 qb=new ProEconPowerstationInfoDay2(); ProEconPowerstationInfoDay2 fd=new ProEconPowerstationInfoDay2(); ProEconPowerstationInfoDay2 gf=new ProEconPowerstationInfoDay2(); if(CacheContext.cpmap.containsKey(entry.getKey())) { ProBasicCompany cp=CacheContext.cpmap.get(entry.getKey()); gf.setRegionId(cp.getRegionId()); gf.setCompanyId(cp.getId()); gf.setRecordDate(DateUtils.truncate(recordDate)); gf.setForeignKeyId("-2"); gf.setLocation(Location.cp.getValue()); fd.setRegionId(cp.getRegionId()); fd.setCompanyId(cp.getId()); fd.setRecordDate(DateUtils.truncate(recordDate)); fd.setForeignKeyId("-1"); fd.setLocation(Location.cp.getValue()); qb.setRegionId(cp.getRegionId()); qb.setCompanyId(cp.getId()); qb.setRecordDate(DateUtils.truncate(recordDate)); qb.setForeignKeyId("0"); qb.setLocation(Location.cp.getValue()); //计算公司级全部场站 calCp(qb,qbls); //计算公司级风电场站 calCp(fd,fdls); //计算公司级光电场站 calCp(gf,gfls); proEconPowerstationInfoDay2Service.save(qb); proEconPowerstationInfoDay2Service.save(fd); proEconPowerstationInfoDay2Service.save(gf); } // }else // { // logger.debug("公司所属场站数量与保存的场站日信息数量不一致,未进行{0}统计-------结束", entry.getKey()); // // } } } } private void calCp(ProEconPowerstationInfoDay2 pewp,List ls) { if(!ls.isEmpty()) { for(ProEconPowerstationInfoDay2 pepid:ls) { //日合计故障小时(明细) pewp.setRhjgzxsmx(StringUtils.round(pewp.getRhjgzxsmx()+pepid.getRhjgzxsmx(),2)); //日合计场内受累故障小时(明细) pewp.setRhjcnslgzxsmx(StringUtils.round(pewp.getRhjcnslgzxsmx()+pepid.getRhjcnslgzxsmx(),2)); //日合计检修小时(明细) pewp.setRhjjxxsmx(StringUtils.round(pewp.getRhjjxxsmx()+pepid.getRhjjxxsmx(),2)); //日合计场内受累检修小时(明细) pewp.setRhjcnsljxxsmx(StringUtils.round(pewp.getRhjcnsljxxsmx()+pepid.getRhjcnsljxxsmx(),2)); //日合计待机小时(明细) pewp.setRhjdjxsmx(StringUtils.round(pewp.getRhjdjxsmx()+pepid.getRhjdjxsmx(),2)); //日合计缺陷降出力小时(明细) pewp.setRhjqxjclxsmx(StringUtils.round(pewp.getRhjqxjclxsmx()+pepid.getRhjqxjclxsmx(),2)); //日合计手动停机小时(明细) pewp.setRhjsdtjxsmx(StringUtils.round(pewp.getRhjsdtjxsmx()+pepid.getRhjsdtjxsmx(),2)); //日合计性能小时(明细) pewp.setRhjbwxsmx(StringUtils.round(pewp.getRhjbwxsmx()+pepid.getRhjbwxsmx(),2)); //日合计限电停机小时(明细) pewp.setRhjxdtjxsmx(StringUtils.round(pewp.getRhjxdtjxsmx()+pepid.getRhjxdtjxsmx(),2)); //日合计限电降出力小时(明细) pewp.setRhjxdjclxsmx(StringUtils.round(pewp.getRhjxdjclxsmx()+pepid.getRhjxdjclxsmx(),2)); //日合计场外受累电网小时(明细) pewp.setRhjcwsldwxsmx(StringUtils.round(pewp.getRhjcwsldwxsmx()+pepid.getRhjcwsldwxsmx(),2)); //日合计场外受累电网小时(明细) pewp.setRhjcwsltqxsmx(StringUtils.round(pewp.getRhjcwsltqxsmx()+pepid.getRhjcwsltqxsmx(),2)); //日合计通讯中断小时(明细) pewp.setRhjtxzdxsmx(StringUtils.round(pewp.getRhjtxzdxsmx()+pepid.getRhjtxzdxsmx(),2)); //日合计离线小时(明细) pewp.setRhjlxxsmx(StringUtils.round(pewp.getRhjlxxsmx()+pepid.getRhjlxxsmx(),2)); //月合计故障小时(明细) pewp.setYhjgzxsmx(StringUtils.round(pewp.getYhjgzxsmx()+pepid.getYhjgzxsmx(),2)); //月合计场内受累故障小时(明细) pewp.setYhjcnslgzxsmx(StringUtils.round(pewp.getYhjcnslgzxsmx()+pepid.getYhjcnslgzxsmx(),2)); //月合计检修小时(明细) pewp.setYhjjxxsmx(StringUtils.round(pewp.getYhjjxxsmx()+pepid.getYhjjxxsmx(),2)); //月合计场内受累检修小时(明细) pewp.setYhjcnsljxxsmx(StringUtils.round(pewp.getYhjcnsljxxsmx()+pepid.getYhjcnsljxxsmx(),2)); //月合计待机小时(明细) pewp.setYhjdjxsmx(StringUtils.round(pewp.getYhjdjxsmx()+pepid.getYhjdjxsmx(),2)); //月合计缺陷降出力小时(明细) pewp.setYhjqxjclxsmx(StringUtils.round(pewp.getYhjqxjclxsmx()+pepid.getYhjqxjclxsmx(),2)); //月合计手动停机小时(明细) pewp.setYhjsdtjxsmx(StringUtils.round(pewp.getYhjsdtjxsmx()+pepid.getYhjsdtjxsmx(),2)); //月合计性能小时(明细) pewp.setYhjbwxsmx(StringUtils.round(pewp.getYhjbwxsmx()+pepid.getYhjbwxsmx(),2)); //月合计限电停机小时(明细) pewp.setYhjxdtjxsmx(StringUtils.round(pewp.getYhjxdtjxsmx()+pepid.getYhjxdtjxsmx(),2)); //月合计限电降出力小时(明细) pewp.setYhjxdjclxsmx(StringUtils.round(pewp.getYhjxdjclxsmx()+pepid.getYhjxdjclxsmx(),2)); //月合计场外受累电网小时(明细) pewp.setYhjcwsldwxsmx(StringUtils.round(pewp.getYhjcwsldwxsmx()+pepid.getYhjcwsldwxsmx(),2)); //月合计场外受累电网小时(明细) pewp.setYhjcwsltqxsmx(StringUtils.round(pewp.getYhjcwsltqxsmx()+pepid.getYhjcwsltqxsmx(),2)); //月合计通讯中断小时(明细) pewp.setYhjtxzdxsmx(StringUtils.round(pewp.getYhjtxzdxsmx()+pepid.getYhjtxzdxsmx(),2)); //月合计离线小时(明细) pewp.setYhjlxxsmx(StringUtils.round(pewp.getYhjlxxsmx()+pepid.getYhjlxxsmx(),2)); //年合计故障小时(明细) pewp.setNhjgzxsmx(StringUtils.round(pewp.getNhjgzxsmx()+pepid.getNhjgzxsmx(),2)); //年合计场内受累故障小时(明细) pewp.setNhjcnslgzxsmx(StringUtils.round(pewp.getNhjcnslgzxsmx()+pepid.getNhjcnslgzxsmx(),2)); //年合计检修小时(明细) pewp.setNhjjxxsmx(StringUtils.round(pewp.getNhjjxxsmx()+pepid.getNhjjxxsmx(),2)); //年合计场内受累检修小时(明细) pewp.setNhjcnsljxxsmx(StringUtils.round(pewp.getNhjcnsljxxsmx()+pepid.getNhjcnsljxxsmx(),2)); //年合计待机小时(明细) pewp.setNhjdjxsmx(StringUtils.round(pewp.getNhjdjxsmx()+pepid.getNhjdjxsmx(),2)); //年合计缺陷降出力小时(明细) pewp.setNhjqxjclxsmx(StringUtils.round(pewp.getNhjqxjclxsmx()+pepid.getNhjqxjclxsmx(),2)); //年合计手动停机小时(明细) pewp.setNhjsdtjxsmx(StringUtils.round(pewp.getNhjsdtjxsmx()+pepid.getNhjsdtjxsmx(),2)); //年合计性能小时(明细) pewp.setNhjbwxsmx(StringUtils.round(pewp.getNhjbwxsmx()+pepid.getNhjbwxsmx(),2)); //年合计限电停机小时(明细) pewp.setNhjxdtjxsmx(StringUtils.round(pewp.getNhjxdtjxsmx()+pepid.getNhjxdtjxsmx(),2)); //年合计限电降出力小时(明细) pewp.setNhjxdjclxsmx(StringUtils.round(pewp.getNhjxdjclxsmx()+pepid.getNhjxdjclxsmx(),2)); //年合计场外受累电网小时(明细) pewp.setNhjcwsldwxsmx(StringUtils.round(pewp.getNhjcwsldwxsmx()+pepid.getNhjcwsldwxsmx(),2)); //年合计场外受累电网小时(明细) pewp.setNhjcwsltqxsmx(StringUtils.round(pewp.getNhjcwsltqxsmx()+pepid.getNhjcwsltqxsmx(),2)); //年合计通讯中断小时(明细) pewp.setNhjtxzdxsmx(StringUtils.round(pewp.getNhjtxzdxsmx()+pepid.getNhjtxzdxsmx(),2)); //年合计离线小时(明细) pewp.setNhjlxxsmx(StringUtils.round(pewp.getNhjlxxsmx()+pepid.getNhjlxxsmx(),2)); } } } /** * 计算场站日信息 */ public void calWindpowerInfoDay(Date recordDate) throws Exception { Calendar c=Calendar.getInstance(); c.setTime(recordDate); Date end=c.getTime(); Date begin= DateUtils.truncate(c.getTime()); //判断是否有重复记录,先删除重复记录 List idls = proEconPowerstationInfoDay2Service.list().stream() .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate))==0 && CacheContext.wpmap.containsKey(i.getWindpowerstationId()) && i.getLocation().equals(Location.wp.getValue())).map(ProEconPowerstationInfoDay2::getId) .collect(Collectors.toList()); if (idls.size() > 0) { proEconPowerstationInfoDay2Service.removeByIds(idls); } for(ProBasicPowerstation wp:CacheContext.wpls) { if(CacheContext.wppointmap.containsKey(wp.getId())) { // Map pointmap=CacheContext.wppointmap.get(wp.getId()); ProEconPowerstationInfoDay2 pewp=new ProEconPowerstationInfoDay2(); Initial.initial(pewp); pewp.setRegionId(wp.getRegionId()); pewp.setCompanyId(wp.getCompanyId()); pewp.setRecordDate(DateUtils.truncate(recordDate)); pewp.setForeignKeyId("0"); pewp.setWindpowerstationId(wp.getId()); pewp.setLocation(Location.wp.getValue()); //昨日的统计结果 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 = proEconPowerstationInfoDay2Service.list().stream() .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(cl.getTime())) == 0 && i.getWindpowerstationId().equals(wp.getId()) && i.getLocation().equals(Location.wp.getValue())) .collect(Collectors.toList()); } calDetiall(pewp, end, begin, CacheContext.wpwtmap.get(wp.getId()), pepidls); calSimple( pewp, end, begin, CacheContext.wpwtmap.get(wp.getId()),pepidls); //*******************************************年信息统计*********************************************************/ // wpinfodayls.add(pewp); proEconPowerstationInfoDay2Service.save(pewp); } } } /** * 计算项目日信息 */ public void calProjectInfoDay(Date recordDate) throws Exception { Calendar c=Calendar.getInstance(); c.setTime(recordDate); Date end=c.getTime(); Date begin= DateUtils.truncate(c.getTime()); //判断是否有重复记录,先删除重复记录 List idls = proEconPowerstationInfoDay2Service.list().stream() .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate))==0 && CacheContext.pjmap.containsKey(i.getProjectId()) && i.getLocation().equals(Location.pj.getValue())).map(ProEconPowerstationInfoDay2::getId) .collect(Collectors.toList()); if (idls.size() > 0) { proEconPowerstationInfoDay2Service.removeByIds(idls); } for(ProBasicProject pj:CacheContext.pjls) { if(CacheContext.wppointmap.containsKey(pj.getId())) { // Map pointmap=CacheContext.wppointmap.get(pj.getId()); ProEconPowerstationInfoDay2 pewp=new ProEconPowerstationInfoDay2(); Initial.initial(pewp); pewp.setForeignKeyId("0"); pewp.setWindpowerstationId(pj.getWindpowerstationId()); pewp.setProjectId(pj.getId()); pewp.setLocation(Location.pj.getValue()); pewp.setRecordDate(DateUtils.truncate(recordDate)); //昨日的统计结果 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 = proEconPowerstationInfoDay2Service.list().stream() .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(cl.getTime())) == 0 && i.getProjectId().equals(pj.getId()) && i.getLocation().equals(Location.pj.getValue())) .collect(Collectors.toList()); } calDetiall(pewp, end, begin, CacheContext.pjwtmap.get(pj.getId()), pepidls); calSimple( pewp, end, begin, CacheContext.pjwtmap.get(pj.getId()),pepidls); proEconPowerstationInfoDay2Service.save(pewp); } } } /** * 计算线路日信息 */ public void calLineInfoDay(Date recordDate) throws Exception { Calendar c=Calendar.getInstance(); c.setTime(recordDate); Date end=c.getTime(); Date begin= DateUtils.truncate(c.getTime()); //判断是否有重复记录,先删除重复记录 List idls = proEconPowerstationInfoDay2Service.list().stream() .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate))==0 && CacheContext.lnmap.containsKey(i.getLineId()) && i.getLocation().equals(Location.ln.getValue()) ).map(ProEconPowerstationInfoDay2::getId) .collect(Collectors.toList()); if (idls.size() > 0) { proEconPowerstationInfoDay2Service.removeByIds(idls); } for(ProBasicLine ln:CacheContext.lnls) { if(CacheContext.wppointmap.containsKey(ln.getId())) { // Map pointmap=CacheContext.wppointmap.get(ln.getId()); ProEconPowerstationInfoDay2 pewp=new ProEconPowerstationInfoDay2(); Initial.initial(pewp); pewp.setForeignKeyId("0"); pewp.setLineId(ln.getId()); pewp.setLocation(Location.ln.getValue()); pewp.setProjectId(ln.getProjectId()); pewp.setRecordDate(DateUtils.truncate(recordDate)); //昨日的统计结果 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 = proEconPowerstationInfoDay2Service.list().stream() .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(cl.getTime())) == 0 && i.getLineId().equals(ln.getId()) && i.getLocation().equals(Location.ln.getValue())) .collect(Collectors.toList()); } calDetiall( pewp, end, begin, CacheContext.lnwtmap.get(ln.getId()),pepidls); calSimple( pewp, end, begin, CacheContext.lnwtmap.get(ln.getId()),pepidls); proEconPowerstationInfoDay2Service.save(pewp); } } } private void calDetiall(ProEconPowerstationInfoDay2 pewp, Date end, Date begin, List wtls, List pepidls) throws Exception { // // 0 待机 // 1 手动停机 // 2 正常发电 // 3 发电降出力 // 4 故障 // 5 故障受累 // 6 检修 // 7 检修受累 // 8 限电降出力 // 9 限电停机 // 10 电网受累 // 11 环境受累 // 12 通讯中断 // 13 设备离线 double lastState;//上一分钟状态 double djsc=0;//待机时长 double sdtjsc=0;//手动停机时长 double zcfdsc=0;//正常发电时长 double fdjclsc=0;//发电降出力时长 double gzsc=0;//故障时长 double gzslsc=0;//故障受累时长 double jxsc=0;//检修时长 double jxslsc=0;//检修受累时长 double xdjclsc=0;//限电降出力时长 double xdtjsc=0;//限电停机时长 double dwslsc=0;//电网受累时长 double hjslsc=0;//环境受累时长 double txzdsc=0;//通讯中断时长 double sblxsc=0;//设备离线时长 Map> wtpAimap = CacheContext.wtpAimap; for(ProBasicEquipment wt:wtls) { lastState=-1;//上一分钟状态 Map aimap=wtpAimap.get(wt.getId()); if(aimap.containsKey(ContantXk.MXZT)) { ProBasicEquipmentPoint point=aimap.get(ContantXk.MXZT); //按照分钟时间进行统计状态快照值 List pointls=edosUtil.getHistoryDatasSnap(point.getNemCode(), begin.getTime()/1000, end.getTime()/1000); if(!pointls.isEmpty()) { for(PointData po :pointls) { if(po.getPointValueInDouble()==0) { if(lastState!=po.getPointValueInDouble()) { //将当前状态保存到上一分钟状态 lastState=po.getPointValueInDouble(); } //待机时长加1分钟 djsc++; }else if(po.getPointValueInDouble()==1) { if(lastState!=po.getPointValueInDouble()) { //将当前状态保存到上一分钟状态 lastState=po.getPointValueInDouble(); } //手动停机时长加1分钟 sdtjsc++; }else if(po.getPointValueInDouble()==2) { if(lastState!=po.getPointValueInDouble()) { //将当前状态保存到上一分钟状态 lastState=po.getPointValueInDouble(); } //正常发电时长加1分钟 zcfdsc++; }else if(po.getPointValueInDouble()==3) { if(lastState!=po.getPointValueInDouble()) { //将当前状态保存到上一分钟状态 lastState=po.getPointValueInDouble(); } //发电降出力时长加1分钟 fdjclsc++; }else if(po.getPointValueInDouble()==4) { if(lastState!=po.getPointValueInDouble()) { //将当前状态保存到上一分钟状态 lastState=po.getPointValueInDouble(); } //故障时长加1分钟 gzsc++; }else if(po.getPointValueInDouble()==5) { if(lastState!=po.getPointValueInDouble()) { //将当前状态保存到上一分钟状态 lastState=po.getPointValueInDouble(); } //故障受累时长加1分钟 gzslsc++; }else if(po.getPointValueInDouble()==6) { if(lastState!=po.getPointValueInDouble()) { //将当前状态保存到上一分钟状态 lastState=po.getPointValueInDouble(); } //检修时长加1分钟 jxsc++; }else if(po.getPointValueInDouble()==7) { if(lastState!=po.getPointValueInDouble()) { //将当前状态保存到上一分钟状态 lastState=po.getPointValueInDouble(); } //检修受累时长加1分钟 jxslsc++; }else if(po.getPointValueInDouble()==8) { if(lastState!=po.getPointValueInDouble()) { //将当前状态保存到上一分钟状态 lastState=po.getPointValueInDouble(); } //限电降出力时长加1分钟 xdjclsc++; }else if(po.getPointValueInDouble()==9) { if(lastState!=po.getPointValueInDouble()) { //将当前状态保存到上一分钟状态 lastState=po.getPointValueInDouble(); } //限电停机时长加1分钟 xdtjsc++; }else if(po.getPointValueInDouble()==10) { if(lastState!=po.getPointValueInDouble()) { //将当前状态保存到上一分钟状态 lastState=po.getPointValueInDouble(); } //电网受累时长加1分钟 dwslsc++; }else if(po.getPointValueInDouble()==11) { if(lastState!=po.getPointValueInDouble()) { //将当前状态保存到上一分钟状态 lastState=po.getPointValueInDouble(); } //环境受累时长加1分钟 hjslsc++; }else if(po.getPointValueInDouble()==12) { if(lastState!=po.getPointValueInDouble()) { //将当前状态保存到上一分钟状态 lastState=po.getPointValueInDouble(); } //通讯中断时长加1分钟 txzdsc++; }else if(po.getPointValueInDouble()==13) { if(lastState!=po.getPointValueInDouble()) { //将当前状态保存到上一分钟状态 lastState=po.getPointValueInDouble(); } //设备离线时长加1分钟 sblxsc++; } } } } } //日合计故障小时(明细) pewp.setRhjgzxsmx(new BigDecimal(gzsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue()); //日合计场内受累故障小时(明细) pewp.setRhjcnslgzxsmx(new BigDecimal(gzslsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue()); //日合计检修小时(明细) pewp.setRhjjxxsmx(new BigDecimal(jxsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue()); //日合计场内受累检修小时(明细) pewp.setRhjcnsljxxsmx(new BigDecimal(jxslsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue()); //日合计待机小时(明细) pewp.setRhjdjxsmx(new BigDecimal(djsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue()); //日合计缺陷降出力小时(明细) pewp.setRhjqxjclxsmx(new BigDecimal(fdjclsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue()); //日合计手动停机小时(明细) pewp.setRhjsdtjxsmx(new BigDecimal(sdtjsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue()); //日合计性能小时(明细) pewp.setRhjbwxsmx(new BigDecimal(zcfdsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue()); //日合计限电停机小时(明细) pewp.setRhjxdtjxsmx(new BigDecimal(xdtjsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue()); //日合计限电降出力小时(明细) pewp.setRhjxdjclxsmx(new BigDecimal(xdjclsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue()); //日合计场外受累电网小时(明细) pewp.setRhjcwsldwxsmx(new BigDecimal(dwslsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue()); //日合计场外受累电网小时(明细) pewp.setRhjcwsltqxsmx(new BigDecimal(hjslsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue()); //日合计通讯中断小时(明细) pewp.setRhjtxzdxsmx(new BigDecimal(txzdsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue()); //日合计离线小时(明细) pewp.setRhjlxxsmx(new BigDecimal(sblxsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue()); //*******************************************日信息统计*********************************************************/ //*******************************************月信息统计*********************************************************/ if(pepidls.isEmpty()) { setLossHoursMonth(pewp); }else { ProEconPowerstationInfoDay2 pepid=pepidls.get(0); //月合计故障小时(明细) pewp.setYhjgzxsmx(StringUtils.round(pepid.getYhjgzxsmx()+pewp.getRhjgzxsmx(),2)); //月合计场内受累故障小时(明细) pewp.setYhjcnslgzxsmx(StringUtils.round(pepid.getYhjcnslgzxsmx()+pewp.getRhjcnslgzxsmx(),2)); //月合计检修小时(明细) pewp.setYhjjxxsmx(StringUtils.round(pepid.getYhjjxxsmx()+pewp.getRhjjxxsmx(),2)); //月合计场内受累检修小时(明细) pewp.setYhjcnsljxxsmx(StringUtils.round( pepid.getYhjcnsljxxsmx()+pewp.getRhjcnsljxxsmx(),2)); //月合计待机小时(明细) pewp.setYhjdjxsmx(StringUtils.round(pepid.getYhjdjxsmx()+pewp.getRhjdjxsmx(),2)); //月合计缺陷降出力小时(明细) pewp.setYhjqxjclxsmx(StringUtils.round(pepid.getYhjqxjclxsmx()+pewp.getRhjqxjclxsmx(),2)); //月合计手动停机小时(明细) pewp.setYhjsdtjxsmx(StringUtils.round(pepid.getYhjsdtjxsmx()+pewp.getRhjsdtjxsmx(),2)); //月合计性能小时(明细) pewp.setYhjbwxsmx(StringUtils.round(pepid.getYhjbwxsmx()+pewp.getRhjbwxsmx(),2)); //月合计限电停机小时(明细) pewp.setYhjxdtjxsmx(StringUtils.round(pepid.getYhjxdtjxsmx()+pewp.getRhjxdtjxsmx(),2)); //月合计限电降出力小时(明细) pewp.setYhjxdjclxsmx(StringUtils.round(pepid.getYhjxdjclxsmx()+pewp.getRhjxdjclxsmx(),2)); //月合计场外受累电网小时(明细) pewp.setYhjcwsldwxsmx(StringUtils.round(pepid.getYhjcwsldwxsmx()+pewp.getRhjcwsldwxsmx(),2)); //月合计场外受累电网小时(明细) pewp.setYhjcwsltqxsmx(StringUtils.round(pepid.getYhjcwsltqxsmx()+pewp.getRhjcwsltqxsmx(),2)); //月合计通讯中断小时(明细) pewp.setYhjtxzdxsmx(StringUtils.round(pepid.getYhjtxzdxsmx()+pewp.getRhjtxzdxsmx(),2)); //月合计离线小时(明细) pewp.setYhjlxxsmx(StringUtils.round(pepid.getYhjlxxsmx()+pewp.getRhjlxxsmx(),2)); } //*******************************************月信息统计*********************************************************/ //*******************************************年信息统计*********************************************************/ if(pepidls.isEmpty()) { setLossHoursYear(pewp); }else { ProEconPowerstationInfoDay2 pepid=pepidls.get(0); //年合计故障小时(明细) pewp.setNhjgzxsmx(StringUtils.round(pepid.getNhjgzxsmx()+pewp.getRhjgzxsmx(),2)); //年合计场内受累故障小时(明细) pewp.setNhjcnslgzxsmx(StringUtils.round(pepid.getNhjcnslgzxsmx()+pewp.getRhjcnslgzxsmx(),2)); //年合计检修小时(明细) pewp.setNhjjxxsmx(StringUtils.round(pepid.getNhjjxxsmx()+pewp.getRhjjxxsmx(),2)); //年合计场内受累检修小时(明细) pewp.setNhjcnsljxxsmx(StringUtils.round( pepid.getNhjcnsljxxsmx()+pewp.getRhjcnsljxxsmx(),2)); //年合计待机小时(明细) pewp.setNhjdjxsmx(StringUtils.round(pepid.getNhjdjxsmx()+pewp.getRhjdjxsmx(),2)); //年合计缺陷降出力小时(明细) pewp.setNhjqxjclxsmx(StringUtils.round(pepid.getNhjqxjclxsmx()+pewp.getRhjqxjclxsmx(),2)); //年合计手动停机小时(明细) pewp.setNhjsdtjxsmx(StringUtils.round(pepid.getNhjsdtjxsmx()+pewp.getRhjsdtjxsmx(),2)); //年合计性能小时(明细) pewp.setNhjbwxsmx(StringUtils.round(pepid.getNhjbwxsmx()+pewp.getRhjbwxsmx(),2)); //年合计限电停机小时(明细) pewp.setNhjxdtjxsmx(StringUtils.round(pepid.getNhjxdtjxsmx()+pewp.getRhjxdtjxsmx(),2)); //年合计限电降出力小时(明细) pewp.setNhjxdjclxsmx(StringUtils.round(pepid.getNhjxdjclxsmx()+pewp.getRhjxdjclxsmx(),2)); //年合计场外受累电网小时(明细) pewp.setNhjcwsldwxsmx(StringUtils.round(pepid.getNhjcwsldwxsmx()+pewp.getRhjcwsldwxsmx(),2)); //年合计场外受累电网小时(明细) pewp.setNhjcwsltqxsmx(StringUtils.round(pepid.getNhjcwsltqxsmx()+pewp.getRhjcwsltqxsmx(),2)); //年合计通讯中断小时(明细) pewp.setNhjtxzdxsmx(StringUtils.round(pepid.getNhjtxzdxsmx()+pewp.getRhjtxzdxsmx(),2)); //年合计离线小时(明细) pewp.setNhjlxxsmx(StringUtils.round(pepid.getNhjlxxsmx()+pewp.getRhjlxxsmx(),2)); } } private static void setLossHoursYear(ProEconPowerstationInfoDay2 pewp) { //年合计故障小时(明细) pewp.setNhjgzxsmx(pewp.getRhjgzxsmx()); //年合计场内受累故障小时(明细) pewp.setNhjcnslgzxsmx(pewp.getRhjcnslgzxsmx()); //年合计检修小时(明细) pewp.setNhjjxxsmx(pewp.getRhjjxxsmx()); //年合计场内受累检修小时(明细) pewp.setNhjcnsljxxsmx(pewp.getRhjcnsljxxsmx()); //年合计待机小时(明细) pewp.setNhjdjxsmx(pewp.getRhjdjxsmx()); //年合计缺陷降出力小时(明细) pewp.setNhjqxjclxsmx(pewp.getRhjqxjclxsmx()); //年合计手动停机小时(明细) pewp.setNhjsdtjxsmx(pewp.getRhjsdtjxsmx()); //年合计性能小时(明细) pewp.setNhjbwxsmx(pewp.getRhjbwxsmx()); //年合计限电停机小时(明细) pewp.setNhjxdtjxsmx(pewp.getRhjxdtjxsmx()); //年合计限电降出力小时(明细) pewp.setNhjxdjclxsmx(pewp.getRhjxdjclxsmx()); //年合计场外受累电网小时(明细) pewp.setNhjcwsldwxsmx(pewp.getRhjcwsldwxsmx()); //年合计场外受累电网小时(明细) pewp.setNhjcwsltqxsmx(pewp.getRhjcwsltqxsmx()); //年合计通讯中断小时(明细) pewp.setNhjtxzdxsmx(pewp.getRhjtxzdxsmx()); //年合计离线小时(明细) pewp.setNhjlxxsmx(pewp.getRhjlxxsmx()); } private static void setLossHoursMonth(ProEconPowerstationInfoDay2 pewp) { //月合计故障小时(明细) pewp.setYhjgzxsmx(pewp.getRhjgzxsmx()); //月合计场内受累故障小时(明细) pewp.setYhjcnslgzxsmx(pewp.getRhjcnslgzxsmx()); //月合计检修小时(明细) pewp.setYhjjxxsmx(pewp.getRhjjxxsmx()); //月合计场内受累检修小时(明细) pewp.setYhjcnsljxxsmx(pewp.getRhjcnsljxxsmx()); //月合计待机小时(明细) pewp.setYhjdjxsmx(pewp.getRhjdjxsmx()); //月合计缺陷降出力小时(明细) pewp.setYhjqxjclxsmx(pewp.getRhjqxjclxsmx()); //月合计手动停机小时(明细) pewp.setYhjsdtjxsmx(pewp.getRhjsdtjxsmx()); //月合计性能小时(明细) pewp.setYhjbwxsmx(pewp.getRhjbwxsmx()); //月合计限电停机小时(明细) pewp.setYhjxdtjxsmx(pewp.getRhjxdtjxsmx()); //月合计限电降出力小时(明细) pewp.setYhjxdjclxsmx(pewp.getRhjxdjclxsmx()); //月合计场外受累电网小时(明细) pewp.setYhjcwsldwxsmx(pewp.getRhjcwsldwxsmx()); //月合计场外受累电网小时(明细) pewp.setYhjcwsltqxsmx(pewp.getRhjcwsltqxsmx()); //月合计通讯中断小时(明细) pewp.setYhjtxzdxsmx(pewp.getRhjtxzdxsmx()); //月合计离线小时(明细) pewp.setYhjlxxsmx(pewp.getRhjlxxsmx()); } private static void setLossHoursMonthSimple(ProEconPowerstationInfoDay2 pewp) { //月合计待机小时 pewp.setYhjdjxs(pewp.getRhjdjxs()); //月合计维护停机小时 pewp.setYhjjxtjxs(pewp.getRhjjxtjxs()); // 月合计故障停机小时 pewp.setYhjgztjxs(pewp.getRhjgztjxs()); //月合计运行小时 pewp.setYhjyxxs(pewp.getRhjyxxs()); //月合计限电小时 pewp.setYhjxdxs(pewp.getRhjxdxs()); //月合计通讯中断小时 pewp.setYhjtxzdxs(pewp.getRhjtxzdxs()); //月合计受累小时 pewp.setYhjslxs(pewp.getRhjslxs()); } private static void setLossHoursYearSimple(ProEconPowerstationInfoDay2 pewp) { //年合计待机小时 pewp.setNhjdjxs(pewp.getRhjdjxs()); //年合计维护停机小时 pewp.setNhjjxtjxs(pewp.getRhjjxtjxs()); // 年合计故障小时 pewp.setNhjgztjxs(pewp.getRhjgztjxs()); //年合计运行小时 pewp.setNhjyxxs(pewp.getRhjyxxs()); //年合计限电小时 pewp.setNhjxdxs(pewp.getRhjxdxs()); //年合计通讯中断小时 pewp.setNhjtxzdxs(pewp.getRhjtxzdxs()); //年合计受累小时 pewp.setNhjslxs(pewp.getRhjslxs()); } private void calSimple(ProEconPowerstationInfoDay2 pewp, Date end, Date begin, List wtls, List pepidls) throws Exception { // 0 待机 // 1 运行 // 2 故障 // 3 检修 // 4 限电 // 5 受累 // 6 离线 //*******************************************日信息统计*********************************************************/ double lastState=-1;//上一分钟状态 double djsc=0;//待机时长 double zcfdsc=0;//正常发电时长 double gzsc=0;//故障时长 double jxsc=0;//检修时长 double xdtjsc=0;//限电停机时长 double slsc=0;//受累时长 double txzdsc=0;//通讯中断时长 Map> wtpAimap = CacheContext.wtpAimap; for(ProBasicEquipment wt:wtls) { Map aimap=wtpAimap.get(wt.getId()); if(aimap.containsKey(ContantXk.SBZT)) { ProBasicEquipmentPoint point=aimap.get(ContantXk.SBZT); //按照分钟时间进行统计状态快照值 List pointls=edosUtil.getHistoryDatasSnap(point.getNemCode(), begin.getTime()/1000, end.getTime()/1000); if(!pointls.isEmpty()) { for (PointData po : pointls) { if (po.getPointValueInDouble() == 0) { if (lastState != po.getPointValueInDouble()) { //将当前状态保存到上一分钟状态 lastState = po.getPointValueInDouble(); } //待机时长加1分钟 djsc++; } else if (po.getPointValueInDouble() == 1) { if (lastState != po.getPointValueInDouble()) { //将当前状态保存到上一分钟状态 lastState = po.getPointValueInDouble(); } //正常发电时长加1分钟 zcfdsc++; } else if (po.getPointValueInDouble() == 2) { if (lastState != po.getPointValueInDouble()) { //将当前状态保存到上一分钟状态 lastState = po.getPointValueInDouble(); } //故障时长加1分钟 gzsc++; } else if (po.getPointValueInDouble() == 3) { if (lastState != po.getPointValueInDouble()) { //将当前状态保存到上一分钟状态 lastState = po.getPointValueInDouble(); } //检修时长加1分钟 jxsc++; } else if (po.getPointValueInDouble() == 4) { if (lastState != po.getPointValueInDouble()) { //将当前状态保存到上一分钟状态 lastState = po.getPointValueInDouble(); } //限电停机时长加1分钟 xdtjsc++; } else if (po.getPointValueInDouble() == 5) { if (lastState != po.getPointValueInDouble()) { //将当前状态保存到上一分钟状态 lastState = po.getPointValueInDouble(); } //受累时长加1分钟 slsc++; } else if (po.getPointValueInDouble() == 6) { if (lastState != po.getPointValueInDouble()) { //将当前状态保存到上一分钟状态 lastState = po.getPointValueInDouble(); } //通讯中断时长加1分钟 txzdsc++; } } } } } //日合计待机小时 pewp.setRhjdjxs(new BigDecimal(gzsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue()); //日合计维护停机小时 pewp.setRhjjxtjxs(new BigDecimal(jxsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue()); // 日合计待机小时 pewp.setRhjdjxs(new BigDecimal(djsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue()); //日合计运行小时 pewp.setRhjyxxs(new BigDecimal(zcfdsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue()); //日合计限电小时 pewp.setRhjxdxs(new BigDecimal(xdtjsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue()); //日合计通讯中断小时 pewp.setRhjtxzdxs(new BigDecimal(txzdsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue()); //日合计受累小时 pewp.setRhjslxs(new BigDecimal(slsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue()); //*******************************************日信息统计*********************************************************/ //*******************************************月信息统计*********************************************************/ if(pepidls.isEmpty()) { setLossHoursMonthSimple(pewp); }else { ProEconPowerstationInfoDay2 pepid=pepidls.get(0); //月合计待机小时 pewp.setYhjdjxs(StringUtils.round(pepid.getYhjdjxs()+pewp.getRhjdjxs(),2)); //月合计维护停机小时 pewp.setYhjjxtjxs(StringUtils.round(pepid.getYhjjxtjxs()+pewp.getRhjjxtjxs(),2)); // 月合计故障小时 pewp.setYhjgztjxs(StringUtils.round(pepid.getYhjgztjxs()+pewp.getRhjgztjxs(),2)); //月合计运行小时 pewp.setYhjyxxs(StringUtils.round(pepid.getYhjyxxs()+pewp.getRhjyxxs(),2)); //月合计限电小时 pewp.setYhjxdxs(StringUtils.round(pepid.getYhjxdxs()+pewp.getRhjxdxs(),2)); //月合计通讯中断小时 pewp.setYhjtxzdxs(StringUtils.round(pepid.getYhjtxzdxs()+pewp.getRhjtxzdxs(),2)); //月合计受累小时 pewp.setYhjslxs(StringUtils.round(pepid.getYhjslxs()+pewp.getRhjslxs(),2)); } //*******************************************月信息统计*********************************************************/ //*******************************************年信息统计*********************************************************/ if(pepidls.isEmpty()) { setLossHoursYearSimple(pewp); }else { ProEconPowerstationInfoDay2 pepid=pepidls.get(0); //年合计待机小时 pewp.setNhjdjxs(StringUtils.round(pepid.getNhjdjxs()+pewp.getRhjdjxs(),2)); //年合计维护停机小时 pewp.setNhjjxtjxs(StringUtils.round(pepid.getNhjjxtjxs()+pewp.getRhjjxtjxs(),2)); // 年合计故障小时 pewp.setNhjgztjxs(StringUtils.round(pepid.getNhjgztjxs()+pewp.getRhjgztjxs(),2)); //年合计运行小时 pewp.setNhjyxxs(StringUtils.round(pepid.getNhjyxxs()+pewp.getRhjyxxs(),2)); //年合计限电小时 pewp.setNhjxdxs(StringUtils.round(pepid.getNhjxdxs()+pewp.getRhjxdxs(),2)); //年合计通讯中断小时 pewp.setNhjtxzdxs(StringUtils.round(pepid.getNhjtxzdxs()+pewp.getRhjtxzdxs(),2)); //年合计受累小时 pewp.setNhjslxs(StringUtils.round(pepid.getNhjslxs()+pewp.getRhjslxs(),2)); } //*******************************************年信息统计*********************************************************/ } }