|
@@ -4,7 +4,11 @@ import cn.hutool.core.date.DateTime;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.db.Entity;
|
|
import cn.hutool.db.Entity;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.jiayue.biz.conf.RequestDataHelper;
|
|
import com.jiayue.biz.domain.*;
|
|
import com.jiayue.biz.domain.*;
|
|
import com.jiayue.biz.dto.EquipmentDto;
|
|
import com.jiayue.biz.dto.EquipmentDto;
|
|
import com.jiayue.biz.dto.ProjectEvolveDto;
|
|
import com.jiayue.biz.dto.ProjectEvolveDto;
|
|
@@ -28,6 +32,7 @@ import org.springframework.stereotype.Service;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.math.RoundingMode;
|
|
import java.math.RoundingMode;
|
|
import java.sql.Timestamp;
|
|
import java.sql.Timestamp;
|
|
|
|
+import java.sql.Wrapper;
|
|
import java.text.ParseException;
|
|
import java.text.ParseException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -66,6 +71,8 @@ public class HomePageServiceImpl extends ServiceImpl<WindTowerDataParentTableMap
|
|
|
|
|
|
private final OtherStationInfoService otherStationInfoService;
|
|
private final OtherStationInfoService otherStationInfoService;
|
|
|
|
|
|
|
|
+ private final WindDirectionStatisticsDataService windDirectionStatisticsDataService;
|
|
|
|
+
|
|
|
|
|
|
private final BigDecimal threeParameterOne = new BigDecimal("1.146");
|
|
private final BigDecimal threeParameterOne = new BigDecimal("1.146");
|
|
private final BigDecimal threeParameterTow = new BigDecimal("77.42");
|
|
private final BigDecimal threeParameterTow = new BigDecimal("77.42");
|
|
@@ -84,72 +91,212 @@ public class HomePageServiceImpl extends ServiceImpl<WindTowerDataParentTableMap
|
|
public Map<String, Object> getWsAndWpdForHeight(String equipmentId, String month) {
|
|
public Map<String, Object> getWsAndWpdForHeight(String equipmentId, String month) {
|
|
List<WindTowerInfo> windTowerInfoList = windTowerInfoService.lambdaQuery().eq(WindTowerInfo::getEquipmentNo, equipmentId).list();
|
|
List<WindTowerInfo> windTowerInfoList = windTowerInfoService.lambdaQuery().eq(WindTowerInfo::getEquipmentNo, equipmentId).list();
|
|
String[] heights = windTowerInfoList.get(0).getHeights().split(",");
|
|
String[] heights = windTowerInfoList.get(0).getHeights().split(",");
|
|
- //风速数据
|
|
|
|
- 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);
|
|
|
|
- prophaseAnemometryDataList = prophaseAnemometryDataService.selectWsAve(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
|
|
|
|
- weatherDataList = prophaseWeatherDataService.selectAir(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
|
|
|
|
- } catch (ParseException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- // 最新一天数据
|
|
|
|
- List<Entity> lastData = prophaseWeatherDataService.getLastData(equipmentId);
|
|
|
|
- Timestamp timeEnd = (Timestamp) lastData.get(0).get("last (ts)");
|
|
|
|
- DateTime startTime = DateUtil.beginOfDay(new Date(timeEnd.getTime()));
|
|
|
|
- prophaseAnemometryDataList = prophaseAnemometryDataService.selectWsAve(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
|
|
|
|
- weatherDataList = prophaseWeatherDataService.selectAir(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
|
|
|
|
|
|
+ //获取最后一条记录
|
|
|
|
+ WindTowerCalculationData lastDataCalculation = windTowerCalculationDataService.getLastDataCalculation(equipmentId);
|
|
|
|
+ Date yearDay = DateTimeUtil.getYearDay(lastDataCalculation.getTime().getTime());
|
|
|
|
+ //获取去年月份开始时间
|
|
|
|
+ Date beginTime = DateUtil.offsetMonth(DateUtil.beginOfMonth(yearDay), 1);
|
|
|
|
+ Date endTime = lastDataCalculation.getTime();
|
|
|
|
|
|
- }
|
|
|
|
- //时间和空气密度map
|
|
|
|
- Map<Timestamp, Float> timeAndAirMap = weatherDataList.stream().collect(Collectors.toMap(ProphaseWeatherData::getTs, ProphaseWeatherData::getAirDensity));
|
|
|
|
|
|
+
|
|
|
|
+ List<EquipmentAttribute> equipmentAttributeList = equipmentAttributeService.lambdaQuery().likeLeft(EquipmentAttribute::getFieldName, "wpdMonth").or().likeLeft(EquipmentAttribute::getFieldName, "awsMonth").list();
|
|
|
|
+ List<WindTowerCalculationData> windTowerCalculationData = windTowerCalculationDataService.getByBetweenTimeAndEquipmentIdAndEbId(beginTime, endTime, equipmentId, equipmentAttributeList);
|
|
|
|
|
|
HashMap<String, Object> dataMap = new HashMap<>();
|
|
HashMap<String, Object> dataMap = new HashMap<>();
|
|
ArrayList<BigDecimal> wpdList = new ArrayList<>();
|
|
ArrayList<BigDecimal> wpdList = new ArrayList<>();
|
|
ArrayList<BigDecimal> wsList = new ArrayList<>();
|
|
ArrayList<BigDecimal> wsList = new ArrayList<>();
|
|
ArrayList<String> heightList = new ArrayList<>();
|
|
ArrayList<String> heightList = new ArrayList<>();
|
|
-
|
|
|
|
|
|
+ //循环层高
|
|
for (String height : heights) {
|
|
for (String height : heights) {
|
|
- //根据层高获取时间和风速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(airAndTime.getValue()), BigDecimal.valueOf(map.get(airAndTime.getKey())));
|
|
|
|
- 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);
|
|
|
|
- }
|
|
|
|
- heightList.add(height + "m");
|
|
|
|
|
|
+ //获取风速风功率的统计id
|
|
|
|
+ List<EquipmentAttribute> equipmentAttributeWpd = equipmentAttributeList.stream().filter(e -> e.getFieldName().equals(height + "wpdMonth")).collect(Collectors.toList());
|
|
|
|
+ List<EquipmentAttribute> equipmentAttributeWs = equipmentAttributeList.stream().filter(e -> e.getFieldName().equals(height + "awsMonth")).collect(Collectors.toList());
|
|
|
|
+ heightList.add(height + "m");
|
|
|
|
+
|
|
|
|
+ //根据id和时间过滤
|
|
|
|
+ BigDecimal wpd = this.getDataForTimeAndId(windTowerCalculationData, equipmentAttributeWpd.get(0).getId(), beginTime.getTime(), endTime.getTime());
|
|
|
|
+ wpdList.add(wpd);
|
|
|
|
+ //根据id和时间过滤
|
|
|
|
+ BigDecimal ws = this.getDataForTimeAndId(windTowerCalculationData, equipmentAttributeWs.get(0).getId(), beginTime.getTime(), endTime.getTime());
|
|
|
|
+ wsList.add(ws);
|
|
|
|
+
|
|
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+// //风速数据
|
|
|
|
+// 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);
|
|
|
|
+// prophaseAnemometryDataList = prophaseAnemometryDataService.selectWsAve(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
|
|
|
|
+// weatherDataList = prophaseWeatherDataService.selectAir(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
|
|
|
|
+// } catch (ParseException e) {
|
|
|
|
+// e.printStackTrace();
|
|
|
|
+// }
|
|
|
|
+// } else {
|
|
|
|
+// // 最新一天数据
|
|
|
|
+// List<Entity> lastData = prophaseWeatherDataService.getLastData(equipmentId);
|
|
|
|
+// Timestamp timeEnd = (Timestamp) lastData.get(0).get("last (ts)");
|
|
|
|
+// DateTime startTime = DateUtil.beginOfDay(new Date(timeEnd.getTime()));
|
|
|
|
+// prophaseAnemometryDataList = prophaseAnemometryDataService.selectWsAve(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
|
|
|
|
+// weatherDataList = prophaseWeatherDataService.selectAir(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
|
|
|
|
+//
|
|
|
|
+// }
|
|
|
|
+// //时间和空气密度map
|
|
|
|
+// Map<Timestamp, Float> timeAndAirMap = weatherDataList.stream().collect(Collectors.toMap(ProphaseWeatherData::getTs, ProphaseWeatherData::getAirDensity));
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+// for (String height : heights) {
|
|
|
|
+// //根据层高获取时间和风速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(airAndTime.getValue()), BigDecimal.valueOf(map.get(airAndTime.getKey())));
|
|
|
|
+// 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);
|
|
|
|
+// }
|
|
|
|
+// heightList.add(height + "m");
|
|
|
|
+//
|
|
|
|
+// }
|
|
|
|
+// }
|
|
dataMap.put("ws", wsList);
|
|
dataMap.put("ws", wsList);
|
|
dataMap.put("wpd", wpdList);
|
|
dataMap.put("wpd", wpdList);
|
|
dataMap.put("height", heightList);
|
|
dataMap.put("height", heightList);
|
|
|
|
+
|
|
return dataMap;
|
|
return dataMap;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //计算统计数据时间段内平均值
|
|
|
|
+ public BigDecimal getDataForTimeAndId(List<WindTowerCalculationData> windTowerCalculationData, String ebId, Long startTime, Long endTime) {
|
|
|
|
+ List<BigDecimal> calculationData = windTowerCalculationData.stream().filter(w -> w.getEbId().equals(ebId) && w.getTime().getTime() >= startTime && w.getTime().getTime() <= endTime).map(WindTowerCalculationData::getValue).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return calculationData.size() > 0 ? CalculationUtil.getAvgWind(calculationData) : BigDecimal.ZERO;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 首页查询风速对比
|
|
|
|
+ *
|
|
|
|
+ * @param equipmentId 设备编号
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public Map<String, Object> homePageCharts(String equipmentId, String month) {
|
|
|
|
+
|
|
|
|
+ HashMap<String, Object> everyMap = new HashMap();
|
|
|
|
+
|
|
|
|
+ List<WindTowerInfo> windTowerInfoList = windTowerInfoService.lambdaQuery().eq(WindTowerInfo::getEquipmentNo, equipmentId).list();
|
|
|
|
+ String[] heights = windTowerInfoList.get(0).getHeights().split(",");
|
|
|
|
+ //获取最后一条记录
|
|
|
|
+ WindTowerCalculationData lastDataCalculation = windTowerCalculationDataService.getLastDataCalculation(equipmentId);
|
|
|
|
+ Date yearDay = DateTimeUtil.getYearDay(lastDataCalculation.getTime().getTime());
|
|
|
|
+ //获取去年月份开始时间
|
|
|
|
+ Date beginTime = DateUtil.offsetMonth(DateUtil.beginOfMonth(yearDay), 1);
|
|
|
|
+ Date endTime = lastDataCalculation.getTime();
|
|
|
|
+
|
|
|
|
+ List<EquipmentAttribute> equipmentAttributeList = equipmentAttributeService.lambdaQuery().likeLeft(EquipmentAttribute::getFieldName, "awsDay").list();
|
|
|
|
+ List<WindTowerCalculationData> windTowerCalculationData = windTowerCalculationDataService.getByBetweenTimeAndEquipmentIdAndEbId(beginTime, endTime, equipmentId, equipmentAttributeList);
|
|
|
|
+ //数据list 风速 层高
|
|
|
|
+ ArrayList<Object> everyData = new ArrayList<>();
|
|
|
|
+ //时间list
|
|
|
|
+ ArrayList<String> timeList = new ArrayList();
|
|
|
|
+ boolean type = true;
|
|
|
|
+ for (String height : heights) {
|
|
|
|
+ List<EquipmentAttribute> equipmentAttributes = equipmentAttributeList.stream().filter(e -> e.getFieldName().equals(height + "awsDay")).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ ArrayList<Object> hList = new ArrayList();
|
|
|
|
+ HashMap<String, Object> hMap = new HashMap();
|
|
|
|
+
|
|
|
|
+ for (long i = beginTime.getTime(); i <= endTime.getTime(); i = i + 86400000) {
|
|
|
|
+ long finalI = i;
|
|
|
|
+ List<WindTowerCalculationData> calculationData = windTowerCalculationData.stream().filter(w -> w.getEbId().equals(equipmentAttributes.get(0).getId()) && w.getTime().getTime() == finalI).collect(Collectors.toList());
|
|
|
|
+ if (type) {
|
|
|
|
+ timeList.add(DateUtil.format(new Date(i), "yyyy-MM-dd"));
|
|
|
|
+ }
|
|
|
|
+ hList.add(calculationData.size() > 0 ? calculationData.get(0).getValue() : BigDecimal.ZERO);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ hMap.put("height", height);
|
|
|
|
+ hMap.put("value", hList);
|
|
|
|
+ everyData.add(hMap);
|
|
|
|
+ type = false;
|
|
|
|
+ }
|
|
|
|
+ everyMap.put("chart", everyData);
|
|
|
|
+ everyMap.put("time", timeList);
|
|
|
|
+
|
|
|
|
+// 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 = prophaseAnemometryDataService.selectWsAve(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
|
|
|
|
+// } catch (ParseException e) {
|
|
|
|
+// e.printStackTrace();
|
|
|
|
+// }
|
|
|
|
+// } else {
|
|
|
|
+// // 最新一天数据
|
|
|
|
+// List<Entity> lastData = prophaseWeatherDataService.getLastData(equipmentId);
|
|
|
|
+// Timestamp timeEnd = (Timestamp) lastData.get(0).get("last (ts)");
|
|
|
|
+// DateTime startTime = DateUtil.beginOfDay(new Date(timeEnd.getTime()));
|
|
|
|
+// mapList = prophaseAnemometryDataService.selectWsAve(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
|
|
|
|
+//
|
|
|
|
+// }
|
|
|
|
+//// HashMap<String, Object> everyMap = new HashMap();
|
|
|
|
+// //获取风速层高
|
|
|
|
+// List<WindTowerInfo> windTowerInfos = windTowerInfoService.getByEquipmentNo(equipmentId);
|
|
|
|
+// String height = windTowerInfos.get(0).getHeights();
|
|
|
|
+// String[] heightAll = height.split(",");
|
|
|
|
+//
|
|
|
|
+// // 时间list
|
|
|
|
+//// ArrayList<String> timeList = new ArrayList();
|
|
|
|
+//// ArrayList<Object> everyData = new ArrayList<>();
|
|
|
|
+//
|
|
|
|
+// for (String h : heightAll) {
|
|
|
|
+// timeList = new ArrayList();
|
|
|
|
+// ArrayList<Object> hList = new ArrayList();
|
|
|
|
+// 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);
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return everyMap;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
/*首页地图 测风塔信息*/
|
|
/*首页地图 测风塔信息*/
|
|
public List<Map<String, Object>> homePageMap() {
|
|
public List<Map<String, Object>> homePageMap() {
|
|
List<Map<String, Object>> list = new ArrayList<>();
|
|
List<Map<String, Object>> list = new ArrayList<>();
|
|
@@ -362,12 +509,12 @@ public class HomePageServiceImpl extends ServiceImpl<WindTowerDataParentTableMap
|
|
// 最新一天数据
|
|
// 最新一天数据
|
|
List<Entity> lastData = prophaseWeatherDataService.getLastData(equipmentId);
|
|
List<Entity> lastData = prophaseWeatherDataService.getLastData(equipmentId);
|
|
Timestamp timeEnd = (Timestamp) lastData.get(0).get("last (ts)");
|
|
Timestamp timeEnd = (Timestamp) lastData.get(0).get("last (ts)");
|
|
- DateTime startTime = DateUtil.beginOfDay(new Date(timeEnd.getTime()));
|
|
|
|
|
|
+ DateTime startTime = DateUtil.beginOfDay(DateTimeUtil.getYearDay(timeEnd.getTime()));
|
|
anemometryData = prophaseAnemometryDataService.selectWdAveAndWdAveAndWsStaForHeight(equipmentId, new Timestamp(startTime.getTime()), timeEnd, height);
|
|
anemometryData = prophaseAnemometryDataService.selectWdAveAndWdAveAndWsStaForHeight(equipmentId, new Timestamp(startTime.getTime()), timeEnd, height);
|
|
}
|
|
}
|
|
|
|
|
|
HashMap<String, Integer> hashMap = new HashMap<>();
|
|
HashMap<String, Integer> hashMap = new HashMap<>();
|
|
- BigDecimal total = BigDecimal.ZERO;
|
|
|
|
|
|
+
|
|
Map<String, BigDecimal> map = new HashMap<>();
|
|
Map<String, BigDecimal> map = new HashMap<>();
|
|
Map<String, BigDecimal> windPowerMap = new HashMap<>();
|
|
Map<String, BigDecimal> windPowerMap = new HashMap<>();
|
|
for (WindDirectionEnum value : WindDirectionEnum.values()) {
|
|
for (WindDirectionEnum value : WindDirectionEnum.values()) {
|
|
@@ -381,7 +528,7 @@ public class HomePageServiceImpl extends ServiceImpl<WindTowerDataParentTableMap
|
|
}
|
|
}
|
|
|
|
|
|
hashMap.put(value.name(), heightAndWindDirectionEnum.size());
|
|
hashMap.put(value.name(), heightAndWindDirectionEnum.size());
|
|
- total = total.add(BigDecimal.valueOf(heightAndWindDirectionEnum.size()));
|
|
|
|
|
|
+ BigDecimal total = BigDecimal.valueOf(heightAndWindDirectionEnum.size());
|
|
if (anemometryData.size() > 0) {
|
|
if (anemometryData.size() > 0) {
|
|
//风向频率
|
|
//风向频率
|
|
BigDecimal wdF = BigDecimal.valueOf(heightAndWindDirectionEnum.size()).divide(BigDecimal.valueOf(anemometryData.size()), 2, RoundingMode.HALF_UP);
|
|
BigDecimal wdF = BigDecimal.valueOf(heightAndWindDirectionEnum.size()).divide(BigDecimal.valueOf(anemometryData.size()), 2, RoundingMode.HALF_UP);
|
|
@@ -408,183 +555,90 @@ public class HomePageServiceImpl extends ServiceImpl<WindTowerDataParentTableMap
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 首页查询最新一天的平均风速
|
|
|
|
- *
|
|
|
|
- * @param equipmentId 设备编号
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- public Map<String, Object> homePageCharts(String equipmentId, String month) {
|
|
|
|
- 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 = prophaseAnemometryDataService.selectWsAve(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
|
|
|
|
- } catch (ParseException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- // 最新一天数据
|
|
|
|
- List<Entity> lastData = prophaseWeatherDataService.getLastData(equipmentId);
|
|
|
|
- Timestamp timeEnd = (Timestamp) lastData.get(0).get("last (ts)");
|
|
|
|
- DateTime startTime = DateUtil.beginOfDay(new Date(timeEnd.getTime()));
|
|
|
|
- mapList = prophaseAnemometryDataService.selectWsAve(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- HashMap<String, Object> everyMap = new HashMap();
|
|
|
|
- //获取风速层高
|
|
|
|
- List<WindTowerInfo> windTowerInfos = windTowerInfoService.getByEquipmentNo(equipmentId);
|
|
|
|
- String height = windTowerInfos.get(0).getHeights();
|
|
|
|
- String[] heightAll = height.split(",");
|
|
|
|
-
|
|
|
|
- // 时间list
|
|
|
|
- ArrayList<String> timeList = new ArrayList();
|
|
|
|
- ArrayList<Object> everyData = new ArrayList<>();
|
|
|
|
-
|
|
|
|
- for (String h : heightAll) {
|
|
|
|
- timeList = new ArrayList();
|
|
|
|
- ArrayList<Object> hList = new ArrayList();
|
|
|
|
- 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);
|
|
|
|
- }
|
|
|
|
- everyMap.put("chart", everyData);
|
|
|
|
- everyMap.put("time", timeList);
|
|
|
|
- return everyMap;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
* 首页空气密度、温度、压强平均值 湍流 风切变 满发小时数 日发电量 经纬度 数据起止时间
|
|
* 首页空气密度、温度、压强平均值 湍流 风切变 满发小时数 日发电量 经纬度 数据起止时间
|
|
*
|
|
*
|
|
* @param equipmentId 场站编号
|
|
* @param equipmentId 场站编号
|
|
* @return Map<String, BigDecimal>
|
|
* @return Map<String, BigDecimal>
|
|
*/
|
|
*/
|
|
public Map<String, Object> getAirAndPaAndT(String equipmentId, String month) {
|
|
public Map<String, Object> getAirAndPaAndT(String equipmentId, String month) {
|
|
- List<ProphaseWeatherData> weatherDataList = new ArrayList<>();
|
|
|
|
- List<ProphaseAnemometryData> anemometryDataList = new ArrayList<>();
|
|
|
|
- //获取最新数据起止时间
|
|
|
|
- Map<String, Long> dataTimeStartAndEnd = prophaseWeatherDataService.getDataTimeStartAndEnd(equipmentId);
|
|
|
|
- //获取测风塔基本信息
|
|
|
|
- WindTowerInfo windTowerInfo = windTowerInfoService.getByEquipmentNo(equipmentId).get(0);
|
|
|
|
- //获取层高
|
|
|
|
- String[] heights = windTowerInfo.getHeights().split(",");
|
|
|
|
- //获取风向 层高 最高层
|
|
|
|
- String wdHeights = windTowerInfo.getWdHeights();
|
|
|
|
- String wdHeightMax = "";
|
|
|
|
- if (!wdHeights.isEmpty()) {
|
|
|
|
- ArrayList<String> wdHeightList = new ArrayList(Arrays.asList(wdHeights.split(",")));
|
|
|
|
- List<Integer> collect = wdHeightList.stream().map(Integer::parseInt).sorted().collect(Collectors.toList());
|
|
|
|
- wdHeightMax = collect.get(collect.size() - 1).toString();
|
|
|
|
- }
|
|
|
|
|
|
+ List<WindTowerInfo> windTowerInfoList = windTowerInfoService.lambdaQuery().eq(WindTowerInfo::getEquipmentNo, equipmentId).list();
|
|
|
|
+ String[] wdHeight = windTowerInfoList.get(0).getWdHeights().split(",");
|
|
|
|
|
|
|
|
+ ArrayList<String> arrayList = new ArrayList(Arrays.asList(windTowerInfoList.get(0).getHeights().split(",")));
|
|
|
|
+ //层高排序
|
|
|
|
+ List<Integer> heightList = arrayList.stream().map(s -> Integer.parseInt(CalculationUtil.getNumberFromString(s))).sorted().collect(Collectors.toList());
|
|
|
|
+ Integer maxHeight = heightList.get(heightList.size() - 1);
|
|
|
|
+ //获取最后一条记录
|
|
|
|
+ WindTowerCalculationData lastDataCalculation = windTowerCalculationDataService.getLastDataCalculation(equipmentId);
|
|
|
|
|
|
- if (!month.equals("")) {
|
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
|
|
|
|
- try {
|
|
|
|
- Date startDate = sdf.parse(month);
|
|
|
|
- Date endDate = DateTimeUtil.endOfMonth(startDate);
|
|
|
|
- weatherDataList = prophaseWeatherDataService.selectTAveAndPaAveAndAir(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
|
|
|
|
- anemometryDataList = prophaseAnemometryDataService.selectWdAveAndWdAveAndWsSta(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
|
|
|
|
- } catch (ParseException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- List<Entity> lastData = prophaseWeatherDataService.getLastData(equipmentId);
|
|
|
|
- Timestamp timeEnd = (Timestamp) lastData.get(0).get("last (ts)");
|
|
|
|
- DateTime startTime = DateUtil.beginOfDay(new Date(timeEnd.getTime()));
|
|
|
|
- // 最新一天数据
|
|
|
|
- weatherDataList = prophaseWeatherDataService.selectTAveAndPaAveAndAir(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
|
|
|
|
- anemometryDataList = prophaseAnemometryDataService.selectWdAveAndWdAveAndWsSta(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
|
|
|
|
- }
|
|
|
|
|
|
+ Date yearDay = DateTimeUtil.getYearDay(lastDataCalculation.getTime().getTime());
|
|
|
|
+ //获取去年月份开始时间
|
|
|
|
+ Date beginTime = DateUtil.offsetMonth(DateUtil.beginOfMonth(yearDay), 1);
|
|
|
|
+ Date endTime = lastDataCalculation.getTime();
|
|
|
|
|
|
- HashMap<String, Object> dataMap = new HashMap<>();
|
|
|
|
- BigDecimal tAve = BigDecimal.ZERO;
|
|
|
|
- BigDecimal airDensity = BigDecimal.ZERO;
|
|
|
|
- BigDecimal pa = BigDecimal.ZERO;
|
|
|
|
-
|
|
|
|
- // 风速集合
|
|
|
|
- String finalHeight = CalculationUtil.getNumberFromString(heights[0]);
|
|
|
|
- List<BigDecimal> wsForHeight = anemometryDataList.stream().filter(a -> a.getLayerHeight().equals(finalHeight) && a.getWsAve() != null)
|
|
|
|
- .map(h -> BigDecimal.valueOf(h.getWsAve()))
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
- // 风速标准差集合
|
|
|
|
- List<BigDecimal> wsStaForHeight = anemometryDataList.stream().filter(a -> a.getLayerHeight().equals(finalHeight) && a.getWsSta() != null)
|
|
|
|
- .map(h -> BigDecimal.valueOf(h.getWsSta()))
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
-
|
|
|
|
- BigDecimal avgWs = CalculationUtil.getAvgWind(wsForHeight); // 风速平均值
|
|
|
|
- BigDecimal avgWsSta = CalculationUtil.getAvgWind(wsStaForHeight);// 风速标准差平均值
|
|
|
|
- BigDecimal turbulence = CalculationUtil.caTurbulenceIntensity(avgWsSta, avgWs); // 湍流
|
|
|
|
- BigDecimal windShear = CalculationUtil.getWindShear(anemometryDataList, heights);//计算综合风切变
|
|
|
|
-
|
|
|
|
- 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);
|
|
|
|
- }
|
|
|
|
- HashMap<String, Integer> wdMap = new HashMap<>();
|
|
|
|
- for (WindDirectionEnum value : WindDirectionEnum.values()) {
|
|
|
|
|
|
+ List<EquipmentAttribute> equipmentAttributeList = equipmentAttributeService.lambdaQuery().eq(EquipmentAttribute::getFieldName, "airDensityMonth").or().eq(EquipmentAttribute::getFieldName, "tAVE").or().
|
|
|
|
+ eq(EquipmentAttribute::getFieldName, "paAVE").or().eq(EquipmentAttribute::getFieldName, maxHeight + "turbulenceMonth").or().
|
|
|
|
+ eq(EquipmentAttribute::getFieldName, "windShearMonth").or().eq(EquipmentAttribute::getFieldName, "batteryDay")
|
|
|
|
+ .or().eq(EquipmentAttribute::getFieldName, wdHeight[0] + "monthWdRose").list();
|
|
|
|
|
|
- String finalWdHeightMax = wdHeightMax;
|
|
|
|
- List<ProphaseAnemometryData> dataList = anemometryDataList.stream().filter(a -> a.getLayerHeight().equals(finalWdHeightMax)).collect(Collectors.toList());
|
|
|
|
- List<ProphaseAnemometryData> forHeightAndWindDirectionEnum = CalculationUtil.getForHeightAndWindDirectionEnum(dataList, value);
|
|
|
|
- wdMap.put(value.name(), forHeightAndWindDirectionEnum.size());
|
|
|
|
- }
|
|
|
|
- Integer total = 0;
|
|
|
|
- for (Map.Entry<String, Integer> entry : wdMap.entrySet()) {
|
|
|
|
- if (entry.getValue() >= total) {
|
|
|
|
- dataMap.put("wdSum", entry.getKey());
|
|
|
|
- total = entry.getValue();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- BigDecimal batterySum = BigDecimal.ZERO;
|
|
|
|
- for (BigDecimal ws : wsForHeight) {
|
|
|
|
-// 日发电量 = 风速*功率*塔个数*频率 累加至24小时
|
|
|
|
- BigDecimal battery = CalculationUtil.getBattery(ws);
|
|
|
|
- batterySum = batterySum.add(battery);
|
|
|
|
- }
|
|
|
|
- //日发电量
|
|
|
|
- batterySum = batterySum.divide(BigDecimal.valueOf(6 * 1000), 2, RoundingMode.HALF_UP);
|
|
|
|
|
|
+ List<WindTowerCalculationData> windTowerCalculationDataList = windTowerCalculationDataService.getByBetweenTimeAndEquipmentIdAndEbId(beginTime, endTime, equipmentId, equipmentAttributeList);
|
|
|
|
+
|
|
|
|
+ HashMap<String, Object> dataMap = new HashMap<>();
|
|
|
|
+ //温度
|
|
|
|
+ dataMap.put("t", this.getDataForCalculationByEb(equipmentAttributeList, windTowerCalculationDataList, "tAVE"));
|
|
|
|
+ //空气密度
|
|
|
|
+ dataMap.put("air", this.getDataForCalculationByEb(equipmentAttributeList, windTowerCalculationDataList, "airDensityMonth"));
|
|
|
|
+ //压强
|
|
|
|
+ dataMap.put("pa", this.getDataForCalculationByEb(equipmentAttributeList, windTowerCalculationDataList, "paAVE"));
|
|
|
|
+ //湍流
|
|
|
|
+ dataMap.put("turbulence", this.getDataForCalculationByEb(equipmentAttributeList, windTowerCalculationDataList, maxHeight + "turbulenceMonth"));
|
|
|
|
+ //风切变
|
|
|
|
+ dataMap.put("windShear", this.getDataForCalculationByEb(equipmentAttributeList, windTowerCalculationDataList, "windShearMonth"));
|
|
|
|
+ //层高
|
|
|
|
+ dataMap.put("height", maxHeight);
|
|
|
|
+ List<EquipmentAttribute> batteryDay1 = equipmentAttributeList.stream().filter(e -> e.getFieldName().equals("batteryDay")).collect(Collectors.toList());
|
|
|
|
+ List<WindTowerCalculationData> calculationDataList = windTowerCalculationDataList.stream().filter(w -> w.getEbId().equals(batteryDay1.get(0).getId())).collect(Collectors.toList());
|
|
|
|
+ BigDecimal batteryDay = calculationDataList.stream().map(WindTowerCalculationData::getValue).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
+ BigDecimal hourMax = batteryDay.divide(BigDecimal.valueOf(6.25), 2, RoundingMode.HALF_UP);
|
|
|
|
+ //发电量
|
|
|
|
+ dataMap.put("battery", batteryDay);
|
|
//满发小时数
|
|
//满发小时数
|
|
- BigDecimal hourMax = batterySum.divide(BigDecimal.valueOf(6.25), 2, RoundingMode.HALF_UP);
|
|
|
|
- dataMap.put("battery", batterySum);
|
|
|
|
dataMap.put("hour", hourMax);
|
|
dataMap.put("hour", hourMax);
|
|
|
|
+
|
|
|
|
+ List<EquipmentAttribute> equipmentAttributes = equipmentAttributeList.stream().filter(e -> e.getFieldName().equals(wdHeight[0] + "monthWdRose")).collect(Collectors.toList());
|
|
|
|
+ List<WindDirectionStatisticsData> windDirectionStatisticsDataList = windDirectionStatisticsDataService.lambdaQuery().eq(WindDirectionStatisticsData::getEbId, equipmentAttributes.get(0).getId()).between(WindDirectionStatisticsData::getTime, beginTime, endTime)
|
|
|
|
+ .eq(WindDirectionStatisticsData::getEquipmentId, equipmentId).list();
|
|
|
|
+
|
|
|
|
+ Map<String, List<WindDirectionStatisticsData>> collect = windDirectionStatisticsDataList.stream().collect(Collectors.groupingBy(w -> w.getDirection()));
|
|
|
|
+ HashMap<String, BigDecimal> hashMap = new HashMap<>();
|
|
|
|
+ for (Map.Entry<String, List<WindDirectionStatisticsData>> k : collect.entrySet()) {
|
|
|
|
+ BigDecimal reduce = k.getValue().stream().map(WindDirectionStatisticsData::getValue).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
+ hashMap.put(k.getKey(), reduce);
|
|
|
|
+ }
|
|
|
|
+ Map.Entry<String, BigDecimal> stringBigDecimalEntry = hashMap.entrySet().stream().max(Comparator.comparing(Map.Entry::getValue)).get();
|
|
|
|
+ //主风向
|
|
|
|
+ dataMap.put("wdSum", stringBigDecimalEntry.getKey());
|
|
|
|
+ //起止时间
|
|
|
|
+ Map<String, Long> dataTimeStartAndEnd = prophaseWeatherDataService.getDataTimeStartAndEnd(equipmentId);
|
|
String startTime = DateUtil.format(new Date(dataTimeStartAndEnd.get("startTime")), "yyyy-MM-dd");
|
|
String startTime = DateUtil.format(new Date(dataTimeStartAndEnd.get("startTime")), "yyyy-MM-dd");
|
|
- String endTime = DateUtil.format(new Date(dataTimeStartAndEnd.get("endTime")), "yyyy-MM-dd");
|
|
|
|
-
|
|
|
|
- dataMap.put("dataTime", startTime + "-" + endTime);
|
|
|
|
- dataMap.put("longitude", windTowerInfo.getLongitude());
|
|
|
|
- dataMap.put("latitude", windTowerInfo.getLatitude());
|
|
|
|
-
|
|
|
|
- dataMap.put("t", tAve);
|
|
|
|
- dataMap.put("air", airDensity);
|
|
|
|
- dataMap.put("pa", pa);
|
|
|
|
- dataMap.put("turbulence", turbulence);
|
|
|
|
- dataMap.put("windShear", windShear);
|
|
|
|
- dataMap.put("height", finalHeight);
|
|
|
|
|
|
+ String endTimeStr = DateUtil.format(endTime, "yyyy-MM-dd");
|
|
|
|
+ dataMap.put("dataTime", startTime + "-" + endTimeStr);
|
|
|
|
+ dataMap.put("longitude", windTowerInfoList.get(0).getLongitude());
|
|
|
|
+ dataMap.put("latitude", windTowerInfoList.get(0).getLatitude());
|
|
|
|
+
|
|
return dataMap;
|
|
return dataMap;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public BigDecimal getDataForCalculationByEb(List<EquipmentAttribute> equipmentAttributeList, List<WindTowerCalculationData> windTowerCalculationDataList, String fieldName) {
|
|
|
|
+ List<String> ebId = equipmentAttributeList.stream().filter(e -> e.getFieldName().equals(fieldName)).map(EquipmentAttribute::getId).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ List<BigDecimal> dataList = windTowerCalculationDataList.stream().filter(w -> w.getEbId().equals(ebId.get(0))).map(WindTowerCalculationData::getValue).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ return dataList.size() > 0 ? CalculationUtil.getAvgWind(dataList) : BigDecimal.ZERO;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
//首页全省资源概述
|
|
//首页全省资源概述
|
|
public HashMap<String, String> getResourcesOverview() {
|
|
public HashMap<String, String> getResourcesOverview() {
|