|
|
@@ -1,1005 +1,1144 @@
|
|
|
-//package com.gyee.generation.service;
|
|
|
-//
|
|
|
-//import com.gyee.common.contant.Contant;
|
|
|
-//import com.gyee.generation.init.CacheContext;
|
|
|
-//import com.gyee.generation.model.auto.*;
|
|
|
-//import com.gyee.generation.model.vo.CureFitting;
|
|
|
-//import com.gyee.generation.model.vo.PointVo;
|
|
|
-//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.springframework.beans.factory.annotation.Value;
|
|
|
-//
|
|
|
-//import javax.annotation.Resource;
|
|
|
-//import java.io.Console;
|
|
|
-//import java.util.*;
|
|
|
-//import java.util.stream.Collectors;
|
|
|
-//
|
|
|
-//public class PowerCurveFittingService {
|
|
|
-//
|
|
|
-// @Resource
|
|
|
-// private IEdosUtil edosUtil;
|
|
|
-//
|
|
|
-// @Value("${curvefitting.dimension}")
|
|
|
-// private Integer dimension;
|
|
|
-// @Value("${curvefitting.scale}")
|
|
|
-// private Double scale;
|
|
|
-//
|
|
|
-// public Map<String, Double> windturbineCapacity;
|
|
|
-//
|
|
|
-// @Resource
|
|
|
-// private IProEconWtCurveFittingMonthService proEconWtCurveFittingMonthService;
|
|
|
-// @Resource
|
|
|
-// private IProEconWtCurveFittingService proEconWtCurveFittingService;
|
|
|
-//
|
|
|
-// @Resource
|
|
|
-// private IProEconCurveFittingMainService proEconCurveFittingMainService;
|
|
|
-// @Resource
|
|
|
-// private IProEconCurveFittingSubService proEconCurveFittingSubService;
|
|
|
-// @Resource
|
|
|
-// private IProEconCurveFittMonthMainService proEconCurveFittMonthMainService;
|
|
|
-// @Resource
|
|
|
-// private IProEconCurveFittMonthSubService proEconCurveFittMonthSubService;
|
|
|
-//
|
|
|
-// public void CureFitting(Date nowDate, Date begion, int insertType, String fdcId, List<String> fdjIds)
|
|
|
-// {
|
|
|
-//
|
|
|
-// //日期变为昨天
|
|
|
-// Date current = DateUtils.addDays(DateUtils.truncDay(nowDate),-1);
|
|
|
-//
|
|
|
-// Calendar c=Calendar.getInstance();
|
|
|
-// c.setTime(current);
|
|
|
-// int year = c.get(Calendar.YEAR);
|
|
|
-// int month = c.get(Calendar.MONTH)+1;
|
|
|
-// c.set(Calendar.DAY_OF_MONTH,1);
|
|
|
-// Date begin1 = c.getTime();
|
|
|
-//
|
|
|
-// Date begin2 = DateUtils.addDays(current,-6);;
|
|
|
-//
|
|
|
-// Date end = DateUtils.truncDay(nowDate);
|
|
|
-// if (begion.getTime() != new Date(0).getTime() && begion.getTime() != new Date(Long.MAX_VALUE).getTime())
|
|
|
-// {
|
|
|
-// begin1 = begion;
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// int dimension = this.dimension;
|
|
|
-// double scale = this.scale;
|
|
|
-//
|
|
|
-// //上个月
|
|
|
-// c.setTime(DateUtils.addMonths(begin1,-1));
|
|
|
-// int year2 = c.get(Calendar.YEAR);
|
|
|
-// int month2 = c.get(Calendar.MONTH)+1;
|
|
|
-//
|
|
|
-// //去年同期
|
|
|
-// c.setTime(DateUtils.addYears(begin1,-1));
|
|
|
-// int year3 = c.get(Calendar.YEAR);
|
|
|
-// int month3 = c.get(Calendar.MONTH)+1;
|
|
|
-//
|
|
|
-//
|
|
|
-// Map<String, CureFitting> windMap = new HashMap<String, CureFitting>();
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// List<ProBasicWindturbine> wtls = CacheContext.wtls;
|
|
|
-//
|
|
|
-// if (windturbineCapacity == null)
|
|
|
-// {
|
|
|
-// windturbineCapacity = new HashMap<String, Double>();
|
|
|
-// Map<String, ProEconEquipmentmodel> modelMap = CacheContext.modelMap;
|
|
|
-// for (ProBasicWindturbine windturbine : wtls)
|
|
|
-// {
|
|
|
-// if (modelMap.containsKey(windturbine.getModelId()))
|
|
|
-// {
|
|
|
-// windturbineCapacity.put(windturbine.getId(), modelMap.get(windturbine.getModelId()).getPowerProduction());
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// for (ProBasicWindturbine wt : wtls)
|
|
|
-// {
|
|
|
-// String windturbineId = wt.getId();
|
|
|
-// String windpowerId = wt.getWindpowerstationId();
|
|
|
-//
|
|
|
-// if (StringUtils.notEmp(fdcId))
|
|
|
-// {
|
|
|
-// if (!fdcId.equals(windpowerId))
|
|
|
-// {
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// if (fdjIds != null)
|
|
|
-// {
|
|
|
-// if (!fdjIds.contains(windturbineId))
|
|
|
-// {
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// Map<String, ProBasicEquipmentPoint> windturbinetestingpointnewMap = CacheContext.wtpAimap.get(wt.getId());
|
|
|
-//
|
|
|
-// String pointIdGL =windturbinetestingpointnewMap.get(Contant.AI130).getCode();
|
|
|
-//
|
|
|
-//
|
|
|
-// String pointIdZT =windturbinetestingpointnewMap.get(Contant.ZTMX).getCode();
|
|
|
-//
|
|
|
-// String pointIdFS = "";
|
|
|
-// if (wt.getWindpowerstationId().endsWith("GDC"))
|
|
|
-// {
|
|
|
-// pointIdFS = windturbinetestingpointnewMap.get(Contant.IRRAD).getCode();;
|
|
|
-//
|
|
|
-// }else
|
|
|
-// {
|
|
|
-// pointIdFS = windturbinetestingpointnewMap.get(Contant.AI022).getCode();
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// CureFitting item = new CureFitting();
|
|
|
-//
|
|
|
-// item.setPointIdFS(pointIdFS);
|
|
|
-// item.setPointIdZT(pointIdZT);
|
|
|
-// item.setPointIdGL(pointIdZT);
|
|
|
-// //获取标杆风机编号
|
|
|
-// if(CacheContext.wtstandardmap.containsKey(wt.getId()))
|
|
|
-// {
|
|
|
-// item.setStandardId(CacheContext.wtstandardmap.get(wt.getId()));
|
|
|
-// }else
|
|
|
-// {
|
|
|
-// item.setStandardId(wt.getId());
|
|
|
-// }
|
|
|
-//
|
|
|
-// windMap.put(windturbineId, item);
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// for (String key : windMap.keySet())
|
|
|
-// {
|
|
|
-// windMap.get(key).setMyPoints1(new ArrayList<PointVo>());
|
|
|
-// windMap.get(key).setMyPointsFF1(new ArrayList<PointVo>());
|
|
|
-// windMap.get(key).setMyPoints2(new ArrayList<PointVo>());
|
|
|
-// windMap.get(key).setMyPointsFF2(new ArrayList<PointVo>());
|
|
|
-//
|
|
|
-//
|
|
|
-// if (windMap.get(key).getPointIdGL() == null || windMap.get(key).getPointIdFS() == null || windMap.get(key).getPointIdZT() == null)
|
|
|
-// {
|
|
|
-// System.out.println(key);
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// CurveFittingBuilder(begin1, end, dimension, scale, windMap.get(key).getPointIdGL(), windMap.get(key).getPointIdFS(), windMap.get(key).getPointIdZT(),windMap.get(key).getMyPoints1(), windMap.get(key).getMyPointsFF1(), key);
|
|
|
-// CurveFittingBuilder(begin2, end, dimension, scale, windMap.get(key).getPointIdGL(), windMap.get(key).getPointIdFS(), windMap.get(key).getPointIdZT(), windMap.get(key).getMyPoints2(), windMap.get(key).getMyPointsFF2(), key);
|
|
|
-// }
|
|
|
-//
|
|
|
-// for (String key : windMap.keySet())
|
|
|
-// {
|
|
|
-//
|
|
|
-// Double modelpower = 1500.0;
|
|
|
-// if (windturbineCapacity.containsKey(key))
|
|
|
-// {
|
|
|
-// modelpower = windturbineCapacity.get(key);
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// //月的上月
|
|
|
-// List<PointVo> monthPoints = new ArrayList<PointVo>();
|
|
|
-// //月的去年同期
|
|
|
-// List<PointVo> yearPoints = new ArrayList<PointVo>();
|
|
|
-// //月标准功率
|
|
|
-// List<PointVo> standardPoints = new ArrayList<PointVo>();
|
|
|
-//
|
|
|
-//
|
|
|
-// //日的昨天
|
|
|
-// List<PointVo> monthdayPoints = new ArrayList<PointVo>();
|
|
|
-// //日的去年同期
|
|
|
-// List<PointVo> yeardayPoints = new ArrayList<PointVo>();
|
|
|
-// //日标准功率
|
|
|
-// List<PointVo> standarddayPoints = new ArrayList<PointVo>();
|
|
|
-//
|
|
|
-// //保证功率
|
|
|
-// List<PointVo> powerPoints = new ArrayList<PointVo>();
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// if (CacheContext.wtstandardmap.containsKey(key))
|
|
|
-// {
|
|
|
-// String standardId =CacheContext.wtstandardmap.get(key);
|
|
|
-// if (StringUtils.notEmp(standardId))
|
|
|
-// {
|
|
|
-// if (windMap.containsKey(key))
|
|
|
-// {
|
|
|
-// standardPoints = windMap.get(standardId).getMyPoints1();
|
|
|
-// standarddayPoints =windMap.get(standardId).getMyPoints2();
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// String stringyear = String.valueOf(year);
|
|
|
-// String stringmonth = String.valueOf(month);
|
|
|
-//
|
|
|
-// String stringyear2 =String.valueOf(year2);
|
|
|
-// String stringmonth2 = String.valueOf(month2);
|
|
|
-//
|
|
|
-// String stringyear3 = String.valueOf(year3);
|
|
|
-// String stringmonth3 = String.valueOf(month3);
|
|
|
-//
|
|
|
-//
|
|
|
-// List<ProEconWtCurveFittingMonth> wcfmls=proEconWtCurveFittingMonthService.list().stream().filter(i->i.getWindturbineId().equals(key) &&
|
|
|
-// i.getYear().equals(stringmonth2) && i.getMonth().equals(stringmonth2)).collect(Collectors.toList());
|
|
|
-// wcfmls.sort(Comparator.comparing(ProEconWtCurveFittingMonth::getSpeed));
|
|
|
-//
|
|
|
-//
|
|
|
-// BuildPoints(wcfmls, monthPoints);
|
|
|
-// wcfmls = null;
|
|
|
-//
|
|
|
-// wcfmls=proEconWtCurveFittingMonthService.list().stream().filter(i->i.getWindturbineId().equals(key) &&
|
|
|
-// i.getYear().equals(stringyear3) && i.getMonth().equals(stringmonth3)).collect(Collectors.toList());
|
|
|
-// wcfmls.sort(Comparator.comparing(ProEconWtCurveFittingMonth::getSpeed));
|
|
|
-//
|
|
|
-// BuildPoints(wcfmls, yearPoints);
|
|
|
-//
|
|
|
-// Date d1 = DateUtils.addDays(current,-1);
|
|
|
-// Date d2 = DateUtils.addDays(current,-1);
|
|
|
-//
|
|
|
-// List<ProEconWtCurveFitting> wcfls=proEconWtCurveFittingService.list().stream().filter(i->i.getWindturbineId().equals(key) &&
|
|
|
-// i.getRecordDate().compareTo(d1)==0).collect(Collectors.toList());
|
|
|
-//
|
|
|
-//
|
|
|
-// BuildPoints(wcfls, monthdayPoints);
|
|
|
-//
|
|
|
-// wcfls = null;
|
|
|
-// wcfls=proEconWtCurveFittingService.list().stream().filter(i->i.getWindturbineId().equals(key) &&
|
|
|
-// i.getRecordDate().compareTo(d2)==0).collect(Collectors.toList());
|
|
|
-//
|
|
|
-//
|
|
|
-// BuildPoints(wcfls, monthPoints);
|
|
|
-//
|
|
|
-// if (CacheContext.wtmap.containsKey(key))
|
|
|
-// {
|
|
|
-// String modelid = CacheContext.wtmap.get(key).getModelId();
|
|
|
-// if (StringUtils.notEmp(modelid))
|
|
|
-// {
|
|
|
-// //获取模型功率曲线
|
|
|
-// if (CacheContext.modelpowermap.containsKey(modelid))
|
|
|
-// {
|
|
|
-// for (Double speed :CacheContext.modelpowermap.get(modelid).keySet())
|
|
|
-// {
|
|
|
-// PointVo point = new PointVo();
|
|
|
-// point.setX(speed);
|
|
|
-// point.setY(CacheContext.modelpowermap.get(modelid).get(speed).getEnsurePower());
|
|
|
-//
|
|
|
-// powerPoints.add(point);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// ProEconCurveFittMonthMain main1 = (from c : entities.ProEconCurveFittMonthMain
|
|
|
-// where (c.WINDTURBINEID == key && c.YEAR == stringyear && c.MONTH == stringmonth)
|
|
|
-// select c).FirstOrDefault();
|
|
|
-// if (main1 == null)
|
|
|
-// {
|
|
|
-// main1 = new ProEconCurveFittMonthMain();
|
|
|
-// main1.ID = Guid.NewGuid().ToString();
|
|
|
-// main1.WINDTURBINEID = key;
|
|
|
-// main1.YEAR = year.ToString();
|
|
|
-// main1.MONTH = month.ToString();
|
|
|
-// entities.AddToCURVEFITTINGMONTHMAIN(main1);
|
|
|
-// }
|
|
|
-// //月---实际/最优
|
|
|
-// main1.DEVIATIONRATE1 = (Double)pcl(windMap[key].myPoints1, windMap[key].myPointsFF1, modelpower);
|
|
|
-// //月---实际/保证
|
|
|
-// main1.DEVIATIONRATE2 = (Double)pcl(windMap[key].myPoints1, powerPoints, modelpower);
|
|
|
-// //月---最优/保证
|
|
|
-// main1.DEVIATIONRATE3 = (Double)pcl(windMap[key].myPointsFF1, powerPoints, modelpower);
|
|
|
-// //月---实际/上月实际
|
|
|
-// main1.MONTHDEVIATIONRATE = (Double)pcl(windMap[key].myPoints1, monthPoints, modelpower);
|
|
|
-// //月---实际/同期实际
|
|
|
-// main1.YEARDEVIATIONRATE = (Double)pcl(windMap[key].myPoints1, yearPoints, modelpower);
|
|
|
-// //月---实际/标杆实际
|
|
|
-// main1.STANDARDDEVIATIONRATE = (Double)pcl(windMap[key].myPoints1, standardPoints, modelpower);
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// CURVEFITTINGMAIN main2 = (from c : entities.CURVEFITTINGMAIN
|
|
|
-// where (c.WINDTURBINEID == key && c.RECORDDATE.Value.CompareTo(current) == 0)
|
|
|
-// select c).FirstOrDefault();
|
|
|
-// if (main2 == null)
|
|
|
-// {
|
|
|
-// main2 = new CURVEFITTINGMAIN();
|
|
|
-// main2.ID = Guid.NewGuid().ToString();
|
|
|
-// main2.WINDTURBINEID = key;
|
|
|
-// main2.RECORDDATE = current;
|
|
|
-//
|
|
|
-// entities.AddToCURVEFITTINGMAIN(main2);
|
|
|
-//
|
|
|
-// }
|
|
|
-// //日---实际/最优
|
|
|
-// main2.DEVIATIONRATE1 = (Double)pcl(windMap[key].myPoints2, windMap[key].myPointsFF2, modelpower);
|
|
|
-// //日---实际/保证
|
|
|
-// main2.DEVIATIONRATE2 = (Double)pcl(windMap[key].myPoints2, powerPoints, modelpower);
|
|
|
-// //日---最优/保证
|
|
|
-// main2.DEVIATIONRATE3 = (Double)pcl(windMap[key].myPointsFF2, powerPoints, modelpower);
|
|
|
-// //日---实际/上日实际
|
|
|
-// main2.MONTHDEVIATIONRATE = (Double)pcl(windMap[key].myPoints2, monthdayPoints, modelpower);
|
|
|
-// //日---实际/同期实际
|
|
|
-// main2.YEARDEVIATIONRATE = (Double)pcl(windMap[key].myPoints2, yeardayPoints, modelpower);
|
|
|
-// //日---实际/标杆实际
|
|
|
-// main2.STANDARDDEVIATIONRATE = (Double)pcl(windMap[key].myPoints2, standarddayPoints, modelpower);
|
|
|
-//
|
|
|
-// PLCBuild(entities, key, stringyear, stringmonth, current, windMap, modelpower, 3, powerPoints, monthPoints, yearPoints, standardPoints, monthdayPoints, yeardayPoints, standarddayPoints);
|
|
|
-// PLCBuild(entities, key, stringyear, stringmonth, current, windMap, modelpower, 4, powerPoints, monthPoints, yearPoints, standardPoints, monthdayPoints, yeardayPoints, standarddayPoints);
|
|
|
-// PLCBuild(entities, key, stringyear, stringmonth, current, windMap, modelpower, 5, powerPoints, monthPoints, yearPoints, standardPoints, monthdayPoints, yeardayPoints, standarddayPoints);
|
|
|
-// PLCBuild(entities, key, stringyear, stringmonth, current, windMap, modelpower, 6, powerPoints, monthPoints, yearPoints, standardPoints, monthdayPoints, yeardayPoints, standarddayPoints);
|
|
|
-// PLCBuild(entities, key, stringyear, stringmonth, current, windMap, modelpower, 7, powerPoints, monthPoints, yearPoints, standardPoints, monthdayPoints, yeardayPoints, standarddayPoints);
|
|
|
-// PLCBuild(entities, key, stringyear, stringmonth, current, windMap, modelpower, 8, powerPoints, monthPoints, yearPoints, standardPoints, monthdayPoints, yeardayPoints, standarddayPoints);
|
|
|
-// PLCBuild(entities, key, stringyear, stringmonth, current, windMap, modelpower, 9, powerPoints, monthPoints, yearPoints, standardPoints, monthdayPoints, yeardayPoints, standarddayPoints);
|
|
|
-// PLCBuild(entities, key, stringyear, stringmonth, current, windMap, modelpower, 10, powerPoints, monthPoints, yearPoints, standardPoints, monthdayPoints, yeardayPoints, standarddayPoints);
|
|
|
-// PLCBuild(entities, key, stringyear, stringmonth, current, windMap, modelpower, 11, powerPoints, monthPoints, yearPoints, standardPoints, monthdayPoints, yeardayPoints, standarddayPoints);
|
|
|
-// PLCBuild(entities, key, stringyear, stringmonth, current, windMap, modelpower, 12, powerPoints, monthPoints, yearPoints, standardPoints, monthdayPoints, yeardayPoints, standarddayPoints);
|
|
|
-// PLCBuild(entities, key, stringyear, stringmonth, current, windMap, modelpower, 13, powerPoints, monthPoints, yearPoints, standardPoints, monthdayPoints, yeardayPoints, standarddayPoints);
|
|
|
-//
|
|
|
-//
|
|
|
-// if (insertType == 0)
|
|
|
-// {
|
|
|
-// InsertPoints(current, stringyear, stringmonth, entities, windMap[key].myPoints1, windMap[key].myPointsFF1, windMap[key].myPoints2, windMap[key].myPointsFF2, key);
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-// InsertPoints2(current, stringyear, stringmonth, entities, windMap[key].myPoints1, windMap[key].myPointsFF1, windMap[key].myPoints2, windMap[key].myPointsFF2, key);
|
|
|
-// }
|
|
|
-// Console.WriteLine(key);
|
|
|
-// int z = entities.SaveChanges(false);
|
|
|
-// logger.Info(String.Format("{1}:更新sqlserver数据库记录数:{0}", z, Date.Now));
|
|
|
-//
|
|
|
-//
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// }
|
|
|
-//
|
|
|
-// public void PLCBuild(GdsjEntities entities, String key, String stringyear, String stringmonth, Date current, Map<String, CureFitting> windMap, Double modelpower, double speed,
|
|
|
-// List<PointVo> powerPoints, List<PointVo> monthPoints, List<PointVo> yearPoints, List<PointVo> standardPoints, List<PointVo> monthdayPoints, List<PointVo> yeardayPoints, List<PointVo> standarddayPoints)
|
|
|
-// {
|
|
|
-//
|
|
|
-// String speedStr = speed.ToString();
|
|
|
-//
|
|
|
-// CURVEFITTINGMONTHSUB main1 = (from c : entities.CURVEFITTINGMONTHSUB
|
|
|
-// where (c.WINDTURBINEID == key && c.YEAR == stringyear && c.MONTH == stringmonth && c.SPEED == speedStr)
|
|
|
-// select c).FirstOrDefault();
|
|
|
-// if (main1 == null)
|
|
|
-// {
|
|
|
-// main1 = new CURVEFITTINGMONTHSUB();
|
|
|
-// main1.ID = Guid.NewGuid().ToString();
|
|
|
-// main1.WINDTURBINEID = key;
|
|
|
-// main1.YEAR = stringyear;
|
|
|
-// main1.MONTH = stringmonth;
|
|
|
-// main1.SPEED = speed.ToString();
|
|
|
-// entities.AddToCURVEFITTINGMONTHSUB(main1);
|
|
|
-// }
|
|
|
-// //月---实际/最优
|
|
|
-// main1.DEVIATIONRATE1 = (Double)pcl2(windMap[key].myPoints1, windMap[key].myPointsFF1, modelpower, speed);
|
|
|
-// //月---实际/保证
|
|
|
-// main1.DEVIATIONRATE2 = (Double)pcl2(windMap[key].myPoints1, powerPoints, modelpower, speed);
|
|
|
-// //月---最优/保证
|
|
|
-// main1.DEVIATIONRATE3 = (Double)pcl2(windMap[key].myPointsFF1, powerPoints, modelpower, speed);
|
|
|
-// //月---实际/上月实际
|
|
|
-// main1.MONTHDEVIATIONRATE = (Double)pcl2(windMap[key].myPoints1, monthPoints, modelpower, speed);
|
|
|
-// //月---实际/同期实际
|
|
|
-// main1.YEARDEVIATIONRATE = (Double)pcl2(windMap[key].myPoints1, yearPoints, modelpower, speed);
|
|
|
-// //月---实际/标杆实际
|
|
|
-// main1.STANDARDDEVIATIONRATE = (Double)pcl2(windMap[key].myPoints1, standardPoints, modelpower, speed);
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// CURVEFITTINGSUB main2 = (from c : entities.CURVEFITTINGSUB
|
|
|
-// where (c.WINDTURBINEID == key && c.RECORDDATE.Value.CompareTo(current) == 0 && c.SPEED == speedStr)
|
|
|
-// select c).FirstOrDefault();
|
|
|
-// if (main2 == null)
|
|
|
-// {
|
|
|
-// main2 = new CURVEFITTINGSUB();
|
|
|
-// main2.ID = Guid.NewGuid().ToString();
|
|
|
-// main2.WINDTURBINEID = key;
|
|
|
-// main2.RECORDDATE = current;
|
|
|
-// main2.SPEED = speed.ToString();
|
|
|
-// entities.AddToCURVEFITTINGSUB(main2);
|
|
|
-//
|
|
|
-// }
|
|
|
-// //日---实际/最优
|
|
|
-// main2.DEVIATIONRATE1 = (Double)pcl2(windMap[key].myPoints2, windMap[key].myPointsFF2, modelpower, speed);
|
|
|
-// //日---实际/保证
|
|
|
-// main2.DEVIATIONRATE2 = (Double)pcl2(windMap[key].myPoints2, powerPoints, modelpower, speed);
|
|
|
-// //日---最优/保证
|
|
|
-// main2.DEVIATIONRATE3 = (Double)pcl2(windMap[key].myPointsFF2, powerPoints, modelpower, speed);
|
|
|
-// //日---实际/上日实际
|
|
|
-// main2.MONTHDEVIATIONRATE = (Double)pcl2(windMap[key].myPoints2, monthdayPoints, modelpower, speed);
|
|
|
-// //日---实际/同期实际
|
|
|
-// main2.YEARDEVIATIONRATE = (Double)pcl2(windMap[key].myPoints2, yeardayPoints, modelpower, speed);
|
|
|
-// //日---实际/标杆实际
|
|
|
-// main2.STANDARDDEVIATIONRATE = (Double)pcl2(windMap[key].myPoints2, standarddayPoints, modelpower, speed);
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// private void InsertPoints(Date current, String year, String month, GdsjEntities entities, List<PointVo> pointsF1, List<PointVo> pointsFF1, List<PointVo> pointsF2, List<PointVo> pointsFF2, String windturbineId)
|
|
|
-// {
|
|
|
-// var data = (from c : entities.ProEconWtCurveFittingMonth
|
|
|
-// where (c.WINDTURBINEID == windturbineId && c.YEAR == year && c.MONTH == month)
|
|
|
-// select c).ToList();
|
|
|
-//
|
|
|
-// for (int i = 0; i < data.Count; i++)
|
|
|
-// {
|
|
|
-// entities.DeleteObject(data[i]);
|
|
|
-// }
|
|
|
-//
|
|
|
-// if (pointsF1.Count == pointsFF1.Count)
|
|
|
-// {
|
|
|
-// for (int i = 0; i < pointsF1.Count; i++)
|
|
|
-// {
|
|
|
-// ProEconWtCurveFittingMonth item = new ProEconWtCurveFittingMonth();
|
|
|
-// item.WINDTURBINEID = windturbineId;
|
|
|
-//
|
|
|
-// if (type == "GDC")
|
|
|
-// {
|
|
|
-// continue;
|
|
|
-// item.SPEED = Double.Truncate((Double)pointsF1[i].X);
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-//
|
|
|
-// item.SPEED = (Double)pointsF1[i].X;
|
|
|
-// }
|
|
|
-// item.ACTUALPOWER = (Double)pointsF1[i].Y;
|
|
|
-// item.OPTIMALPOWER = (Double)pointsFF1[i].Y;
|
|
|
-// item.YEAR = year.ToString();
|
|
|
-// item.MONTH = month.ToString();
|
|
|
-// entities.AddToWINDTURBINECURVEFITTINGMONTH(item);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-//
|
|
|
-// logger.WarnFormat(String.Format("下标不一致的风机编号:{0},实际功率:{1},最有功率:{2}", windturbineId, pointsF1.Count, pointsFF1.Count));
|
|
|
-//
|
|
|
-// for (int i = 0; i < pointsF1.Count; i++)
|
|
|
-// {
|
|
|
-// ProEconWtCurveFittingMonth item = new ProEconWtCurveFittingMonth();
|
|
|
-// item.WINDTURBINEID = windturbineId;
|
|
|
-// if (type == "GDC")
|
|
|
-// {
|
|
|
-// continue;
|
|
|
-// item.SPEED = Double.Truncate((Double)pointsF1[i].X);
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-//
|
|
|
-// item.SPEED = (Double)pointsF1[i].X;
|
|
|
-// }
|
|
|
-// item.ACTUALPOWER = (Double)pointsF1[i].Y;
|
|
|
-// item.OPTIMALPOWER = (Double)pointsFF1.Where(it => it.X == pointsF1[i].X).Select(it => it.Y).FirstOrDefault();
|
|
|
-// item.YEAR = year.ToString();
|
|
|
-// item.MONTH = month.ToString();
|
|
|
-// entities.AddToWINDTURBINECURVEFITTINGMONTH(item);
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// var data2 = (from c : entities.ProEconWtCurveFitting
|
|
|
-// where (c.WINDTURBINEID == windturbineId && c.RECORDDATE.Value.CompareTo(current) == 0)
|
|
|
-// select c).ToList();
|
|
|
-//
|
|
|
-//
|
|
|
-// for (int i = 0; i < data2.Count; i++)
|
|
|
-// {
|
|
|
-// entities.DeleteObject(data2[i]);
|
|
|
-// }
|
|
|
-//
|
|
|
-// if (pointsF2.Count == pointsFF2.Count)
|
|
|
-// {
|
|
|
-// for (int i = 0; i < pointsF2.Count; i++)
|
|
|
-// {
|
|
|
-// ProEconWtCurveFitting item = new ProEconWtCurveFitting();
|
|
|
-// item.WINDTURBINEID = windturbineId;
|
|
|
-// if (type == "GDC")
|
|
|
-// {
|
|
|
-// continue;
|
|
|
-// item.SPEED = Double.Truncate((Double)pointsF2[i].X);
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-// bool l = pointsF2[i].X.ToString().contains(".");
|
|
|
-// if (l)
|
|
|
-// {
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// item.SPEED = (Double)pointsF2[i].X;
|
|
|
-// }
|
|
|
-// item.ACTUALPOWER = (int)pointsF2[i].Y;
|
|
|
-// item.OPTIMALPOWER = (int)pointsFF2[i].Y;
|
|
|
-// item.RECORDDATE = current;
|
|
|
-//
|
|
|
-// entities.AddToWINDTURBINECURVEFITTING(item);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-// logger.WarnFormat(String.Format("下标不一致的风机编号:{0},实际功率:{1},最有功率:{2}", windturbineId, pointsF2.Count, pointsFF2.Count));
|
|
|
-//
|
|
|
-// for (int i = 0; i < pointsF2.Count; i++)
|
|
|
-// {
|
|
|
-// ProEconWtCurveFitting item = new ProEconWtCurveFitting();
|
|
|
-// item.WINDTURBINEID = windturbineId;
|
|
|
-// if (type == "GDC")
|
|
|
-// {
|
|
|
-// continue;
|
|
|
-// item.SPEED = Double.Truncate((Double)pointsF2[i].X);
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-// bool l = pointsF2[i].X.ToString().contains(".");
|
|
|
-// if (l)
|
|
|
-// {
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// item.SPEED = (Double)pointsF2[i].X;
|
|
|
-// }
|
|
|
-// item.ACTUALPOWER = (int)pointsF2[i].Y;
|
|
|
-// item.OPTIMALPOWER = (int)pointsFF2.Where(it => it.X == pointsF2[i].X).Select(it => it.Y).FirstOrDefault();
|
|
|
-// item.RECORDDATE = current;
|
|
|
-//
|
|
|
-// entities.AddToWINDTURBINECURVEFITTING(item);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// private void InsertPoints2(Date current, String year, String month, GdsjEntities entities, List<PointVo> pointsF1, List<PointVo> pointsFF1, List<PointVo> pointsF2, List<PointVo> pointsFF2, String windturbineId)
|
|
|
-// {
|
|
|
-// var data = (from c : entities.WINDTURBINEPOWERCURVEFITTING
|
|
|
-// where (c.WINDTURBINEID == windturbineId)
|
|
|
-// select c).ToList();
|
|
|
-//
|
|
|
-// for (int i = 0; i < data.Count; i++)
|
|
|
-// {
|
|
|
-// entities.DeleteObject(data[i]);
|
|
|
-// }
|
|
|
-//
|
|
|
-// if (pointsF1.Count == pointsFF1.Count)
|
|
|
-// {
|
|
|
-// for (int i = 0; i < pointsF1.Count; i++)
|
|
|
-// {
|
|
|
-// WINDTURBINEPOWERCURVEFITTING item = new WINDTURBINEPOWERCURVEFITTING();
|
|
|
-// item.ID = Guid.NewGuid().ToString();
|
|
|
-// item.WINDTURBINEID = windturbineId;
|
|
|
-//
|
|
|
-// if (type == "GDC")
|
|
|
-// {
|
|
|
-// continue;
|
|
|
-// item.SPEED = Double.Truncate((Double)pointsF1[i].X);
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-// bool l = pointsF1[i].X.ToString().contains(".");
|
|
|
-// if (l)
|
|
|
-// {
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// item.SPEED = (Double)pointsF1[i].X;
|
|
|
-// }
|
|
|
-// item.ACTUALPOWER = (Double)pointsF1[i].Y;
|
|
|
-// item.OPTIMALPOWER = (Double)pointsFF1[i].Y;
|
|
|
-//
|
|
|
-// entities.AddToWINDTURBINEPOWERCURVEFITTING(item);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-//
|
|
|
-// logger.WarnFormat(String.Format("下标不一致的风机编号:{0},实际功率:{1},最有功率:{2}", windturbineId, pointsF1.Count, pointsFF1.Count));
|
|
|
-//
|
|
|
-// for (int i = 0; i < pointsF1.Count; i++)
|
|
|
-// {
|
|
|
-// WINDTURBINEPOWERCURVEFITTING item = new WINDTURBINEPOWERCURVEFITTING();
|
|
|
-// item.ID = Guid.NewGuid().ToString();
|
|
|
-// item.WINDTURBINEID = windturbineId;
|
|
|
-// if (type == "GDC")
|
|
|
-// {
|
|
|
-// continue;
|
|
|
-// item.SPEED = Double.Truncate((Double)pointsF1[i].X);
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-// bool l = pointsF1[i].X.ToString().contains(".");
|
|
|
-// if (l)
|
|
|
-// {
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// item.SPEED = (Double)pointsF1[i].X;
|
|
|
-// }
|
|
|
-// item.ACTUALPOWER = (Double)pointsF1[i].Y;
|
|
|
-// item.OPTIMALPOWER = (Double)pointsFF1.Where(it => it.X == pointsF1[i].X).Select(it => it.Y).FirstOrDefault();
|
|
|
-//
|
|
|
-// entities.AddToWINDTURBINEPOWERCURVEFITTING(item);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// private void BuildPoints(List<ProEconWtCurveFittingMonth> data, List<PointVo> points)
|
|
|
-// {
|
|
|
-// if (data != null)
|
|
|
-// {
|
|
|
-// for (int i = 0; i < data.Count; i++)
|
|
|
-// {
|
|
|
-// PointVo point = new PointVo();
|
|
|
-// point.X = (double)data[i].SPEED.Value;
|
|
|
-// point.Y = (double)data[i].ACTUALPOWER.Value;
|
|
|
-// points.Add(point);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// private void BuildPoints(List<ProEconWtCurveFitting> data, List<PointVo> points)
|
|
|
-// {
|
|
|
-// if (data != null)
|
|
|
-// {
|
|
|
-// for (int i = 0; i < data.Count; i++)
|
|
|
-// {
|
|
|
-// PointVo point = new PointVo();
|
|
|
-// point.X = (double)data[i].SPEED.Value;
|
|
|
-// point.Y = (double)data[i].ACTUALPOWER.Value;
|
|
|
-// points.Add(point);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// //曲线偏差率
|
|
|
-// private double pcl(List<PointVo> Points1, List<PointVo> Points2, Double modelpower)
|
|
|
-// {
|
|
|
-// double result = -0;
|
|
|
-// double pc = 0;
|
|
|
-// if (Points1 != null && Points1.Count != 0 && Points2 != null && Points2.Count != 0)
|
|
|
-// {
|
|
|
-// double count = 0;
|
|
|
-// double sum = 0;
|
|
|
-// double max = (double)modelpower;
|
|
|
-// for (PointVo point : Points1)
|
|
|
-// {
|
|
|
-// var item = Points2.Where(it => it.X == point.X).ToList();
|
|
|
-// if (item != null && item.Count > 0)
|
|
|
-// {
|
|
|
-// sum += Math.Pow((point.Y - item[0].Y), 2);
|
|
|
-// count++;
|
|
|
-// pc += point.Y - item[0].Y;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// sum = Math.Sqrt(sum);
|
|
|
-// count = Math.Sqrt(count);
|
|
|
-// max = max * count;
|
|
|
-// if (max != 0)
|
|
|
-// {
|
|
|
-// result = sum / max * 100;
|
|
|
-// }
|
|
|
-//
|
|
|
-// if (pc < 0)
|
|
|
-// {
|
|
|
-// result = 0 - result;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// return result;
|
|
|
-// }
|
|
|
-// //曲线偏差率2
|
|
|
-// private double pcl2(List<PointVo> Points1, List<PointVo> Points2, Double modelpower, double speed)
|
|
|
-// {
|
|
|
-// double minSpeed = speed;
|
|
|
-// double maxSpeed = minSpeed + 1;
|
|
|
-// double result = -0;
|
|
|
-// double pc = 0;
|
|
|
-// if (Points1 != null && Points1.Count != 0 && Points2 != null && Points2.Count != 0)
|
|
|
-// {
|
|
|
-// double count = 0;
|
|
|
-// double sum = 0;
|
|
|
-// double max = (double)modelpower;
|
|
|
-// for (PointVo point : Points1)
|
|
|
-// {
|
|
|
-// var item = Points2.Where(it => it.X == point.X).ToList();
|
|
|
-// if (item != null && item.Count > 0 && item[0].X >= minSpeed && item[0].X < maxSpeed)
|
|
|
-// {
|
|
|
-// sum += Math.Pow((point.Y - item[0].Y), 2);
|
|
|
-// count++;
|
|
|
-// pc += point.Y - item[0].Y;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// sum = Math.Sqrt(sum);
|
|
|
-// count = Math.Sqrt(count);
|
|
|
-// max = max * count;
|
|
|
-// if (max != 0)
|
|
|
-// {
|
|
|
-// result = sum / max * 100;
|
|
|
-// }
|
|
|
-//
|
|
|
-// if (pc < 0)
|
|
|
-// {
|
|
|
-// result = 0 - result;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// return result;
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// //功率曲线拟合
|
|
|
-// public void CurveFittingBuilder(Date begin, Date end, int dimension, double scale, String pointIdGL, String pointIdFS, String pointIdZT, List<PointVo> myPoints, List<PointVo> myPointsFF, String windturbineId)
|
|
|
-// {
|
|
|
-// double maxPower = (double)windturbineCapacity[windturbineId] * 1.3;
|
|
|
-// List<PointF> pointsF = new ArrayList<PointF>();
|
|
|
-// Map<float, PointF> pointsFF = new HashMap<float, PointF>();
|
|
|
-//
|
|
|
-// if (end > begin)
|
|
|
-// {
|
|
|
-// if (String.Empty != pointIdGL && String.Empty != pointIdFS)
|
|
|
-// {
|
|
|
-// var glpoints = ednaHelper.GetHisData(pointIdGL, begin, end);
|
|
|
-// var fspoints = ednaHelper.GetHisData(pointIdFS, begin, end);
|
|
|
-// var ztpoints = ednaHelper.GetHisData(pointIdZT, begin, end);
|
|
|
-//
|
|
|
-// //var ztpoints2 = GoldenHelper.GetHisData(pointIdZT2, begin, end);
|
|
|
-//
|
|
|
-// //Console.WriteLine(ztpoints2);
|
|
|
-//
|
|
|
-//
|
|
|
-// if (glpoints.Count != fspoints.Count || glpoints.Count != ztpoints.Count)
|
|
|
-// {
|
|
|
-// for (int i = 0; i < fspoints.Count; i++)
|
|
|
-// {
|
|
|
-// double x = double.Parse(fspoints[i].value.ToString());
|
|
|
-// double y = -1;
|
|
|
-// double z = -1;
|
|
|
-// double z1 = -1;
|
|
|
-// var yArray = glpoints.Where(it => it.time == fspoints[i].time).ToList();
|
|
|
-// if (yArray != null && yArray.Count > 0)
|
|
|
-// {
|
|
|
-//
|
|
|
-// y = double.Parse(yArray[0].value.ToString());
|
|
|
-// }
|
|
|
-//
|
|
|
-// yArray = ztpoints.Where(it => it.time == fspoints[i].time).ToList();
|
|
|
-// if (yArray != null && yArray.Count > 0)
|
|
|
-// {
|
|
|
-//
|
|
|
-// z = double.Parse(yArray[0].value.ToString());
|
|
|
-// }
|
|
|
-//
|
|
|
-// //yArray = ztpoints2.Where(it => it.time == fspoints[i].time).ToList();
|
|
|
-// //if (yArray != null && yArray.Count > 0)
|
|
|
-// //{
|
|
|
-// // z1 = double.Parse(yArray[0].value.ToString());
|
|
|
-// //}
|
|
|
-//
|
|
|
-// float x1 = (float)Math.Round(x, 2);
|
|
|
-// float y1 = (float)y;
|
|
|
-//
|
|
|
-//
|
|
|
-// bool b = true;
|
|
|
-// if (type == "GDC")
|
|
|
-// b = (x >= 0 && y > 0);
|
|
|
-// else
|
|
|
-// if (z == 2)
|
|
|
-// {
|
|
|
-//
|
|
|
-// b = (x >= 0 && x <= 30 && y >= 0 && y <= maxPower);
|
|
|
-//
|
|
|
-// if (b)
|
|
|
-// {
|
|
|
-// if (x > 3 && y <= 0)
|
|
|
-// {
|
|
|
-// b = false;
|
|
|
-// }
|
|
|
-// if (x <= 3 && y > 0)
|
|
|
-// {
|
|
|
-// b = false;
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-// b = false;
|
|
|
-// }
|
|
|
-// if (b)
|
|
|
-// {
|
|
|
-// pointsF.Add(new PointF(x1, y1));
|
|
|
-//
|
|
|
-// if (pointsFF.containsKey(x1))
|
|
|
-// {
|
|
|
-// if (pointsFF[x1].Y < y1)
|
|
|
-// {
|
|
|
-// pointsFF[x1] = new PointF(x1, y1);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-// pointsFF.Add(x1, new PointF(x1, y1));
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// }
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-//
|
|
|
-// for (int i = 0; i < fspoints.Count; i++)
|
|
|
-// {
|
|
|
-// double x = double.Parse(fspoints[i].value.ToString());
|
|
|
-// double y = double.Parse(glpoints[i].value.ToString());
|
|
|
-// double z = double.Parse(ztpoints[i].value.ToString());
|
|
|
-// //double z1 = double.Parse(ztpoints2[i].value.ToString());
|
|
|
-//
|
|
|
-// float x1 = (float)Math.Round(x, 2);
|
|
|
-// float y1 = (float)y;
|
|
|
-//
|
|
|
-//
|
|
|
-// bool b = true;
|
|
|
-// if (type == "GDC")
|
|
|
-// b = (x >= 0 && y > 0);
|
|
|
-// else
|
|
|
-// {
|
|
|
-// if (z == 2)
|
|
|
-// {
|
|
|
-//
|
|
|
-// b = (x >= 0 && x <= 30 && y >= 0 && y <= maxPower);
|
|
|
-//
|
|
|
-// if (b)
|
|
|
-// {
|
|
|
-// if (x > 3 && y <= 0)
|
|
|
-// {
|
|
|
-// b = false;
|
|
|
-// }
|
|
|
-// if (x <= 3 && y > 0)
|
|
|
-// {
|
|
|
-// b = false;
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-// b = false;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// if (b)
|
|
|
-// {
|
|
|
-// pointsF.Add(new PointF(x1, y1));
|
|
|
-//
|
|
|
-// if (pointsFF.containsKey(x1))
|
|
|
-// {
|
|
|
-// if (pointsFF[x1].Y < y1)
|
|
|
-// {
|
|
|
-// pointsFF[x1] = new PointF(x1, y1);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-// pointsFF.Add(x1, new PointF(x1, y1));
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// pointsF.Add(new PointF(0, 0));
|
|
|
-//
|
|
|
-// pointsF = pointsF.Where(it => it.X >= 3).OrderBy(it => it.X).ToList();
|
|
|
-//
|
|
|
-// var temp = MyMath.Line.BuildLine(pointsF.Select(it => (double)it.X).ToArray(), pointsF.Select(it => (double)it.Y).ToArray(), pointsF.Count, dimension, scale);
|
|
|
-//
|
|
|
-// myPoints.AddRange(temp);
|
|
|
-// if (myPoints != null && myPoints.Count != 0)
|
|
|
-// {
|
|
|
-// BuildMyPoints(myPoints, scale);
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// if (!pointsFF.containsKey(0))
|
|
|
-// pointsFF.Add(0, new PointF(0, 0));
|
|
|
-//
|
|
|
-// List<PointF> FF = pointsFF.Values.Where(it => it.X >= 3).OrderBy(it => it.X).ToList();
|
|
|
-// if (FF != null && FF.Count != 0)
|
|
|
-// {
|
|
|
-// temp = MyMath.Line.BuildLine(FF.Select(it => (double)it.X).ToArray(), FF.Select(it => (double)it.Y).ToArray(), FF.Count, dimension, scale);
|
|
|
-// }
|
|
|
-// myPointsFF.AddRange(temp);
|
|
|
-// if (myPointsFF != null && myPointsFF.Count != 0)
|
|
|
-// {
|
|
|
-// BuildMyPoints(myPointsFF, scale);
|
|
|
-// }
|
|
|
-//
|
|
|
-// myPoints = myPoints.Where(it => it.X >= 0 && it.X <= 25).OrderBy(it => it.X).ToList();
|
|
|
-//
|
|
|
-// myPointsFF = myPointsFF.Where(it => it.X >= 0 && it.X <= 25).OrderBy(it => it.X).ToList();
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// private static void BuildMyPoints(List<PointVo> myPoints, double scale)
|
|
|
-// {
|
|
|
-// int coefficient = 1;
|
|
|
-// int dec = 0;
|
|
|
-// int smax = 25;
|
|
|
-// if (scale == 0.01)
|
|
|
-// {
|
|
|
-// coefficient = 100;
|
|
|
-// dec = 2;
|
|
|
-// }
|
|
|
-// if (scale == 0.1)
|
|
|
-// {
|
|
|
-// coefficient = 10;
|
|
|
-// dec = 1;
|
|
|
-// }
|
|
|
-//
|
|
|
-// smax *= coefficient;
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// double min = myPoints.Min(it => it.X) * coefficient;
|
|
|
-// double max = myPoints.Max(it => it.X) * coefficient;
|
|
|
-//
|
|
|
-// double maxval = myPoints.Max(it => it.Y);
|
|
|
-//
|
|
|
-// for (double i = 0; i < min; i += 1)
|
|
|
-// {
|
|
|
-// PointVo point = new PointVo();
|
|
|
-// point.X = Math.Round(i / coefficient, dec);
|
|
|
-// point.Y = 0;
|
|
|
-// myPoints.Add(point);
|
|
|
-// }
|
|
|
-// //var tt = myPoints.Where(it => it.X == 3).ToList();
|
|
|
-//
|
|
|
-// //Console.WriteLine(tt);
|
|
|
-//
|
|
|
-// for (double i = smax; i > max; i -= 1)
|
|
|
-// {
|
|
|
-// PointVo point = new PointVo();
|
|
|
-// point.X = Math.Round(i / coefficient, dec);
|
|
|
-// point.Y = maxval;
|
|
|
-// myPoints.Add(point);
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// private static void BuildMyPoints2(List<PointVo> myPoints)
|
|
|
-// {
|
|
|
-// double min = myPoints.Min(it => it.X);
|
|
|
-// double max = myPoints.Max(it => it.X);
|
|
|
-//
|
|
|
-// double maxval = myPoints.Max(it => it.Y);
|
|
|
-//
|
|
|
-// for (int i = 0; i < min; i += 1)
|
|
|
-// {
|
|
|
-// PointVo point = new PointVo();
|
|
|
-// point.X = i;
|
|
|
-// point.Y = 0;
|
|
|
-// myPoints.Add(point);
|
|
|
-// }
|
|
|
-// //var tt = myPoints.Where(it => it.X == 3).ToList();
|
|
|
-//
|
|
|
-// //Console.WriteLine(tt);
|
|
|
-//
|
|
|
-// for (int i = 25; i > max; i -= 1)
|
|
|
-// {
|
|
|
-// PointVo point = new PointVo();
|
|
|
-// point.X = i;
|
|
|
-// point.Y = maxval;
|
|
|
-// myPoints.Add(point);
|
|
|
-// }
|
|
|
-// }
|
|
|
-//}
|
|
|
-//}
|
|
|
+package com.gyee.generation.service;
|
|
|
+
|
|
|
+import com.gyee.common.contant.Contant;
|
|
|
+import com.gyee.common.model.PointData;
|
|
|
+import com.gyee.generation.init.CacheContext;
|
|
|
+import com.gyee.generation.model.auto.*;
|
|
|
+import com.gyee.generation.model.vo.CureFitting;
|
|
|
+import com.gyee.generation.model.vo.PointVo;
|
|
|
+import com.gyee.generation.model.vo.PointfVo;
|
|
|
+import com.gyee.generation.service.auto.*;
|
|
|
+import com.gyee.generation.util.DateUtils;
|
|
|
+import com.gyee.generation.util.LineUtil;
|
|
|
+import com.gyee.generation.util.StringUtils;
|
|
|
+import com.gyee.generation.util.realtimesource.IEdosUtil;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class PowerCurveFittingService {
|
|
|
+
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(PowerCurveFittingService.class);
|
|
|
+ @Resource
|
|
|
+ private IEdosUtil edosUtil;
|
|
|
+
|
|
|
+ @Value("${curvefitting.dimension}")
|
|
|
+ private Integer dimension;
|
|
|
+ @Value("${curvefitting.scale}")
|
|
|
+ private Double scale;
|
|
|
+
|
|
|
+ public Map<String, Double> windturbineCapacity;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IProEconWtCurveFittingMonthService proEconWtCurveFittingMonthService;
|
|
|
+ @Resource
|
|
|
+ private IProEconWtCurveFittingService proEconWtCurveFittingService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IProEconCurveFittingMainService proEconCurveFittingMainService;
|
|
|
+ @Resource
|
|
|
+ private IProEconCurveFittingSubService proEconCurveFittingSubService;
|
|
|
+ @Resource
|
|
|
+ private IProEconCurveFittMonthMainService proEconCurveFittMonthMainService;
|
|
|
+ @Resource
|
|
|
+ private IProEconCurveFittMonthSubService proEconCurveFittMonthSubService;
|
|
|
+ @Resource
|
|
|
+ private IProEconWtPowerCurveFittingService proEconWtPowerCurveFittingService;
|
|
|
+
|
|
|
+
|
|
|
+ public void CureFitting(Date nowDate, Date begion, int insertType, String fdcId, List<String> fdjIds) throws Exception {
|
|
|
+
|
|
|
+ //日期变为昨天
|
|
|
+ Date current = DateUtils.addDays(DateUtils.truncDay(nowDate),-1);
|
|
|
+
|
|
|
+ Calendar c=Calendar.getInstance();
|
|
|
+ c.setTime(current);
|
|
|
+ int year = c.get(Calendar.YEAR);
|
|
|
+ int month = c.get(Calendar.MONTH)+1;
|
|
|
+ c.set(Calendar.DAY_OF_MONTH,1);
|
|
|
+ Date begin1 = c.getTime();
|
|
|
+
|
|
|
+ Date begin2 = DateUtils.addDays(current,-6);;
|
|
|
+
|
|
|
+ Date end = DateUtils.truncDay(nowDate);
|
|
|
+ if (begion.getTime() != new Date(0).getTime() && begion.getTime() != new Date(Long.MAX_VALUE).getTime())
|
|
|
+ {
|
|
|
+ begin1 = begion;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ int dimension = this.dimension;
|
|
|
+ double scale = this.scale;
|
|
|
+
|
|
|
+ //上个月
|
|
|
+ c.setTime(DateUtils.addMonths(begin1,-1));
|
|
|
+ int year2 = c.get(Calendar.YEAR);
|
|
|
+ int month2 = c.get(Calendar.MONTH)+1;
|
|
|
+
|
|
|
+ //去年同期
|
|
|
+ c.setTime(DateUtils.addYears(begin1,-1));
|
|
|
+ int year3 = c.get(Calendar.YEAR);
|
|
|
+ int month3 = c.get(Calendar.MONTH)+1;
|
|
|
+
|
|
|
+
|
|
|
+ Map<String, CureFitting> windMap = new HashMap<String, CureFitting>();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ List<ProBasicWindturbine> wtls = CacheContext.wtls;
|
|
|
+
|
|
|
+ if (windturbineCapacity == null)
|
|
|
+ {
|
|
|
+ windturbineCapacity = new HashMap<String, Double>();
|
|
|
+ Map<String, ProEconEquipmentmodel> modelMap = CacheContext.modelMap;
|
|
|
+ for (ProBasicWindturbine windturbine : wtls)
|
|
|
+ {
|
|
|
+ if (modelMap.containsKey(windturbine.getModelId()))
|
|
|
+ {
|
|
|
+ windturbineCapacity.put(windturbine.getId(), modelMap.get(windturbine.getModelId()).getPowerProduction());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (ProBasicWindturbine wt : wtls)
|
|
|
+ {
|
|
|
+ String windturbineId = wt.getId();
|
|
|
+ String windpowerId = wt.getWindpowerstationId();
|
|
|
+
|
|
|
+ if (StringUtils.notEmp(fdcId))
|
|
|
+ {
|
|
|
+ if (!fdcId.equals(windpowerId))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (fdjIds != null)
|
|
|
+ {
|
|
|
+ if (!fdjIds.contains(windturbineId))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, ProBasicEquipmentPoint> windturbinetestingpointnewMap = CacheContext.wtpAimap.get(wt.getId());
|
|
|
+
|
|
|
+ String pointIdGL =windturbinetestingpointnewMap.get(Contant.AI130).getCode();
|
|
|
+
|
|
|
+
|
|
|
+ String pointIdZT =windturbinetestingpointnewMap.get(Contant.ZTMX).getCode();
|
|
|
+
|
|
|
+ String pointIdFS = "";
|
|
|
+ if (wt.getWindpowerstationId().endsWith("GDC"))
|
|
|
+ {
|
|
|
+ pointIdFS = windturbinetestingpointnewMap.get(Contant.IRRAD).getCode();;
|
|
|
+
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ pointIdFS = windturbinetestingpointnewMap.get(Contant.AI022).getCode();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ CureFitting item = new CureFitting();
|
|
|
+
|
|
|
+ item.setPointIdFS(pointIdFS);
|
|
|
+ item.setPointIdZT(pointIdZT);
|
|
|
+ item.setPointIdGL(pointIdZT);
|
|
|
+ //获取标杆风机编号
|
|
|
+ if(CacheContext.wtstandardmap.containsKey(wt.getId()))
|
|
|
+ {
|
|
|
+ item.setStandardId(CacheContext.wtstandardmap.get(wt.getId()));
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ item.setStandardId(wt.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ windMap.put(windturbineId, item);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ for (String key : windMap.keySet())
|
|
|
+ {
|
|
|
+ windMap.get(key).setMyPoints1(new ArrayList<PointVo>());
|
|
|
+ windMap.get(key).setMyPointsFF1(new ArrayList<PointVo>());
|
|
|
+ windMap.get(key).setMyPoints2(new ArrayList<PointVo>());
|
|
|
+ windMap.get(key).setMyPointsFF2(new ArrayList<PointVo>());
|
|
|
+
|
|
|
+
|
|
|
+ if (windMap.get(key).getPointIdGL() == null || windMap.get(key).getPointIdFS() == null || windMap.get(key).getPointIdZT() == null)
|
|
|
+ {
|
|
|
+ System.out.println(key);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ curveFittingBuilder(begin1, end, dimension, scale, windMap.get(key).getPointIdGL(), windMap.get(key).getPointIdFS(), windMap.get(key).getPointIdZT(),windMap.get(key).getMyPoints1(), windMap.get(key).getMyPointsFF1(), key);
|
|
|
+ curveFittingBuilder(begin2, end, dimension, scale, windMap.get(key).getPointIdGL(), windMap.get(key).getPointIdFS(), windMap.get(key).getPointIdZT(), windMap.get(key).getMyPoints2(), windMap.get(key).getMyPointsFF2(), key);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (String key : windMap.keySet())
|
|
|
+ {
|
|
|
+
|
|
|
+ Double modelpower = 1500.0;
|
|
|
+ if (windturbineCapacity.containsKey(key))
|
|
|
+ {
|
|
|
+ modelpower = windturbineCapacity.get(key);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //月的上月
|
|
|
+ List<PointVo> monthPoints = new ArrayList<PointVo>();
|
|
|
+ //月的去年同期
|
|
|
+ List<PointVo> yearPoints = new ArrayList<PointVo>();
|
|
|
+ //月标准功率
|
|
|
+ List<PointVo> standardPoints = new ArrayList<PointVo>();
|
|
|
+
|
|
|
+
|
|
|
+ //日的昨天
|
|
|
+ List<PointVo> monthdayPoints = new ArrayList<PointVo>();
|
|
|
+ //日的去年同期
|
|
|
+ List<PointVo> yeardayPoints = new ArrayList<PointVo>();
|
|
|
+ //日标准功率
|
|
|
+ List<PointVo> standarddayPoints = new ArrayList<PointVo>();
|
|
|
+
|
|
|
+ //保证功率
|
|
|
+ List<PointVo> powerPoints = new ArrayList<PointVo>();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (CacheContext.wtstandardmap.containsKey(key))
|
|
|
+ {
|
|
|
+ String standardId =CacheContext.wtstandardmap.get(key);
|
|
|
+ if (StringUtils.notEmp(standardId))
|
|
|
+ {
|
|
|
+ if (windMap.containsKey(key))
|
|
|
+ {
|
|
|
+ standardPoints = windMap.get(standardId).getMyPoints1();
|
|
|
+ standarddayPoints =windMap.get(standardId).getMyPoints2();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String stringyear = String.valueOf(year);
|
|
|
+ String stringmonth = String.valueOf(month);
|
|
|
+
|
|
|
+ String stringyear2 =String.valueOf(year2);
|
|
|
+ String stringmonth2 = String.valueOf(month2);
|
|
|
+
|
|
|
+ String stringyear3 = String.valueOf(year3);
|
|
|
+ String stringmonth3 = String.valueOf(month3);
|
|
|
+
|
|
|
+
|
|
|
+ List<ProEconWtCurveFittingMonth> wcfmls=proEconWtCurveFittingMonthService.list().stream().filter(i->i.getWindturbineId().equals(key) &&
|
|
|
+ i.getYear().equals(stringyear2) && i.getMonth().equals(stringmonth2)).collect(Collectors.toList());
|
|
|
+ wcfmls.sort(Comparator.comparing(ProEconWtCurveFittingMonth::getSpeed));
|
|
|
+
|
|
|
+
|
|
|
+ monthBuildPoints(wcfmls, monthPoints);
|
|
|
+ wcfmls = null;
|
|
|
+
|
|
|
+ wcfmls=proEconWtCurveFittingMonthService.list().stream().filter(i->i.getWindturbineId().equals(key) &&
|
|
|
+ i.getYear().equals(stringyear3) && i.getMonth().equals(stringmonth3)).collect(Collectors.toList());
|
|
|
+ wcfmls.sort(Comparator.comparing(ProEconWtCurveFittingMonth::getSpeed));
|
|
|
+
|
|
|
+ monthBuildPoints(wcfmls, yearPoints);
|
|
|
+
|
|
|
+ Date d1 = DateUtils.addDays(current,-1);
|
|
|
+ Date d2 = DateUtils.addDays(current,-1);
|
|
|
+
|
|
|
+ List<ProEconWtCurveFitting> wcfls=proEconWtCurveFittingService.list().stream().filter(i->i.getWindturbineId().equals(key) &&
|
|
|
+ i.getRecordDate().compareTo(d1)==0).collect(Collectors.toList());
|
|
|
+
|
|
|
+
|
|
|
+ dayBuildPoints(wcfls, monthdayPoints);
|
|
|
+
|
|
|
+ wcfls = null;
|
|
|
+ wcfls=proEconWtCurveFittingService.list().stream().filter(i->i.getWindturbineId().equals(key) &&
|
|
|
+ i.getRecordDate().compareTo(d2)==0).collect(Collectors.toList());
|
|
|
+
|
|
|
+
|
|
|
+ dayBuildPoints(wcfls, monthPoints);
|
|
|
+
|
|
|
+ if (CacheContext.wtmap.containsKey(key))
|
|
|
+ {
|
|
|
+ String modelid = CacheContext.wtmap.get(key).getModelId();
|
|
|
+ if (StringUtils.notEmp(modelid))
|
|
|
+ {
|
|
|
+ //获取模型功率曲线
|
|
|
+ if (CacheContext.modelpowermap.containsKey(modelid))
|
|
|
+ {
|
|
|
+ for (Double speed :CacheContext.modelpowermap.get(modelid).keySet())
|
|
|
+ {
|
|
|
+ PointVo point = new PointVo();
|
|
|
+ point.setX(speed);
|
|
|
+ point.setY(CacheContext.modelpowermap.get(modelid).get(speed).getEnsurePower());
|
|
|
+
|
|
|
+ powerPoints.add(point);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ Optional<ProEconCurveFittMonthMain> cfmmo= proEconCurveFittMonthMainService.list().stream().filter(i->i.getWindturbineId().equals(key)
|
|
|
+ && i.getYear().equals(stringyear) && i.getMonth().equals(stringmonth)).findFirst();
|
|
|
+ ProEconCurveFittMonthMain cfmm=null;
|
|
|
+ if(cfmmo.isPresent())
|
|
|
+ {
|
|
|
+ cfmm=cfmmo.get();
|
|
|
+ }
|
|
|
+ if (cfmm == null)
|
|
|
+ {
|
|
|
+ cfmm = new ProEconCurveFittMonthMain();
|
|
|
+ cfmm.setWindturbineId(key);
|
|
|
+ cfmm.setYear(String.valueOf(year));
|
|
|
+ cfmm.setMonth(String.valueOf(month));
|
|
|
+
|
|
|
+ proEconCurveFittMonthMainService.save(cfmm);
|
|
|
+ }
|
|
|
+ //月---实际/最优
|
|
|
+ cfmm.setDeviationRate1((Double)pcl(windMap.get(key).getMyPoints1(),windMap.get(key).getMyPointsFF1(), modelpower));
|
|
|
+ //月---实际/保证
|
|
|
+ cfmm.setDeviationRate2((Double)pcl(windMap.get(key).getMyPoints1(), powerPoints, modelpower));
|
|
|
+ //月---最优/保证
|
|
|
+ cfmm.setDeviationRate3 ((Double)pcl(windMap.get(key).getMyPointsFF1(), powerPoints, modelpower));
|
|
|
+ //月---实际/上月实际
|
|
|
+ cfmm.setMonthDeviationRate( (Double)pcl(windMap.get(key).getMyPoints1(), monthPoints, modelpower));
|
|
|
+ //月---实际/同期实际
|
|
|
+ cfmm.setYearDeviationRate( (Double)pcl(windMap.get(key).getMyPoints1(), yearPoints, modelpower));
|
|
|
+ //月---实际/标杆实际
|
|
|
+ cfmm.setStandardDeviationRate((Double)pcl(windMap.get(key).getMyPoints1(), standardPoints, modelpower));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ Optional<ProEconCurveFittingMain> cfmo= proEconCurveFittingMainService.list().stream().filter(i->i.getWindturbineId().equals(key)
|
|
|
+ && i.getRecordDate().compareTo(current)==0).findFirst();
|
|
|
+ ProEconCurveFittingMain cfm=null;
|
|
|
+
|
|
|
+ if(cfmo.isPresent())
|
|
|
+ {
|
|
|
+ cfm=cfmo.get();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (cfm == null)
|
|
|
+ {
|
|
|
+ cfm = new ProEconCurveFittingMain();
|
|
|
+ cfm.setWindturbineId(key);
|
|
|
+ cfm.setRecordDate(current);
|
|
|
+
|
|
|
+ proEconCurveFittingMainService.save(cfm);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ cfm.setDeviationRate2((Double)pcl(windMap.get(key).getMyPoints2(),windMap.get(key).getMyPointsFF2(), modelpower));
|
|
|
+ //日---实际/保证
|
|
|
+ cfm.setDeviationRate2((Double)pcl(windMap.get(key).getMyPoints2(), powerPoints, modelpower));
|
|
|
+ //日---最优/保证
|
|
|
+ cfm.setDeviationRate3 ((Double)pcl(windMap.get(key).getMyPointsFF2(), powerPoints, modelpower));
|
|
|
+ //日---实际/上日实际
|
|
|
+ cfm.setMonthDeviationRate( (Double)pcl(windMap.get(key).getMyPoints2(), monthPoints, modelpower));
|
|
|
+ //日---实际/同期实际
|
|
|
+ cfm.setYearDeviationRate( (Double)pcl(windMap.get(key).getMyPoints2(), yearPoints, modelpower));
|
|
|
+ //日---实际/标杆实际
|
|
|
+ cfm.setStandardDeviationRate((Double)pcl(windMap.get(key).getMyPoints2(), standardPoints, modelpower));
|
|
|
+
|
|
|
+ pLCBuild( key, stringyear, stringmonth, current, windMap, modelpower, 3, powerPoints, monthPoints, yearPoints, standardPoints, monthdayPoints, yeardayPoints, standarddayPoints);
|
|
|
+ pLCBuild( key, stringyear, stringmonth, current, windMap, modelpower, 4, powerPoints, monthPoints, yearPoints, standardPoints, monthdayPoints, yeardayPoints, standarddayPoints);
|
|
|
+ pLCBuild( key, stringyear, stringmonth, current, windMap, modelpower, 5, powerPoints, monthPoints, yearPoints, standardPoints, monthdayPoints, yeardayPoints, standarddayPoints);
|
|
|
+ pLCBuild( key, stringyear, stringmonth, current, windMap, modelpower, 6, powerPoints, monthPoints, yearPoints, standardPoints, monthdayPoints, yeardayPoints, standarddayPoints);
|
|
|
+ pLCBuild( key, stringyear, stringmonth, current, windMap, modelpower, 7, powerPoints, monthPoints, yearPoints, standardPoints, monthdayPoints, yeardayPoints, standarddayPoints);
|
|
|
+ pLCBuild( key, stringyear, stringmonth, current, windMap, modelpower, 8, powerPoints, monthPoints, yearPoints, standardPoints, monthdayPoints, yeardayPoints, standarddayPoints);
|
|
|
+ pLCBuild( key, stringyear, stringmonth, current, windMap, modelpower, 9, powerPoints, monthPoints, yearPoints, standardPoints, monthdayPoints, yeardayPoints, standarddayPoints);
|
|
|
+ pLCBuild( key, stringyear, stringmonth, current, windMap, modelpower, 10, powerPoints, monthPoints, yearPoints, standardPoints, monthdayPoints, yeardayPoints, standarddayPoints);
|
|
|
+ pLCBuild( key, stringyear, stringmonth, current, windMap, modelpower, 11, powerPoints, monthPoints, yearPoints, standardPoints, monthdayPoints, yeardayPoints, standarddayPoints);
|
|
|
+ pLCBuild( key, stringyear, stringmonth, current, windMap, modelpower, 12, powerPoints, monthPoints, yearPoints, standardPoints, monthdayPoints, yeardayPoints, standarddayPoints);
|
|
|
+ pLCBuild( key, stringyear, stringmonth, current, windMap, modelpower, 13, powerPoints, monthPoints, yearPoints, standardPoints, monthdayPoints, yeardayPoints, standarddayPoints);
|
|
|
+
|
|
|
+
|
|
|
+ if (insertType == 0)
|
|
|
+ {
|
|
|
+ insertPoints(current, stringyear, stringmonth, windMap.get(key).getMyPoints1(), windMap.get(key).getMyPointsFF1(),windMap.get(key).getMyPoints2(), windMap.get(key).getMyPointsFF2(), key);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ insertPoints2(current, stringyear, stringmonth, windMap.get(key).getMyPoints1(),windMap.get(key).getMyPointsFF1(), windMap.get(key).getMyPoints2(), windMap.get(key).getMyPointsFF2(), key);
|
|
|
+ }
|
|
|
+ System.out.println(key);
|
|
|
+//
|
|
|
+// log.info(String.format("{1}:更新sqlserver数据库记录数:{0}", z, new Date()));
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void pLCBuild( String key, String stringyear, String stringmonth, Date current, Map<String, CureFitting> windMap, Double modelpower, double speed,
|
|
|
+ List<PointVo> powerPoints, List<PointVo> monthPoints, List<PointVo> yearPoints, List<PointVo> standardPoints, List<PointVo> monthdayPoints, List<PointVo> yeardayPoints, List<PointVo> standarddayPoints)
|
|
|
+ {
|
|
|
+
|
|
|
+ String speedStr = String.valueOf(speed);
|
|
|
+
|
|
|
+
|
|
|
+ Optional<ProEconCurveFittMonthSub> cfmmso= proEconCurveFittMonthSubService.list().stream().filter(i->i.getWindturbineId().equals(key)
|
|
|
+ && i.getYear().equals(stringyear) && i.getMonth().equals(stringmonth) && i.getSpeed().equals(speedStr)).findFirst();
|
|
|
+ ProEconCurveFittMonthSub cfmms=null;
|
|
|
+
|
|
|
+ if(cfmmso.isPresent())
|
|
|
+ {
|
|
|
+ cfmms=cfmmso.get();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (cfmms == null)
|
|
|
+ {
|
|
|
+ cfmms = new ProEconCurveFittMonthSub();
|
|
|
+ cfmms.setWindturbineId(key);
|
|
|
+ cfmms.setYear(stringyear);
|
|
|
+ cfmms.setMonth(stringmonth);
|
|
|
+ cfmms.setSpeed(String.valueOf(speed));
|
|
|
+
|
|
|
+ proEconCurveFittMonthSubService.save(cfmms);
|
|
|
+ }
|
|
|
+
|
|
|
+ //月---实际/最优
|
|
|
+ cfmms.setDeviationRate1((Double)pcl2(windMap.get(key).getMyPoints1(),windMap.get(key).getMyPointsFF1(), modelpower, speed));
|
|
|
+ //月---实际/保证
|
|
|
+ cfmms.setDeviationRate2((Double)pcl2(windMap.get(key).getMyPoints1(), powerPoints, modelpower, speed));
|
|
|
+ //月---最优/保证
|
|
|
+ cfmms.setDeviationRate3 ((Double)pcl2(windMap.get(key).getMyPointsFF1(), powerPoints, modelpower, speed));
|
|
|
+ //月---实际/上月实际
|
|
|
+ cfmms.setMonthDeviationRate( (Double)pcl2(windMap.get(key).getMyPoints1(), monthPoints, modelpower, speed));
|
|
|
+ //月---实际/同期实际
|
|
|
+ cfmms.setYearDeviationRate( (Double)pcl2(windMap.get(key).getMyPoints1(), yearPoints, modelpower, speed));
|
|
|
+ //月---实际/标杆实际
|
|
|
+ cfmms.setStandardDeviationRate((Double)pcl2(windMap.get(key).getMyPoints1(), standardPoints, modelpower, speed));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ Optional<ProEconCurveFittingSub> cfmso= proEconCurveFittingSubService.list().stream().filter(i->i.getWindturbineId().equals(key)
|
|
|
+ && i.getRecordDate().compareTo(current) == 0 && i.getSpeed().equals(speedStr)).findFirst();
|
|
|
+ ProEconCurveFittingSub cfms=null;
|
|
|
+
|
|
|
+ if(cfmso.isPresent())
|
|
|
+ {
|
|
|
+ cfms=cfmso.get();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (cfms == null)
|
|
|
+ {
|
|
|
+ cfms = new ProEconCurveFittingSub();
|
|
|
+ cfms.setWindturbineId(key);
|
|
|
+ cfms.setSpeed(String.valueOf(speed));
|
|
|
+ cfms.setRecordDate(current);
|
|
|
+
|
|
|
+ proEconCurveFittingSubService.save(cfms);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ cfms.setDeviationRate2((Double)pcl2(windMap.get(key).getMyPoints2(),windMap.get(key).getMyPointsFF2(), modelpower, speed));
|
|
|
+ //日---实际/保证
|
|
|
+ cfms.setDeviationRate2((Double)pcl2(windMap.get(key).getMyPoints2(), powerPoints, modelpower, speed));
|
|
|
+ //日---最优/保证
|
|
|
+ cfms.setDeviationRate3 ((Double)pcl2(windMap.get(key).getMyPointsFF2(), powerPoints, modelpower, speed));
|
|
|
+ //日---实际/上日实际
|
|
|
+ cfms.setMonthDeviationRate( (Double)pcl2(windMap.get(key).getMyPoints2(), monthPoints, modelpower, speed));
|
|
|
+ //日---实际/同期实际
|
|
|
+ cfms.setYearDeviationRate( (Double)pcl2(windMap.get(key).getMyPoints2(), yearPoints, modelpower, speed));
|
|
|
+ //日---实际/标杆实际
|
|
|
+ cfms.setStandardDeviationRate((Double)pcl2(windMap.get(key).getMyPoints2(), standardPoints, modelpower, speed));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void insertPoints(Date current, String year, String month, List<PointVo> pointsF1, List<PointVo> pointsFF1, List<PointVo> pointsF2, List<PointVo> pointsFF2, String windturbineId)
|
|
|
+ {
|
|
|
+
|
|
|
+ List<Integer> wtcfmidls=proEconWtCurveFittingMonthService.list().stream().filter(i->i.getWindturbineId().equals(windturbineId) &&
|
|
|
+ i.getYear().equals(year) && i.getMonth().equals(month)).map(i->i.getId()).collect(Collectors.toList());
|
|
|
+
|
|
|
+
|
|
|
+ for (int i = 0; i < wtcfmidls.size(); i++)
|
|
|
+ {
|
|
|
+ proEconWtCurveFittingMonthService.removeByIds(wtcfmidls);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pointsF1.size() == pointsFF1.size())
|
|
|
+ {
|
|
|
+ for (int i = 0; i < pointsF1.size(); i++)
|
|
|
+ {
|
|
|
+ ProEconWtCurveFittingMonth item = new ProEconWtCurveFittingMonth();
|
|
|
+
|
|
|
+ item.setWindturbineId(windturbineId);
|
|
|
+ if(CacheContext.wtmap.containsKey(windturbineId))
|
|
|
+ {
|
|
|
+ ProBasicWindturbine wt=CacheContext.wtmap.get(windturbineId);
|
|
|
+ if (wt.getWindpowerstationId().endsWith("GDC"))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ // item.SPEED = Double.Truncate((Double)pointsF1[i].X);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ item.setSpeed(pointsF1.get(i).getX());
|
|
|
+
|
|
|
+ }
|
|
|
+ item.setActualPower(pointsF1.get(i).getY());
|
|
|
+ item.setOptimalPower(pointsFF1.get(i).getY());
|
|
|
+ item.setYear(String.valueOf(year));
|
|
|
+ item.setMonth(String.valueOf(month));
|
|
|
+
|
|
|
+ proEconWtCurveFittingMonthService.save(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ log.warn(String.format("下标不一致的风机编号:{0},实际功率:{1},最有功率:{2}", windturbineId, pointsF1.size(), pointsFF1.size()));
|
|
|
+
|
|
|
+
|
|
|
+ for (int i = 0; i < pointsF1.size(); i++)
|
|
|
+ {
|
|
|
+ ProEconWtCurveFittingMonth item = new ProEconWtCurveFittingMonth();
|
|
|
+ item.setWindturbineId(windturbineId);
|
|
|
+ if(CacheContext.wtmap.containsKey(windturbineId)) {
|
|
|
+
|
|
|
+ ProBasicWindturbine wt=CacheContext.wtmap.get(windturbineId);
|
|
|
+ if (wt.getWindpowerstationId().endsWith("GDC"))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ //item.SPEED = Double.Truncate((Double)pointsF1[i].X);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+ item.setSpeed(pointsF1.get(i).getX());
|
|
|
+ }
|
|
|
+ item.setActualPower(pointsF1.get(i).getY());
|
|
|
+
|
|
|
+ int finalI = i;
|
|
|
+ OptionalDouble op=pointsFF1.stream().filter(x->x.getX() ==pointsF1.get(finalI).getX()).mapToDouble(x->x.getY()).findFirst();
|
|
|
+
|
|
|
+ if(op.isPresent())
|
|
|
+ {
|
|
|
+ item.setOptimalPower(op.getAsDouble());
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ item.setOptimalPower(0.0);
|
|
|
+ }
|
|
|
+
|
|
|
+ item.setYear(String.valueOf(year));
|
|
|
+ item.setMonth(String.valueOf(month));
|
|
|
+
|
|
|
+ proEconWtCurveFittingMonthService.save(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ List<Integer> wtcfidls=proEconWtCurveFittingService.list().stream().filter(i->i.getWindturbineId().equals(windturbineId) &&
|
|
|
+ i.getRecordDate().compareTo(current)==0).map(i->i.getId()).collect(Collectors.toList());
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ for (int i = 0; i < wtcfidls.size(); i++)
|
|
|
+ {
|
|
|
+ proEconWtCurveFittingService.removeByIds(wtcfidls);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pointsF2.size() == pointsFF2.size())
|
|
|
+ {
|
|
|
+ for (int i = 0; i < pointsF2.size(); i++)
|
|
|
+ {
|
|
|
+ ProEconWtCurveFitting item = new ProEconWtCurveFitting();
|
|
|
+ item.setWindturbineId(windturbineId);
|
|
|
+
|
|
|
+ if(CacheContext.wtmap.containsKey(windturbineId)) {
|
|
|
+ ProBasicWindturbine wt=CacheContext.wtmap.get(windturbineId);
|
|
|
+ if (wt.getWindpowerstationId().endsWith("GDC"))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ // item.SPEED = Double.Truncate((Double)pointsF2[i].X);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ boolean l =String.valueOf( pointsF2.get(i).getX()).contains(".");
|
|
|
+ if (l)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ item.setSpeed( pointsF2.get(i).getX());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ item.setActualPower(pointsF2.get(i).getY());
|
|
|
+ item.setOptimalPower(pointsFF2.get(i).getY());
|
|
|
+ item.setRecordDate(current);
|
|
|
+
|
|
|
+ proEconWtCurveFittingService.save(item);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ log.warn(String.format("下标不一致的风机编号:{0},实际功率:{1},最有功率:{2}", windturbineId, pointsF2.size(), pointsFF2.size()));
|
|
|
+
|
|
|
+ for (int i = 0; i < pointsF2.size(); i++)
|
|
|
+ {
|
|
|
+ ProEconWtCurveFitting item = new ProEconWtCurveFitting();
|
|
|
+ item.setWindturbineId(windturbineId);
|
|
|
+
|
|
|
+ if(CacheContext.wtmap.containsKey(windturbineId)) {
|
|
|
+ ProBasicWindturbine wt=CacheContext.wtmap.get(windturbineId);
|
|
|
+ if (wt.getWindpowerstationId().endsWith("GDC"))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ //item.SPEED = Double.Truncate((Double)pointsF2[i].X);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ boolean l =String.valueOf( pointsF2.get(i).getX()).contains(".");
|
|
|
+ if (l)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ item.setSpeed( pointsF2.get(i).getX());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ int finalI = i;
|
|
|
+ OptionalDouble op=pointsFF2.stream().filter(x->x.getX() ==pointsF2.get(finalI).getX()).mapToDouble(x->x.getY()).findFirst();
|
|
|
+
|
|
|
+ if(op.isPresent())
|
|
|
+ {
|
|
|
+ item.setOptimalPower(op.getAsDouble());
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ item.setOptimalPower(0.0);
|
|
|
+ }
|
|
|
+
|
|
|
+ item.setActualPower(pointsF2.get(i).getY());
|
|
|
+ item.setRecordDate(current);
|
|
|
+ proEconWtCurveFittingService.save(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private void insertPoints2(Date current, String year, String month, List<PointVo> pointsF1, List<PointVo> pointsFF1, List<PointVo> pointsF2, List<PointVo> pointsFF2, String windturbineId)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ List<Integer> wtpcfidls=proEconWtPowerCurveFittingService.list().stream().filter(i->i.getWindturbineId().equals(windturbineId)).map(i->i.getId()).collect(Collectors.toList());
|
|
|
+
|
|
|
+
|
|
|
+ for (int i = 0; i < wtpcfidls.size(); i++)
|
|
|
+ {
|
|
|
+ proEconWtPowerCurveFittingService.removeByIds(wtpcfidls);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pointsF1.size() == pointsFF1.size())
|
|
|
+ {
|
|
|
+ for (int i = 0; i < pointsF1.size(); i++)
|
|
|
+ {
|
|
|
+ ProEconWtPowerCurveFitting item = new ProEconWtPowerCurveFitting();
|
|
|
+
|
|
|
+ item.setWindturbineId(windturbineId);
|
|
|
+
|
|
|
+ if(CacheContext.wtmap.containsKey(windturbineId)) {
|
|
|
+
|
|
|
+ ProBasicWindturbine wt=CacheContext.wtmap.get(windturbineId);
|
|
|
+ if (wt.getWindpowerstationId().endsWith("GDC"))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ // item.SPEED = Double.Truncate((Double)pointsF1[i].X);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ boolean l =String.valueOf( pointsF1.get(i).getX()).contains(".");
|
|
|
+ if (l)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ item.setSpeed( pointsF1.get(i).getX());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ item.setActualPower(pointsF1.get(i).getY());
|
|
|
+ item.setOptimalPower(pointsFF1.get(i).getY());
|
|
|
+
|
|
|
+
|
|
|
+ proEconWtPowerCurveFittingService.save(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+ log.warn(String.format("下标不一致的风机编号:{0},实际功率:{1},最有功率:{2}", windturbineId, pointsF1.size(), pointsFF1.size()));
|
|
|
+
|
|
|
+ for (int i = 0; i < pointsF1.size(); i++)
|
|
|
+ {
|
|
|
+ ProEconWtPowerCurveFitting item = new ProEconWtPowerCurveFitting();
|
|
|
+
|
|
|
+ item.setWindturbineId(windturbineId);
|
|
|
+
|
|
|
+ if(CacheContext.wtmap.containsKey(windturbineId)) {
|
|
|
+
|
|
|
+ ProBasicWindturbine wt=CacheContext.wtmap.get(windturbineId);
|
|
|
+ if (wt.getWindpowerstationId().endsWith("GDC"))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ //item.SPEED = Double.Truncate((Double)pointsF1[i].X);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ boolean l =String.valueOf( pointsF1.get(i).getX()).contains(".");
|
|
|
+ if (l)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ item.setSpeed( pointsF1.get(i).getX());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ item.setActualPower(pointsF1.get(i).getY());
|
|
|
+ int finalI = i;
|
|
|
+ OptionalDouble op=pointsFF1.stream().filter(x->x.getX() ==pointsF1.get(finalI).getX()).mapToDouble(x->x.getY()).findFirst();
|
|
|
+
|
|
|
+ if(op.isPresent())
|
|
|
+ {
|
|
|
+ item.setOptimalPower(op.getAsDouble());
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ item.setOptimalPower(0.0);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ proEconWtPowerCurveFittingService.save(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void monthBuildPoints(List<ProEconWtCurveFittingMonth> data, List<PointVo> points)
|
|
|
+ {
|
|
|
+ if (data != null)
|
|
|
+ {
|
|
|
+ for (int i = 0; i < data.size(); i++)
|
|
|
+ {
|
|
|
+ PointVo point = new PointVo();
|
|
|
+ point.setX(data.get(i).getSpeed());
|
|
|
+ point.setY(data.get(i).getActualPower());
|
|
|
+ points.add(point);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void dayBuildPoints(List<ProEconWtCurveFitting> data, List<PointVo> points)
|
|
|
+ {
|
|
|
+ if (data != null)
|
|
|
+ {
|
|
|
+ for (int i = 0; i < data.size(); i++)
|
|
|
+ {
|
|
|
+ PointVo point = new PointVo();
|
|
|
+ point.setX(data.get(i).getSpeed());
|
|
|
+ point.setY(data.get(i).getActualPower());
|
|
|
+ points.add(point);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //曲线偏差率
|
|
|
+ private double pcl(List<PointVo> points1, List<PointVo> points2, Double modelpower)
|
|
|
+ {
|
|
|
+ double result = -0;
|
|
|
+ double pc = 0;
|
|
|
+ if (points1 != null && points1.size() != 0 && points2 != null && points2.size() != 0)
|
|
|
+ {
|
|
|
+ double count = 0;
|
|
|
+ double sum = 0;
|
|
|
+ double max = (double)modelpower;
|
|
|
+ for (PointVo point : points1)
|
|
|
+ {
|
|
|
+ List<PointVo> item = points2.stream().filter(it -> it.getX() == point.getX()).collect(Collectors.toList());
|
|
|
+ if (item != null && item.size() > 0)
|
|
|
+ {
|
|
|
+ sum += Math.pow((point.getY() - item.get(0).getY()), 2);
|
|
|
+ count++;
|
|
|
+ pc += point.getY() - item.get(0).getY();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sum = Math.sqrt(sum);
|
|
|
+ count = Math.sqrt(count);
|
|
|
+ max = max * count;
|
|
|
+ if (max != 0)
|
|
|
+ {
|
|
|
+ result = sum / max * 100;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pc < 0)
|
|
|
+ {
|
|
|
+ result = 0 - result;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ //曲线偏差率2
|
|
|
+ private double pcl2(List<PointVo> points1, List<PointVo> points2, Double modelpower, double speed)
|
|
|
+ {
|
|
|
+ double minSpeed = speed;
|
|
|
+ double maxSpeed = minSpeed + 1;
|
|
|
+ double result = -0;
|
|
|
+ double pc = 0;
|
|
|
+ if (points1 != null && points1.size() != 0 && points2 != null && points2.size() != 0)
|
|
|
+ {
|
|
|
+ double count = 0;
|
|
|
+ double sum = 0;
|
|
|
+ double max = (double)modelpower;
|
|
|
+ for (PointVo point : points1)
|
|
|
+ {
|
|
|
+ List<PointVo> item = points2.stream().filter(it -> it.getX() == point.getX()).collect(Collectors.toList());
|
|
|
+ if (item != null && item.size() > 0)
|
|
|
+ {
|
|
|
+ sum += Math.pow((point.getY() - item.get(0).getY()), 2);
|
|
|
+ count++;
|
|
|
+ pc += point.getY() - item.get(0).getY();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sum = Math.sqrt(sum);
|
|
|
+ count = Math.sqrt(count);
|
|
|
+ max = max * count;
|
|
|
+ if (max != 0)
|
|
|
+ {
|
|
|
+ result = sum / max * 100;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pc < 0)
|
|
|
+ {
|
|
|
+ result = 0 - result;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //功率曲线拟合
|
|
|
+ public void curveFittingBuilder(Date begin, Date end, int dimension, double scale, String pointIdGL, String pointIdFS, String pointIdZT, List<PointVo> myPoints, List<PointVo> myPointsFF, String windturbineId) throws Exception {
|
|
|
+ double maxPower = (double)windturbineCapacity.get(windturbineId) * 1.3;
|
|
|
+ List<PointfVo> pointsF = new ArrayList<PointfVo>();
|
|
|
+ Map<Double, PointfVo> pointsFF = new HashMap<Double, PointfVo>();
|
|
|
+
|
|
|
+ if (end.after(begin))
|
|
|
+ {
|
|
|
+ if (StringUtils.notEmp(pointIdGL) && StringUtils.notEmp(pointIdFS))
|
|
|
+ {
|
|
|
+ List<PointData> glpoints =edosUtil.getHistoryDatasSnap(pointIdGL, begin.getTime()/1000, end.getTime()/1000,null,60l);
|
|
|
+ List<PointData> fspoints =edosUtil.getHistoryDatasSnap(pointIdFS, begin.getTime()/1000, end.getTime()/1000,null,60l);
|
|
|
+ List<PointData> ztpoints =edosUtil.getHistoryDatasSnap(pointIdZT, begin.getTime()/1000, end.getTime()/1000,null,60l);
|
|
|
+
|
|
|
+
|
|
|
+ //var ztpoints2 = GoldenHelper.GetHisData(pointIdZT2, begin, end);
|
|
|
+
|
|
|
+ //Console.WriteLine(ztpoints2);
|
|
|
+
|
|
|
+
|
|
|
+ if (glpoints.size() != fspoints.size() || glpoints.size() != ztpoints.size())
|
|
|
+ {
|
|
|
+ for (int i = 0; i < fspoints.size(); i++)
|
|
|
+ {
|
|
|
+ double x =fspoints.get(i).getPointValueInDouble();
|
|
|
+ double y = -1;
|
|
|
+ double z = -1;
|
|
|
+ double z1 = -1;
|
|
|
+ int finalI1 = i;
|
|
|
+ List<PointData> yArray = glpoints.stream().filter(it -> it.getPointTime().compareTo(fspoints.get(finalI1).getPointTime())==0 ).collect(Collectors.toList());
|
|
|
+ if (yArray != null && yArray.size() > 0)
|
|
|
+ {
|
|
|
+
|
|
|
+ y = yArray.get(i).getPointValueInDouble();
|
|
|
+ }
|
|
|
+
|
|
|
+ int finalI = i;
|
|
|
+ yArray = ztpoints.stream().filter(it -> it.getPointTime().compareTo(fspoints.get(finalI).getPointTime())==0 ).collect(Collectors.toList());
|
|
|
+ if (yArray != null && yArray.size() > 0)
|
|
|
+ {
|
|
|
+
|
|
|
+ z = yArray.get(i).getPointValueInDouble();
|
|
|
+ }
|
|
|
+
|
|
|
+ //yArray = ztpoints2.Where(it => it.time == fspoints[i].time).ToList();
|
|
|
+ //if (yArray != null && yArray.size() > 0)
|
|
|
+ //{
|
|
|
+ // z1 = double.Parse(yArray[0].value.ToString());
|
|
|
+ //}
|
|
|
+
|
|
|
+ Double x1 = StringUtils.round (x,2);
|
|
|
+ Double y1 = (Double)y;
|
|
|
+
|
|
|
+
|
|
|
+ boolean b = true;
|
|
|
+
|
|
|
+ if(CacheContext.wtmap.containsKey(windturbineId)) {
|
|
|
+
|
|
|
+ ProBasicWindturbine wt=CacheContext.wtmap.get(windturbineId);
|
|
|
+ if (wt.getWindpowerstationId().endsWith("GDC"))
|
|
|
+ {
|
|
|
+ b = (x >= 0 && y > 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (z == 2)
|
|
|
+ {
|
|
|
+
|
|
|
+ b = (x >= 0 && x <= 30 && y >= 0 && y <= maxPower);
|
|
|
+
|
|
|
+ if (b)
|
|
|
+ {
|
|
|
+ if (x > 3 && y <= 0)
|
|
|
+ {
|
|
|
+ b = false;
|
|
|
+ }
|
|
|
+ if (x <= 3 && y > 0)
|
|
|
+ {
|
|
|
+ b = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ b = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (b)
|
|
|
+ {
|
|
|
+ pointsF.add(new PointfVo(x1, y1));
|
|
|
+
|
|
|
+ if (pointsFF.containsKey(x1))
|
|
|
+ {
|
|
|
+ if (pointsFF.get(x1).getY()< y1)
|
|
|
+ {
|
|
|
+ pointsFF.put(x1,new PointfVo(x1, y1));
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ pointsFF.put(x1, new PointfVo(x1, y1));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+ for (int i = 0; i < fspoints.size(); i++)
|
|
|
+ {
|
|
|
+ double x = fspoints.get(i).getPointValueInDouble();
|
|
|
+ double y = glpoints.get(i).getPointValueInDouble();
|
|
|
+ double z = ztpoints.get(i).getPointValueInDouble();
|
|
|
+ //double z1 = double.Parse(ztpoints2[i].value.ToString());
|
|
|
+
|
|
|
+ Double x1 =StringUtils.round (x,2);
|
|
|
+ Double y1 = (Double)y;
|
|
|
+
|
|
|
+
|
|
|
+ boolean b = true;
|
|
|
+ if(CacheContext.wtmap.containsKey(windturbineId)) {
|
|
|
+
|
|
|
+ ProBasicWindturbine wt=CacheContext.wtmap.get(windturbineId);
|
|
|
+ if (wt.getWindpowerstationId().endsWith("GDC"))
|
|
|
+ {
|
|
|
+ b = (x >= 0 && y > 0);
|
|
|
+ }else {
|
|
|
+ if (z == 2)
|
|
|
+ {
|
|
|
+
|
|
|
+ b = (x >= 0 && x <= 30 && y >= 0 && y <= maxPower);
|
|
|
+
|
|
|
+ if (b)
|
|
|
+ {
|
|
|
+ if (x > 3 && y <= 0)
|
|
|
+ {
|
|
|
+ b = false;
|
|
|
+ }
|
|
|
+ if (x <= 3 && y > 0)
|
|
|
+ {
|
|
|
+ b = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ b = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (b)
|
|
|
+ {
|
|
|
+ pointsF.add(new PointfVo(x1, y1));
|
|
|
+
|
|
|
+ if (pointsFF.containsKey(x1))
|
|
|
+ {
|
|
|
+ if (pointsFF.get(x1).getY()< y1)
|
|
|
+ {
|
|
|
+ pointsFF.put(x1,new PointfVo(x1, y1));
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ pointsFF.put(x1, new PointfVo(x1, y1));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ pointsF.add(new PointfVo(0.0, 0.0));
|
|
|
+
|
|
|
+ pointsF = pointsF.stream().filter(it -> it.getX()>= 3).sorted(Comparator.comparing(PointfVo::getX)).collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<PointVo> temp = LineUtil.buildLine(pointsF.stream().mapToDouble(i->i.getX()).toArray(), pointsF.stream().mapToDouble(i->i.getY()).toArray(), pointsF.size(), dimension, scale);
|
|
|
+
|
|
|
+ myPoints.addAll(temp);
|
|
|
+ if (myPoints != null && myPoints.size() != 0)
|
|
|
+ {
|
|
|
+ buildMyPoints(myPoints, scale);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (!pointsFF.containsKey(0))
|
|
|
+ pointsFF.put(0.0, new PointfVo(0.0, 0.0));
|
|
|
+
|
|
|
+ List<PointfVo> FF = pointsFF.values().stream().filter(it -> it.getX()>= 3).sorted(Comparator.comparing(PointfVo::getX)).collect(Collectors.toList());
|
|
|
+ if (FF != null && FF.size() != 0)
|
|
|
+ {
|
|
|
+ temp = LineUtil.buildLine(FF.stream().mapToDouble(i->i.getX()).toArray(), FF.stream().mapToDouble(i->i.getY()).toArray(), FF.size(), dimension, scale);
|
|
|
+ }
|
|
|
+ myPointsFF.addAll(temp);
|
|
|
+ if (myPointsFF != null && myPointsFF.size() != 0)
|
|
|
+ {
|
|
|
+ buildMyPoints(myPointsFF, scale);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ myPoints = myPoints.stream().filter(it -> it.getX()>= 0 && it.getX()<=25).sorted(Comparator.comparing(PointVo::getX)).collect(Collectors.toList());
|
|
|
+
|
|
|
+ myPointsFF = myPointsFF.stream().filter(it -> it.getX()>= 0 && it.getX()<=25).sorted(Comparator.comparing(PointVo::getX)).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void buildMyPoints(List<PointVo> myPoints, double scale)
|
|
|
+ {
|
|
|
+ int coefficient = 1;
|
|
|
+ int dec = 0;
|
|
|
+ int smax = 25;
|
|
|
+ if (scale == 0.01)
|
|
|
+ {
|
|
|
+ coefficient = 100;
|
|
|
+ dec = 2;
|
|
|
+ }
|
|
|
+ if (scale == 0.1)
|
|
|
+ {
|
|
|
+ coefficient = 10;
|
|
|
+ dec = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ smax *= coefficient;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ double min = myPoints.stream().min((a, b) ->a.getX().compareTo(b.getX())).get().getX() * coefficient;
|
|
|
+ double max = myPoints.stream().max((a, b) ->a.getX().compareTo(b.getX())).get().getX() * coefficient;
|
|
|
+
|
|
|
+ double maxval = myPoints.stream().max((a, b) ->a.getY().compareTo(b.getY())).get().getY();
|
|
|
+
|
|
|
+ for (double i = 0; i < min; i += 1)
|
|
|
+ {
|
|
|
+ PointVo point = new PointVo();
|
|
|
+ point.setX(StringUtils.round(i / coefficient, dec));
|
|
|
+ point.setY(0.0);
|
|
|
+
|
|
|
+ myPoints.add(point);
|
|
|
+ }
|
|
|
+ //var tt = myPoints.Where(it => it.X == 3).ToList();
|
|
|
+
|
|
|
+ //Console.WriteLine(tt);
|
|
|
+
|
|
|
+ for (double i = smax; i > max; i -= 1)
|
|
|
+ {
|
|
|
+ PointVo point = new PointVo();
|
|
|
+ point.setX(StringUtils.round(i / coefficient, dec));
|
|
|
+ point.setY(maxval);
|
|
|
+
|
|
|
+ myPoints.add(point);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void buildMyPoints2(List<PointVo> myPoints)
|
|
|
+ {
|
|
|
+
|
|
|
+ double min = myPoints.stream().min((a, b) ->a.getX().compareTo(b.getX())).get().getX() ;
|
|
|
+ double max = myPoints.stream().max((a, b) ->a.getX().compareTo(b.getX())).get().getX();
|
|
|
+
|
|
|
+ double maxval = myPoints.stream().max((a, b) ->a.getY().compareTo(b.getY())).get().getY();
|
|
|
+
|
|
|
+ for (int i = 0; i < min; i += 1)
|
|
|
+ {
|
|
|
+ PointVo point = new PointVo();
|
|
|
+ point.setX(Double.valueOf(i));
|
|
|
+ point.setY(0.0);
|
|
|
+
|
|
|
+ myPoints.add(point);
|
|
|
+ }
|
|
|
+ //var tt = myPoints.Where(it => it.X == 3).ToList();
|
|
|
+
|
|
|
+ //Console.WriteLine(tt);
|
|
|
+
|
|
|
+ for (int i = 25; i > max; i -= 1)
|
|
|
+ {
|
|
|
+
|
|
|
+ PointVo point = new PointVo();
|
|
|
+ point.setX(Double.valueOf(i));
|
|
|
+ point.setY(maxval);
|
|
|
+
|
|
|
+ myPoints.add(point);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|