|
@@ -0,0 +1,1670 @@
|
|
|
+package com.jiayue.biz.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.date.DatePattern;
|
|
|
+import com.jiayue.biz.domain.*;
|
|
|
+import com.jiayue.biz.dto.SpeedAndDensityDto;
|
|
|
+import com.jiayue.biz.eunms.WindDirectionEnum;
|
|
|
+import com.jiayue.biz.service.EquipmentAttributeService;
|
|
|
+import com.jiayue.biz.service.WindDataCalculationService;
|
|
|
+import com.jiayue.biz.service.WindTowerInfoService;
|
|
|
+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 org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 风资源相关计算服务
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+@AllArgsConstructor
|
|
|
+public class WindDataCalculationServiceImpl implements WindDataCalculationService {
|
|
|
+ //风功率密度和平均风速的统一标识
|
|
|
+ private final String attributeFunction = "WindPowerDensity";
|
|
|
+ private final String tDay = "tDay";
|
|
|
+ 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 wpdFunction = "WindPowerDensity";
|
|
|
+ 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 long oneDay = 86400000L;
|
|
|
+ private final long oneHour = 3600000L;
|
|
|
+ private final SimpleDateFormat yyyyMMdd = new SimpleDateFormat("yyyyMMdd");
|
|
|
+ private final SimpleDateFormat yyyyMMddHH = new SimpleDateFormat("yyyyMMddHH");
|
|
|
+
|
|
|
+ private final WindTowerInfoService windTowerInfoService;
|
|
|
+
|
|
|
+ private final EquipmentAttributeService equipmentAttributeService;
|
|
|
+ private final WindDirectionStatisticsDataServiceImpl windDirectionStatisticsDataServiceImpl;
|
|
|
+ private final WindTowerCalculationDataServiceImpl windTowerCalculationDataServiceImpl;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 统一计算
|
|
|
+ *
|
|
|
+ * @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) {
|
|
|
+
|
|
|
+
|
|
|
+ //小时平均风速风功率密度
|
|
|
+ ArrayList<WindTowerCalculationData> wsAndWpdList = this.calculateWindPowerDensity(startDate.getTime(), endDate.getTime(), equipmentNo, prophaseAnemometryDataList
|
|
|
+ , prophaseWeatherDataList, equipmentAttributeMap, windTowerCalculationDataList, windTowerInfo);
|
|
|
+ dataList.addAll(wsAndWpdList);
|
|
|
+ //每小时风切变指数
|
|
|
+ ArrayList<WindTowerCalculationData> windShearList = this.calculateWindPowerShear(startDate, endDate, equipmentNo, prophaseAnemometryDataList, windTowerCalculationDataList, equipmentAttributeMap, windTowerInfo);
|
|
|
+ dataList.addAll(windShearList);
|
|
|
+
|
|
|
+ //计算日均
|
|
|
+ calcuForDay(dataList, startDate, endDate, equipmentNo, prophaseAnemometryDataList, prophaseWeatherDataList, equipmentAttributeMap, windTowerCalculationDataList, windTowerInfo);
|
|
|
+
|
|
|
+ //如果结束时间和数据统计的时间相差大于30天就分割月份进行计算
|
|
|
+ if (endDate.getTime() - startDate.getTime() > oneDay * 30) {
|
|
|
+ List<Long> dateTime = DateTimeUtil.getIntervalTimeByMonth(DateTimeUtil.beginOfMonth(startDate), DateTimeUtil.beginOfMonth(endDate));
|
|
|
+ for (Long l : dateTime) {
|
|
|
+ log.info("计算设备:{} 在时间:{} 的统计数据", equipmentNo, cn.hutool.core.date.DateUtil.format(cn.hutool.core.date.DateUtil.date(l), DatePattern.NORM_DATE_FORMAT));
|
|
|
+ //传入时间的月初
|
|
|
+ Date startMonthDate = DateTimeUtil.beginOfMonth(new Date(l));
|
|
|
+ //传入时间的月末
|
|
|
+ Date endMonthDate = DateTimeUtil.endOfMonth(new Date(l));
|
|
|
+ //月玫瑰图
|
|
|
+ this.roseMonth(startMonthDate, endMonthDate, equipmentNo, prophaseAnemometryDataList, prophaseWeatherDataList, equipmentAttributeMap, windTowerInfo);
|
|
|
+ this.calcuForMonth(dataList, startMonthDate, endMonthDate, equipmentNo, prophaseAnemometryDataList, prophaseWeatherDataList
|
|
|
+ , equipmentAttributeMap, windTowerCalculationDataList, windTowerInfo);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //传入时间的月初
|
|
|
+ Date startMonthDate = DateTimeUtil.beginOfMonth(startDate);
|
|
|
+ //前一天23点59分
|
|
|
+ Date endDate1 = DateTimeUtil.getDayLastTime(DateUtil.yesterday().getTime());
|
|
|
+ //传入时间的月末
|
|
|
+ Date endMonthDate = DateTimeUtil.endOfMonth(endDate1);
|
|
|
+
|
|
|
+ log.info("计算设备:{} 在时间:{} 的统计数据", equipmentNo, cn.hutool.core.date.DateUtil.format(startMonthDate, DatePattern.NORM_DATE_FORMAT));
|
|
|
+ this.calcuForMonth(dataList, startMonthDate, endMonthDate, equipmentNo, prophaseAnemometryDataList, prophaseWeatherDataList, equipmentAttributeMap, windTowerCalculationDataList, windTowerInfo);
|
|
|
+
|
|
|
+ // 月玫瑰图
|
|
|
+ this.roseMonth(startMonthDate, endMonthDate, equipmentNo, prophaseAnemometryDataList, prophaseWeatherDataList, equipmentAttributeMap, windTowerInfo);
|
|
|
+
|
|
|
+ }
|
|
|
+ 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, Date startDate, Date endDate, String equipmentNo
|
|
|
+ , List<ProphaseAnemometryData> prophaseAnemometryDataList, List<ProphaseWeatherData> prophaseWeatherDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap, List<WindTowerCalculationData> windTowerCalculationDataList, WindTowerInfo windTowerInfo) {
|
|
|
+ //日平均温度
|
|
|
+ ArrayList<WindTowerCalculationData> tList = this.tDay(startDate, endDate, equipmentNo, prophaseWeatherDataList, equipmentAttributeMap);
|
|
|
+ dataList.addAll(tList);
|
|
|
+ //日平均气压
|
|
|
+ ArrayList<WindTowerCalculationData> paList = this.paDay(startDate, endDate, equipmentNo, prophaseWeatherDataList, equipmentAttributeMap);
|
|
|
+ dataList.addAll(paList);
|
|
|
+ //发电量与满发小时数
|
|
|
+ ArrayList<WindTowerCalculationData> calculateBattery = this.calculateBattery(startDate.getTime(), endDate.getTime(), windTowerInfo, prophaseAnemometryDataList, equipmentAttributeMap, windTowerCalculationDataList);
|
|
|
+ dataList.addAll(calculateBattery);
|
|
|
+ //日平均空气密度
|
|
|
+ ArrayList<WindTowerCalculationData> airList = this.airDensityDay(startDate, endDate, equipmentNo, prophaseWeatherDataList, equipmentAttributeMap, windTowerCalculationDataList);
|
|
|
+ dataList.addAll(airList);
|
|
|
+ //日平均风速标差
|
|
|
+ ArrayList<WindTowerCalculationData> staDay = this.calculateStaDay(startDate, endDate, equipmentNo, prophaseAnemometryDataList, equipmentAttributeMap, windTowerInfo, windTowerCalculationDataList);
|
|
|
+ dataList.addAll(staDay);
|
|
|
+ //日平均风速
|
|
|
+ ArrayList<WindTowerCalculationData> wsDayList = this.wsDay(startDate, endDate, equipmentNo, windTowerCalculationDataList, equipmentAttributeMap, windTowerInfo);
|
|
|
+ dataList.addAll(wsDayList);
|
|
|
+ //日平均湍流
|
|
|
+ ArrayList<WindTowerCalculationData> turList = this.turbulenceDay(startDate, endDate, equipmentNo, equipmentAttributeMap, windTowerInfo, windTowerCalculationDataList);
|
|
|
+ dataList.addAll(turList);
|
|
|
+ //日平均风切变
|
|
|
+ ArrayList<WindTowerCalculationData> windShearDay = this.shearDay(startDate, endDate, equipmentNo, windTowerCalculationDataList, equipmentAttributeMap, windTowerInfo, prophaseAnemometryDataList);
|
|
|
+ dataList.addAll(windShearDay);
|
|
|
+ //日平均风功率密度
|
|
|
+ ArrayList<WindTowerCalculationData> wpdDayList = this.wpdDay(startDate, endDate, equipmentNo, windTowerCalculationDataList, equipmentAttributeMap, windTowerInfo);
|
|
|
+ dataList.addAll(wpdDayList);
|
|
|
+
|
|
|
+ return dataList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ArrayList<WindTowerCalculationData> calcuForMonth(ArrayList<WindTowerCalculationData> dataList, Date startDate, Date endDate, String equipmentNo
|
|
|
+ , List<ProphaseAnemometryData> prophaseAnemometryDataList, List<ProphaseWeatherData> prophaseWeatherDataList, Map<String, EquipmentAttribute> equipmentAttributeMap
|
|
|
+ , List<WindTowerCalculationData> windTowerCalculationDataList, WindTowerInfo windTowerInfo) {
|
|
|
+ //月平均风速
|
|
|
+ ArrayList<WindTowerCalculationData> wsMonth = this.wsMonth(startDate, endDate, equipmentNo, windTowerCalculationDataList, equipmentAttributeMap, windTowerInfo);
|
|
|
+ dataList.addAll(wsMonth);
|
|
|
+ //月平均风功率密度
|
|
|
+ ArrayList<WindTowerCalculationData> wpdMonth = this.wpdMonth(startDate, endDate, equipmentNo, windTowerCalculationDataList, equipmentAttributeMap, windTowerInfo);
|
|
|
+ dataList.addAll(wpdMonth);
|
|
|
+ //月平均湍流
|
|
|
+ ArrayList<WindTowerCalculationData> turbulenceMonth = this.turbulenceMonth(startDate, endDate, equipmentNo, windTowerCalculationDataList, equipmentAttributeMap, windTowerInfo);
|
|
|
+ dataList.addAll(turbulenceMonth);
|
|
|
+ //月平均空气密度
|
|
|
+ ArrayList<WindTowerCalculationData> airDensityMonth = this.airDensityMonth(startDate, endDate, equipmentNo, windTowerCalculationDataList, equipmentAttributeMap);
|
|
|
+ dataList.addAll(airDensityMonth);
|
|
|
+ //月最大风速
|
|
|
+ ArrayList<WindTowerCalculationData> wsMaxMonth = this.wsMaxMonth(startDate, endDate, equipmentNo, prophaseAnemometryDataList, equipmentAttributeMap, windTowerInfo);
|
|
|
+ dataList.addAll(wsMaxMonth);
|
|
|
+ //月平均风切变
|
|
|
+ ArrayList<WindTowerCalculationData> shearMonth = this.shearMonth(startDate, endDate, equipmentNo, windTowerCalculationDataList, equipmentAttributeMap, windTowerInfo, prophaseAnemometryDataList);
|
|
|
+ dataList.addAll(shearMonth);
|
|
|
+ //月平均风速标差
|
|
|
+ ArrayList<WindTowerCalculationData> staMonth = this.staMonth(startDate, endDate, equipmentNo, prophaseAnemometryDataList, equipmentAttributeMap, windTowerInfo);
|
|
|
+ dataList.addAll(staMonth);
|
|
|
+
|
|
|
+ //月平均环境数据
|
|
|
+ ArrayList<WindTowerCalculationData> environmentData = this.environmentData(startDate, endDate, equipmentNo, prophaseWeatherDataList, equipmentAttributeMap);
|
|
|
+ dataList.addAll(environmentData);
|
|
|
+ //空气密度月逐时
|
|
|
+ ArrayList<WindTowerCalculationData> airDensityMonth1 = this.airDensityMonth(equipmentNo, startDate, endDate, prophaseWeatherDataList, equipmentAttributeMap);
|
|
|
+ dataList.addAll(airDensityMonth1);
|
|
|
+ //湍流月逐时
|
|
|
+ ArrayList<WindTowerCalculationData> turbulenceHourForMonth = this.turbulenceHourForMonth(equipmentNo, startDate, endDate, prophaseAnemometryDataList, equipmentAttributeMap, windTowerInfo);
|
|
|
+ dataList.addAll(turbulenceHourForMonth);
|
|
|
+ return dataList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 风功率密度和平均风速计算方法
|
|
|
+ */
|
|
|
+ public ArrayList<WindTowerCalculationData> calculateWindPowerDensity(Long startTime, Long endTime, String eqNo, List<ProphaseAnemometryData> prophaseAnemometryDataList
|
|
|
+ , List<ProphaseWeatherData> prophaseWeatherDataList, Map<String, EquipmentAttribute> equipmentAttributeMap, List<WindTowerCalculationData> windTowerCalculationDataList, WindTowerInfo windTowerInfo) {
|
|
|
+ //获取对应测风塔数据
|
|
|
+ List<ProphaseAnemometryData> anemometryDataList = prophaseAnemometryDataList.stream().filter(p -> p.getTs().getTime() >= startTime
|
|
|
+ && p.getTs().getTime() <= endTime && null != p.getWsAve() && p.getWsAve() > 0).collect(Collectors.toList());
|
|
|
+ List<ProphaseWeatherData> weatherDataList = prophaseWeatherDataList.stream().filter(p -> p.getTs().getTime() >= startTime
|
|
|
+ && p.getTs().getTime() <= endTime && null != p.getAirDensity() && p.getAirDensity() > 0).collect(Collectors.toList());
|
|
|
+
|
|
|
+
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ //遍历24小时,用来计算逐小时数据
|
|
|
+ for (long time = startTime; time <= endTime; time += oneHour) {
|
|
|
+ //过滤出对应测风塔数据
|
|
|
+ long finalTime = time;
|
|
|
+ //风数据过滤
|
|
|
+ List<ProphaseAnemometryData> anemometryData = anemometryDataList.stream().filter(w -> w.getTs().getTime() >= finalTime
|
|
|
+ && w.getTs().getTime() <= finalTime + oneHour - 1000 && w.getLayerHeight().equals(h)).collect(Collectors.toList());
|
|
|
+ if (anemometryData.isEmpty()) {
|
|
|
+ log.error("计算{}设备平均风速和风功率密度 无风速数据##,计算时间范围:{}", eqNo, DateTimeUtil.getFormatDateStr(time));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //根据层高获取所有风速数据
|
|
|
+ List<BigDecimal> bigDecimals = anemometryData.stream().map((ProphaseAnemometryData p) -> {
|
|
|
+ return BigDecimal.valueOf(p.getWsAve());
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //风速数据时所有计算的根本,无数据不计算
|
|
|
+ if (bigDecimals.isEmpty()) {
|
|
|
+ log.error("计算{}设备平均风速和风功率密度 无有效数据##,计算时间范围:{}", eqNo, DateTimeUtil.getFormatDateStr(time));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //环境数据过滤
|
|
|
+ List<ProphaseWeatherData> weatherData = weatherDataList.stream().filter(w -> w.getTs().getTime() >= finalTime
|
|
|
+ && w.getTs().getTime() <= finalTime + oneHour - 1000).collect(Collectors.toList());
|
|
|
+ SpeedAndDensityDto speedAndDensityDto = getSpeedAndDensityDto(bigDecimals, anemometryData, weatherData);
|
|
|
+ Date dataTime = new Date(time);
|
|
|
+ if (speedAndDensityDto.getWindPowerDensity().compareTo(BigDecimal.ZERO) < 0 ||
|
|
|
+ speedAndDensityDto.getWindSpeed().compareTo(BigDecimal.ZERO) < 0) {
|
|
|
+ log.error("计算风功率密度/平均风速出现异常值 平均风速:{} 风功率密度:{};时间:{} ;设备编号:{}", speedAndDensityDto.getWindSpeed(), speedAndDensityDto.getWindPowerDensity(), dataTime, eqNo);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //保存平均风速
|
|
|
+ WindTowerCalculationData windTowerCalculationData = new WindTowerCalculationData();
|
|
|
+ windTowerCalculationData.setTime(dataTime);
|
|
|
+ windTowerCalculationData.setEbId(equipmentAttributeAws.getId());
|
|
|
+ windTowerCalculationData.setEquipmentId(eqNo);
|
|
|
+ windTowerCalculationData.setValue(speedAndDensityDto.getWindSpeed());
|
|
|
+ windTowerCalculationDataList.add(windTowerCalculationData);
|
|
|
+ list.add(windTowerCalculationData);
|
|
|
+ //保存风功率密度
|
|
|
+ WindTowerCalculationData windTowerCalculationDataWpd = new WindTowerCalculationData();
|
|
|
+ windTowerCalculationDataWpd.setTime(dataTime);
|
|
|
+ windTowerCalculationDataWpd.setEbId(equipmentAttributeWpd.getId());
|
|
|
+ windTowerCalculationDataWpd.setEquipmentId(eqNo);
|
|
|
+ windTowerCalculationDataWpd.setValue(speedAndDensityDto.getWindPowerDensity());
|
|
|
+ windTowerCalculationDataList.add(windTowerCalculationDataWpd);
|
|
|
+ list.add(windTowerCalculationDataWpd);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("计算{}设备平均风速和风功率密度失败!!!{}", eqNo, e);
|
|
|
+ }
|
|
|
+ log.info("计算{}设备平均风速和风功率密度完成^ ^", eqNo);
|
|
|
+
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算月平均风速标差
|
|
|
+ *
|
|
|
+ * @param startTime 开始时间
|
|
|
+ * @param endTime 结束时间
|
|
|
+ * @param equipmentId 设备id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ArrayList<WindTowerCalculationData> staMonth(Date startTime, Date endTime, String
|
|
|
+ equipmentId, List<ProphaseAnemometryData> prophaseAnemometryDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap, WindTowerInfo windTowerInfo) {
|
|
|
+ //时间-1防止0点数据查不到
|
|
|
+ Date startHour = new Date(startTime.getTime() - 1);
|
|
|
+ List<ProphaseAnemometryData> collect = prophaseAnemometryDataList.stream().filter(p -> p.getTs().getTime() >= startTime.getTime()
|
|
|
+ && p.getTs().getTime() <= endTime.getTime() && null != p.getWsSta() && p.getWsSta() >= 0).collect(Collectors.toList());
|
|
|
+
|
|
|
+ ArrayList<WindTowerCalculationData> windTowerCalculationDataList = new ArrayList<>();
|
|
|
+ if (!collect.isEmpty()) {
|
|
|
+ String[] heights = windTowerInfo.getHeights().split(",");
|
|
|
+ //计算标差
|
|
|
+ for (String height : heights) {
|
|
|
+ EquipmentAttribute equipmentAttribute = equipmentAttributeMap.get(height + "staMonth");
|
|
|
+ BigDecimal sumSta = CalculationUtil.getBigDecimal(collect.stream().filter(c -> c.getLayerHeight().equals(height)).mapToDouble(ProphaseAnemometryData::getWsSta).sum());
|
|
|
+ WindTowerCalculationData windTowerCalculationData = new WindTowerCalculationData();
|
|
|
+ windTowerCalculationData.setEbId(equipmentAttribute.getId());
|
|
|
+ windTowerCalculationData.setTime(startHour);
|
|
|
+ windTowerCalculationData.setValue(sumSta.divide(new BigDecimal(collect.size()), 2, RoundingMode.HALF_UP));
|
|
|
+ windTowerCalculationData.setEquipmentId(equipmentId);
|
|
|
+ windTowerCalculationDataList.add(windTowerCalculationData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return windTowerCalculationDataList;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 温湿度气压月 最大,均值
|
|
|
+ *
|
|
|
+ * @param startTime 开始时间
|
|
|
+ * @param endTime 结束时间
|
|
|
+ * @param equipmentId 设备id
|
|
|
+ * @param equipmentAttributeMap 属性集合
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ArrayList<WindTowerCalculationData> environmentData(Date startTime, Date endTime, String equipmentId
|
|
|
+ , List<ProphaseWeatherData> prophaseWeatherDataList, Map<String, EquipmentAttribute> equipmentAttributeMap) {
|
|
|
+ ArrayList<WindTowerCalculationData> windTowerCalculationDataList = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ //时间-1防止0点数据查不到
|
|
|
+ Date startHour = new Date(startTime.getTime() - 1);
|
|
|
+ List<ProphaseWeatherData> prophaseWeatherData = prophaseWeatherDataList.stream().filter(p -> p.getTs().getTime() >= startHour.getTime()
|
|
|
+ && p.getTs().getTime() <= endTime.getTime()).collect(Collectors.toList());
|
|
|
+
|
|
|
+
|
|
|
+ if (prophaseWeatherData.isEmpty()) {
|
|
|
+ log.error("计算温湿度气压数据时,原数据{prophaseWeatherData}为空");
|
|
|
+ return windTowerCalculationDataList;
|
|
|
+ }
|
|
|
+ List<BigDecimal> paList = new ArrayList<>();
|
|
|
+ List<BigDecimal> rhList = new ArrayList<>();
|
|
|
+ List<BigDecimal> tList = new ArrayList<>();
|
|
|
+ /*计算平均值数值为null 不计算*/
|
|
|
+ for (ProphaseWeatherData map : prophaseWeatherData) {
|
|
|
+ if (null != map.getPaAve() && map.getPaAve() > 0) {
|
|
|
+ paList.add(CalculationUtil.getBigDecimal(map.getPaAve()));
|
|
|
+ }
|
|
|
+ if (null != map.getRhAve() && map.getRhAve() > 0) {
|
|
|
+ rhList.add(CalculationUtil.getBigDecimal(map.getRhAve()));
|
|
|
+ }
|
|
|
+ if (null != map.getTAve() && map.getTAve() != -99) {
|
|
|
+ tList.add(CalculationUtil.getBigDecimal(map.getTAve()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ BigDecimal sumPa = new BigDecimal(0);
|
|
|
+ BigDecimal avePa = new BigDecimal(0);
|
|
|
+
|
|
|
+ /*气压*/
|
|
|
+ BigDecimal maxPa = new BigDecimal(0);
|
|
|
+ BigDecimal minPa = new BigDecimal(0);
|
|
|
+ if (!paList.isEmpty()) {
|
|
|
+ maxPa = paList.stream().max(BigDecimal::compareTo).get();
|
|
|
+ minPa = paList.stream().min(BigDecimal::compareTo).get();
|
|
|
+ for (BigDecimal pa : paList) {
|
|
|
+ sumPa = sumPa.add(pa);
|
|
|
+ }
|
|
|
+ avePa = sumPa.divide(new BigDecimal(paList.size()), 2, RoundingMode.HALF_UP);
|
|
|
+ }
|
|
|
+
|
|
|
+ windTowerCalculationDataList.add(new WindTowerCalculationData(startTime, equipmentId, equipmentAttributeMap.get("paMAX").getId(), maxPa));
|
|
|
+ windTowerCalculationDataList.add(new WindTowerCalculationData(startTime, equipmentId, equipmentAttributeMap.get("paMIN").getId(), minPa));
|
|
|
+ windTowerCalculationDataList.add(new WindTowerCalculationData(startTime, equipmentId, equipmentAttributeMap.get("paAVE").getId(), avePa));
|
|
|
+
|
|
|
+ BigDecimal sumT = new BigDecimal(0);
|
|
|
+ BigDecimal aveT = new BigDecimal(0);
|
|
|
+ /*温度*/
|
|
|
+ BigDecimal maxT = new BigDecimal(0);
|
|
|
+ BigDecimal minT = new BigDecimal(0);
|
|
|
+ if (!tList.isEmpty()) {
|
|
|
+ maxT = tList.stream().max(BigDecimal::compareTo).get();
|
|
|
+ minT = tList.stream().min(BigDecimal::compareTo).get();
|
|
|
+ for (BigDecimal t : tList) {
|
|
|
+ sumT = sumT.add(t);
|
|
|
+ }
|
|
|
+ aveT = sumT.divide(new BigDecimal(tList.size()), 2, RoundingMode.HALF_UP);
|
|
|
+ }
|
|
|
+ windTowerCalculationDataList.add(new WindTowerCalculationData(startTime, equipmentId, equipmentAttributeMap.get("tMAX").getId(), maxT));
|
|
|
+ windTowerCalculationDataList.add(new WindTowerCalculationData(startTime, equipmentId, equipmentAttributeMap.get("tMIN").getId(), minT));
|
|
|
+ windTowerCalculationDataList.add(new WindTowerCalculationData(startTime, equipmentId, equipmentAttributeMap.get("tAVE").getId(), aveT));
|
|
|
+
|
|
|
+
|
|
|
+ BigDecimal sumRh = new BigDecimal(0);
|
|
|
+ BigDecimal aveRh = new BigDecimal(0);
|
|
|
+ /*湿度*/
|
|
|
+ BigDecimal maxRh = new BigDecimal(0);
|
|
|
+ BigDecimal minRh = new BigDecimal(0);
|
|
|
+ if (!rhList.isEmpty()) {
|
|
|
+ maxRh = rhList.stream().max(BigDecimal::compareTo).get();
|
|
|
+ minRh = rhList.stream().min(BigDecimal::compareTo).get();
|
|
|
+ for (BigDecimal rh : rhList) {
|
|
|
+ sumRh = sumRh.add(rh);
|
|
|
+ }
|
|
|
+ aveRh = sumRh.divide(new BigDecimal(rhList.size()), 2, RoundingMode.HALF_UP);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ windTowerCalculationDataList.add(new WindTowerCalculationData(startTime, equipmentId, equipmentAttributeMap.get("rhMAX").getId(), maxRh));
|
|
|
+ windTowerCalculationDataList.add(new WindTowerCalculationData(startTime, equipmentId, equipmentAttributeMap.get("rhMIN").getId(), minRh));
|
|
|
+ windTowerCalculationDataList.add(new WindTowerCalculationData(startTime, equipmentId, equipmentAttributeMap.get("rhAVE").getId(), aveRh));
|
|
|
+
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return windTowerCalculationDataList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 湍流月逐时
|
|
|
+ *
|
|
|
+ * @param equipmentId 设备Id
|
|
|
+ * @param startTime 开始时间
|
|
|
+ * @param endTime 结束时间
|
|
|
+ * @param equipmentAttributeMap 属性集合
|
|
|
+ * @param windTowerInfo 测风塔信息
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ArrayList<WindTowerCalculationData> turbulenceHourForMonth(String equipmentId, Date startTime, Date
|
|
|
+ endTime, List<ProphaseAnemometryData> prophaseAnemometryDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap, WindTowerInfo windTowerInfo) {
|
|
|
+ String[] heights = windTowerInfo.getHeights().split(",");
|
|
|
+
|
|
|
+ ArrayList<WindTowerCalculationData> list = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ //遍历层高
|
|
|
+ for (String h : heights) {
|
|
|
+ //获取湍流年逐时ebId
|
|
|
+ String ebId = equipmentAttributeMap.get(h + "turDayForMonth").getId();
|
|
|
+ HashMap<Integer, BigDecimal> timeAndTurMap = new HashMap<>();
|
|
|
+ HashMap<Integer, BigDecimal> totalAndTurMap = new HashMap<>();
|
|
|
+
|
|
|
+ //循环开始时间到时间一小时为间隔
|
|
|
+ for (long time = startTime.getTime(); time <= endTime.getTime(); time = time + oneHour) {
|
|
|
+
|
|
|
+ long startHour = time;
|
|
|
+ long endHour = time + oneHour;
|
|
|
+ //筛选小时数据
|
|
|
+ List<ProphaseAnemometryData> anemometryDataList = prophaseAnemometryDataList.stream()
|
|
|
+ .filter(p -> p.getTs().getTime() >= startHour && p.getTs().getTime() <= endHour && p.getLayerHeight().equals(h)).collect(Collectors.toList());
|
|
|
+
|
|
|
+
|
|
|
+ if (null == anemometryDataList || anemometryDataList.isEmpty()) {
|
|
|
+ log.warn("时间区间:{}-{} 计算设备:{} 层高:{} 原数据为空", DateTimeUtil.getFormatDateStr(time), DateTimeUtil.getFormatDateStr(endHour), equipmentId, h);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ BigDecimal turAve = BigDecimal.ZERO;
|
|
|
+ //循环实时数据计算总风速和标差
|
|
|
+ BigDecimal wsSun = CalculationUtil.getBigDecimal(anemometryDataList.stream().filter(a -> null != a.getWsAve()
|
|
|
+ && a.getWsAve() >= 0).mapToDouble(ProphaseAnemometryData::getWsAve).sum());
|
|
|
+ BigDecimal staSun = CalculationUtil.getBigDecimal(anemometryDataList.stream().filter(a -> null != a.getWsSta()
|
|
|
+ && a.getWsSta() >= 0).mapToDouble(ProphaseAnemometryData::getWsSta).sum());
|
|
|
+ //除以一小时的个数 求小时的平均值
|
|
|
+ BigDecimal wsAve = wsSun.divide(BigDecimal.valueOf(anemometryDataList.size()), 2, RoundingMode.HALF_UP);
|
|
|
+ BigDecimal staAve = staSun.divide(BigDecimal.valueOf(anemometryDataList.size()), 2, RoundingMode.HALF_UP);
|
|
|
+ //如果除数等于0就跳过本次循环
|
|
|
+ if (wsAve.compareTo(BigDecimal.ZERO) == 0 || staAve.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ log.warn("计算设备:{} 层高:{} 时间区间:{}-{} wsAve:{} staAve:{} ", equipmentId, h, DateTimeUtil.getFormatDateStr(time)
|
|
|
+ , DateTimeUtil.getFormatDateStr(endHour), wsAve.doubleValue(), staAve.doubleValue());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ turAve = staAve.divide(wsAve, 2, RoundingMode.HALF_UP);
|
|
|
+ //判断map中是否存在此小时的key 如果存在就把数值相加 个数加一
|
|
|
+ int curentHours = new Date(startHour).getHours();
|
|
|
+ if (timeAndTurMap.get(curentHours) != null) {
|
|
|
+
|
|
|
+ BigDecimal Average = timeAndTurMap.get(curentHours).add(turAve);
|
|
|
+ BigDecimal total = totalAndTurMap.get(curentHours).add(BigDecimal.ONE);
|
|
|
+
|
|
|
+ timeAndTurMap.put(curentHours, Average);
|
|
|
+ totalAndTurMap.put(curentHours, total);
|
|
|
+ } else {
|
|
|
+ //如果map中不存在这个key则直接把平均值加入 个数加一
|
|
|
+ timeAndTurMap.put(curentHours, turAve);
|
|
|
+ totalAndTurMap.put(curentHours, BigDecimal.ONE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (timeAndTurMap.entrySet().isEmpty()) {
|
|
|
+ log.error("计算设备:{} 层高:{} 时间区间:{}-{} 中间结果 {timeAndTurMap}为空,无法计算 湍流月逐时", equipmentId, h);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ //设置数据时间为开始时间
|
|
|
+ String start = yyyyMMdd.format(new Date(startTime.getTime()));
|
|
|
+ for (Map.Entry<Integer, BigDecimal> a : timeAndTurMap.entrySet()) {
|
|
|
+ Date timeMonth = yyyyMMddHH.parse(start + String.valueOf(a.getKey()));
|
|
|
+ BigDecimal airAve = a.getValue().divide(totalAndTurMap.get(a.getKey()), 2, RoundingMode.HALF_UP);
|
|
|
+ if (airAve.compareTo(zero) < 0) {
|
|
|
+ log.error("计算得到的湍流月逐时异常,为负数:{}", airAve);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ list.add(new WindTowerCalculationData(timeMonth, equipmentId, ebId, airAve));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ } catch (ParseException e) {
|
|
|
+ log.error("设备编号{},湍流年逐时计算错误", equipmentId);
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("设备编号{},湍流年逐时,计算完成", equipmentId);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 空气密度月逐时入库
|
|
|
+ *
|
|
|
+ * @param equipmentId 设备id
|
|
|
+ * @param startTime 开始时间
|
|
|
+ * @param endTime 结束时间
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ArrayList<WindTowerCalculationData> airDensityMonth(String equipmentId, Date startTime, Date
|
|
|
+ endTime, List<ProphaseWeatherData> prophaseWeatherDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap) {
|
|
|
+ //获取ebId
|
|
|
+ String ebId = equipmentAttributeMap.get("airDensityDayForYear").getId();
|
|
|
+ ArrayList<WindTowerCalculationData> list = new ArrayList<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ HashMap<Integer, BigDecimal> timeAndAirMap = new HashMap<>();
|
|
|
+ HashMap<Integer, BigDecimal> totalAndAirMap = new HashMap<>();
|
|
|
+
|
|
|
+ for (long time = startTime.getTime(); time <= endTime.getTime(); time = time + oneHour) {
|
|
|
+ BigDecimal airSun = BigDecimal.ZERO;
|
|
|
+ long startHour = time;
|
|
|
+ long endHour = time + oneHour;
|
|
|
+ List<ProphaseWeatherData> weatherDataList = prophaseWeatherDataList.stream().filter(p -> p.getTs().getTime() >= startHour
|
|
|
+ && p.getTs().getTime() <= endHour && null != p.getAirDensity() && p.getAirDensity() > 0).collect(Collectors.toList());
|
|
|
+ for (ProphaseWeatherData map : weatherDataList) {
|
|
|
+ //过滤异常数据
|
|
|
+ airSun = airSun.add(CalculationUtil.getBigDecimal(map.getAirDensity()));
|
|
|
+
|
|
|
+ }
|
|
|
+ if (weatherDataList.size() > 0) {
|
|
|
+ BigDecimal airAve = airSun.divide(BigDecimal.valueOf(weatherDataList.size()), 2, RoundingMode.HALF_UP);
|
|
|
+ //判断map的key是否包含此小时 不包含直接加入value中 包含则相加
|
|
|
+ int curentHours = new Date(startHour).getHours();
|
|
|
+ if (timeAndAirMap.get(curentHours) != null) {
|
|
|
+
|
|
|
+ BigDecimal Average = timeAndAirMap.get(curentHours).add(airAve);
|
|
|
+ BigDecimal total = totalAndAirMap.get(curentHours).add(BigDecimal.ONE);
|
|
|
+
|
|
|
+ timeAndAirMap.put(curentHours, Average);
|
|
|
+ totalAndAirMap.put(curentHours, total);
|
|
|
+ } else {
|
|
|
+ //如果map中不存在这个key则直接把平均值加入个数加一
|
|
|
+ timeAndAirMap.put(curentHours, airAve);
|
|
|
+ totalAndAirMap.put(curentHours, BigDecimal.ONE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (timeAndAirMap.entrySet().isEmpty()) {
|
|
|
+ log.error("计算设备:{} 中间结果 {timeAndAirMap}为空,无法计算 空气密度月逐时", equipmentId);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+ //设置数据时间为开始时间
|
|
|
+ String start = yyyyMMdd.format(new Date(startTime.getTime()));
|
|
|
+ for (Map.Entry<Integer, BigDecimal> a : timeAndAirMap.entrySet()) {
|
|
|
+ //拼接时间
|
|
|
+ Date time = yyyyMMddHH.parse(start + String.valueOf(a.getKey()));
|
|
|
+ BigDecimal airAve = a.getValue().divide(totalAndAirMap.get(a.getKey()), 2, RoundingMode.HALF_UP);
|
|
|
+ WindTowerCalculationData windTowerCalculationData = new WindTowerCalculationData();
|
|
|
+ windTowerCalculationData.setEbId(ebId);
|
|
|
+ windTowerCalculationData.setTime(time);
|
|
|
+ windTowerCalculationData.setEquipmentId(equipmentId);
|
|
|
+ windTowerCalculationData.setValue(airAve);
|
|
|
+ if (windTowerCalculationData.getValue().doubleValue() < 0) {
|
|
|
+ windTowerCalculationData.setValue(zero);
|
|
|
+ }
|
|
|
+ list.add(windTowerCalculationData);
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备编号{},空气密度月逐时计算错误:{}", equipmentId, e);
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("设备编号{},空气密度月逐时,计算完成", equipmentId);
|
|
|
+ return list;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 日平均温度入库
|
|
|
+ *
|
|
|
+ * @param startTime 开始时间
|
|
|
+ * @param endTime 结束时间
|
|
|
+ * @param equipmentId 设备Id
|
|
|
+ * @param equipmentAttributeMap 属性集合
|
|
|
+ */
|
|
|
+ public ArrayList<WindTowerCalculationData> tDay(Date startTime, Date endTime, String
|
|
|
+ equipmentId, List<ProphaseWeatherData> prophaseWeatherDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap) {
|
|
|
+ String ebId = equipmentAttributeMap.get(tDay).getId();
|
|
|
+
|
|
|
+ ArrayList<WindTowerCalculationData> tList = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ for (long time = startTime.getTime(); time < endTime.getTime(); time += oneDay) {
|
|
|
+ long dayTime = time;
|
|
|
+ //过滤一天数据
|
|
|
+ List<ProphaseWeatherData> collect = prophaseWeatherDataList.stream().filter(p -> p.getTs().getTime() >= dayTime && p.getTs().getTime() < dayTime + oneDay && p.getTAve() != null && p.getTAve() != -99).collect(Collectors.toList());
|
|
|
+ if (collect.isEmpty()) {
|
|
|
+ log.error("计算设备:{} 时间:{} 源数据为空,无法计算 日平均温度", equipmentId, DateTimeUtil.getFormatDateStr(dayTime));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //计算时间段内所有温度
|
|
|
+ BigDecimal tSum = CalculationUtil.getBigDecimal(collect.stream().mapToDouble(ProphaseWeatherData::getTAve).sum());
|
|
|
+ WindTowerCalculationData windTowerCalculationData = new WindTowerCalculationData();
|
|
|
+ windTowerCalculationData.setEbId(ebId);
|
|
|
+ windTowerCalculationData.setTime(new Date(dayTime));
|
|
|
+ windTowerCalculationData.setValue(tSum.divide(BigDecimal.valueOf(collect.size()), 2, RoundingMode.HALF_UP));
|
|
|
+
|
|
|
+ windTowerCalculationData.setEquipmentId(equipmentId);
|
|
|
+ tList.add(windTowerCalculationData);
|
|
|
+
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备{}日平均温度统计异常", equipmentId, e);
|
|
|
+ }
|
|
|
+ log.info("{}设备日平均温度计算完成", equipmentId);
|
|
|
+ return tList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 日平均气压入库
|
|
|
+ *
|
|
|
+ * @param startTime 开始时间
|
|
|
+ * @param endTime 结束时间
|
|
|
+ * @param equipmentId 设备Id
|
|
|
+ * @param equipmentAttributeMap 属性集合
|
|
|
+ */
|
|
|
+ public ArrayList<WindTowerCalculationData> paDay(Date startTime, Date endTime, String
|
|
|
+ equipmentId, List<ProphaseWeatherData> prophaseWeatherDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap) {
|
|
|
+ String ebId = equipmentAttributeMap.get("paDay").getId();
|
|
|
+
|
|
|
+ ArrayList<WindTowerCalculationData> list = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ for (long time = startTime.getTime(); time < endTime.getTime(); time += oneDay) {
|
|
|
+ long dayTime = time;
|
|
|
+ //过滤一天数据
|
|
|
+ List<ProphaseWeatherData> collect = prophaseWeatherDataList.stream().filter(p -> p.getTs().getTime() >= dayTime && p.getTs().getTime() < dayTime + oneDay
|
|
|
+ && null != p.getPaAve() && p.getPaAve() > 0).collect(Collectors.toList());
|
|
|
+ if (collect.isEmpty()) {
|
|
|
+ log.error("计算设备:{} 时间:{} 源数据为空,无法计算 日平均气压", equipmentId, DateTimeUtil.getFormatDateStr(dayTime));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ BigDecimal paSum = CalculationUtil.getBigDecimal(collect.stream().mapToDouble(ProphaseWeatherData::getPaAve).sum());
|
|
|
+ WindTowerCalculationData windTowerCalculationData = new WindTowerCalculationData();
|
|
|
+ windTowerCalculationData.setEbId(ebId);
|
|
|
+ windTowerCalculationData.setTime(new Date(dayTime));
|
|
|
+ windTowerCalculationData.setValue(paSum.divide(BigDecimal.valueOf(collect.size()), 2, RoundingMode.HALF_UP));
|
|
|
+ windTowerCalculationData.setEquipmentId(equipmentId);
|
|
|
+ list.add(windTowerCalculationData);
|
|
|
+
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备{}日平均气压统计异常", equipmentId, e);
|
|
|
+ }
|
|
|
+ log.info("{}设备日平均气压计算完成", equipmentId);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算上一个小时 每10分钟的风切变指数
|
|
|
+ */
|
|
|
+ public ArrayList<WindTowerCalculationData> calculateWindPowerShear(Date startTime, Date endTime, String
|
|
|
+ equipmentId
|
|
|
+ , List<ProphaseAnemometryData> prophaseAnemometryDataList, List<WindTowerCalculationData> windTowerCalculationDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap, WindTowerInfo windTowerInfo) {
|
|
|
+ log.info("开始计算小时风切变指数");
|
|
|
+ String[] heights = windTowerInfo.getHeights().split(",");
|
|
|
+ ArrayList<WindTowerCalculationData> listAll = new ArrayList<>();
|
|
|
+
|
|
|
+ String ebId = equipmentAttributeMap.get(windShearFiledName).getId();
|
|
|
+ try {
|
|
|
+ for (long start1 = startTime.getTime(); start1 <= endTime.getTime(); start1 = start1 + oneHour) {
|
|
|
+ //开始时间--->start1 结束时间---->start2
|
|
|
+ long start2 = start1 + oneHour;
|
|
|
+
|
|
|
+ long finalStart = start1;
|
|
|
+ List<ProphaseAnemometryData> collect = prophaseAnemometryDataList.stream().filter(p -> p.getTs().getTime() >= finalStart && p.getTs().getTime() < start2
|
|
|
+ && null != p.getWsAve() && p.getWsAve() >= 3).collect(Collectors.toList());
|
|
|
+ //计算综合风切变
|
|
|
+ if (collect.isEmpty()) {
|
|
|
+ log.error("计算设备:{} 时间:{} 源数据为空,无法计算 综合风切变", equipmentId, DateTimeUtil.getFormatDateStr(start1));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ BigDecimal windShear = CalculationUtil.getWindShear(collect, heights);
|
|
|
+ WindTowerCalculationData windTowerCalculationData = new WindTowerCalculationData();
|
|
|
+ windTowerCalculationData.setEquipmentId(equipmentId);
|
|
|
+ windTowerCalculationData.setTime(new Date(start1));
|
|
|
+ windTowerCalculationData.setValue(windShear);
|
|
|
+ windTowerCalculationData.setEbId(ebId);
|
|
|
+ windTowerCalculationDataList.add(windTowerCalculationData);
|
|
|
+ listAll.add(windTowerCalculationData);
|
|
|
+
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备{}小时风切变统计异常:{}", equipmentId, e);
|
|
|
+ }
|
|
|
+ log.info("{}设备风切变指数计算完成", equipmentId);
|
|
|
+ return listAll;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算日发电量与满发小时数
|
|
|
+ */
|
|
|
+
|
|
|
+ public ArrayList<WindTowerCalculationData> calculateBattery(Long startTime, Long endTime, WindTowerInfo
|
|
|
+ windTowerInfo, List<ProphaseAnemometryData> prophaseAnemometryDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap, List<WindTowerCalculationData> windTowerCalculationDataList) {
|
|
|
+
|
|
|
+ ArrayList<WindTowerCalculationData> batteryList = new ArrayList<>();
|
|
|
+ EquipmentAttribute batteryDay = equipmentAttributeMap.get("batteryDay");
|
|
|
+ //获取最高层高
|
|
|
+ String maxHeight = CalculationUtil.getNumberFromString(Arrays.asList(windTowerInfo.getHeights().split(",")).get(0));
|
|
|
+ for (long time = startTime; time < endTime; time += oneDay) {
|
|
|
+ long finalTime = time;
|
|
|
+ BigDecimal batterySum = prophaseAnemometryDataList.stream().filter(p -> p.getLayerHeight().equals(maxHeight) && null != p.getWsAve() && p.getWsAve() >= 0
|
|
|
+ && p.getTs().getTime() >= finalTime && p.getTs().getTime() < finalTime + oneDay)
|
|
|
+ .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(new Date(time)));
|
|
|
+ windTowerCalculationData.setEquipmentId(windTowerInfo.getEquipmentNo());
|
|
|
+ batteryList.add(windTowerCalculationData);
|
|
|
+ windTowerCalculationDataList.add(windTowerCalculationData);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ return batteryList;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算日平均空气密度
|
|
|
+ *
|
|
|
+ * @param startTime 开始时间
|
|
|
+ * @param endTime 结束时间
|
|
|
+ * @param equipmentId 设备ID
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ArrayList<WindTowerCalculationData> airDensityDay(Date startTime, Date endTime, String
|
|
|
+ equipmentId, List<ProphaseWeatherData> prophaseWeatherDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap, List<WindTowerCalculationData> windTowerCalculationDataList) {
|
|
|
+
|
|
|
+ long startHour = startTime.getTime();
|
|
|
+ long endHour = endTime.getTime();
|
|
|
+ //空气密度属性
|
|
|
+ EquipmentAttribute equipmentAttribute = equipmentAttributeMap.get("airDensity");
|
|
|
+ ArrayList<WindTowerCalculationData> list = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ for (long start1 = startHour; start1 < endHour; start1 = start1 + oneDay) {
|
|
|
+ //每天的结束时间
|
|
|
+ long start2 = start1 + oneDay - 1L;
|
|
|
+
|
|
|
+ long start = start1;
|
|
|
+ List<ProphaseWeatherData> collect = prophaseWeatherDataList.stream().filter(p -> p.getTs().getTime() >= start && p.getTs().getTime() <= start2
|
|
|
+ && null != p.getAirDensity() && p.getAirDensity() > 0).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //存平均值
|
|
|
+ if (collect.isEmpty()) {
|
|
|
+ log.error("计算设备:{} 时间:{} 源数据为空,无法计算 日平均空气密度", equipmentId, DateTimeUtil.getFormatDateStr(start1));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ BigDecimal airDensityDay = zero;
|
|
|
+ for (ProphaseWeatherData map : collect) {
|
|
|
+ airDensityDay = airDensityDay.add(CalculationUtil.getBigDecimal(map.getAirDensity()));
|
|
|
+ }
|
|
|
+ WindTowerCalculationData windTowerCalculationData = new WindTowerCalculationData();
|
|
|
+ windTowerCalculationData.setEbId(equipmentAttribute.getId());
|
|
|
+ windTowerCalculationData.setTime(new Date(start1));
|
|
|
+ windTowerCalculationData.setValue(airDensityDay.divide(new BigDecimal(collect.size()), 2, RoundingMode.HALF_UP));
|
|
|
+ if (windTowerCalculationData.getValue().doubleValue() < 0) {
|
|
|
+ windTowerCalculationData.setValue(zero);
|
|
|
+ }
|
|
|
+ windTowerCalculationData.setEquipmentId(equipmentId);
|
|
|
+ windTowerCalculationDataList.add(windTowerCalculationData);
|
|
|
+ list.add(windTowerCalculationData);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("计算日平均空气密度错误:{}", e);
|
|
|
+ }
|
|
|
+ log.info("计算日平均空气密度完成");
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算月最大风速
|
|
|
+ *
|
|
|
+ * @param startTime 开始时间
|
|
|
+ * @param endTime 结束时间
|
|
|
+ * @param equipmentId 设备id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ArrayList<WindTowerCalculationData> wsMaxMonth(Date startTime, Date endTime, String
|
|
|
+ equipmentId, List<ProphaseAnemometryData> prophaseAnemometryDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap, WindTowerInfo windTowerInfo) {
|
|
|
+
|
|
|
+ List<ProphaseAnemometryData> collect = prophaseAnemometryDataList.stream().filter(p -> p.getTs().getTime() >= startTime.getTime()
|
|
|
+ && p.getTs().getTime() <= endTime.getTime() && null != p.getWsMax() && p.getWsMax() >= 0).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //获取所有层高
|
|
|
+ String[] height = windTowerInfo.getHeights().split(",");
|
|
|
+ ArrayList<WindTowerCalculationData> list = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ if (!collect.isEmpty()) {
|
|
|
+ for (String h : height) {
|
|
|
+ //获取对应层高的字段
|
|
|
+ String ebIdMonth = equipmentAttributeMap.get(h + "maxwsMonth").getId();
|
|
|
+
|
|
|
+ BigDecimal max = CalculationUtil.getBigDecimal(collect.stream().filter(c -> c.getLayerHeight().equals(h)).mapToDouble(ProphaseAnemometryData::getWsMax).sum());
|
|
|
+ WindTowerCalculationData windTowerCalculationData = new WindTowerCalculationData();
|
|
|
+ windTowerCalculationData.setEbId(ebIdMonth);
|
|
|
+ windTowerCalculationData.setTime(startTime);
|
|
|
+ windTowerCalculationData.setEquipmentId(equipmentId);
|
|
|
+ windTowerCalculationData.setValue(max.divide(BigDecimal.valueOf(collect.size()), 2, RoundingMode.HALF_UP));
|
|
|
+ list.add(windTowerCalculationData);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.error("计算设备:{} 源数据为空,无法计算 月最大风速", equipmentId);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备编号{}月最大风速计算错误:{}", equipmentId, e);
|
|
|
+ }
|
|
|
+ log.info("设备编号{}月最大风速计算完成^ ^", equipmentId);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算月平均空气密度
|
|
|
+ *
|
|
|
+ * @param startTime 开始时间
|
|
|
+ * @param endTime 结束时间
|
|
|
+ * @param equipmentId 设备ID
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ArrayList<WindTowerCalculationData> airDensityMonth(Date startTime, Date endTime, String
|
|
|
+ equipmentId, List<WindTowerCalculationData> windTowerCalculationDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap) {
|
|
|
+ ArrayList<WindTowerCalculationData> list = new ArrayList<>();
|
|
|
+ //时间-1防止0点数据查不到
|
|
|
+ Date startHour = new Date(startTime.getTime() - 1);
|
|
|
+ //获取时间段所有统计数据
|
|
|
+ List<WindTowerCalculationData> windTowerCalculationDataList1 = windTowerCalculationDataList.stream().filter(w -> w.getEquipmentId().equals(equipmentId) && w.getTime().after(startHour) && w.getTime().before(endTime)).collect(Collectors.toList());
|
|
|
+
|
|
|
+ EquipmentAttribute equipmentAttribute = equipmentAttributeMap.get("airDensity");
|
|
|
+ EquipmentAttribute equipmentAttributeMonth = equipmentAttributeMap.get("airDensityMonth");
|
|
|
+
|
|
|
+ BigDecimal airDensityMonth = new BigDecimal(0);
|
|
|
+ try {
|
|
|
+
|
|
|
+ //所有数据日空气密度
|
|
|
+ List<WindTowerCalculationData> windCalDataList = windTowerCalculationDataList1.stream().filter(w -> w.getTime().after(startHour) &&
|
|
|
+ w.getTime().before(endTime) && w.getEquipmentId().equals(equipmentId) && w.getEbId().equals(equipmentAttribute.getId())).collect(Collectors.toList());
|
|
|
+ for (WindTowerCalculationData w : windCalDataList) {
|
|
|
+ airDensityMonth = airDensityMonth.add(w.getValue());
|
|
|
+ }
|
|
|
+ //平均值
|
|
|
+ if (!windCalDataList.isEmpty()) {
|
|
|
+ WindTowerCalculationData windTowerCalculationData = new WindTowerCalculationData();
|
|
|
+ windTowerCalculationData.setEbId(equipmentAttributeMonth.getId());
|
|
|
+ windTowerCalculationData.setTime(startTime);
|
|
|
+ windTowerCalculationData.setValue(airDensityMonth.divide(new BigDecimal(windCalDataList.size()), 2, RoundingMode.HALF_UP));
|
|
|
+ windTowerCalculationData.setEquipmentId(equipmentId);
|
|
|
+ list.add(windTowerCalculationData);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("计算月平均空气密度失败");
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ log.info("计算月平均空气密度完成");
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算日平均风速
|
|
|
+ *
|
|
|
+ * @param startTime 开始时间
|
|
|
+ * @param endTime 结束时间
|
|
|
+ * @param equipmentId 设备id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ArrayList<WindTowerCalculationData> wsDay(Date startTime, Date endTime, String
|
|
|
+ equipmentId, List<WindTowerCalculationData> windTowerCalculationDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap, WindTowerInfo windTowerInfo) {
|
|
|
+ long startHour = startTime.getTime();
|
|
|
+ long endHour = endTime.getTime();
|
|
|
+
|
|
|
+ //获取测风塔所有层高
|
|
|
+ String[] strings = windTowerInfo.getHeights().split(",");
|
|
|
+ List<WindTowerCalculationData> windTowerCalculationDataList1 = windTowerCalculationDataList.stream().filter(w -> w.getEquipmentId().equals(equipmentId) && w.getTime().after(startTime) && w.getTime().before(endTime)).collect(Collectors.toList());
|
|
|
+ ArrayList<WindTowerCalculationData> list = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ if (windTowerCalculationDataList1.isEmpty()) {
|
|
|
+ log.error("计算设备:{} 源数据为空,无法计算 日平均风速", equipmentId);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+ //遍历测风塔所有层高
|
|
|
+ for (String h : strings) {
|
|
|
+ //获取小时风速表
|
|
|
+ EquipmentAttribute awsEq = equipmentAttributeMap.get(h + "aws");
|
|
|
+ //获取日风速表
|
|
|
+ EquipmentAttribute awsDayEq = equipmentAttributeMap.get(h + "awsDay");
|
|
|
+
|
|
|
+ for (long start1 = startHour; start1 < endHour; start1 = start1 + oneDay) {
|
|
|
+ long start2 = start1 + oneDay - 1L;
|
|
|
+ //获取小时风速数据
|
|
|
+ long start = start1;
|
|
|
+ List<WindTowerCalculationData> wsCalDataList = windTowerCalculationDataList1.stream().filter(
|
|
|
+ w -> w.getTime().after(new Date(start)) &&
|
|
|
+ w.getTime().before(new Date(start2)) &&
|
|
|
+ w.getEquipmentId().equals(equipmentId) &&
|
|
|
+ w.getEbId().equals(awsEq.getId()))
|
|
|
+ .collect(Collectors.toList()
|
|
|
+ );
|
|
|
+ //小时风功率总值
|
|
|
+ BigDecimal awsSum = BigDecimal.ZERO;
|
|
|
+ for (WindTowerCalculationData ws : wsCalDataList) {
|
|
|
+ awsSum = awsSum.add(ws.getValue()).setScale(4, RoundingMode.HALF_UP);
|
|
|
+ }
|
|
|
+ if (!wsCalDataList.isEmpty()) {
|
|
|
+ WindTowerCalculationData windTowerCalculationData = new WindTowerCalculationData();
|
|
|
+ windTowerCalculationData.setEquipmentId(equipmentId);
|
|
|
+ windTowerCalculationData.setValue(awsSum.divide(new BigDecimal(wsCalDataList.size()), 2, RoundingMode.HALF_UP));
|
|
|
+ windTowerCalculationData.setEbId(awsDayEq.getId());
|
|
|
+ windTowerCalculationData.setTime(new Date(start1));
|
|
|
+ windTowerCalculationDataList.add(windTowerCalculationData);
|
|
|
+ list.add(windTowerCalculationData);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备编号{}日平均风速计算错误:{}", equipmentId, e);
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("设备编号{}米层高日平均风速计算完成", equipmentId);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算月平均风速
|
|
|
+ *
|
|
|
+ * @param startTime 开始时间
|
|
|
+ * @param endTime 结束时间
|
|
|
+ * @param equipmentId 设备编号
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ArrayList<WindTowerCalculationData> wsMonth(Date startTime, Date endTime, String
|
|
|
+ equipmentId, List<WindTowerCalculationData> windTowerCalculationDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap, WindTowerInfo windTowerInfo) {
|
|
|
+ //时间-1防止0点数据查不到
|
|
|
+ Date startHour = new Date(startTime.getTime() - 1);
|
|
|
+ //获取时间段所有统计数据
|
|
|
+ List<WindTowerCalculationData> windTowerCalculationDataList1 = windTowerCalculationDataList.stream().filter(w -> w.getEquipmentId().equals(equipmentId) && w.getTime().after(startHour) && w.getTime().before(endTime)).collect(Collectors.toList());
|
|
|
+
|
|
|
+ ArrayList<WindTowerCalculationData> list = new ArrayList<>();
|
|
|
+ //遍历层高
|
|
|
+ try {
|
|
|
+ if (windTowerCalculationDataList1.isEmpty()) {
|
|
|
+ log.error("计算设备:{} 源数据为空,无法计算 日平均风速", equipmentId);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+ //获取所有层高
|
|
|
+ String[] height = windTowerInfo.getHeights().split(",");
|
|
|
+ for (String h : height) {
|
|
|
+ //获取对应层高的月平均风速字段
|
|
|
+ String ebIdMonth = equipmentAttributeMap.get(h + "awsMonth").getId();
|
|
|
+ String ebIdDay = equipmentAttributeMap.get(h + "awsDay").getId();
|
|
|
+
|
|
|
+ //获取所有日平均风速
|
|
|
+ List<WindTowerCalculationData> windTowerCalculationDatas = windTowerCalculationDataList1.stream().filter(w -> w.getEbId().equals(ebIdDay)
|
|
|
+ && w.getTime().after(startHour) && w.getTime().before(endTime) && w.getEquipmentId().equals(equipmentId)).collect(Collectors.toList());
|
|
|
+ BigDecimal wsSum = new BigDecimal(0);
|
|
|
+
|
|
|
+ for (WindTowerCalculationData w : windTowerCalculationDatas) {
|
|
|
+ wsSum = wsSum.add(w.getValue());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!windTowerCalculationDatas.isEmpty()) {
|
|
|
+ WindTowerCalculationData windTowerCalculationData = new WindTowerCalculationData();
|
|
|
+ windTowerCalculationData.setEbId(ebIdMonth);
|
|
|
+ windTowerCalculationData.setTime(startTime);
|
|
|
+ windTowerCalculationData.setEquipmentId(equipmentId);
|
|
|
+ windTowerCalculationData.setValue(wsSum.divide(new BigDecimal(windTowerCalculationDatas.size()), 2, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP));
|
|
|
+ list.add(windTowerCalculationData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备编号{}月平均风速计算错误:{}", equipmentId, e);
|
|
|
+ }
|
|
|
+ log.info("{}设备月平均风速统计完成", equipmentId);
|
|
|
+ return list;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算日平均风功率密度
|
|
|
+ *
|
|
|
+ * @param startTime 开始时间
|
|
|
+ * @param endTime 结束时间
|
|
|
+ * @param equipmentId 设备id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ArrayList<WindTowerCalculationData> wpdDay(Date startTime, Date endTime, String
|
|
|
+ equipmentId, List<WindTowerCalculationData> windTowerCalculationDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap, WindTowerInfo windTowerInfo) {
|
|
|
+ long startHour = startTime.getTime();
|
|
|
+ long endHour = endTime.getTime();
|
|
|
+ List<WindTowerCalculationData> windTowerCalculationDataList1 = windTowerCalculationDataList.stream().filter(w -> w.getEquipmentId().equals(equipmentId) && w.getTime().after(startTime) && w.getTime().before(endTime)).collect(Collectors.toList());
|
|
|
+ //获取所有层高
|
|
|
+ String[] strings = windTowerInfo.getHeights().split(",");
|
|
|
+ ArrayList<WindTowerCalculationData> list = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ if (windTowerCalculationDataList1.isEmpty()) {
|
|
|
+ log.error("计算设备:{} 源数据为空,无法计算 日平均风功率密度", equipmentId);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+ //遍历层高
|
|
|
+ for (String h : strings) {
|
|
|
+ //获取所有小时风功率表
|
|
|
+ EquipmentAttribute wpdList = equipmentAttributeMap.get(h + "wpd");
|
|
|
+ //获取所有日风功率表
|
|
|
+ EquipmentAttribute wpdDayList = equipmentAttributeMap.get(h + "wpdDay");
|
|
|
+ for (long start1 = startHour; start1 < endHour; start1 = start1 + oneDay) {
|
|
|
+ long start2 = start1 + oneDay - 1L;
|
|
|
+
|
|
|
+ //获取所有小时风功率数据
|
|
|
+ long start = start1;
|
|
|
+ List<WindTowerCalculationData> wpdCalDataList = windTowerCalculationDataList1.stream().filter(w -> w.getTime().after(new Date(start)) &&
|
|
|
+ w.getTime().before(new Date(start2)) && w.getEquipmentId().equals(equipmentId) && w.getEbId().equals(wpdList.getId())).collect(Collectors.toList());
|
|
|
+ //小时风功率总值
|
|
|
+ BigDecimal wpdSum = BigDecimal.ZERO;
|
|
|
+ for (WindTowerCalculationData wpd : wpdCalDataList) {
|
|
|
+ wpdSum = wpdSum.add(wpd.getValue());
|
|
|
+ }
|
|
|
+ if (!wpdCalDataList.isEmpty()) {
|
|
|
+ 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(new Date(start1));
|
|
|
+ windTowerCalculationDataList.add(windTowerCalculationData);
|
|
|
+ list.add(windTowerCalculationData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备编号{}日平均风功率计算错误:{}", equipmentId, e);
|
|
|
+ }
|
|
|
+ log.info("设备编号{}日平均风功率计算完成^ ^", equipmentId);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算月平均风功率密度
|
|
|
+ *
|
|
|
+ * @param startTime 开始时间
|
|
|
+ * @param endTime 结束时间
|
|
|
+ * @param equipmentId 设备id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Transactional
|
|
|
+ public ArrayList<WindTowerCalculationData> wpdMonth(Date startTime, Date endTime, String
|
|
|
+ equipmentId, List<WindTowerCalculationData> windTowerCalculationDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap, WindTowerInfo windTowerInfo) {
|
|
|
+ //时间-1防止0点数据查不到
|
|
|
+ Date startHour = new Date(startTime.getTime() - 1);
|
|
|
+ //获取时间段所有统计数据
|
|
|
+ List<WindTowerCalculationData> windTowerCalculationDataList1 = windTowerCalculationDataList.stream().filter(w -> w.getEquipmentId().equals(equipmentId) && w.getTime().after(startHour)
|
|
|
+ && w.getTime().before(endTime)).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //获取所有层高
|
|
|
+ String[] height = windTowerInfo.getHeights().split(",");
|
|
|
+ ArrayList<WindTowerCalculationData> list = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ for (String h : height) {
|
|
|
+ //获取对应层高的月平均风速字段
|
|
|
+ String ebIdMonth = equipmentAttributeMap.get(h + "wpdMonth").getId();
|
|
|
+ String ebIdDay = equipmentAttributeMap.get(h + "wpdDay").getId();
|
|
|
+ //获取所有日平均风功率密度
|
|
|
+ List<WindTowerCalculationData> windTowerCalculationDatas = windTowerCalculationDataList1.stream().filter(w -> w.getEbId().equals(ebIdDay) && w.getTime().after(startHour)
|
|
|
+ && w.getTime().before(endTime) && w.getEquipmentId().equals(equipmentId)).collect(Collectors.toList());
|
|
|
+ BigDecimal sum = zero;
|
|
|
+
|
|
|
+ for (WindTowerCalculationData w : windTowerCalculationDatas) {
|
|
|
+ sum = sum.add(w.getValue());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!windTowerCalculationDatas.isEmpty()) {
|
|
|
+ WindTowerCalculationData windTowerCalculationData = new WindTowerCalculationData();
|
|
|
+ windTowerCalculationData.setEbId(ebIdMonth);
|
|
|
+ windTowerCalculationData.setTime(startTime);
|
|
|
+ windTowerCalculationData.setEquipmentId(equipmentId);
|
|
|
+ windTowerCalculationData.setValue(sum.divide(new BigDecimal(windTowerCalculationDatas.size()), 2, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP));
|
|
|
+ list.add(windTowerCalculationData);
|
|
|
+ } else {
|
|
|
+ log.error("计算设备:{} 源数据为空,无法计算 月平均风功率", equipmentId);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备编号{}月平均风功率计算错误:{}", equipmentId, e);
|
|
|
+ }
|
|
|
+ log.info("设备编号{}高月平均风功率计算完成", equipmentId);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算日平均风速标差
|
|
|
+ *
|
|
|
+ * @param startTime 开始时间
|
|
|
+ * @param endTime 结束时间
|
|
|
+ * @param equipmentId 测风塔编号
|
|
|
+ * @param equipmentAttributeMap 属性表
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ArrayList<WindTowerCalculationData> calculateStaDay(Date startTime, Date endTime, String
|
|
|
+ equipmentId, List<ProphaseAnemometryData> prophaseAnemometryDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap, WindTowerInfo
|
|
|
+ windTowerInfo, List<WindTowerCalculationData> windTowerCalculationDataList) {
|
|
|
+ ArrayList<WindTowerCalculationData> dataList = new ArrayList<>();
|
|
|
+ long startHour = startTime.getTime();
|
|
|
+ long endHour = endTime.getTime();
|
|
|
+ String[] heights = windTowerInfo.getHeights().split(",");
|
|
|
+ prophaseAnemometryDataList = prophaseAnemometryDataList.stream().filter(p -> null != p.getWsSta() && p.getWsSta() >= 0).collect(Collectors.toList());
|
|
|
+ try {
|
|
|
+ for (String h : heights) {
|
|
|
+ //获取对应层高的属性
|
|
|
+ EquipmentAttribute equipmentAttributes = equipmentAttributeMap.get(h + "staDay");
|
|
|
+ //每天循环
|
|
|
+ for (long time = startHour; time < endHour; time = time + oneDay) {
|
|
|
+ long startDate = time;
|
|
|
+ //过滤一天的数据
|
|
|
+ List<ProphaseAnemometryData> collect = prophaseAnemometryDataList.stream().filter(p -> p.getTs().getTime() >= startDate && p.getTs().getTime() < startDate + oneDay
|
|
|
+ && p.getLayerHeight().equals(h)).collect(Collectors.toList());
|
|
|
+
|
|
|
+ if (collect.size() > 0) {
|
|
|
+ BigDecimal staSum = CalculationUtil.getBigDecimal(collect.stream().mapToDouble(ProphaseAnemometryData::getWsSta).sum());
|
|
|
+ WindTowerCalculationData windTowerCalculationData = new WindTowerCalculationData();
|
|
|
+ windTowerCalculationData.setEquipmentId(equipmentId);
|
|
|
+ windTowerCalculationData.setTime(new Date(startDate));
|
|
|
+ windTowerCalculationData.setValue(staSum.divide(CalculationUtil.getBigDecimal(collect.size()), 2, RoundingMode.HALF_UP));
|
|
|
+ windTowerCalculationData.setEbId(equipmentAttributes.getId());
|
|
|
+ windTowerCalculationDataList.add(windTowerCalculationData);
|
|
|
+ dataList.add(windTowerCalculationData);
|
|
|
+ } else {
|
|
|
+ log.error("计算设备:{} 源数据为空,无法计算 日平均风速标差", equipmentId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备编号{}日平均风速标差计算错误:{} ", equipmentId, e);
|
|
|
+ }
|
|
|
+ log.info("设备编号{},风速标差数据计算完成", equipmentId);
|
|
|
+ return dataList;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算日平均湍流
|
|
|
+ *
|
|
|
+ * @param startTime 开始时间
|
|
|
+ * @param endTime 结束时间
|
|
|
+ * @param equipmentId 设备id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ArrayList<WindTowerCalculationData> turbulenceDay(Date startTime, Date endTime, String
|
|
|
+ equipmentId, Map<String, EquipmentAttribute> equipmentAttributeMap, WindTowerInfo
|
|
|
+ windTowerInfo, List<WindTowerCalculationData> windTowerCalculationDataList) {
|
|
|
+ long startHour = startTime.getTime();
|
|
|
+ long endHour = endTime.getTime();
|
|
|
+ String[] heightAll = windTowerInfo.getHeights().split(",");
|
|
|
+ //获取对应测风塔数据
|
|
|
+ ArrayList<WindTowerCalculationData> list = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ for (String h : heightAll) {
|
|
|
+
|
|
|
+ EquipmentAttribute turList = equipmentAttributeMap.get(h + turbulenceDay);
|
|
|
+ EquipmentAttribute staList = equipmentAttributeMap.get(h + staDay);
|
|
|
+ EquipmentAttribute wsList = equipmentAttributeMap.get(h + "awsDay");
|
|
|
+
|
|
|
+ for (long start1 = startHour; start1 < endHour; start1 = start1 + oneDay) {
|
|
|
+
|
|
|
+ long finalStart = start1;
|
|
|
+ List<WindTowerCalculationData> staDay = windTowerCalculationDataList.stream().filter(w -> w.getEbId().equals(staList.getId())
|
|
|
+ && w.getTime().getTime() == finalStart).collect(Collectors.toList());
|
|
|
+ List<WindTowerCalculationData> wsDay = windTowerCalculationDataList.stream().filter(w -> w.getEbId().equals(wsList.getId())
|
|
|
+ && w.getTime().getTime() == finalStart).collect(Collectors.toList());
|
|
|
+
|
|
|
+ if (!staDay.isEmpty() && !wsDay.isEmpty()) {
|
|
|
+
|
|
|
+ //数据入库
|
|
|
+ WindTowerCalculationData windTowerCalculationData = new WindTowerCalculationData();
|
|
|
+ windTowerCalculationData.setTime(new Date(start1));
|
|
|
+ windTowerCalculationData.setEbId(turList.getId());
|
|
|
+ windTowerCalculationData.setEquipmentId(equipmentId);
|
|
|
+ windTowerCalculationData.setValue(CalculationUtil.caTurbulenceIntensity(staDay.get(0).getValue(), wsDay.get(0).getValue()));
|
|
|
+ windTowerCalculationDataList.add(windTowerCalculationData);
|
|
|
+ list.add(windTowerCalculationData);
|
|
|
+ } else {
|
|
|
+ log.error("计算设备:{} 源数据为空,无法计算 日平均湍流", equipmentId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ log.error("设备编号{}日平均湍流计算错误:{}", equipmentId, e);
|
|
|
+ }
|
|
|
+ log.info("设备编号{}日平均湍流计算完成", equipmentId);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 月平均湍流
|
|
|
+ *
|
|
|
+ * @param startTime 开始时间
|
|
|
+ * @param endTime 结束时间
|
|
|
+ * @param equipmentId 设备编号
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ArrayList<WindTowerCalculationData> turbulenceMonth(Date startTime, Date endTime, String
|
|
|
+ equipmentId, List<WindTowerCalculationData> windTowerCalculationDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap, WindTowerInfo windTowerInfo) {
|
|
|
+ //时间-1防止0点数据查不到
|
|
|
+ Date startHour = new Date(startTime.getTime() - 1);
|
|
|
+ //获取时间段所有统计数据
|
|
|
+ List<WindTowerCalculationData> windTowerCalculationDataList1 = windTowerCalculationDataList.stream().filter(w -> w.getEquipmentId().equals(equipmentId) && w.getTime().after(startHour) && w.getTime().before(endTime)).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //获取所有层高
|
|
|
+ String[] height = windTowerInfo.getHeights().split(",");
|
|
|
+ ArrayList<WindTowerCalculationData> list = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ for (String h : height) {
|
|
|
+ //获取对应层高的月平均风速字段
|
|
|
+ String ebIdDay = equipmentAttributeMap.get(h + "turbulenceDay").getId();
|
|
|
+ String ebIdMonth = equipmentAttributeMap.get(h + "turbulenceMonth").getId();
|
|
|
+
|
|
|
+ //获取所有日平均湍流风速
|
|
|
+ List<WindTowerCalculationData> windTowerCalculationDatas = windTowerCalculationDataList1.stream().filter(w -> w.getEbId().equals(ebIdDay) && w.getTime().after(startHour)
|
|
|
+ && w.getTime().before(endTime) && w.getEquipmentId().equals(equipmentId)).collect(Collectors.toList());
|
|
|
+ BigDecimal sum = new BigDecimal(0);
|
|
|
+
|
|
|
+ for (WindTowerCalculationData w : windTowerCalculationDatas) {
|
|
|
+ sum = sum.add(w.getValue());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!windTowerCalculationDatas.isEmpty()) {
|
|
|
+ WindTowerCalculationData windTowerCalculationData = new WindTowerCalculationData();
|
|
|
+ windTowerCalculationData.setEbId(ebIdMonth);
|
|
|
+ windTowerCalculationData.setTime(startTime);
|
|
|
+ windTowerCalculationData.setEquipmentId(equipmentId);
|
|
|
+ windTowerCalculationData.setValue(sum.divide(new BigDecimal(windTowerCalculationDatas.size()), 2, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP));
|
|
|
+ list.add(windTowerCalculationData);
|
|
|
+ } else {
|
|
|
+ log.error("计算设备:{} 源数据为空,无法计算 月平均湍流", equipmentId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备编号{}月平均湍流计算错误:{}", equipmentId, e);
|
|
|
+ }
|
|
|
+ log.info("设备编号{}月平均湍流计算完成", equipmentId);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算日风切变入库
|
|
|
+ *
|
|
|
+ * @param startTime 开始时间
|
|
|
+ * @param endTime 结束时间
|
|
|
+ * @param equipmentId 设备id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ArrayList<WindTowerCalculationData> shearDay(Date startTime, Date endTime, String
|
|
|
+ equipmentId, List<WindTowerCalculationData> windTowerCalculationDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap, WindTowerInfo
|
|
|
+ windTowerInfo, List<ProphaseAnemometryData> prophaseAnemometryDataList) {
|
|
|
+ long startHour = startTime.getTime();
|
|
|
+ long endHour = endTime.getTime();
|
|
|
+ String[] heights = windTowerInfo.getHeights().split(",");
|
|
|
+ List<ProphaseAnemometryData> prophaseAnemometryData = prophaseAnemometryDataList.stream().filter(p -> null != p.getWsAve() && p.getWsAve() >= 3).collect(Collectors.toList());
|
|
|
+ ArrayList<WindTowerCalculationData> list = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ //获取日综合风切变
|
|
|
+ EquipmentAttribute shearDayList = equipmentAttributeMap.get(windShearDayFiledName);
|
|
|
+
|
|
|
+ for (long start1 = startHour; start1 < endHour; start1 = start1 + oneDay) {
|
|
|
+ long start2 = start1 + oneDay - 1L;
|
|
|
+
|
|
|
+ //获取所有小时风切变数据
|
|
|
+ long start = start1;
|
|
|
+ List<ProphaseAnemometryData> collect = prophaseAnemometryData.stream().filter(p -> p.getTs().getTime() >= start && p.getTs().getTime() < start2).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(new Date(start1));
|
|
|
+ windTowerCalculationDataList.add(windTowerCalculationData);
|
|
|
+ list.add(windTowerCalculationData);
|
|
|
+ } else {
|
|
|
+ log.error("计算设备:{} 源数据为空,无法计算 日平均风切变", equipmentId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备编号{}日平均风切变计算错误", equipmentId, e);
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ log.info("设备编号{}日平均风切变计算完成", equipmentId);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算月风切变入库
|
|
|
+ *
|
|
|
+ * @param startTime 开始时间
|
|
|
+ * @param endTime 结束时间
|
|
|
+ * @param equipmentId 设备id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ArrayList<WindTowerCalculationData> shearMonth(Date startTime, Date endTime, String
|
|
|
+ equipmentId, List<WindTowerCalculationData> windTowerCalculationDataList
|
|
|
+ , 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();
|
|
|
+ List<ProphaseAnemometryData> collect = prophaseAnemometryDataList.stream().filter(p -> p.getTs().getTime() >= startTime.getTime()
|
|
|
+ && p.getTs().getTime() < endTime.getTime() && null != p.getWsAve() && p.getWsAve() >= 3).collect(Collectors.toList());
|
|
|
+ BigDecimal windShear = CalculationUtil.getWindShear(collect, heights.split(","));
|
|
|
+
|
|
|
+ if (collect.size() > 0) {
|
|
|
+ WindTowerCalculationData windTowerCalculationData = new WindTowerCalculationData();
|
|
|
+ windTowerCalculationData.setEbId(ebIdMonth);
|
|
|
+ windTowerCalculationData.setTime(startTime);
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 玫瑰图 数据计算
|
|
|
+ */
|
|
|
+ public void roseMonth(Date startTime, Date endTime, String equipmentId
|
|
|
+ , List<ProphaseAnemometryData> prophaseAnemometryDataList, List<ProphaseWeatherData> prophaseWeatherDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap, WindTowerInfo windTowerInfo) {
|
|
|
+
|
|
|
+ //风数据
|
|
|
+ List<ProphaseAnemometryData> anemometryDataList = prophaseAnemometryDataList.stream().filter(p -> p.getTs().getTime() >= startTime.getTime()
|
|
|
+ && p.getTs().getTime() <= endTime.getTime()).collect(Collectors.toList());
|
|
|
+ //环境数据
|
|
|
+ List<ProphaseWeatherData> weatherDataList = prophaseWeatherDataList.stream().filter(p -> p.getTs().getTime() >= startTime.getTime()
|
|
|
+ && p.getTs().getTime() <= endTime.getTime()).collect(Collectors.toList());
|
|
|
+
|
|
|
+ ArrayList<WindDirectionStatisticsData> list = new ArrayList<>();
|
|
|
+ //获取所有层高
|
|
|
+ String[] heights = windTowerInfo.getWdHeights().split(",");
|
|
|
+ if (!anemometryDataList.isEmpty() && !weatherDataList.isEmpty()) {
|
|
|
+ //风向玫瑰图
|
|
|
+ ArrayList<WindDirectionStatisticsData> wdRose = wdRose(startTime, endTime, equipmentId, anemometryDataList, equipmentAttributeMap, heights);
|
|
|
+ list.addAll(wdRose);
|
|
|
+ //风功率玫瑰图
|
|
|
+ ArrayList<WindDirectionStatisticsData> powerRose = powerRose(startTime, endTime, equipmentId, anemometryDataList, weatherDataList, equipmentAttributeMap, heights);
|
|
|
+ list.addAll(powerRose);
|
|
|
+ //湍流玫瑰图
|
|
|
+ ArrayList<WindDirectionStatisticsData> turRose = turRose(startTime, endTime, equipmentId, anemometryDataList, equipmentAttributeMap, heights);
|
|
|
+ list.addAll(turRose);
|
|
|
+ //风切变玫瑰图
|
|
|
+ ArrayList<WindDirectionStatisticsData> windShearRose = windShearRose(startTime, endTime, equipmentId, anemometryDataList, equipmentAttributeMap, heights);
|
|
|
+ list.addAll(windShearRose);
|
|
|
+ windDirectionStatisticsDataServiceImpl.saveBatch(list);
|
|
|
+ } else {
|
|
|
+ log.info("设备编号{},{}月,玫瑰图计算失败,缺少测风塔数据^ ^", equipmentId, startTime.getMonth() + 1);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 风向玫瑰图统计计算
|
|
|
+ */
|
|
|
+ public ArrayList<WindDirectionStatisticsData> wdRose(Date startTime, Date endTime, String
|
|
|
+ equipmentId, List<ProphaseAnemometryData> anemometryDataList, Map<String, EquipmentAttribute> equipmentAttributeMap, String[]
|
|
|
+ heights) {
|
|
|
+ ArrayList<WindDirectionStatisticsData> list = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ for (String height : heights) {
|
|
|
+ String ebIdMonth = equipmentAttributeMap.get(height + "monthWdRose").getId();
|
|
|
+ //删除时间段所有数据
|
|
|
+ windDirectionStatisticsDataServiceImpl.removeByStartTimeBetweenAndEquipmentIdAndEbId(new Date(startTime.getTime() - 1), endTime, equipmentId, ebIdMonth);
|
|
|
+ //筛选本层风数据
|
|
|
+ List<ProphaseAnemometryData> collect = anemometryDataList.stream().filter(a -> a.getLayerHeight().equals(height)).collect(Collectors.toList());
|
|
|
+ for (WindDirectionEnum value : WindDirectionEnum.values()) {
|
|
|
+
|
|
|
+ List<ProphaseAnemometryData> forHeightAndWindDirectionEnum = CalculationUtil.getForHeightAndWindDirectionEnum(collect, value);
|
|
|
+ if (!forHeightAndWindDirectionEnum.isEmpty()) {
|
|
|
+ WindDirectionStatisticsData windDirectionStatisticsData = new WindDirectionStatisticsData();
|
|
|
+ windDirectionStatisticsData.setEbId(ebIdMonth);
|
|
|
+ windDirectionStatisticsData.setTime(startTime);
|
|
|
+ windDirectionStatisticsData.setEquipmentId(equipmentId);
|
|
|
+ windDirectionStatisticsData.setDirection(value.name());
|
|
|
+ windDirectionStatisticsData.setValue(BigDecimal.valueOf(forHeightAndWindDirectionEnum.size()));
|
|
|
+ list.add(windDirectionStatisticsData);
|
|
|
+ } else {
|
|
|
+ log.error("计算设备:{} 源数据为空,无法计算 风向玫瑰图统计", equipmentId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 风功率玫瑰图统计计算
|
|
|
+ */
|
|
|
+ public ArrayList<WindDirectionStatisticsData> powerRose(Date startTime, Date endTime, String
|
|
|
+ equipmentId, List<ProphaseAnemometryData> anemometryDataList, List<ProphaseWeatherData> prophaseWeatherDataList, Map<String, EquipmentAttribute> equipmentAttributeMap, String[]
|
|
|
+ heights) {
|
|
|
+ ArrayList<WindDirectionStatisticsData> list = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ for (String height : heights) {
|
|
|
+ String ebIdMonth = equipmentAttributeMap.get(height + "monthPowerRose").getId();
|
|
|
+ //删除时间段所有数据
|
|
|
+ windDirectionStatisticsDataServiceImpl.removeByStartTimeBetweenAndEquipmentIdAndEbId(startTime, endTime, equipmentId, ebIdMonth);
|
|
|
+ List<ProphaseAnemometryData> collect = anemometryDataList.stream().filter(a -> a.getLayerHeight().equals(height)).collect(Collectors.toList());
|
|
|
+ for (WindDirectionEnum value : WindDirectionEnum.values()) {
|
|
|
+ List<ProphaseAnemometryData> forHeightAndWindDirectionEnum = CalculationUtil.getForHeightAndWindDirectionEnum(collect, value);
|
|
|
+ if (!forHeightAndWindDirectionEnum.isEmpty()) {
|
|
|
+ //根据风向获取风能数
|
|
|
+ BigDecimal bigDecimal = CalculationUtil.windEnergyDensity(forHeightAndWindDirectionEnum, prophaseWeatherDataList);
|
|
|
+ // 数据集合
|
|
|
+ WindDirectionStatisticsData windDirectionStatisticsData = new WindDirectionStatisticsData();
|
|
|
+ windDirectionStatisticsData.setEbId(ebIdMonth);
|
|
|
+ windDirectionStatisticsData.setTime(startTime);
|
|
|
+ windDirectionStatisticsData.setEquipmentId(equipmentId);
|
|
|
+ windDirectionStatisticsData.setDirection(value.name());
|
|
|
+ windDirectionStatisticsData.setValue(bigDecimal.equals(new BigDecimal(-99)) ? zero : bigDecimal);
|
|
|
+ list.add(windDirectionStatisticsData);
|
|
|
+ } else {
|
|
|
+ log.error("计算设备:{} 源数据为空,无法计算 风功率玫瑰图统计", equipmentId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 湍流玫瑰图统计计算
|
|
|
+ */
|
|
|
+ public ArrayList<WindDirectionStatisticsData> turRose(Date startTime, Date endTime, String
|
|
|
+ equipmentId, List<ProphaseAnemometryData> prophaseAnemometryDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap, String[] heights) {
|
|
|
+ BigDecimal zero = new BigDecimal(0);
|
|
|
+ ArrayList<WindDirectionStatisticsData> list = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ for (String height : heights) {
|
|
|
+ String ebIdMonth = equipmentAttributeMap.get(height + "monthTurRose").getId();
|
|
|
+ //删除时间段所有数据
|
|
|
+ windDirectionStatisticsDataServiceImpl.removeByStartTimeBetweenAndEquipmentIdAndEbId(startTime, endTime, equipmentId, ebIdMonth);
|
|
|
+ List<ProphaseAnemometryData> prophaseAnemometryData = prophaseAnemometryDataList.stream().filter(p -> p.getLayerHeight().equals(height)).collect(Collectors.toList());
|
|
|
+ for (WindDirectionEnum value : WindDirectionEnum.values()) {
|
|
|
+ List<ProphaseAnemometryData> heightAndWindDirectionEnum = CalculationUtil.getForHeightAndWindDirectionEnum(prophaseAnemometryData, value);
|
|
|
+
|
|
|
+ if (!heightAndWindDirectionEnum.isEmpty()) {
|
|
|
+ //获取指定层高风速数据
|
|
|
+ List<BigDecimal> wsForHeight = heightAndWindDirectionEnum.stream().filter(h -> h.getWsAve() != null && h.getWsAve() != 0 && h.getWsAve() != -99).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(startTime);
|
|
|
+ windDirectionStatisticsData.setEquipmentId(equipmentId);
|
|
|
+ windDirectionStatisticsData.setDirection(value.name());
|
|
|
+ windDirectionStatisticsData.setValue(bigDecimal.equals(new BigDecimal(-99)) ? zero : bigDecimal);
|
|
|
+ list.add(windDirectionStatisticsData);
|
|
|
+ } else {
|
|
|
+ log.error("计算设备:{} 源数据为空,无法计算 湍流玫瑰图统计", equipmentId);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 风切变玫瑰图统计计算
|
|
|
+ */
|
|
|
+ public ArrayList<WindDirectionStatisticsData> windShearRose(Date startTime, Date endTime, String
|
|
|
+ equipmentId, List<ProphaseAnemometryData> anemometryDataList
|
|
|
+ , Map<String, EquipmentAttribute> equipmentAttributeMap, String[] heights) {
|
|
|
+ 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();
|
|
|
+ //删除时间段所有数据
|
|
|
+ windDirectionStatisticsDataServiceImpl.removeByStartTimeBetweenAndEquipmentIdAndEbId(startTime, endTime, equipmentId, ebIdMonth);
|
|
|
+ for (WindDirectionEnum value : WindDirectionEnum.values()) {
|
|
|
+
|
|
|
+ List<ProphaseAnemometryData> heightAndWindDirectionEnum = CalculationUtil.getForHeightAndWindDirectionEnum(anemometryDataList, value);
|
|
|
+ if (!heightAndWindDirectionEnum.isEmpty()) {
|
|
|
+ //获取指定层高风速数据
|
|
|
+ List<BigDecimal> wsForHeight = heightAndWindDirectionEnum.stream().filter(h -> h.getWsAve() != null && h.getWsAve() != 0 && h.getWsAve() != -99 && h.getLayerHeight().equals(height)).map((ProphaseAnemometryData p) ->
|
|
|
+ {
|
|
|
+ return CalculationUtil.getBigDecimal(p.getWsAve());
|
|
|
+ }
|
|
|
+ ).collect(Collectors.toList());
|
|
|
+ //计算当前层高平均风速
|
|
|
+ BigDecimal avgWindSpeed = CalculationUtil.getAvgWind(wsForHeight);
|
|
|
+ //获取指定最小层高风速数据
|
|
|
+ String finalHeightMin = String.valueOf(heightMin);
|
|
|
+ List<BigDecimal> wsMinForHeight = heightAndWindDirectionEnum.stream().filter(h -> h.getWsAve() != null && h.getWsAve() != 0 && h.getWsAve() != -99 && h.getLayerHeight().equals(finalHeightMin)).map((ProphaseAnemometryData p) ->
|
|
|
+ {
|
|
|
+ return CalculationUtil.getBigDecimal(p.getWsAve());
|
|
|
+ }
|
|
|
+ ).collect(Collectors.toList());
|
|
|
+ //计算最小层高平均风速
|
|
|
+ BigDecimal minAvgWindSpeed = CalculationUtil.getAvgWind(wsMinForHeight);
|
|
|
+ BigDecimal bigDecimal = new BigDecimal(-99);
|
|
|
+
|
|
|
+ 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(startTime);
|
|
|
+ windDirectionStatisticsData.setEquipmentId(equipmentId);
|
|
|
+ windDirectionStatisticsData.setDirection(value.name());
|
|
|
+ windDirectionStatisticsData.setValue(bigDecimal.equals(new BigDecimal(-99)) ? zero : bigDecimal);
|
|
|
+ list.add(windDirectionStatisticsData);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ speedAndDensityDto.setWindPowerDensity(CalculationUtil.windEnergyDensity(anemometryData, weatherData));
|
|
|
+
|
|
|
+ return speedAndDensityDto;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|