From dc09f666f10fd569fcb473cc5ce59eef03ea71b4 Mon Sep 17 00:00:00 2001 From: lyfO_o <764716047@qq.com> Date: 星期五, 26 八月 2022 09:39:41 +0800 Subject: [PATCH] 4个线程保持连接 --- equipment/equipment-service/src/main/java/com/gkhy/safePlatform/equipment/schedule/KeepAliveRobot.java | 27 +++++++++++++ incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/schedule/KeepAliveRobot.java | 27 +++++++++++++ goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/schedule/KeepAliveRobot.java | 27 +++++++++++++ emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/schedule/KeepAliveRobot.java | 27 +++++++++++++ 4 files changed, 108 insertions(+), 0 deletions(-) diff --git a/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/schedule/KeepAliveRobot.java b/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/schedule/KeepAliveRobot.java new file mode 100644 index 0000000..dedd0dc --- /dev/null +++ b/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/schedule/KeepAliveRobot.java @@ -0,0 +1,27 @@ +package com.gkhy.safePlatform.emergency.schedule; + +import com.gkhy.safePlatform.emergency.service.baseService.EmergencyPlanInfoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + + +@Component("emergencyKeepAlive") +@EnableScheduling +@ConditionalOnProperty(prefix = "threadPool.scheduling", name = "enabled", havingValue = "true") +public class KeepAliveRobot { + + @Autowired + private EmergencyPlanInfoService emergencyPlanInfoService; + + // 30m + @Scheduled(cron = "0 0/30 * * * ?") + public void keepAlive(){ + // + emergencyPlanInfoService.getById(-1L); + + } + +} diff --git a/equipment/equipment-service/src/main/java/com/gkhy/safePlatform/equipment/schedule/KeepAliveRobot.java b/equipment/equipment-service/src/main/java/com/gkhy/safePlatform/equipment/schedule/KeepAliveRobot.java new file mode 100644 index 0000000..15470e3 --- /dev/null +++ b/equipment/equipment-service/src/main/java/com/gkhy/safePlatform/equipment/schedule/KeepAliveRobot.java @@ -0,0 +1,27 @@ +package com.gkhy.safePlatform.equipment.schedule; + +import com.gkhy.safePlatform.equipment.service.EquipmentInfoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + + +@Component("equipmentKeepAlive") +@EnableScheduling +@ConditionalOnProperty(prefix = "threadPool.scheduling", name = "enabled", havingValue = "true") +public class KeepAliveRobot { + + @Autowired + private EquipmentInfoService equipmentInfoService; + + // 30m + @Scheduled(cron = "0 0/30 * * * ?") + public void keepAlive(){ + // + equipmentInfoService.getById(-1L); + + } + +} diff --git a/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/schedule/KeepAliveRobot.java b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/schedule/KeepAliveRobot.java new file mode 100644 index 0000000..7e457f0 --- /dev/null +++ b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/schedule/KeepAliveRobot.java @@ -0,0 +1,27 @@ +package com.gkhy.safePlatform.targetDuty.schedule; + +import com.gkhy.safePlatform.targetDuty.service.TargetTypeService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + + +@Component("goalKeepAlive") +@EnableScheduling +@ConditionalOnProperty(prefix = "threadPool.scheduling", name = "enabled", havingValue = "true") +public class KeepAliveRobot { + + @Autowired + private TargetTypeService targetTypeService; + + // 30m + @Scheduled(cron = "0 0/30 * * * ?") + public void keepAlive(){ + // + targetTypeService.getById(-1L); + + } + +} diff --git a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/schedule/KeepAliveRobot.java b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/schedule/KeepAliveRobot.java new file mode 100644 index 0000000..8a7f560 --- /dev/null +++ b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/schedule/KeepAliveRobot.java @@ -0,0 +1,27 @@ +package com.gkhy.safePlatform.incidentManage.schedule; + +import com.gkhy.safePlatform.incidentManage.service.baseService.AccidentCaseInfoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + + +@Component("incidentKeepAlive") +@EnableScheduling +@ConditionalOnProperty(prefix = "threadPool.scheduling", name = "enabled", havingValue = "true") +public class KeepAliveRobot { + + @Autowired + private AccidentCaseInfoService accidentCaseInfoService; + + // 30m + @Scheduled(cron = "0 0/30 * * * ?") + public void keepAlive(){ + // + accidentCaseInfoService.getById(-1L); + + } + +} -- Gitblit v1.9.2