|
@@ -1,435 +1,152 @@
|
|
|
-//package com.gyee.generation.service;
|
|
|
-//
|
|
|
-//import com.gyee.generation.init.CacheContext;
|
|
|
-//import com.gyee.generation.model.auto.ProBasicWindpowerstation;
|
|
|
-//import com.gyee.generation.model.auto.ProBasicWindturbine;
|
|
|
-//import com.gyee.generation.model.auto.ProEconEquipmentInfoDay1;
|
|
|
-//import com.gyee.generation.model.auto.ProEconEquipmentInfoDay2;
|
|
|
-//import com.gyee.generation.model.vo.EquipmentInfo15Vo;
|
|
|
-//import com.gyee.generation.service.auto.IProEconEquipmentInfoDay1Service;
|
|
|
-//import com.gyee.generation.service.auto.IProEconEquipmentInfoDay2Service;
|
|
|
-//import com.gyee.generation.service.auto.IProEconEquipmentInfoDay3Service;
|
|
|
-//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.math.BigDecimal;
|
|
|
-//import java.math.RoundingMode;
|
|
|
-//import java.util.*;
|
|
|
-//import java.util.stream.Collectors;
|
|
|
-//
|
|
|
-//@Service
|
|
|
-//public class ActivePowerService {
|
|
|
-//
|
|
|
-//
|
|
|
-// private static final Logger logger = LoggerFactory.getLogger(ActivePowerService.class);
|
|
|
-// @Resource
|
|
|
-// private IEdosUtil edosUtil;
|
|
|
-//
|
|
|
-// @Resource
|
|
|
-// private IProEconEquipmentInfoDay1Service proEconEquipmentInfoDay1Service;
|
|
|
-// private IProEconEquipmentInfoDay2Service proEconEquipmentInfoDay2Service;
|
|
|
-// private IProEconEquipmentInfoDay3Service proEconEquipmentInfoDay3Service;
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// public List<EquipmentInfo15Vo> initailEi1515(List<ProBasicWindturbine> wtls,Date currentDate,ProBasicWindpowerstation station)
|
|
|
-// {
|
|
|
-//
|
|
|
-// List<EquipmentInfo15Vo> ei15ls=new ArrayList<>();
|
|
|
-// if(!wtls.isEmpty())
|
|
|
-// {
|
|
|
-// Map<String,ProEconEquipmentInfoDay1> peeidmap1=new HashMap<>();
|
|
|
-// Map<String,ProEconEquipmentInfoDay2> peeidmap2=new HashMap<>();
|
|
|
-// List<ProEconEquipmentInfoDay1> peeidls1 = proEconEquipmentInfoDay1Service.list().stream()
|
|
|
-// .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(currentDate)) == 0
|
|
|
-// && i.getWindpowerstationId().equals(station.getId())
|
|
|
-// ).collect(Collectors.toList());
|
|
|
-//
|
|
|
-// if(!peeidls1.isEmpty())
|
|
|
-// {
|
|
|
-// for(ProEconEquipmentInfoDay1 peeid:peeidls1)
|
|
|
-// {
|
|
|
-// peeidmap1.put(peeid.getWindturbineId(),peeid);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// List<ProEconEquipmentInfoDay2> peeidls2 = proEconEquipmentInfoDay2Service.list().stream()
|
|
|
-// .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(currentDate)) == 0
|
|
|
-// && i.getWindpowerstationId().equals(station.getId())
|
|
|
-// ).collect(Collectors.toList());
|
|
|
-//
|
|
|
-// if(!peeidls2.isEmpty())
|
|
|
-// {
|
|
|
-// for(ProEconEquipmentInfoDay2 peeid:peeidls2)
|
|
|
-// {
|
|
|
-// peeidmap2.put(peeid.getWindturbineId(),peeid);
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// for(ProBasicWindturbine wt:wtls)
|
|
|
-// {
|
|
|
-// EquipmentInfo15Vo vo=new EquipmentInfo15Vo();
|
|
|
-// vo.setWindpowerstationId(wt.getWindpowerstationId());
|
|
|
-// vo.setWindturbineId(wt.getId());
|
|
|
-// vo.setProjectId(wt.getProjectId());
|
|
|
-// vo.setLineId(wt.getLineId());
|
|
|
-// vo.setCompanyId(wt.getCompanyId());
|
|
|
-// vo.setRegionId(wt.getRegionId());
|
|
|
-//
|
|
|
-// if(peeidmap1.containsKey(wt.getId()))
|
|
|
-// {
|
|
|
-// ProEconEquipmentInfoDay1 peeid1= peeidmap1.get(wt.getId());
|
|
|
-// vo.setRecordDate(peeid1.getRecordDate());
|
|
|
-// vo.setRpjfs(peeid1.getRpjfs());
|
|
|
-// vo.setRpjgl(peeid1.getRpjgl());
|
|
|
-// }
|
|
|
-//
|
|
|
-// if(peeidmap2.containsKey(wt.getId()))
|
|
|
-// {
|
|
|
-// ProEconEquipmentInfoDay2 peeid1= peeidmap2.get(wt.getId());
|
|
|
-// vo.setRecordDate(peeid1.getRecordDate());
|
|
|
-//
|
|
|
-// //日合计故障小时(明细)
|
|
|
-// vo.setRgzxsmx(vo.getRgzxsmx());
|
|
|
-// //日合计场内受累故障小时(明细)
|
|
|
-// vo.setRcnslgzxsmx(vo.getRcnslgzxsmx());
|
|
|
-// //日合计检修小时(明细)
|
|
|
-// vo.setRjxxsmx(vo.getRjxxsmx());
|
|
|
-// //日合计场内受累检修小时(明细)
|
|
|
-// vo.setRcnsljxxsmx(vo.getRcnsljxxsmx());
|
|
|
-// //日合计待机小时(明细)
|
|
|
-// vo.setRdjxsmx(vo.getRdjxsmx());
|
|
|
-// //日合计缺陷降出力小时(明细)
|
|
|
-// vo.setRqxjclxsmx(vo.getRqxjclxsmx());
|
|
|
-// //日合计手动停机小时(明细)
|
|
|
-// vo.setRsdtjxsmx(vo.getRsdtjxsmx());
|
|
|
-// //日合计性能小时(明细)
|
|
|
-// vo.setRbwxsmx(vo.getRbwxsmx());
|
|
|
-// //日合计限电停机小时(明细)
|
|
|
-// vo.setRxdtjxsmx(vo.getRxdtjxsmx());
|
|
|
-// //日合计限电降出力小时(明细)
|
|
|
-// vo.setRxdjclxsmx( vo.getRxdjclxsmx());
|
|
|
-// //日合计场外受累电网小时(明细)
|
|
|
-// vo.setRcwsldwxsmx(vo.getRcwsldwxsmx());
|
|
|
-// //日合计场外受累电网小时(明细)
|
|
|
-// vo.setRcwsltqxsmx(vo.getRcwsltqxsmx());
|
|
|
-// //日合计通讯中断小时(明细)
|
|
|
-// vo.setRtxzdxsmx(vo.getRtxzdxsmx());
|
|
|
-// //日合计离线小时(明细)
|
|
|
-// vo.setRlxxsmx(vo.getRlxxsmx());
|
|
|
-//
|
|
|
-// }
|
|
|
-// ei15ls.add(vo);
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// return ei15ls;
|
|
|
-// }
|
|
|
-//
|
|
|
-// public void calcActivePowerData(Date currentDate)
|
|
|
-// {
|
|
|
-// Calendar c=Calendar.getInstance();
|
|
|
-// c.setTime(currentDate);
|
|
|
-// Date beginDate = DateUtils.truncate(currentDate);
|
|
|
-//
|
|
|
-// c.set(Calendar.HOUR_OF_DAY, 23);
|
|
|
-// c.set(Calendar.MINUTE, 59);
|
|
|
-// c.set(Calendar.SECOND, 59);
|
|
|
-// Date endDate = c.getTime();
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// Map<String, Double> windInfo = new HashMap<String, Double>();
|
|
|
-// for (ProBasicWindpowerstation station : CacheContext.wpls)
|
|
|
-// {
|
|
|
-// List<ProBasicWindturbine> wtls= CacheContext.wpwtmap.get(station.getId());
|
|
|
-// List<EquipmentInfo15Vo> ei15ls= initailEi1515(wtls,currentDate,station);
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// Map<String/*风机编号*/, Map<Double/*风速*/, List<Double>>> map =
|
|
|
-// new HashMap<String, Map<Double, List<Double>>>();
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// Map<Double/*风速*/, List<Double>> speedMap;
|
|
|
-// for (EquipmentInfo15Vo item : ei15ls)
|
|
|
-// {
|
|
|
-//
|
|
|
-// if (map.containsKey(item.getWindturbineId()))
|
|
|
-// {
|
|
|
-// speedMap = map.get(item.getWindturbineId());
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-// speedMap = new HashMap<Double, List<Double>>();
|
|
|
-// map.put(item.getWindturbineId(), speedMap);
|
|
|
-// }
|
|
|
-// Double speed = StringUtils.round(item.getRpjfs(),2);
|
|
|
-// if (speed > item.getRpjfs())
|
|
|
-// {
|
|
|
-//
|
|
|
-// if (speed - item.getRpjfs() > 0.25)
|
|
|
-// {
|
|
|
-// speed -= 0.5;
|
|
|
-// }
|
|
|
-// else if (speed - item.getRpjfs() > 0.175)
|
|
|
-// {
|
|
|
-// speed -= 0.25;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// else if (speed < item.getRpjfs())
|
|
|
-// {
|
|
|
-// if (item.getRpjfs() - speed > 0.25)
|
|
|
-// {
|
|
|
-// speed += 0.5;
|
|
|
-// }
|
|
|
-// else if (item.getRpjfs() - speed > 0.175)
|
|
|
-// {
|
|
|
-// speed += 0.25;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// if ((item.getRpjgl() > 0 && item.getRpjfs() >= 3) || (item.getRpjfs() <= 3))
|
|
|
-// {
|
|
|
-// List<Double> powers;
|
|
|
-// if (speedMap.containsKey(speed))
|
|
|
-// {
|
|
|
-// powers = speedMap.get(speed);
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-// powers = new ArrayList<Double>();
|
|
|
-// speedMap.put(speed, powers);
|
|
|
-// }
|
|
|
-// powers.add(item.getRpjgl());
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
-// for (String windturbineId : map.keySet())
|
|
|
-// {
|
|
|
-// List<ACTIVEPOWERDATA> dataList = new ArrayList<ACTIVEPOWERDATA>();
|
|
|
-// int frequency = 0;
|
|
|
-// Map<Double/*风速*/, List<Double>> intnalMap = map[windturbineId];
|
|
|
-// for (Double speed : intnalMap.keySet())
|
|
|
-// {
|
|
|
-// List<Double> powers = intnalMap[speed];
|
|
|
-//
|
|
|
-// var data = (from c : entities.ACTIVEPOWERDATA
|
|
|
-// where (c.WINDTURBINEID == windturbineId && c.RECORDDATE.Value.CompareTo(beginDate) == 0 && c.SPEED == speed)
|
|
|
-// select c).FirstOrDefault();
|
|
|
-//
|
|
|
-// if (data == null)
|
|
|
-// {
|
|
|
-// data = new Entities.ACTIVEPOWERDATA();
|
|
|
-// BuildActivePowerData(beginDate, entities, station, windturbineId, speed, powers, data);
|
|
|
-// entities.AddToACTIVEPOWERDATA(data);
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-// BuildActivePowerData(beginDate, entities, station, windturbineId, speed, powers, data);
|
|
|
-// }
|
|
|
-// frequency += powers.Count;
|
|
|
-// dataList.Add(data);
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// //if (dataList.Count > 0)
|
|
|
-// //{
|
|
|
-//
|
|
|
-// // Date recordDate = dataList[0].RECORDDATE.Value;
|
|
|
-// // var dayInfo = (from c : entities.WINDTURBINEINFODAY
|
|
|
-// // where (c.WINDTURBINEID == windturbineId && c.RECORDDATE.Value.CompareTo(recordDate) == 0)
|
|
|
-// // select c).FirstOrDefault();
|
|
|
-// // if (dayInfo != null)
|
|
|
-// // {
|
|
|
-// // Double result = UpdateTheoryGeneration(dataList, frequency, beginDate,windturbineId);
|
|
|
-// // dayInfo.THEORYGENERATION = result;
|
|
|
-//
|
|
|
-//
|
|
|
-// // #region 新添风场日信息表代码
|
|
|
-// // if (windInfo.containsKey(dayInfo.LINEID))
|
|
|
-// // {
|
|
|
-// // windInfo[dayInfo.LINEID] += result;
|
|
|
-// // }
|
|
|
-// // else
|
|
|
-// // {
|
|
|
-// // windInfo.Add(dayInfo.LINEID, result);
|
|
|
-// // }
|
|
|
-//
|
|
|
-// // if (windInfo.containsKey(dayInfo.PROJECTID))
|
|
|
-// // {
|
|
|
-// // windInfo[dayInfo.PROJECTID] += result;
|
|
|
-// // }
|
|
|
-// // else
|
|
|
-// // {
|
|
|
-// // windInfo.Add(dayInfo.PROJECTID, result);
|
|
|
-// // }
|
|
|
-//
|
|
|
-// // if (windInfo.containsKey(dayInfo.WINDPOWERSTATIONID))
|
|
|
-// // {
|
|
|
-// // windInfo[dayInfo.WINDPOWERSTATIONID] += result;
|
|
|
-// // }
|
|
|
-// // else
|
|
|
-// // {
|
|
|
-// // windInfo.Add(dayInfo.WINDPOWERSTATIONID, result);
|
|
|
-// // }
|
|
|
-// // #endregion
|
|
|
-// // }
|
|
|
-// //}
|
|
|
-// }
|
|
|
-//
|
|
|
-// //for (var key : windInfo.keySet())
|
|
|
-// //{
|
|
|
-// // var dayInfo = (from c : entities.WINDPOWERINFODAY
|
|
|
-// // where (c.FOREIGNKEYID == key && c.RECORDDATE.Value.CompareTo(beginDate) == 0)
|
|
|
-// // select c).FirstOrDefault();
|
|
|
-//
|
|
|
-// // if (dayInfo != null)
|
|
|
-// // {
|
|
|
-// // dayInfo.THEORYGENERATION = windInfo[key]/10000;
|
|
|
-// // }
|
|
|
-// //}
|
|
|
-// #endregion
|
|
|
-//
|
|
|
-// int z = entities.SaveChanges(false);
|
|
|
-// logger.Info(String.Format("{1}:更新sqlserver数据库记录数:{0}", z, Date.Now));
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// private void BuildActivePowerData(Date beginDate, GdsjEntities entities, String station, String windturbineId, Double speed, List<Double> powers, Entities.ACTIVEPOWERDATA data)
|
|
|
-// {
|
|
|
-// data.WINDPOWERSTATIONID = station;
|
|
|
-// data.WINDTURBINEID = windturbineId;
|
|
|
-// data.POWER = powers.Average();
|
|
|
-// data.SPEED = speed;
|
|
|
-// data.FREQUENCY = powers.Count;
|
|
|
-// data.RECORDDATE = beginDate;
|
|
|
-// data.WINDTURBINECODE = this.windTurbineDictionary[windturbineId].CODE;
|
|
|
-// data.MODELID = windTurbineDictionary[windturbineId].MODELID;
|
|
|
-// data.MODELNAME = this.windTurbineModelDictionary[data.MODELID].CODE;
|
|
|
-//
|
|
|
-// }
|
|
|
-//
|
|
|
-// private Double UpdateTheoryGeneration(List<Entities.ACTIVEPOWERDATA> dataList, int frequency, Date currentDate, String windturbineId)
|
|
|
-// {
|
|
|
-// //电量分析主要针对省公司和各风场的每月实际发电量与计划的对比分析,可以查看省公司及各风场每月计划的完成情况和总体的计划完成情况,可以同比和环比进行比较;
|
|
|
-// //对省公司和各风场的实际发电量与理论发电量的对比分析,利用标准功率曲线中的风速,理论功率,和固定时间段的风频进行统计,设计统计分析公式为:
|
|
|
-// //理论发电量=(T*f1/f)*P1+(T*f2/f)*P2+…………(T*fn/f)*Pn
|
|
|
-// //T是选取的时间段;
|
|
|
-// //f是所有风频的和;
|
|
|
-// //f1、f2、fn是某风速对应的风频;
|
|
|
-// //P1、Pn是某风速对应理论曲线上的功率。
|
|
|
-// //必要性:如果理论电量能够实现计算的准确,调峰电量就可以用理论电量来减去实际电量得出。
|
|
|
-// //b、可选一段时间内的实际功率和理论功率能够形成曲线形式展示对比,理论功率根据实际风速利用理论功率曲线得出。
|
|
|
-// //c、风频数据取值时间段需要统一。
|
|
|
-//
|
|
|
-//
|
|
|
-// #region WINDTURBINECURVEFITTINGMONTH 替换成WINDTURBINEPOWERCURVEFITTING
|
|
|
-// //List<WINDTURBINECURVEFITTINGMONTH> powerList = null;
|
|
|
-// List<WINDTURBINEPOWERCURVEFITTING> powerList = null;
|
|
|
-// #endregion
|
|
|
-// using (GdsjEntities entity = new GdsjEntities())
|
|
|
-// {
|
|
|
-// //powerList = entity.WINDTURBINECURVEFITTING.Where(it => it.WINDTURBINEID == windturbineId && it.RECORDDATE.Value.CompareTo(currentDate) == 0).ToList();
|
|
|
-//
|
|
|
-// String year=currentDate.Year.ToString();
|
|
|
-// String month=currentDate.Month.ToString();
|
|
|
-//
|
|
|
-//
|
|
|
-// #region WINDTURBINECURVEFITTINGMONTH 替换成WINDTURBINEPOWERCURVEFITTING
|
|
|
-// //powerList = entity.WINDTURBINECURVEFITTINGMONTH.Where(it => it.WINDTURBINEID == windturbineId && it.YEAR == year && it.MONTH == month).ToList();
|
|
|
-// powerList = entity.WINDTURBINEPOWERCURVEFITTING.Where(it => it.WINDTURBINEID == windturbineId).ToList();
|
|
|
-// #endregion
|
|
|
-//
|
|
|
-// }
|
|
|
-//
|
|
|
-// Double t = 24;
|
|
|
-//
|
|
|
-// Double result = 0;
|
|
|
-//
|
|
|
-//
|
|
|
-// for (var data : dataList)
|
|
|
-// {
|
|
|
-// Double speed = data.SPEED.Value;
|
|
|
-// #region WINDTURBINECURVEFITTINGMONTH 替换成 WINDTURBINEPOWERCURVEFITTING
|
|
|
-// //if (type == "GDC")
|
|
|
-// //{
|
|
|
-// // speed /= 100;
|
|
|
-// // speed = Math.Round(speed, 1);
|
|
|
-// // speed *= 100;
|
|
|
-//
|
|
|
-// // speed = Double.Truncate(speed);
|
|
|
-// //}
|
|
|
-// //else
|
|
|
-// //{
|
|
|
-// // speed = Math.Round(speed, 1);
|
|
|
-// //}
|
|
|
-// if (type == "GDC")
|
|
|
-// {
|
|
|
-// speed /= 100;
|
|
|
-// speed = Math.Round(speed, 2);
|
|
|
-// speed *= 100;
|
|
|
-//
|
|
|
-// speed = Double.Truncate(speed);
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-// speed = Math.Round(speed, 2);
|
|
|
-// }
|
|
|
-// #endregion
|
|
|
-//
|
|
|
-// if (modelPowerDictionary.containsKey(data.MODELID))
|
|
|
-// {
|
|
|
-// if (modelPowerDictionary[data.MODELID].Count > 0)
|
|
|
-// {
|
|
|
-// if (modelPowerDictionary[data.MODELID].containsKey(speed))
|
|
|
-// {
|
|
|
-// Double p = modelPowerDictionary[data.MODELID][speed].ENSUREPOWER.Value;
|
|
|
-//
|
|
|
-// result += (t * data.FREQUENCY.Value / frequency) * p;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-// if (powerList != null && powerList.Count>0)
|
|
|
-// {
|
|
|
-// Double? p = powerList.Where(it => it.SPEED == speed).Select(it => it.OPTIMALPOWER).FirstOrDefault();
|
|
|
-//
|
|
|
-// if (p != null)
|
|
|
-// {
|
|
|
-// result += (t * data.FREQUENCY.Value / frequency) * p.Value;
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-// Double max = powerList.Max(it => it.SPEED).Value;
|
|
|
-// if (speed > max)
|
|
|
-// {
|
|
|
-// p = powerList.Max(it => it.ACTUALPOWER).Value;
|
|
|
-// if (p != null)
|
|
|
-// {
|
|
|
-//
|
|
|
-// result += (t * data.FREQUENCY.Value / frequency) * p.Value;
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
-// return result;
|
|
|
-//
|
|
|
-// }
|
|
|
-//}
|
|
|
-//
|
|
|
-// }
|
|
|
+package com.gyee.generation.service;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+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 ActivePowerService {
|
|
|
+
|
|
|
+
|
|
|
+ private static final Logger logger = LoggerFactory.getLogger(ActivePowerService.class);
|
|
|
+ @Resource
|
|
|
+ private IEdosUtil edosUtil;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IProEconEquipmentInfo15minuteService proEconEquipmentInfo15minuteService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IProEconActivePowerDataService proEconActivePowerDataService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IProEconWtPowerCurveFittingService proEconWtPowerCurveFittingService;
|
|
|
+
|
|
|
+
|
|
|
+ public void calcActivePowerData(Date currentDate) {
|
|
|
+ Calendar c = Calendar.getInstance();
|
|
|
+ c.setTime(currentDate);
|
|
|
+ Date beginDate = DateUtils.truncate(currentDate);
|
|
|
+ c.add(Calendar.DAY_OF_MONTH,1);
|
|
|
+ Date endDate=c.getTime();
|
|
|
+ for (ProBasicWindpowerstation station : CacheContext.wpls) {
|
|
|
+
|
|
|
+ List<ProEconEquipmentInfo15minute> ei15ls = proEconEquipmentInfo15minuteService.list().stream()
|
|
|
+ .filter(i -> i.getWindpowerstationId().equals(station)
|
|
|
+ && ( i.getRecordDate().compareTo(beginDate)==0 || i.getRecordDate().after(beginDate))
|
|
|
+ && (i.getRecordDate().compareTo(endDate)==0 || i.getRecordDate().before(endDate))
|
|
|
+ ).collect(Collectors.toList());
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ Map<String/*风机编号*/, Map<Double/*风速*/, List<Double>>> map =
|
|
|
+ new HashMap<String, Map<Double, List<Double>>>();
|
|
|
+
|
|
|
+
|
|
|
+ Map<Double/*风速*/, List<Double>> speedMap;
|
|
|
+ for (ProEconEquipmentInfo15minute item : ei15ls) {
|
|
|
+
|
|
|
+ if (map.containsKey(item.getWindturbineId())) {
|
|
|
+ speedMap = map.get(item.getWindturbineId());
|
|
|
+ } else {
|
|
|
+ speedMap = new HashMap<Double, List<Double>>();
|
|
|
+ map.put(item.getWindturbineId(), speedMap);
|
|
|
+ }
|
|
|
+ Double speed = StringUtils.round(item.getFpjfs(), 2);
|
|
|
+ if (speed > item.getFpjfs()) {
|
|
|
+
|
|
|
+ if (speed - item.getFpjfs() > 0.25) {
|
|
|
+ speed -= 0.5;
|
|
|
+ } else if (speed - item.getFpjfs() > 0.175) {
|
|
|
+ speed -= 0.25;
|
|
|
+ }
|
|
|
+ } else if (speed < item.getFpjfs()) {
|
|
|
+ if (item.getFpjfs() - speed > 0.25) {
|
|
|
+ speed += 0.5;
|
|
|
+ } else if (item.getFpjfs() - speed > 0.175) {
|
|
|
+ speed += 0.25;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ((item.getFpjgl() > 0 && item.getFpjfs() >= 3) || (item.getFpjfs() <= 3)) {
|
|
|
+ List<Double> powers;
|
|
|
+ if (speedMap.containsKey(speed)) {
|
|
|
+ powers = speedMap.get(speed);
|
|
|
+ } else {
|
|
|
+ powers = new ArrayList<>();
|
|
|
+ speedMap.put(speed, powers);
|
|
|
+ }
|
|
|
+ powers.add(item.getFpjgl());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ for (String windturbineId : map.keySet()) {
|
|
|
+ List<ProEconActivePowerData> dataList = new ArrayList<ProEconActivePowerData>();
|
|
|
+ Map<Double/*风速*/, List<Double>> intnalMap = map.get(windturbineId);
|
|
|
+ for (Double speed : intnalMap.keySet()) {
|
|
|
+ List<Double> powers = intnalMap.get(speed);
|
|
|
+
|
|
|
+ Optional<ProEconActivePowerData> data = proEconActivePowerDataService.list().stream()
|
|
|
+ .filter(i -> i.getWindturbineId().equals(windturbineId)
|
|
|
+ && i.getRecordDate().compareTo(beginDate) == 0
|
|
|
+ && i.getSpeed() == speed
|
|
|
+ ).findFirst();
|
|
|
+
|
|
|
+ ProEconActivePowerData apdata = new ProEconActivePowerData();
|
|
|
+ if (!data.isPresent()) {
|
|
|
+
|
|
|
+ QueryWrapper<ProEconActivePowerData> wrapper = new QueryWrapper<>();
|
|
|
+ wrapper.eq("id", data.get().getId());
|
|
|
+ proEconActivePowerDataService.remove(wrapper);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ apdata = new ProEconActivePowerData();
|
|
|
+ buildActivePowerData(beginDate, station.getId(), windturbineId, speed, powers, apdata);
|
|
|
+ proEconActivePowerDataService.save(apdata);
|
|
|
+
|
|
|
+ dataList.add(apdata);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void buildActivePowerData(Date beginDate, String station, String windturbineId, Double speed, List<Double> powers, ProEconActivePowerData data) {
|
|
|
+ data.setWindturbineId(windturbineId);
|
|
|
+ data.setWindpowerstationId(station);
|
|
|
+ DoubleSummaryStatistics summaryStatistics = powers.stream().mapToDouble(n -> n).summaryStatistics();
|
|
|
+ data.setPower(summaryStatistics.getAverage());
|
|
|
+ data.setSpeed(speed);
|
|
|
+ data.setFrequency(powers.size());
|
|
|
+ data.setRecordDate(beginDate);
|
|
|
+
|
|
|
+ if (CacheContext.wtmap.containsKey(windturbineId)) {
|
|
|
+ ProBasicWindturbine wt = CacheContext.wtmap.get(windturbineId);
|
|
|
+ data.setModelId(wt.getModelId());
|
|
|
+ data.setWindturbineCode(wt.getNemCode());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.notEmp(data.getModelId()) && CacheContext.modelMap.containsKey(data.getModelId())) {
|
|
|
+ ProEconEquipmentmodel em = CacheContext.modelMap.get(data.getModelId());
|
|
|
+ data.setModelName(em.getName());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|