Browse Source

Merge remote-tracking branch 'origin/master'

malijun 1 year ago
parent
commit
ea3c976a7f
22 changed files with 346 additions and 217 deletions
  1. 10 0
      common/data/src/main/java/com/gyee/gaia/common/data/taos/RealtimeAverageTarget.java
  2. 1 0
      electricity/wind/build.gradle
  3. 13 0
      electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/init/CacheContext.java
  4. 71 9
      electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/job/CalcEquipPowerGenDay.java
  5. 41 0
      electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/serviceimpl/RealtimeAverageTargetServiceImpl.java
  6. 16 6
      electricity/wind/src/main/resources/bootstrap.yaml
  7. 0 119
      electricity/wind/src/test/resources/bootstrap.yaml
  8. 32 0
      realtime/wind/src/main/java/com/gyee/gaia/realtime/wind/init/CacheContext.java
  9. 30 15
      realtime/wind/src/main/java/com/gyee/gaia/realtime/wind/job/CauseJobHandler.java
  10. 3 2
      realtime/wind/src/main/java/com/gyee/gaia/realtime/wind/service/impl/RealtimeAverageTargetServiceImpl.java
  11. 2 2
      realtime/wind/src/main/resources/bootstrap.yaml
  12. 3 0
      state/cause/build.gradle
  13. 27 24
      state/cause/src/main/java/com/gyee/gaia/cause/entity/StateCause.java
  14. 17 0
      state/cause/src/main/java/com/gyee/gaia/cause/init/CacheContext.java
  15. 10 12
      state/cause/src/main/java/com/gyee/gaia/cause/job/CauseJobHandler.java
  16. 3 1
      state/cause/src/main/java/com/gyee/gaia/cause/mapper/StateCauseMapper.java
  17. 13 14
      state/cause/src/main/java/com/gyee/gaia/cause/service/CalculateService.java
  18. 4 1
      state/cause/src/main/java/com/gyee/gaia/cause/service/IStateCauseService.java
  19. 24 0
      state/cause/src/main/java/com/gyee/gaia/cause/service/impl/StateCauseServiceImpl.java
  20. 18 8
      state/cause/src/main/resources/bootstrap.yaml
  21. 1 0
      资源文件/sql/jsfw.state_cause.txt
  22. 7 4
      资源文件/sql/taossql.sql

+ 10 - 0
common/data/src/main/java/com/gyee/gaia/common/data/taos/RealtimeAverageTarget.java

@@ -32,6 +32,8 @@ public class RealtimeAverageTarget implements Serializable {
 
     private Double windDirection;
 
+    private Double theoryGeneration;
+
     private String stationId;
     private String equipmentId;
     private String uniformCode;
@@ -101,6 +103,14 @@ public class RealtimeAverageTarget implements Serializable {
         this.windDirection = windDirection;
     }
 
+    public Double getTheoryGeneration() {
+        return theoryGeneration;
+    }
+
+    public void setTheoryGeneration(Double theoryGeneration) {
+        this.theoryGeneration = theoryGeneration;
+    }
+
     public String getStationId() {
         return stationId;
     }

+ 1 - 0
electricity/wind/build.gradle

@@ -43,6 +43,7 @@ dependencies {
 
     implementation("$cloudGroup:spring-cloud-starter-openfeign")
     implementation("cn.hutool:hutool-all:5.8.18")
+    implementation("com.baomidou:dynamic-datasource-spring-boot-starter:$mybatisPlusVersion")
 }
 
 test {

+ 13 - 0
electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/init/CacheContext.java

@@ -46,6 +46,14 @@ public class CacheContext implements ApplicationRunner {
      * 风场,风机
      */
     public static Map<String, List<Equipment>> stationEquipMap;
+    /**
+     * 风机,机型
+     */
+    public static Map<String, String> equipModelMap;
+    /**
+     * 机型,风速,功率
+     */
+    public static Map<String, Map<Double, Double>> mpdsMapMap;
 
     @Override
     public void run(ApplicationArguments args) throws Exception {
@@ -58,11 +66,16 @@ public class CacheContext implements ApplicationRunner {
         List<Equipment> emList = equipmentService.list();
         equipMap = emList.stream().collect(Collectors.toMap(Equipment::getId, Function.identity()));
         stationEquipMap = emList.stream().collect(Collectors.groupingBy(Equipment::getWindpowerstationId));
+        equipModelMap = emList.stream().collect(Collectors.toMap(Equipment::getId, Equipment::getModelId));
 
         log.info("加载风场信息!");
         List<Powerstation> stationList = powerstationService.list();
         stationMap = stationList.stream().collect(Collectors.toMap(Powerstation::getId, Function.identity()));
 
+        log.info("查询风速功率匹配!");
+        List<ModelPowerDetails> mpdList = modelPowerDetailsService.list();
+        mpdsMapMap = mpdList.stream().collect(Collectors.groupingBy(ModelPowerDetails::getModelId, Collectors.toMap(ModelPowerDetails::getSpeed, ModelPowerDetails::getTheoryPower)));
+
         calcEquipPowerGenDay.calcEquipPowerGenDay();
     }
 }

+ 71 - 9
electricity/wind/src/main/java/com/gyee/gaia/electricity/wind/job/CalcEquipPowerGenDay.java

@@ -5,20 +5,30 @@ import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.gyee.gaia.common.data.point.PointData;
 import com.gyee.gaia.common.data.point.TestingPoint;
+import com.gyee.gaia.common.data.power.ModelPowerDetails;
+import com.gyee.gaia.common.data.taos.RealtimeAverageTarget;
 import com.gyee.gaia.common.data.windturbine.Equipment;
 import com.gyee.gaia.dao.sql.Windturbine.IEquipmentService;
 import com.gyee.gaia.dao.sql.point.ITestingPointService;
+import com.gyee.gaia.dao.sql.power.IModelPowerDetailsService;
+import com.gyee.gaia.dao.sql.taos.IRealtimeAverageTargetService;
 import com.gyee.gaia.electricity.wind.adapter.IAdapterApi;
 import com.gyee.gaia.electricity.wind.config.AppConfig;
 import com.gyee.gaia.electricity.wind.entity.EquipPowerGenDay;
+import com.gyee.gaia.electricity.wind.init.CacheContext;
 import com.gyee.gaia.electricity.wind.iservice.IEquipPowerGenDayService;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.stream.Collectors;
 
 @Component
 public class CalcEquipPowerGenDay {
@@ -32,6 +42,10 @@ public class CalcEquipPowerGenDay {
     @Resource
     private IEquipPowerGenDayService equipPowerGenDayService;
     @Resource
+    private IRealtimeAverageTargetService realtimeAverageTargetService;
+    @Resource
+    private IModelPowerDetailsService modelPowerDetailsService;
+    @Resource
     private AppConfig appConfig;
 
     @XxlJob("CalcEquipPowerGenDay")
@@ -46,16 +60,64 @@ public class CalcEquipPowerGenDay {
 
     }
 
-    private void calcTheoryGeneration(DateTime time1, DateTime time2) {
-        String speedUc = appConfig.getUniformcode().get("speed");
-        QueryWrapper<TestingPoint> tpWrapper = new QueryWrapper<>();
-        tpWrapper.eq("thing_type", "windturbine").eq("uniform_code", speedUc);
-        List<TestingPoint> list = testingPointService.list(tpWrapper);
-        for (TestingPoint point : list) {
-            List<PointData> historyRaw = adapter.getHistoryRaw(point.getCode(), time1.getTime(), time2.getTime());
+    /**
+     * 计算损失电量
+     */
+    private List<EquipPowerGenDay> calcLossPower(DateTime time1, DateTime time2){
 
+        return null;
+    }
+
+    /**
+     * 计算理论电量
+     */
+    private List<EquipPowerGenDay> calcTheoryGeneration(DateTime time1, DateTime time2) {
+
+        //查询1分钟平均风速
+        QueryWrapper<RealtimeAverageTarget> ratWrapper = new QueryWrapper<>();
+        ratWrapper.select("time", "wind_speed", "station_id", "equipment_id").eq("uniform_code", "1FZPJZB")
+                .between("time", time1, time2).orderByAsc("time");
+        List<RealtimeAverageTarget> ratList = realtimeAverageTargetService.list(ratWrapper);
+        Map<String, List<RealtimeAverageTarget>> ratsListMap = ratList.stream().collect(Collectors.groupingBy(RealtimeAverageTarget::getEquipmentId));
+
+        //查询日电量信息
+        QueryWrapper<EquipPowerGenDay> epgdWrapper = new QueryWrapper<>();
+        epgdWrapper.eq("date", time1);
+        List<EquipPowerGenDay> epgdList = equipPowerGenDayService.list(epgdWrapper);
+
+        Map<String, EquipPowerGenDay> sepgdMap=new HashMap<>();
+        if(epgdList.size()>0){
+            sepgdMap = epgdList.stream().collect(Collectors.toMap(EquipPowerGenDay::getFacilityId, Function.identity()));
         }
 
+        String equipId;
+        List<RealtimeAverageTarget> targets;
+        EquipPowerGenDay epgd;
+        for (Map.Entry<String, List<RealtimeAverageTarget>> ratslEntry : ratsListMap.entrySet()) {
+            equipId = ratslEntry.getKey();
+            targets = ratslEntry.getValue();
+
+            epgd = sepgdMap.get(equipId);
+            if(epgd==null) {
+                epgd = new EquipPowerGenDay();
+                epgd.setDate(time1.toLocalDateTime().toLocalDate());
+                epgd.setStation(targets.get(0).getStationId());
+                epgd.setCategory("windturbine");
+                epgd.setFacilityId(targets.get(0).getEquipmentId());
+                epgdList.add(epgd);
+            }
+            double theoryPower = targets.stream().mapToDouble(RealtimeAverageTarget::getTheoryGeneration).sum();
+            /*double theoryPower = 0;
+            for (RealtimeAverageTarget target : targets) {
+                Double power = CacheContext.mpdsMapMap.get(CacheContext.equipModelMap.get(equipId)).get(target.getWindSpeed());
+                if(power==null) {
+                    System.out.println();
+                }
+                theoryPower += power / 1000 / 60;
+            }*/
+            epgd.setGeneratingCapacity(BigDecimal.valueOf(theoryPower/1000).setScale(2, RoundingMode.HALF_UP));
+        }
+        return epgdList;
     }
 
     /**
@@ -128,19 +190,19 @@ public class CalcEquipPowerGenDay {
                 }
             }
 
-            Equipment thingId1 = equipmentService.getOne(new QueryWrapper<Equipment>().eq("nem_code", thingId));
+            //Equipment thingId1 = equipmentService.getOne(new QueryWrapper<Equipment>().eq("nem_code", thingId));
 
             EquipPowerGenDay epgd = new EquipPowerGenDay();
             epgd.setDate(time1.toLocalDateTime().toLocalDate());
             epgd.setStation(testingPoint.getStationId());
             epgd.setCategory(testingPoint.getThingType());
+            epgd.setFacilityId(testingPoint.getThingId());
             epgd.setGeneratingCapacity(rfdl);
             epgdList.add(epgd);
         }
         return epgdList;
     }
 
-
 }
 
 

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

@@ -0,0 +1,41 @@
+package com.gyee.gaia.electricity.wind.serviceimpl;
+
+import cn.hutool.core.collection.ListUtil;
+import com.baomidou.dynamic.datasource.annotation.DS;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.gaia.common.data.taos.RealtimeAverageTarget;
+import com.gyee.gaia.dao.sql.taos.IRealtimeAverageTargetService;
+import com.gyee.gaia.dao.taos.RealtimeAverageTargetMapper;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 服务实现类
+ * </p>
+ *
+ * @author gfhd
+ * @since 2023-05-18
+ */
+@DS("jsfw")
+@Service
+public class RealtimeAverageTargetServiceImpl extends ServiceImpl<RealtimeAverageTargetMapper, RealtimeAverageTarget> implements IRealtimeAverageTargetService {
+
+    public int saveBatch(List<RealtimeAverageTarget> entityList) {
+        List<List<RealtimeAverageTarget>> split = ListUtil.split(entityList, 3000);
+
+        int count = 0;
+        for (List<RealtimeAverageTarget> targets : split) {
+            StringBuilder sb = new StringBuilder();
+            for (RealtimeAverageTarget target : targets) {
+                sb.append(target.getTbname()).append(" values(").append(target.getTime().getTime())
+                        .append(",").append(target.getWindSpeed()).append(",").append(target.getPower())
+                        .append(",").append(target.getGeneratorSpeed()).append(",").append(target.getImpellerSpeed())
+                        .append(",").append(target.getWindDirection()).append(") ");
+            }
+            count += baseMapper.insert(sb.toString());
+        }
+        return count;
+    }
+}

+ 16 - 6
electricity/wind/src/main/resources/bootstrap.yaml

@@ -23,11 +23,21 @@ spring:
   cache:
     type: SIMPLE
   datasource:
-    driver-class-name: org.postgresql.Driver
-    url: jdbc:postgresql://192.168.1.67:5432/gyee
-    username: gyee
-    password: Gyee@2023!@#
-    type: com.alibaba.druid.pool.DruidDataSource
+    dynamic:
+      primary: master #设置默认的数据源或者数据源组,默认值即为master
+      strict: false #严格匹配数据源,默认false. true未匹配到指定数据源时抛异常,false使用默认数据源
+      datasource:
+        master:
+          url: jdbc:postgresql://192.168.1.67:5432/gyee
+          username: gyee
+          password: Gyee@2023!@#
+          driver-class-name: org.postgresql.Driver
+          type: com.alibaba.druid.pool.DruidDataSource
+        jsfw:
+          url: jdbc:TAOS-RS://192.168.1.67:6041/jsfw?charset=UTF-8&locale=en_US.UTF-8&timezone=UTC-8
+          username: root
+          password: taosdata
+          driver-class-name: com.taosdata.jdbc.rs.RestfulDriver
     druid:
       max-active: 20
       initial-size: 1
@@ -89,7 +99,7 @@ mybatis-plus:
     #配置JdbcTypeForNull, oracle数据库必须配置
     jdbc-type-for-null: 'null'
     callSettersOnNulls: true
-    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+    #log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
 
 xxl:
   job:

+ 0 - 119
electricity/wind/src/test/resources/bootstrap.yaml

@@ -1,119 +0,0 @@
-server:
-  port: 8321
-
-spring:
-  application:
-    name: state-cause
-  profiles:
-    # 环境配置
-    active: nx
-  cloud:
-    nacos:
-      discovery:
-        # 服务注册地址
-        server-addr: 192.168.10.18:8848
-      config:
-        # 配置中心地址
-        server-addr: 192.168.10.18:8848
-        # 配置文件格式
-        file-extension: yml
-        # 共享配置
-        shared-configs:
-          - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
-  cache:
-    type: SIMPLE
-  datasource:
-    driver-class-name: org.postgresql.Driver
-    url: jdbc:postgresql://192.168.1.67:5432/gyee
-    username: gyee
-    password: Gyee@2023!@#
-    type: com.alibaba.druid.pool.DruidDataSource
-    druid:
-      max-active: 20
-      initial-size: 1
-      min-idle: 3
-      max-wait: 60000
-      time-between-eviction-runs-millis: 60000
-      min-evictable-idle-time-millis: 300000
-      test-while-idle: true
-      test-on-borrow: false
-      test-on-return: false
-  jackson:
-    date-format: yyyy-MM-dd HH:mm:ss
-    time-zone: GMT+8
-    default-property-inclusion: always
-
-meter:
-  stations: MHS_FDC,NSS_FDC
-  adapter-url: http://192.168.10.18:8011
-  sharding-url: http://192.168.10.18:8075
-  time:
-    #小于多长时间的故障不计算在内,单位秒
-    fault-min: 180
-    #限电跳变,2次限电间隔多长时间认为是同一次限电,单位秒
-    ration: 180
-    #小于多长时间的限电不计算在内,单位秒
-    ration-min: 180
-  uniformcode:
-    #8种状态
-    state8: FJZT8
-    #桨叶角度
-    blade-angle: AI082
-    #功率-有功功率
-    active-power: AI130
-    #风速
-    speed: AI022
-  uniformcode-boost:
-    #有功设定限值
-    active-power-set: BTYGSDXZ
-    #理论功率
-    apparent-power: BTLLGL
-    #实发有功
-    output-power: BTSFYG
-
-
-mybatis-plus:
-  typeAliasesPackage: com.gyee.gaia.meter.entity
-  mapper-locations: classpath:mappers-postgresql/*.xml
-  global-config:
-    #主键类型  0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID";
-    id-type: 3
-    #字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断"
-    field-strategy: 2
-    #驼峰下划线转换
-    db-column-underline: true
-    #mp2.3+ 全局表前缀 mp_
-    #table-prefix: mp_
-    #刷新mapper 调试神器
-    #refresh-mapper: true
-    #数据库大写下划线转换
-    #capital-mode: true
-    # Sequence序列接口实现类配置
-    key-generator: com.baomidou.mybatisplus.incrementer.OracleKeyGenerator
-    #逻辑删除配置(下面3个配置)
-    logic-delete-value: 1
-    logic-not-delete-value: 0
-    #sql-injector: com.baomidou.mybatisplus.mapper.LogicSqlInjector
-    #自定义填充策略接口实现
-    #meta-object-handler: com.baomidou.springboot.MyMetaObjectHandler
-  configuration:
-    #配置返回数据库(column下划线命名&&返回java实体是驼峰命名),自动匹配无需as(没开启这个,SQL需要写as: select user_id as userId)
-    map-underscore-to-camel-case: true
-    cache-enabled: false
-    #配置JdbcTypeForNull, oracle数据库必须配置
-    jdbc-type-for-null: 'null'
-    callSettersOnNulls: true
-    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
-
-xxl:
-  job:
-    admin:
-      addresses: http://192.168.10.18:8080/xxl-job-admin
-    accessToken:
-    executor:
-      appname: meter
-      address:
-      ip:
-      port: 9021
-      logpath: d:/xxl-job/meter/logs
-      logretentiondays: 30

+ 32 - 0
realtime/wind/src/main/java/com/gyee/gaia/realtime/wind/init/CacheContext.java

@@ -1,10 +1,14 @@
 package com.gyee.gaia.realtime.wind.init;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.gyee.gaia.common.data.power.ModelPowerDetails;
+import com.gyee.gaia.common.data.taos.RealtimeAverageTarget;
 import com.gyee.gaia.common.data.windturbine.Equipment;
 import com.gyee.gaia.common.data.windturbine.Powerstation;
 import com.gyee.gaia.dao.sql.Windturbine.IEquipmentService;
 import com.gyee.gaia.dao.sql.Windturbine.IPowerstationService;
+import com.gyee.gaia.dao.sql.power.IModelPowerDetailsService;
+import com.gyee.gaia.dao.sql.taos.IRealtimeAverageTargetService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.boot.ApplicationArguments;
 import org.springframework.boot.ApplicationRunner;
@@ -38,6 +42,23 @@ public class CacheContext implements ApplicationRunner {
      * 风场,风机
      */
     public static Map<String, List<Equipment>> stationEquipMap;
+    @Resource
+    private IModelPowerDetailsService modelPowerDetailsService;
+    @Resource
+    private IRealtimeAverageTargetService realtimeAverageTargetService;
+    /**
+     * 风机,机型
+     */
+    public static Map<String, String> equipModelMap;
+    /**
+     * 机型,风速,功率
+     */
+    public static Map<String, Map<Double, Double>> mpdsMapMap;
+
+    /**
+     * 风机id,1分钟平均指标测点
+     */
+    public static Map<String, String> pjzb1fzMap;
 
     @Override
     public void run(ApplicationArguments args) throws Exception {
@@ -48,9 +69,20 @@ public class CacheContext implements ApplicationRunner {
         List<Equipment> emList = equipmentService.list(emWrapper);
         equipMap = emList.stream().collect(Collectors.toMap(Equipment::getId, Function.identity()));
         stationEquipMap = emList.stream().collect(Collectors.groupingBy(Equipment::getWindpowerstationId));
+        equipModelMap = emList.stream().collect(Collectors.toMap(Equipment::getId, Equipment::getModelId));
 
         log.info("加载风场信息!");
         List<Powerstation> stationList = powerstationService.list();
         stationMap = stationList.stream().collect(Collectors.toMap(Powerstation::getId, Function.identity()));
+
+        log.info("查询风速功率匹配!");
+        List<ModelPowerDetails> mpdList = modelPowerDetailsService.list();
+        mpdsMapMap = mpdList.stream().collect(Collectors.groupingBy(ModelPowerDetails::getModelId, Collectors.toMap(ModelPowerDetails::getSpeed, ModelPowerDetails::getTheoryPower)));
+
+        log.info("加载风机-1分钟平均指标测点!");
+        QueryWrapper<RealtimeAverageTarget> ratWrapper = new QueryWrapper<>();
+        ratWrapper.select("tbname", "equipment_id").eq("uniform_code", "1FZPJZB");
+        List<RealtimeAverageTarget> ratList = realtimeAverageTargetService.list(ratWrapper);
+        pjzb1fzMap = ratList.stream().collect(Collectors.toMap(RealtimeAverageTarget::getEquipmentId, RealtimeAverageTarget::getTbname));
     }
 }

+ 30 - 15
realtime/wind/src/main/java/com/gyee/gaia/realtime/wind/job/CauseJobHandler.java

@@ -43,7 +43,6 @@ public class CauseJobHandler implements ApplicationRunner {
      * 风机id,uniformcode,点名
      */
     private Map<String, Map<String, String>> equipUcMap = new HashMap<>();
-    private Map<String, String> pjzb1fzMap;
 
     @Override
     public void run(ApplicationArguments args) throws Exception {
@@ -104,10 +103,6 @@ public class CauseJobHandler implements ApplicationRunner {
             }
         }
         //realtimeAverageTargetService.saveBatch(rats, 3000);
-        QueryWrapper<RealtimeAverageTarget> ratWrapper = new QueryWrapper<>();
-        ratWrapper.select("tbname", "equipment_id").eq("uniform_code", "1FZPJZB");
-        List<RealtimeAverageTarget> ratList = realtimeAverageTargetService.list(ratWrapper);
-        pjzb1fzMap = ratList.stream().collect(Collectors.toMap(RealtimeAverageTarget::getEquipmentId, RealtimeAverageTarget::getTbname));
 
         pointCodes = sb.delete(0, 1).toString();
         init();
@@ -167,41 +162,61 @@ public class CauseJobHandler implements ApplicationRunner {
 
     private void calcRealtimeAverageTarget() {
 
-        String pointCode = null;
         try {
+            String pointCode = null;
+            RealtimeAverageTarget target;
+            double v;
+            //uniformcode,点名
+            Map<String, String> entryValue;
+            Map<String, String> uniformcodeOne = appConfig.getUniformcodeOne();
+            double speed;
+            Double power;
+
             while (true) {
                 if (LocalDateTime.now().getSecond() == 59) {
 
-                    RealtimeAverageTarget target;
-                    double v;
                     List<RealtimeAverageTarget> targets = new ArrayList<>();
                     for (Map.Entry<String, Map<String, String>> entry : equipUcMap.entrySet()) {
+
+                        entryValue = entry.getValue();
+
                         target = new RealtimeAverageTarget();
                         target.setTime(DateUtil.beginOfMinute(DateUtil.date()).toTimestamp());
                         //target.setEquipmentId(entry.getKey());
-                        target.setTbname(pjzb1fzMap.get(entry.getKey()));
+                        target.setTbname(CacheContext.pjzb1fzMap.get(entry.getKey()));
 
-                        pointCode = entry.getValue().get(appConfig.getUniformcodeOne().get("wind-speed"));
+                        pointCode = entryValue.get(uniformcodeOne.get("wind-speed"));
                         if (pointCode != null) {
                             v = pdaqMap.get(pointCode).stream().mapToDouble(data -> data.getDoubleValue()).average().orElse(0);
-                            target.setWindSpeed(NumberUtil.round(v, 2).doubleValue());
+                            speed = NumberUtil.round(v, 2).doubleValue();
+                            target.setWindSpeed(speed);
+                            if(speed<3) {
+                                power = Double.valueOf(0);
+                            }else {
+                                power = CacheContext.mpdsMapMap.get(CacheContext.equipModelMap.get(entry.getKey())).get(speed);
+                            }
+                            if(power==null){
+                                power = Double.valueOf(0);
+                                System.out.println(entry.getKey()+speed);
+                            }
+                            target.setTheoryGeneration(NumberUtil.round(power/60, 3).doubleValue());
                         }
-                        pointCode = entry.getValue().get(appConfig.getUniformcodeOne().get("active-power"));
+                        pointCode = entryValue.get(uniformcodeOne.get("active-power"));
                         if (pointCode != null) {
                             v = pdaqMap.get(pointCode).stream().mapToDouble(data -> data.getDoubleValue()).average().orElse(0);
                             target.setPower(NumberUtil.round(v, 2).doubleValue());
                         }
-                        pointCode = entry.getValue().get(appConfig.getUniformcodeOne().get("generator_speed"));
+                        pointCode = entryValue.get(uniformcodeOne.get("generator_speed"));
                         if (pointCode != null) {
                             v = pdaqMap.get(pointCode).stream().mapToDouble(data -> data.getDoubleValue()).average().orElse(0);
                             target.setGeneratorSpeed(NumberUtil.round(v, 2).doubleValue());
                         }
-                        pointCode = entry.getValue().get(appConfig.getUniformcodeOne().get("impeller_speed"));
+                        pointCode = entryValue.get(uniformcodeOne.get("impeller_speed"));
                         if (pointCode != null) {
                             v = pdaqMap.get(pointCode).stream().mapToDouble(data -> data.getDoubleValue()).average().orElse(0);
                             target.setImpellerSpeed(NumberUtil.round(v, 2).doubleValue());
                         }
-                        pointCode = entry.getValue().get(appConfig.getUniformcodeOne().get("wind_direction"));
+                        pointCode = entryValue.get(uniformcodeOne.get("wind_direction"));
                         if (pointCode != null) {
                             v = pdaqMap.get(pointCode).stream().mapToDouble(data -> data.getDoubleValue()).average().orElse(0);
                             target.setWindDirection(NumberUtil.round(v, 2).doubleValue());

+ 3 - 2
realtime/wind/src/main/java/com/gyee/gaia/realtime/wind/service/impl/RealtimeAverageTargetServiceImpl.java

@@ -18,7 +18,7 @@ import java.util.List;
  * @author gfhd
  * @since 2023-05-18
  */
-@DS("fjjsfw")
+@DS("jsfw")
 @Service
 public class RealtimeAverageTargetServiceImpl extends ServiceImpl<RealtimeAverageTargetMapper, RealtimeAverageTarget> implements IRealtimeAverageTargetService {
 
@@ -32,7 +32,8 @@ public class RealtimeAverageTargetServiceImpl extends ServiceImpl<RealtimeAverag
                 sb.append(target.getTbname()).append(" values(").append(target.getTime().getTime())
                         .append(",").append(target.getWindSpeed()).append(",").append(target.getPower())
                         .append(",").append(target.getGeneratorSpeed()).append(",").append(target.getImpellerSpeed())
-                        .append(",").append(target.getWindDirection()).append(") ");
+                        .append(",").append(target.getWindDirection()).append(",").append(target.getTheoryGeneration())
+                        .append(") ");
             }
             count += baseMapper.insert(sb.toString());
         }

+ 2 - 2
realtime/wind/src/main/resources/bootstrap.yaml

@@ -33,7 +33,7 @@ spring:
           password: Gyee@2023!@#
           driver-class-name: org.postgresql.Driver
           type: com.alibaba.druid.pool.DruidDataSource
-        fjjsfw:
+        jsfw:
           url: jdbc:TAOS-RS://192.168.1.67:6041/jsfw?charset=UTF-8&locale=en_US.UTF-8&timezone=UTC-8
           username: root
           password: taosdata
@@ -96,7 +96,7 @@ mybatis-plus:
     #配置JdbcTypeForNull, oracle数据库必须配置
     jdbc-type-for-null: 'null'
     callSettersOnNulls: true
-    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+    #log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
 
 xxl:
   job:

+ 3 - 0
state/cause/build.gradle

@@ -41,8 +41,11 @@ dependencies {
     implementation("com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-discovery")
     implementation("com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-config")
 
+    implementation("com.taosdata.jdbc:taos-jdbcdriver:$taosVersion2")
+
     implementation("$cloudGroup:spring-cloud-starter-openfeign")
     implementation("cn.hutool:hutool-all:5.8.18")
+    implementation("com.baomidou:dynamic-datasource-spring-boot-starter:$mybatisPlusVersion")
 }
 
 test {

+ 27 - 24
state/cause/src/main/java/com/gyee/gaia/cause/entity/StateCause.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 
 import java.io.Serializable;
+import java.sql.Timestamp;
 import java.util.Date;
 
 /**
@@ -20,18 +21,17 @@ public class StateCause implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
-    @TableId(value = "id", type = IdType.AUTO)
-    private Integer id;
+    private String tbname;
 
     /**
-     * 场站
+     * 开始时间
      */
-    private String stationId;
+    private Date startTime;
 
     /**
-     * 设备
+     * 结束时间
      */
-    private String equipmentId;
+    private Date endTime;
 
     /**
      * 事件-运行、限电、故障、受累、计划检修、待机
@@ -39,16 +39,6 @@ public class StateCause implements Serializable {
     private String event;
 
     /**
-     * 开始时间
-     */
-    private Date startTime;
-
-    /**
-     * 结束时间
-     */
-    private Date endTime;
-
-    /**
      * 事前状态
      */
     private String advanceState;
@@ -65,23 +55,36 @@ public class StateCause implements Serializable {
 
     private Long time;
 
-    public StateCause(String stationId, String equipmentId, String event, Date startTime, Date endTime, String advanceState, String afterState, Long time) {
-        this.stationId = stationId;
-        this.equipmentId = equipmentId;
+    /**
+     * 场站
+     */
+    private String stationId;
+
+    /**
+     * 设备
+     */
+    private String equipmentId;
+
+    public StateCause() {
+    }
+
+    public StateCause(String tbname, String event, Date startTime, Date endTime, String advanceState, String afterState, Long time) {
+        this.tbname = tbname;
         this.event = event;
         this.startTime = startTime;
         this.endTime = endTime;
         this.advanceState = advanceState;
         this.afterState = afterState;
         this.time = time / 1000;
+        this.userFlag = "";
     }
 
-    public Integer getId() {
-        return id;
+    public String getTbname() {
+        return tbname;
     }
 
-    public void setId(Integer id) {
-        this.id = id;
+    public void setTbname(String tbname) {
+        this.tbname = tbname;
     }
 
     public String getStationId() {
@@ -159,7 +162,7 @@ public class StateCause implements Serializable {
     @Override
     public String toString() {
         return "StateCause{" +
-                "id = " + id +
+                "tbname = " + tbname +
                 ", stationId = " + stationId +
                 ", equipmentId = " + equipmentId +
                 ", event = " + event +

+ 17 - 0
state/cause/src/main/java/com/gyee/gaia/cause/init/CacheContext.java

@@ -2,8 +2,11 @@ package com.gyee.gaia.cause.init;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.gyee.gaia.cause.config.AppConfig;
+import com.gyee.gaia.cause.entity.StateCause;
+import com.gyee.gaia.cause.service.IStateCauseService;
 import com.gyee.gaia.common.data.point.TestingPoint;
 import com.gyee.gaia.common.data.power.ModelPower;
+import com.gyee.gaia.common.data.taos.RealtimeAverageTarget;
 import com.gyee.gaia.common.data.windturbine.Booststation;
 import com.gyee.gaia.common.data.windturbine.Equipment;
 import com.gyee.gaia.common.data.windturbine.Powerstation;
@@ -41,6 +44,8 @@ public class CacheContext implements ApplicationRunner {
     @Resource
     private IPowerstationService powerstationService;
     @Resource
+    private IStateCauseService stateCauseService;
+    @Resource
     private AppConfig appConfig;
 
     public static Map<String, ModelPower> fullSpeeds;
@@ -66,6 +71,11 @@ public class CacheContext implements ApplicationRunner {
      */
     public static Map<String, List<Equipment>> stationEquipMap;
 
+    /**
+     * 风机id,五损时间测点
+     */
+    public static Map<String, String> scEquipTbMap;
+
     @Override
     public void run(ApplicationArguments args) throws Exception {
         /*log.info("加载统一编码!");
@@ -123,8 +133,15 @@ public class CacheContext implements ApplicationRunner {
                 boostStationMap.put(pj, bs);
             }
         }
+
         log.info("加载风场信息!");
         List<Powerstation> stationList = powerstationService.list();
         stationMap = stationList.stream().collect(Collectors.toMap(Powerstation::getId, Function.identity()));
+
+        log.info("加载风机-1分钟平均指标测点!");
+        QueryWrapper<StateCause> ratWrapper = new QueryWrapper<>();
+        ratWrapper.select("tbname", "equipment_id");
+        List<StateCause> ratList = stateCauseService.list(ratWrapper);
+        scEquipTbMap = ratList.stream().collect(Collectors.toMap(StateCause::getEquipmentId, StateCause::getTbname));
     }
 }

+ 10 - 12
state/cause/src/main/java/com/gyee/gaia/cause/job/CauseJobHandler.java

@@ -16,18 +16,16 @@ import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
 import java.util.Date;
+import java.util.List;
 import java.util.Map;
 
 import static com.xxl.job.core.biz.model.ReturnT.SUCCESS_CODE;
 
 
-@Order(2)
 @Component
-public class CauseJobHandler implements ApplicationRunner {
+public class CauseJobHandler {
 
     @Resource
-    private ITestingPointService testingPointService;
-    @Resource
     private IStateCauseService stateCauseService;
     @Resource
     private CalculateService calculateService;
@@ -37,20 +35,20 @@ public class CauseJobHandler implements ApplicationRunner {
         //String command = XxlJobHelper.getJobParam();
         //Map<String, String> map = JSON.parseObject(command, Map.class);
 
-        return new ReturnT(SUCCESS_CODE, "调度成功111");
+        run();
+        return new ReturnT(SUCCESS_CODE, "调度成功!");
     }
 
-    @Override
-    public void run(ApplicationArguments args) throws Exception {
+    public synchronized void run() {
         //获取最新更新时间
         QueryWrapper<StateCause> scWrapper = new QueryWrapper<>();
-        scWrapper.select("max(end_time)");
-        Map<String, Object> map = stateCauseService.getMap(scWrapper);
+        scWrapper.select("last_row(*)");
+        StateCause list = stateCauseService.getOne(scWrapper);
         Date max;
-        if (map != null && map.size() > 0) {
-            max = (Date) map.get("max");
-        } else {
+        if(list==null){
             max = DateUtil.yesterday();
+        }else {
+            max = list.getEndTime();
         }
 
         //CalculateService calculateService = new CalculateService();

+ 3 - 1
state/cause/src/main/java/com/gyee/gaia/cause/mapper/StateCauseMapper.java

@@ -2,6 +2,7 @@ package com.gyee.gaia.cause.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.gyee.gaia.cause.entity.StateCause;
+import org.apache.ibatis.annotations.Insert;
 import org.apache.ibatis.annotations.Mapper;
 
 /**
@@ -14,5 +15,6 @@ import org.apache.ibatis.annotations.Mapper;
  */
 @Mapper
 public interface StateCauseMapper extends BaseMapper<StateCause> {
-
+    @Insert("insert into ${entity}")
+    int insert(String entity);
 }

+ 13 - 14
state/cause/src/main/java/com/gyee/gaia/cause/service/CalculateService.java

@@ -58,10 +58,9 @@ public class CalculateService {
         log.info("加载升压站故障");
         List<FaultInfo> syzGz = shardingApi.getFaultInfoList("SYZ", "2023-05-10", "2023-05-13", null, null, null);
         syzGzMap = syzGz.stream().filter(fi -> fi.getAlertText().contains("位状态"))
-                .map(fi -> {
+                .peek(fi -> {
                     fi.setConfirmPerson(fi.getAlertText().substring(fi.getAlertText().indexOf("--")));
                     fi.setAlertText(fi.getAlertText().substring(0, fi.getAlertText().indexOf("--")));
-                    return fi;
                 })
                 .collect(Collectors.groupingBy(FaultInfo::getStationId));
     }
@@ -91,11 +90,11 @@ public class CalculateService {
                     LinkedHashMap<Long, Long> map = calcElectricityRation(thingId, advanceTime, ts);
                     StateCause cause;
                     for (Map.Entry<Long, Long> entry : map.entrySet()) {
-                        if (entry.getKey().equals(doubleValue)) {
-                            cause = new StateCause(thingId2StationId(thingId), thingId, stateMap.get(8.0), new Date(entry.getKey()),
+                        if (ts==entry.getKey()) {
+                            cause = new StateCause(CacheContext.scEquipTbMap.get(thingId), stateMap.get(8.0), new Date(entry.getKey()),
                                     new Date(entry.getValue()), stateMap.get(4.0), stateMap.get(doubleValue), entry.getValue() - entry.getKey());
                         } else {
-                            cause = new StateCause(thingId2StationId(thingId), thingId, stateMap.get(8.0), new Date(entry.getKey()),
+                            cause = new StateCause(CacheContext.scEquipTbMap.get(thingId), stateMap.get(8.0), new Date(entry.getKey()),
                                     new Date(entry.getValue()), stateMap.get(4.0), stateMap.get(4.0), entry.getValue() - entry.getKey());
                         }
                         stateCauseList.add(cause);
@@ -103,23 +102,23 @@ public class CalculateService {
                 } else if (advanceState == 2) {
                     //计算限停
                     if (judgmentStop(thingId, advanceTime, ts)) {
-                        StateCause cause = new StateCause(thingId2StationId(thingId), thingId, stateMap.get(8.0),
+                        StateCause cause = new StateCause(CacheContext.scEquipTbMap.get(thingId), stateMap.get(8.0),
                                 new Date(advanceTime), new Date(ts), stateMap.get(2.0), stateMap.get(doubleValue), ts - advanceTime);
                         stateCauseList.add(cause);
                     } else {
-                        StateCause cause = new StateCause(thingId2StationId(thingId), thingId, stateMap.get(2.0),
+                        StateCause cause = new StateCause(CacheContext.scEquipTbMap.get(thingId), stateMap.get(2.0),
                                 new Date(advanceTime), new Date(ts), stateMap.get(2.0), stateMap.get(doubleValue), ts - advanceTime);
                         stateCauseList.add(cause);
                     }
                 } else if (advanceState == 6) {
                     if (hasFaultEvent(thingId, advanceTime, ts)) {
                         //故障
-                        StateCause cause = new StateCause(thingId2StationId(thingId), thingId, stateMap.get(5.0),
+                        StateCause cause = new StateCause(CacheContext.scEquipTbMap.get(thingId), stateMap.get(5.0),
                                 new Date(advanceTime), new Date(ts), stateMap.get(6.0), stateMap.get(doubleValue), ts - advanceTime);
                         stateCauseList.add(cause);
                     } else {
                         //计划检修
-                        StateCause cause = new StateCause(thingId2StationId(thingId), thingId, stateMap.get(9.0),
+                        StateCause cause = new StateCause(CacheContext.scEquipTbMap.get(thingId), stateMap.get(9.0),
                                 new Date(advanceTime), new Date(ts), stateMap.get(6.0), stateMap.get(doubleValue), ts - advanceTime);
                         stateCauseList.add(cause);
                     }
@@ -132,7 +131,7 @@ public class CalculateService {
                     calcBurdened(stateCauseList, thingId, advanceTime, ts, 7, doubleValue);
                 } else if (advanceState == 0) {
                     if (ts - advanceTime < appConfig.getLongTime().get("fault-min")) continue;
-                    StateCause cause = new StateCause(thingId2StationId(thingId), thingId, stateMap.get(5.0),
+                    StateCause cause = new StateCause(CacheContext.scEquipTbMap.get(thingId), stateMap.get(5.0),
                             new Date(advanceTime), new Date(ts), stateMap.get(0.0), stateMap.get(doubleValue), ts - advanceTime);
                     stateCauseList.add(cause);
                 }
@@ -162,7 +161,7 @@ public class CalculateService {
         //有功设定
         double apsDouble = apsRbk.stream().mapToDouble(PointData::getDoubleValue).average().getAsDouble() * (apsTp.getRate() == null ? 1 : apsTp.getRate());
         //应发功率
-        double apDouble = 0;
+        double apDouble;
         if (boostStation.getId().contains("QS")) {
             TestingPoint apTp2 = CacheContext.pointMapMap.get("apparent-power").get(boostStation.getId() + "2");
             List<PointData> apRbk2 = adapterApi.getValuesByKey(apTp2.getCode(), start, end, 30);
@@ -350,12 +349,12 @@ public class CalculateService {
         }
         if (k / size > 9.5) {
             //受累
-            StateCause cause = new StateCause(stationId, thingId, stateMap.get(10.0), new Date(start), new Date(end),
+            StateCause cause = new StateCause(CacheContext.scEquipTbMap.get(thingId), stateMap.get(10.0), new Date(start), new Date(end),
                     stateMap.get(starteventstate), stateMap.get(endeventstate), end - start);
             stateCauseList.add(cause);
         } else {//if(starteventstate==5 || isHasFaultEvent(thingId,start,end)){
             //故障
-            StateCause cause = new StateCause(stationId, thingId, stateMap.get(5.0), new Date(start), new Date(end),
+            StateCause cause = new StateCause(CacheContext.scEquipTbMap.get(thingId), stateMap.get(5.0), new Date(start), new Date(end),
                     stateMap.get(starteventstate), stateMap.get(endeventstate), end - start);
             stateCauseList.add(cause);
         }/*else {
@@ -432,7 +431,7 @@ public class CalculateService {
         }
         //限电跳变处理
         long t0 = 0;
-        long t1 = 0;
+        long t1;
         long tstart = 0;
         long tend = 0;
         LinkedHashMap<Long, Long> llm2 = new LinkedHashMap<>();

+ 4 - 1
state/cause/src/main/java/com/gyee/gaia/cause/service/IStateCauseService.java

@@ -2,6 +2,9 @@ package com.gyee.gaia.cause.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.gyee.gaia.cause.entity.StateCause;
+import com.gyee.gaia.common.data.taos.RealtimeAverageTarget;
+
+import java.util.List;
 
 /**
  * <p>
@@ -12,5 +15,5 @@ import com.gyee.gaia.cause.entity.StateCause;
  * @since 2023-05-04
  */
 public interface IStateCauseService extends IService<StateCause> {
-
+    int saveBatch(List<StateCause> entityList);
 }

+ 24 - 0
state/cause/src/main/java/com/gyee/gaia/cause/service/impl/StateCauseServiceImpl.java

@@ -1,11 +1,17 @@
 package com.gyee.gaia.cause.service.impl;
 
+import cn.hutool.core.collection.ListUtil;
+import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.gyee.gaia.cause.entity.StateCause;
 import com.gyee.gaia.cause.mapper.StateCauseMapper;
 import com.gyee.gaia.cause.service.IStateCauseService;
+import com.gyee.gaia.common.data.taos.RealtimeAverageTarget;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.sql.DataSourceDefinition;
+import java.util.List;
+
 /**
  * <p>
  * 服务实现类
@@ -14,7 +20,25 @@ import org.springframework.stereotype.Service;
  * @author gfhd
  * @since 2023-05-04
  */
+@DS("jsfw")
 @Service
 public class StateCauseServiceImpl extends ServiceImpl<StateCauseMapper, StateCause> implements IStateCauseService {
 
+    public int saveBatch(List<StateCause> entityList) {
+        List<List<StateCause>> split = ListUtil.split(entityList, 3000);
+
+        int count = 0;
+        for (List<StateCause> targets : split) {
+            StringBuilder sb = new StringBuilder();
+            for (StateCause target : targets) {
+                sb.append(target.getTbname()).append(" values(").append(target.getStartTime().getTime())
+                        .append(",").append(target.getEndTime().getTime()).append(",'").append(target.getEvent())
+                        .append("','").append(target.getAdvanceState()).append("','").append(target.getAfterState())
+                        .append("','").append(target.getUserFlag()).append("',").append(target.getTime())
+                        .append(") ");
+            }
+            count += baseMapper.insert(sb.toString());
+        }
+        return count;
+    }
 }

+ 18 - 8
state/cause/src/main/resources/bootstrap.yaml

@@ -23,11 +23,21 @@ spring:
   cache:
     type: SIMPLE
   datasource:
-    driver-class-name: org.postgresql.Driver
-    url: jdbc:postgresql://192.168.1.67:5432/gyee
-    username: gyee
-    password: Gyee@2023!@#
-    type: com.alibaba.druid.pool.DruidDataSource
+    dynamic:
+      primary: master #设置默认的数据源或者数据源组,默认值即为master
+      strict: false #严格匹配数据源,默认false. true未匹配到指定数据源时抛异常,false使用默认数据源
+      datasource:
+        master:
+          url: jdbc:postgresql://192.168.1.67:5432/gyee
+          username: gyee
+          password: Gyee@2023!@#
+          driver-class-name: org.postgresql.Driver
+          type: com.alibaba.druid.pool.DruidDataSource
+        jsfw:
+          url: jdbc:TAOS-RS://192.168.1.67:6041/jsfw?charset=UTF-8&locale=en_US.UTF-8&timezone=UTC-8
+          username: root
+          password: taosdata
+          driver-class-name: com.taosdata.jdbc.rs.RestfulDriver
     druid:
       max-active: 20
       initial-size: 1
@@ -103,7 +113,7 @@ mybatis-plus:
     #配置JdbcTypeForNull, oracle数据库必须配置
     jdbc-type-for-null: 'null'
     callSettersOnNulls: true
-    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+    #log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
 
 xxl:
   job:
@@ -111,9 +121,9 @@ xxl:
       addresses: http://192.168.10.18:8080/xxl-job-admin
     accessToken:
     executor:
-      appname: meter
+      appname: state-cause
       address:
       ip:
       port: 9021
-      logpath: d:/xxl-job/meter/logs
+      logpath: d:/xxl-job/statecause/logs
       logretentiondays: 30

File diff suppressed because it is too large
+ 1 - 0
资源文件/sql/jsfw.state_cause.txt


+ 7 - 4
资源文件/sql/taossql.sql

@@ -2,14 +2,13 @@ CREATE DATABASE IF NOT EXISTS fjjsfw UPDATE 2 cacheLast 1
 
 DROP DATABASE fjjsfw;
 CREATE DATABASE IF NOT EXISTS jsfw UPDATE 2 cacheLast 1
-CREATE
-STABLE IF NOT EXISTS jsfw.realtime_average_target
-(time TIMESTAMP, wind_speed FLOAT, power FLOAT, generator_speed FLOAT, impeller_speed FLOAT, wind_direction FLOAT)
+CREATE STABLE IF NOT EXISTS jsfw.realtime_average_target
+(time TIMESTAMP, wind_speed FLOAT, power FLOAT, generator_speed FLOAT, impeller_speed FLOAT, wind_direction FLOAT, theory_generation FLOAT)
 TAGS (station_id BINARY(30),equipment_id BINARY(30),uniform_code BINARY(20), description NCHAR(50))
 CREATE TABLE realtime_average_target.USING realtime_average_target TAGS
 (,
 );
-
+ALTER STABLE jsfw.realtime_average_target ADD COLUMN theory_generation FLOAT;
 
 
 CREATE TABLE IF NOT EXISTS fjjsfw.realtime_average_target
@@ -22,3 +21,7 @@ CREATE TABLE IF NOT EXISTS fjjsfw.realtime_average_target
     impeller_speed  FLOAT,
     wind_direction  FLOAT
 );
+
+CREATE STABLE IF NOT EXISTS jsfw.state_cause
+(start_time TIMESTAMP, end_time TIMESTAMP, event NCHAR(30), advance_state NCHAR(30), after_state NCHAR(30), user_flag NCHAR(30), time INT UNSIGNED)
+TAGS (station_id BINARY(30),equipment_id BINARY(30))