|
@@ -1,6 +1,8 @@
|
|
|
package com.jiayue.biz.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.db.Entity;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.jiayue.biz.domain.*;
|
|
|
import com.jiayue.biz.dto.EquipmentDto;
|
|
@@ -8,6 +10,8 @@ import com.jiayue.biz.dto.ProjectEvolveDto;
|
|
|
import com.jiayue.biz.dto.ProjectInfoDto;
|
|
|
import com.jiayue.biz.dto.SelectLabForVal;
|
|
|
import com.jiayue.biz.eunms.WindDirectionEnum;
|
|
|
+import com.jiayue.biz.mapper.ProphaseAnemometryDataMapper;
|
|
|
+import com.jiayue.biz.mapper.ProphaseWeatherDataMapper;
|
|
|
import com.jiayue.biz.mapper.WindTowerDataParentTableMapper;
|
|
|
import com.jiayue.biz.service.*;
|
|
|
import com.jiayue.biz.util.CalculationUtil;
|
|
@@ -15,12 +19,14 @@ import com.jiayue.biz.util.DateTimeUtil;
|
|
|
import com.jiayue.common.core.redis.RedisCache;
|
|
|
import com.jiayue.common.utils.DateUtil;
|
|
|
import com.jiayue.common.utils.spring.SpringUtils;
|
|
|
+import com.sun.corba.se.spi.ior.ObjectKey;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
+import java.sql.Timestamp;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
@@ -53,6 +59,11 @@ public class HomePageServiceImpl extends ServiceImpl<WindTowerDataParentTableMap
|
|
|
private final TotalityInfoService totalityInfoService;
|
|
|
private final FanModelDataService fanModelDataService;
|
|
|
|
|
|
+ private final ProphaseAnemometryDataMapper prophaseAnemometryDataMapper;
|
|
|
+ private final ProphaseWeatherDataMapper prophaseWeatherDataMapper;
|
|
|
+
|
|
|
+ private final OtherStationInfoService otherStationInfoService;
|
|
|
+
|
|
|
|
|
|
private final BigDecimal threeParameterOne = new BigDecimal("1.146");
|
|
|
private final BigDecimal threeParameterTow = new BigDecimal("77.42");
|
|
@@ -71,52 +82,64 @@ public class HomePageServiceImpl extends ServiceImpl<WindTowerDataParentTableMap
|
|
|
public Map<String, Object> getWsAndWpdForHeight(String equipmentId, String month) {
|
|
|
List<WindTowerInfo> windTowerInfoList = windTowerInfoService.lambdaQuery().eq(WindTowerInfo::getEquipmentNo, equipmentId).list();
|
|
|
String[] heights = windTowerInfoList.get(0).getHeights().split(",");
|
|
|
- List<Map<String, Object>> mapList = new ArrayList<>();
|
|
|
+ //风速数据
|
|
|
+ List<ProphaseAnemometryData> prophaseAnemometryDataList = new ArrayList<>();
|
|
|
+ //空气密度
|
|
|
+ List<ProphaseWeatherData> weatherDataList = new ArrayList<>();
|
|
|
if (!month.equals("")) {
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
|
|
|
try {
|
|
|
Date startDate = sdf.parse(month);
|
|
|
Date endDate = DateTimeUtil.endOfMonth(startDate);
|
|
|
- mapList = selectDataByBetweenTimeAndEquipmetId(startDate, endDate, equipmentId);
|
|
|
+ prophaseAnemometryDataList = prophaseAnemometryDataMapper.selectWsAve(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
|
|
|
+ weatherDataList = prophaseWeatherDataMapper.selectAir(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
|
|
|
} catch (ParseException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
} else {
|
|
|
// 最新一天数据
|
|
|
- mapList = windTowerDataParentTableService.getStartTimeAndEndTimeForData(equipmentId);
|
|
|
+ List<Entity> lastData = prophaseWeatherDataMapper.getLastData(equipmentId);
|
|
|
+ Timestamp timeEnd = (Timestamp) lastData.get(0).get("last (ts)");
|
|
|
+ DateTime startTime = DateUtil.beginOfDay(new Date(timeEnd.getTime()));
|
|
|
+ prophaseAnemometryDataList = prophaseAnemometryDataMapper.selectWsAve(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
|
|
|
+ weatherDataList = prophaseWeatherDataMapper.selectAir(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
|
|
|
+
|
|
|
}
|
|
|
- // 最新一天数据
|
|
|
-// List<Map<String, Object>> mapList = windTowerDataParentTableService.getStartTimeAndEndTimeForData(equipmentId);
|
|
|
- //空气密度不涉及层高
|
|
|
- List<BigDecimal> airList = CalculationUtil.getAir(mapList);
|
|
|
- //空气密度总和
|
|
|
- BigDecimal airSum = airList.stream().reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ //时间和空气密度map
|
|
|
+ Map<Timestamp, Float> timeAndAirMap = weatherDataList.stream().collect(Collectors.toMap(ProphaseWeatherData::getTs, ProphaseWeatherData::getAirDensity));
|
|
|
+
|
|
|
HashMap<String, Object> dataMap = new HashMap<>();
|
|
|
ArrayList<BigDecimal> wpdList = new ArrayList<>();
|
|
|
ArrayList<BigDecimal> wsList = new ArrayList<>();
|
|
|
ArrayList<String> heightList = new ArrayList<>();
|
|
|
|
|
|
for (String height : heights) {
|
|
|
- BigDecimal wpdSum = BigDecimal.ZERO;
|
|
|
- HashMap<String, Object> heightMap = new HashMap<>();
|
|
|
- //获取该层高所有风速
|
|
|
- List<BigDecimal> wsForHeight = CalculationUtil.getWsForHeight(mapList, height);
|
|
|
- if (wsForHeight.size() > 0) {
|
|
|
- //本层空气密度平均值
|
|
|
- BigDecimal airAve = airSum.divide(BigDecimal.valueOf(mapList.size()), 2, RoundingMode.HALF_UP);
|
|
|
- //循环计算空气密度 * 风速立方
|
|
|
- for (BigDecimal ws : wsForHeight) {
|
|
|
- wpdSum = wpdSum.add(ws.multiply(ws).multiply(ws).multiply(airAve));
|
|
|
+ //根据层高获取时间和风速map
|
|
|
+ Map<Timestamp, Float> timeAndWsMap = prophaseAnemometryDataList.stream().filter(p -> p.getLayerHeight().equals(height)).collect(Collectors.toMap(ProphaseAnemometryData::getTs, ProphaseAnemometryData::getWsAve));
|
|
|
+
|
|
|
+ if (!timeAndWsMap.isEmpty() && !timeAndAirMap.isEmpty()) {
|
|
|
+ ArrayList<BigDecimal> wsSumList = new ArrayList<>();
|
|
|
+ ArrayList<BigDecimal> wpdSumList = new ArrayList<>();
|
|
|
+ //遍历空气密度
|
|
|
+ for (Map.Entry<Timestamp, Float> airAndTime : timeAndAirMap.entrySet()) {
|
|
|
+ //过滤风速map
|
|
|
+ Map<Timestamp, Float> map = timeAndWsMap.entrySet().stream().filter(t -> t.getKey().getTime() == airAndTime.getKey().getTime()).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
|
|
+ if (!map.isEmpty()) {
|
|
|
+ BigDecimal wpdCalculate = CalculationUtil.getWpdCalculate(BigDecimal.valueOf(map.get(airAndTime.getKey())), BigDecimal.valueOf(airAndTime.getValue()));
|
|
|
+ wpdSumList.add(wpdCalculate);
|
|
|
+ wsSumList.add(BigDecimal.valueOf(map.get(airAndTime.getKey())));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (wsSumList.size() > 0) {
|
|
|
+ BigDecimal wpdAve = BigDecimal.valueOf(wsSumList.stream().collect(Collectors.averagingDouble(BigDecimal::doubleValue))).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ wsList.add(wpdAve);
|
|
|
+ }
|
|
|
+ if (wpdSumList.size() > 0) {
|
|
|
+ BigDecimal wpdAve = BigDecimal.valueOf(wpdSumList.stream().collect(Collectors.averagingDouble(BigDecimal::doubleValue))).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ wpdList.add(wpdAve);
|
|
|
}
|
|
|
- //本层高风功率密度平均值
|
|
|
- BigDecimal wpdAve = wpdSum.divide(BigDecimal.valueOf(2).multiply(BigDecimal.valueOf(wsForHeight.size())), 2, RoundingMode.HALF_UP);
|
|
|
- //本层高风速总和
|
|
|
- BigDecimal wsSum = wsForHeight.stream().reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- //本层高风速平均值
|
|
|
- BigDecimal wsAve = wsSum.divide(BigDecimal.valueOf(mapList.size()), 2, RoundingMode.HALF_UP);
|
|
|
- wsList.add(wsAve);
|
|
|
heightList.add(height + "m");
|
|
|
- wpdList.add(wpdAve);
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
dataMap.put("ws", wsList);
|
|
@@ -323,39 +346,43 @@ public class HomePageServiceImpl extends ServiceImpl<WindTowerDataParentTableMap
|
|
|
*/
|
|
|
@Override
|
|
|
public HashMap<String, Object> homePageRose(String equipmentId, String height, String month) {
|
|
|
- List<Map<String, Object>> maps = new ArrayList<>();
|
|
|
+ List<ProphaseAnemometryData> anemometryData = new ArrayList<>();
|
|
|
if (!month.equals("")) {
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
|
|
|
try {
|
|
|
Date startDate = sdf.parse(month);
|
|
|
Date endDate = DateTimeUtil.endOfMonth(startDate);
|
|
|
- maps = selectDataByBetweenTimeAndEquipmetId(startDate, endDate, equipmentId);
|
|
|
+ anemometryData = prophaseAnemometryDataMapper.selectWdAveAndWdAveAndWsStaForHeight(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()), height);
|
|
|
} catch (ParseException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
} else {
|
|
|
// 最新一天数据
|
|
|
- maps = windTowerDataParentTableService.getStartTimeAndEndTimeForData(equipmentId);
|
|
|
+ List<Entity> lastData = prophaseWeatherDataMapper.getLastData(equipmentId);
|
|
|
+ Timestamp timeEnd = (Timestamp) lastData.get(0).get("last (ts)");
|
|
|
+ DateTime startTime = DateUtil.beginOfDay(new Date(timeEnd.getTime()));
|
|
|
+ anemometryData = prophaseAnemometryDataMapper.selectWdAveAndWdAveAndWsStaForHeight(equipmentId, new Timestamp(startTime.getTime()), timeEnd, height);
|
|
|
}
|
|
|
-// List<Map<String, Object>> maps = windTowerDataParentTableService.getStartTimeAndEndTimeForData(equipmentId);
|
|
|
+
|
|
|
HashMap<String, Integer> hashMap = new HashMap<>();
|
|
|
BigDecimal total = BigDecimal.ZERO;
|
|
|
Map<String, BigDecimal> map = new HashMap<>();
|
|
|
Map<String, BigDecimal> windPowerMap = new HashMap<>();
|
|
|
for (WindDirectionEnum value : WindDirectionEnum.values()) {
|
|
|
- BigDecimal wsAve = BigDecimal.ZERO;
|
|
|
//根据设备属性风向获取数据
|
|
|
- List<Map<String, Object>> forHeightAndWindDirectionEnum = CalculationUtil.getForHeightAndWindDirectionEnum(maps, height, value);
|
|
|
- List<BigDecimal> wsList = CalculationUtil.getWsForHeight(forHeightAndWindDirectionEnum, height);
|
|
|
- // 平均风速
|
|
|
- if (!wsList.isEmpty()) {
|
|
|
- wsAve = wsList.stream().reduce(BigDecimal.ZERO, BigDecimal::add).divide(BigDecimal.valueOf(wsList.size()), 4, RoundingMode.HALF_UP);
|
|
|
+ List<ProphaseAnemometryData> heightAndWindDirectionEnum = CalculationUtil.getForHeightAndWindDirectionEnum(anemometryData, value);
|
|
|
+ BigDecimal wsAve = BigDecimal.ZERO;
|
|
|
+ if (heightAndWindDirectionEnum.size() > 0) {
|
|
|
+ wsAve = BigDecimal.valueOf(heightAndWindDirectionEnum.stream().map(h -> {
|
|
|
+ return BigDecimal.valueOf(h.getWsAve());
|
|
|
+ }).collect(Collectors.averagingDouble(BigDecimal::doubleValue)));
|
|
|
}
|
|
|
- hashMap.put(value.name(), forHeightAndWindDirectionEnum.size());
|
|
|
- total = total.add(BigDecimal.valueOf(forHeightAndWindDirectionEnum.size()));
|
|
|
- if (maps.size() > 0) {
|
|
|
+
|
|
|
+ hashMap.put(value.name(), heightAndWindDirectionEnum.size());
|
|
|
+ total = total.add(BigDecimal.valueOf(heightAndWindDirectionEnum.size()));
|
|
|
+ if (anemometryData.size() > 0) {
|
|
|
//风向频率
|
|
|
- BigDecimal wdF = BigDecimal.valueOf(forHeightAndWindDirectionEnum.size()).divide(BigDecimal.valueOf(maps.size()), 2, RoundingMode.HALF_UP);
|
|
|
+ BigDecimal wdF = BigDecimal.valueOf(heightAndWindDirectionEnum.size()).divide(BigDecimal.valueOf(anemometryData.size()), 2, RoundingMode.HALF_UP);
|
|
|
map.put(value.name(), BigDecimal.valueOf(100).multiply(wdF));
|
|
|
// 风能:风向频率 * 平均风速的立方
|
|
|
windPowerMap.put(value.name(), wsAve.multiply(wsAve).multiply(wsAve).multiply(wdF).setScale(2, RoundingMode.HALF_UP));
|
|
@@ -425,21 +452,24 @@ public class HomePageServiceImpl extends ServiceImpl<WindTowerDataParentTableMap
|
|
|
* @return
|
|
|
*/
|
|
|
public Map<String, Object> homePageCharts(String equipmentId, String month) {
|
|
|
- List<Map<String, Object>> mapList = new ArrayList<>();
|
|
|
+ List<ProphaseAnemometryData> mapList = new ArrayList<>();
|
|
|
if (!month.equals("")) {
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
|
|
|
try {
|
|
|
Date startDate = sdf.parse(month);
|
|
|
Date endDate = DateTimeUtil.endOfMonth(startDate);
|
|
|
- mapList = selectDataByBetweenTimeAndEquipmetId(startDate, endDate, equipmentId);
|
|
|
+ mapList = prophaseAnemometryDataMapper.selectWsAve(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
|
|
|
} catch (ParseException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
} else {
|
|
|
// 最新一天数据
|
|
|
- mapList = windTowerDataParentTableService.getStartTimeAndEndTimeForData(equipmentId);
|
|
|
- }
|
|
|
+ List<Entity> lastData = prophaseWeatherDataMapper.getLastData(equipmentId);
|
|
|
+ Timestamp timeEnd = (Timestamp) lastData.get(0).get("last (ts)");
|
|
|
+ DateTime startTime = DateUtil.beginOfDay(new Date(timeEnd.getTime()));
|
|
|
+ mapList = prophaseAnemometryDataMapper.selectWsAve(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
|
|
|
|
|
|
+ }
|
|
|
HashMap<String, Object> everyMap = new HashMap();
|
|
|
//获取风速层高
|
|
|
List<WindTowerInfo> windTowerInfos = windTowerInfoService.getByEquipmentNo(equipmentId);
|
|
@@ -449,87 +479,27 @@ public class HomePageServiceImpl extends ServiceImpl<WindTowerDataParentTableMap
|
|
|
// 时间list
|
|
|
ArrayList<String> timeList = new ArrayList();
|
|
|
ArrayList<Object> everyData = new ArrayList<>();
|
|
|
- boolean status = true;
|
|
|
+
|
|
|
for (String h : heightAll) {
|
|
|
- HashMap<String, Object> hMap = new HashMap();
|
|
|
+ timeList = new ArrayList();
|
|
|
ArrayList<Object> hList = new ArrayList();
|
|
|
- for (Map<String, Object> map : mapList) {
|
|
|
- String time = DateUtil.format(new Date(Long.parseLong(map.get("time").toString())), "yyyy-MM-dd HH:mm:ss");
|
|
|
- if (status) {
|
|
|
- timeList.add(time);
|
|
|
- }
|
|
|
- String abnormal_type = "";
|
|
|
- BigDecimal wsAve = BigDecimal.ZERO;
|
|
|
- if (map.get("abnormal_type") != null) {
|
|
|
- abnormal_type = map.get("abnormal_type").toString();
|
|
|
- }
|
|
|
- if (map.get("ws_ave" + h) != null && !map.get("ws_ave" + h).equals("") && (!abnormal_type.contains("wsAve" + h) || !abnormal_type.contains("ws_ave" + h))) {
|
|
|
- wsAve = CalculationUtil.getBigDecimal(map.get("ws_ave" + h));
|
|
|
- }
|
|
|
- hList.add(wsAve);
|
|
|
+ HashMap<String, Object> hMap = new HashMap();
|
|
|
+ //根据层高过滤时间和风速
|
|
|
+ TreeMap<Long, Float> heightForTimeAndWs = new TreeMap<>(mapList.stream().filter(p -> p.getLayerHeight().equals(h)).collect(Collectors.toMap(prophaseAnemometryData -> prophaseAnemometryData != null ? prophaseAnemometryData.getTs().getTime() : null, prophaseAnemometryData1 -> prophaseAnemometryData1 != null ? prophaseAnemometryData1.getWsAve() : null)));
|
|
|
+ for (Map.Entry<Long, Float> entry : heightForTimeAndWs.entrySet()) {
|
|
|
+ String time = DateUtil.format(new Date(entry.getKey()), "yyyy-MM-dd HH:mm:ss");
|
|
|
+ timeList.add(time);
|
|
|
+ hList.add(entry.getValue());
|
|
|
}
|
|
|
hMap.put("height", h);
|
|
|
hMap.put("value", hList);
|
|
|
everyData.add(hMap);
|
|
|
- status = false;
|
|
|
}
|
|
|
everyMap.put("chart", everyData);
|
|
|
everyMap.put("time", timeList);
|
|
|
return everyMap;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 首页风功率与风速折线图
|
|
|
- *
|
|
|
- * @param equipmentId 场站编号
|
|
|
- * @return HashMap<String, Object>
|
|
|
- */
|
|
|
- public Map<String, Object> selectWpdAndWs(String equipmentId) {
|
|
|
- //获取最新一天的数据
|
|
|
- List<Map<String, Object>> mapList = windTowerDataParentTableService.getStartTimeAndEndTimeForData(equipmentId);
|
|
|
- ArrayList<Object> wpdList = new ArrayList<>();
|
|
|
- ArrayList<Object> wsList = new ArrayList<>();
|
|
|
- ArrayList<Object> timeList = new ArrayList<>();
|
|
|
- WindTowerInfo windTowerInfo = windTowerInfoService.getByEquipmentNo(equipmentId).get(0);
|
|
|
- String height;
|
|
|
- //最终返回的map
|
|
|
- HashMap<String, Object> hashMap1 = new HashMap<>();
|
|
|
- if (windTowerInfo.getDisplayHeight() != null && !windTowerInfo.getDisplayHeight().equals("")) {
|
|
|
- height = windTowerInfo.getDisplayHeight();
|
|
|
- } else {
|
|
|
- String[] strings = windTowerInfo.getHeights().split(",");
|
|
|
- height = CalculationUtil.getNumberFromString(strings[0]);
|
|
|
- }
|
|
|
- //循环数据并计算放入各自集合
|
|
|
- for (Map<String, Object> map : mapList) {
|
|
|
- String abnormal_type = "";
|
|
|
- BigDecimal airDensity = BigDecimal.ZERO;
|
|
|
- BigDecimal wsAve = BigDecimal.ZERO;
|
|
|
- if (map.get("abnormal_type") != null) {
|
|
|
- abnormal_type = map.get("abnormal_type").toString();
|
|
|
- }
|
|
|
- if (map.get("air_density") != null && !map.get("air_density").equals("") && (!abnormal_type.contains("air_density"))) {
|
|
|
- airDensity = CalculationUtil.getBigDecimal(map.get("air_density"));
|
|
|
- }
|
|
|
- if (map.get("ws_ave" + height) != null && !map.get("ws_ave" + height).equals("") && (!abnormal_type.contains("wsAve" + height) || !abnormal_type.contains("ws_ave" + height))) {
|
|
|
- wsAve = CalculationUtil.getBigDecimal(map.get("ws_ave" + height));
|
|
|
- }
|
|
|
- //时间
|
|
|
- String time = DateUtil.format(new Date(Long.parseLong(map.get("time").toString())), "yyyy-MM-dd HH:mm:ss");
|
|
|
- //风功率密度计算公式 风速的立方 × 空气密度 × 1/2
|
|
|
- BigDecimal wpd = wsAve.multiply(wsAve).multiply(wsAve).multiply(airDensity).multiply(BigDecimal.valueOf(0.5)).setScale(2, RoundingMode.HALF_UP);
|
|
|
- wpdList.add(wpd);
|
|
|
- wsList.add(wsAve);
|
|
|
- timeList.add(time);
|
|
|
- }
|
|
|
- //集合放入map准备返回
|
|
|
- hashMap1.put("wpd", wpdList);
|
|
|
- hashMap1.put("ws", wsList);
|
|
|
- hashMap1.put("time", timeList);
|
|
|
- hashMap1.put("height", height);
|
|
|
- return hashMap1;
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
/**
|
|
|
* 首页空气密度和温度 折线图
|
|
@@ -577,23 +547,29 @@ public class HomePageServiceImpl extends ServiceImpl<WindTowerDataParentTableMap
|
|
|
* @return Map<String, BigDecimal>
|
|
|
*/
|
|
|
public Map<String, Object> getAirAndPaAndT(String equipmentId, String month) {
|
|
|
- List<Map<String, Object>> mapList = new ArrayList<>();
|
|
|
+ List<ProphaseWeatherData> weatherDataList = new ArrayList<>();
|
|
|
+ List<ProphaseAnemometryData> anemometryDataList = new ArrayList<>();
|
|
|
+
|
|
|
if (!month.equals("")) {
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
|
|
|
try {
|
|
|
Date startDate = sdf.parse(month);
|
|
|
Date endDate = DateTimeUtil.endOfMonth(startDate);
|
|
|
- mapList = selectDataByBetweenTimeAndEquipmetId(startDate, endDate, equipmentId);
|
|
|
+ weatherDataList = prophaseWeatherDataMapper.selectTAveAndPaAveAndAir(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
|
|
|
+ anemometryDataList = prophaseAnemometryDataMapper.selectAveAndSta(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
|
|
|
} catch (ParseException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
} else {
|
|
|
+ List<Entity> lastData = prophaseWeatherDataMapper.getLastData(equipmentId);
|
|
|
+ Timestamp timeEnd = (Timestamp) lastData.get(0).get("last (ts)");
|
|
|
+ DateTime startTime = DateUtil.beginOfDay(new Date(timeEnd.getTime()));
|
|
|
// 最新一天数据
|
|
|
- mapList = windTowerDataParentTableService.getStartTimeAndEndTimeForData(equipmentId);
|
|
|
+ weatherDataList = prophaseWeatherDataMapper.selectTAveAndPaAveAndAir(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
|
|
|
+ anemometryDataList = prophaseAnemometryDataMapper.selectAveAndSta(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
|
|
|
}
|
|
|
WindTowerInfo windTowerInfo = windTowerInfoService.getByEquipmentNo(equipmentId).get(0);
|
|
|
-// //获取最新一天的数据
|
|
|
-// List<Map<String, Object>> mapList = windTowerDataParentTableService.getStartTimeAndEndTimeForData(equipmentId);
|
|
|
+
|
|
|
|
|
|
String height;
|
|
|
String[] strings = windTowerInfo.getHeights().split(",");
|
|
@@ -602,19 +578,26 @@ public class HomePageServiceImpl extends ServiceImpl<WindTowerDataParentTableMap
|
|
|
if (windTowerInfo.getDisplayHeight() != null && !windTowerInfo.getDisplayHeight().equals("")) {
|
|
|
height = windTowerInfo.getDisplayHeight();
|
|
|
}
|
|
|
+
|
|
|
HashMap<String, Object> dataMap = new HashMap<>();
|
|
|
BigDecimal tAve = BigDecimal.ZERO;
|
|
|
BigDecimal airDensity = BigDecimal.ZERO;
|
|
|
BigDecimal pa = BigDecimal.ZERO;
|
|
|
|
|
|
- BigDecimal tAveTotal = BigDecimal.ZERO;
|
|
|
- BigDecimal airDensityAveTotal = BigDecimal.ZERO;
|
|
|
- BigDecimal paAveTotal = BigDecimal.ZERO;
|
|
|
// 风速集合
|
|
|
- List<BigDecimal> wsForHeight = CalculationUtil.getWsForHeight(mapList, height);
|
|
|
- List<BigDecimal> minWsForHeight = CalculationUtil.getWsForHeight(mapList, minHeight);
|
|
|
+ String finalHeight = height;
|
|
|
+ List<BigDecimal> wsForHeight = anemometryDataList.stream().filter(a -> a.getLayerHeight().equals(finalHeight)).map(h -> {
|
|
|
+ return BigDecimal.valueOf(h.getWsAve());
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<BigDecimal> minWsForHeight = anemometryDataList.stream().filter(a -> a.getLayerHeight().equals(minHeight)).map(h -> {
|
|
|
+ return BigDecimal.valueOf(h.getWsAve());
|
|
|
+ }).collect(Collectors.toList());
|
|
|
// 风速标准差集合
|
|
|
- List<BigDecimal> wsStaForHeight = CalculationUtil.getWsStaForHeight(mapList, height);
|
|
|
+ List<BigDecimal> wsStaForHeight = anemometryDataList.stream().filter(a -> a.getLayerHeight().equals(minHeight)).map(h -> {
|
|
|
+ return BigDecimal.valueOf(h.getWsSta());
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
BigDecimal avgWs = CalculationUtil.getAvgWind(wsForHeight); // 风速平均值
|
|
|
BigDecimal avgMinWs = CalculationUtil.getAvgWind(minWsForHeight); // 最小风速平均值
|
|
|
BigDecimal avgWsSta = CalculationUtil.getAvgWind(wsStaForHeight);// 风速标准差平均值
|
|
@@ -623,35 +606,20 @@ public class HomePageServiceImpl extends ServiceImpl<WindTowerDataParentTableMap
|
|
|
if (avgWs.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
windShear = CalculationUtil.caWindShear(avgWs, avgMinWs, new BigDecimal(height), new BigDecimal(minHeight));// 风切变
|
|
|
}
|
|
|
- for (Map<String, Object> map : mapList) {
|
|
|
- String abnormal_type = "";
|
|
|
- //过滤异常值
|
|
|
- if (map.get("abnormal_type") != null) {
|
|
|
- abnormal_type = map.get("abnormal_type").toString();
|
|
|
- }
|
|
|
- if (map.get("t_ave") != null && !map.get("t_ave").equals("") && (!abnormal_type.contains("t_ave"))) {
|
|
|
- tAve = tAve.add(CalculationUtil.getBigDecimal(map.get("t_ave")));
|
|
|
- tAveTotal = tAveTotal.add(BigDecimal.ONE);
|
|
|
- }
|
|
|
- if (map.get("air_density") != null && !map.get("air_density").equals("") && (!abnormal_type.contains("air_density"))) {
|
|
|
- airDensity = airDensity.add(CalculationUtil.getBigDecimal(map.get("air_density")));
|
|
|
- airDensityAveTotal = airDensityAveTotal.add(BigDecimal.ONE);
|
|
|
- }
|
|
|
- if (map.get("pa_ave") != null && !map.get("pa_ave").equals("") && (!abnormal_type.contains("pa_ave"))) {
|
|
|
- pa = pa.add(CalculationUtil.getBigDecimal(map.get("pa_ave")));
|
|
|
- paAveTotal = paAveTotal.add(BigDecimal.ONE);
|
|
|
- }
|
|
|
- }
|
|
|
- if (tAveTotal.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- tAve = tAve.divide(tAveTotal, 2, RoundingMode.HALF_UP);
|
|
|
- }
|
|
|
- if (airDensityAveTotal.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- airDensity = airDensity.divide(airDensityAveTotal, 2, RoundingMode.HALF_UP);
|
|
|
- }
|
|
|
- if (paAveTotal.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- pa = pa.divide(paAveTotal, 2, RoundingMode.HALF_UP);
|
|
|
- }
|
|
|
+ if(!weatherDataList.isEmpty()){
|
|
|
+
|
|
|
+ airDensity = BigDecimal.valueOf(weatherDataList.stream().map(w -> {
|
|
|
+ return BigDecimal.valueOf(w.getAirDensity());
|
|
|
+ }).collect(Collectors.averagingDouble(BigDecimal::doubleValue))).setScale(2,RoundingMode.HALF_UP);
|
|
|
|
|
|
+ tAve = BigDecimal.valueOf(weatherDataList.stream().map(w -> {
|
|
|
+ return BigDecimal.valueOf(w.getTAve());
|
|
|
+ }).collect(Collectors.averagingDouble(BigDecimal::doubleValue))).setScale(2,RoundingMode.HALF_UP);
|
|
|
+
|
|
|
+ pa = BigDecimal.valueOf(weatherDataList.stream().map(w -> {
|
|
|
+ return BigDecimal.valueOf(w.getPaAve());
|
|
|
+ }).collect(Collectors.averagingDouble(BigDecimal::doubleValue))).setScale(2,RoundingMode.HALF_UP);
|
|
|
+ }
|
|
|
|
|
|
BigDecimal batterySum = BigDecimal.ZERO;
|
|
|
for (BigDecimal ws : wsForHeight) {
|
|
@@ -880,9 +848,11 @@ public class HomePageServiceImpl extends ServiceImpl<WindTowerDataParentTableMap
|
|
|
/**
|
|
|
* 查询所有的场站坐标
|
|
|
*/
|
|
|
- public ArrayList<Object> getStationSeat() {
|
|
|
- ArrayList<Object> arrayList = new ArrayList<>();
|
|
|
+ public HashMap<String, Object> getStationSeat() {
|
|
|
+ HashMap<String, Object> dataMap = new HashMap<>();
|
|
|
+ List<OtherStationInfo> otherStationInfoList = otherStationInfoService.selectOtherStationInfo();
|
|
|
List<StationInfo> stationInfos = stationInfoService.selectStationInfo();
|
|
|
+ ArrayList<HashMap<String, Object>> stationList = new ArrayList<>();
|
|
|
for (StationInfo stationInfo : stationInfos) {
|
|
|
HashMap<String, Object> hashMap = new HashMap<>();
|
|
|
hashMap.put("id", stationInfo.getId());
|
|
@@ -891,9 +861,24 @@ public class HomePageServiceImpl extends ServiceImpl<WindTowerDataParentTableMap
|
|
|
hashMap.put("longitude", stationInfo.getStationBasicInfo().getLongitude());
|
|
|
//纬度
|
|
|
hashMap.put("latitude", stationInfo.getStationBasicInfo().getLatitude());
|
|
|
- arrayList.add(hashMap);
|
|
|
+ stationList.add(hashMap);
|
|
|
}
|
|
|
- return arrayList;
|
|
|
+ ArrayList<HashMap<String, Object>> otherStationList = new ArrayList<>();
|
|
|
+ for (OtherStationInfo otherStationInfo : otherStationInfoList) {
|
|
|
+ HashMap<String, Object> hashMap = new HashMap<>();
|
|
|
+ hashMap.put("id", otherStationInfo.getId());
|
|
|
+ hashMap.put("stationName", otherStationInfo.getStationName());
|
|
|
+ //经度
|
|
|
+ hashMap.put("longitude", otherStationInfo.getLongitude());
|
|
|
+ //纬度
|
|
|
+ hashMap.put("latitude", otherStationInfo.getLatitude());
|
|
|
+ otherStationList.add(hashMap);
|
|
|
+
|
|
|
+ }
|
|
|
+ dataMap.put("HDStation",stationList);
|
|
|
+ dataMap.put("otherStation",otherStationList);
|
|
|
+
|
|
|
+ return dataMap;
|
|
|
}
|
|
|
|
|
|
/**
|