12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220 |
- 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<ProEconPowerstationInfoDay2> 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<String, Map<String, List<ProEconPowerstationInfoDay2>>>rgmap=new HashMap<>();
- for(ProEconPowerstationInfoDay2 wpinfo:wpinfodayls)
- {
- if(rgmap.containsKey(wpinfo.getRegionId()))
- {
- Map<String, List<ProEconPowerstationInfoDay2>> map=rgmap.get(wpinfo.getRegionId());
- List<ProEconPowerstationInfoDay2> qbls=map.get("qb");
- List<ProEconPowerstationInfoDay2> gfls=map.get("fd");
- List<ProEconPowerstationInfoDay2> 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<ProEconPowerstationInfoDay2>> map=new HashMap<>();
- List<ProEconPowerstationInfoDay2> qbls=new ArrayList<>();
- List<ProEconPowerstationInfoDay2> gfls=new ArrayList<>();
- List<ProEconPowerstationInfoDay2> 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<String> 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<String, Map<String, List<ProEconPowerstationInfoDay2>>> entry:rgmap.entrySet()){
- Map<String, List<ProEconPowerstationInfoDay2>> map=entry.getValue();
- List<ProEconPowerstationInfoDay2> qbls=map.get("qb");
- List<ProEconPowerstationInfoDay2> gfls=map.get("fd");
- List<ProEconPowerstationInfoDay2> 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<ProEconPowerstationInfoDay2> 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<String, Map<String, List<ProEconPowerstationInfoDay2>>>cpmap=new HashMap<>();
- for(ProEconPowerstationInfoDay2 wpinfo:wpinfodayls)
- {
- if(cpmap.containsKey(wpinfo.getCompanyId()))
- {
- Map<String, List<ProEconPowerstationInfoDay2>> map=cpmap.get(wpinfo.getCompanyId());
- List<ProEconPowerstationInfoDay2> qbls=map.get("qb");
- List<ProEconPowerstationInfoDay2> gfls=map.get("fd");
- List<ProEconPowerstationInfoDay2> fdls=map.get("gf");
- if(wpinfo.getWindpowerstationId().contains("FDC"))
- {
- fdls.add(wpinfo);
- }else {
- gfls.add(wpinfo);
- }
- qbls.add(wpinfo);
- }else
- {
- Map<String, List<ProEconPowerstationInfoDay2>> map=new HashMap<>();
- List<ProEconPowerstationInfoDay2> qbls=new ArrayList<>();
- List<ProEconPowerstationInfoDay2> gfls=new ArrayList<>();
- List<ProEconPowerstationInfoDay2> 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<String> 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<String, Map<String, List<ProEconPowerstationInfoDay2>>> entry:cpmap.entrySet()){
- Map<String, List<ProEconPowerstationInfoDay2>> map=entry.getValue();
- List<ProEconPowerstationInfoDay2> qbls=map.get("qb");
- List<ProEconPowerstationInfoDay2> gfls=map.get("fd");
- List<ProEconPowerstationInfoDay2> 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<ProEconPowerstationInfoDay2> 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<String> 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<String, ProBasicPowerstationPoint> 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<ProEconPowerstationInfoDay2> 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<String> 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<String, ProBasicPowerstationPoint> 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<ProEconPowerstationInfoDay2> 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<String> 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<String, ProBasicPowerstationPoint> 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<ProEconPowerstationInfoDay2> 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<ProBasicEquipment> wtls, List<ProEconPowerstationInfoDay2> 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<String, Map<String, ProBasicEquipmentPoint>> wtpAimap = CacheContext.wtpAimap;
- for(ProBasicEquipment wt:wtls)
- {
- lastState=-1;//上一分钟状态
- Map<String, ProBasicEquipmentPoint> aimap=wtpAimap.get(wt.getId());
- if(aimap.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.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<ProBasicEquipment> wtls, List<ProEconPowerstationInfoDay2> 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(ProBasicEquipment wt:wtls)
- {
- Map<String, ProBasicEquipmentPoint> aimap=wtpAimap.get(wt.getId());
- if(aimap.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.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));
- }
- //*******************************************年信息统计*********************************************************/
- }
- }
|