Kaynağa Gözat

1、数据入库时 数据分别存放org表以及筛选之后的表
2、修改因数据筛选之后统计数据异常问题
3、修改基础数据(风速、环境数据 展示未筛选的数据)查询逻辑

hxf 2 yıl önce
ebeveyn
işleme
a3a078da1e
17 değiştirilmiş dosya ile 388 ekleme ve 184 silme
  1. 8 14
      neim-biz/src/main/java/com/jiayue/biz/job/FileAnalysisJob.java
  2. 10 0
      neim-biz/src/main/java/com/jiayue/biz/mapper/ProphaseAnemometryDataOrgMapper.java
  3. 12 0
      neim-biz/src/main/java/com/jiayue/biz/mapper/ProphaseWeatherDataOrgMapper.java
  4. 19 0
      neim-biz/src/main/java/com/jiayue/biz/service/ProphaseAnemometryDataOrgService.java
  5. 19 0
      neim-biz/src/main/java/com/jiayue/biz/service/ProphaseWeatherDataOrgService.java
  6. 1 0
      neim-biz/src/main/java/com/jiayue/biz/service/ProphaseWeatherDataService.java
  7. 8 3
      neim-biz/src/main/java/com/jiayue/biz/service/impl/AnalysisDataImpl.java
  8. 78 7
      neim-biz/src/main/java/com/jiayue/biz/service/impl/CheckDataRecode.java
  9. 3 13
      neim-biz/src/main/java/com/jiayue/biz/service/impl/DataRecalculationImpl.java
  10. 28 0
      neim-biz/src/main/java/com/jiayue/biz/service/impl/ProphaseAnemometryDataOrgServiceImpl.java
  11. 32 0
      neim-biz/src/main/java/com/jiayue/biz/service/impl/ProphaseWeatherDataOrgServiceImpl.java
  12. 5 0
      neim-biz/src/main/java/com/jiayue/biz/service/impl/ProphaseWeatherDataServiceImpl.java
  13. 13 5
      neim-biz/src/main/java/com/jiayue/biz/service/impl/RealTimeDisplayServiceImpl.java
  14. 5 5
      neim-biz/src/main/java/com/jiayue/biz/service/impl/WindDirectionStatisticsDataServiceImpl.java
  15. 41 36
      neim-biz/src/main/java/com/jiayue/biz/service/impl/WindTowerCalculationDataServiceImpl.java
  16. 105 100
      neim-biz/src/main/java/com/jiayue/biz/service/impl/WindTowerDataParentTableServiceImpl.java
  17. 1 1
      neim-biz/src/main/java/com/jiayue/biz/util/CalculationUtil.java

+ 8 - 14
neim-biz/src/main/java/com/jiayue/biz/job/FileAnalysisJob.java

@@ -1,29 +1,17 @@
 package com.jiayue.biz.job;
 
-import cn.hutool.core.collection.ListUtil;
-import cn.hutool.core.date.DateUtil;
-import com.jiayue.biz.domain.ProphaseAnemometryData;
-import com.jiayue.biz.domain.ProphaseWeatherData;
-import com.jiayue.biz.domain.WindTowerInfo;
-import com.jiayue.biz.mapper.ProphaseAnemometryDataMapper;
-import com.jiayue.biz.mapper.ProphaseWeatherDataMapper;
+
 import com.jiayue.biz.service.ProphaseAnemometryDataService;
 import com.jiayue.biz.service.ProphaseWeatherDataService;
-import com.jiayue.biz.service.WindTowerDataParentTableService;
 import com.jiayue.biz.service.WindTowerInfoService;
 import com.jiayue.biz.service.impl.AnalysisDataImpl;
 import com.jiayue.biz.service.impl.EmailImpl;
-import com.jiayue.biz.util.CalculationUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 
-import java.math.RoundingMode;
-import java.sql.Timestamp;
-import java.util.*;
-import java.util.stream.Collectors;
 
 /**
  * 定时扫描系统邮件并解析
@@ -84,7 +72,13 @@ public class FileAnalysisJob {
         log.debug("eol文件解析定时任务执行完成");
 
     }
-//    @Scheduled(fixedDelay = 60000 * 6000)
+
+    @Scheduled(cron = "0 51 16 13 6 ?")
+    public void cronOne(){
+        System.out.println("xxxxxxxxxx = ");
+
+
+    }
 
 
 

+ 10 - 0
neim-biz/src/main/java/com/jiayue/biz/mapper/ProphaseAnemometryDataOrgMapper.java

@@ -6,6 +6,11 @@ import com.jiayue.biz.domain.ProphaseAnemometryData;
 import com.jiayue.biz.domain.ProphaseAnemometryDataOrg;
 import org.apache.ibatis.annotations.Insert;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+import java.sql.Timestamp;
+import java.util.List;
 
 @DS("tdengine")
 public interface ProphaseAnemometryDataOrgMapper extends BaseMapper<ProphaseAnemometryDataOrg> {
@@ -13,4 +18,9 @@ public interface ProphaseAnemometryDataOrgMapper extends BaseMapper<ProphaseAnem
     @Insert("INSERT INTO anemometry_org_${equipmentId}_${layerHeight} USING prophase_anemometry_data_org TAGS(#{equipmentId}, #{layerHeight}) VALUES(#{ts}, #{wsInst}, #{wsMax}, #{wsMin}, #{wsAve}, #{wsGust}, #{wsSta}, #{wdInst}, #{wdMax}, #{wdMin}, #{wdAve}, #{wdSta})")
     int insertOneWithNew(ProphaseAnemometryData one);
 
+
+    //所有层高风速风向平均值
+    @Select("SELECT t1.ts,t1.ws_ave,t1.wd_ave,t1.layer_height FROM prophase_anemometry_data_org t1 where  t1.equipment_id = #{equipmentId} and  t1.ts >= #{startTime} and t1.ts <= #{endTime}")
+    List<ProphaseAnemometryData> selectAve(@Param("equipmentId") String equipmentId, @Param("startTime") Timestamp startTime, @Param("endTime") Timestamp endTime);
+
 }

+ 12 - 0
neim-biz/src/main/java/com/jiayue/biz/mapper/ProphaseWeatherDataOrgMapper.java

@@ -7,7 +7,9 @@ import com.jiayue.biz.domain.ProphaseWeatherDataOrg;
 import org.apache.ibatis.annotations.Insert;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
 
+import java.sql.Timestamp;
 import java.util.List;
 
 @DS("tdengine")
@@ -21,4 +23,14 @@ public interface ProphaseWeatherDataOrgMapper extends BaseMapper<ProphaseWeather
             "</script>")
     int insertSplice(@Param("prophaseWeatherDataList") List<ProphaseWeatherData> prophaseWeatherDataList, @Param("equipmentId") String equipmentId);
 
+
+    //查询温度平均值和压强平均值
+    @Select("SELECT t1.ts,t1.t_ave,t1.pa_ave,t1.air_density FROM weather_org_${equipmentId} t1 where  t1.ts >= #{startTime} and t1.ts <= #{endTime}")
+    List<ProphaseWeatherData> selectTAveAndPaAveAndAir(@Param("equipmentId") String equipmentId, @Param("startTime") Timestamp startTime, @Param("endTime") Timestamp endTime);  //查询温度平均值和压强平均值
+
+    @Insert("INSERT INTO weather_org_${equipmentId} USING prophase_weather_data TAGS(#{equipmentId}) VALUES(#{ts},#{tInst},#{tMax},#{tMin},#{tAve},#{tSta},#{rhInst},#{rhMax},#{rhMin},#{rhAve},#{rhSta},#{paInst},#{paMax},#{paMin},#{paAve},#{paSta},#{airDensity})")
+    int insertOneWithNew(ProphaseWeatherData one);
+
+
+
 }

+ 19 - 0
neim-biz/src/main/java/com/jiayue/biz/service/ProphaseAnemometryDataOrgService.java

@@ -0,0 +1,19 @@
+package com.jiayue.biz.service;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.jiayue.biz.domain.ProphaseAnemometryData;
+import com.jiayue.biz.domain.ProphaseAnemometryDataOrg;
+
+import java.sql.Timestamp;
+import java.util.List;
+
+public interface ProphaseAnemometryDataOrgService extends IService<ProphaseAnemometryDataOrg> {
+
+
+    List<ProphaseAnemometryData> selectAveWsAndWd(String equipmentId, Timestamp startTime, Timestamp endTime);
+
+    //单条保存
+    void insertOneWithNew(ProphaseAnemometryData prophaseAnemometryData);
+
+}

+ 19 - 0
neim-biz/src/main/java/com/jiayue/biz/service/ProphaseWeatherDataOrgService.java

@@ -0,0 +1,19 @@
+package com.jiayue.biz.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.jiayue.biz.domain.ProphaseWeatherData;
+import com.jiayue.biz.domain.ProphaseWeatherDataOrg;
+
+import java.sql.Timestamp;
+import java.util.List;
+
+public interface ProphaseWeatherDataOrgService extends IService<ProphaseWeatherDataOrg> {
+    List<ProphaseWeatherData> selectTAveAndPaAveAndAir(String equipmentId, Timestamp startTime, Timestamp endTime);
+
+    //批量保存
+    void insertSplice(List<ProphaseWeatherData> prophaseWeatherDataList,String equipmentId);
+
+
+    void insertOne(ProphaseWeatherData prophaseWeatherData);
+
+}

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

@@ -42,5 +42,6 @@ public interface ProphaseWeatherDataService extends IService<ProphaseWeatherData
 
     //删除时间段内数据
     void deleteData(String equipmentId, Timestamp startTime, Timestamp endTime);
+    void insertOne(ProphaseWeatherData prophaseWeatherData);
 
 }

+ 8 - 3
neim-biz/src/main/java/com/jiayue/biz/service/impl/AnalysisDataImpl.java

@@ -182,6 +182,9 @@ public class AnalysisDataImpl {
                     str = valueString;
                 }
                 if (valueString.contains("Height")) {
+//                    if(valueString.contains(".")){
+//                        valueString = valueString.substring(0,valueString.indexOf("."));
+//                    }
                     String height = getNumberFromString(valueString);
                     for (Map.Entry<String, String> p : CHMap.entrySet()) {
                         if (p.getKey().equals(CH)) {
@@ -220,6 +223,8 @@ public class AnalysisDataImpl {
                     String split = s[2].substring(0, 2);
                     latitude = s[1] + " " + split;
                     latitude = CoordinateUtil.changeToDu(latitude);
+
+
                 }
                 if (valueString.contains("Longitude")) {
                     //经度
@@ -228,6 +233,7 @@ public class AnalysisDataImpl {
                     String split = s[2].substring(0, 2);
                     longitude = s[1] + " " + split;
                     longitude = CoordinateUtil.changeToDu(longitude);
+
                 }
                 if (valueString.contains("Serial #")) {
                     //记录仪编号
@@ -1021,7 +1027,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"));
@@ -1050,7 +1056,6 @@ public class AnalysisDataImpl {
     }
 
 
-
     //解析eol文件
     public void parseEol(File fileCsv, HashMap<String, String> stringStringHashMap, String eqNo, File fileNameForELog) {
         //todo 需要修改
@@ -1112,7 +1117,7 @@ public class AnalysisDataImpl {
                 windTowerInfo.setRecorderNo(stringStringHashMap.get("SiteNumber"));
                 windTowerInfo.setModelNumber("eol");
                 windTowerInfoService.saveOrUpdate(windTowerInfo);
-            }else{
+            } else {
                 try {
                     //移动原始文件
                     com.jiayue.biz.util.FileUtil.move(fileNameForELog.getPath(), eolFilePath + File.separator + eqNo);

+ 78 - 7
neim-biz/src/main/java/com/jiayue/biz/service/impl/CheckDataRecode.java

@@ -11,6 +11,7 @@ import java.math.BigDecimal;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 为审核数据的合理性提供历史数据
@@ -93,7 +94,7 @@ public class CheckDataRecode {
                         int min;
                         int change;
                         if (key.contains("Sta") || key.contains("sta")) {
-                            max = 3;
+                            max = 6;
                             min = 0;
                             change = 1;
                         } else {
@@ -114,7 +115,7 @@ public class CheckDataRecode {
                         int min;
                         int change;
                         if (key.contains("Sta") || key.contains("sta")) {
-                            max = 3;
+                            max = 6;
                             min = 0;
                             change = 1;
                         } else {
@@ -135,7 +136,7 @@ public class CheckDataRecode {
                         int min;
                         int change;
                         if (key.contains("Sta") || key.contains("sta")) {
-                            max = 3;
+                            max = 6;
                             min = 0;
                             change = 1;
                         } else {
@@ -161,7 +162,8 @@ public class CheckDataRecode {
                 }
                 filterData.add(map);
             }
-
+        Map<String, Object> startTimeAndEndTimeMap = map.entrySet().stream().filter(k -> k.getKey().contains("DeadDataStartTimeAndEndTime")).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
+        compareData(startTimeAndEndTimeMap, filterData,simpleDateFormat);
         } catch (Exception e) {
             log.error("数据筛选异常" + e);
             e.printStackTrace();
@@ -169,6 +171,38 @@ public class CheckDataRecode {
         return filterData;
     }
 
+
+    public void compareData(Map<String, Object> startTimeAndEndTimeMap, List<Map<String, Object>> filterData,SimpleDateFormat simpleDateFormat) throws ParseException {
+        for (Map<String, Object> filterDatum : filterData) {
+            for (Map.Entry<String, Object> entry : startTimeAndEndTimeMap.entrySet()) {
+                //获取异常数据字段名
+                String dataName = entry.getKey().replace("DeadDataStartTimeAndEndTime", "");
+                //是否存在多时间段异常数据
+                if (entry.getValue().toString().contains(",")) {
+                    String[] startTimeAndEndTime = entry.getValue().toString().split(",");
+                    for (String time : startTimeAndEndTime) {
+                        //保存异常值
+                        replaceData(time, filterDatum, dataName, simpleDateFormat);
+                    }
+                } else {
+                    replaceData(entry.getValue().toString(), filterDatum, dataName, simpleDateFormat);
+                }
+            }
+        }
+    }
+
+
+    public void replaceData(String value, Map<String, Object> filterDatum, String dataName,SimpleDateFormat simpleDateFormat) throws ParseException {
+        String[] startTimeAndEndTimeSp = value.split("-");
+        //在时间段内 并且没有此字段名
+        if (simpleDateFormat.parse(filterDatum.get("time").toString()).getTime() >= Long.parseLong(startTimeAndEndTimeSp[0]) && simpleDateFormat.parse(filterDatum.get("time").toString()).getTime() <= Long.parseLong(startTimeAndEndTimeSp[1])) {
+            if (filterDatum.get("abnormalType") != null && !filterDatum.get("abnormalType").toString().contains(dataName)) {
+                filterDatum.put("abnormalType", filterDatum.get("abnormalType") + "," + dataName);
+            }
+        }
+    }
+
+
     public String check(Object object, Integer max, Integer min, Integer change, String name, Long time) {
         String s = "";
         if (null != object) {
@@ -199,7 +233,7 @@ public class CheckDataRecode {
         }
         map.putIfAbsent(name + "OriginalVal", val);
         map.putIfAbsent(name + "Time", new DateTime(time));
-        map.putIfAbsent(name + "DeadDataStartTime", new DateTime(time));
+        map.putIfAbsent(name + "DeadDataStartTime", new DateTime(time));//设置区分死值的时间
     }
 
     /**
@@ -236,7 +270,7 @@ public class CheckDataRecode {
             if (isLowerMin(name, value, min)) {
                 return FakeDataRecord.IrrationalDataType.LowerMin;
             }
-            if (isDeadVal(name, value, time)) {
+            if (isDeadValForWeather(name, value, time)) {
                 return FakeDataRecord.IrrationalDataType.DeadVal;
             }
             if (isSuddenChange(name, value, change)) {
@@ -290,7 +324,41 @@ public class CheckDataRecode {
         if (map.get(name + "OriginalVal") != null && map.get(name + "OriginalVal").equals(value)) {
             String ddst = map.get(name + "DeadDataStartTime").toString();
             //如果死值数据开始时间不为空  并且  死值开始时间和传入的时间差距大于四小时
-            if (!"".equals(ddst) && Minutes.minutesBetween(new DateTime(ddst), dateTime).getMinutes() > 240) {
+            if (!"".equals(ddst) && Minutes.minutesBetween(new DateTime(ddst), dateTime).getMinutes() >= 240) {
+                //获取死值起止时间根据name区分 可能有多个区间段 用-分割 放入map 最终筛选数据再赋值异常数据
+                if (map.get(name + "DeadDataStartTimeAndEndTime") == null) {
+                    map.put(name + "DeadDataStartTimeAndEndTime", new DateTime(ddst).getMillis() + "-" + time);
+                } else {
+                    String[] deadDataStartTimeAndEndTime = map.get(name + "DeadDataStartTimeAndEndTime").toString().split("-");
+                    if (deadDataStartTimeAndEndTime[0].equals(String.valueOf(new DateTime(ddst).getMillis()))) {
+                        map.put(name + "DeadDataStartTimeAndEndTime", new DateTime(ddst).getMillis() + "-" + time);
+                    } else {
+                        map.put(name + "DeadDataStartTimeAndEndTime", map.get(name + "DeadDataStartTimeAndEndTime") + "," + new DateTime(ddst).getMillis() + "-" + time);
+                    }
+                }
+                log.warn("{}数据死值,数值为{},开始时间为{}", name, value, new DateTime(ddst).toString("HH:mm:ss"));
+                flag = true;
+            }
+        } else {
+            map.put(name + "DeadDataStartTime", dateTime);
+        }
+        return flag;
+    }
+
+    /**
+     * 数据是否是死数据
+     *
+     * @param value 传入值
+     * @return 是否是死值
+     */
+    private boolean isDeadValForWeather(String name, BigDecimal value, Long time) {
+        DateTime dateTime = new DateTime(time);
+        boolean flag = false;
+        //上个合理值不等于空并且上个合理值和传入值相等
+        if (map.get(name + "OriginalVal") != null && map.get(name + "OriginalVal").equals(value)) {
+            String ddst = map.get(name + "DeadDataStartTime").toString();
+            //如果死值数据开始时间不为空  并且  死值开始时间和传入的时间差距大于六小时
+            if (!"".equals(ddst) && Minutes.minutesBetween(new DateTime(ddst), dateTime).getMinutes() > 300) {
                 log.warn("{}数据死值,数值为{},开始时间为{}", name, value, new DateTime(ddst).toString("HH:mm:ss"));
                 flag = true;
             }
@@ -300,6 +368,7 @@ public class CheckDataRecode {
         return flag;
     }
 
+
     /**
      * 数据是否为突变数据
      *
@@ -314,4 +383,6 @@ public class CheckDataRecode {
             return false;
         }
     }
+
+
 }

+ 3 - 13
neim-biz/src/main/java/com/jiayue/biz/service/impl/DataRecalculationImpl.java

@@ -560,9 +560,9 @@ public class DataRecalculationImpl implements DataRecalculationService {
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
         //所有数据
         List<Map<String, Object>> maps = windTowerDataParentTableService.selectDataByBetweenTimeAndEquipmetId(startTime, endTime, equipmentNo);
+        List<WindTowerInfo> list = windTowerInfoService.lambdaQuery().eq(WindTowerInfo::getEquipmentNo, equipmentNo).list();
         CheckDataRecode checkDataRecode = new CheckDataRecode();
         checkDataRecode.map.clear();
-        List<String> parentIdList = new ArrayList<>();
         try {
             if (!maps.isEmpty()) {
                 long startDate = Long.parseLong(maps.get(0).get("time").toString());
@@ -580,20 +580,10 @@ public class DataRecalculationImpl implements DataRecalculationService {
                         endDate = Long.parseLong(map.get("time").toString());
                     }
                 }
-                //如果存在数据先删除
-                if (!maps.isEmpty()) {
-                    for (Map<String, Object> map : maps) {
-                        if (!map.get("id").toString().isEmpty()) {
-                            parentIdList.add(map.get("id").toString());
-                        }
-                    }
-                    windTowerDataChildTableService.deleteBetweenTimeAndEquipmentIdAndChild(parentIdList, equipmentNo);
-                    windTowerDataParentTableService.deleteBetweenTimeAndEquipmentIdAndParent(DateTimeUtil.getDayStartTime(startDate), DateTimeUtil.getDayLastTime(endDate), equipmentNo);
-                }
                 log.info("正在进行数据过滤");
                 //重新走一遍数据过滤 然后存库
-                List<Map<String, Object>> mapList = new CheckDataRecode().checkValue(maps, "rld");
-                windTowerDataParentTableService.packageData(mapList, equipmentNo, sdf.format(new Date(startDate)), "rld", "DataRecalculation");
+                List<Map<String, Object>> mapList = new CheckDataRecode().checkValue(maps, list.get(0).getModelNumber());
+                windTowerDataParentTableService.packageData(mapList, equipmentNo, sdf.format(new Date(startDate)), list.get(0).getModelNumber(), "DataRecalculation");
                 return AjaxResult.success("数据筛选完成");
             } else {
                 return AjaxResult.success("该时间范围内没有数据");

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

@@ -0,0 +1,28 @@
+package com.jiayue.biz.service.impl;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.jiayue.biz.domain.ProphaseAnemometryData;
+import com.jiayue.biz.domain.ProphaseAnemometryDataOrg;
+import com.jiayue.biz.mapper.ProphaseAnemometryDataOrgMapper;
+import com.jiayue.biz.service.ProphaseAnemometryDataOrgService;
+import org.springframework.stereotype.Service;
+
+import java.sql.Timestamp;
+import java.util.List;
+
+@Service
+public class ProphaseAnemometryDataOrgServiceImpl extends ServiceImpl<ProphaseAnemometryDataOrgMapper, ProphaseAnemometryDataOrg> implements ProphaseAnemometryDataOrgService {
+
+    //所有层高风速风向平均值
+    public List<ProphaseAnemometryData> selectAveWsAndWd(String equipmentId, Timestamp startTime, Timestamp endTime) {
+        return baseMapper.selectAve(equipmentId, startTime, endTime);
+    }
+
+    //单条保存
+    public void insertOneWithNew(ProphaseAnemometryData prophaseAnemometryData){
+        baseMapper.insertOneWithNew(prophaseAnemometryData);
+    }
+
+
+}

+ 32 - 0
neim-biz/src/main/java/com/jiayue/biz/service/impl/ProphaseWeatherDataOrgServiceImpl.java

@@ -0,0 +1,32 @@
+package com.jiayue.biz.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.jiayue.biz.domain.ProphaseWeatherData;
+import com.jiayue.biz.domain.ProphaseWeatherDataOrg;
+import com.jiayue.biz.mapper.ProphaseWeatherDataOrgMapper;
+import com.jiayue.biz.service.ProphaseWeatherDataOrgService;
+import org.springframework.stereotype.Service;
+
+import java.sql.Timestamp;
+import java.util.List;
+
+@Service
+public class ProphaseWeatherDataOrgServiceImpl extends ServiceImpl<ProphaseWeatherDataOrgMapper, ProphaseWeatherDataOrg> implements ProphaseWeatherDataOrgService {
+
+    //查询温度平均值、压强平均值、空气密度
+    public List<ProphaseWeatherData> selectTAveAndPaAveAndAir(String equipmentId, Timestamp startTime, Timestamp endTime){
+        return baseMapper.selectTAveAndPaAveAndAir(equipmentId,startTime,endTime);
+    }
+
+    //批量保存
+    public void insertSplice(List<ProphaseWeatherData> prophaseWeatherDataList,String equipmentId){
+        baseMapper.insertSplice(prophaseWeatherDataList,equipmentId);
+    }
+
+    public void insertOne(ProphaseWeatherData prophaseWeatherData){
+        baseMapper.insertOneWithNew(prophaseWeatherData);
+    }
+
+
+
+}

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

@@ -78,5 +78,10 @@ public class ProphaseWeatherDataServiceImpl extends ServiceImpl<ProphaseWeatherD
         baseMapper.deleteData(equipmentId, startTime, endTime);
     }
 
+    public void insertOne(ProphaseWeatherData prophaseWeatherData){
+        baseMapper.insertOneWithNew(prophaseWeatherData);
+    }
+
+
 
 }

+ 13 - 5
neim-biz/src/main/java/com/jiayue/biz/service/impl/RealTimeDisplayServiceImpl.java

@@ -37,8 +37,10 @@ public class RealTimeDisplayServiceImpl implements RealTimeDisplayService {
     private StatisticsSituationService statisticsSituationService;
 
     private ProphaseAnemometryDataService prophaseAnemometryDataService;
+    private ProphaseAnemometryDataOrgService prophaseAnemometryDataOrgService;
 
     private ProphaseWeatherDataService prophaseWeatherDataService;
+    private ProphaseWeatherDataOrgService prophaseWeatherDataOrgService;
 
     private final double e = 2.71828183;
 
@@ -189,7 +191,7 @@ public class RealTimeDisplayServiceImpl implements RealTimeDisplayService {
             timeList.add(sdf.format(new Date(i)));
         }
         // 测风塔数据集合
-        List<ProphaseAnemometryData> prophaseAnemometryDataList = prophaseAnemometryDataService.selectAve(equipmentId, new Timestamp(startTime), new Timestamp(endTime));
+        List<ProphaseAnemometryData> prophaseAnemometryDataList = prophaseAnemometryDataOrgService.selectAveWsAndWd(equipmentId, new Timestamp(startTime), new Timestamp(endTime));
         List<WindTowerInfo> windTowerInfoList = windTowerInfoService.lambdaQuery().eq(WindTowerInfo::getEquipmentNo, equipmentId).list();
         String[] wdHeight = windTowerInfoList.get(0).getWdHeights().split(",");
         if (height == null || height.equals("")) {
@@ -409,7 +411,7 @@ public class RealTimeDisplayServiceImpl implements RealTimeDisplayService {
         List paList = new ArrayList();
         List timeList = new ArrayList();
         //所有数据
-        List<ProphaseWeatherData> prophaseWeatherDataList = prophaseWeatherDataService.selectTAveAndPaAveAndAir(equipmentId, new Timestamp(startTime), new Timestamp(endTime));
+        List<ProphaseWeatherData> prophaseWeatherDataList = prophaseWeatherDataOrgService.selectTAveAndPaAveAndAir(equipmentId, new Timestamp(startTime), new Timestamp(endTime));
         if (prophaseWeatherDataList.size() > 0) {
 
             SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -445,9 +447,15 @@ public class RealTimeDisplayServiceImpl implements RealTimeDisplayService {
                 /*表格数据*/
                 Map<String, Object> dataMap = new HashMap<>();
                 dataMap.put("time", formatter.format(p.getTs()));
-                dataMap.put("t", BigDecimal.valueOf(p.getTAve()).setScale(2, RoundingMode.HALF_UP));
-                dataMap.put("pa", BigDecimal.valueOf(p.getPaAve()).setScale(2, RoundingMode.HALF_UP));
-                dataMap.put("airDensity", BigDecimal.valueOf(p.getAirDensity()).setScale(2, RoundingMode.HALF_UP));
+                if (p.getTAve() != null) {
+                    dataMap.put("t", CalculationUtil.getBigDecimal(p.getTAve()).setScale(2, RoundingMode.HALF_UP));
+                }
+                if (p.getPaAve() != null) {
+                    dataMap.put("pa", CalculationUtil.getBigDecimal(p.getPaAve()).setScale(2, RoundingMode.HALF_UP));
+                }
+                if (p.getAirDensity() != null) {
+                    dataMap.put("airDensity", CalculationUtil.getBigDecimal(p.getAirDensity()).setScale(2, RoundingMode.HALF_UP));
+                }
                 dataList.add(dataMap);
             }
             /*计算平均值*/

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

@@ -102,7 +102,7 @@ public class WindDirectionStatisticsDataServiceImpl extends ServiceImpl<WindDire
             ArrayList<WindDirectionStatisticsData> wdRose = wdRose(startTime, endTime, equipmentId, anemometryDataList, equipmentAttributeList, heights);
             list.addAll(wdRose);
             //风功率玫瑰图
-            ArrayList<WindDirectionStatisticsData> powerRose = powerRose(startTime, endTime, equipmentId, anemometryDataList, prophaseWeatherDataList, equipmentAttributeList, heights);
+            ArrayList<WindDirectionStatisticsData> powerRose = powerRose(startTime, endTime, equipmentId, anemometryDataList, weatherDataList, equipmentAttributeList, heights);
             list.addAll(powerRose);
             //湍流玫瑰图
             ArrayList<WindDirectionStatisticsData> turRose = turRose(startTime, endTime, equipmentId, anemometryDataList, equipmentAttributeList, heights);
@@ -210,7 +210,7 @@ public class WindDirectionStatisticsDataServiceImpl extends ServiceImpl<WindDire
 
                     if (!heightAndWindDirectionEnum.isEmpty()) {
                         //获取指定层高风速数据
-                        List<BigDecimal> wsForHeight = heightAndWindDirectionEnum.stream().filter(h -> h.getWsAve() != null && h.getWsAve() != 0).map((ProphaseAnemometryData p) ->
+                        List<BigDecimal> wsForHeight = heightAndWindDirectionEnum.stream().filter(h -> h.getWsAve() != null && h.getWsAve() != 0 && h.getWsAve() != -99).map((ProphaseAnemometryData p) ->
                                 {
                                     return CalculationUtil.getBigDecimal(p.getWsAve());
                                 }
@@ -221,7 +221,7 @@ public class WindDirectionStatisticsDataServiceImpl extends ServiceImpl<WindDire
                         //平均风速
                         BigDecimal avgWindSpeed = CalculationUtil.getAvgWind(wsForHeight);
                         //获取指定层高标差数据集合
-                        List<BigDecimal> staForHeight = heightAndWindDirectionEnum.stream().filter(h -> h.getWsSta() != null && h.getWsSta() != 0).map((ProphaseAnemometryData p) ->
+                        List<BigDecimal> staForHeight = heightAndWindDirectionEnum.stream().filter(h -> h.getWsSta() != null && h.getWsSta() != 0 && h.getWsSta() != -99).map((ProphaseAnemometryData p) ->
                                 {
                                     return CalculationUtil.getBigDecimal(p.getWsSta());
                                 }
@@ -286,7 +286,7 @@ public class WindDirectionStatisticsDataServiceImpl extends ServiceImpl<WindDire
                     List<ProphaseAnemometryData> heightAndWindDirectionEnum = CalculationUtil.getForHeightAndWindDirectionEnum(anemometryDataList, value);
                     if (!heightAndWindDirectionEnum.isEmpty()) {
                         //获取指定层高风速数据
-                        List<BigDecimal> wsForHeight = heightAndWindDirectionEnum.stream().filter(h -> h.getWsAve() != null && h.getWsAve() != 0 && h.getLayerHeight().equals(height)).map((ProphaseAnemometryData p) ->
+                        List<BigDecimal> wsForHeight = heightAndWindDirectionEnum.stream().filter(h -> h.getWsAve() != null && h.getWsAve() != 0  && h.getWsAve() != -99 && h.getLayerHeight().equals(height)).map((ProphaseAnemometryData p) ->
                                 {
                                     return CalculationUtil.getBigDecimal(p.getWsAve());
                                 }
@@ -295,7 +295,7 @@ public class WindDirectionStatisticsDataServiceImpl extends ServiceImpl<WindDire
                         BigDecimal avgWindSpeed = CalculationUtil.getAvgWind(wsForHeight);
                         //获取指定最小层高风速数据
                         String finalHeightMin = String.valueOf(heightMin);
-                        List<BigDecimal> wsMinForHeight = heightAndWindDirectionEnum.stream().filter(h -> h.getWsAve() != null && h.getWsAve() != 0 && h.getLayerHeight().equals(finalHeightMin)).map((ProphaseAnemometryData p) ->
+                        List<BigDecimal> wsMinForHeight = heightAndWindDirectionEnum.stream().filter(h -> h.getWsAve() != null && h.getWsAve() != 0  && h.getWsAve() != -99 && h.getLayerHeight().equals(finalHeightMin)).map((ProphaseAnemometryData p) ->
                                 {
                                     return CalculationUtil.getBigDecimal(p.getWsAve());
                                 }

+ 41 - 36
neim-biz/src/main/java/com/jiayue/biz/service/impl/WindTowerCalculationDataServiceImpl.java

@@ -84,7 +84,7 @@ public class WindTowerCalculationDataServiceImpl extends ServiceImpl<WindTowerCa
     public ArrayList<WindTowerCalculationData> calculateWindPowerDensity(Long startTime, Long endTime, String eqNo, List<ProphaseAnemometryData> prophaseAnemometryDataList, List<ProphaseWeatherData> prophaseWeatherDataList, List<EquipmentAttribute> equipmentAttributeList, List<WindTowerCalculationData> windTowerCalculationDataList) {
         //获取对应测风塔数据
         List<ProphaseAnemometryData> anemometryDataList = prophaseAnemometryDataList.stream().filter(p -> p.getTs().getTime() >= startTime && p.getTs().getTime() <= endTime && p.getWsAve() != null && p.getWsAve() != -99).collect(Collectors.toList());
-        List<ProphaseWeatherData> weatherDataList = prophaseWeatherDataList.stream().filter(p -> p.getTs().getTime() >= startTime && p.getTs().getTime() <= endTime).collect(Collectors.toList());
+        List<ProphaseWeatherData> weatherDataList = prophaseWeatherDataList.stream().filter(p -> p.getTs().getTime() >= startTime && p.getTs().getTime() <= endTime && p.getAirDensity() != null && p.getAirDensity() >= 0).collect(Collectors.toList());
         long hour = 3600000L;
         List<WindTowerInfo> windTowerInfos = windTowerInfoService.lambdaQuery().eq(WindTowerInfo::getEquipmentNo, eqNo).list();
         String[] height = windTowerInfos.get(0).getHeights().split(",");
@@ -130,13 +130,16 @@ public class WindTowerCalculationDataServiceImpl extends ServiceImpl<WindTowerCa
                         windTowerCalculationDataList.add(windTowerCalculationData);
                         list.add(windTowerCalculationData);
                         //保存风功率密度
-                        WindTowerCalculationData windTowerCalculationDataWpd = new WindTowerCalculationData();
-                        windTowerCalculationDataWpd.setTime(new Date(time));
-                        windTowerCalculationDataWpd.setEbId(equipmentAttributeWpd.getId());
-                        windTowerCalculationDataWpd.setEquipmentId(eqNo);
-                        windTowerCalculationDataWpd.setValue(speedAndDensityDto.getWindPowerDensity());
-                        windTowerCalculationDataList.add(windTowerCalculationDataWpd);
-                        list.add(windTowerCalculationDataWpd);
+                        if (speedAndDensityDto.getWindPowerDensity().compareTo(BigDecimal.ZERO) != 0) {
+                            WindTowerCalculationData windTowerCalculationDataWpd = new WindTowerCalculationData();
+                            windTowerCalculationDataWpd.setTime(new Date(time));
+                            windTowerCalculationDataWpd.setEbId(equipmentAttributeWpd.getId());
+                            windTowerCalculationDataWpd.setEquipmentId(eqNo);
+                            windTowerCalculationDataWpd.setValue(speedAndDensityDto.getWindPowerDensity());
+                            windTowerCalculationDataList.add(windTowerCalculationDataWpd);
+                            list.add(windTowerCalculationDataWpd);
+                        }
+
                     }
                 }
 
@@ -1176,12 +1179,13 @@ public class WindTowerCalculationDataServiceImpl extends ServiceImpl<WindTowerCa
                 long start2 = start1 + dayTime - 1L;
                 BigDecimal airDensityDay = new BigDecimal(0);
                 long start = start1;
-                List<ProphaseWeatherData> collect = prophaseWeatherDataList.stream().filter(p -> p.getTs().getTime() >= start && p.getTs().getTime() <= start2).collect(Collectors.toList());
-                for (ProphaseWeatherData map : collect) {
-                    airDensityDay = airDensityDay.add(CalculationUtil.getBigDecimal(map.getAirDensity()));
-                }
+                List<ProphaseWeatherData> collect = prophaseWeatherDataList.stream().filter(p -> p.getTs().getTime() >= start && p.getTs().getTime() <= start2 && p.getAirDensity() != null && p.getAirDensity() > 0).collect(Collectors.toList());
+
                 //存平均值
                 if (!collect.isEmpty()) {
+                    for (ProphaseWeatherData map : collect) {
+                        airDensityDay = airDensityDay.add(CalculationUtil.getBigDecimal(map.getAirDensity()));
+                    }
                     WindTowerCalculationData windTowerCalculationData = new WindTowerCalculationData();
                     windTowerCalculationData.setEbId(equipmentAttribute.getId());
                     windTowerCalculationData.setTime(new Date(start1));
@@ -1216,7 +1220,7 @@ public class WindTowerCalculationDataServiceImpl extends ServiceImpl<WindTowerCa
 //        List<Map<String, Object>> collects = mapList.stream().filter(w -> Long.parseLong(w.get("time").toString()) >= startTime.getTime()
 //                && Long.parseLong(w.get("time").toString()) <= endTime.getTime() && w.get("equipment_id").equals(equipmentId)).collect(Collectors.toList());
 
-    List<ProphaseAnemometryData> collect = prophaseAnemometryDataList.stream().filter(p -> p.getTs().getTime() >= startTime.getTime() && p.getTs().getTime() <= endTime.getTime() && p.getWsMax() != null && p.getWsMax() != -99).collect(Collectors.toList());
+        List<ProphaseAnemometryData> collect = prophaseAnemometryDataList.stream().filter(p -> p.getTs().getTime() >= startTime.getTime() && p.getTs().getTime() <= endTime.getTime() && p.getWsMax() != null && p.getWsMax() != -99).collect(Collectors.toList());
 
         //获取所有层高
         String[] height = windTowerInfoList.stream().filter(w -> w.getEquipmentNo().equals(equipmentId)).collect(Collectors.toList()).get(0).getHeights().split(",");
@@ -1880,10 +1884,10 @@ public class WindTowerCalculationDataServiceImpl extends ServiceImpl<WindTowerCa
             for (long time = startTime.getTime(); time < endTime.getTime(); time += day) {
                 long dayTime = time;
                 //过滤一天数据
-                List<ProphaseWeatherData> collect = prophaseWeatherDataList.stream().filter(p -> p.getTs().getTime() >= dayTime && p.getTs().getTime() < dayTime + day).collect(Collectors.toList());
-                //计算时间段内所有温度
-                BigDecimal tSum = CalculationUtil.getBigDecimal(collect.stream().filter(c -> c.getTAve() != null && c.getTAve() != 0).mapToDouble(ProphaseWeatherData::getTAve).sum());
+                List<ProphaseWeatherData> collect = prophaseWeatherDataList.stream().filter(p -> p.getTs().getTime() >= dayTime && p.getTs().getTime() < dayTime + day && p.getTAve() != null && p.getTAve() != -99).collect(Collectors.toList());
                 if (!collect.isEmpty()) {
+                    //计算时间段内所有温度
+                    BigDecimal tSum = CalculationUtil.getBigDecimal(collect.stream().mapToDouble(ProphaseWeatherData::getTAve).sum());
                     WindTowerCalculationData windTowerCalculationData = new WindTowerCalculationData();
                     windTowerCalculationData.setEbId(ebId);
                     windTowerCalculationData.setTime(new Date(dayTime));
@@ -1918,10 +1922,9 @@ public class WindTowerCalculationDataServiceImpl extends ServiceImpl<WindTowerCa
             for (long time = startTime.getTime(); time < endTime.getTime(); time += day) {
                 long dayTime = time;
                 //过滤一天数据
-                List<ProphaseWeatherData> collect = prophaseWeatherDataList.stream().filter(p -> p.getTs().getTime() >= dayTime && p.getTs().getTime() < dayTime + day).collect(Collectors.toList());
-                BigDecimal paSum = CalculationUtil.getBigDecimal(collect.stream().filter(c -> c.getPaAve() != null && c.getPaAve() != 0).mapToDouble(ProphaseWeatherData::getPaAve).sum());
-
+                List<ProphaseWeatherData> collect = prophaseWeatherDataList.stream().filter(p -> p.getTs().getTime() >= dayTime && p.getTs().getTime() < dayTime + day && p.getPaAve() != null && p.getPaAve() > 0).collect(Collectors.toList());
                 if (!collect.isEmpty()) {
+                    BigDecimal paSum = CalculationUtil.getBigDecimal(collect.stream().mapToDouble(ProphaseWeatherData::getPaAve).sum());
                     WindTowerCalculationData windTowerCalculationData = new WindTowerCalculationData();
                     windTowerCalculationData.setEbId(ebId);
                     windTowerCalculationData.setTime(new Date(dayTime));
@@ -2327,7 +2330,7 @@ public class WindTowerCalculationDataServiceImpl extends ServiceImpl<WindTowerCa
 //            List<Map<String, Object>> collect = mapList.stream().filter(w -> Long.parseLong(w.get("time").toString()) >= startHour.getTime() && Long.parseLong(w.get("time").toString()) <= endTime.getTime() && w.get("equipment_id").equals(equipmentId)).collect(Collectors.toList());
             List<ProphaseWeatherData> prophaseWeatherData = prophaseWeatherDataList.stream().filter(p -> p.getTs().getTime() >= startHour.getTime() && p.getTs().getTime() <= endTime.getTime()).collect(Collectors.toList());
 
-            equipmentAttributeList = equipmentAttributeList.stream().filter(w -> "environment".equals(w.getAttributeFunction())).collect(Collectors.toList());
+            List<EquipmentAttribute> equipmentAttributes = equipmentAttributeList.stream().filter(w -> "environment".equals(w.getAttributeFunction())).collect(Collectors.toList());
             BigDecimal sumPa = new BigDecimal(0);
             BigDecimal avePa = new BigDecimal(0);
             BigDecimal sumRh = new BigDecimal(0);
@@ -2341,13 +2344,13 @@ public class WindTowerCalculationDataServiceImpl extends ServiceImpl<WindTowerCa
                 List<BigDecimal> tList = new ArrayList<>();
                 /*计算平均值数值为null 不计算*/
                 for (ProphaseWeatherData map : prophaseWeatherData) {
-                    if (map.getPaAve() != null && map.getPaAve() != 0) {
+                    if (map.getPaAve() != null && map.getPaAve() > 0) {
                         paList.add(CalculationUtil.getBigDecimal(map.getPaAve()));
                     }
-                    if (map.getRhAve() != null && map.getRhAve() != 0) {
+                    if (map.getRhAve() != null && map.getRhAve() > 0) {
                         rhList.add(CalculationUtil.getBigDecimal(map.getRhAve()));
                     }
-                    if (map.getTAve() != null && map.getTAve() != 0) {
+                    if (map.getTAve() != null && map.getTAve() != -99) {
                         tList.add(CalculationUtil.getBigDecimal(map.getTAve()));
                     }
                 }
@@ -2388,15 +2391,15 @@ public class WindTowerCalculationDataServiceImpl extends ServiceImpl<WindTowerCa
                     aveRh = sumRh.divide(new BigDecimal(rhList.size()), 2, RoundingMode.HALF_UP);
                 }
 
-                List<EquipmentAttribute> paMax = equipmentAttributeList.stream().filter(w -> w.getFieldName().equals("paMAX")).collect(Collectors.toList());
-                List<EquipmentAttribute> paMin = equipmentAttributeList.stream().filter(w -> w.getFieldName().equals("paMIN")).collect(Collectors.toList());
-                List<EquipmentAttribute> paAve = equipmentAttributeList.stream().filter(w -> w.getFieldName().equals("paAVE")).collect(Collectors.toList());
-                List<EquipmentAttribute> rhMax = equipmentAttributeList.stream().filter(w -> w.getFieldName().equals("rhMAX")).collect(Collectors.toList());
-                List<EquipmentAttribute> rhMin = equipmentAttributeList.stream().filter(w -> w.getFieldName().equals("rhMIN")).collect(Collectors.toList());
-                List<EquipmentAttribute> rhAve = equipmentAttributeList.stream().filter(w -> w.getFieldName().equals("rhAVE")).collect(Collectors.toList());
-                List<EquipmentAttribute> tMax = equipmentAttributeList.stream().filter(w -> w.getFieldName().equals("tMAX")).collect(Collectors.toList());
-                List<EquipmentAttribute> tMin = equipmentAttributeList.stream().filter(w -> w.getFieldName().equals("tMIN")).collect(Collectors.toList());
-                List<EquipmentAttribute> tAve = equipmentAttributeList.stream().filter(w -> w.getFieldName().equals("tAVE")).collect(Collectors.toList());
+                List<EquipmentAttribute> paMax = equipmentAttributes.stream().filter(w -> w.getFieldName().equals("paMAX")).collect(Collectors.toList());
+                List<EquipmentAttribute> paMin = equipmentAttributes.stream().filter(w -> w.getFieldName().equals("paMIN")).collect(Collectors.toList());
+                List<EquipmentAttribute> paAve = equipmentAttributes.stream().filter(w -> w.getFieldName().equals("paAVE")).collect(Collectors.toList());
+                List<EquipmentAttribute> rhMax = equipmentAttributes.stream().filter(w -> w.getFieldName().equals("rhMAX")).collect(Collectors.toList());
+                List<EquipmentAttribute> rhMin = equipmentAttributes.stream().filter(w -> w.getFieldName().equals("rhMIN")).collect(Collectors.toList());
+                List<EquipmentAttribute> rhAve = equipmentAttributes.stream().filter(w -> w.getFieldName().equals("rhAVE")).collect(Collectors.toList());
+                List<EquipmentAttribute> tMax = equipmentAttributes.stream().filter(w -> w.getFieldName().equals("tMAX")).collect(Collectors.toList());
+                List<EquipmentAttribute> tMin = equipmentAttributes.stream().filter(w -> w.getFieldName().equals("tMIN")).collect(Collectors.toList());
+                List<EquipmentAttribute> tAve = equipmentAttributes.stream().filter(w -> w.getFieldName().equals("tAVE")).collect(Collectors.toList());
                 removeByStartTimeBetweenAndEquipmentIdAndEbId(startTime, endTime, equipmentId, paMax.get(0).getId());
                 removeByStartTimeBetweenAndEquipmentIdAndEbId(startTime, endTime, equipmentId, paMin.get(0).getId());
                 removeByStartTimeBetweenAndEquipmentIdAndEbId(startTime, endTime, equipmentId, paAve.get(0).getId());
@@ -2500,14 +2503,16 @@ public class WindTowerCalculationDataServiceImpl extends ServiceImpl<WindTowerCa
                     long endHour = time + hour;
                     //筛选小时数据
 //                    List<Map<String, Object>> collect = mapList.stream().filter(w -> Long.parseLong(w.get("time").toString()) >= startHour && Long.parseLong(w.get("time").toString()) <= endHour && w.get("equipment_id").equals(equipmentId)).collect(Collectors.toList());
-                    List<ProphaseAnemometryData> anemometryDataList = prophaseAnemometryDataList.stream().filter(p -> p.getTs().getTime() >= startHour && p.getTs().getTime() <= endHour && p.getLayerHeight().equals(h)).collect(Collectors.toList());
+                    List<ProphaseAnemometryData> anemometryDataList = prophaseAnemometryDataList.stream().filter(p -> p.getTs().getTime() >= startHour && p.getTs().getTime() <= endHour && p.getLayerHeight().equals(h)
+                            && p.getWsAve() != null && p.getWsAve() != -99
+                            && p.getWsSta() != null && p.getWsSta() != -99).collect(Collectors.toList());
 
 
                     if (anemometryDataList.size() > 0) {
                         BigDecimal turAve = BigDecimal.ZERO;
                         //循环实时数据计算总风速和标差
-                        BigDecimal wsSun = CalculationUtil.getBigDecimal(anemometryDataList.stream().filter(a -> a.getWsAve() != null).mapToDouble(ProphaseAnemometryData::getWsAve).sum());
-                        BigDecimal staSun = CalculationUtil.getBigDecimal(anemometryDataList.stream().filter(a -> a.getWsSta() != null).mapToDouble(ProphaseAnemometryData::getWsSta).sum());
+                        BigDecimal wsSun = CalculationUtil.getBigDecimal(anemometryDataList.stream().mapToDouble(ProphaseAnemometryData::getWsAve).sum());
+                        BigDecimal staSun = CalculationUtil.getBigDecimal(anemometryDataList.stream().mapToDouble(ProphaseAnemometryData::getWsSta).sum());
                         //除以一小时的个数 求小时的平均值
                         BigDecimal wsAve = wsSun.divide(BigDecimal.valueOf(anemometryDataList.size()), 2, RoundingMode.HALF_UP);
                         BigDecimal staAve = staSun.divide(BigDecimal.valueOf(anemometryDataList.size()), 2, RoundingMode.HALF_UP);
@@ -2583,7 +2588,7 @@ public class WindTowerCalculationDataServiceImpl extends ServiceImpl<WindTowerCa
                 long startHour = time;
                 long endHour = time + hour;
 //                List<Map<String, Object>> collect = mapList.stream().filter(w -> Long.parseLong(w.get("time").toString()) >= startHour && Long.parseLong(w.get("time").toString()) <= endHour && w.get("equipment_id").equals(equipmentId)).collect(Collectors.toList());
-                List<ProphaseWeatherData> weatherDataList = prophaseWeatherDataList.stream().filter(p -> p.getTs().getTime() >= startHour && p.getTs().getTime() <= endHour).collect(Collectors.toList());
+                List<ProphaseWeatherData> weatherDataList = prophaseWeatherDataList.stream().filter(p -> p.getTs().getTime() >= startHour && p.getTs().getTime() <= endHour && p.getAirDensity() != null && p.getAirDensity() > 0).collect(Collectors.toList());
                 for (ProphaseWeatherData map : weatherDataList) {
                     //过滤异常数据
 

+ 105 - 100
neim-biz/src/main/java/com/jiayue/biz/service/impl/WindTowerDataParentTableServiceImpl.java

@@ -14,10 +14,7 @@ import com.jiayue.biz.domain.*;
 import com.jiayue.biz.mapper.ProphaseAnemometryDataMapper;
 import com.jiayue.biz.mapper.ProphaseWeatherDataMapper;
 import com.jiayue.biz.mapper.WindTowerDataParentTableMapper;
-import com.jiayue.biz.service.ProphaseAnemometryDataService;
-import com.jiayue.biz.service.ProphaseWeatherDataService;
-import com.jiayue.biz.service.WindTowerDataChildTableService;
-import com.jiayue.biz.service.WindTowerDataParentTableService;
+import com.jiayue.biz.service.*;
 import com.jiayue.biz.util.CalculationUtil;
 import com.jiayue.biz.util.CommonUtil;
 import com.jiayue.biz.util.DateTimeUtil;
@@ -65,6 +62,12 @@ public class WindTowerDataParentTableServiceImpl extends ServiceImpl<WindTowerDa
     ProphaseAnemometryDataService prophaseAnemometryDataService;
 
     @Autowired
+    ProphaseAnemometryDataOrgService prophaseAnemometryDataOrgService;
+
+    @Autowired
+    ProphaseWeatherDataOrgService prophaseWeatherDataOrgService;
+
+    @Autowired
     ProphaseWeatherDataService prophaseWeatherDataService;
 
 
@@ -100,117 +103,119 @@ public class WindTowerDataParentTableServiceImpl extends ServiceImpl<WindTowerDa
         heightAll.addAll(Arrays.asList(wdHeight));
         heightAll.addAll(Arrays.asList(heights));
         //层高
-        ArrayList<ProphaseAnemometryData> prophaseAnemometryDataArrayList = new ArrayList<>();
-        ArrayList<ProphaseWeatherData> prophaseAnemometryPublicDataArrayList = new ArrayList<>();
-
+//        ArrayList<ProphaseAnemometryData> prophaseAnemometryDataArrayList = new ArrayList<>();
+//        ArrayList<ProphaseWeatherData> prophaseAnemometryPublicDataArrayList = new ArrayList<>();
         try {
             //所有数据
             for (Map<String, Object> m : allData) {
-                for (String height : heightAll) {
-                if(m.get("time").toString().contains("4:50")){
-                    System.out.println("height = " + m);
-                }
-
-                    //异常数据赋值为-99
-                    if (m.get("abnormalType") != null) {
-                        if (m.get("abnormalType").toString().contains(",")) {
-                            String[] abnormalTypes = m.get("abnormalType").toString().split(",");
-                            for (String abnormalType : abnormalTypes) {
-                                m.put(abnormalType, -99f);
-                            }
-                        } else {
-                            m.put(m.get("abnormalType").toString(), -99f);
+                this.packageOrgData(m, heightAll, simpleDateFormat, eqNo, "org");
+                //异常数据赋值为-99
+                if (m.get("abnormalType") != null) {
+                    if (m.get("abnormalType").toString().contains(",")) {
+                        String[] abnormalTypes = m.get("abnormalType").toString().split(",");
+                        for (String abnormalType : abnormalTypes) {
+                            m.put(abnormalType, -99f);
                         }
+                    } else {
+                        m.put(m.get("abnormalType").toString(), -99f);
                     }
-                    ProphaseAnemometryData one = new ProphaseAnemometryData();
-                    //组装子表数据
-                    one.setWsAve(m.get("wsAve_" + height) == null ? null : CalculationUtil.getBigDecimal(m.get("wsAve_" + height)).setScale(2, RoundingMode.HALF_UP).floatValue());
-                    one.setWsMin(m.get("wsMin_" + height) == null ? null : CalculationUtil.getBigDecimal(m.get("wsMin_" + height)).setScale(2, RoundingMode.HALF_UP).floatValue());
-                    one.setWsMax(m.get("wsMax_" + height) == null ? null : CalculationUtil.getBigDecimal(m.get("wsMax_" + height)).setScale(2, RoundingMode.HALF_UP).floatValue());
-                    one.setWsSta(m.get("wsSta_" + height) == null ? null : CalculationUtil.getBigDecimal(m.get("wsSta_" + height)).setScale(2, RoundingMode.HALF_UP).floatValue());
-                    one.setWsInst(m.get("wsInst_" + height) == null ? null : CalculationUtil.getBigDecimal(m.get("wsInst_" + height)).setScale(2, RoundingMode.HALF_UP).floatValue());
-                    one.setWdAve(m.get("wdAve_" + height) == null ? null : CalculationUtil.getBigDecimal(m.get("wdAve_" + height)).setScale(2, RoundingMode.HALF_UP).floatValue());
-                    one.setWdMax(m.get("wdMax_" + height) == null ? null : CalculationUtil.getBigDecimal(m.get("wdMax_" + height)).setScale(2, RoundingMode.HALF_UP).floatValue());
-                    one.setWdMin(m.get("wdMin_" + height) == null ? null : CalculationUtil.getBigDecimal(m.get("wdMin_" + height)).setScale(2, RoundingMode.HALF_UP).floatValue());
-                    one.setWdSta(m.get("wdSta_" + height) == null ? null : CalculationUtil.getBigDecimal(m.get("wdSta_" + height)).setScale(2, RoundingMode.HALF_UP).floatValue());
-                    one.setWdInst(m.get("wdInst_" + height) == null ? null : CalculationUtil.getBigDecimal(m.get("wdInst_" + height)).setScale(2, RoundingMode.HALF_UP).floatValue());
-                    one.setLayerHeight(height);
-                    one.setEquipmentId(equipmentId);
-                    prophaseAnemometryDataArrayList.add(one);
-                    if (m.get("time") != null) {
-                        try {
-                            try {
-                                one.setTs(new Timestamp(simpleDateFormat.parse(m.get("time").toString()).getTime()));
-                            } catch (ParseException e) {
-                                one.setTs(new Timestamp(new Date(Long.parseLong(m.get("time").toString())).getTime()));
-                            }
+                }
+                this.packageOrgData(m, heightAll, simpleDateFormat, eqNo, "noOrg");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
 
-                        } catch (Exception e) {
-                            log.error("时间转换异常:" + e);
-                        }
+    }
+
+
+    public void packageOrgData(Map<String, Object> m, HashSet<String> heightAll, SimpleDateFormat simpleDateFormat, String equipmentId, String org) {
+        for (String height : heightAll) {
+            ProphaseAnemometryData one = new ProphaseAnemometryData();
+            //组装子表数据
+            one.setWsAve(m.get("wsAve_" + height) == null ? null : CalculationUtil.getBigDecimal(m.get("wsAve_" + height)).setScale(2, RoundingMode.HALF_UP).floatValue());
+            one.setWsMin(m.get("wsMin_" + height) == null ? null : CalculationUtil.getBigDecimal(m.get("wsMin_" + height)).setScale(2, RoundingMode.HALF_UP).floatValue());
+            one.setWsMax(m.get("wsMax_" + height) == null ? null : CalculationUtil.getBigDecimal(m.get("wsMax_" + height)).setScale(2, RoundingMode.HALF_UP).floatValue());
+            one.setWsSta(m.get("wsSta_" + height) == null ? null : CalculationUtil.getBigDecimal(m.get("wsSta_" + height)).setScale(2, RoundingMode.HALF_UP).floatValue());
+            one.setWsInst(m.get("wsInst_" + height) == null ? null : CalculationUtil.getBigDecimal(m.get("wsInst_" + height)).setScale(2, RoundingMode.HALF_UP).floatValue());
+            one.setWdAve(m.get("wdAve_" + height) == null ? null : CalculationUtil.getBigDecimal(m.get("wdAve_" + height)).setScale(2, RoundingMode.HALF_UP).floatValue());
+            one.setWdMax(m.get("wdMax_" + height) == null ? null : CalculationUtil.getBigDecimal(m.get("wdMax_" + height)).setScale(2, RoundingMode.HALF_UP).floatValue());
+            one.setWdMin(m.get("wdMin_" + height) == null ? null : CalculationUtil.getBigDecimal(m.get("wdMin_" + height)).setScale(2, RoundingMode.HALF_UP).floatValue());
+            one.setWdSta(m.get("wdSta_" + height) == null ? null : CalculationUtil.getBigDecimal(m.get("wdSta_" + height)).setScale(2, RoundingMode.HALF_UP).floatValue());
+            one.setWdInst(m.get("wdInst_" + height) == null ? null : CalculationUtil.getBigDecimal(m.get("wdInst_" + height)).setScale(2, RoundingMode.HALF_UP).floatValue());
+            one.setLayerHeight(height);
+            one.setEquipmentId(equipmentId);
+            if (m.get("time") != null) {
+                try {
+                    try {
+                        one.setTs(new Timestamp(simpleDateFormat.parse(m.get("time").toString()).getTime()));
+                    } catch (ParseException e) {
+                        one.setTs(new Timestamp(new Date(Long.parseLong(m.get("time").toString())).getTime()));
                     }
-                    prophaseAnemometryDataService.insertOneWithNew(one);
-                }
 
-//                log.error("prophaseAnemometryDataArrayList = " + JSONUtil.toJsonPrettyStr(prophaseAnemometryDataArrayList));
-//                prophaseAnemometryDataMapper.insertSplice(prophaseAnemometryDataArrayList, equipmentId, height);
-
-
-                ProphaseWeatherData prophaseAnemometryPublicData = new ProphaseWeatherData();
-                if (m.get("paMax") != null)
-                    //kpa转hpa
-                    if (BigDecimal.valueOf(Double.parseDouble(m.get("paMax").toString())).compareTo(new BigDecimal(200)) < 0)
-                        prophaseAnemometryPublicData.setPaMax(CalculationUtil.getBigDecimal(m.get("paMax").toString()).multiply(new BigDecimal(10)).setScale(2, RoundingMode.HALF_UP).floatValue());
-                    else
-                        prophaseAnemometryPublicData.setPaMax(CalculationUtil.getBigDecimal(m.get("paMax").toString()).floatValue());
-                if (m.get("paMin") != null)
-                    //kpa转hpa
-                    if (BigDecimal.valueOf(Double.parseDouble(m.get("paMin").toString())).compareTo(new BigDecimal(200)) < 0)
-                        prophaseAnemometryPublicData.setPaMin(CalculationUtil.getBigDecimal(m.get("paMin").toString()).multiply(new BigDecimal(10)).setScale(2, RoundingMode.HALF_UP).floatValue());
-                    else
-                        prophaseAnemometryPublicData.setPaMin(CalculationUtil.getBigDecimal(m.get("paMin").toString()).floatValue());
-                if (m.get("paAve") != null)
-                    //kpa转hpa
-                    if (BigDecimal.valueOf(Double.parseDouble(m.get("paAve").toString())).compareTo(new BigDecimal(200)) < 0)
-                        prophaseAnemometryPublicData.setPaAve(CalculationUtil.getBigDecimal(m.get("paAve").toString()).multiply(new BigDecimal(10)).setScale(2, RoundingMode.HALF_UP).floatValue());
-                    else
-                        prophaseAnemometryPublicData.setPaAve(CalculationUtil.getBigDecimal(m.get("paAve").toString()).floatValue());
-                prophaseAnemometryPublicData.setPaSta(m.get("paSta") == null ? null : CalculationUtil.getBigDecimal(m.get("paSta")).setScale(2, RoundingMode.HALF_UP).floatValue());
-                prophaseAnemometryPublicData.setTMax(m.get("tMax") == null ? null : CalculationUtil.getBigDecimal(m.get("tMax")).setScale(2, RoundingMode.HALF_UP).floatValue());
-                prophaseAnemometryPublicData.setTMin(m.get("tMin") == null ? null : CalculationUtil.getBigDecimal(m.get("tMin")).setScale(2, RoundingMode.HALF_UP).floatValue());
-                prophaseAnemometryPublicData.setTAve(m.get("tAve") == null ? null : CalculationUtil.getBigDecimal(m.get("tAve")).setScale(2, RoundingMode.HALF_UP).floatValue());
-                prophaseAnemometryPublicData.setTSta(m.get("tSta") == null ? null : CalculationUtil.getBigDecimal(m.get("tSta")).setScale(2, RoundingMode.HALF_UP).floatValue());
-                prophaseAnemometryPublicData.setRhMax(m.get("rhMax") == null ? null : CalculationUtil.getBigDecimal(m.get("rhMax")).setScale(2, RoundingMode.HALF_UP).floatValue());
-                prophaseAnemometryPublicData.setRhMin(m.get("rhMin") == null ? null : CalculationUtil.getBigDecimal(m.get("rhMin")).setScale(2, RoundingMode.HALF_UP).floatValue());
-                prophaseAnemometryPublicData.setRhAve(m.get("rhAve") == null ? null : CalculationUtil.getBigDecimal(m.get("rhAve")).setScale(2, RoundingMode.HALF_UP).floatValue());
-                prophaseAnemometryPublicData.setRhSta(m.get("rhSta") == null ? null : CalculationUtil.getBigDecimal(m.get("rhSta")).setScale(2, RoundingMode.HALF_UP).floatValue());
-                //计算空气密度  1.293*(273/(273+温度摄氏度))*气压百帕/1013
-                if (prophaseAnemometryPublicData.getTAve() != null && prophaseAnemometryPublicData.getPaAve() != null) {
-                    BigDecimal airDensity = BigDecimal.valueOf(1.293).multiply(new BigDecimal(273).divide(new BigDecimal(273).add(BigDecimal.valueOf(prophaseAnemometryPublicData.getTAve())), 2, RoundingMode.HALF_UP)).multiply(BigDecimal.valueOf(prophaseAnemometryPublicData.getPaAve())).divide(new BigDecimal(1013), 2, RoundingMode.HALF_UP);
-                    prophaseAnemometryPublicData.setAirDensity(airDensity.floatValue());
+                } catch (Exception e) {
+                    log.error("时间转换异常:" + e);
                 }
-                if (m.get("time") != null) {
-                    try {
-                        try {
-                            prophaseAnemometryPublicData.setTs(new Timestamp(simpleDateFormat.parse(m.get("time").toString()).getTime()));
-                        } catch (ParseException e) {
-                            prophaseAnemometryPublicData.setTs(new Timestamp(new Date(Long.parseLong(m.get("time").toString())).getTime()));
-                        }
+            }
+            if (org.equals("org")) {
+                prophaseAnemometryDataOrgService.insertOneWithNew(one);
+            } else {
+                prophaseAnemometryDataService.insertOneWithNew(one);
+            }
+        }
 
-                    } catch (Exception e) {
-                        log.error("时间转换异常:" + e);
-                    }
+        ProphaseWeatherData prophaseAnemometryPublicData = new ProphaseWeatherData();
+        prophaseAnemometryPublicData.setEquipmentId(equipmentId);
+        if (m.get("paMax") != null)
+            //kpa转hpa
+            if (BigDecimal.valueOf(Double.parseDouble(m.get("paMax").toString())).compareTo(new BigDecimal(200)) < 0)
+                prophaseAnemometryPublicData.setPaMax(CalculationUtil.getBigDecimal(m.get("paMax").toString()).multiply(new BigDecimal(10)).setScale(2, RoundingMode.HALF_UP).floatValue());
+            else
+                prophaseAnemometryPublicData.setPaMax(CalculationUtil.getBigDecimal(m.get("paMax").toString()).floatValue());
+        if (m.get("paMin") != null)
+            //kpa转hpa
+            if (BigDecimal.valueOf(Double.parseDouble(m.get("paMin").toString())).compareTo(new BigDecimal(200)) < 0)
+                prophaseAnemometryPublicData.setPaMin(CalculationUtil.getBigDecimal(m.get("paMin").toString()).multiply(new BigDecimal(10)).setScale(2, RoundingMode.HALF_UP).floatValue());
+            else
+                prophaseAnemometryPublicData.setPaMin(CalculationUtil.getBigDecimal(m.get("paMin").toString()).floatValue());
+        if (m.get("paAve") != null)
+            //kpa转hpa
+            if (BigDecimal.valueOf(Double.parseDouble(m.get("paAve").toString())).compareTo(new BigDecimal(200)) < 0)
+                prophaseAnemometryPublicData.setPaAve(CalculationUtil.getBigDecimal(m.get("paAve").toString()).multiply(new BigDecimal(10)).setScale(2, RoundingMode.HALF_UP).floatValue());
+            else
+                prophaseAnemometryPublicData.setPaAve(CalculationUtil.getBigDecimal(m.get("paAve").toString()).floatValue());
+        prophaseAnemometryPublicData.setPaSta(m.get("paSta") == null ? null : CalculationUtil.getBigDecimal(m.get("paSta")).setScale(2, RoundingMode.HALF_UP).floatValue());
+        prophaseAnemometryPublicData.setTMax(m.get("tMax") == null ? null : CalculationUtil.getBigDecimal(m.get("tMax")).setScale(2, RoundingMode.HALF_UP).floatValue());
+        prophaseAnemometryPublicData.setTMin(m.get("tMin") == null ? null : CalculationUtil.getBigDecimal(m.get("tMin")).setScale(2, RoundingMode.HALF_UP).floatValue());
+        prophaseAnemometryPublicData.setTAve(m.get("tAve") == null ? null : CalculationUtil.getBigDecimal(m.get("tAve")).setScale(2, RoundingMode.HALF_UP).floatValue());
+        prophaseAnemometryPublicData.setTSta(m.get("tSta") == null ? null : CalculationUtil.getBigDecimal(m.get("tSta")).setScale(2, RoundingMode.HALF_UP).floatValue());
+        prophaseAnemometryPublicData.setRhMax(m.get("rhMax") == null ? null : CalculationUtil.getBigDecimal(m.get("rhMax")).setScale(2, RoundingMode.HALF_UP).floatValue());
+        prophaseAnemometryPublicData.setRhMin(m.get("rhMin") == null ? null : CalculationUtil.getBigDecimal(m.get("rhMin")).setScale(2, RoundingMode.HALF_UP).floatValue());
+        prophaseAnemometryPublicData.setRhAve(m.get("rhAve") == null ? null : CalculationUtil.getBigDecimal(m.get("rhAve")).setScale(2, RoundingMode.HALF_UP).floatValue());
+        prophaseAnemometryPublicData.setRhSta(m.get("rhSta") == null ? null : CalculationUtil.getBigDecimal(m.get("rhSta")).setScale(2, RoundingMode.HALF_UP).floatValue());
+        //计算空气密度  1.293*(273/(273+温度摄氏度))*气压百帕/1013
+        if (prophaseAnemometryPublicData.getTAve() != null && prophaseAnemometryPublicData.getPaAve() != null) {
+            BigDecimal airDensity = BigDecimal.valueOf(1.293).multiply(new BigDecimal(273).divide(new BigDecimal(273).add(BigDecimal.valueOf(prophaseAnemometryPublicData.getTAve())), 2, RoundingMode.HALF_UP)).multiply(BigDecimal.valueOf(prophaseAnemometryPublicData.getPaAve())).divide(new BigDecimal(1013), 2, RoundingMode.HALF_UP);
+            prophaseAnemometryPublicData.setAirDensity(airDensity.floatValue());
+        }
+        if (m.get("time") != null) {
+            try {
+                try {
+                    prophaseAnemometryPublicData.setTs(new Timestamp(simpleDateFormat.parse(m.get("time").toString()).getTime()));
+                } catch (ParseException e) {
+                    prophaseAnemometryPublicData.setTs(new Timestamp(new Date(Long.parseLong(m.get("time").toString())).getTime()));
                 }
-                prophaseAnemometryPublicDataArrayList.add(prophaseAnemometryPublicData);
 
+            } catch (Exception e) {
+                log.error("时间转换异常:" + e);
             }
-
-//            log.error("prophaseAnemometryPublicDataArrayList = " + JSONUtil.toJsonPrettyStr(prophaseAnemometryPublicDataArrayList));
-            prophaseWeatherDataService.insertSplice(prophaseAnemometryPublicDataArrayList, equipmentId);
-        } catch (Exception e) {
-            e.printStackTrace();
         }
 
+        if (org.equals("org")) {
+            prophaseWeatherDataOrgService.insertOne(prophaseAnemometryPublicData);
+        } else {
+            prophaseWeatherDataService.insertOne(prophaseAnemometryPublicData);
+        }
     }
 
 

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

@@ -91,7 +91,7 @@ public class CalculationUtil {
             if (anemometryData.size() != 0) {
                 BigDecimal wpdSum = new BigDecimal(0);
                 for (ProphaseAnemometryData anemometryDatum : anemometryData) {
-                    List<ProphaseWeatherData> collect = weatherData.stream().filter(w -> w.getTs().getTime() == anemometryDatum.getTs().getTime()).collect(Collectors.toList());
+                    List<ProphaseWeatherData> collect = weatherData.stream().filter(w -> w.getTs().getTime() == anemometryDatum.getTs().getTime() && anemometryDatum.getWsAve() != null && anemometryDatum.getWsAve() != -99).collect(Collectors.toList());
                     if (collect.size() > 0) {
                         wpdSum = wpdSum.add(getWpdCalculate(getBigDecimal(collect.get(0).getAirDensity()), getBigDecimal(anemometryDatum.getWsAve())));
                     }