Przeglądaj źródła

中环scada增加激活状态处理

欧阳劲驰 2 tygodni temu
rodzic
commit
919cdd23fb

+ 1 - 1
bespoke-gateway-app/src/main/resources/application-jldma.yml

@@ -30,5 +30,5 @@ calling:
 #任务
 scheduling:
   activates:
-    collect-iot-platform: off
     sync-devices: off
+    collect-iot-platform: off

+ 6 - 0
bespoke-gateway-app/src/main/resources/application-zhscada.yml

@@ -31,6 +31,12 @@ calling:
   endpoints:
     zhonghuan-scada:
       url: http://119.96.174.191:9434
+#任务
+scheduling:
+  activates:
+    sync-device-tags: off
+    collect-scada: off
+    migrate-scada: off
 #迁移
 migrate:
   #模式

+ 18 - 0
bespoke-gateway-zhscada/src/main/java/com/shkpr/service/bespokegateway/zhscada/constants/ScadaPlatformMetadata.java

@@ -71,4 +71,22 @@ public abstract class ScadaPlatformMetadata {
         //区号
         AreaCode AREA_CODE = AreaCode.ZAO_YANG;
     }
+
+    /**
+     * 任务key
+     */
+    public interface SchedulingKeys {
+        /**
+         * 同步设备标签
+         */
+        String SYNC_DEVICE_TAGS = "sync-device-tags";
+        /**
+         * 采集scada
+         */
+        String COLLECT_SCADA =  "collect-scada";
+        /**
+         * 合并scada
+         */
+        String MIGRATE_SCADA = "migrate-scada";
+    }
 }

+ 10 - 3
bespoke-gateway-zhscada/src/main/java/com/shkpr/service/bespokegateway/zhscada/manager/DataCollectManager.java

@@ -1,7 +1,9 @@
 package com.shkpr.service.bespokegateway.zhscada.manager;
 
 
+import com.shkpr.service.bespokegateway.core.properties.SchedulingProperties;
 import com.shkpr.service.bespokegateway.zhscada.components.DataCollector;
+import com.shkpr.service.bespokegateway.zhscada.constants.ScadaPlatformMetadata;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 import org.springframework.stereotype.Component;
@@ -17,11 +19,14 @@ import javax.annotation.PostConstruct;
 @Component
 public class DataCollectManager {
     final
+    SchedulingProperties schedulingProperties;
+    final
     ThreadPoolTaskExecutor taskScheduler;
     final
     DataCollector dataCollector;
 
-    public DataCollectManager(ThreadPoolTaskExecutor taskScheduler, DataCollector dataCollector) {
+    public DataCollectManager(SchedulingProperties schedulingProperties, ThreadPoolTaskExecutor taskScheduler, DataCollector dataCollector) {
+        this.schedulingProperties = schedulingProperties;
         this.taskScheduler = taskScheduler;
         this.dataCollector = dataCollector;
     }
@@ -32,7 +37,8 @@ public class DataCollectManager {
     @PostConstruct
     public void init() {
         //采集实时数据
-        taskScheduler.execute(dataCollector::collectScada);
+        if (schedulingProperties.isTaskActive(ScadaPlatformMetadata.SchedulingKeys.COLLECT_SCADA))
+            taskScheduler.execute(dataCollector::collectScada);
     }
 
     /**
@@ -41,6 +47,7 @@ public class DataCollectManager {
     @Scheduled(cron = "0 * * * * ?")
     public void minuteTask() {
         //采集实时数据
-        taskScheduler.execute(dataCollector::collectScada);
+        if (schedulingProperties.isTaskActive(ScadaPlatformMetadata.SchedulingKeys.COLLECT_SCADA))
+            taskScheduler.execute(dataCollector::collectScada);
     }
 }

+ 8 - 2
bespoke-gateway-zhscada/src/main/java/com/shkpr/service/bespokegateway/zhscada/manager/DataMigrateManager.java

@@ -1,6 +1,8 @@
 package com.shkpr.service.bespokegateway.zhscada.manager;
 
+import com.shkpr.service.bespokegateway.core.properties.SchedulingProperties;
 import com.shkpr.service.bespokegateway.zhscada.components.DataMigrator;
+import com.shkpr.service.bespokegateway.zhscada.constants.ScadaPlatformMetadata;
 import com.shkpr.service.bespokegateway.zhscada.properties.MigrateProperties;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
@@ -18,11 +20,14 @@ import javax.annotation.PostConstruct;
 @EnableConfigurationProperties(MigrateProperties.class)
 public class DataMigrateManager {
     final
+    SchedulingProperties schedulingProperties;
+    final
     ThreadPoolTaskExecutor taskScheduler;
     final
     DataMigrator dataMigrator;
 
-    public DataMigrateManager(ThreadPoolTaskExecutor taskScheduler, DataMigrator dataMigrator) {
+    public DataMigrateManager(SchedulingProperties schedulingProperties, ThreadPoolTaskExecutor taskScheduler, DataMigrator dataMigrator) {
+        this.schedulingProperties = schedulingProperties;
         this.taskScheduler = taskScheduler;
         this.dataMigrator = dataMigrator;
     }
@@ -33,6 +38,7 @@ public class DataMigrateManager {
     @PostConstruct
     public void init() {
         //迁移scada
-//        taskScheduler.execute(dataMigrator::migrateScada);
+        if (schedulingProperties.isTaskActive(ScadaPlatformMetadata.SchedulingKeys.MIGRATE_SCADA))
+            taskScheduler.execute(dataMigrator::migrateScada);
     }
 }

+ 10 - 3
bespoke-gateway-zhscada/src/main/java/com/shkpr/service/bespokegateway/zhscada/manager/InfoSyncManager.java

@@ -1,6 +1,8 @@
 package com.shkpr.service.bespokegateway.zhscada.manager;
 
+import com.shkpr.service.bespokegateway.core.properties.SchedulingProperties;
 import com.shkpr.service.bespokegateway.zhscada.components.InfoSynchronizer;
+import com.shkpr.service.bespokegateway.zhscada.constants.ScadaPlatformMetadata;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 import org.springframework.stereotype.Component;
@@ -16,11 +18,14 @@ import javax.annotation.PostConstruct;
 @Component
 public class InfoSyncManager {
     final
+    SchedulingProperties schedulingProperties;
+    final
     ThreadPoolTaskExecutor taskScheduler;
     final
     InfoSynchronizer infoSynchronizer;
 
-    public InfoSyncManager(ThreadPoolTaskExecutor taskScheduler, InfoSynchronizer infoSynchronizer) {
+    public InfoSyncManager(SchedulingProperties schedulingProperties, ThreadPoolTaskExecutor taskScheduler, InfoSynchronizer infoSynchronizer) {
+        this.schedulingProperties = schedulingProperties;
         this.taskScheduler = taskScheduler;
         this.infoSynchronizer = infoSynchronizer;
     }
@@ -31,7 +36,8 @@ public class InfoSyncManager {
     @PostConstruct
     public void init() {
         //同步备标签信息
-        taskScheduler.execute(infoSynchronizer::syncDeviceTags);
+        if (schedulingProperties.isTaskActive(ScadaPlatformMetadata.SchedulingKeys.SYNC_DEVICE_TAGS))
+            taskScheduler.execute(infoSynchronizer::syncDeviceTags);
     }
 
     /**
@@ -40,6 +46,7 @@ public class InfoSyncManager {
     @Scheduled(cron = "0 */10 * * * *")
     public void minuteTask() {
         //同步设备标签信息
-        taskScheduler.execute(infoSynchronizer::syncDeviceTags);
+        if (schedulingProperties.isTaskActive(ScadaPlatformMetadata.SchedulingKeys.SYNC_DEVICE_TAGS))
+            taskScheduler.execute(infoSynchronizer::syncDeviceTags);
     }
 }