1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258 |
- 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.IProEconPowerstationInfoDay3Service;
- import com.gyee.generation.util.DateUtils;
- import com.gyee.generation.util.realtimesource.IEdosUtil;
- import com.gyee.generation.util.statisticcs.Initial;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- 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 WindPowerInfo3Service {
- private static final Logger logger = LoggerFactory.getLogger(WindPowerInfo2Service.class);
- @Resource
- private IEdosUtil edosUtil;
- @Resource
- private IProEconPowerstationInfoDay3Service proEconPowerstationInfoDay3Service;
- /**
- * 计算区域日信息
- * @param recordDate
- * @throws Exception
- */
- public void calRegionInfoDay(Date recordDate) throws Exception {
- List<ProEconPowerstationInfoDay3> wpinfodayls = proEconPowerstationInfoDay3Service.list().stream()
- .filter(i -> i.getRecordDate().compareTo(DateUtils.truncDay(recordDate))==0
- // && CacheContext.wpmap.containsKey(i.getWindpowerstationId())
- && i.getLocation().equals(Location.cp.getValue()))
- .collect(Collectors.toList());
- if(!wpinfodayls.isEmpty())
- {
- Map<String, Map<String, List<ProEconPowerstationInfoDay3>>>rgmap=new HashMap<>();
- for(ProEconPowerstationInfoDay3 wpinfo:wpinfodayls)
- {
- if(rgmap.containsKey(wpinfo.getCompanyId()))
- {
- Map<String, List<ProEconPowerstationInfoDay3>> map=rgmap.get(wpinfo.getCompanyId());
- List<ProEconPowerstationInfoDay3> qbls=map.get("qb");
- List<ProEconPowerstationInfoDay3> gfls=map.get("fd");
- List<ProEconPowerstationInfoDay3> 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<String, List<ProEconPowerstationInfoDay3>> map=new HashMap<>();
- List<ProEconPowerstationInfoDay3> qbls=new ArrayList<>();
- List<ProEconPowerstationInfoDay3> gfls=new ArrayList<>();
- List<ProEconPowerstationInfoDay3> 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);
- }
- }
- //判断是否有重复记录,先删除重复记录
- List<String> idls = proEconPowerstationInfoDay3Service.list().stream()
- .filter(i -> i.getRecordDate().compareTo(DateUtils.truncDay(recordDate))==0
- // && CacheContext.wpmap.containsKey(i.getWindpowerstationId())
- && i.getLocation().equals(Location.rg.getValue())).map(ProEconPowerstationInfoDay3::getId)
- .collect(Collectors.toList());
- if (idls != null && idls.size() > 0) {
- proEconPowerstationInfoDay3Service.removeByIds(idls);
- }
- for(Map.Entry<String, Map<String, List<ProEconPowerstationInfoDay3>>> entry:rgmap.entrySet()){
- Map<String, List<ProEconPowerstationInfoDay3>> map=entry.getValue();
- List<ProEconPowerstationInfoDay3> qbls=map.get("qb");
- List<ProEconPowerstationInfoDay3> gfls=map.get("fd");
- List<ProEconPowerstationInfoDay3> fdls=map.get("gf");
- // if(CacheContext.cpwpmap.size()==qbls.size())
- // {
- ProEconPowerstationInfoDay3 qb=new ProEconPowerstationInfoDay3();
- ProEconPowerstationInfoDay3 fd=new ProEconPowerstationInfoDay3();
- ProEconPowerstationInfoDay3 gf=new ProEconPowerstationInfoDay3();
- if(CacheContext.rgmap.containsKey(entry.getKey()))
- {
- ProBasicRegion cp=CacheContext.rgmap.get(entry.getKey());
- gf.setRegionId(cp.getId());
- gf.setRecordDate(DateUtils.truncDay(recordDate));
- gf.setForeignKeyId("-2");
- gf.setLocation(Location.rg.getValue());
- fd.setRegionId(cp.getId());
- fd.setRecordDate(DateUtils.truncDay(recordDate));
- fd.setForeignKeyId("-1");
- fd.setLocation(Location.rg.getValue());
- qb.setRegionId(cp.getId());
- qb.setRecordDate(DateUtils.truncDay(recordDate));
- qb.setForeignKeyId("0");
- qb.setLocation(Location.rg.getValue());
- //计算区域级全部
- calCp(qb,qbls);
- //计算公司级风电场站
- calCp(fd,fdls);
- //计算公司级光电场站
- calCp(gf,gfls);
- proEconPowerstationInfoDay3Service.save(qb);
- proEconPowerstationInfoDay3Service.save(fd);
- proEconPowerstationInfoDay3Service.save(gf);
- }
- // }else
- // {
- // logger.debug("公司所属场站数量与保存的场站日信息数量不一致,未进行{0}统计-------结束", entry.getKey());
- //
- // }
- };
- }
- }
- /**
- * 计算公司日信息
- * @param recordDate
- * @throws Exception
- */
- public void calCompanyInfoDay(Date recordDate) throws Exception {
- List<ProEconPowerstationInfoDay3> wpinfodayls = proEconPowerstationInfoDay3Service.list().stream()
- .filter(i -> i.getRecordDate().compareTo(DateUtils.truncDay(recordDate))==0
- // && CacheContext.wpmap.containsKey(i.getWindpowerstationId())
- && i.getLocation().equals(Location.wp.getValue()))
- .collect(Collectors.toList());
- if(!wpinfodayls.isEmpty())
- {
- Map<String, Map<String, List<ProEconPowerstationInfoDay3>>>cpmap=new HashMap<>();
- for(ProEconPowerstationInfoDay3 wpinfo:wpinfodayls)
- {
- if(cpmap.containsKey(wpinfo.getCompanyId()))
- {
- Map<String, List<ProEconPowerstationInfoDay3>> map=cpmap.get(wpinfo.getCompanyId());
- List<ProEconPowerstationInfoDay3> qbls=map.get("qb");
- List<ProEconPowerstationInfoDay3> gfls=map.get("fd");
- List<ProEconPowerstationInfoDay3> fdls=map.get("gf");
- if(wpinfo.getWindpowerstationId().indexOf("FDC")>=0)
- {
- fdls.add(wpinfo);
- }else {
- gfls.add(wpinfo);
- }
- qbls.add(wpinfo);
- }else
- {
- Map<String, List<ProEconPowerstationInfoDay3>> map=new HashMap<>();
- List<ProEconPowerstationInfoDay3> qbls=new ArrayList<>();
- List<ProEconPowerstationInfoDay3> gfls=new ArrayList<>();
- List<ProEconPowerstationInfoDay3> fdls=new ArrayList<>();
- if(wpinfo.getWindpowerstationId().indexOf("FDC")>=0)
- {
- fdls.add(wpinfo);
- }else {
- gfls.add(wpinfo);
- }
- qbls.add(wpinfo);
- map.put("qb",qbls);
- map.put("fd",fdls);
- map.put("gf",gfls);
- }
- }
- //判断是否有重复记录,先删除重复记录
- List<String> idls = proEconPowerstationInfoDay3Service.list().stream()
- .filter(i -> i.getRecordDate().compareTo(DateUtils.truncDay(recordDate))==0
- // && CacheContext.wpmap.containsKey(i.getWindpowerstationId())
- && i.getLocation().equals(Location.cp.getValue())).map(ProEconPowerstationInfoDay3::getId)
- .collect(Collectors.toList());
- if (idls != null && idls.size() > 0) {
- proEconPowerstationInfoDay3Service.removeByIds(idls);
- }
- for(Map.Entry<String, Map<String, List<ProEconPowerstationInfoDay3>>> entry:cpmap.entrySet()){
- Map<String, List<ProEconPowerstationInfoDay3>> map=entry.getValue();
- List<ProEconPowerstationInfoDay3> qbls=map.get("qb");
- List<ProEconPowerstationInfoDay3> gfls=map.get("fd");
- List<ProEconPowerstationInfoDay3> fdls=map.get("gf");
- // if(CacheContext.cpwpmap.size()==qbls.size())
- // {
- ProEconPowerstationInfoDay3 qb=new ProEconPowerstationInfoDay3();
- ProEconPowerstationInfoDay3 fd=new ProEconPowerstationInfoDay3();
- ProEconPowerstationInfoDay3 gf=new ProEconPowerstationInfoDay3();
- if(CacheContext.cpmap.containsKey(entry.getKey()))
- {
- ProBasicCompany cp=CacheContext.cpmap.get(entry.getKey());
- gf.setRegionId(cp.getRegionId());
- gf.setCompanyId(cp.getId());
- gf.setRecordDate(DateUtils.truncDay(recordDate));
- gf.setForeignKeyId("-2");
- gf.setLocation(Location.cp.getValue());
- fd.setRegionId(cp.getRegionId());
- fd.setCompanyId(cp.getId());
- fd.setRecordDate(DateUtils.truncDay(recordDate));
- fd.setForeignKeyId("-1");
- fd.setLocation(Location.cp.getValue());
- qb.setRegionId(cp.getRegionId());
- qb.setCompanyId(cp.getId());
- qb.setRecordDate(DateUtils.truncDay(recordDate));
- qb.setForeignKeyId("0");
- qb.setLocation(Location.cp.getValue());
- //计算公司级全部场站
- calCp(qb,qbls);
- //计算公司级风电场站
- calCp(fd,fdls);
- //计算公司级光电场站
- calCp(gf,gfls);
- proEconPowerstationInfoDay3Service.save(qb);
- proEconPowerstationInfoDay3Service.save(fd);
- proEconPowerstationInfoDay3Service.save(gf);
- }
- // }else
- // {
- // logger.debug("公司所属场站数量与保存的场站日信息数量不一致,未进行{0}统计-------结束", entry.getKey());
- //
- // }
- };
- }
- }
- private void calCp(ProEconPowerstationInfoDay3 pewp,List<ProEconPowerstationInfoDay3> ls) throws Exception {
- if(!ls.isEmpty())
- {
- for(ProEconPowerstationInfoDay3 pepid:ls)
- {
- //日合计故障小时(明细)
- pewp.setRhjgzcsmx(StringUtils.round(pewp.getRhjgzcsmx()+pepid.getRhjgzcsmx(),2));
- //日合计场内受累故障小时(明细)
- pewp.setRhjcnslgzcsmx(StringUtils.round(pewp.getRhjcnslgzcsmx()+pepid.getRhjcnslgzcsmx(),2));
- //日合计检修小时(明细)
- pewp.setRhjjxcsmx(StringUtils.round(pewp.getRhjjxcsmx()+pepid.getRhjjxcsmx(),2));
- //日合计场内受累检修小时(明细)
- pewp.setRhjcnsljxcsmx(StringUtils.round(pewp.getRhjcnsljxcsmx()+pepid.getRhjcnsljxcsmx(),2));
- //日合计待机小时(明细)
- pewp.setRhjdjcsmx(StringUtils.round(pewp.getRhjdjcsmx()+pepid.getRhjdjcsmx(),2));
- //日合计缺陷降出力小时(明细)
- pewp.setRhjqxjclcsmx(StringUtils.round(pewp.getRhjqxjclcsmx()+pepid.getRhjqxjclcsmx(),2));
- //日合计手动停机小时(明细)
- pewp.setRhjsdtjcsmx(StringUtils.round(pewp.getRhjsdtjcsmx()+pepid.getRhjsdtjcsmx(),2));
- //日合计性能小时(明细)
- pewp.setRhjbwcsmx(StringUtils.round(pewp.getRhjbwcsmx()+pepid.getRhjbwcsmx(),2));
- //日合计限电停机小时(明细)
- pewp.setRhjxdtjcsmx(StringUtils.round(pewp.getRhjxdtjcsmx()+pepid.getRhjxdtjcsmx(),2));
- //日合计限电降出力小时(明细)
- pewp.setRhjxdjclcsmx(StringUtils.round(pewp.getRhjxdjclcsmx()+pepid.getRhjxdjclcsmx(),2));
- //日合计场外受累电网小时(明细)
- pewp.setRhjcwsldwcsmx(StringUtils.round(pewp.getRhjcwsldwcsmx()+pepid.getRhjcwsldwcsmx(),2));
- //日合计场外受累电网小时(明细)
- pewp.setRhjcwsltqcsmx(StringUtils.round(pewp.getRhjcwsltqcsmx()+pepid.getRhjcwsltqcsmx(),2));
- //日合计通讯中断小时(明细)
- pewp.setRhjtxzdcsmx(StringUtils.round(pewp.getRhjtxzdcsmx()+pepid.getRhjtxzdcsmx(),2));
- //日合计离线小时(明细)
- pewp.setRhjlxcsmx(StringUtils.round(pewp.getRhjlxcsmx()+pepid.getRhjlxcsmx(),2));
- //月合计故障小时(明细)
- pewp.setYhjgzcsmx(StringUtils.round(pewp.getYhjgzcsmx()+pepid.getYhjgzcsmx(),2));
- //月合计场内受累故障小时(明细)
- pewp.setYhjcnslgzcsmx(StringUtils.round(pewp.getYhjcnslgzcsmx()+pepid.getYhjcnslgzcsmx(),2));
- //月合计检修小时(明细)
- pewp.setYhjjxcsmx(StringUtils.round(pewp.getYhjjxcsmx()+pepid.getYhjjxcsmx(),2));
- //月合计场内受累检修小时(明细)
- pewp.setYhjcnsljxcsmx(StringUtils.round(pewp.getYhjcnsljxcsmx()+pepid.getYhjcnsljxcsmx(),2));
- //月合计待机小时(明细)
- pewp.setYhjdjcsmx(StringUtils.round(pewp.getYhjdjcsmx()+pepid.getYhjdjcsmx(),2));
- //月合计缺陷降出力小时(明细)
- pewp.setYhjqxjclcsmx(StringUtils.round(pewp.getYhjqxjclcsmx()+pepid.getYhjqxjclcsmx(),2));
- //月合计手动停机小时(明细)
- pewp.setYhjsdtjcsmx(StringUtils.round(pewp.getYhjsdtjcsmx()+pepid.getYhjsdtjcsmx(),2));
- //月合计性能小时(明细)
- pewp.setYhjbwcsmx(StringUtils.round(pewp.getYhjbwcsmx()+pepid.getYhjbwcsmx(),2));
- //月合计限电停机小时(明细)
- pewp.setYhjxdtjcsmx(StringUtils.round(pewp.getYhjxdtjcsmx()+pepid.getYhjxdtjcsmx(),2));
- //月合计限电降出力小时(明细)
- pewp.setYhjxdjclcsmx(StringUtils.round(pewp.getYhjxdjclcsmx()+pepid.getYhjxdjclcsmx(),2));
- //月合计场外受累电网小时(明细)
- pewp.setYhjcwsldwcsmx(StringUtils.round(pewp.getYhjcwsldwcsmx()+pepid.getYhjcwsldwcsmx(),2));
- //月合计场外受累电网小时(明细)
- pewp.setYhjcwsltqcsmx(StringUtils.round(pewp.getYhjcwsltqcsmx()+pepid.getYhjcwsltqcsmx(),2));
- //月合计通讯中断小时(明细)
- pewp.setYhjtxzdcsmx(StringUtils.round(pewp.getYhjtxzdcsmx()+pepid.getYhjtxzdcsmx(),2));
- //月合计离线小时(明细)
- pewp.setYhjlxcsmx(StringUtils.round(pewp.getYhjlxcsmx()+pepid.getYhjlxcsmx(),2));
- //年合计故障小时(明细)
- pewp.setNhjgzcsmx(StringUtils.round(pewp.getNhjgzcsmx()+pepid.getNhjgzcsmx(),2));
- //年合计场内受累故障小时(明细)
- pewp.setNhjcnslgzcsmx(StringUtils.round(pewp.getNhjcnslgzcsmx()+pepid.getNhjcnslgzcsmx(),2));
- //年合计检修小时(明细)
- pewp.setNhjjxcsmx(StringUtils.round(pewp.getNhjjxcsmx()+pepid.getNhjjxcsmx(),2));
- //年合计场内受累检修小时(明细)
- pewp.setNhjcnsljxcsmx(StringUtils.round(pewp.getNhjcnsljxcsmx()+pepid.getNhjcnsljxcsmx(),2));
- //年合计待机小时(明细)
- pewp.setNhjdjcsmx(StringUtils.round(pewp.getNhjdjcsmx()+pepid.getNhjdjcsmx(),2));
- //年合计缺陷降出力小时(明细)
- pewp.setNhjqxjclcsmx(StringUtils.round(pewp.getNhjqxjclcsmx()+pepid.getNhjqxjclcsmx(),2));
- //年合计手动停机小时(明细)
- pewp.setNhjsdtjcsmx(StringUtils.round(pewp.getNhjsdtjcsmx()+pepid.getNhjsdtjcsmx(),2));
- //年合计性能小时(明细)
- pewp.setNhjbwcsmx(StringUtils.round(pewp.getNhjbwcsmx()+pepid.getNhjbwcsmx(),2));
- //年合计限电停机小时(明细)
- pewp.setNhjxdtjcsmx(StringUtils.round(pewp.getNhjxdtjcsmx()+pepid.getNhjxdtjcsmx(),2));
- //年合计限电降出力小时(明细)
- pewp.setNhjxdjclcsmx(StringUtils.round(pewp.getNhjxdjclcsmx()+pepid.getNhjxdjclcsmx(),2));
- //年合计场外受累电网小时(明细)
- pewp.setNhjcwsldwcsmx(StringUtils.round(pewp.getNhjcwsldwcsmx()+pepid.getNhjcwsldwcsmx(),2));
- //年合计场外受累电网小时(明细)
- pewp.setNhjcwsltqcsmx(StringUtils.round(pewp.getNhjcwsltqcsmx()+pepid.getNhjcwsltqcsmx(),2));
- //年合计通讯中断小时(明细)
- pewp.setNhjtxzdcsmx(StringUtils.round(pewp.getNhjtxzdcsmx()+pepid.getNhjtxzdcsmx(),2));
- //年合计离线小时(明细)
- pewp.setNhjlxcsmx(StringUtils.round(pewp.getNhjlxcsmx()+pepid.getNhjlxcsmx(),2));
- }
- }
- }
- /**
- * 计算场站日信息
- * @param recordDate
- * @throws Exception
- */
- public void calWindpowerInfoDay(Date recordDate) throws Exception {
- Calendar c=Calendar.getInstance();
- c.setTime(recordDate);
- Date end=c.getTime();
- Date begin= DateUtils.truncDay(c.getTime());
- List<ProEconPowerstationInfoDay3> wpinfodayls=new ArrayList<>();
- //判断是否有重复记录,先删除重复记录
- List<String> idls = proEconPowerstationInfoDay3Service.list().stream()
- .filter(i -> i.getRecordDate().compareTo(DateUtils.truncDay(recordDate))==0
- && CacheContext.wpmap.containsKey(i.getWindpowerstationId())
- && i.getLocation().equals(Location.wp.getValue())).map(ProEconPowerstationInfoDay3::getId)
- .collect(Collectors.toList());
- if (idls != null && idls.size() > 0) {
- proEconPowerstationInfoDay3Service.removeByIds(idls);
- }
- for(ProBasicWindpowerstation wp:CacheContext.wpls)
- {
- if(CacheContext.wppointmap.containsKey(wp.getId()))
- {
- Map<String, ProBasicWppoint> pointmap=CacheContext.wppointmap.get(wp.getId());
- ProEconPowerstationInfoDay3 pewp=new ProEconPowerstationInfoDay3();
- Initial.initial(pewp);
- pewp.setRegionId(wp.getRegionId());
- pewp.setCompanyId(wp.getCompanyId());
- pewp.setRecordDate(DateUtils.truncDay(recordDate));
- pewp.setForeignKeyId("0");
- pewp.setWindpowerstationId(wp.getId());
- pewp.setLocation(Location.wp.getValue());
- //昨日的统计结果
- List<ProEconPowerstationInfoDay3> pepidls =new ArrayList<>();
- Calendar cl=Calendar.getInstance();
- cl.setTime(recordDate);
- if(cl.get(Calendar.DAY_OF_MONTH)!=1)
- {
- pepidls = proEconPowerstationInfoDay3Service.list().stream()
- .filter(i -> i.getRecordDate().compareTo(DateUtils.truncDay(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);
- /*******************************************年信息统计*********************************************************/
- // wpinfodayls.add(pewp);
- proEconPowerstationInfoDay3Service.save(pewp);
- }
- }
- }
- /**
- * 计算项目日信息
- * @param recordDate
- * @throws Exception
- */
- public void calProjectInfoDay(Date recordDate) throws Exception {
- Calendar c=Calendar.getInstance();
- c.setTime(recordDate);
- Date end=c.getTime();
- Date begin= DateUtils.truncDay(c.getTime());
- //判断是否有重复记录,先删除重复记录
- List<String> idls = proEconPowerstationInfoDay3Service.list().stream()
- .filter(i -> i.getRecordDate().compareTo(DateUtils.truncDay(recordDate))==0
- && CacheContext.pjmap.containsKey(i.getProjectId())
- && i.getLocation().equals(Location.pj.getValue())).map(ProEconPowerstationInfoDay3::getId)
- .collect(Collectors.toList());
- if (idls != null && idls.size() > 0) {
- proEconPowerstationInfoDay3Service.removeByIds(idls);
- }
- for(ProBasicProject pj:CacheContext.pjls)
- {
- if(CacheContext.wppointmap.containsKey(pj.getId()))
- {
- Map<String, ProBasicWppoint> pointmap=CacheContext.wppointmap.get(pj.getId());
- ProEconPowerstationInfoDay3 pewp=new ProEconPowerstationInfoDay3();
- Initial.initial(pewp);
- pewp.setForeignKeyId("0");
- pewp.setWindpowerstationId(pj.getWindpowerstationId());
- pewp.setProjectId(pj.getId());
- pewp.setLocation(Location.pj.getValue());
- pewp.setRecordDate(DateUtils.truncDay(recordDate));
- //昨日的统计结果
- List<ProEconPowerstationInfoDay3> pepidls =new ArrayList<>();
- Calendar cl=Calendar.getInstance();
- cl.setTime(recordDate);
- if(cl.get(Calendar.DAY_OF_MONTH)!=1)
- {
- pepidls = proEconPowerstationInfoDay3Service.list().stream()
- .filter(i -> i.getRecordDate().compareTo(DateUtils.truncDay(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);
- proEconPowerstationInfoDay3Service.save(pewp);
- }
- }
- }
- /**
- * 计算线路日信息
- * @param recordDate
- * @throws Exception
- */
- public void calLineInfoDay(Date recordDate) throws Exception {
- Calendar c=Calendar.getInstance();
- c.setTime(recordDate);
- Date end=c.getTime();
- Date begin= DateUtils.truncDay(c.getTime());
- //判断是否有重复记录,先删除重复记录
- List<String> idls = proEconPowerstationInfoDay3Service.list().stream()
- .filter(i -> i.getRecordDate().compareTo(DateUtils.truncDay(recordDate))==0
- && CacheContext.lnmap.containsKey(i.getLineId())
- && i.getLocation().equals(Location.ln.getValue()) ).map(ProEconPowerstationInfoDay3::getId)
- .collect(Collectors.toList());
- if (idls != null && idls.size() > 0) {
- proEconPowerstationInfoDay3Service.removeByIds(idls);
- }
- for(ProBasicLine ln:CacheContext.lnls)
- {
- if(CacheContext.wppointmap.containsKey(ln.getId()))
- {
- Map<String, ProBasicWppoint> pointmap=CacheContext.wppointmap.get(ln.getId());
- ProEconPowerstationInfoDay3 pewp=new ProEconPowerstationInfoDay3();
- Initial.initial(pewp);
- pewp.setForeignKeyId("0");
- pewp.setLineId(ln.getId());
- pewp.setLocation(Location.ln.getValue());
- pewp.setProjectId(ln.getProjectId());
- pewp.setRecordDate(DateUtils.truncDay(recordDate));
- //昨日的统计结果
- List<ProEconPowerstationInfoDay3> pepidls =new ArrayList<>();
- Calendar cl=Calendar.getInstance();
- cl.setTime(recordDate);
- if(cl.get(Calendar.DAY_OF_MONTH)!=1)
- {
- pepidls = proEconPowerstationInfoDay3Service.list().stream()
- .filter(i -> i.getRecordDate().compareTo(DateUtils.truncDay(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);
- proEconPowerstationInfoDay3Service.save(pewp);
- }
- }
- }
- private void calDetiall(ProEconPowerstationInfoDay3 pewp,Date end, Date begin,List<ProBasicWindturbine> wtls,List<ProEconPowerstationInfoDay3> pepidls) throws Exception {
- // // 0 待机
- // 1 手动停机
- // 2 正常发电
- // 3 发电降出力
- // 4 故障
- // 5 故障受累
- // 6 检修
- // 7 检修受累
- // 8 限电降出力
- // 9 限电停机
- // 10 电网受累
- // 11 环境受累
- // 12 通讯中断
- // 13 设备离线
- double lastState=-1;//上一分钟状态
- 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<String, Map<String, ProBasicEquipmentPoint>> wtpAimap = CacheContext.wtpAimap;
- for(ProBasicWindturbine wt:wtls)
- {
- lastState=-1;//上一分钟状态
- Map<String, ProBasicEquipmentPoint> aimap=wtpAimap.get(wt.getNemCode());
- if(wtpAimap.containsKey(ContantXk.MXZT));
- {
- ProBasicEquipmentPoint point=aimap.get(ContantXk.MXZT);
- //按照分钟时间进行统计状态快照值
- List<PointData> 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.setRhjgzcsmx(new BigDecimal(gzsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
- //日合计场内受累故障小时(明细)
- pewp.setRhjcnslgzcsmx(new BigDecimal(gzslsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
- //日合计检修小时(明细)
- pewp.setRhjjxcsmx(new BigDecimal(jxsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
- //日合计场内受累检修小时(明细)
- pewp.setRhjcnsljxcsmx(new BigDecimal(jxslsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
- //日合计待机小时(明细)
- pewp.setRhjdjcsmx(new BigDecimal(djsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
- //日合计缺陷降出力小时(明细)
- pewp.setRhjqxjclcsmx(new BigDecimal(fdjclsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
- //日合计手动停机小时(明细)
- pewp.setRhjsdtjcsmx(new BigDecimal(sdtjsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
- //日合计性能小时(明细)
- pewp.setRhjbwcsmx(new BigDecimal(zcfdsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
- //日合计限电停机小时(明细)
- pewp.setRhjxdtjcsmx(new BigDecimal(xdtjsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
- //日合计限电降出力小时(明细)
- pewp.setRhjxdjclcsmx(new BigDecimal(xdjclsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
- //日合计场外受累电网小时(明细)
- pewp.setRhjcwsldwcsmx(new BigDecimal(dwslsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
- //日合计场外受累电网小时(明细)
- pewp.setRhjcwsltqcsmx(new BigDecimal(hjslsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
- //日合计通讯中断小时(明细)
- pewp.setRhjtxzdcsmx(new BigDecimal(txzdsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
- //日合计离线小时(明细)
- pewp.setRhjlxcsmx(new BigDecimal(sblxsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
- /*******************************************日信息统计*********************************************************/
- /*******************************************月信息统计*********************************************************/
- if(pepidls.isEmpty())
- {
- setLossHoursMonth(pewp);
- }else
- {
- if(!pepidls.isEmpty())
- {
- ProEconPowerstationInfoDay3 pepid=pepidls.get(0);
- //月合计故障小时(明细)
- pewp.setYhjgzcsmx(StringUtils.round(pepid.getYhjgzcsmx()+pewp.getRhjgzcsmx(),2));
- //月合计场内受累故障小时(明细)
- pewp.setYhjcnslgzcsmx(StringUtils.round(pepid.getYhjcnslgzcsmx()+pewp.getRhjcnslgzcsmx(),2));
- //月合计检修小时(明细)
- pewp.setYhjjxcsmx(StringUtils.round(pepid.getYhjjxcsmx()+pewp.getRhjjxcsmx(),2));
- //月合计场内受累检修小时(明细)
- pewp.setYhjcnsljxcsmx(StringUtils.round( pepid.getYhjcnsljxcsmx()+pewp.getRhjcnsljxcsmx(),2));
- //月合计待机小时(明细)
- pewp.setYhjdjcsmx(StringUtils.round(pepid.getYhjdjcsmx()+pewp.getRhjdjcsmx(),2));
- //月合计缺陷降出力小时(明细)
- pewp.setYhjqxjclcsmx(StringUtils.round(pepid.getYhjqxjclcsmx()+pewp.getRhjqxjclcsmx(),2));
- //月合计手动停机小时(明细)
- pewp.setYhjsdtjcsmx(StringUtils.round(pepid.getYhjsdtjcsmx()+pewp.getRhjsdtjcsmx(),2));
- //月合计性能小时(明细)
- pewp.setYhjbwcsmx(StringUtils.round(pepid.getYhjbwcsmx()+pewp.getRhjbwcsmx(),2));
- //月合计限电停机小时(明细)
- pewp.setYhjxdtjcsmx(StringUtils.round(pepid.getYhjxdtjcsmx()+pewp.getRhjxdtjcsmx(),2));
- //月合计限电降出力小时(明细)
- pewp.setYhjxdjclcsmx(StringUtils.round(pepid.getYhjxdjclcsmx()+pewp.getRhjxdjclcsmx(),2));
- //月合计场外受累电网小时(明细)
- pewp.setYhjcwsldwcsmx(StringUtils.round(pepid.getYhjcwsldwcsmx()+pewp.getRhjcwsldwcsmx(),2));
- //月合计场外受累电网小时(明细)
- pewp.setYhjcwsltqcsmx(StringUtils.round(pepid.getYhjcwsltqcsmx()+pewp.getRhjcwsltqcsmx(),2));
- //月合计通讯中断小时(明细)
- pewp.setYhjtxzdcsmx(StringUtils.round(pepid.getYhjtxzdcsmx()+pewp.getRhjtxzdcsmx(),2));
- //月合计离线小时(明细)
- pewp.setYhjlxcsmx(StringUtils.round(pepid.getYhjlxcsmx()+pewp.getRhjlxcsmx(),2));
- }else
- {
- setLossHoursMonth(pewp);
- }
- }
- /*******************************************月信息统计*********************************************************/
- /*******************************************年信息统计*********************************************************/
- if(pepidls.isEmpty())
- {
- setLossHoursYear(pewp);
- }else
- {
- if(!pepidls.isEmpty())
- {
- ProEconPowerstationInfoDay3 pepid=pepidls.get(0);
- //年合计故障小时(明细)
- pewp.setYhjgzcsmx(StringUtils.round(pepid.getNhjgzcsmx()+pewp.getRhjgzcsmx(),2));
- //年合计场内受累故障小时(明细)
- pewp.setYhjcnslgzcsmx(StringUtils.round(pepid.getNhjcnslgzcsmx()+pewp.getRhjcnslgzcsmx(),2));
- //年合计检修小时(明细)
- pewp.setYhjjxcsmx(StringUtils.round(pepid.getNhjjxcsmx()+pewp.getRhjjxcsmx(),2));
- //年合计场内受累检修小时(明细)
- pewp.setYhjcnsljxcsmx(StringUtils.round( pepid.getNhjcnsljxcsmx()+pewp.getRhjcnsljxcsmx(),2));
- //年合计待机小时(明细)
- pewp.setYhjdjcsmx(StringUtils.round(pepid.getNhjdjcsmx()+pewp.getRhjdjcsmx(),2));
- //年合计缺陷降出力小时(明细)
- pewp.setYhjqxjclcsmx(StringUtils.round(pepid.getNhjqxjclcsmx()+pewp.getRhjqxjclcsmx(),2));
- //年合计手动停机小时(明细)
- pewp.setYhjsdtjcsmx(StringUtils.round(pepid.getNhjsdtjcsmx()+pewp.getRhjsdtjcsmx(),2));
- //年合计性能小时(明细)
- pewp.setYhjbwcsmx(StringUtils.round(pepid.getNhjbwcsmx()+pewp.getRhjbwcsmx(),2));
- //年合计限电停机小时(明细)
- pewp.setYhjxdtjcsmx(StringUtils.round(pepid.getNhjxdtjcsmx()+pewp.getRhjxdtjcsmx(),2));
- //年合计限电降出力小时(明细)
- pewp.setYhjxdjclcsmx(StringUtils.round(pepid.getNhjxdjclcsmx()+pewp.getRhjxdjclcsmx(),2));
- //年合计场外受累电网小时(明细)
- pewp.setYhjcwsldwcsmx(StringUtils.round(pepid.getNhjcwsldwcsmx()+pewp.getRhjcwsldwcsmx(),2));
- //年合计场外受累电网小时(明细)
- pewp.setYhjcwsltqcsmx(StringUtils.round(pepid.getNhjcwsltqcsmx()+pewp.getRhjcwsltqcsmx(),2));
- //年合计通讯中断小时(明细)
- pewp.setYhjtxzdcsmx(StringUtils.round(pepid.getNhjtxzdcsmx()+pewp.getRhjtxzdcsmx(),2));
- //年合计离线小时(明细)
- pewp.setYhjlxcsmx(StringUtils.round(pepid.getNhjlxcsmx()+pewp.getRhjlxcsmx(),2));
- }else
- {
- setLossHoursYear(pewp);
- }
- }
- }
- private static void setLossHoursYear(ProEconPowerstationInfoDay3 pewp) {
- //年合计故障小时(明细)
- pewp.setNhjgzcsmx(pewp.getRhjgzcsmx());
- //年合计场内受累故障小时(明细)
- pewp.setNhjcnslgzcsmx(pewp.getRhjcnslgzcsmx());
- //年合计检修小时(明细)
- pewp.setNhjjxcsmx(pewp.getRhjjxcsmx());
- //年合计场内受累检修小时(明细)
- pewp.setNhjcnsljxcsmx(pewp.getRhjcnsljxcsmx());
- //年合计待机小时(明细)
- pewp.setNhjdjcsmx(pewp.getRhjdjcsmx());
- //年合计缺陷降出力小时(明细)
- pewp.setNhjqxjclcsmx(pewp.getRhjqxjclcsmx());
- //年合计手动停机小时(明细)
- pewp.setNhjsdtjcsmx(pewp.getRhjsdtjcsmx());
- //年合计性能小时(明细)
- pewp.setNhjbwcsmx(pewp.getRhjbwcsmx());
- //年合计限电停机小时(明细)
- pewp.setNhjxdtjcsmx(pewp.getRhjxdtjcsmx());
- //年合计限电降出力小时(明细)
- pewp.setNhjxdjclcsmx(pewp.getRhjxdjclcsmx());
- //年合计场外受累电网小时(明细)
- pewp.setNhjcwsldwcsmx(pewp.getRhjcwsldwcsmx());
- //年合计场外受累电网小时(明细)
- pewp.setNhjcwsltqcsmx(pewp.getRhjcwsltqcsmx());
- //年合计通讯中断小时(明细)
- pewp.setNhjtxzdcsmx(pewp.getRhjtxzdcsmx());
- //年合计离线小时(明细)
- pewp.setNhjlxcsmx(pewp.getRhjlxcsmx());
- }
- private static void setLossHoursMonth(ProEconPowerstationInfoDay3 pewp) {
- //月合计故障小时(明细)
- pewp.setYhjgzcsmx(pewp.getRhjgzcsmx());
- //月合计场内受累故障小时(明细)
- pewp.setYhjcnslgzcsmx(pewp.getRhjcnslgzcsmx());
- //月合计检修小时(明细)
- pewp.setYhjjxcsmx(pewp.getRhjjxcsmx());
- //月合计场内受累检修小时(明细)
- pewp.setYhjcnsljxcsmx(pewp.getRhjcnsljxcsmx());
- //月合计待机小时(明细)
- pewp.setYhjdjcsmx(pewp.getRhjdjcsmx());
- //月合计缺陷降出力小时(明细)
- pewp.setYhjqxjclcsmx(pewp.getRhjqxjclcsmx());
- //月合计手动停机小时(明细)
- pewp.setYhjsdtjcsmx(pewp.getRhjsdtjcsmx());
- //月合计性能小时(明细)
- pewp.setYhjbwcsmx(pewp.getRhjbwcsmx());
- //月合计限电停机小时(明细)
- pewp.setYhjxdtjcsmx(pewp.getRhjxdtjcsmx());
- //月合计限电降出力小时(明细)
- pewp.setYhjxdjclcsmx(pewp.getRhjxdjclcsmx());
- //月合计场外受累电网小时(明细)
- pewp.setYhjcwsldwcsmx(pewp.getRhjcwsldwcsmx());
- //月合计场外受累电网小时(明细)
- pewp.setYhjcwsltqcsmx(pewp.getRhjcwsltqcsmx());
- //月合计通讯中断小时(明细)
- pewp.setYhjtxzdcsmx(pewp.getRhjtxzdcsmx());
- //月合计离线小时(明细)
- pewp.setYhjlxcsmx(pewp.getRhjlxcsmx());
- }
- private static void setLossHoursMonthSimple(ProEconPowerstationInfoDay3 pewp) {
- //月合计待机小时
- pewp.setYhjdjcs(pewp.getRhjdjcs());
- //月合计维护停机小时
- pewp.setYhjjxtjcs(pewp.getRhjjxtjcs());
- // 月合计故障停机小时
- pewp.setYhjgztjcs(pewp.getRhjgztjcs());
- //月合计运行小时
- pewp.setYhjyxcs(pewp.getRhjyxcs());
- //月合计限电小时
- pewp.setYhjxdcs(pewp.getRhjxdcs());
- //月合计通讯中断小时
- pewp.setYhjtxzdcs(pewp.getRhjtxzdcs());
- //月合计受累小时
- pewp.setYhjslcs(pewp.getRhjslcs());
- }
- private static void setLossHoursYearSimple(ProEconPowerstationInfoDay3 pewp) {
- //年合计待机小时
- pewp.setNhjdjcs(pewp.getRhjdjcs());
- //年合计维护停机小时
- pewp.setNhjjxtjcs(pewp.getRhjjxtjcs());
- // 年合计故障小时
- pewp.setNhjgztjcs(pewp.getRhjgztjcs());
- //年合计运行小时
- pewp.setNhjyxcs(pewp.getRhjyxcs());
- //年合计限电小时
- pewp.setNhjxdcs(pewp.getRhjxdcs());
- //年合计通讯中断小时
- pewp.setNhjtxzdcs(pewp.getRhjtxzdcs());
- //年合计受累小时
- pewp.setNhjslcs(pewp.getRhjslcs());
- }
- private void calSimple(ProEconPowerstationInfoDay3 pewp,Date end, Date begin,List<ProBasicWindturbine> wtls,List<ProEconPowerstationInfoDay3> 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<String, Map<String, ProBasicEquipmentPoint>> wtpAimap = CacheContext.wtpAimap;
- for(ProBasicWindturbine wt:wtls)
- {
- Map<String, ProBasicEquipmentPoint> aimap=wtpAimap.get(wt.getNemCode());
- if(wtpAimap.containsKey(ContantXk.SBZT));
- {
- ProBasicEquipmentPoint point=aimap.get(ContantXk.SBZT);
- //按照分钟时间进行统计状态快照值
- List<PointData> 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.setRhjdjcs(new BigDecimal(gzsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
- //日合计维护停机小时
- pewp.setRhjjxtjcs(new BigDecimal(jxsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
- // 日合计待机小时
- pewp.setRhjdjcs(new BigDecimal(djsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
- //日合计运行小时
- pewp.setRhjyxcs(new BigDecimal(zcfdsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
- //日合计限电小时
- pewp.setRhjxdcs(new BigDecimal(xdtjsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
- //日合计通讯中断小时
- pewp.setRhjtxzdcs(new BigDecimal(txzdsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
- //日合计受累小时
- pewp.setRhjslcs(new BigDecimal(slsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue());
- /*******************************************日信息统计*********************************************************/
- /*******************************************月信息统计*********************************************************/
- if(pepidls.isEmpty())
- {
- setLossHoursMonthSimple(pewp);
- }else
- {
- if(!pepidls.isEmpty())
- {
- ProEconPowerstationInfoDay3 pepid=pepidls.get(0);
- //月合计待机小时
- pewp.setYhjdjcs(StringUtils.round(pepid.getYhjdjcs()+pewp.getRhjdjcs(),2));
- //月合计维护停机小时
- pewp.setYhjjxtjcs(StringUtils.round(pepid.getYhjjxtjcs()+pewp.getRhjjxtjcs(),2));
- // 月合计故障小时
- pewp.setYhjgztjcs(StringUtils.round(pepid.getYhjgztjcs()+pewp.getRhjgztjcs(),2));
- //月合计运行小时
- pewp.setYhjyxcs(StringUtils.round(pepid.getYhjyxcs()+pewp.getRhjyxcs(),2));
- //月合计限电小时
- pewp.setYhjxdcs(StringUtils.round(pepid.getYhjxdcs()+pewp.getRhjxdcs(),2));
- //月合计通讯中断小时
- pewp.setYhjtxzdcs(StringUtils.round(pepid.getYhjtxzdcs()+pewp.getRhjtxzdcs(),2));
- //月合计受累小时
- pewp.setYhjslcs(StringUtils.round(pepid.getYhjslcs()+pewp.getRhjslcs(),2));
- }else
- {
- setLossHoursMonthSimple(pewp);
- }
- }
- /*******************************************月信息统计*********************************************************/
- /*******************************************年信息统计*********************************************************/
- if(pepidls.isEmpty())
- {
- setLossHoursYearSimple(pewp);
- }else
- {
- if(!pepidls.isEmpty())
- {
- ProEconPowerstationInfoDay3 pepid=pepidls.get(0);
- //年合计待机小时
- pewp.setNhjdjcs(StringUtils.round(pepid.getNhjdjcs()+pewp.getRhjdjcs(),2));
- //年合计维护停机小时
- pewp.setNhjjxtjcs(StringUtils.round(pepid.getNhjjxtjcs()+pewp.getRhjjxtjcs(),2));
- // 年合计故障小时
- pewp.setNhjgztjcs(StringUtils.round(pepid.getNhjgztjcs()+pewp.getRhjgztjcs(),2));
- //年合计运行小时
- pewp.setNhjyxcs(StringUtils.round(pepid.getNhjyxcs()+pewp.getRhjyxcs(),2));
- //年合计限电小时
- pewp.setNhjxdcs(StringUtils.round(pepid.getNhjxdcs()+pewp.getRhjxdcs(),2));
- //年合计通讯中断小时
- pewp.setNhjtxzdcs(StringUtils.round(pepid.getNhjtxzdcs()+pewp.getRhjtxzdcs(),2));
- //年合计受累小时
- pewp.setNhjslcs(StringUtils.round(pepid.getNhjslcs()+pewp.getRhjslcs(),2));
- }else
- {
- setLossHoursYearSimple(pewp);
- }
- }
- /*******************************************年信息统计*********************************************************/
- }
- }
|