瀏覽代碼

修改湍流平均值 以及统计计算逻辑 湍流平均值取风速段14.5-15.5之间

hxf 1 年之前
父節點
當前提交
c4e1e6cc66

文件差異過大導致無法顯示
+ 1 - 1
neim-biz/src/main/java/com/jiayue/biz/job/AirDensityJob.java


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

@@ -11,7 +11,12 @@ import java.util.List;
 import java.util.Map;
 
 public interface ProphaseWeatherDataService extends IService<ProphaseWeatherData> {
-    //获取测风塔起止时间
+    /**
+     *
+     * @param equipmentNo 场站id
+     * @return startTime 开始时间 endTime 结束时间
+     *
+     */
     Map<String, Long> getDataTimeStartAndEnd(String equipmentNo);
 
     //根据设备编号取出所有条数

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

@@ -635,7 +635,7 @@ public class DataRecalculationImpl implements DataRecalculationService {
             ArrayList<WindTowerCalculationData> calculationData1 = windTowerCalculationDataService.calculateStaDay(startTime, endTime, equipmentNo, prophaseAnemometryDataList, equipmentAttributeList, windTowerInfoList, windTowerCalculationDataList);
             allDataList.addAll(calculationData1);
             //日平均湍流
-            ArrayList<WindTowerCalculationData> turbulenceDay = windTowerCalculationDataService.turbulenceDay(startTime, endTime, equipmentNo, equipmentAttributeList, windTowerInfoList, windTowerCalculationDataList);
+            ArrayList<WindTowerCalculationData> turbulenceDay = windTowerCalculationDataService.turbulenceDay(startTime, endTime, equipmentNo, equipmentAttributeList, windTowerInfoList, windTowerCalculationDataList,prophaseAnemometryDataList);
             allDataList.addAll(turbulenceDay);
             //日平均空气密度
             ArrayList<WindTowerCalculationData> airDensityDay = windTowerCalculationDataService.airDensityDay(startTime, endTime, equipmentNo, prophaseWeatherDataList, equipmentAttributeList, windTowerCalculationDataList);

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

@@ -517,7 +517,7 @@ public class HomePageServiceImpl extends ServiceImpl<WindTowerDataParentTableMap
 
         Date yearDay = DateTimeUtil.getYearDay(lastDataCalculation.getTime().getTime());
         //获取去年月份开始时间
-        Date beginTime = DateUtil.offsetMonth(DateUtil.beginOfMonth(yearDay), 1);
+//        Date beginTime = DateUtil.offsetMonth(DateUtil.beginOfMonth(yearDay), 1);
         Date endTime = lastDataCalculation.getTime();
 
         List<EquipmentAttribute> equipmentAttributeList = equipmentAttributeService.lambdaQuery().eq(EquipmentAttribute::getFieldName, "airDensityMonth").or().eq(EquipmentAttribute::getFieldName, "tAVE").or().
@@ -525,8 +525,8 @@ public class HomePageServiceImpl extends ServiceImpl<WindTowerDataParentTableMap
                 eq(EquipmentAttribute::getFieldName, "windShearMonth").or().eq(EquipmentAttribute::getFieldName, "batteryDay")
                 .or().eq(EquipmentAttribute::getFieldName, wdHeight[0] + "monthWdRose").list();
 
-        List<WindTowerCalculationData> windTowerCalculationDataList = windTowerCalculationDataService.getByBetweenTimeAndEquipmentIdAndEbId(beginTime, endTime, equipmentId, equipmentAttributeList);
-
+        List<WindTowerCalculationData> windTowerCalculationDataList = windTowerCalculationDataService.getByBetweenTimeAndEquipmentIdAndEbId(yearDay, endTime, equipmentId, equipmentAttributeList);
+        windTowerCalculationDataList = windTowerCalculationDataList.stream().filter(w ->  w.getTime().getTime() >= yearDay.getTime() && w.getTime().getTime() <= endTime.getTime()).collect(Collectors.toList());
         HashMap<String, Object> dataMap = new HashMap<>();
         //温度
         dataMap.put("t", this.getDataForCalculationByEb(equipmentAttributeList, windTowerCalculationDataList, "tAVE"));
@@ -550,7 +550,7 @@ public class HomePageServiceImpl extends ServiceImpl<WindTowerDataParentTableMap
         dataMap.put("hour", hourMax);
 
         List<EquipmentAttribute> equipmentAttributes = equipmentAttributeList.stream().filter(e -> e.getFieldName().equals(wdHeight[0] + "monthWdRose")).collect(Collectors.toList());
-        List<WindDirectionStatisticsData> windDirectionStatisticsDataList = windDirectionStatisticsDataService.lambdaQuery().eq(WindDirectionStatisticsData::getEbId, equipmentAttributes.get(0).getId()).between(WindDirectionStatisticsData::getTime, beginTime, endTime)
+        List<WindDirectionStatisticsData> windDirectionStatisticsDataList = windDirectionStatisticsDataService.lambdaQuery().eq(WindDirectionStatisticsData::getEbId, equipmentAttributes.get(0).getId()).between(WindDirectionStatisticsData::getTime, yearDay, endTime)
                 .eq(WindDirectionStatisticsData::getEquipmentId, equipmentId).list();
 
         Map<String, List<WindDirectionStatisticsData>> collect = windDirectionStatisticsDataList.stream().collect(Collectors.groupingBy(w -> w.getDirection()));

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

@@ -97,7 +97,7 @@ public class RealTimeDisplayServiceImpl implements RealTimeDisplayService {
             /*
              * 风速段-----湍流平均值
              */
-            TreeMap<Object, Object> treeMap = new TreeMap();
+            TreeMap<BigDecimal, BigDecimal> treeMap = new TreeMap();
             Map<BigDecimal, BigDecimal> speedLevel_turbulenceAvgMap = new HashMap<>();
             BigDecimal avgContent;
             for (Map.Entry<BigDecimal, List<BigDecimal>> e : speedLevel_turbulenceMap.entrySet()) {
@@ -116,27 +116,18 @@ public class RealTimeDisplayServiceImpl implements RealTimeDisplayService {
 
             ArrayList<Object> densityList1 = new ArrayList<>();
             densityList2 = new ArrayList<>();
-            BigDecimal TurCount = BigDecimal.ZERO;
-            BigDecimal TurSum = BigDecimal.ZERO;
             BigDecimal TurAve = BigDecimal.ZERO;
-            int i1 = treeMap.entrySet().size();
-            TurCount = TurCount.add(BigDecimal.valueOf(i1));
 
 
             //拼接返回给前台
-            for (Map.Entry<Object, Object> o1 : treeMap.entrySet()) {
+            for (Map.Entry<BigDecimal, BigDecimal> o1 : treeMap.entrySet()) {
                 Map<String, Object> map2 = new HashMap();
-
                 map2.put("ws", o1.getKey());
                 map2.put("tur", o1.getValue());
-                densityList1.add(map2);
-                if (o1.getValue() != null) {
-                    TurSum = TurSum.add(BigDecimal.valueOf(Double.parseDouble(o1.getValue().toString())));
+                if(o1.getKey().compareTo(BigDecimal.valueOf(15)) == 0){
+                    TurAve = o1.getValue();
                 }
-            }
-            //如果不等于0
-            if (!TurCount.equals(BigDecimal.ZERO)) {
-                TurAve = TurSum.divide(TurCount, 2, RoundingMode.HALF_UP);
+                densityList1.add(map2);
             }
             //放入风速和湍流值
             map.put(h, densityList1);

+ 34 - 21
neim-biz/src/main/java/com/jiayue/biz/service/impl/WindTowerCalculationDataServiceImpl.java

@@ -1604,7 +1604,7 @@ public class WindTowerCalculationDataServiceImpl extends ServiceImpl<WindTowerCa
      * @param equipmentId 设备id
      * @return
      */
-    public ArrayList<WindTowerCalculationData> turbulenceDay(Date startTime, Date endTime, String equipmentId, List<EquipmentAttribute> equipmentAttributeList, List<WindTowerInfo> windTowerInfoList, List<WindTowerCalculationData> windTowerCalculationDataList) {
+    public ArrayList<WindTowerCalculationData> turbulenceDay(Date startTime, Date endTime, String equipmentId, List<EquipmentAttribute> equipmentAttributeList, List<WindTowerInfo> windTowerInfoList, List<WindTowerCalculationData> windTowerCalculationDataList, List<ProphaseAnemometryData> prophaseAnemometryDataList) {
         long startHour = startTime.getTime();
         long endHour = endTime.getTime();
         long dayTime = 86400000L;
@@ -1614,26 +1614,29 @@ public class WindTowerCalculationDataServiceImpl extends ServiceImpl<WindTowerCa
         ArrayList<WindTowerCalculationData> list = new ArrayList<>();
         try {
             for (String h : heightAll) {
-
+                List<ProphaseAnemometryData> anemometryDataList = prophaseAnemometryDataList.stream().filter(p -> p.getLayerHeight().equals(h)).collect(Collectors.toList());
                 List<EquipmentAttribute> turList = equipmentAttributeList.stream().filter(equipmentAttribute -> equipmentAttribute.getFieldName().equals(h + turbulenceDay)).collect(Collectors.toList());
-                List<EquipmentAttribute> staList = equipmentAttributeList.stream().filter(equipmentAttribute -> equipmentAttribute.getFieldName().equals(h + staDay)).collect(Collectors.toList());
-                List<EquipmentAttribute> wsList = equipmentAttributeList.stream().filter(equipmentAttribute -> equipmentAttribute.getFieldName().equals(h + "awsDay")).collect(Collectors.toList());
 
                 removeByStartTimeBetweenAndEquipmentIdAndEbId(startTime, endTime, equipmentId, turList.get(0).getId());
                 for (long start1 = startHour; start1 < endHour; start1 = start1 + dayTime) {
-
+                    BigDecimal turAve = BigDecimal.ZERO;
                     long finalStart = start1;
-                    List<WindTowerCalculationData> staDay = windTowerCalculationDataList.stream().filter(w -> w.getEbId().equals(staList.get(0).getId()) && w.getTime().getTime() == finalStart).collect(Collectors.toList());
-                    List<WindTowerCalculationData> wsDay = windTowerCalculationDataList.stream().filter(w -> w.getEbId().equals(wsList.get(0).getId()) && w.getTime().getTime() == finalStart).collect(Collectors.toList());
-
-                    if (!staDay.isEmpty() && !wsDay.isEmpty()) {
+                    List<ProphaseAnemometryData> prophaseAnemometryData = anemometryDataList.stream().filter(p -> p.getTs().getTime() >= finalStart && p.getTs().getTime() < finalStart + dayTime && p.getWsAve() != null && p.getWsAve() >= 14.5 && p.getWsAve() <= 15.5 && p.getWsSta() != null && p.getWsSta() > 0).collect(Collectors.toList());
+                    if (prophaseAnemometryData.size() > 0) {
+                        BigDecimal turSum = BigDecimal.ZERO;
+                        for (ProphaseAnemometryData prophaseAnemometryDatum : prophaseAnemometryData) {
+                            turSum = turSum.add(CalculationUtil.caTurbulenceIntensity(BigDecimal.valueOf(prophaseAnemometryDatum.getWsSta()), BigDecimal.valueOf(prophaseAnemometryDatum.getWsAve())));
+                        }
+                        turAve = turSum.divide(BigDecimal.valueOf(prophaseAnemometryData.size()), 2, RoundingMode.HALF_UP);
+                    }
+                    if (anemometryDataList.size() > 0) {
 
                         //数据入库
                         WindTowerCalculationData windTowerCalculationData = new WindTowerCalculationData();
                         windTowerCalculationData.setTime(new Date(start1));
                         windTowerCalculationData.setEbId(turList.get(0).getId());
                         windTowerCalculationData.setEquipmentId(equipmentId);
-                        windTowerCalculationData.setValue(CalculationUtil.caTurbulenceIntensity(staDay.get(0).getValue(), wsDay.get(0).getValue()));
+                        windTowerCalculationData.setValue(turAve);
                         windTowerCalculationDataList.add(windTowerCalculationData);
                         list.add(windTowerCalculationData);
                     } else {
@@ -1680,17 +1683,23 @@ public class WindTowerCalculationDataServiceImpl extends ServiceImpl<WindTowerCa
                 //获取所有日平均湍流风速
                 List<WindTowerCalculationData> windTowerCalculationDatas = windTowerCalculationDataList1.stream().filter(w -> w.getEbId().equals(ebIdDay) && w.getTime().after(startHour) && w.getTime().before(endTime) && w.getEquipmentId().equals(equipmentId)).collect(Collectors.toList());
                 BigDecimal sum = new BigDecimal(0);
-
+                BigDecimal total = new BigDecimal(0);
+                BigDecimal turMonth = new BigDecimal(0);
                 for (WindTowerCalculationData w : windTowerCalculationDatas) {
-                    sum = sum.add(w.getValue());
+                    if (w.getValue().compareTo(BigDecimal.ZERO) > 0) {
+                        sum = sum.add(w.getValue());
+                        total = total.add(BigDecimal.ONE);
+                    }
+                }
+                if (total.compareTo(BigDecimal.ZERO) > 0) {
+                    turMonth = sum.divide(total, 2, RoundingMode.HALF_UP);
                 }
-
                 if (!windTowerCalculationDatas.isEmpty()) {
                     WindTowerCalculationData windTowerCalculationData = new WindTowerCalculationData();
                     windTowerCalculationData.setEbId(ebIdMonth);
                     windTowerCalculationData.setTime(startTime);
                     windTowerCalculationData.setEquipmentId(equipmentId);
-                    windTowerCalculationData.setValue(sum.divide(new BigDecimal(windTowerCalculationDatas.size()), 2, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP));
+                    windTowerCalculationData.setValue(turMonth);
                     list.add(windTowerCalculationData);
                 } else {
                     log.info("设备编号{},{}月,{}米层高月平均湍流计算失败,缺少数据^ ^", equipmentId, startTime.getMonth() + 1, h);
@@ -2502,12 +2511,12 @@ public class WindTowerCalculationDataServiceImpl extends ServiceImpl<WindTowerCa
                     //筛选小时数据
 //                    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)
-                            && p.getWsAve() != null && p.getWsAve() != -99
-                            && p.getWsSta() != null && p.getWsSta() != -99).collect(Collectors.toList());
+                            && p.getWsAve() != null && p.getWsAve() > 0
+                            && p.getWsSta() != null && p.getWsSta() > 0).collect(Collectors.toList());
 
-
-                    if (anemometryDataList.size() > 0) {
-                        BigDecimal turAve = BigDecimal.ZERO;
+                    BigDecimal turAve = BigDecimal.ZERO;
+                    List<ProphaseAnemometryData> prophaseAnemometryData = anemometryDataList.stream().filter(a -> a.getWsAve() >= 14.5 && a.getWsAve() <= 15.5).collect(Collectors.toList());
+                    if (prophaseAnemometryData.size() > 0) {
                         //循环实时数据计算总风速和标差
                         BigDecimal wsSun = CalculationUtil.getBigDecimal(anemometryDataList.stream().mapToDouble(ProphaseAnemometryData::getWsAve).sum());
                         BigDecimal staSun = CalculationUtil.getBigDecimal(anemometryDataList.stream().mapToDouble(ProphaseAnemometryData::getWsSta).sum());
@@ -2519,6 +2528,8 @@ public class WindTowerCalculationDataServiceImpl extends ServiceImpl<WindTowerCa
                             continue;
                         }
                         turAve = staAve.divide(wsAve, 2, RoundingMode.HALF_UP);
+                    }
+                    if (anemometryDataList.size() > 0) {
                         //判断map中是否存在此小时的key 如果存在就把数值相加 个数加一
                         if (timeAndTurMap.get(new Date(startHour).getHours()) != null) {
 
@@ -2526,14 +2537,16 @@ public class WindTowerCalculationDataServiceImpl extends ServiceImpl<WindTowerCa
                             BigDecimal total = totalAndTurMap.get(new Date(startHour).getHours()).add(BigDecimal.ONE);
 
                             timeAndTurMap.put(new Date(startHour).getHours(), Average);
-                            totalAndTurMap.put(new Date(startHour).getHours(), total);
+                            if (turAve.compareTo(BigDecimal.ZERO) != 0) {
+                                totalAndTurMap.put(new Date(startHour).getHours(), total);
+                            }
                         } else {
                             //如果map中不存在这个key则直接把平均值加入 个数加一
                             timeAndTurMap.put(new Date(startHour).getHours(), turAve);
                             totalAndTurMap.put(new Date(startHour).getHours(), BigDecimal.ONE);
                         }
-                    }
 
+                    }
                 }
                 if (!timeAndTurMap.entrySet().isEmpty()) {
                     SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMMdd");

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

@@ -308,7 +308,7 @@ public class CalculationUtil {
                     .add(BigDecimal.valueOf(2.152).multiply(BigDecimal.valueOf(Math.pow(10, 4)).multiply(ws)))
                     .subtract(BigDecimal.valueOf(2.153).multiply(BigDecimal.valueOf(Math.pow(10, 4)))))
                     .setScale(4, RoundingMode.HALF_UP);
-        } else if (ws.compareTo(BigDecimal.valueOf(12.5)) >= 0) {
+        } else if (ws.compareTo(BigDecimal.valueOf(12)) >= 0) {
             battery = BigDecimal.valueOf(6250);
         }
         //单个风速功率
@@ -316,6 +316,29 @@ public class CalculationUtil {
 
     }
 
+    /**
+     * 机型:WH6.25N-182
+     *
+     * @param ws 风速
+     * @return 拟合功率 BigDecimal
+     */
+    public static BigDecimal getBatteryDome(BigDecimal ws) {
+        BigDecimal battery = new BigDecimal(0);
+        if (ws.compareTo(BigDecimal.valueOf(3)) > 0 && ws.compareTo(BigDecimal.valueOf(12)) < 0) {
+            //拟合功率 = (-9.066 * e^-5 * ws^8)+ (0.01055 * ws^7) - (0.5109 * ws^6) + (13.29 * ws^5) - (200.3 * ws^4) + (1755 * ws^3) - (8549 * ws^2) + (2.152 * e^4 * ws) - (2.153 * e^4)
+            battery = BigDecimal.valueOf(0.7593).multiply(CalculationUtil.power(ws, 5))
+                    .subtract(BigDecimal.valueOf(29.67).multiply(CalculationUtil.power(ws, 4)))
+                    .add(BigDecimal.valueOf(421).multiply(CalculationUtil.power(ws, 3)))
+                    .subtract(BigDecimal.valueOf(2646).multiply(CalculationUtil.power(ws, 2)))
+                    .add(BigDecimal.valueOf(7918).multiply(ws))
+                    .subtract(BigDecimal.valueOf(8948));
+        } else if (ws.compareTo(BigDecimal.valueOf(12)) >= 0 && ws.compareTo(BigDecimal.valueOf(18)) <= 0) {
+            battery = BigDecimal.valueOf(6250);
+        }
+        //单个风速功率
+        return battery;
+
+    }
 
     /**
      * 计算威布尔值
@@ -361,10 +384,9 @@ public class CalculationUtil {
             if (maxHeight.contains("A")) {
                 continue;
             }
-            List<BigDecimal> maxHeightForWsList = prophaseAnemometryData.stream().filter(p -> p.getLayerHeight().equals(maxHeight)).map(p -> {
+            BigDecimal wsAveForMax = new BigDecimal(prophaseAnemometryData.stream().filter(p -> p.getLayerHeight().equals(maxHeight)).map(p -> {
                 return getBigDecimal(p.getWsAve());
-            }).collect(Collectors.toList());
-            BigDecimal wsAveForMax = getAvgWind(maxHeightForWsList);
+            }).collect(Collectors.averagingDouble(BigDecimal::doubleValue))).setScale(8, RoundingMode.HALF_UP);
             //筛选低层高
             List<String> heightList = new ArrayList<>(Arrays.asList(heights)).stream().filter(s -> Integer.valueOf(CalculationUtil.getNumberFromString(maxHeight)) > Integer.valueOf(CalculationUtil.getNumberFromString(s))).collect(Collectors.toList());
             //计算风切变
@@ -372,11 +394,11 @@ public class CalculationUtil {
                 if (minHeight.contains("A")) {
                     continue;
                 }
-                List<BigDecimal> minHeightForWsList = prophaseAnemometryData.stream().filter(p -> p.getLayerHeight().equals(minHeight)).map(p -> {
-                    return getBigDecimal(p.getWsAve());
-                }).collect(Collectors.toList());
                 //计算平均风速
-                BigDecimal wsAveMin = getAvgWind(minHeightForWsList);
+                BigDecimal wsAveMin = new BigDecimal(prophaseAnemometryData.stream().filter(p -> p.getLayerHeight().equals(minHeight)).map(p -> {
+                    return getBigDecimal(p.getWsAve());
+                }).collect(Collectors.averagingDouble(BigDecimal::doubleValue))).setScale(8, RoundingMode.HALF_UP);
+//                BigDecimal wsAveMin = getAvgWind(minHeightForWsList);
                 double z = new BigDecimal(getNumberFromString(maxHeight)).divide(new BigDecimal(getNumberFromString(minHeight)), 8, RoundingMode.HALF_UP).doubleValue();
                 //计算log 层高
                 double z1 = Math.log10(z);
@@ -391,7 +413,7 @@ public class CalculationUtil {
         }
 
         if (total.compareTo(BigDecimal.ZERO) != 0) {
-            sumWShear = sumWShear.divide(total, 2, RoundingMode.HALF_UP);
+            sumWShear = sumWShear.divide(total, 4, RoundingMode.HALF_UP);
         }
         return sumWShear;
     }

部分文件因文件數量過多而無法顯示