Bläddra i källkod

整合 mongodb

hxf 2 år sedan
förälder
incheckning
94eb7fffe0

+ 0 - 19
neim-biz/src/main/java/com/jiayue/biz/conf/MongoConfig.java

@@ -1,19 +0,0 @@
-//package com.jiayue.biz.conf;
-//
-//
-//import com.mongodb.ServerAddress;
-//import com.mongodb.client.MongoCollection;
-//import com.mongodb.client.MongoDatabase;
-//import org.springframework.beans.factory.annotation.Autowired;
-//import org.springframework.boot.autoconfigure.mongo.MongoProperties;
-//import org.springframework.context.annotation.Bean;
-//import org.springframework.context.annotation.Configuration;
-//
-//
-//@Configuration
-//public class MongoConfig {
-//
-//
-//
-//}
-//

+ 1 - 17
neim-biz/src/main/java/com/jiayue/biz/controller/HomePageController.java

@@ -1,9 +1,5 @@
 package com.jiayue.biz.controller;
 
-import com.jiayue.biz.domain.ProjectBasicInfo;
-import com.jiayue.biz.domain.ProjectInfo;
-import com.jiayue.biz.domain.ProvincialEnergyStations;
-import com.jiayue.biz.domain.TotalityInfo;
 import com.jiayue.biz.service.*;
 import com.jiayue.common.core.controller.BaseController;
 import com.jiayue.common.core.domain.AjaxResult;
@@ -14,11 +10,7 @@ import lombok.RequiredArgsConstructor;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
+
 
 
 /**
@@ -54,14 +46,6 @@ public class HomePageController extends BaseController {
         return AjaxResult.success(homePageService.homePageRose(equipmentId, height, month));
     }
 
-    /**
-     * 首页风功率密度与风速
-     */
-    @GetMapping("/selectWpdAndWs")
-    public AjaxResult selectWpdAndWs(String equipmentId) {
-
-        return AjaxResult.success(homePageService.selectWpdAndWs(equipmentId));
-    }
 
     /**
      * 首页风功率密度与风速(柱状图)

+ 20 - 0
neim-biz/src/main/java/com/jiayue/biz/domain/OtherStationInfo.java

@@ -0,0 +1,20 @@
+package com.jiayue.biz.domain;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+//全省其他场站信息
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Document("other_station_info")
+public class OtherStationInfo {
+    private String id;
+    private String stationName;
+    private String stationType;
+    private String longitude;
+    private String latitude;
+    private String company;
+}

+ 1 - 9
neim-biz/src/main/java/com/jiayue/biz/service/HomePageService.java

@@ -42,14 +42,6 @@ public interface HomePageService extends IService<WindTowerDataParentTable> {
     /*首页所有塔的地图*/
     List<Map<String,Object>> homePageAllWindMap();
 
-    /**
-     * 首页空气密度与风速折线图
-     *
-     * @param equipmentId 场站编号
-     * @return HashMap<String, List < Object>>
-     */
-     Map<String, Object> selectWpdAndWs(String equipmentId);
-
 
     /**
      * 首页空气密度和温度
@@ -100,7 +92,7 @@ public interface HomePageService extends IService<WindTowerDataParentTable> {
     //地图点位坐标 (风机、测风塔、拐点)
     HashMap<String, Object> getPointMap();
     //查询所有的场站坐标
-    ArrayList<Object> getStationSeat();
+    HashMap<String, Object> getStationSeat();
     //查询所有的项目坐标
     ArrayList<Object> getProjectSeat();
 }

+ 12 - 0
neim-biz/src/main/java/com/jiayue/biz/service/OtherStationInfoService.java

@@ -0,0 +1,12 @@
+package com.jiayue.biz.service;
+
+import com.jiayue.biz.domain.OtherStationInfo;
+
+import java.util.List;
+
+public interface OtherStationInfoService {
+
+
+    //查询全省其他场站基本信息
+     List<OtherStationInfo> selectOtherStationInfo();
+}

+ 142 - 157
neim-biz/src/main/java/com/jiayue/biz/service/impl/HomePageServiceImpl.java

@@ -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;
     }
 
     /**

+ 28 - 0
neim-biz/src/main/java/com/jiayue/biz/service/impl/OtherStationInfoServiceImpl.java

@@ -0,0 +1,28 @@
+package com.jiayue.biz.service.impl;
+
+import com.jiayue.biz.domain.OtherStationInfo;
+import com.jiayue.biz.service.OtherStationInfoService;
+import lombok.AllArgsConstructor;
+import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.data.mongodb.core.query.Query;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+@AllArgsConstructor
+public class OtherStationInfoServiceImpl implements OtherStationInfoService {
+
+    private final MongoTemplate mongoTemplate;
+
+
+    //查询全省其他场站基本信息
+    public List<OtherStationInfo> selectOtherStationInfo(){
+
+       return mongoTemplate.find(new Query(),OtherStationInfo.class,"other_station_info");
+
+    }
+
+
+
+}

+ 1 - 0
neim-biz/src/main/java/com/jiayue/biz/service/impl/ProphaseAnemometryDataServiceImpl.java

@@ -40,4 +40,5 @@ public class ProphaseAnemometryDataServiceImpl extends ServiceImpl<ProphaseAnemo
     }
 
 
+
 }

+ 3 - 3
neim-biz/src/main/java/com/jiayue/biz/util/CalculationUtil.java

@@ -180,12 +180,12 @@ public class CalculationUtil {
                     if (weatherData.get(i).getAirDensity() != null && anemometryData.get(i).getWsAve() != null) {
                         if (weatherData.get(i).getTs().getTime() == anemometryData.get(i).getTs().getTime()) {
                             //计算风功率密度 空气密度*第i点的风速值的立方 求和/2 各个层高都有
-                            count = count.add(wpdCalculate(getBigDecimal(weatherData.get(i).getAirDensity()),getBigDecimal(anemometryData.get(i).getWsAve())));
+                            count = count.add(getWpdCalculate(getBigDecimal(weatherData.get(i).getAirDensity()),getBigDecimal(anemometryData.get(i).getWsAve())));
                         } else {
                             int finalI = i;
                             List<ProphaseWeatherData> collect = weatherData.stream().filter(w -> w.getTs().getTime() == anemometryData.get(finalI).getTs().getTime()).collect(Collectors.toList());
                             if (collect.size() > 0) {
-                                count = count.add(wpdCalculate(getBigDecimal(collect.get(0).getAirDensity()),getBigDecimal(anemometryData.get(i).getWsAve())));
+                                count = count.add(getWpdCalculate(getBigDecimal(collect.get(0).getAirDensity()),getBigDecimal(anemometryData.get(i).getWsAve())));
                             }
                         }
                     }
@@ -200,7 +200,7 @@ public class CalculationUtil {
     }
 
     //计算风功率密度公式
-    public static BigDecimal wpdCalculate(BigDecimal wsAve, BigDecimal airAve){
+    public static BigDecimal getWpdCalculate(BigDecimal wsAve, BigDecimal airAve){
        return airAve.multiply(power(getBigDecimal(wsAve), 3)).multiply(BigDecimal.valueOf(0.5));
     }
 

+ 0 - 83
neim-biz/src/main/java/com/jiayue/biz/util/MongoDBUtil.java

@@ -1,83 +0,0 @@
-//package com.jiayue.biz.util;
-//
-//import com.mongodb.MongoClient;
-//import com.mongodb.MongoCredential;
-//import com.mongodb.ServerAddress;
-//import com.mongodb.client.MongoDatabase;
-//import org.slf4j.Logger;
-//import org.slf4j.LoggerFactory;
-//
-//import java.util.ArrayList;
-//import java.util.List;
-//
-//public class MongoDBUtil{
-//
-//    private static Logger logger= LoggerFactory.getLogger(MongoDBUtil.class);
-//
-//
-//
-//    /**
-//     *
-//     * 获取MongoDB数据库连接
-//     *
-//     * @param host:服务器地址
-//     * @param port:服务器端口号
-//     * @param username 用户名
-//     * @param databaseName 数据库名称
-//     * @param password 密码
-//     * @return MongoClient
-//     */
-//
-//    public static MongoClient getMongoClient(String host, int port, String username, String databaseName, String password){
-//        //连接到MongoDB服务 如果是远程连接可以替换“localhost”为服务器所在IP地址
-//        //ServerAddress()两个参数分别为 服务器地址 和 端口
-//        ServerAddress serverAddress = new ServerAddress(host,port);
-//        List<ServerAddress> addrs = new ArrayList<ServerAddress>();
-//        addrs.add(serverAddress);
-//        //MongoCredential.createScramSha1Credential()三个参数分别为 用户名 数据库名称 密码
-//        MongoCredential credential = MongoCredential.createScramSha1Credential(username, databaseName, password.toCharArray());
-//
-//        List<MongoCredential> credentials = new ArrayList<MongoCredential>();
-//
-//        credentials.add(credential);
-//
-//        //通过连接认证获取MongoDB连接
-//        MongoClient mongoClient = new MongoClient(addrs,credentials);
-//        return mongoClient;
-//
-//    }
-//
-//
-//
-//    /**
-//     * MongoDB 获取数据库连接
-//     *
-//     * @param mongoClient MongoDB客户端连接
-//     * @param host:服务器地址
-//     * @param port:服务器端口号
-//     * @param username 用户名
-//     * @param databaseName 数据库名称
-//     * @param password 密码
-//     *
-//     * @return MongoDatabase
-//     */
-//
-//    public static MongoDatabase getMongoDatabase(MongoClient mongoClient, String host, int port, String username, String databaseName, String password){
-//        try {
-//        //连接到数据库
-//            MongoDatabase mongoDatabase = mongoClient.getDatabase(databaseName);
-//            logger.info("Connect to database successfully");
-//
-//            return mongoDatabase;
-//
-//        } catch (Exception e) {
-//            logger.error( e.getClass().getName() + ": " + e.getMessage() );
-//        }
-//
-//        return null;
-//
-//    }
-//
-//
-//
-//}