Explorar el Código

首页测风塔起止时间 经纬度 主风向

hxf hace 2 años
padre
commit
5ab4561943

+ 3 - 1
neim-biz/src/main/java/com/jiayue/biz/service/ProphaseWeatherDataService.java

@@ -5,8 +5,10 @@ import com.jiayue.biz.domain.ProphaseWeatherData;
 
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 
 public interface ProphaseWeatherDataService extends IService<ProphaseWeatherData> {
-
+    //获取测风塔起止时间
+     Map<String, Long> getDataTimeStartAndEnd(String equipmentNo);
 
 }

+ 44 - 28
neim-biz/src/main/java/com/jiayue/biz/service/impl/HomePageServiceImpl.java

@@ -62,6 +62,8 @@ public class HomePageServiceImpl extends ServiceImpl<WindTowerDataParentTableMap
     private final ProphaseAnemometryDataMapper prophaseAnemometryDataMapper;
     private final ProphaseWeatherDataMapper prophaseWeatherDataMapper;
 
+    private final ProphaseWeatherDataService prophaseWeatherDataService;
+
     private final OtherStationInfoService otherStationInfoService;
 
 
@@ -549,14 +551,22 @@ public class HomePageServiceImpl extends ServiceImpl<WindTowerDataParentTableMap
     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 height;
+        String[] strings = windTowerInfo.getHeights().split(",");
+        height = CalculationUtil.getNumberFromString(strings[0]);
+        String minHeight = CalculationUtil.getNumberFromString(strings[strings.length - 1]); //最底层
+        if (windTowerInfo.getDisplayHeight() != null && !windTowerInfo.getDisplayHeight().equals("")) {
+            height = windTowerInfo.getDisplayHeight();
+        }
         if (!month.equals("")) {
             SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
             try {
                 Date startDate = sdf.parse(month);
                 Date endDate = DateTimeUtil.endOfMonth(startDate);
                 weatherDataList = prophaseWeatherDataMapper.selectTAveAndPaAveAndAir(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
-                anemometryDataList = prophaseAnemometryDataMapper.selectAveAndSta(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
+                anemometryDataList = prophaseAnemometryDataMapper.selectWdAveAndWdAveAndWsStaForHeight(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()), height);
             } catch (ParseException e) {
                 e.printStackTrace();
             }
@@ -566,17 +576,7 @@ public class HomePageServiceImpl extends ServiceImpl<WindTowerDataParentTableMap
             DateTime startTime = DateUtil.beginOfDay(new Date(timeEnd.getTime()));
             // 最新一天数据
             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);
-
-
-        String height;
-        String[] strings = windTowerInfo.getHeights().split(",");
-        height = CalculationUtil.getNumberFromString(strings[0]);
-        String minHeight = CalculationUtil.getNumberFromString(strings[strings.length - 1]); //最底层
-        if (windTowerInfo.getDisplayHeight() != null && !windTowerInfo.getDisplayHeight().equals("")) {
-            height = windTowerInfo.getDisplayHeight();
+            anemometryDataList = prophaseAnemometryDataMapper.selectWdAveAndWdAveAndWsStaForHeight(equipmentId, new Timestamp(startTime.getTime()), timeEnd, height);
         }
 
         HashMap<String, Object> dataMap = new HashMap<>();
@@ -585,16 +585,15 @@ public class HomePageServiceImpl extends ServiceImpl<WindTowerDataParentTableMap
         BigDecimal pa = BigDecimal.ZERO;
 
         // 风速集合
-        String finalHeight = height;
-        List<BigDecimal> wsForHeight = anemometryDataList.stream().filter(a -> a.getLayerHeight().equals(finalHeight)).map(h -> {
+        List<BigDecimal> wsForHeight = anemometryDataList.stream().map(h -> {
             return BigDecimal.valueOf(h.getWsAve());
         }).collect(Collectors.toList());
-
-        List<BigDecimal> minWsForHeight = anemometryDataList.stream().filter(a -> a.getLayerHeight().equals(minHeight)).map(h -> {
+        //最小风速集合
+        List<BigDecimal> minWsForHeight = anemometryDataList.stream().map(h -> {
             return BigDecimal.valueOf(h.getWsAve());
         }).collect(Collectors.toList());
         // 风速标准差集合
-        List<BigDecimal> wsStaForHeight = anemometryDataList.stream().filter(a -> a.getLayerHeight().equals(minHeight)).map(h -> {
+        List<BigDecimal> wsStaForHeight = anemometryDataList.stream().map(h -> {
             return BigDecimal.valueOf(h.getWsSta());
         }).collect(Collectors.toList());
 
@@ -606,21 +605,32 @@ public class HomePageServiceImpl extends ServiceImpl<WindTowerDataParentTableMap
         if (avgWs.compareTo(BigDecimal.ZERO) != 0) {
             windShear = CalculationUtil.caWindShear(avgWs, avgMinWs, new BigDecimal(height), new BigDecimal(minHeight));// 风切变
         }
-        if(!weatherDataList.isEmpty()){
+        if (!weatherDataList.isEmpty()) {
 
-            airDensity =  BigDecimal.valueOf(weatherDataList.stream().map(w -> {
+            airDensity = BigDecimal.valueOf(weatherDataList.stream().map(w -> {
                 return BigDecimal.valueOf(w.getAirDensity());
-            }).collect(Collectors.averagingDouble(BigDecimal::doubleValue))).setScale(2,RoundingMode.HALF_UP);
+            }).collect(Collectors.averagingDouble(BigDecimal::doubleValue))).setScale(2, RoundingMode.HALF_UP);
 
-            tAve =  BigDecimal.valueOf(weatherDataList.stream().map(w -> {
+            tAve = BigDecimal.valueOf(weatherDataList.stream().map(w -> {
                 return BigDecimal.valueOf(w.getTAve());
-            }).collect(Collectors.averagingDouble(BigDecimal::doubleValue))).setScale(2,RoundingMode.HALF_UP);
+            }).collect(Collectors.averagingDouble(BigDecimal::doubleValue))).setScale(2, RoundingMode.HALF_UP);
 
-            pa =  BigDecimal.valueOf(weatherDataList.stream().map(w -> {
+            pa = BigDecimal.valueOf(weatherDataList.stream().map(w -> {
                 return BigDecimal.valueOf(w.getPaAve());
-            }).collect(Collectors.averagingDouble(BigDecimal::doubleValue))).setScale(2,RoundingMode.HALF_UP);
+            }).collect(Collectors.averagingDouble(BigDecimal::doubleValue))).setScale(2, RoundingMode.HALF_UP);
+        }
+        HashMap<String, Integer> wdMap = new HashMap<>();
+        for (WindDirectionEnum value : WindDirectionEnum.values()) {
+            List<ProphaseAnemometryData> forHeightAndWindDirectionEnum = CalculationUtil.getForHeightAndWindDirectionEnum(anemometryDataList, 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小时
@@ -633,6 +643,12 @@ public class HomePageServiceImpl extends ServiceImpl<WindTowerDataParentTableMap
         BigDecimal hourMax = batterySum.divide(BigDecimal.valueOf(6.25), 2, RoundingMode.HALF_UP);
         dataMap.put("battery", batterySum);
         dataMap.put("hour", hourMax);
+        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);
@@ -882,8 +898,8 @@ public class HomePageServiceImpl extends ServiceImpl<WindTowerDataParentTableMap
             otherStationList.add(hashMap);
 
         }
-        dataMap.put("HDStation",stationList);
-        dataMap.put("otherStation",otherStationList);
+        dataMap.put("HDStation", stationList);
+        dataMap.put("otherStation", otherStationList);
 
         return dataMap;
     }

+ 18 - 5
neim-biz/src/main/java/com/jiayue/biz/service/impl/ProphaseWeatherDataServiceImpl.java

@@ -1,5 +1,6 @@
 package com.jiayue.biz.service.impl;
 
+import cn.hutool.db.Entity;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.jiayue.biz.domain.ProphaseWeatherData;
 import com.jiayue.biz.mapper.ProphaseWeatherDataMapper;
@@ -9,15 +10,27 @@ import org.springframework.stereotype.Service;
 
 import java.sql.Timestamp;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 @Service
 @AllArgsConstructor
-public class ProphaseWeatherDataServiceImpl extends ServiceImpl<ProphaseWeatherDataMapper,ProphaseWeatherData> implements ProphaseWeatherDataService {
-
-
-
-
+public class ProphaseWeatherDataServiceImpl extends ServiceImpl<ProphaseWeatherDataMapper, ProphaseWeatherData> implements ProphaseWeatherDataService {
+
+    //获取测风塔起止时间
+    public Map<String, Long> getDataTimeStartAndEnd(String equipmentNo) {
+        HashMap<String, Long> hashMap = new HashMap<>();
+        List<Entity> lastData = baseMapper.getLastData(equipmentNo);
+        List<Entity> firstData = baseMapper.getFirstData(equipmentNo);
+        if(!lastData.isEmpty() && !firstData.isEmpty()){
+            Timestamp timeEnd = (Timestamp) lastData.get(0).get("last (ts)");
+            Timestamp timeStart = (Timestamp) firstData.get(0).get("first (ts)");
+            hashMap.put("startTime",timeStart.getTime());
+            hashMap.put("endTime",timeEnd.getTime());
+        }
+        return hashMap;
+    }
 
 
 }