|
@@ -0,0 +1,202 @@
|
|
|
|
+package com.gyee.generation.service;
|
|
|
|
+
|
|
|
|
+import com.gyee.benchmarkinghistroy.util.realtimesource.IEdosUtil;
|
|
|
|
+import com.gyee.common.contant.Contant;
|
|
|
|
+import com.gyee.common.model.PointData;
|
|
|
|
+import com.gyee.common.util.DateUtils;
|
|
|
|
+import com.gyee.generation.init.CacheContext;
|
|
|
|
+import com.gyee.generation.model.auto.*;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+import java.util.*;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @ClassName : AverageAndGeneratingService
|
|
|
|
+ * @Author : xieshengjie
|
|
|
|
+ * @Date: 2022/3/22 10:42
|
|
|
|
+ * @Description :
|
|
|
|
+ */
|
|
|
|
+@Service
|
|
|
|
+public class AverageAndGeneratingService {
|
|
|
|
+
|
|
|
|
+ private Date samedayZero;
|
|
|
|
+ private Date monthFirstZero;
|
|
|
|
+ private Date yearFirstZero;
|
|
|
|
+ private Date currentDate;
|
|
|
|
+ private List<Windpowerstation> wpls;
|
|
|
|
+ private Map<String, List<Project>> wppromap;
|
|
|
|
+ private Map<String, List<Line>> prolinemap;
|
|
|
|
+ private Map<String, List<Windturbine>> linewtmap;
|
|
|
|
+ private List<Windturbine> wtls;
|
|
|
|
+ private Map<String, Map<String, Windpowerstationpointnew>> wppointmap;
|
|
|
|
+ private Map<String, Map<String, Windpowerstationpointnew>> linepointmap;
|
|
|
|
+ private Map<String, Map<String, Windpowerstationpointnew>> propointmap;
|
|
|
|
+ private Map<String, Map<String, Windturbinetestingpointnew>> wtpAimap;
|
|
|
|
+ @Resource
|
|
|
|
+ private IEdosUtil edosUtil;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private void init(){
|
|
|
|
+ samedayZero = DateUtils.getSamedayZero();
|
|
|
|
+ monthFirstZero = DateUtils.getMonthFirstZero();
|
|
|
|
+ yearFirstZero = DateUtils.getYearFirstZero();
|
|
|
|
+ currentDate = DateUtils.getCurrentDate();
|
|
|
|
+ wpls = CacheContext.wpls;
|
|
|
|
+ wtls = CacheContext.wtls;
|
|
|
|
+ wppromap = CacheContext.wppromap;
|
|
|
|
+ prolinemap = CacheContext.prolinemap;
|
|
|
|
+ wppointmap = CacheContext.wppointmap;
|
|
|
|
+ linepointmap = CacheContext.linepointmap;
|
|
|
|
+ propointmap = CacheContext.propointmap;
|
|
|
|
+ wtpAimap = CacheContext.wtpAimap;
|
|
|
|
+ linewtmap = CacheContext.linewtmap;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 保存风速,功率实时计算点
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ public void saveAvespeedAndAvepowerAndScada() throws Exception {
|
|
|
|
+ init();
|
|
|
|
+ List<PointData> resultList = new ArrayList<>();
|
|
|
|
+ wpls.stream().forEach(wp->{
|
|
|
|
+ List<Project> projects = wppromap.get(wp.getId());
|
|
|
|
+ Map<String, Windpowerstationpointnew> wppointnewmap = wppointmap.get(wp.getId());
|
|
|
|
+ Windpowerstationpointnew wppointnew = wppointnewmap.get(Contant.RPJFS);
|
|
|
|
+ Windpowerstationpointnew powerwppointnew = wppointnewmap.get(Contant.RPJGL);
|
|
|
|
+ List<PointData> projectavespeedList = new ArrayList<>();
|
|
|
|
+ List<PointData> projectavepowerList = new ArrayList<>();
|
|
|
|
+ projects.stream().forEach(project -> {
|
|
|
|
+ List<Line> lines = prolinemap.get(project);
|
|
|
|
+ Map<String, Windpowerstationpointnew> projectpointnewmap = propointmap.get(project.getId());
|
|
|
|
+ Windpowerstationpointnew projectpointnew = projectpointnewmap.get(Contant.RPJFS);
|
|
|
|
+ Windpowerstationpointnew powerprojectpointnew = projectpointnewmap.get(Contant.RPJGL);
|
|
|
|
+ List<PointData> lineavespeedList = new ArrayList<>();
|
|
|
|
+ List<PointData> lineavepowerList = new ArrayList<>();
|
|
|
|
+ lines.stream().forEach(line -> {
|
|
|
|
+ List<Windturbine> windturbines = linewtmap.get(line.getId());
|
|
|
|
+ Map<String, Windpowerstationpointnew> linepointnewmap = linepointmap.get(line.getId());
|
|
|
|
+ Windpowerstationpointnew linepointnew = linepointnewmap.get(Contant.RPJFS);
|
|
|
|
+ Windpowerstationpointnew linepowerpointnew = linepointnewmap.get(Contant.RPJGL);
|
|
|
|
+ List<PointData> wtavespeedList = new ArrayList<>();
|
|
|
|
+ List<PointData> wtavepowerList = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ windturbines.stream().forEach(wt->{
|
|
|
|
+ Map<String, Windturbinetestingpointnew> windturbinetestingpointnewMap = wtpAimap.get(wt.getId());
|
|
|
|
+ Windturbinetestingpointnew aveSpeedPoint = windturbinetestingpointnewMap.get(Contant.RPJFS);
|
|
|
|
+ Windturbinetestingpointnew fjssfs = windturbinetestingpointnewMap.get(Contant.AI022);
|
|
|
|
+ Windturbinetestingpointnew avePowerPoint = windturbinetestingpointnewMap.get(Contant.RPJGL);
|
|
|
|
+ Windturbinetestingpointnew fjssgl = windturbinetestingpointnewMap.get(Contant.AI130);
|
|
|
|
+ try {
|
|
|
|
+ //算平均风速
|
|
|
|
+ List<PointData> ssfsList = edosUtil.getHistStat(fjssfs, samedayZero.getTime() / 1000, currentDate.getTime() / 1000, 1l, null, 2);
|
|
|
|
+ Optional<PointData> ssfsFirst = ssfsList.stream().findFirst();
|
|
|
|
+ if (ssfsFirst.isPresent()){
|
|
|
|
+ PointData pointData = ssfsFirst.get();
|
|
|
|
+ double inDouble = pointData.getPointValueInDouble();
|
|
|
|
+ pointData.setEdnaId(aveSpeedPoint.getCode());
|
|
|
|
+ pointData.setPointName(aveSpeedPoint.getName());
|
|
|
|
+ pointData.setPointValueInDouble(inDouble);
|
|
|
|
+ pointData.setPointValue(String.valueOf(inDouble));
|
|
|
|
+ pointData.setPointTime(currentDate.getTime());
|
|
|
|
+ wtavespeedList.add(pointData);
|
|
|
|
+ }
|
|
|
|
+ //算平均功率
|
|
|
|
+ List<PointData> ssglList = edosUtil.getHistStat(fjssgl, samedayZero.getTime() / 1000, currentDate.getTime() / 1000, 1l, null, 2);
|
|
|
|
+ Optional<PointData> ssglFirst = ssglList.stream().findFirst();
|
|
|
|
+ if (ssglFirst.isPresent()){
|
|
|
|
+ PointData pointData = ssglFirst.get();
|
|
|
|
+ double inDouble = pointData.getPointValueInDouble();
|
|
|
|
+ pointData.setEdnaId(avePowerPoint.getCode());
|
|
|
|
+ pointData.setPointName(avePowerPoint.getName());
|
|
|
|
+ pointData.setPointValueInDouble(inDouble);
|
|
|
|
+ pointData.setPointValue(String.valueOf(inDouble));
|
|
|
|
+ pointData.setPointTime(currentDate.getTime());
|
|
|
|
+ wtavepowerList.add(pointData);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ resultList.addAll(wtavespeedList);
|
|
|
|
+ resultList.addAll(wtavepowerList);
|
|
|
|
+ OptionalDouble average = wtavespeedList.stream().mapToDouble(PointData::getPointValueInDouble).average();
|
|
|
|
+ if (average.isPresent()){
|
|
|
|
+ double linespeed = average.getAsDouble();
|
|
|
|
+ PointData pointData = new PointData();
|
|
|
|
+ pointData.setEdnaId(linepointnew.getCode());
|
|
|
|
+ pointData.setPointTime(currentDate.getTime());
|
|
|
|
+ pointData.setPointName(linepointnew.getName());
|
|
|
|
+ pointData.setPointValue(String.valueOf(linespeed));
|
|
|
|
+ pointData.setPointValueInDouble(linespeed);
|
|
|
|
+ lineavespeedList.add(pointData);
|
|
|
|
+ }
|
|
|
|
+ OptionalDouble poweraverage = wtavepowerList.stream().mapToDouble(PointData::getPointValueInDouble).average();
|
|
|
|
+ if (poweraverage.isPresent()){
|
|
|
|
+ double linepower = poweraverage.getAsDouble();
|
|
|
|
+ PointData pointData = new PointData();
|
|
|
|
+ pointData.setEdnaId(linepowerpointnew.getCode());
|
|
|
|
+ pointData.setPointTime(currentDate.getTime());
|
|
|
|
+ pointData.setPointName(linepowerpointnew.getName());
|
|
|
|
+ pointData.setPointValue(String.valueOf(linepower));
|
|
|
|
+ pointData.setPointValueInDouble(linepower);
|
|
|
|
+ lineavepowerList.add(pointData);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ OptionalDouble average = lineavespeedList.stream().mapToDouble(PointData::getPointValueInDouble).average();
|
|
|
|
+ OptionalDouble poweraverage = lineavepowerList.stream().mapToDouble(PointData::getPointValueInDouble).average();
|
|
|
|
+ resultList.addAll(lineavespeedList);
|
|
|
|
+ resultList.addAll(lineavepowerList);
|
|
|
|
+ if (average.isPresent()){
|
|
|
|
+ double projectspeed = average.getAsDouble();
|
|
|
|
+ PointData pointData = new PointData();
|
|
|
|
+ pointData.setEdnaId(projectpointnew.getCode());
|
|
|
|
+ pointData.setPointTime(currentDate.getTime());
|
|
|
|
+ pointData.setPointName(projectpointnew.getName());
|
|
|
|
+ pointData.setPointValue(String.valueOf(projectspeed));
|
|
|
|
+ pointData.setPointValueInDouble(projectspeed);
|
|
|
|
+ projectavespeedList.add(pointData);
|
|
|
|
+ }
|
|
|
|
+ if (poweraverage.isPresent()){
|
|
|
|
+ double projectpower = poweraverage.getAsDouble();
|
|
|
|
+ PointData pointData = new PointData();
|
|
|
|
+ pointData.setEdnaId(powerprojectpointnew.getCode());
|
|
|
|
+ pointData.setPointTime(currentDate.getTime());
|
|
|
|
+ pointData.setPointName(powerprojectpointnew.getName());
|
|
|
|
+ pointData.setPointValue(String.valueOf(projectpower));
|
|
|
|
+ pointData.setPointValueInDouble(projectpower);
|
|
|
|
+ projectavepowerList.add(pointData);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ });
|
|
|
|
+ OptionalDouble average = projectavespeedList.stream().mapToDouble(PointData::getPointValueInDouble).average();
|
|
|
|
+ resultList.addAll(projectavespeedList);
|
|
|
|
+ if (average.isPresent()){
|
|
|
|
+ double wpspeed = average.getAsDouble();
|
|
|
|
+ PointData pointData = new PointData();
|
|
|
|
+ pointData.setEdnaId(wppointnew.getCode());
|
|
|
|
+ pointData.setPointTime(currentDate.getTime());
|
|
|
|
+ pointData.setPointName(wppointnew.getName());
|
|
|
|
+ pointData.setPointValue(String.valueOf(wpspeed));
|
|
|
|
+ pointData.setPointValueInDouble(wpspeed);
|
|
|
|
+ resultList.add(pointData);
|
|
|
|
+ }
|
|
|
|
+ OptionalDouble poweraverage = projectavepowerList.stream().mapToDouble(PointData::getPointValueInDouble).average();
|
|
|
|
+ resultList.addAll(projectavepowerList);
|
|
|
|
+ if (poweraverage.isPresent()){
|
|
|
|
+ double wppwer = poweraverage.getAsDouble();
|
|
|
|
+ PointData pointData = new PointData();
|
|
|
|
+ pointData.setEdnaId(powerwppointnew.getCode());
|
|
|
|
+ pointData.setPointTime(currentDate.getTime());
|
|
|
|
+ pointData.setPointName(powerwppointnew.getName());
|
|
|
|
+ pointData.setPointValue(String.valueOf(wppwer));
|
|
|
|
+ pointData.setPointValueInDouble(wppwer);
|
|
|
|
+ resultList.add(pointData);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ edosUtil.sendMultiPoint(resultList);
|
|
|
|
+ }
|
|
|
|
+}
|