Bladeren bron

声雷达数据接入

hxf 1 jaar geleden
bovenliggende
commit
7b5fe66482

+ 2 - 1
wrdep-biz/src/main/java/com/jiayue/biz/controller/WindTowerInfoController.java

@@ -29,6 +29,7 @@ import org.springframework.web.bind.annotation.RestController;
 import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
 import java.util.*;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 import javax.servlet.http.HttpServletResponse;
 
@@ -178,7 +179,7 @@ public class WindTowerInfoController extends BaseController {
     @Log(title = "测风塔信息", businessType = BusinessType.UPDATE)
     @PutMapping
     public AjaxResult edit(@RequestBody WindTowerInfo windTowerInfo) {
-        return toAjax(windTowerInfoService.updateById(windTowerInfo) ? 1 : 0);
+        return toAjax(windTowerInfoService.update(windTowerInfo) ? 1 : 0);
     }
 
     /**

+ 1 - 1
wrdep-biz/src/main/java/com/jiayue/biz/job/FileAnalysisJob.java

@@ -53,7 +53,7 @@ public class FileAnalysisJob {
         this.emailImpl = emailImpl;
     }
 
-//    @Scheduled(fixedDelay = 60000)
+    @Scheduled(fixedDelay = 60000)
     public void fileAnalysis() {
 
         log.debug("文件解析定时任务执行开始");

+ 2 - 0
wrdep-biz/src/main/java/com/jiayue/biz/service/WindTowerInfoService.java

@@ -28,6 +28,8 @@ public interface WindTowerInfoService extends IService<WindTowerInfo> {
     //查询所有测风塔信息
     List<WindTowerInfo> getAllWindTower();
 
+    boolean update(WindTowerInfo windTowerInfo);
+
     boolean deleteWindTowerInfo(List<String> ids);
 
     List<Map<String, String>> listEquipmentIdAndDataTime();

+ 54 - 27
wrdep-biz/src/main/java/com/jiayue/biz/service/impl/AnalysisDataImpl.java

@@ -828,24 +828,26 @@ public class AnalysisDataImpl {
      */
     public void acousticRadar(File file, String eqId) {
         List<Map<String, Object>> mapList = new ArrayList<>();
+        HashMap<String, ArrayList<Double>> wsStaMapList = new HashMap<>();
         CsvReader reader = CsvUtil.getReader();
         //解析csv文件设置编码为GBK
         CsvData data = reader.read(file, Charset.forName("gbk"));
         //获取到csv文件
         List<CsvRow> rows = data.getRows();
         //获取层高
-        List<WindTowerInfo> equipmentNo = windTowerInfoService.getByEquipmentNo(eqId);
+        List<WindTowerInfo> equipmentNo = windTowerInfoService.lambdaQuery().eq(WindTowerInfo::getEquipmentNo,eqId).list();
         String height = "";
         if (equipmentNo.size() == 0) {
             CsvRow csvRow = rows.get(0);
             StringBuilder heights = new StringBuilder();
-            for (String s : csvRow) {
-                if (s.contains("高度")) {
+            for (int i = csvRow.size() - 1; i >= 0; i--) {
+                if (csvRow.get(i).contains("高度")) {
                     if (heights.length() != 0) {
                         heights.append(",");
                     }
-                    heights.append(CalculationUtil.getNumberFromString(s));
+                    heights.append(CalculationUtil.getNumberFromString(csvRow.get(i)));
                 }
+
             }
             height = heights.toString();
             WindTowerInfo windTowerInfo = new WindTowerInfo();
@@ -860,6 +862,7 @@ public class AnalysisDataImpl {
         }
         int total = 0;
         String str = "";
+        boolean firstBoolean = true;
         //遍历表头 设置表头
         try {
             for (String s : rows.get(0)) {
@@ -899,6 +902,7 @@ public class AnalysisDataImpl {
                     continue;
                 }
                 HashMap<String, Object> hashMap = new HashMap<>();
+//                HashMap<String, Object> firstMap = new HashMap<>();
 
                 if (rows.get(0).contains("time")) {
                     int time = rows.get(0).indexOf("time");
@@ -908,43 +912,66 @@ public class AnalysisDataImpl {
                         if (time1.contains("000000000000")) {
                             continue;
                         }
-                        hashMap.put("time", time1);
                     }
                 }
 
-                BigDecimal tAve = conversion("t_ave", row, rows);
-                hashMap.put("tAve", tAve);
-                CheckDataRecode.map.put("tAve" + "DeadDataStartTime", new DateTime(sdf.parse(time1)));
+                for (String h : height.split(",")) {
 
-                BigDecimal rhAve = conversion("rh_ave", row, rows);
-                hashMap.put("rhAve", rhAve);
-                CheckDataRecode.map.put("rhAve" + "DeadDataStartTime", new DateTime(sdf.parse(time1)));
+                    BigDecimal wsAve = conversion("ws_Ave" + h, row, rows);
+                    if (wsStaMapList.get(h) == null) {
+                        ArrayList<Double> wsStaList = new ArrayList<>();
+                        wsStaList.add(wsAve.doubleValue());
+                        wsStaMapList.put(h, wsStaList);
+                    } else {
+                        wsStaMapList.get(h).add(wsAve.doubleValue());
+                    }
 
-                BigDecimal paAve = conversion("pa_ave", row, rows);
-                hashMap.put("paAve", paAve);
-                CheckDataRecode.map.put("paAve" + "DeadDataStartTime", new DateTime(sdf.parse(time1)));
 
-                BigDecimal airDensity = BigDecimal.valueOf(1.293).multiply(new BigDecimal(273).divide(new BigDecimal(273).add(CalculationUtil.getBigDecimal(tAve)), 2, RoundingMode.HALF_UP)).multiply(CalculationUtil.getBigDecimal(paAve)).divide(new BigDecimal(1013), 2, RoundingMode.HALF_UP);
-                hashMap.put("airDensity", airDensity);
-                CheckDataRecode.map.put("airDensity" + "DeadDataStartTime", new DateTime(sdf.parse(time1)));
+                }
 
-                for (String h : height.split(",")) {
+                if ((sdf.parse(time1).getMinutes() % 10) == 0) {
+                    hashMap.put("time", time1);
+                    BigDecimal tAve = conversion("t_ave", row, rows);
+                    hashMap.put("tAve", tAve);
+                    CheckDataRecode.map.put("tAve" + "DeadDataStartTime", new DateTime(sdf.parse(time1)));
 
-                    BigDecimal wsAve = conversion("ws_Ave" + h, row, rows);
-                    hashMap.put("wsAve_" + h, wsAve);
-                    CheckDataRecode.map.put("wsAve_" + h + "DeadDataStartTime", new DateTime(sdf.parse(time1)));
+                    BigDecimal rhAve = conversion("rh_ave", row, rows);
+                    hashMap.put("rhAve", rhAve);
+                    CheckDataRecode.map.put("rhAve" + "DeadDataStartTime", new DateTime(sdf.parse(time1)));
+
+                    BigDecimal paAve = conversion("pa_ave", row, rows);
+                    hashMap.put("paAve", paAve);
+                    CheckDataRecode.map.put("paAve" + "DeadDataStartTime", new DateTime(sdf.parse(time1)));
+
+                    BigDecimal airDensity = BigDecimal.valueOf(1.293).multiply(new BigDecimal(273).divide(new BigDecimal(273).add(CalculationUtil.getBigDecimal(tAve)), 2, RoundingMode.HALF_UP)).multiply(CalculationUtil.getBigDecimal(paAve)).divide(new BigDecimal(1013), 2, RoundingMode.HALF_UP);
+                    hashMap.put("airDensity", airDensity);
+                    CheckDataRecode.map.put("airDensity" + "DeadDataStartTime", new DateTime(sdf.parse(time1)));
+
+                    for (Map.Entry<String, ArrayList<Double>> entry : wsStaMapList.entrySet()) {
 
-                    BigDecimal wdAve = conversion("wd_Ave" + h, row, rows);
-                    hashMap.put("wdAve_" + h, wdAve);
-                    CheckDataRecode.map.put("wdAve_" + h + "DeadDataStartTime", new DateTime(sdf.parse(time1)));
+                        BigDecimal wsAve = conversion("ws_Ave" + entry.getKey(), row, rows);
+                        hashMap.put("wsAve_" + entry.getKey(), wsAve);
+                        CheckDataRecode.map.put("wsAve_" + entry.getKey() + "DeadDataStartTime", new DateTime(sdf.parse(time1)));
 
+
+                        BigDecimal wdAve = conversion("wd_Ave" + entry.getKey(), row, rows);
+                        hashMap.put("wdAve_" + entry.getKey(), wdAve);
+                        CheckDataRecode.map.put("wdAve_" + entry.getKey() + "DeadDataStartTime", new DateTime(sdf.parse(time1)));
+
+                        hashMap.put("wsSta_" + entry.getKey(), CalculationUtil.calculateSD(entry.getValue()));
+                        CheckDataRecode.map.put("wsSta_" + entry.getKey() + "DeadDataStartTime", new DateTime(sdf.parse(time1)));
+                    }
+//                    if(firstBoolean){
+//                        firstMap = hashMap;
+//                        firstBoolean = false;
+//                    }
+                    mapList.add(hashMap);
+                    wsStaMapList = new HashMap<>();
                 }
-                mapList.add(hashMap);
             }
 
             //过滤数据
             List<Map<String, Object>> mapList1 = new CheckDataRecode().checkValue(mapList, "sld");
-
             windTowerDataParentTableService.packageData(mapList1, eqId, time1, "sld", "");
         } catch (Exception e) {
             e.printStackTrace();
@@ -1032,7 +1059,7 @@ public class AnalysisDataImpl {
                 if (file1.isDirectory()) {
                     File[] files1 = file1.listFiles();
                     //筛选包含.log后缀的文件
-                    List<File> fileNameList = Arrays.asList(files1).stream().filter(f ->  !f.isDirectory() &&  f.getName().substring(f.getName().lastIndexOf(".")).contains(".log")).collect(Collectors.toList());
+                    List<File> fileNameList = Arrays.asList(files1).stream().filter(f -> !f.isDirectory() && f.getName().substring(f.getName().lastIndexOf(".")).contains(".log")).collect(Collectors.toList());
                     //循环文件名
                     for (File fileNameForELog : fileNameList) {
                         String fileName = fileNameForELog.getName().substring(0, fileNameForELog.getName().indexOf(".log"));

+ 2 - 2
wrdep-biz/src/main/java/com/jiayue/biz/service/impl/EmailImpl.java

@@ -469,7 +469,7 @@ public class EmailImpl extends ServiceImpl<EmailMapper, Email> implements EmailS
     /**
      * 执行命令通过软件解压rld文件到D:\out\new\下
      */
-    public void systemCommand(String subject) {
+    public void systemCommand(String subjectId) {
         try {
             Runtime runtime = Runtime.getRuntime();
             File file = new File("D:\\in\\");
@@ -554,7 +554,7 @@ public class EmailImpl extends ServiceImpl<EmailMapper, Email> implements EmailS
                     //把txt文件转成excel文件并解析
                     analysisDataService.analysisData(type);
                 }else if(type.equals("csv")){
-                    String id = subject.substring(subject.indexOf("[") + 1, subject.lastIndexOf("]"));
+                    String id = subjectId.substring(subjectId.indexOf("[") + 1, subjectId.lastIndexOf("]"));
                     analysisDataService.acousticRadar(f,id);
 
 

+ 5 - 0
wrdep-biz/src/main/java/com/jiayue/biz/service/impl/HomePageServiceImpl.java

@@ -158,6 +158,11 @@ public class HomePageServiceImpl extends ServiceImpl<WindTowerDataParentTableMap
         Date yearDay = DateTimeUtil.getYearDay(lastDataCalculation.getTime().getTime());
         //获取去年月份开始时间
         Date beginTime = DateUtil.offsetMonth(DateUtil.beginOfMonth(yearDay), 1);
+        Map<String, Long> startAndEnd = prophaseWeatherDataService.getDataTimeStartAndEnd(equipmentId);
+
+        if(beginTime.getTime() < startAndEnd.get("startTime")){
+            beginTime = new Date(startAndEnd.get("startTime"));
+        }
         Date endTime = lastDataCalculation.getTime();
 
         List<EquipmentAttribute> equipmentAttributeList = equipmentAttributeService.lambdaQuery().likeLeft(EquipmentAttribute::getFieldName, "awsDay").list();

+ 13 - 15
wrdep-biz/src/main/java/com/jiayue/biz/service/impl/RealTimeDisplayServiceImpl.java

@@ -124,7 +124,7 @@ public class RealTimeDisplayServiceImpl implements RealTimeDisplayService {
 
             //拼接返回给前台
             for (Map.Entry<BigDecimal, BigDecimal> o1 : treeMap.entrySet()) {
-                if(o1.getKey().compareTo(BigDecimal.valueOf(15)) == 0){
+                if (o1.getKey().compareTo(BigDecimal.valueOf(15)) == 0) {
                     HashMap<String, Object> mapTi = new HashMap<>();
                     mapTi.put("heightTi", h);
                     mapTi.put("TurAveTi", o1.getValue());
@@ -708,28 +708,26 @@ public class RealTimeDisplayServiceImpl implements RealTimeDisplayService {
      */
     public List<Map<String, Object>> getWindShear(Long startTime, Long endTime, String eqId, String height, String heightMin) {
         List<ProphaseAnemometryData> anemometryData = prophaseAnemometryDataService.selectWdAveAndWdAveAndWsSta(eqId, new Timestamp(startTime), new Timestamp(endTime));
-//        String[] heights = windTowerInfoService.getByEquipmentNo(eqId).get(0).getHeights().split(",");
-//        ArrayList<String> heightAll = new ArrayList<>(Arrays.asList(heights));
-//        //获取最小层高
-//        List<Integer> collect = heightAll.stream().map(h -> {
-//            return Integer.parseInt(CalculationUtil.getNumberFromString(h));
-//        }).sorted().collect(Collectors.toList());
-//        String finalHeight = height;
-//        if (height.contains("A")) {
-//            finalHeight = height.substring(0, height.length() - 1);
-//        }
-
-
         BigDecimal zero = new BigDecimal(0);
         List<Map<String, Object>> list = new ArrayList<>();
+        //获取低层高风速所有数据
+        List<ProphaseAnemometryData> mixWindOrgList = anemometryData.stream().filter(a -> a.getLayerHeight().equals(heightMin)).collect(Collectors.toList());
         for (WindDirectionEnum value : WindDirectionEnum.values()) {
             Map<String, Object> map = new HashMap<>();
             List<ProphaseAnemometryData> heightAndWindDirectionEnum = CalculationUtil.getForHeightAndWindDirectionEnum(anemometryData, value);
+            //筛选出高层高风数据
+            List<ProphaseAnemometryData> maxWindList = heightAndWindDirectionEnum.stream().filter(val -> val.getLayerHeight().equals(height)).collect(Collectors.toList());
+            ArrayList<ProphaseAnemometryData> minWindList = new ArrayList<>();
+            //遍历获取同一时间点 低层高的数据
+            for (ProphaseAnemometryData wind : maxWindList) {
+                ProphaseAnemometryData prophaseAnemometryData = mixWindOrgList.stream().filter(m -> m.getTs().getTime() == wind.getTs().getTime()).collect(Collectors.toList()).get(0);
+                minWindList.add(prophaseAnemometryData);
 
+            }
             //获取平均风速
-            BigDecimal avgWindSpeed = CalculationUtil.getAvgWind(CalculationUtil.getWsForHeight(heightAndWindDirectionEnum, height));
+            BigDecimal avgWindSpeed = CalculationUtil.getAvgWind(CalculationUtil.getWsForHeight(maxWindList, height));
 
-            BigDecimal avgWindSpeed10 = CalculationUtil.getAvgWind(CalculationUtil.getWsForHeight(heightAndWindDirectionEnum, heightMin));
+            BigDecimal avgWindSpeed10 = CalculationUtil.getAvgWind(CalculationUtil.getWsForHeight(minWindList, heightMin));
             BigDecimal bigDecimal = new BigDecimal(-99);
             if (avgWindSpeed10.compareTo(BigDecimal.ZERO) != 0) {
                 bigDecimal = CalculationUtil.caWindShear(avgWindSpeed, avgWindSpeed10, new BigDecimal(height), new BigDecimal(heightMin));

+ 19 - 10
wrdep-biz/src/main/java/com/jiayue/biz/service/impl/WindTowerInfoServiceImpl.java

@@ -50,10 +50,11 @@ public class WindTowerInfoServiceImpl extends ServiceImpl<WindTowerInfoMapper, W
 
     //获取所有测风塔信息
     public List<WindTowerInfo> getAllWindTower(){
-        if(redisCache.getCacheObject("getAllWindTower") == null){
-            redisCache.setCacheObject("getAllWindTower",this.list(),24, TimeUnit.HOURS);
-        }
-        return redisCache.getCacheObject("getAllWindTower");
+//        if(redisCache.getCacheObject("getAllWindTower") == null){
+//            redisCache.setCacheObject("getAllWindTower",this.list(),24, TimeUnit.HOURS);
+//        }
+//        redisCache.getCacheObject("getAllWindTower");
+        return this.list();
     }
 
     /**
@@ -65,10 +66,18 @@ public class WindTowerInfoServiceImpl extends ServiceImpl<WindTowerInfoMapper, W
     public boolean saveWindTowerInfo(WindTowerInfo windTowerInfo) {
         baseMapper.createCalculationTable("wind_tower_calculation_data_" + windTowerInfo.getEquipmentNo());
         boolean save = this.save(windTowerInfo);
-        redisCache.setCacheObject("getAllWindTower",this.list(),24, TimeUnit.HOURS);
+//        redisCache.setCacheObject("getAllWindTower",this.list(),24, TimeUnit.HOURS);
         return save;
     }
 
+
+    public boolean update(WindTowerInfo windTowerInfo){
+        boolean b = this.updateById(windTowerInfo);
+//        redisCache.setCacheObject("getAllWindTower",this.list(),24, TimeUnit.HOURS);
+
+        return b;
+    }
+
     /**
      * 删除塔时删除表
      *
@@ -81,7 +90,7 @@ public class WindTowerInfoServiceImpl extends ServiceImpl<WindTowerInfoMapper, W
             baseMapper.deleteCalculationTable("wind_tower_calculation_data_" + w.getEquipmentNo());
         }
         boolean b = this.removeByIds(ids);
-        redisCache.setCacheObject("getAllWindTower",this.list(),24, TimeUnit.HOURS);
+//        redisCache.setCacheObject("getAllWindTower",this.list(),24, TimeUnit.HOURS);
         return b;
     }
 
@@ -120,9 +129,9 @@ public class WindTowerInfoServiceImpl extends ServiceImpl<WindTowerInfoMapper, W
     }
 
     public List<Map<String, String>> listEquipmentIdAndDataTime() {
-        if (redisCache.getCacheObject("listEquipmentIdAndDataTime") != null) {
-            return redisCache.getCacheObject("listEquipmentIdAndDataTime");
-        }
+//        if (redisCache.getCacheObject("listEquipmentIdAndDataTime") != null) {
+//            return redisCache.getCacheObject("listEquipmentIdAndDataTime");
+//        }
         //TODO韩雪峰  新建的塔没有统计概述的时候无法显示  需要考虑到这种情况
         List<WindTowerInfo> windTowerInfoList = this.list();
         List<StatisticsSituation> statisticsSituationList = statisticsSituationService.list();
@@ -175,7 +184,7 @@ public class WindTowerInfoServiceImpl extends ServiceImpl<WindTowerInfoMapper, W
             }
         }
         mapList.addAll(statusMapList);
-        redisCache.setCacheObject("listEquipmentIdAndDataTime", mapList, 12, TimeUnit.HOURS);
+//        redisCache.setCacheObject("listEquipmentIdAndDataTime", mapList, 12, TimeUnit.HOURS);
         return mapList;
     }
 

+ 35 - 0
wrdep-biz/src/main/java/com/jiayue/biz/util/CalculationUtil.java

@@ -54,6 +54,7 @@ public class CalculationUtil {
     }
 
 
+
     /**
      * 根据层高获取风速数据 todo 旧
      *
@@ -427,4 +428,38 @@ public class CalculationUtil {
 
     }
 
+    public static void main(String[] args) {
+        Double[] doubles = {0.97,1.01,0.97,1.23,1.23,1.23,1.23,1.38,1.38,1.54};
+
+        List<Double> list = Arrays.asList(doubles);
+
+        BigDecimal v = calculateSD(list);
+        System.out.println("v = " + v);
+    }
+
+
+    /**
+     * 计算标差
+     * @param numArray 数据数组
+     * @return 标差
+     */
+    public static BigDecimal calculateSD(List<Double> numArray) {
+        double sum = 0.0, standardDeviation = 0.0;
+        int length = numArray.size();
+        if(length == 0){
+            return BigDecimal.ZERO;
+        }
+        for(double num : numArray) {
+            sum += num;
+        }
+
+        double mean = sum/length;
+
+        for(double num: numArray) {
+            standardDeviation += Math.pow(num - mean, 2);
+        }
+
+        return BigDecimal.valueOf(Math.sqrt(standardDeviation/length)).setScale(2, RoundingMode.HALF_UP);
+    }
+
 }

+ 1 - 1
wrdep-biz/src/main/resources/mapper/dataQuery/WindTowerInfoMapper.xml

@@ -70,7 +70,7 @@
     </update>
     <!--建塔时新建该塔对应的数据统计表-->
     <update id="createCalculationTable" parameterType="string">
-        CREATE TABLE ${calculationTableName}
+        CREATE TABLE IF NOT EXISTS ${calculationTableName}
         (
             `id`           varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键ID',
             `equipment_id` varchar(64)                                            NOT NULL COMMENT '父表ID',

+ 6 - 0
wrdep-ui/src/api/biz/dataQuery/defaultOption.js

@@ -1092,6 +1092,8 @@ export default {
     {value: '150A', label: '150Am'},
     {value: '140', label: '140m'},
     {value: '140A', label: '140Am'},
+    {value: '130', label: '130m'},
+    {value: '130A', label: '130Am'},
     {value: '120', label: '120m'},
     {value: '120A', label: '120Am'},
     {value: '110', label: '110m'},
@@ -1108,8 +1110,12 @@ export default {
     {value: '60A', label: '60Am'},
     {value: '50', label: '50m'},
     {value: '50A', label: '50Am'},
+    {value: '40', label: '40m'},
+    {value: '40A', label: '40Am'},
     {value: '30', label: '30m'},
     {value: '30A', label: '30Am'},
+    {value: '20', label: '20m'},
+    {value: '20A', label: '20Am'},
     {value: '10', label: '10m'},
     {value: '10A', label: '10Am'}
   ]