| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835 |
- package com.gyee.generation.service;
- import com.gyee.common.contant.ContantXk;
- import com.gyee.common.model.PointData;
- import com.gyee.generation.init.CacheContext;
- import com.gyee.generation.model.auto.*;
- import com.gyee.generation.service.auto.*;
- import com.gyee.generation.util.DateUtils;
- import com.gyee.generation.util.StringUtils;
- import com.gyee.generation.util.realtimesource.IEdosUtil;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.stereotype.Service;
- import javax.annotation.Resource;
- import java.util.*;
- import java.util.stream.Collectors;
- @Service
- public class ShutdownService {
- @Resource
- private IEdosUtil edosUtil;
- @Resource
- private IProEconWindturbineStatusService proEconWindturbineStatusService;
- @Resource
- private IProEconShutdownEventService proEconShutdownEventService;
- @Resource
- private IProEconShutdownEvent2Service proEconShutdownEvent2Service;
- @Resource
- private IProEconInterruptionService proEconInterruptionService;
- @Resource
- private IProEconInputOrOutputSpeedService proEconInputOrOutputSpeedService;
- public static Logger logger = LoggerFactory.getLogger(ShutdownService.class);
- /// <summary>
- /// 风机状态测点,key为风机编号
- /// </summary>
- public Map<String, ProBasicEquipmentPoint> statusPoints = new HashMap<>();
- /// <summary>
- /// 风机功率测点,key为风机编号
- /// </summary>
- public Map<String, ProBasicEquipmentPoint> powerPoints = new HashMap<>();
- /// <summary>
- /// 风机当前状态,key为风机编号
- /// </summary>
- public Map<String, Integer> status = new HashMap<>();
- /// <summary>
- /// 保存风机信息,key为风机编号
- /// </summary>
- public Map<String, ProBasicEquipment> windTurbines = new HashMap<>();
- /// <summary>
- /// 风机状态说明,key为状态码,value为状态说明
- /// </summary>
- public Map<Integer, String> statusDescription = new HashMap<>();
- public Date date = new Date();
- Map<String, ProEconWindturbineStatus> oldStatusMap = new HashMap<>();
- Map<String, ProEconShutdownEvent> oldShutdownEvent = new HashMap<>();
- Map<String, ProEconInterruption> oldInterrup = new HashMap<>();
- //新增shutdownevent2 实时
- Map<String, ProEconShutdownEvent2> oldShutdownEvent2 = new HashMap<>();
- /// <summary>
- /// 风机功率 key为风机编号
- /// </summary>
- Map<String, ProBasicEquipmentPoint> powerpointMap = new HashMap<>();//功率
- /// <summary>
- /// 风机风速 key为风机编号
- /// </summary>
- Map<String, ProBasicEquipmentPoint> speedpointMap = new HashMap<>();//风速
- /// <summary>
- /// 测风塔风速 key为风场编号
- /// </summary>
- Map<String, ProBasicPowerstationPoint> gzdpointMap = new HashMap<>();//测风塔风速
- Map<String, ProBasicPowerstation> windpowerMap;//风场
- public void init()
- {
- // statusDescription.put(0, "待机");
- // statusDescription.put(1, "并网");
- // statusDescription.put(2, "停机");
- // statusDescription.put(3, "通讯中断");
- // statusDescription.put(4, "维护");
- // statusDescription.put(5, "限电");
- statusDescription.put(0, "待机");
- statusDescription.put(1, "手动停机");
- statusDescription.put(2, "正常发电");
- statusDescription.put(3, "缺陷降出力");
- statusDescription.put(4, "故障停机");
- statusDescription.put(5, "故障受累");
- statusDescription.put(6, "检修停机");
- statusDescription.put(7, "检修受累");
- statusDescription.put(8, "限电降出力");
- statusDescription.put(9, "限电停机");
- statusDescription.put(10, "电网受累");
- statusDescription.put(11, "环境受累");
- statusDescription.put(12, "通讯中断");
- statusDescription.put(13, "设备离线");
- windpowerMap = CacheContext.wpmap;
- List<ProBasicEquipmentPoint> items=new ArrayList<>();
- List<ProBasicEquipmentPoint> powerpointList = new ArrayList<>();
- List<ProBasicEquipmentPoint> speedpointList = new ArrayList<>();
- List<ProBasicEquipment> wtls= CacheContext.wtls;
- Map<String, Map<String, ProBasicEquipmentPoint>> wtpAimap=CacheContext.wtpAimap;
- //筛选风机对应测点
- wtls.forEach(wt->{
- Map<String, ProBasicEquipmentPoint> windturbinetestingpointnewMap = wtpAimap.get(wt.getId());
- if(windturbinetestingpointnewMap.containsKey(ContantXk.MXZT))
- {
- ProBasicEquipmentPoint mxztPoint = windturbinetestingpointnewMap.get(ContantXk.MXZT);
- items.add(mxztPoint);
- }
- if(windturbinetestingpointnewMap.containsKey(ContantXk.CJ_SSGL))
- {
- ProBasicEquipmentPoint ssglPoint = windturbinetestingpointnewMap.get(ContantXk.CJ_SSGL);
- powerPoints.put(ssglPoint.getNemCode(),ssglPoint);
- powerpointList.add(ssglPoint);
- }
- if(windturbinetestingpointnewMap.containsKey(ContantXk.CJ_SSFS))
- {
- ProBasicEquipmentPoint ssfsPoint = windturbinetestingpointnewMap.get(ContantXk.CJ_SSFS);
- speedpointList.add(ssfsPoint);
- }
- });
- //进行测点排序
- powerpointList.sort(Comparator.comparing(ProBasicEquipmentPoint::getWindturbineId));
- speedpointList.sort(Comparator.comparing(ProBasicEquipmentPoint::getWindturbineId));
- for (ProBasicEquipmentPoint item : items)
- {
- statusPoints.put(item.getWindturbineId(), item);
- status.put(item.getWindturbineId(), -1);
- }
- windTurbines=CacheContext.wtmap;
- List<ProBasicPowerstationPoint> gzdpointList =new ArrayList<>();
- CacheContext.wpls.forEach(wp->{
- Map<String, ProBasicPowerstationPoint> wppointsmap = CacheContext.wppointmap.get(wp.getId());
- if(wppointsmap.containsKey(ContantXk.FCCFTFS70))
- {
- ProBasicPowerstationPoint mxztPoint = wppointsmap.get(ContantXk.FCCFTFS70);
- gzdpointList.add(mxztPoint);
- }
- });
- for (ProBasicEquipmentPoint proBasicEquipmentPoint : powerpointList) {
- if (!powerpointMap.containsKey(proBasicEquipmentPoint.getWindturbineId())) {
- powerpointMap.put(proBasicEquipmentPoint.getWindturbineId(), proBasicEquipmentPoint);
- }
- }
- for (ProBasicEquipmentPoint proBasicEquipmentPoint : speedpointList) {
- if (!speedpointMap.containsKey(proBasicEquipmentPoint.getWindturbineId())) {
- speedpointMap.put(proBasicEquipmentPoint.getWindturbineId(), proBasicEquipmentPoint);
- }
- }
- for (ProBasicPowerstationPoint proBasicPowerstationPoint : gzdpointList) {
- if (!gzdpointMap.containsKey(proBasicPowerstationPoint.getWindpowerstationId())) {
- gzdpointMap.put(proBasicPowerstationPoint.getWindpowerstationId(), proBasicPowerstationPoint);
- }
- }
- // List<ProBasicModelPowerRd> pbmprls=proBasicModelPowerRdService.list().stream()
- //
- // .sorted(Comparator.comparing(ProBasicModelPowerRd::getSpeed)).collect(Collectors.toList());
- //
- //
- // if(!pbmprls.isEmpty())
- // {
- // for(ProBasicModelPowerRd pwpcf:pbmprls)
- // {
- //
- // if(modelPowerMap.containsKey(pwpcf.getId()))
- // {
- // Map<Double, ProBasicModelPowerRd> map =modelPowerMap.get(pwpcf.getId());
- // map.put(pwpcf.getSpeed(),pwpcf);
- // modelPowerMap.put(pwpcf.getId(),map);
- // }else
- // {
- // Map<Double, ProBasicModelPowerRd> map = new HashMap<Double, ProBasicModelPowerRd>();
- // map.put(pwpcf.getSpeed(),pwpcf);
- // modelPowerMap.put(pwpcf.getId(),map);
- // }
- //
- // }
- // }
- }
- public void execShutdown() throws Exception {
- init();
- oldStatusMap.clear();
- oldShutdownEvent.clear();
- oldInterrup.clear();
- oldShutdownEvent2.clear();
- logger.debug("{0}开始", date);
- //循环读取所有风机的当前状态,并且给几个缓存字典初始化
- for (String key : statusPoints.keySet())
- {
- //取实时状态数据 赋值给status
- double power = 0;
- if (powerPoints.containsKey(key))
- {
- power = StringUtils.round(edosUtil.getRealData(powerPoints.get(key).getNemCode()).getPointValueInDouble(),4);
- }
- double value = StringUtils.round(edosUtil.getRealData(statusPoints.get(key).getNemCode()).getPointValueInDouble(),4);
- if (power > 1)
- {
- status.put(key,value == 9 ? 1 : (int) value);
- }
- else
- {
- status.put(key,value == 9 ? 0 : (int) value);
- }
- oldStatusMap.put(key, null);
- oldShutdownEvent.put(key, null);
- oldInterrup.put(key, null);
- // 新增 shutdownevent2 实时
- oldShutdownEvent2.put(key, null);
- }
- //读取oracle中 五种小时数、停机记录、中断记录
- //读取数据库存在的恢复时间为NULL的数据
- List<ProEconWindturbineStatus> oldStatusQuery=proEconWindturbineStatusService.list().stream()
- .filter(i->StringUtils.empty(i.getStartTime()))
- .sorted(Comparator.comparing(ProEconWindturbineStatus::getStopTime)).collect(Collectors.toList());
- for (ProEconWindturbineStatus oldStatus : oldStatusQuery)
- {
- if (oldStatusMap.containsKey(oldStatus.getWindturbineId()))
- {
- oldStatusMap.put(oldStatus.getWindturbineId(),oldStatus);
- }
- }
- List<ProEconShutdownEvent> oldShutdwonQuery=proEconShutdownEventService.list().stream()
- .filter(i->StringUtils.empty(i.getStartTime()))
- .sorted(Comparator.comparing(ProEconShutdownEvent::getStopTime)).collect(Collectors.toList());
- for (ProEconShutdownEvent shutdown : oldShutdwonQuery)
- {
- if (oldShutdownEvent.containsKey(shutdown.getWindturbineId()))
- {
- oldShutdownEvent.put(shutdown.getWindturbineId(),shutdown);
- }
- }
- List<ProEconInterruption> oldInterrupQuery=proEconInterruptionService.list().stream()
- .filter(i->StringUtils.empty(i.getStartTime()))
- .sorted(Comparator.comparing(ProEconInterruption::getStopTime)).collect(Collectors.toList());
- for (ProEconInterruption interrup : oldInterrupQuery)
- {
- if (oldInterrup.containsKey(interrup.getWindturbineId()))
- {
- oldInterrup.put(interrup.getWindturbineId(),interrup);
- }
- }
- // 新增 shutdownevent2 实时
- List<ProEconShutdownEvent2> oldShutdwonQuery2=proEconShutdownEvent2Service.list().stream()
- .filter(i->StringUtils.empty(i.getStartTime()))
- .sorted(Comparator.comparing(ProEconShutdownEvent2::getStopTime)).collect(Collectors.toList());
- for (ProEconShutdownEvent2 shutdown : oldShutdwonQuery2)
- {
- if (oldShutdownEvent2.containsKey(shutdown.getWindturbineId()))
- {
- oldShutdownEvent2.put(shutdown.getWindturbineId(),shutdown);
- }
- }
- for (String s : oldStatusMap.keySet())
- {
- ProEconWindturbineStatus item = oldStatusMap.get(s);
- if (item == null)
- {
- //logger.debug("{0}重复加入 风机编号{1}", date,s);
- ProEconShutdownEvent shutdwonEvent=new ProEconShutdownEvent();
- ProEconInterruption interrup=new ProEconInterruption();
- //新增 shutdownevent2 实时
- ProEconShutdownEvent2 shutdwonEvent2=new ProEconShutdownEvent2();
- item = buildWindturbineStatus(s, date, shutdwonEvent, interrup, shutdwonEvent2);
- proEconWindturbineStatusService.save(item);
- proEconShutdownEventService.save(shutdwonEvent);
- proEconInterruptionService.save(interrup);
- // 新增 shutdownevent2 实时
- //20分钟以内的报警数据
- Date dtbegin = DateUtils.addMinutes(shutdwonEvent2.getStopTime(),-15);
- Date dtend = shutdwonEvent2.getStopTime();
- Optional<ProEconShutdownEvent2> olditemo= proEconShutdownEvent2Service.list().stream()
- .filter(i -> i.getWindturbineId().equals(s)
- && (i.getStartTime().compareTo(dtbegin) == 0 || i.getStartTime().after(dtbegin))
- && (i.getStartTime().compareTo(dtend) == 0 || i.getStartTime().before(dtend))
- ).min(Comparator.comparing(ProEconShutdownEvent2::getStartTime));
- ProEconShutdownEvent2 lditem;
- if (!olditemo.isPresent())
- {
- proEconShutdownEvent2Service.save(shutdwonEvent2);
- }
- else
- {
- lditem=olditemo.get();
- lditem.setStartTime(null);
- if (!oldShutdownEvent2.containsKey(lditem.getWindturbineId()))
- oldShutdownEvent2.put(lditem.getWindturbineId(), lditem);
- }
- continue;
- }
- Calendar c=Calendar.getInstance();
- c.setTime(date);
- if (c.get(Calendar.HOUR_OF_DAY) == 0 &&c.get(Calendar.MINUTE) == 0)
- {
- logger.debug("{0}--整点操作--{1}", s, date);
- updateAndAddStatus( item);
- }
- else if (!Objects.equals(item.getSatusCode(), status.get(s)))
- {
- updateAndAddStatus(item);
- // #region 切入切出风速
- if (item.getSatusCode() == 0 && status.get(s) == 2)
- {
- ProEconInputOrOutputSpeed input = new ProEconInputOrOutputSpeed();
- input.setWindturbineId(s);
- input.setWindpowerstationId(windTurbines.get(s).getWindpowerstationId());
- input.setProjectId(windTurbines.get(s).getProjectId());
- input.setLineId(windTurbines.get(s).getLineId());
- input.setRecordDate(date);
- input.setInputOrOutput(1);
- if (speedpointMap.containsKey(s))
- {
- double value =edosUtil.getRealData(speedpointMap.get(s).getNemCode()).getPointValueInDouble();
- input.setSpeed(value);
- }
- proEconInputOrOutputSpeedService.save(input);
- }
- else if (item.getSatusCode() == 1 && status.get(s)== 0)
- {
- ProEconInputOrOutputSpeed input = new ProEconInputOrOutputSpeed();
- input.setWindturbineId(s);
- input.setWindpowerstationId(windTurbines.get(s).getWindpowerstationId());
- input.setProjectId(windTurbines.get(s).getProjectId());
- input.setLineId(windTurbines.get(s).getLineId());
- input.setRecordDate(date);
- input.setInputOrOutput(0);
- if (speedpointMap.containsKey(s))
- {
- double value =edosUtil.getRealData(speedpointMap.get(s).getNemCode()).getPointValueInDouble();
- input.setSpeed(value);
- }
- proEconInputOrOutputSpeedService.save(input);
- }
- }
- updateAndAddStatus2(item);
- }
- logger.debug("{0}-------结束", date);
- }
- /// <summary>
- /// 计算损失电量
- /// </summary>
- /// <param name="entities"></param>
- /// <param name="status"></param>
- private void updateAndAddStatus2(ProEconWindturbineStatus status) throws Exception {
- Integer oldStatus = status.getSatusCode();
- if (oldStatus == 4 || oldStatus == 6)
- {
- ProEconShutdownEvent ose = oldShutdownEvent.get(status.getWindturbineId());
- if (ose != null)
- {
- Double gc = calcLossPower(ose.getWindturbineId(), ose.getStopTime(), date);
- ose.setLossPower(gc);
- }
- // 新增 shutdownevent2 实时
- ProEconShutdownEvent2 ose2 = oldShutdownEvent2.get(status.getWindturbineId());
- if (ose2 != null)
- {
- Double gc = calcLossPower(ose2.getWindturbineId(), ose2.getStopTime(), date);
- ose2.setLossPower(gc);
- }
- }
- }
- private void updateAndAddStatus( ProEconWindturbineStatus status) throws Exception {
- status.setStartTime(date);
- List<PointData> speedDataList1;
- if (windTurbines.get(status.getWindturbineId()).getWindpowerstationId().contains("GDC"))
- {
- String point=gzdpointMap.get(windTurbines.get(status.getWindturbineId()).getWindpowerstationId()).getNemCode();
- speedDataList1 =edosUtil.getHistoryDatasSnap(point,status.getStopTime().getTime()/1000,status.getStartTime().getTime()/1000);
- }
- else
- {
- String point=speedpointMap.get(status.getWindturbineId()).getNemCode();
- speedDataList1 =edosUtil.getHistoryDatasSnap(point,status.getStopTime().getTime()/1000,status.getStartTime().getTime()/1000);
- }
- if (speedDataList1 != null && speedDataList1.size() > 0)
- {
- status.setSpeed(speedDataList1.get(0).getPointValueInDouble());
- DoubleSummaryStatistics summaryStatistics=speedDataList1.stream().mapToDouble(PointData::getPointValueInDouble).summaryStatistics();
- status.setAvgSpeed(summaryStatistics.getAverage());
- }
- else
- {
- status.setSpeed(0.0);
- status.setAvgSpeed(0.0);
- }
- double timehour=DateUtils.hoursDiff2(date,status.getStopTime());
- status.setStopHours(timehour);
- ProEconShutdownEvent shutdwonEvent = new ProEconShutdownEvent();
- ProEconInterruption interrup = new ProEconInterruption();
- // #region 新增 shutdownevent2 实时
- ProEconShutdownEvent2 shutdwonEvent2 = new ProEconShutdownEvent2();
- ProEconWindturbineStatus newStatusItem = buildWindturbineStatus(status.getWindturbineId(), date, shutdwonEvent, interrup, shutdwonEvent2);
- proEconWindturbineStatusService.save(newStatusItem);
- Integer oldStatus = status.getSatusCode();
- Integer currentStatus = this.status.get(status.getWindturbineId());
- if (currentStatus == 4 || currentStatus == 6)
- {
- if (oldStatus == 0 || oldStatus == 1 || oldStatus == 12)
- {
- proEconShutdownEventService.save(shutdwonEvent);
- }
- }
- if (currentStatus == 12 && oldStatus != 12)
- {
- proEconInterruptionService.save(interrup);
- }
- // 新增 shutdownevent2 实时
- if (currentStatus == 4 || currentStatus == 6)
- {
- if (oldStatus == 0 || oldStatus == 1 || oldStatus == 12)
- {
- Date dtbegin = DateUtils.addMinutes(shutdwonEvent2.getStopTime(),-30);
- Date dtend = shutdwonEvent2.getStopTime();
- String windTurbineId = shutdwonEvent2.getWindturbineId();
- Optional<ProEconShutdownEvent2> olditem= proEconShutdownEvent2Service.list().stream()
- .filter(i -> i.getWindturbineId().equals(windTurbineId)
- && (i.getStartTime().compareTo(dtbegin) == 0 || i.getStartTime().after(dtbegin))
- && (i.getStartTime().compareTo(dtend) == 0 || i.getStartTime().before(dtend))
- ).min(Comparator.comparing(ProEconShutdownEvent2::getStartTime));
- ProEconShutdownEvent2 temp;
- if (!olditem.isPresent())
- {
- proEconShutdownEvent2Service.save(shutdwonEvent2);
- }
- else
- {
- temp=olditem.get();
- temp.setStartTime(null);
- if (!oldShutdownEvent2.containsKey(temp.getWindturbineId()))
- oldShutdownEvent2.put(temp.getWindturbineId(), temp);
- }
- }
- }
- if (oldStatus == 4 || oldStatus == 6)
- {
- if (currentStatus == 0 || currentStatus == 1 || currentStatus == 12)
- {
- ProEconShutdownEvent ose = oldShutdownEvent.get(status.getWindturbineId());
- if (ose != null)
- {
- ose.setStartTime(date);
- timehour=DateUtils.hoursDiff2(date,ose.getStopTime());
- ose.setStopHours(timehour);
- if (!ose.getStoptypeId().equals("wh"))
- {
- String s =newMethod( status.getWindturbineId(), DateUtils.addMinutes(ose.getStopTime(),-5), date);
- if (StringUtils.notEmp(s))
- {
- ose.setStoptypeId(s);
- }
- }
- //Double gc = calcLossPower(ose.WINDTURBINEID, ose.STOPTIME.Value, ose.STARTTIME.Value, ose.STOPHOURS.Value, entities);
- //ose.LOSSPOWER = gc;
- }
- // 新增 shutdownevent2 实时
- ProEconShutdownEvent2 ose2 = oldShutdownEvent2.get(status.getWindturbineId());
- if (ose2 != null )
- {
- ose2.setStartTime(date);
- timehour=DateUtils.hoursDiff2(date,ose2.getStopTime());
- ose2.setStopHours(timehour);
- if (ose!=null && !ose.getStoptypeId().equals("wh"))
- {
- ose2.setStopTypeId(ose.getStoptypeId());
- }
- }
- }
- }
- if (oldStatus == 12 && currentStatus != 12)
- {
- ProEconInterruption item = oldInterrup.get(status.getWindturbineId());
- if (item != null)
- {
- item.setStartTime(date);
- timehour=DateUtils.hoursDiff2(date,item.getStopTime());
- item.setStopHours(timehour);
- }
- }
- }
- private Double calcLossPower(String windturbineId, Date startDate, Date endDate) throws Exception {
- double result = 0.0;
- Map<String, Map<String, ProBasicEquipmentPoint>> wtpAimap = CacheContext.wtpAimap;
- Map<String, ProBasicEquipmentPoint> wtpointmap=wtpAimap.get(windturbineId);
- Calendar c1=Calendar.getInstance();
- c1.setTime(startDate);
- Calendar c2=Calendar.getInstance();
- c2.setTime(endDate);
- //判定限电是否跨年
- if(endDate.after(startDate) && c1.get(Calendar.YEAR)==c2.get(Calendar.YEAR))
- {
- //年故障损失电量
- if(wtpointmap.containsKey(ContantXk.NGZSSDL) )
- {
- double beginvalue;
- double endvalue;
- List<String> pointid=new ArrayList<>();
- pointid.add(wtpointmap.get(ContantXk.NGZSSDL).getNemCode());
- List<PointData> xdbegin=edosUtil.getHistMatrix(pointid,startDate.getTime()/1000);
- List<PointData> xdend=edosUtil.getHistMatrix(pointid,endDate.getTime()/1000);
- if(xdbegin.size()==1 && xdend.size()==1)
- {
- beginvalue=xdbegin.get(0).getPointValueInDouble();
- endvalue=xdend.get(0).getPointValueInDouble();
- if (endvalue > beginvalue) {
- result =result+(endvalue - beginvalue);
- }
- }
- }
- }else
- {
- Calendar c=Calendar.getInstance();
- c.setTime(DateUtils.truncDay(startDate));
- c.add(Calendar.DAY_OF_MONTH,1);
- //获得1月1日零点值
- Date endtime=c.getTime();
- //年故障损失电量
- if(wtpointmap.containsKey(ContantXk.NGZSSDL) )
- {
- double beginvalue;
- double endvalue;
- List<String> pointid=new ArrayList<>();
- pointid.add(wtpointmap.get(ContantXk.NGZSSDL).getNemCode());
- List<PointData> xdbegin=edosUtil.getHistMatrix(pointid,startDate.getTime()/1000);
- List<PointData> xdend=edosUtil.getHistMatrix(pointid,endtime.getTime()/1000);
- if(xdbegin.size()==1 && xdend.size()==1)
- {
- beginvalue=xdbegin.get(0).getPointValueInDouble();
- endvalue=xdend.get(0).getPointValueInDouble();
- if (endvalue > beginvalue) {
- result =result+(endvalue - beginvalue);
- }
- }
- }
- //日故障损失电量
- if(wtpointmap.containsKey(ContantXk.NGZSSDL) )
- {
- double endvalue;
- List<String> pointid=new ArrayList<>();
- pointid.add(wtpointmap.get(ContantXk.NGZSSDL).getNemCode());
- List<PointData> xdend=edosUtil.getHistMatrix(pointid,startDate.getTime()/1000);
- if(xdend.size()==1)
- {
- endvalue=xdend.get(0).getPointValueInDouble();
- if (endvalue > 0) {
- result =result+endvalue;
- }
- }
- }
- }
- return result;
- }
- // 新增 shutdownevent2 实时
- private ProEconWindturbineStatus buildWindturbineStatus(String windturbineId, Date date, ProEconShutdownEvent shutdwonEvent,
- ProEconInterruption interrup, ProEconShutdownEvent2 shutdwonEvent2)
- {
- ProEconWindturbineStatus retValue = new ProEconWindturbineStatus();
- retValue.setProjectId(windTurbines.get(windturbineId).getProjectId());
- retValue.setSatusCode(status.get(windturbineId));
- retValue.setStatusDesc(statusDescription.get(status.get(windturbineId)));
- retValue.setStopTime(date);
- retValue.setWindpowerstationId(windTurbines.get(windturbineId).getWindpowerstationId());
- retValue.setWindturbineId(windturbineId);
- Integer currentStatus = status.get(windturbineId);
- if (currentStatus == 4 || currentStatus == 6)
- {
- shutdwonEvent.setId(StringUtils.getUUID());
- shutdwonEvent.setProjectId(retValue.getProjectId());
- shutdwonEvent.setStatusCode(currentStatus);
- shutdwonEvent.setStopTime(date);
- shutdwonEvent.setWindpowerstationId(retValue.getWindpowerstationId());
- shutdwonEvent.setWindturbineId(windturbineId);
- shutdwonEvent2.setId(StringUtils.getUUID());
- shutdwonEvent2.setProjectId(retValue.getProjectId());
- shutdwonEvent2.setStatusCode(currentStatus);
- shutdwonEvent2.setStopTime(date);
- shutdwonEvent2.setWinpowerstationId(retValue.getWindpowerstationId());
- shutdwonEvent2.setWindturbineId(windturbineId);
- if (currentStatus == 4)
- {
- Date begin =DateUtils.addMinutes(date,-5);
- Date end = DateUtils.addMinutes(date,5);
- shutdwonEvent.setStoptypeId("gzbmq");
- shutdwonEvent2.setStopTypeId("gzbmq");
- //读取报警记录表前后五分钟数据,选取第一个报警报警类型
- String s =newMethod( windturbineId, begin, end);
- if (StringUtils.notEmp(s))
- {
- shutdwonEvent.setStoptypeId(s);
- shutdwonEvent2.setStopTypeId(s);
- }
- }
- else
- {
- shutdwonEvent.setStoptypeId("wh");
- shutdwonEvent2.setStopTypeId("wh");
- }
- retValue.setShutdownEventId(shutdwonEvent.getId());
- }
- if (currentStatus == 12)
- {
- interrup.setProjectId(retValue.getProjectId());
- interrup.setStopTime(date);
- interrup.setWindpowerstationId(retValue.getWindpowerstationId());
- interrup.setWindturbineId(windturbineId);
- }
- return retValue;
- }
- //TODO-SL 需要添加报警记录关联停机事件方法
- /**
- *
- */
- private String newMethod( String windturbineId, Date begin, Date end)
- {
- String result = "";
- return result;
- }
- }
|