|
@@ -0,0 +1,1379 @@
|
|
|
+package com.jiayue.biz.service;
|
|
|
+
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
+import com.jiayue.biz.domain.*;
|
|
|
+import com.jiayue.biz.dto.SpeedAndDensityDto;
|
|
|
+import com.jiayue.biz.eunms.WindDirectionEnum;
|
|
|
+import com.jiayue.biz.service.impl.WindDirectionStatisticsDataServiceImpl;
|
|
|
+import com.jiayue.biz.util.CalculationUtil;
|
|
|
+import com.jiayue.biz.util.DateTimeUtil;
|
|
|
+import com.jiayue.common.utils.DateUtil;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 风资源相关计算服务
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+@AllArgsConstructor
|
|
|
+public class WindDataCalculation2ServiceImpl implements WindDataCalculation2Service {
|
|
|
+ private final String tDay = "tDay";
|
|
|
+ private final String paDay = "paDay";
|
|
|
+ private final String airDensity = "airDensity";
|
|
|
+ private final String shearFunction = "shear";
|
|
|
+ private final String turbulenceFunction = "turbulence";
|
|
|
+ private final String wsFunction = "ws";
|
|
|
+ private final String wsDayFunction = "wsDay";
|
|
|
+ private final String wsMonthFunction = "wsMonth";
|
|
|
+ private final String wsMaxMonthFunction = "maxWsMonth";
|
|
|
+ private final String turbulenceDay = "turbulenceDay";
|
|
|
+ private final String staDay = "staDay";
|
|
|
+
|
|
|
+ private final String windShearFiledName = "windShear";
|
|
|
+ private final String windShearDayFiledName = "windShearDay";
|
|
|
+
|
|
|
+ private final BigDecimal zero = new BigDecimal(0);
|
|
|
+ private final WindDirectionStatisticsDataServiceImpl windDirectionStatisticsDataServiceImpl;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 统一计算
|
|
|
+ *
|
|
|
+ * @param dataList
|
|
|
+ * @param startDate
|
|
|
+ * @param endDate
|
|
|
+ * @param equipmentNo
|
|
|
+ * @param prophaseAnemometryDataList
|
|
|
+ * @param prophaseWeatherDataList
|
|
|
+ * @param equipmentAttributeMap
|
|
|
+ * @param windTowerCalculationDataList
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ArrayList<WindTowerCalculationData> calcu(ArrayList<WindTowerCalculationData> dataList, Date startDate, Date endDate, String equipmentNo
|
|
|
+ , List<ProphaseAnemometryData> prophaseAnemometryDataList, List<ProphaseWeatherData> prophaseWeatherDataList, Map<String, EquipmentAttribute> equipmentAttributeMap
|
|
|
+ , List<WindTowerCalculationData> windTowerCalculationDataList, WindTowerInfo windTowerInfo) throws Exception {
|
|
|
+
|
|
|
+ //获取对应测风塔数据
|
|
|
+ List<ProphaseAnemometryData> anemometryDataList = prophaseAnemometryDataList.stream().filter(p -> p.getTs().getTime() >= startDate.getTime()
|
|
|
+ && p.getTs().getTime() <= endDate.getTime() && null != p.getWsAve() && p.getWsAve() > 0 && p.getWsAve() < 30).collect(Collectors.toList());
|
|
|
+ List<ProphaseWeatherData> weatherDataList = prophaseWeatherDataList.stream().filter(p -> p.getTs().getTime() >= startDate.getTime()
|
|
|
+ && p.getTs().getTime() <= endDate.getTime() && null != p.getAirDensity() && p.getAirDensity() > 0).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //按层高分map
|
|
|
+ Map<String, List<ProphaseAnemometryData>> proAnemomentryDataHMap = anemometryDataList.stream().collect(Collectors.groupingBy(ProphaseAnemometryData::getLayerHeight));
|
|
|
+ Map<String, List<ProphaseWeatherData>> weatherDataHMap = weatherDataList.stream().collect(Collectors.groupingBy(x -> DateTimeUtil.getFormatDateStrForHH(x.getTs().getTime())));
|
|
|
+
|
|
|
+ //小时平均风速风功率密度
|
|
|
+ ArrayList<WindTowerCalculationData> wsAndWpdList = this.calculateWindPowerDensity(equipmentNo, proAnemomentryDataHMap, weatherDataHMap
|
|
|
+ , equipmentAttributeMap, windTowerInfo);
|
|
|
+ dataList.addAll(wsAndWpdList);
|
|
|
+ //每小时风切变指数
|
|
|
+ ArrayList<WindTowerCalculationData> windShearList = this.calculateWindPowerShear(equipmentNo, anemometryDataList, equipmentAttributeMap, windTowerInfo);
|
|
|
+ dataList.addAll(windShearList);
|
|
|
+
|
|
|
+ //计算日均
|
|
|
+ calcuForDay(dataList, equipmentNo, anemometryDataList, prophaseWeatherDataList, equipmentAttributeMap, windTowerCalculationDataList, windTowerInfo);
|
|
|
+ //计算月均
|
|
|
+ calcuForMonth(dataList, equipmentNo, anemometryDataList, weatherDataList
|
|
|
+ , equipmentAttributeMap, windTowerInfo);
|
|
|
+
|
|
|
+ //删除时间段所有数据
|
|
|
+ windDirectionStatisticsDataServiceImpl.removeByStartTimeBetweenAndEquipmentIdAndEbId(startDate, endDate, equipmentNo, "");
|
|
|
+ //月玫瑰图
|
|
|
+ roseMonth(equipmentNo, proAnemomentryDataHMap, weatherDataList, equipmentAttributeMap, windTowerInfo, anemometryDataList);
|
|
|
+
|
|
|
+ return dataList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 重算调用方法
|
|
|
+ *
|
|
|
+ * @param dataList
|
|
|
+ * @param startDate
|
|
|
+ * @param endDate
|
|
|
+ * @param equipmentNo
|
|
|
+ * @param prophaseAnemometryDataList
|
|
|
+ * @param prophaseWeatherDataList
|
|
|
+ * @param equipmentAttributeMap
|
|
|
+ * @param windTowerCalculationDataList
|
|
|
+ * @param windTowerInfo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ArrayList<WindTowerCalculationData> calcuRe(ArrayList<WindTowerCalculationData> dataList, Date startDate, Date endDate, String equipmentNo
|
|
|
+ , List<ProphaseAnemometryData> prophaseAnemometryDataList, List<ProphaseWeatherData> prophaseWeatherDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap, List<WindTowerCalculationData> windTowerCalculationDataList, WindTowerInfo windTowerInfo) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ArrayList<WindTowerCalculationData> calcuForDay(ArrayList<WindTowerCalculationData> dataList, String equipmentNo
|
|
|
+ , List<ProphaseAnemometryData> prophaseAnemometryDataList, List<ProphaseWeatherData> prophaseWeatherDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap, List<WindTowerCalculationData> windTowerCalculationDataList, WindTowerInfo windTowerInfo
|
|
|
+ ) {
|
|
|
+ //日平均(温度/气压/空气密度)
|
|
|
+ ArrayList<WindTowerCalculationData> tList = this.tAndPaAndAirDensityDay(equipmentNo, prophaseWeatherDataList, equipmentAttributeMap);
|
|
|
+ dataList.addAll(tList);
|
|
|
+
|
|
|
+ Map<String, List<ProphaseAnemometryData>> proAnemomentryDataDayMap = prophaseAnemometryDataList.stream().collect(Collectors.groupingBy(x -> DateTimeUtil.getFormatDateStrForDay(x.getTs().getTime())));
|
|
|
+ //发电量与满发小时数
|
|
|
+ ArrayList<WindTowerCalculationData> calculateBattery = this.calculateBattery(windTowerInfo, proAnemomentryDataDayMap, equipmentAttributeMap);
|
|
|
+ dataList.addAll(calculateBattery);
|
|
|
+ //日平均风切变
|
|
|
+ ArrayList<WindTowerCalculationData> windShearDay = this.shearDay(equipmentNo, equipmentAttributeMap, windTowerInfo, proAnemomentryDataDayMap);
|
|
|
+ dataList.addAll(windShearDay);
|
|
|
+ //日平均风速标差
|
|
|
+ ArrayList<WindTowerCalculationData> staDay = this.calculateStaDay(equipmentNo, prophaseAnemometryDataList, equipmentAttributeMap);
|
|
|
+ dataList.addAll(staDay);
|
|
|
+ //日平均风速
|
|
|
+ ArrayList<WindTowerCalculationData> wsDayList = this.wsDay(equipmentNo, dataList, equipmentAttributeMap, windTowerInfo);
|
|
|
+ dataList.addAll(wsDayList);
|
|
|
+ //日平均湍流
|
|
|
+ ArrayList<WindTowerCalculationData> turList = this.turbulenceDay(equipmentNo, equipmentAttributeMap, windTowerInfo, dataList);
|
|
|
+ dataList.addAll(turList);
|
|
|
+ //日平均风功率密度
|
|
|
+ ArrayList<WindTowerCalculationData> wpdDayList = this.wpdDay(equipmentNo, dataList, equipmentAttributeMap, windTowerInfo);
|
|
|
+ dataList.addAll(wpdDayList);
|
|
|
+
|
|
|
+ return dataList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ArrayList<WindTowerCalculationData> calcuForMonth(ArrayList<WindTowerCalculationData> dataList, String equipmentNo
|
|
|
+ , List<ProphaseAnemometryData> prophaseAnemometryDataList, List<ProphaseWeatherData> prophaseWeatherDataList, Map<String, EquipmentAttribute> equipmentAttributeMap
|
|
|
+ , WindTowerInfo windTowerInfo) {
|
|
|
+ //月平均 数据计算
|
|
|
+ ArrayList<WindTowerCalculationData> wsMonth = this.avgMonth(equipmentNo, dataList, equipmentAttributeMap, windTowerInfo);
|
|
|
+ dataList.addAll(wsMonth);
|
|
|
+ //月平均风切变
|
|
|
+ ArrayList<WindTowerCalculationData> shearMonth = this.shearMonth(equipmentNo, equipmentAttributeMap, windTowerInfo, prophaseAnemometryDataList);
|
|
|
+ dataList.addAll(shearMonth);
|
|
|
+ //月平均风速标差
|
|
|
+ ArrayList<WindTowerCalculationData> staMonth = this.staMonth(equipmentNo, prophaseAnemometryDataList, equipmentAttributeMap);
|
|
|
+ dataList.addAll(staMonth);
|
|
|
+ //月平均环境数据
|
|
|
+ ArrayList<WindTowerCalculationData> environmentData = this.environmentData(equipmentNo, prophaseWeatherDataList, equipmentAttributeMap);
|
|
|
+ dataList.addAll(environmentData);
|
|
|
+
|
|
|
+ //月最大风速
|
|
|
+ ArrayList<WindTowerCalculationData> wsMaxMonth = this.wsMaxMonth(equipmentNo, prophaseAnemometryDataList, equipmentAttributeMap, windTowerInfo);
|
|
|
+ dataList.addAll(wsMaxMonth);
|
|
|
+
|
|
|
+ //空气密度月逐时
|
|
|
+ ArrayList<WindTowerCalculationData> airDensityMonth = this.airDensityMonth(equipmentNo, prophaseWeatherDataList, equipmentAttributeMap);
|
|
|
+ dataList.addAll(airDensityMonth);
|
|
|
+ //湍流月逐时
|
|
|
+ ArrayList<WindTowerCalculationData> turbulenceHourForMonth = this.turbulenceHourForMonth(equipmentNo, prophaseAnemometryDataList, equipmentAttributeMap);
|
|
|
+ dataList.addAll(turbulenceHourForMonth);
|
|
|
+ return dataList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 风功率密度和平均风速计算方法
|
|
|
+ */
|
|
|
+ public ArrayList<WindTowerCalculationData> calculateWindPowerDensity(String eqNo, Map<String, List<ProphaseAnemometryData>> proAnemomentryDataMap
|
|
|
+ , Map<String, List<ProphaseWeatherData>> weatherDataListMap
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap, WindTowerInfo windTowerInfo) {
|
|
|
+
|
|
|
+ String[] height = windTowerInfo.getHeights().split(",");
|
|
|
+ //定义数据空集合用来装载 结果数据
|
|
|
+ ArrayList<WindTowerCalculationData> list = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ //遍历出过滤出的平均风速属性
|
|
|
+ for (String h : height) {
|
|
|
+ EquipmentAttribute equipmentAttributeAws = equipmentAttributeMap.get(h + "aws");
|
|
|
+ EquipmentAttribute equipmentAttributeWpd = equipmentAttributeMap.get(h + "wpd");
|
|
|
+ if (null == equipmentAttributeAws || null == equipmentAttributeWpd) {
|
|
|
+ log.error("属性 {} 和 {} 信息查询失败,属性集合数量:{}", h + "aws", h + "wpd", equipmentAttributeMap.size());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //当前层高的所有数据
|
|
|
+ List<ProphaseAnemometryData> anemometryDataOneHList = proAnemomentryDataMap.get(h);
|
|
|
+ if (null != anemometryDataOneHList && !anemometryDataOneHList.isEmpty()) {
|
|
|
+ Map<String, List<ProphaseAnemometryData>> proAnemomentryOneHDataMap = anemometryDataOneHList.stream()
|
|
|
+ .collect(Collectors.groupingBy(x -> DateTimeUtil.getFormatDateStrForHH(x.getTs().getTime())));
|
|
|
+
|
|
|
+ proAnemomentryOneHDataMap.forEach((key, anemometryData) -> {
|
|
|
+ //根据层高获取所有风速数据
|
|
|
+ List<BigDecimal> bigDecimals = anemometryData.stream().map((ProphaseAnemometryData p) -> {
|
|
|
+ return BigDecimal.valueOf(p.getWsAve());
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //风速数据时所有计算的根本,无数据不计算
|
|
|
+ if (null == bigDecimals || bigDecimals.isEmpty()) {
|
|
|
+ log.error("计算 {} 设备 层高:{} 小时:{} 的 平均风速和风功率密度 无有效数据", eqNo, h, key);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //环境数据过滤
|
|
|
+ List<ProphaseWeatherData> weatherData = weatherDataListMap.get(key);
|
|
|
+
|
|
|
+ if (null != weatherData && weatherData.size() > 0) {
|
|
|
+
|
|
|
+ SpeedAndDensityDto speedAndDensityDto = getSpeedAndDensityDto(bigDecimals, anemometryData, weatherData);
|
|
|
+ Date dataTime = DateUtil.parse(key + ":00:00");
|
|
|
+ if (speedAndDensityDto.getWindPowerDensity().compareTo(BigDecimal.ZERO) < 0 ||
|
|
|
+ speedAndDensityDto.getWindSpeed().compareTo(BigDecimal.ZERO) < 0) {
|
|
|
+ log.error("计算风功率密度/平均风速出现异常值 平均风速:{} 风功率密度:{};时间:{} ;设备编号:{}", speedAndDensityDto.getWindSpeed(), speedAndDensityDto.getWindPowerDensity(), dataTime, eqNo);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //保存平均风速
|
|
|
+ list.add(new WindTowerCalculationData(dataTime, eqNo, equipmentAttributeAws.getId(), speedAndDensityDto.getWindSpeed()));
|
|
|
+ //保存风功率密度
|
|
|
+ list.add(new WindTowerCalculationData(dataTime, eqNo, equipmentAttributeWpd.getId(), speedAndDensityDto.getWindPowerDensity()));
|
|
|
+ } else {
|
|
|
+ log.error("计算 {} 设备平均风速和风功率密度 未查询到 时间:{} 层高:{} 的环境数据", eqNo, key, h);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("计算{}设备平均风速和风功率密度失败!!!{}", eqNo, e);
|
|
|
+ }
|
|
|
+ log.info("计算{}设备平均风速和风功率密度完成^ ^", eqNo);
|
|
|
+
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算月平均风速标差
|
|
|
+ *
|
|
|
+ * @param equipmentId 设备id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ArrayList<WindTowerCalculationData> staMonth(String equipmentId, List<ProphaseAnemometryData> prophaseAnemometryDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap) {
|
|
|
+ ArrayList<WindTowerCalculationData> windTowerCalculationDataList = new ArrayList<>();
|
|
|
+ prophaseAnemometryDataList = prophaseAnemometryDataList.stream().filter(p -> null != p.getWsSta() && p.getWsSta() >= 0).collect(Collectors.toList());
|
|
|
+ Map<String, List<ProphaseAnemometryData>> collect = prophaseAnemometryDataList.stream().collect(Collectors.groupingBy(x -> DateTimeUtil.getFormatDateStrForMonth(x.getTs().getTime())));
|
|
|
+ collect.forEach((month, value) -> {
|
|
|
+
|
|
|
+ if (!value.isEmpty()) {
|
|
|
+ Map<String, List<ProphaseAnemometryData>> heightMap = value.stream()
|
|
|
+ .collect(Collectors.groupingBy(x -> x.getLayerHeight()));
|
|
|
+ heightMap.forEach((height, hvalue) -> {
|
|
|
+ try {
|
|
|
+ if (!hvalue.isEmpty()) {
|
|
|
+ EquipmentAttribute equipmentAttribute = equipmentAttributeMap.get(height + "staMonth");
|
|
|
+ BigDecimal sumSta = CalculationUtil.getBigDecimal(hvalue.stream().mapToDouble(ProphaseAnemometryData::getWsSta).sum());
|
|
|
+ BigDecimal valueAvgSta = sumSta.divide(new BigDecimal(collect.size()), 2, RoundingMode.HALF_UP);
|
|
|
+ windTowerCalculationDataList.add(new WindTowerCalculationData(DateUtil.parse(month + "-01 00:00:00"), equipmentId, equipmentAttribute.getId(), valueAvgSta));
|
|
|
+ } else {
|
|
|
+ log.warn("设备:{} 层高:{} 计算月平均风速标差 的数据为空", equipmentId, height);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备:{} 层高:{} 计算月平均风速标差 错误:{}", equipmentId, height, e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ log.warn("设备:{} 月份:{} 计算月平均风速标差 的数据为空", equipmentId, month);
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ return windTowerCalculationDataList;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 温湿度气压月 最大,均值
|
|
|
+ *
|
|
|
+ * @param equipmentId 设备id
|
|
|
+ * @param equipmentAttributeMap 属性集合
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ArrayList<WindTowerCalculationData> environmentData(String equipmentId
|
|
|
+ , List<ProphaseWeatherData> prophaseWeatherDataList, Map<String, EquipmentAttribute> equipmentAttributeMap) {
|
|
|
+ ArrayList<WindTowerCalculationData> windTowerCalculationDataList = new ArrayList<>();
|
|
|
+ try {
|
|
|
+
|
|
|
+ Map<String, List<ProphaseWeatherData>> monthListMap = prophaseWeatherDataList.stream()
|
|
|
+ .collect(Collectors.groupingBy(x -> DateTimeUtil.getFormatDateStrForMonth(x.getTs().getTime())));
|
|
|
+
|
|
|
+ monthListMap.forEach((month, value) -> {
|
|
|
+ if (value.isEmpty()) {
|
|
|
+ log.error("计算温湿度气压数据时,原数据{prophaseWeatherData}为空");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Date monthTime = DateUtil.parse(month + "-01 00:00:00");
|
|
|
+ List<BigDecimal> paList = new ArrayList<>();
|
|
|
+ List<BigDecimal> rhList = new ArrayList<>();
|
|
|
+ List<BigDecimal> tList = new ArrayList<>();
|
|
|
+ /*计算平均值数值为null 不计算*/
|
|
|
+ for (ProphaseWeatherData map : value) {
|
|
|
+ if (null != map.getPaAve() && map.getPaAve() > 0 && map.getPaAve() < 1200) {
|
|
|
+ paList.add(CalculationUtil.getBigDecimal(map.getPaAve()));
|
|
|
+ }
|
|
|
+ if (null != map.getRhAve() && map.getRhAve() > 0 && map.getRhAve() < 100) {
|
|
|
+ rhList.add(CalculationUtil.getBigDecimal(map.getRhAve()));
|
|
|
+ }
|
|
|
+ if (null != map.getTAve() && map.getTAve() >= -60 && map.getTAve() <= 60) {
|
|
|
+ tList.add(CalculationUtil.getBigDecimal(map.getTAve()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ commonCacuAveAndMaxAndMin(windTowerCalculationDataList, "t", tList, equipmentAttributeMap, monthTime, equipmentId);
|
|
|
+ commonCacuAveAndMaxAndMin(windTowerCalculationDataList, "rh", rhList, equipmentAttributeMap, monthTime, equipmentId);
|
|
|
+ commonCacuAveAndMaxAndMin(windTowerCalculationDataList, "pa", paList, equipmentAttributeMap, monthTime, equipmentId);
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return windTowerCalculationDataList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通用计算一组数据的 平均 最大 最小
|
|
|
+ *
|
|
|
+ * @param windTowerCalculationDataList
|
|
|
+ * @param dataFlagStr
|
|
|
+ * @param valueList
|
|
|
+ * @param equipmentAttributeMap
|
|
|
+ * @param monthTime
|
|
|
+ * @param equipmentId
|
|
|
+ */
|
|
|
+ private List<WindTowerCalculationData> commonCacuAveAndMaxAndMin(ArrayList<WindTowerCalculationData> windTowerCalculationDataList, String dataFlagStr, List<BigDecimal> valueList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap, Date monthTime, String equipmentId) {
|
|
|
+ BigDecimal sumRh = BigDecimal.ZERO;
|
|
|
+ BigDecimal aveRh = BigDecimal.ZERO;
|
|
|
+ /*湿度*/
|
|
|
+ BigDecimal maxRh = BigDecimal.ZERO;
|
|
|
+ BigDecimal minRh = BigDecimal.ZERO;
|
|
|
+ if (!valueList.isEmpty()) {
|
|
|
+ maxRh = valueList.stream().max(BigDecimal::compareTo).get();
|
|
|
+ minRh = valueList.stream().min(BigDecimal::compareTo).get();
|
|
|
+ for (BigDecimal rh : valueList) {
|
|
|
+ sumRh = sumRh.add(rh);
|
|
|
+ }
|
|
|
+ aveRh = sumRh.divide(new BigDecimal(valueList.size()), 2, RoundingMode.HALF_UP);
|
|
|
+ windTowerCalculationDataList.add(new WindTowerCalculationData(monthTime, equipmentId, equipmentAttributeMap.get(dataFlagStr + "MAX").getId(), maxRh));
|
|
|
+ windTowerCalculationDataList.add(new WindTowerCalculationData(monthTime, equipmentId, equipmentAttributeMap.get(dataFlagStr + "MIN").getId(), minRh));
|
|
|
+ windTowerCalculationDataList.add(new WindTowerCalculationData(monthTime, equipmentId, equipmentAttributeMap.get(dataFlagStr + "AVE").getId(), aveRh));
|
|
|
+ }
|
|
|
+
|
|
|
+ return windTowerCalculationDataList;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 湍流月逐时
|
|
|
+ *
|
|
|
+ * @param equipmentId 设备Id
|
|
|
+ * @param equipmentAttributeMap 属性集合
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ArrayList<WindTowerCalculationData> turbulenceHourForMonth(String equipmentId, List<ProphaseAnemometryData> prophaseAnemometryDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap) {
|
|
|
+
|
|
|
+ Map<String, List<ProphaseAnemometryData>> monthListMap = prophaseAnemometryDataList.stream().filter(p -> null != p.getWsAve() && null != p.getWsSta()
|
|
|
+ && p.getWsAve() >= 0 && p.getWsSta() >= 0 && p.getWsAve() <= 60 && p.getWsSta() <= 60)
|
|
|
+ .collect(Collectors.groupingBy(x -> DateTimeUtil.getFormatDateStrForMonth(x.getTs().getTime())));
|
|
|
+ ArrayList<WindTowerCalculationData> list = new ArrayList<>();
|
|
|
+ monthListMap.forEach((month, value) -> {
|
|
|
+ try {
|
|
|
+ if (!value.isEmpty()) {
|
|
|
+ //各层高集合
|
|
|
+ Map<String, List<ProphaseAnemometryData>> hListMap = value.stream()
|
|
|
+ .collect(Collectors.groupingBy(x -> x.getLayerHeight()));
|
|
|
+ //便利各层高数据
|
|
|
+ hListMap.forEach((height, collect) -> {
|
|
|
+ //获取湍流年逐时ebId
|
|
|
+ String ebId = equipmentAttributeMap.get(height + "turDayForMonth").getId();
|
|
|
+ //按小时分组 计算各小时数据
|
|
|
+ Map<String, List<ProphaseAnemometryData>> hourListMap = collect.stream()
|
|
|
+ .collect(Collectors.groupingBy(x -> DateTimeUtil.getFormatDateStrForHour(x.getTs().getTime())));
|
|
|
+ hourListMap.forEach((hour, dayList) -> {
|
|
|
+ try {
|
|
|
+ if (!dayList.isEmpty()) {
|
|
|
+ BigDecimal turAve = BigDecimal.ZERO;
|
|
|
+ //风速平均值
|
|
|
+ BigDecimal wsAvg = CalculationUtil.getBigDecimal(dayList.stream().mapToDouble(ProphaseAnemometryData::getWsAve).average().getAsDouble());
|
|
|
+ //风速标差平均值
|
|
|
+ BigDecimal wsStaAvg = CalculationUtil.getBigDecimal(dayList.stream().mapToDouble(ProphaseAnemometryData::getWsSta).average().getAsDouble());
|
|
|
+
|
|
|
+ turAve = wsStaAvg.divide(wsAvg, 2, BigDecimal.ROUND_UP);
|
|
|
+ if (turAve.doubleValue() >= 0) {
|
|
|
+ list.add(new WindTowerCalculationData(DateUtil.parse(month + "-01 " + hour + ":00:00"), equipmentId, ebId, turAve));
|
|
|
+ } else {
|
|
|
+ log.warn("计算逐时湍流强度错误,设备:{} 月份:{},层高:{} 小时:{} ", equipmentId, month, height, hour);
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ log.warn("计算逐时湍流强度无该小时的数据,设备:{} 月份:{},层高:{} 小时:{} ", equipmentId, month, height, hour);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("计算逐时湍流强度异常:{}", e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ log.error("计算设备:{} 月份:{} 无数据,无法计算 月最大风速", equipmentId, month);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备编号{}月最大风速计算错误:{}", equipmentId, e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 空气密度月逐时入库
|
|
|
+ *
|
|
|
+ * @param equipmentId 设备id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ArrayList<WindTowerCalculationData> airDensityMonth(String equipmentId, List<ProphaseWeatherData> prophaseWeatherDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap) {
|
|
|
+
|
|
|
+ ArrayList<WindTowerCalculationData> list = new ArrayList<>();
|
|
|
+ //获取ebId
|
|
|
+ String ebId = equipmentAttributeMap.get("airDensityDayForYear").getId();
|
|
|
+
|
|
|
+ try {
|
|
|
+ Map<String, List<ProphaseWeatherData>> monthListMap = prophaseWeatherDataList.stream()
|
|
|
+ .collect(Collectors.groupingBy(x -> DateTimeUtil.getFormatDateStrForMonth(x.getTs().getTime())));
|
|
|
+ monthListMap.forEach((month, value) -> {
|
|
|
+ try {
|
|
|
+ if (!value.isEmpty()) {
|
|
|
+ //按小时分组 计算各小时数据
|
|
|
+ Map<String, List<ProphaseWeatherData>> hourListMap = value.stream()
|
|
|
+ .collect(Collectors.groupingBy(x -> DateTimeUtil.getFormatDateStrForHour(x.getTs().getTime())));
|
|
|
+ hourListMap.forEach((hour, dayList) -> {
|
|
|
+ try {
|
|
|
+ if (null != dayList && !dayList.isEmpty()) {
|
|
|
+ //风速平均值
|
|
|
+ BigDecimal airDensityAvg = CalculationUtil.getBigDecimal(dayList.stream().mapToDouble(ProphaseWeatherData::getAirDensity).average().getAsDouble());
|
|
|
+
|
|
|
+ if (airDensityAvg.doubleValue() >= 0) {
|
|
|
+ list.add(new WindTowerCalculationData(DateUtil.parse(month + "-01 " + hour + ":00:00"), equipmentId, ebId, airDensityAvg));
|
|
|
+ } else {
|
|
|
+ log.warn("计算逐时空气密度错误,设备:{} 月份:{},层高:{} 小时:{} ", equipmentId, month, hour);
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ log.warn("计算逐时空气密度无该小时的数据,设备:{} 月份:{},层高:{} 小时:{} ", equipmentId, month, hour);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("计算逐时空气密度 设备:{} 月份:{} 小时:{} 异常:{} ", equipmentId, month, hour, e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ log.error("计算设备:{} 月份:{} 无数据,无法计算 空气密度", equipmentId, month);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("计算逐时空气密度 设备:{} 月份:{} 异常:{} ", equipmentId, month, e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备编号{},空气密度月逐时计算错误:{}", equipmentId, e);
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("设备编号{},空气密度月逐时,计算完成", equipmentId);
|
|
|
+ return list;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算日平均 温度/气压/空气密度
|
|
|
+ *
|
|
|
+ * @param equipmentId 设备Id
|
|
|
+ * @param equipmentAttributeMap 属性集合
|
|
|
+ */
|
|
|
+ public ArrayList<WindTowerCalculationData> tAndPaAndAirDensityDay(String equipmentId, List<ProphaseWeatherData> prophaseWeatherDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap) {
|
|
|
+
|
|
|
+
|
|
|
+ ArrayList<WindTowerCalculationData> list = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ //过滤温度,气压数据,空气密度前面已过滤
|
|
|
+ prophaseWeatherDataList = prophaseWeatherDataList.stream().filter(p -> null != p.getTAve() && null != p.getPaAve()
|
|
|
+ && p.getTAve() >= -60 && p.getTAve() <= 100 && p.getPaAve() > 0 && p.getPaAve() < 1200).collect(Collectors.toList());
|
|
|
+ //按日组合环境数据
|
|
|
+ Map<String, List<ProphaseWeatherData>> weatherDataDayMap = prophaseWeatherDataList.stream().collect(Collectors.groupingBy(x -> DateTimeUtil.getFormatDateStrForDay(x.getTs().getTime())));
|
|
|
+
|
|
|
+ weatherDataDayMap.forEach((day, collect) -> {
|
|
|
+ if (collect.isEmpty()) {
|
|
|
+ log.error("计算设备:{} 时间:{} 源数据为空,无法计算 日平均(温度/气压/空气密度) 数据", equipmentId, day);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Date dayTime = DateUtil.parse(day);
|
|
|
+ //=================================日平均(温度)===================================
|
|
|
+ try {
|
|
|
+ String ebId = equipmentAttributeMap.get(tDay).getId();
|
|
|
+ //计算时间段内所有温度
|
|
|
+ BigDecimal tAvg = CalculationUtil.getBigDecimal(collect.stream().mapToDouble(ProphaseWeatherData::getTAve).average().getAsDouble()).setScale(2, BigDecimal.ROUND_UP);
|
|
|
+ list.add(new WindTowerCalculationData(dayTime, equipmentId, ebId, tAvg));
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("计算设备:{} 时间:{} 的日平均温度错误:{} ", equipmentId, dayTime, e);
|
|
|
+ }//=================================日平均(气压)===================================
|
|
|
+ try {
|
|
|
+ String ebId = equipmentAttributeMap.get(paDay).getId();
|
|
|
+ //计算时间段内所有温度
|
|
|
+ BigDecimal paAvg = CalculationUtil.getBigDecimal(collect.stream().mapToDouble(ProphaseWeatherData::getPaAve).average().getAsDouble()).setScale(2, BigDecimal.ROUND_UP);
|
|
|
+ list.add(new WindTowerCalculationData(dayTime, equipmentId, ebId, paAvg));
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("计算设备:{} 时间:{} 的日平均气压错误:{} ", equipmentId, dayTime, e);
|
|
|
+ }
|
|
|
+
|
|
|
+ //=================================日平均(空气密度)===================================
|
|
|
+ try {
|
|
|
+ String airDensityEbId = equipmentAttributeMap.get(airDensity).getId();
|
|
|
+ //计算时间段内所有温度
|
|
|
+ BigDecimal airDensityAvg = CalculationUtil.getBigDecimal(collect.stream().mapToDouble(ProphaseWeatherData::getAirDensity).average().getAsDouble()).setScale(2, BigDecimal.ROUND_UP);
|
|
|
+ if (airDensityAvg.doubleValue() < 0) {
|
|
|
+ airDensityAvg = BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ list.add(new WindTowerCalculationData(dayTime, equipmentId, airDensityEbId, airDensityAvg));
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("计算设备:{} 时间:{} 的日平均空气密度错误:{} ", equipmentId, dayTime, e);
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备{} 日平均(温度/气压/空气密度) 统计异常", equipmentId, e);
|
|
|
+ }
|
|
|
+ log.info(" {}设备日平均 (温度/气压/空气密度) 计算完成", equipmentId);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 日平均气压入库
|
|
|
+ *
|
|
|
+ * @param equipmentId 设备Id
|
|
|
+ * @param equipmentAttributeMap 属性集合
|
|
|
+ */
|
|
|
+ public ArrayList<WindTowerCalculationData> paDay(String equipmentId, Map<String, List<ProphaseWeatherData>> weatherDataHMap
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap) {
|
|
|
+ String ebId = equipmentAttributeMap.get("paDay").getId();
|
|
|
+
|
|
|
+ ArrayList<WindTowerCalculationData> list = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ weatherDataHMap.forEach((day, value) -> {
|
|
|
+ //过滤一天数据
|
|
|
+ List<ProphaseWeatherData> collect = value.stream().filter(p -> null != p.getPaAve() && p.getPaAve() > 0 && p.getPaAve() < 1200).collect(Collectors.toList());
|
|
|
+ if (collect.isEmpty()) {
|
|
|
+ log.error("计算设备:{} 时间:{} 源数据为空,无法计算 日平均气压", equipmentId, day);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ BigDecimal paAvg = CalculationUtil.getBigDecimal(collect.stream().mapToDouble(ProphaseWeatherData::getPaAve).average().getAsDouble()).setScale(2, BigDecimal.ROUND_UP);
|
|
|
+
|
|
|
+ list.add(new WindTowerCalculationData(DateUtil.parse(day + " 00:00:00"), equipmentId, ebId, paAvg));
|
|
|
+ });
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备{}日平均气压统计异常", equipmentId, e);
|
|
|
+ }
|
|
|
+ log.info("{}设备日平均气压计算完成", equipmentId);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算日平均空气密度
|
|
|
+ *
|
|
|
+ * @param equipmentId 设备ID
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ArrayList<WindTowerCalculationData> airDensityDay(String equipmentId, Map<String, List<ProphaseWeatherData>> weatherDataHMap
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap) {
|
|
|
+
|
|
|
+ //空气密度属性
|
|
|
+ EquipmentAttribute equipmentAttribute = equipmentAttributeMap.get("airDensity");
|
|
|
+ ArrayList<WindTowerCalculationData> list = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ weatherDataHMap.forEach((day, collect) -> {
|
|
|
+ //存平均值
|
|
|
+ if (collect.isEmpty()) {
|
|
|
+ log.error("计算设备:{} 时间:{} 源数据为空,无法计算 日平均空气密度", equipmentId, day);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ BigDecimal airDensityAvg = CalculationUtil.getBigDecimal(collect.stream().mapToDouble(ProphaseWeatherData::getAirDensity).average().getAsDouble()).setScale(2, BigDecimal.ROUND_UP);
|
|
|
+ WindTowerCalculationData windTowerCalculationData = new WindTowerCalculationData();
|
|
|
+ windTowerCalculationData.setEquipmentId(equipmentId);
|
|
|
+ windTowerCalculationData.setEbId(equipmentAttribute.getId());
|
|
|
+ windTowerCalculationData.setTime(DateUtil.parse(day));
|
|
|
+ windTowerCalculationData.setValue(airDensityAvg);
|
|
|
+ if (windTowerCalculationData.getValue().doubleValue() < 0) {
|
|
|
+ windTowerCalculationData.setValue(zero);
|
|
|
+ }
|
|
|
+ list.add(windTowerCalculationData);
|
|
|
+ });
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("计算日平均空气密度错误:{}", e);
|
|
|
+ }
|
|
|
+ log.info("计算日平均空气密度完成");
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算上一个小时 每10分钟的风切变指数
|
|
|
+ */
|
|
|
+ public ArrayList<WindTowerCalculationData> calculateWindPowerShear(String equipmentId
|
|
|
+ , List<ProphaseAnemometryData> prophaseAnemometryDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap, WindTowerInfo windTowerInfo) {
|
|
|
+ log.info("开始计算小时风切变指数");
|
|
|
+ String[] heights = windTowerInfo.getHeights().split(",");
|
|
|
+ ArrayList<WindTowerCalculationData> listAll = new ArrayList<>();
|
|
|
+ //过滤数据
|
|
|
+ prophaseAnemometryDataList = prophaseAnemometryDataList.stream().filter(p -> null != p.getWsAve() && p.getWsAve() >= 3).collect(Collectors.toList());
|
|
|
+ String ebId = equipmentAttributeMap.get(windShearFiledName).getId();
|
|
|
+ try {
|
|
|
+ Map<String, List<ProphaseAnemometryData>> prophaseAnemometryDataHMap = prophaseAnemometryDataList.stream().collect(Collectors.groupingBy(x -> DateTimeUtil.getFormatDateStrForHH(x.getTs().getTime())));
|
|
|
+ prophaseAnemometryDataHMap.forEach((time, collect) -> {
|
|
|
+
|
|
|
+ //计算综合风切变
|
|
|
+ if (collect.isEmpty()) {
|
|
|
+ log.error("计算设备:{} 时间:{} 源数据为空,无法计算 综合风切变", equipmentId, time);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ BigDecimal windShear = CalculationUtil.getWindShear(collect, heights);
|
|
|
+ WindTowerCalculationData windTowerCalculationData = new WindTowerCalculationData();
|
|
|
+ windTowerCalculationData.setEquipmentId(equipmentId);
|
|
|
+ windTowerCalculationData.setTime(DateUtil.parse(time + ":00:00"));
|
|
|
+ windTowerCalculationData.setValue(windShear);
|
|
|
+ windTowerCalculationData.setEbId(ebId);
|
|
|
+ listAll.add(windTowerCalculationData);
|
|
|
+ });
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备{}小时风切变统计异常:{}", equipmentId, e);
|
|
|
+ }
|
|
|
+ log.info("{}设备风切变指数计算完成", equipmentId);
|
|
|
+ return listAll;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算日发电量与满发小时数
|
|
|
+ */
|
|
|
+
|
|
|
+ public ArrayList<WindTowerCalculationData> calculateBattery(WindTowerInfo
|
|
|
+ windTowerInfo, Map<String, List<ProphaseAnemometryData>> proAnemomentryDataDayMap
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap) {
|
|
|
+
|
|
|
+ ArrayList<WindTowerCalculationData> batteryList = new ArrayList<>();
|
|
|
+ EquipmentAttribute batteryDay = equipmentAttributeMap.get("batteryDay");
|
|
|
+ //获取最高层高
|
|
|
+ String maxHeight = CalculationUtil.getNumberFromString(Arrays.asList(windTowerInfo.getHeights().split(",")).get(0));
|
|
|
+
|
|
|
+ proAnemomentryDataDayMap.forEach((day, value) -> {
|
|
|
+ try {
|
|
|
+ BigDecimal batterySum = value.stream().filter(p -> p.getLayerHeight().equals(maxHeight)).map(p -> CalculationUtil.getBattery(BigDecimal.valueOf(p.getWsAve()))).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+
|
|
|
+ //日发电量
|
|
|
+ if (batterySum.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ batterySum = batterySum.divide(BigDecimal.valueOf(6 * 1000), 2, RoundingMode.HALF_UP);
|
|
|
+
|
|
|
+ WindTowerCalculationData windTowerCalculationData = new WindTowerCalculationData();
|
|
|
+ windTowerCalculationData.setValue(batterySum);
|
|
|
+ windTowerCalculationData.setEbId(batteryDay.getId());
|
|
|
+ windTowerCalculationData.setTime(DateUtil.beginOfDay(DateUtil.parse(day)));
|
|
|
+ windTowerCalculationData.setEquipmentId(windTowerInfo.getEquipmentNo());
|
|
|
+ batteryList.add(windTowerCalculationData);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("计算日发电量与满发小时数 错误:{}", e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return batteryList;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算日平均风速
|
|
|
+ *
|
|
|
+ * @param equipmentId 设备id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ArrayList<WindTowerCalculationData> wsDay(String equipmentId, List<WindTowerCalculationData> windTowerCalculationDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap, WindTowerInfo windTowerInfo) {
|
|
|
+
|
|
|
+ //获取测风塔所有层高
|
|
|
+ String[] strings = windTowerInfo.getHeights().split(",");
|
|
|
+ Map<String, List<WindTowerCalculationData>> windTowerCalculationDataListMap = windTowerCalculationDataList.stream().collect(Collectors.groupingBy(x -> DateTimeUtil.getFormatDateStrForDay(x.getTime().getTime())));
|
|
|
+
|
|
|
+ ArrayList<WindTowerCalculationData> list = new ArrayList<>();
|
|
|
+ try {
|
|
|
+
|
|
|
+ windTowerCalculationDataListMap.forEach((day, value) -> {
|
|
|
+
|
|
|
+ if (value.isEmpty()) {
|
|
|
+ log.error("计算设备:{} 日期:{} 的 数据为空,无法计算 日平均风速", equipmentId, day);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ //遍历测风塔所有层高
|
|
|
+ for (String h : strings) {
|
|
|
+ //获取小时风速表
|
|
|
+ EquipmentAttribute awsEq = equipmentAttributeMap.get(h + "aws");
|
|
|
+ //获取日风速表
|
|
|
+ EquipmentAttribute awsDayEq = equipmentAttributeMap.get(h + "awsDay");
|
|
|
+
|
|
|
+ //根据小时平均风速计算日均风速
|
|
|
+ List<WindTowerCalculationData> wsCalDataList = value.stream().filter(
|
|
|
+ w -> w.getEquipmentId().equals(equipmentId) &&
|
|
|
+ w.getEbId().equals(awsEq.getId()))
|
|
|
+ .collect(Collectors.toList()
|
|
|
+ );
|
|
|
+
|
|
|
+ if (!wsCalDataList.isEmpty()) {
|
|
|
+ BigDecimal wsDayAvg = CalculationUtil.getBigDecimal(wsCalDataList.stream().mapToDouble(x -> x.getValue().doubleValue()).average().getAsDouble()).setScale(2, BigDecimal.ROUND_UP);
|
|
|
+ WindTowerCalculationData windTowerCalculationData = new WindTowerCalculationData();
|
|
|
+ windTowerCalculationData.setEquipmentId(equipmentId);
|
|
|
+ windTowerCalculationData.setValue(wsDayAvg);
|
|
|
+ windTowerCalculationData.setEbId(awsDayEq.getId());
|
|
|
+ windTowerCalculationData.setTime(cn.hutool.core.date.DateUtil.parse(day));
|
|
|
+ list.add(windTowerCalculationData);
|
|
|
+ } else {
|
|
|
+ log.warn("日期:{} 过滤小时风速平均之后集合为空,无法计算日平均风速", day);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备编号{}日平均风速计算错误:{}", equipmentId, e);
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("设备编号{}米层高日平均风速计算完成", equipmentId);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算日平均风功率密度
|
|
|
+ *
|
|
|
+ * @param equipmentId 设备id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ArrayList<WindTowerCalculationData> wpdDay(String
|
|
|
+ equipmentId, List<WindTowerCalculationData> windTowerCalculationDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap, WindTowerInfo windTowerInfo) {
|
|
|
+
|
|
|
+ Map<String, List<WindTowerCalculationData>> windTowerCalculationDataListMap = windTowerCalculationDataList.stream()
|
|
|
+ .collect(Collectors.groupingBy(x -> DateTimeUtil.getFormatDateStrForDay(x.getTime().getTime())));
|
|
|
+
|
|
|
+ String[] heightAll = windTowerInfo.getHeights().split(",");
|
|
|
+ //结果集合
|
|
|
+ ArrayList<WindTowerCalculationData> list = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ windTowerCalculationDataListMap.forEach((day, value) -> {
|
|
|
+ Map<String, List<WindTowerCalculationData>> windTowerCalculationDataHMap = value.stream().collect(Collectors.groupingBy(x -> x.getEbId()));
|
|
|
+ for (String h : heightAll) {
|
|
|
+
|
|
|
+ //获取所有小时风功率表
|
|
|
+ EquipmentAttribute wpdList = equipmentAttributeMap.get(h + "wpd");
|
|
|
+ //获取所有日风功率表
|
|
|
+ EquipmentAttribute wpdDayList = equipmentAttributeMap.get(h + "wpdDay");
|
|
|
+ List<WindTowerCalculationData> wpdCalDataList = windTowerCalculationDataHMap.get(wpdList.getId());
|
|
|
+
|
|
|
+ if (null != wpdCalDataList && !wpdCalDataList.isEmpty()) {
|
|
|
+ //小时风功率总值
|
|
|
+ BigDecimal wpdSum = BigDecimal.ZERO;
|
|
|
+ for (WindTowerCalculationData wpd : wpdCalDataList) {
|
|
|
+ wpdSum = wpdSum.add(wpd.getValue());
|
|
|
+ }
|
|
|
+ WindTowerCalculationData windTowerCalculationData = new WindTowerCalculationData();
|
|
|
+ windTowerCalculationData.setEquipmentId(equipmentId);
|
|
|
+ windTowerCalculationData.setValue(wpdSum.divide(BigDecimal.valueOf(wpdCalDataList.size()), 2, RoundingMode.HALF_UP));
|
|
|
+ windTowerCalculationData.setEbId(wpdDayList.getId());
|
|
|
+ windTowerCalculationData.setTime(DateUtil.parse(day));
|
|
|
+ list.add(windTowerCalculationData);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ log.error("计算设备:{} 日期:{} 的数据为空,无法计算 平均风功率密度", equipmentId, day);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备编号{}日平均风功率密度计算错误:{}", equipmentId, e);
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("设备编号{}日平均风功率密度计算完成^ ^", equipmentId);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算日平均风速标差
|
|
|
+ *
|
|
|
+ * @param equipmentId 测风塔编号
|
|
|
+ * @param equipmentAttributeMap 属性表
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ArrayList<WindTowerCalculationData> calculateStaDay(String equipmentId, List<ProphaseAnemometryData> prophaseAnemometryDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap) {
|
|
|
+ ArrayList<WindTowerCalculationData> dataList = new ArrayList<>();
|
|
|
+ prophaseAnemometryDataList = prophaseAnemometryDataList.stream().filter(p -> null != p.getWsSta() && p.getWsSta() >= 0 && p.getWsSta() <= 100).collect(Collectors.toList());
|
|
|
+ //按层高分map
|
|
|
+ Map<String, List<ProphaseAnemometryData>> proAnemomentryDataHMap = prophaseAnemometryDataList.stream().collect(Collectors.groupingBy(ProphaseAnemometryData::getLayerHeight));
|
|
|
+ try {
|
|
|
+ proAnemomentryDataHMap.forEach((h, value) -> {
|
|
|
+ //获取对应层高的属性
|
|
|
+ EquipmentAttribute equipmentAttributes = equipmentAttributeMap.get(h + "staDay");
|
|
|
+ Map<String, List<ProphaseAnemometryData>> proAnemomentryDataDayMap = value.stream().collect(Collectors.groupingBy(x -> DateTimeUtil.getFormatDateStrForDay(x.getTs().getTime())));
|
|
|
+ proAnemomentryDataDayMap.forEach((day, collect) -> {
|
|
|
+ if (collect.size() > 0) {
|
|
|
+ BigDecimal staSum = CalculationUtil.getBigDecimal(collect.stream().mapToDouble(ProphaseAnemometryData::getWsSta).sum());
|
|
|
+ WindTowerCalculationData windTowerCalculationData = new WindTowerCalculationData();
|
|
|
+ windTowerCalculationData.setEquipmentId(equipmentId);
|
|
|
+ windTowerCalculationData.setTime(DateUtil.parse(day));
|
|
|
+ windTowerCalculationData.setValue(staSum.divide(CalculationUtil.getBigDecimal(collect.size()), 2, RoundingMode.HALF_UP));
|
|
|
+ windTowerCalculationData.setEbId(equipmentAttributes.getId());
|
|
|
+ dataList.add(windTowerCalculationData);
|
|
|
+ } else {
|
|
|
+ log.error("计算设备:{} 源数据为空,无法计算 日平均风速标差", equipmentId);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备编号{}日平均风速标差计算错误:{} ", equipmentId, e);
|
|
|
+ }
|
|
|
+ log.info("设备编号{},风速标差数据计算完成", equipmentId);
|
|
|
+ return dataList;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算日平均湍流
|
|
|
+ *
|
|
|
+ * @param equipmentId 设备id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ArrayList<WindTowerCalculationData> turbulenceDay(String equipmentId, Map<String, EquipmentAttribute> equipmentAttributeMap, WindTowerInfo
|
|
|
+ windTowerInfo, List<WindTowerCalculationData> windTowerCalculationDataList) {
|
|
|
+ Map<String, List<WindTowerCalculationData>> windTowerCalculationDataListMap = windTowerCalculationDataList.stream()
|
|
|
+ .collect(Collectors.groupingBy(x -> DateTimeUtil.getFormatDateStrForDay(x.getTime().getTime())));
|
|
|
+
|
|
|
+ String[] heightAll = windTowerInfo.getHeights().split(",");
|
|
|
+ //结果集合
|
|
|
+ ArrayList<WindTowerCalculationData> list = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ windTowerCalculationDataListMap.forEach((day, value) -> {
|
|
|
+ Map<String, List<WindTowerCalculationData>> windTowerCalculationDataHMap = value.stream().collect(Collectors.groupingBy(x -> x.getEbId()));
|
|
|
+ for (String h : heightAll) {
|
|
|
+
|
|
|
+ EquipmentAttribute turAttribute = equipmentAttributeMap.get(h + turbulenceDay);
|
|
|
+ EquipmentAttribute staAttribute = equipmentAttributeMap.get(h + staDay);
|
|
|
+ EquipmentAttribute wsAttribute = equipmentAttributeMap.get(h + "awsDay");
|
|
|
+ List<WindTowerCalculationData> staDay = windTowerCalculationDataHMap.get(staAttribute.getId());
|
|
|
+ List<WindTowerCalculationData> wsDay = windTowerCalculationDataHMap.get(wsAttribute.getId());
|
|
|
+
|
|
|
+ if (null != staDay && null != wsDay && !staDay.isEmpty() && !wsDay.isEmpty()) {
|
|
|
+ //数据入库
|
|
|
+ WindTowerCalculationData windTowerCalculationData = new WindTowerCalculationData();
|
|
|
+ windTowerCalculationData.setTime(DateUtil.parse(day));
|
|
|
+ windTowerCalculationData.setEbId(turAttribute.getId());
|
|
|
+ windTowerCalculationData.setEquipmentId(equipmentId);
|
|
|
+ windTowerCalculationData.setValue(CalculationUtil.caTurbulenceIntensity(staDay.get(0).getValue(), wsDay.get(0).getValue()));
|
|
|
+ list.add(windTowerCalculationData);
|
|
|
+ } else {
|
|
|
+ log.error("计算设备:{} 日期:{} 的数据为空,无法计算 日平均湍流", equipmentId, day);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备编号{}日平均湍流计算错误:{}", equipmentId, e);
|
|
|
+ }
|
|
|
+ log.info("设备编号{}日平均湍流计算完成", equipmentId);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算月最大风速
|
|
|
+ *
|
|
|
+ * @param equipmentId 设备id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ArrayList<WindTowerCalculationData> wsMaxMonth(String
|
|
|
+ equipmentId, List<ProphaseAnemometryData> prophaseAnemometryDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap, WindTowerInfo windTowerInfo) {
|
|
|
+
|
|
|
+ prophaseAnemometryDataList = prophaseAnemometryDataList.stream().filter(p -> null != p.getWsMax() && p.getWsMax() >= 0 && p.getWsMax() <= 50).collect(Collectors.toList());
|
|
|
+ Map<String, List<ProphaseAnemometryData>> monthListMap = prophaseAnemometryDataList.stream()
|
|
|
+ .collect(Collectors.groupingBy(x -> DateTimeUtil.getFormatDateStrForMonth(x.getTs().getTime())));
|
|
|
+ ArrayList<WindTowerCalculationData> list = new ArrayList<>();
|
|
|
+ monthListMap.forEach((month, value) -> {
|
|
|
+ try {
|
|
|
+ if (!value.isEmpty()) {
|
|
|
+ //各层高集合
|
|
|
+ Map<String, List<ProphaseAnemometryData>> hListMap = value.stream()
|
|
|
+ .collect(Collectors.groupingBy(x -> x.getLayerHeight()));
|
|
|
+ hListMap.forEach((h, collect) -> {
|
|
|
+ //获取对应层高的字段
|
|
|
+ String ebIdMonth = equipmentAttributeMap.get(h + "maxwsMonth").getId();
|
|
|
+
|
|
|
+ BigDecimal max = CalculationUtil.getBigDecimal(collect.stream().mapToDouble(ProphaseAnemometryData::getWsMax).sum());
|
|
|
+ BigDecimal maxWsValue = max.divide(BigDecimal.valueOf(collect.size()), 2, RoundingMode.HALF_UP);
|
|
|
+ list.add(new WindTowerCalculationData(DateUtil.parse(month + "-01 00:00:00"), equipmentId, ebIdMonth, maxWsValue));
|
|
|
+ });
|
|
|
+
|
|
|
+ } else {
|
|
|
+ log.error("计算设备:{} 月份:{} 无数据,无法计算 月最大风速", equipmentId, month);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备编号{}月最大风速计算错误:{}", equipmentId, e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //获取所有层高
|
|
|
+ String[] height = windTowerInfo.getHeights().split(",");
|
|
|
+
|
|
|
+
|
|
|
+ log.info("设备编号{}月最大风速计算完成^ ^", equipmentId);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算月平均风速
|
|
|
+ *
|
|
|
+ * @param equipmentId 设备编号
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ArrayList<WindTowerCalculationData> avgMonth(String equipmentId, List<WindTowerCalculationData> windTowerCalculationDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap, WindTowerInfo windTowerInfo) {
|
|
|
+ try {
|
|
|
+ //按月分组
|
|
|
+ Map<String, List<WindTowerCalculationData>> windTowerCalculationDataMonthMap = windTowerCalculationDataList.stream()
|
|
|
+ .collect(Collectors.groupingBy(x -> DateTimeUtil.getFormatDateStrForMonth(x.getTime().getTime())));
|
|
|
+ ArrayList<WindTowerCalculationData> list = new ArrayList<>();
|
|
|
+ windTowerCalculationDataMonthMap.forEach((month, value) -> {
|
|
|
+ Map<String, List<WindTowerCalculationData>> windTowerCalculationDataEbIdMap = value.stream().collect(Collectors.groupingBy(x -> x.getEbId()));
|
|
|
+ String[] height = windTowerInfo.getHeights().split(",");
|
|
|
+ for (String h : height) {
|
|
|
+
|
|
|
+ try {
|
|
|
+ //=============================================计算月平均风速======================================================================
|
|
|
+ String ebIdDay = equipmentAttributeMap.get(h + "awsDay").getId();
|
|
|
+ String ebIdMonth = equipmentAttributeMap.get(h + "awsMonth").getId();
|
|
|
+ cacluMonthAvg(ebIdDay, ebIdMonth, windTowerCalculationDataEbIdMap, list, month, equipmentId, "计算月平均风速");
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备编号 {} 时间:{} 层高:{} 计算月平均风速 错误:{}", equipmentId, month, h, e);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ //=============================================计算月平均风功率密度======================================================================
|
|
|
+ String ebIdDay = equipmentAttributeMap.get(h + "wpdDay").getId();
|
|
|
+ String ebIdMonth = equipmentAttributeMap.get(h + "wpdMonth").getId();
|
|
|
+ cacluMonthAvg(ebIdDay, ebIdMonth, windTowerCalculationDataEbIdMap, list, month, equipmentId, "计算月平均风功率密度");
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备编号 {} 时间:{} 层高:{} 计算月平均风功率密度 错误:{}", equipmentId, month, h, e);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ //=============================================计算月平均湍流======================================================================
|
|
|
+ String ebIdDay = equipmentAttributeMap.get(h + "turbulenceDay").getId();
|
|
|
+ String ebIdMonth = equipmentAttributeMap.get(h + "turbulenceMonth").getId();
|
|
|
+ cacluMonthAvg(ebIdDay, ebIdMonth, windTowerCalculationDataEbIdMap, list, month, equipmentId, "计算月平均湍流");
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备编号 {} 时间:{} 层高:{} 计算月平均湍流 错误:{}", equipmentId, month, h, e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ //=============================================计算月平均空气密度======================================================================
|
|
|
+ String ebIdDay = equipmentAttributeMap.get("airDensity").getId();
|
|
|
+ String ebIdMonth = equipmentAttributeMap.get("airDensityMonth").getId();
|
|
|
+ cacluMonthAvg(ebIdDay, ebIdMonth, windTowerCalculationDataEbIdMap, list, month, equipmentId, "计算月平均空气密度");
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备编号 {} 时间:{} 计算月平均空气密度 错误:{}", equipmentId, month, e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ log.info("{}设备 月平均风速/月平均空气密度/月平均风功率密度/月平均湍流/ 统计完成", equipmentId);
|
|
|
+ return list;
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备编号{}月平均风速计算错误:{}", equipmentId, e);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算月风切变入库
|
|
|
+ *
|
|
|
+ * @param equipmentId 设备id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ArrayList<WindTowerCalculationData> shearMonth(String equipmentId
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap, WindTowerInfo
|
|
|
+ windTowerInfo, List<ProphaseAnemometryData> prophaseAnemometryDataList) {
|
|
|
+ //获取时间段所有统计数据
|
|
|
+ ArrayList<WindTowerCalculationData> list = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ //获取月平均综合风切变字段
|
|
|
+ String ebIdMonth = equipmentAttributeMap.get("windShearMonth").getId();
|
|
|
+
|
|
|
+ String heights = windTowerInfo.getHeights();
|
|
|
+ prophaseAnemometryDataList = prophaseAnemometryDataList.stream().filter(p -> null != p.getWsAve() && p.getWsAve() >= 3).collect(Collectors.toList());
|
|
|
+ Map<String, List<ProphaseAnemometryData>> collect = prophaseAnemometryDataList.stream()
|
|
|
+ .collect(Collectors.groupingBy(x -> DateTimeUtil.getFormatDateStrForMonth(x.getTs().getTime())));
|
|
|
+ collect.forEach((month, value) -> {
|
|
|
+ BigDecimal windShear = CalculationUtil.getWindShear(value, heights.split(","));
|
|
|
+
|
|
|
+ if (value.size() > 0) {
|
|
|
+ WindTowerCalculationData windTowerCalculationData = new WindTowerCalculationData();
|
|
|
+ windTowerCalculationData.setEbId(ebIdMonth);
|
|
|
+ windTowerCalculationData.setTime(DateUtil.parse(month + "-01 00:00:00"));
|
|
|
+ windTowerCalculationData.setEquipmentId(equipmentId);
|
|
|
+ windTowerCalculationData.setValue(windShear);
|
|
|
+ list.add(windTowerCalculationData);
|
|
|
+ } else {
|
|
|
+ log.error("计算设备:{} 源数据为空,无法计算 月平均风月切变", equipmentId);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备编号{}月平均风月切变计算错误{}", equipmentId, e);
|
|
|
+ }
|
|
|
+ log.info("设备编号{}月平均风切变计算完成", equipmentId);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据日统计数据计算
|
|
|
+ * 通用计算月平均数据
|
|
|
+ *
|
|
|
+ * @param dayEqId
|
|
|
+ * @param monthEqId
|
|
|
+ * @param windTowerCalculationDataEbIdMap
|
|
|
+ * @param list 最后保存数据集合
|
|
|
+ * @param month
|
|
|
+ * @param equipmentId
|
|
|
+ * @param dataFlagStr 日志打印标识
|
|
|
+ */
|
|
|
+ public void cacluMonthAvg(String dayEqId, String monthEqId,
|
|
|
+ Map<String, List<WindTowerCalculationData>> windTowerCalculationDataEbIdMap
|
|
|
+ , ArrayList<WindTowerCalculationData> list, String month, String equipmentId, String dataFlagStr) {
|
|
|
+ try {
|
|
|
+ //获取所有日平均数据
|
|
|
+ List<WindTowerCalculationData> windTowerCalculationDatas = windTowerCalculationDataEbIdMap.get(dayEqId);
|
|
|
+ if (null != windTowerCalculationDatas && !windTowerCalculationDatas.isEmpty()) {
|
|
|
+ BigDecimal wsSum = new BigDecimal(0);
|
|
|
+ //日统计数据累加
|
|
|
+ for (WindTowerCalculationData w : windTowerCalculationDatas) {
|
|
|
+ wsSum = wsSum.add(w.getValue());
|
|
|
+ }
|
|
|
+ //计算平均值
|
|
|
+ BigDecimal awsMonthValue = wsSum.divide(new BigDecimal(windTowerCalculationDatas.size()), 2, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ list.add(new WindTowerCalculationData(DateUtil.parse(month + "-01 00:00:00"), equipmentId, monthEqId, awsMonthValue));
|
|
|
+ } else {
|
|
|
+ log.warn("设备 {} 时间:{} 计算 {} 无数据", equipmentId, month, dataFlagStr);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备编号 {} 时间:{} 计算 {} 错误:{}", equipmentId, month, dataFlagStr, e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算日风切变入库
|
|
|
+ *
|
|
|
+ * @param equipmentId 设备id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ArrayList<WindTowerCalculationData> shearDay(String equipmentId, Map<String, EquipmentAttribute> equipmentAttributeMap, WindTowerInfo
|
|
|
+ windTowerInfo, Map<String, List<ProphaseAnemometryData>> proAnemomentryDataDayMap) {
|
|
|
+ String[] heights = windTowerInfo.getHeights().split(",");
|
|
|
+
|
|
|
+ ArrayList<WindTowerCalculationData> list = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ //获取日综合风切变
|
|
|
+ EquipmentAttribute shearDayList = equipmentAttributeMap.get(windShearDayFiledName);
|
|
|
+ proAnemomentryDataDayMap.forEach((day, value) -> {
|
|
|
+ List<ProphaseAnemometryData> collect = value.stream().filter(p -> null != p.getWsAve() && p.getWsAve() >= 3).collect(Collectors.toList());
|
|
|
+ BigDecimal windShear = CalculationUtil.getWindShear(collect, heights);
|
|
|
+ if (collect.size() > 0) {
|
|
|
+ WindTowerCalculationData windTowerCalculationData = new WindTowerCalculationData();
|
|
|
+ windTowerCalculationData.setEquipmentId(equipmentId);
|
|
|
+ windTowerCalculationData.setValue(windShear);
|
|
|
+ windTowerCalculationData.setEbId(shearDayList.getId());
|
|
|
+ windTowerCalculationData.setTime(DateUtil.parse(day));
|
|
|
+ list.add(windTowerCalculationData);
|
|
|
+ } else {
|
|
|
+ log.error("计算设备:{} 源数据为空,无法计算 日平均风切变", equipmentId);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备编号{}日平均风切变计算错误", equipmentId, e);
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ log.info("设备编号{}日平均风切变计算完成", equipmentId);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 玫瑰图 数据计算
|
|
|
+ */
|
|
|
+ public void roseMonth(String equipmentId, Map<String, List<ProphaseAnemometryData>> proAnemomentryDataHMap, List<ProphaseWeatherData> prophaseWeatherDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap, WindTowerInfo windTowerInfo, List<ProphaseAnemometryData> anemometryDataList) {
|
|
|
+ ArrayList<WindDirectionStatisticsData> list = new ArrayList<>();
|
|
|
+ Map<String, List<ProphaseWeatherData>> weatherCollectMonth = prophaseWeatherDataList.stream().collect(Collectors.groupingBy(x -> DateTimeUtil.getFormatDateStrForMonth(x.getTs().getTime())));
|
|
|
+ //获取所有 风向层高 不是所有层高都有风向数据
|
|
|
+ String[] heights = windTowerInfo.getWdHeights().split(",");
|
|
|
+ List<String> heightList = Arrays.asList(heights);
|
|
|
+
|
|
|
+ proAnemomentryDataHMap.forEach((height, valueHeightList) -> {
|
|
|
+
|
|
|
+ if (!heightList.contains(height)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!valueHeightList.isEmpty()) {
|
|
|
+
|
|
|
+ Map<String, List<ProphaseAnemometryData>> collectMonth = valueHeightList.stream()
|
|
|
+ .collect(Collectors.groupingBy(x -> DateTimeUtil.getFormatDateStrForMonth(x.getTs().getTime())));
|
|
|
+ collectMonth.forEach((month, valueList) -> {
|
|
|
+ Date time = DateUtil.parse(month + "-01 00:00:00");
|
|
|
+ //风向玫瑰图
|
|
|
+ ArrayList<WindDirectionStatisticsData> wdRose = wdRose(equipmentId, valueList, equipmentAttributeMap, height, time);
|
|
|
+ list.addAll(wdRose);
|
|
|
+ //湍流玫瑰图
|
|
|
+ ArrayList<WindDirectionStatisticsData> turRose = turRose(equipmentId, valueList, equipmentAttributeMap, height, time);
|
|
|
+ list.addAll(turRose);
|
|
|
+
|
|
|
+ //风功率玫瑰图
|
|
|
+ ArrayList<WindDirectionStatisticsData> powerRose = powerRose(equipmentId, valueList, weatherCollectMonth.get(month), equipmentAttributeMap, height, time);
|
|
|
+ list.addAll(powerRose);
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ } else {
|
|
|
+ log.info("设备编号 {}, 层高:{},月玫瑰图计算失败,无测风塔数据^ ^", equipmentId, height);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //风切变玫瑰图
|
|
|
+ Map<String, List<ProphaseAnemometryData>> anemometryMonthMap = anemometryDataList.stream().collect(Collectors.groupingBy(x -> DateTimeUtil.getFormatDateStrForMonth(x.getTs().getTime())));
|
|
|
+ anemometryMonthMap.forEach((month, value) -> {
|
|
|
+ ArrayList<WindDirectionStatisticsData> windShearRose = windShearRose(equipmentId, value, equipmentAttributeMap, heights, DateUtil.parse(month + "-01 00:00:00"));
|
|
|
+ list.addAll(windShearRose);
|
|
|
+ });
|
|
|
+
|
|
|
+ windDirectionStatisticsDataServiceImpl.saveBatch(list);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 风向玫瑰图统计计算
|
|
|
+ */
|
|
|
+ public ArrayList<WindDirectionStatisticsData> wdRose(String equipmentId, List<ProphaseAnemometryData> anemometryDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap, String height, Date time) {
|
|
|
+ ArrayList<WindDirectionStatisticsData> list = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ String ebIdMonth = equipmentAttributeMap.get(height + "monthWdRose").getId();
|
|
|
+ for (WindDirectionEnum value : WindDirectionEnum.values()) {
|
|
|
+ List<ProphaseAnemometryData> forHeightAndWindDirectionEnum = CalculationUtil.getForHeightAndWindDirectionEnum(anemometryDataList, value);
|
|
|
+ if (!forHeightAndWindDirectionEnum.isEmpty()) {
|
|
|
+ WindDirectionStatisticsData windDirectionStatisticsData = new WindDirectionStatisticsData();
|
|
|
+ windDirectionStatisticsData.setEbId(ebIdMonth);
|
|
|
+ windDirectionStatisticsData.setTime(time);
|
|
|
+ windDirectionStatisticsData.setEquipmentId(equipmentId);
|
|
|
+ windDirectionStatisticsData.setDirection(value.name());
|
|
|
+ windDirectionStatisticsData.setValue(BigDecimal.valueOf(100).multiply(BigDecimal.valueOf(forHeightAndWindDirectionEnum.size())).divide(BigDecimal.valueOf(anemometryDataList.size()), 2, RoundingMode.HALF_UP));
|
|
|
+ list.add(windDirectionStatisticsData);
|
|
|
+ } else {
|
|
|
+ log.error("计算设备:{} 层高:{} 数据为空,无法计算 风向玫瑰图统计", equipmentId, height);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 风功率玫瑰图统计计算
|
|
|
+ */
|
|
|
+ public ArrayList<WindDirectionStatisticsData> powerRose(String equipmentId, List<ProphaseAnemometryData> anemometryDataList
|
|
|
+ , List<ProphaseWeatherData> prophaseWeatherDataList, Map<String, EquipmentAttribute> equipmentAttributeMap, String height, Date time) {
|
|
|
+ ArrayList<WindDirectionStatisticsData> list = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ String ebIdMonth = equipmentAttributeMap.get(height + "monthPowerRose").getId();
|
|
|
+ if (null != prophaseWeatherDataList && prophaseWeatherDataList.size() > 0) {
|
|
|
+ Map<String, ProphaseWeatherData> prophaseWeatherDataMap = prophaseWeatherDataList.stream().collect(Collectors.toMap(x -> x.getTs().getTime() + "", x -> x, (x1, x2) -> x1));
|
|
|
+ for (WindDirectionEnum value : WindDirectionEnum.values()) {
|
|
|
+ List<ProphaseAnemometryData> forHeightAndWindDirectionEnum = CalculationUtil.getForHeightAndWindDirectionEnum(anemometryDataList, value);
|
|
|
+ if (!forHeightAndWindDirectionEnum.isEmpty()) {
|
|
|
+ //根据风向获取风能数
|
|
|
+ BigDecimal bigDecimal = CalculationUtil.windEnergyDensity(forHeightAndWindDirectionEnum, prophaseWeatherDataMap);
|
|
|
+ // 数据集合
|
|
|
+ WindDirectionStatisticsData windDirectionStatisticsData = new WindDirectionStatisticsData();
|
|
|
+ windDirectionStatisticsData.setEbId(ebIdMonth);
|
|
|
+ windDirectionStatisticsData.setTime(time);
|
|
|
+ windDirectionStatisticsData.setEquipmentId(equipmentId);
|
|
|
+ windDirectionStatisticsData.setDirection(value.name());
|
|
|
+ windDirectionStatisticsData.setValue(bigDecimal.equals(new BigDecimal(-99)) ? zero : bigDecimal);
|
|
|
+ list.add(windDirectionStatisticsData);
|
|
|
+ } else {
|
|
|
+ log.error("计算设备:{} 层高:{} 时间:{} 数据为空,无法计算 风功率玫瑰图统计", equipmentId, height, time);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 湍流玫瑰图统计计算
|
|
|
+ */
|
|
|
+ public ArrayList<WindDirectionStatisticsData> turRose(String equipmentId, List<ProphaseAnemometryData> prophaseAnemometryDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap, String height, Date time) {
|
|
|
+ BigDecimal zero = new BigDecimal(0);
|
|
|
+ ArrayList<WindDirectionStatisticsData> list = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ String ebIdMonth = equipmentAttributeMap.get(height + "monthTurRose").getId();
|
|
|
+ for (WindDirectionEnum value : WindDirectionEnum.values()) {
|
|
|
+ List<ProphaseAnemometryData> heightAndWindDirectionEnum = CalculationUtil.getForHeightAndWindDirectionEnum(prophaseAnemometryDataList, value);
|
|
|
+
|
|
|
+ if (!heightAndWindDirectionEnum.isEmpty()) {
|
|
|
+ //获取指定层高风速数据
|
|
|
+ List<BigDecimal> wsForHeight = heightAndWindDirectionEnum.stream().map((ProphaseAnemometryData p) ->
|
|
|
+ {
|
|
|
+ return CalculationUtil.getBigDecimal(p.getWsAve());
|
|
|
+ }
|
|
|
+ ).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //删除值为null的数据
|
|
|
+ wsForHeight.removeAll(Collections.singletonList(null));
|
|
|
+ //平均风速
|
|
|
+ BigDecimal avgWindSpeed = CalculationUtil.getAvgWind(wsForHeight);
|
|
|
+ //获取指定层高标差数据集合
|
|
|
+ List<BigDecimal> staForHeight = heightAndWindDirectionEnum.stream().filter(h -> h.getWsSta() != null && h.getWsSta() != 0 && h.getWsSta() != -99).map((ProphaseAnemometryData p) ->
|
|
|
+ {
|
|
|
+ return CalculationUtil.getBigDecimal(p.getWsSta());
|
|
|
+ }
|
|
|
+ ).collect(Collectors.toList());
|
|
|
+ //平均风速标准差
|
|
|
+ BigDecimal avgWindSpeedSta = CalculationUtil.getAvgWind(staForHeight);
|
|
|
+ // 湍流
|
|
|
+ BigDecimal bigDecimal = CalculationUtil.caTurbulenceIntensity(avgWindSpeedSta, avgWindSpeed);
|
|
|
+ // 数据集合
|
|
|
+ WindDirectionStatisticsData windDirectionStatisticsData = new WindDirectionStatisticsData();
|
|
|
+ windDirectionStatisticsData.setEbId(ebIdMonth);
|
|
|
+ windDirectionStatisticsData.setTime(time);
|
|
|
+ windDirectionStatisticsData.setEquipmentId(equipmentId);
|
|
|
+ windDirectionStatisticsData.setDirection(value.name());
|
|
|
+ windDirectionStatisticsData.setValue(bigDecimal.equals(new BigDecimal(-99)) ? zero : bigDecimal);
|
|
|
+ list.add(windDirectionStatisticsData);
|
|
|
+ } else {
|
|
|
+ log.error("计算设备:{} 层高:{} 时间:{} 数据为空,无法计算 湍流玫瑰图统计", equipmentId, height, time);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 风切变玫瑰图统计计算
|
|
|
+ */
|
|
|
+ public ArrayList<WindDirectionStatisticsData> windShearRose(String equipmentId, List<ProphaseAnemometryData> anemometryDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap, String[] heights, DateTime time) {
|
|
|
+ ArrayList<WindDirectionStatisticsData> list = new ArrayList<>();
|
|
|
+ //设置最小层高 数值越大越好
|
|
|
+ int heightMin = 100;
|
|
|
+ try {
|
|
|
+ //设置临时层高 用于比较
|
|
|
+ int finalHeight = 10;
|
|
|
+ for (String height : heights) {
|
|
|
+ // 若是此层高是第二同层高
|
|
|
+ if (!height.contains("A")) {
|
|
|
+ finalHeight = Integer.parseInt(height);
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (finalHeight < heightMin) {
|
|
|
+ heightMin = Integer.parseInt(height);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (String height : heights) {
|
|
|
+ //如果层高等于最小增高则跳出循环
|
|
|
+ if (height.equals(String.valueOf(heightMin))) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String ebIdMonth = equipmentAttributeMap.get(height + "monthShearRose").getId();
|
|
|
+ for (WindDirectionEnum value : WindDirectionEnum.values()) {
|
|
|
+
|
|
|
+ List<ProphaseAnemometryData> heightAndWindDirectionList = CalculationUtil.getForHeightAndWindDirectionEnum(anemometryDataList, value);
|
|
|
+ if (!heightAndWindDirectionList.isEmpty()) {
|
|
|
+
|
|
|
+ Map<String, List<ProphaseAnemometryData>> heightAndWindDirectionEnumMap = heightAndWindDirectionList.stream().collect(Collectors.groupingBy(ProphaseAnemometryData::getLayerHeight));
|
|
|
+ //获取指定层高风速数据
|
|
|
+ List<ProphaseAnemometryData> height1List = heightAndWindDirectionEnumMap.get(height);
|
|
|
+ if (null != height1List && height1List.size() > 0) {
|
|
|
+ //计算当前层高平均风速
|
|
|
+ BigDecimal avgWindSpeed = BigDecimal.valueOf(height1List.stream().collect(Collectors.averagingDouble(ProphaseAnemometryData::getWsAve))).setScale(2, RoundingMode.HALF_UP);
|
|
|
+
|
|
|
+ //获取指定最小层高风速数据
|
|
|
+ String finalHeightMin = String.valueOf(heightMin);
|
|
|
+ List<ProphaseAnemometryData> height2List = heightAndWindDirectionEnumMap.get(finalHeightMin);
|
|
|
+ if (null != height2List && height2List.size() > 0) {
|
|
|
+ //计算当前层高平均风速
|
|
|
+ BigDecimal minAvgWindSpeed = BigDecimal.valueOf(height2List.stream().collect(Collectors.averagingDouble(ProphaseAnemometryData::getWsAve))).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ BigDecimal bigDecimal = BigDecimal.ZERO;
|
|
|
+
|
|
|
+ if (minAvgWindSpeed.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ //计算风切变值
|
|
|
+ bigDecimal = CalculationUtil.caWindShear(avgWindSpeed, minAvgWindSpeed, new BigDecimal(height), new BigDecimal(heightMin));
|
|
|
+ }
|
|
|
+ // 数据集合
|
|
|
+ WindDirectionStatisticsData windDirectionStatisticsData = new WindDirectionStatisticsData();
|
|
|
+ windDirectionStatisticsData.setEbId(ebIdMonth);
|
|
|
+ windDirectionStatisticsData.setTime(time);
|
|
|
+ windDirectionStatisticsData.setEquipmentId(equipmentId);
|
|
|
+ windDirectionStatisticsData.setDirection(value.name());
|
|
|
+ windDirectionStatisticsData.setValue(bigDecimal);
|
|
|
+ list.add(windDirectionStatisticsData);
|
|
|
+ } else {
|
|
|
+ log.warn("计算设备:{} 风切变玫瑰图 未查询到最小层高:{} 时间:{} 的数据", equipmentId, finalHeightMin, time);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.warn("计算设备:{} 风切变玫瑰图 未查询到指定层高:{} 时间:{} 的数据", equipmentId, height, time);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("计算设备:{} 时间:{} 的 风切变玫瑰图 错误:{}", equipmentId, time, e);
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取风况数据(平均风速,风功率密度)
|
|
|
+ *
|
|
|
+ * @param bigDecimalList 风速数据
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public SpeedAndDensityDto getSpeedAndDensityDto(List<BigDecimal> bigDecimalList, List<ProphaseAnemometryData> anemometryData, List<ProphaseWeatherData> weatherData) {
|
|
|
+
|
|
|
+ SpeedAndDensityDto speedAndDensityDto = new SpeedAndDensityDto();
|
|
|
+ BigDecimal avgWindSpeed = BigDecimal.valueOf(bigDecimalList.stream().collect(Collectors.averagingDouble(BigDecimal::doubleValue)));
|
|
|
+ speedAndDensityDto.setWindSpeed(avgWindSpeed);
|
|
|
+ Map<String, ProphaseWeatherData> prophaseWeatherDataMap = weatherData.stream().collect(Collectors.toMap(x -> x.getTs().getTime() + "", x -> x, (x1, x2) -> x1));
|
|
|
+ if (null != prophaseWeatherDataMap) {
|
|
|
+ speedAndDensityDto.setWindPowerDensity(CalculationUtil.windEnergyDensity(anemometryData, prophaseWeatherDataMap));
|
|
|
+ } else {
|
|
|
+ log.error("获取风况数据错误,未查询到环境数据,时间点:{}", anemometryData.get(0).getTs());
|
|
|
+ }
|
|
|
+ return speedAndDensityDto;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|