Browse Source

增加计算测点

chenminghua 1 year ago
parent
commit
c4757f8924

+ 36 - 108
common/data/src/main/java/com/gyee/gaia/common/data/taos/RealtimeAverageTarget.java

@@ -1,6 +1,7 @@
 package com.gyee.gaia.common.data.taos;
 package com.gyee.gaia.common.data.taos;
 
 
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
 
 
 import java.io.Serializable;
 import java.io.Serializable;
 import java.sql.Timestamp;
 import java.sql.Timestamp;
@@ -13,6 +14,7 @@ import java.sql.Timestamp;
  * @author gfhd
  * @author gfhd
  * @since 2023-05-18
  * @since 2023-05-18
  */
  */
+@Data
 @TableName("realtime_average_target")
 @TableName("realtime_average_target")
 public class RealtimeAverageTarget implements Serializable {
 public class RealtimeAverageTarget implements Serializable {
 
 
@@ -22,128 +24,54 @@ public class RealtimeAverageTarget implements Serializable {
 
 
     private Timestamp time;
     private Timestamp time;
 
 
+    /**
+     * 平均风速
+     */
     private Float windSpeed;
     private Float windSpeed;
 
 
+    /**
+     * 实际功率
+     */
     private Float power;
     private Float power;
 
 
+    /**
+     * 发电机转速
+     */
     private Float generatorSpeed;
     private Float generatorSpeed;
 
 
+    /**
+     * 叶轮转速
+     */
     private Float impellerSpeed;
     private Float impellerSpeed;
 
 
+    /**
+     * 风向
+     */
     private Float windDirection;
     private Float windDirection;
 
 
+    /**
+     * 理论发电量
+     */
     private Float theoryGeneration;
     private Float theoryGeneration;
 
 
+    /**
+     * 桨叶角度
+     */
+    private Float bladeAngle;
+
+    /**
+     * 机舱方向
+     */
+    private Float engineDirection;
+
+    /**
+     * 对风误差
+     */
+    private Float windDeviation;
+
+
     private String stationId;
     private String stationId;
     private String equipmentId;
     private String equipmentId;
     private String uniformCode;
     private String uniformCode;
     private String description;
     private String description;
-
-    public String getTbname() {
-        return tbname;
-    }
-
-    public void setTbname(String tbname) {
-        this.tbname = tbname;
-    }
-
-    public Timestamp getTime() {
-        return time;
-    }
-
-    public void setTime(Timestamp time) {
-        this.time = time;
-    }
-
-    public String getEquipmentId() {
-        return equipmentId;
-    }
-
-    public void setEquipmentId(String equipmentId) {
-        this.equipmentId = equipmentId;
-    }
-
-    public Float getWindSpeed() {
-        return windSpeed;
-    }
-
-    public void setWindSpeed(Float windSpeed) {
-        this.windSpeed = windSpeed;
-    }
-
-    public Float getPower() {
-        return power;
-    }
-
-    public void setPower(Float power) {
-        this.power = power;
-    }
-
-    public Float getGeneratorSpeed() {
-        return generatorSpeed;
-    }
-
-    public void setGeneratorSpeed(Float generatorSpeed) {
-        this.generatorSpeed = generatorSpeed;
-    }
-
-    public Float getImpellerSpeed() {
-        return impellerSpeed;
-    }
-
-    public void setImpellerSpeed(Float impellerSpeed) {
-        this.impellerSpeed = impellerSpeed;
-    }
-
-    public Float getWindDirection() {
-        return windDirection;
-    }
-
-    public void setWindDirection(Float windDirection) {
-        this.windDirection = windDirection;
-    }
-
-    public Float getTheoryGeneration() {
-        return theoryGeneration;
-    }
-
-    public void setTheoryGeneration(Float theoryGeneration) {
-        this.theoryGeneration = theoryGeneration;
-    }
-
-    public String getStationId() {
-        return stationId;
-    }
-
-    public void setStationId(String stationId) {
-        this.stationId = stationId;
-    }
-
-    public String getUniformCode() {
-        return uniformCode;
-    }
-
-    public void setUniformCode(String uniformCode) {
-        this.uniformCode = uniformCode;
-    }
-
-    public String getDescription() {
-        return description;
-    }
-
-    public void setDescription(String description) {
-        this.description = description;
-    }
-
-    @Override
-    public String toString() {
-        return "RealtimeAverageTarget{" +
-                "time = " + time +
-                ", equipmentId = " + equipmentId +
-                ", windSpeed = " + windSpeed +
-                ", generatorSpeed = " + generatorSpeed +
-                ", impellerSpeed = " + impellerSpeed +
-                ", windDirection = " + windDirection +
-                "}";
-    }
 }
 }

+ 1 - 0
electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/serviceimpl/RealtimeAverageTargetServiceImpl.java

@@ -22,6 +22,7 @@ import java.util.List;
 @Service
 @Service
 public class RealtimeAverageTargetServiceImpl extends ServiceImpl<RealtimeAverageTargetMapper, RealtimeAverageTarget> implements IRealtimeAverageTargetService {
 public class RealtimeAverageTargetServiceImpl extends ServiceImpl<RealtimeAverageTargetMapper, RealtimeAverageTarget> implements IRealtimeAverageTargetService {
 
 
+    @Override
     public int saveBatch(List<RealtimeAverageTarget> entityList) {
     public int saveBatch(List<RealtimeAverageTarget> entityList) {
         List<List<RealtimeAverageTarget>> split = ListUtil.split(entityList, 3000);
         List<List<RealtimeAverageTarget>> split = ListUtil.split(entityList, 3000);
         int count = 0;
         int count = 0;

+ 18 - 6
realtime/wind/src/main/java/com/gyee/gaia/realtime/wind/job/CauseJobHandler.java

@@ -83,6 +83,9 @@ public class CauseJobHandler implements ApplicationRunner {
         }
         }
     }
     }
 
 
+    /**
+     * 计算常用测点的1分钟平均数据
+     */
     @Scheduled(fixedRate = 60000)
     @Scheduled(fixedRate = 60000)
     private void calcRealtimeAverageTarget() {
     private void calcRealtimeAverageTarget() {
 
 
@@ -126,12 +129,6 @@ public class CauseJobHandler implements ApplicationRunner {
                     if (speed < 3) {
                     if (speed < 3) {
                         power = 0.0;
                         power = 0.0;
                     } else {
                     } else {
-                        /*Map<Double, Double> map = CacheContext.powerModelMap.get(entry.getKey());
-                        if (map != null && map.size() > 0) {
-                            power = map.get(speed);
-                        } else {
-                            power = CacheContext.mpdsMapMap.get(CacheContext.equipModelMap.get(entry.getKey())).get(speed);
-                        }*/
                         power = CacheContext.mpdsMapMap.get(CacheContext.equipModelMap.get(entry.getKey())).get(speed);
                         power = CacheContext.mpdsMapMap.get(CacheContext.equipModelMap.get(entry.getKey())).get(speed);
                     }
                     }
                     if (power == null) power = 0.0;
                     if (power == null) power = 0.0;
@@ -157,6 +154,21 @@ public class CauseJobHandler implements ApplicationRunner {
                     v = pdaqMap.get(pointCode).stream().mapToDouble(PointData::getDoubleValue).average().orElse(0);
                     v = pdaqMap.get(pointCode).stream().mapToDouble(PointData::getDoubleValue).average().orElse(0);
                     target.setWindDirection(NumberUtil.round(v, 2).floatValue());
                     target.setWindDirection(NumberUtil.round(v, 2).floatValue());
                 }
                 }
+                pointCode = entryValue.get(uniformcodeOne.get("blade_angle"));
+                if (pointCode != null) {
+                    v = pdaqMap.get(pointCode).stream().mapToDouble(PointData::getDoubleValue).average().orElse(0);
+                    target.setBladeAngle(NumberUtil.round(v, 2).floatValue());
+                }
+                pointCode = entryValue.get(uniformcodeOne.get("engine_direction"));
+                if (pointCode != null) {
+                    v = pdaqMap.get(pointCode).stream().mapToDouble(PointData::getDoubleValue).average().orElse(0);
+                    target.setEngineDirection(NumberUtil.round(v, 2).floatValue());
+                }
+                pointCode = entryValue.get(uniformcodeOne.get("wind_deviation"));
+                if (pointCode != null) {
+                    v = pdaqMap.get(pointCode).stream().mapToDouble(PointData::getDoubleValue).average().orElse(0);
+                    target.setWindDeviation(NumberUtil.round(v, 2).floatValue());
+                }
                 targets.add(target);
                 targets.add(target);
             }
             }
             targets = targets.stream().peek(t -> {
             targets = targets.stream().peek(t -> {

+ 17 - 17
realtime/wind/src/main/java/com/gyee/gaia/realtime/wind/job/DataFillJobHandler.java

@@ -33,9 +33,9 @@ public class DataFillJobHandler {
     private AppConfig appConfig;
     private AppConfig appConfig;
 
 
     /**
     /**
+     * 计算常用测点的1分钟平均数据
      * 风机id,uniformcode,平均数据
      * 风机id,uniformcode,平均数据
      */
      */
-    //private Map<String, Map<String, List<PointData>>> dsdlssMap;
 
 
     @XxlJob("DataFilling")
     @XxlJob("DataFilling")
     public void calcEquipPowerGenDay() {
     public void calcEquipPowerGenDay() {
@@ -56,8 +56,6 @@ public class DataFillJobHandler {
             endDate = DateUtil.parse(end);
             endDate = DateUtil.parse(end);
         }
         }
 
 
-        //getDatas(startDate.getTime(), endDate.getTime());
-
         List<RealtimeAverageTarget> realtimeAverageTargetList = new ArrayList<>();
         List<RealtimeAverageTarget> realtimeAverageTargetList = new ArrayList<>();
         QueryWrapper<RealtimeAverageTarget> ratWrapper = new QueryWrapper<>();
         QueryWrapper<RealtimeAverageTarget> ratWrapper = new QueryWrapper<>();
         ratWrapper.select("tbname", "time", "station_id", "equipment_id").eq("uniform_code", "1FZPJZB")
         ratWrapper.select("tbname", "time", "station_id", "equipment_id").eq("uniform_code", "1FZPJZB")
@@ -76,7 +74,6 @@ public class DataFillJobHandler {
                     List<PointData> rawByKey = adapterApi.getRawByKey(point, startDate.getTime(), endDate.getTime());
                     List<PointData> rawByKey = adapterApi.getRawByKey(point, startDate.getTime(), endDate.getTime());
                     lpdsMap.put(uc, rawByKey);
                     lpdsMap.put(uc, rawByKey);
                 });
                 });
-                int i = 0;
                 for (DateTime minute = DateUtil.beginOfMinute(startDate); minute.isBefore(endDate); minute.offset(DateField.MINUTE, 1)) {
                 for (DateTime minute = DateUtil.beginOfMinute(startDate); minute.isBefore(endDate); minute.offset(DateField.MINUTE, 1)) {
                     RealtimeAverageTarget rat = new RealtimeAverageTarget();
                     RealtimeAverageTarget rat = new RealtimeAverageTarget();
                     rat.setTime(new Timestamp(minute.getTime()));
                     rat.setTime(new Timestamp(minute.getTime()));
@@ -84,7 +81,6 @@ public class DataFillJobHandler {
                     setRats(rat, equipmentId, minute.getTime(), minute.getTime() + 59999L, lpdsMap);
                     setRats(rat, equipmentId, minute.getTime(), minute.getTime() + 59999L, lpdsMap);
                     realtimeAverageTargetList.add(rat);
                     realtimeAverageTargetList.add(rat);
                 }
                 }
-
             }
             }
         }else {
         }else {
             //按风机分组
             //按风机分组
@@ -116,18 +112,7 @@ public class DataFillJobHandler {
 
 
         realtimeAverageTargetService.saveBatch(realtimeAverageTargetList);
         realtimeAverageTargetService.saveBatch(realtimeAverageTargetList);
     }
     }
-/*
-    private void getDatas(long time1, long time2) {
-        dsdlssMap = new HashMap<>();
-        CacheContext.equipUcMap.forEach((equipId, ucode) -> {
-            Map<String, List<PointData>> map = new HashMap<>();
-            ucode.forEach((uc, point) -> {
-                List<PointData> rawByKey = adapterApi.getRawByKey(point, time1, time2);
-                map.put(uc, rawByKey);
-            });
-            dsdlssMap.put(equipId, map);
-        });
-    }*/
+
 
 
     private void setRats(RealtimeAverageTarget rat, String equipId, long time1, long time2, Map<String, List<PointData>> lpdsMap) {
     private void setRats(RealtimeAverageTarget rat, String equipId, long time1, long time2, Map<String, List<PointData>> lpdsMap) {
 
 
@@ -136,12 +121,18 @@ public class DataFillJobHandler {
         List<PointData> generator_speeds = lpdsMap.get(appConfig.getUniformcodeOne().get("generator_speed"));
         List<PointData> generator_speeds = lpdsMap.get(appConfig.getUniformcodeOne().get("generator_speed"));
         List<PointData> impeller_speeds = lpdsMap.get(appConfig.getUniformcodeOne().get("impeller_speed"));
         List<PointData> impeller_speeds = lpdsMap.get(appConfig.getUniformcodeOne().get("impeller_speed"));
         List<PointData> wind_directions = lpdsMap.get(appConfig.getUniformcodeOne().get("wind_direction"));
         List<PointData> wind_directions = lpdsMap.get(appConfig.getUniformcodeOne().get("wind_direction"));
+        List<PointData> blade_angle = lpdsMap.get(appConfig.getUniformcodeOne().get("blade_angle"));
+        List<PointData> engine_direction = lpdsMap.get(appConfig.getUniformcodeOne().get("engine_direction"));
+        List<PointData> wind_deviation = lpdsMap.get(appConfig.getUniformcodeOne().get("wind_deviation"));
 
 
         double wsdv = 0;
         double wsdv = 0;
         double apdv = 0;
         double apdv = 0;
         double gsdv = 0;
         double gsdv = 0;
         double isdv = 0;
         double isdv = 0;
         double wddv = 0;
         double wddv = 0;
+        double badv = 0;
+        double eddv = 0;
+        double wtdv = 0;
 
 
         if (wind_speeds != null && wind_speeds.size() > 0)
         if (wind_speeds != null && wind_speeds.size() > 0)
             wsdv = wind_speeds.stream().filter(pd -> pd.getTs() >= time1 && pd.getTs() <= time2).mapToDouble(PointData::getDoubleValue).average().orElse(0);
             wsdv = wind_speeds.stream().filter(pd -> pd.getTs() >= time1 && pd.getTs() <= time2).mapToDouble(PointData::getDoubleValue).average().orElse(0);
@@ -153,6 +144,12 @@ public class DataFillJobHandler {
             isdv = impeller_speeds.stream().filter(pd -> pd.getTs() >= time1 && pd.getTs() <= time2).mapToDouble(PointData::getDoubleValue).average().orElse(0);
             isdv = impeller_speeds.stream().filter(pd -> pd.getTs() >= time1 && pd.getTs() <= time2).mapToDouble(PointData::getDoubleValue).average().orElse(0);
         if (wind_directions != null && wind_directions.size() > 0)
         if (wind_directions != null && wind_directions.size() > 0)
             wddv = wind_directions.stream().filter(pd -> pd.getTs() >= time1 && pd.getTs() <= time2).mapToDouble(PointData::getDoubleValue).average().orElse(0);
             wddv = wind_directions.stream().filter(pd -> pd.getTs() >= time1 && pd.getTs() <= time2).mapToDouble(PointData::getDoubleValue).average().orElse(0);
+        if (blade_angle != null && blade_angle.size() > 0)
+            badv = blade_angle.stream().filter(pd -> pd.getTs() >= time1 && pd.getTs() <= time2).mapToDouble(PointData::getDoubleValue).average().orElse(0);
+        if (engine_direction != null && engine_direction.size() > 0)
+            eddv = engine_direction.stream().filter(pd -> pd.getTs() >= time1 && pd.getTs() <= time2).mapToDouble(PointData::getDoubleValue).average().orElse(0);
+        if (wind_deviation != null && wind_deviation.size() > 0)
+            wtdv = wind_deviation.stream().filter(pd -> pd.getTs() >= time1 && pd.getTs() <= time2).mapToDouble(PointData::getDoubleValue).average().orElse(0);
 
 
         double speed = NumberUtil.round(wsdv, 2).doubleValue();
         double speed = NumberUtil.round(wsdv, 2).doubleValue();
 
 
@@ -161,6 +158,9 @@ public class DataFillJobHandler {
         rat.setGeneratorSpeed(NumberUtil.round(gsdv, 2).floatValue());
         rat.setGeneratorSpeed(NumberUtil.round(gsdv, 2).floatValue());
         rat.setImpellerSpeed(NumberUtil.round(isdv, 2).floatValue());
         rat.setImpellerSpeed(NumberUtil.round(isdv, 2).floatValue());
         rat.setWindDirection(NumberUtil.round(wddv, 2).floatValue());
         rat.setWindDirection(NumberUtil.round(wddv, 2).floatValue());
+        rat.setBladeAngle(NumberUtil.round(badv, 2).floatValue());
+        rat.setEngineDirection(NumberUtil.round(eddv, 2).floatValue());
+        rat.setWindDeviation(NumberUtil.round(wtdv, 2).floatValue());
         if (speed < 3) {
         if (speed < 3) {
             rat.setTheoryGeneration(0f);
             rat.setTheoryGeneration(0f);
         } else {
         } else {

+ 1 - 0
realtime/wind/src/main/java/com/gyee/gaia/realtime/wind/service/impl/RealtimeAverageTargetServiceImpl.java

@@ -22,6 +22,7 @@ import java.util.List;
 @Service
 @Service
 public class RealtimeAverageTargetServiceImpl extends ServiceImpl<RealtimeAverageTargetMapper, RealtimeAverageTarget> implements IRealtimeAverageTargetService {
 public class RealtimeAverageTargetServiceImpl extends ServiceImpl<RealtimeAverageTargetMapper, RealtimeAverageTarget> implements IRealtimeAverageTargetService {
 
 
+    @Override
     public int saveBatch(List<RealtimeAverageTarget> entityList) {
     public int saveBatch(List<RealtimeAverageTarget> entityList) {
         List<List<RealtimeAverageTarget>> split = ListUtil.split(entityList, 3000);
         List<List<RealtimeAverageTarget>> split = ListUtil.split(entityList, 3000);
 
 

+ 3 - 0
realtime/wind/src/main/resources/bootstrap.yaml

@@ -63,6 +63,9 @@ meter:
     generator_speed: AI128  #发电机转速
     generator_speed: AI128  #发电机转速
     impeller_speed: AI012  #叶轮转速
     impeller_speed: AI012  #叶轮转速
     wind_direction: AI010  #风向
     wind_direction: AI010  #风向
+    blade_angle: AI085  #桨叶角度
+    engine_direction: AI034  #机舱方向
+    wind_deviation: AI036  #对风误差
 
 
 
 
 mybatis-plus:
 mybatis-plus: