From d7d19fe385f3cbfbda22091b22cc7e882b6a0eab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B8=B8=E7=86=9F=E5=90=B4=E5=BD=A6=E7=A5=96?= Date: Wed, 27 Aug 2025 10:23:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E5=BC=80?= =?UTF-8?q?=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xujie/sys/common/utils/TaskUtils.java | 48 +++++++++++++++++-- src/main/resources/application-dev.yml | 2 + 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/xujie/sys/common/utils/TaskUtils.java b/src/main/java/com/xujie/sys/common/utils/TaskUtils.java index 8d5782db..077b6bd0 100644 --- a/src/main/java/com/xujie/sys/common/utils/TaskUtils.java +++ b/src/main/java/com/xujie/sys/common/utils/TaskUtils.java @@ -7,6 +7,7 @@ import com.xujie.sys.modules.pms.service.Impl.QcServiceImpl; import com.xujie.sys.modules.reader.service.GetInformationForExcelService; import com.xujie.sys.modules.reader.service.ModbusCommunicateService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; @@ -34,6 +35,9 @@ public class TaskUtils { @Autowired private ModbusCommunicateService modbusCommunicateService; + // 全局任务开关 + @Value("${task.enabled:true}") + private boolean taskEnabled; /** @@ -41,6 +45,9 @@ public class TaskUtils { */ @Scheduled(cron = "${task.data.eamWorkPlanTime}") public void doTask() { + if(!taskEnabled){ + return; + } eamService.eamWorkPlanTask(); } @@ -49,6 +56,10 @@ public class TaskUtils { */ @Scheduled(cron = "${task.data.getExcelInformation}" ) //每五秒执行 读取文件数据 public void getExcel(){ + if(!taskEnabled){ + return; + } + getInformationForExcelService.saveByExcel(); } @@ -57,6 +68,9 @@ public class TaskUtils { */ @Scheduled(cron = "${task.data.sendEmail}" ) public void sendEmail() throws MessagingException, UnsupportedEncodingException { + if(!taskEnabled){ + return; + } eamProjectService.sendEmail(); } @@ -65,33 +79,59 @@ public class TaskUtils { */ @Scheduled(cron = "${task.data.modbusCommunicate}") public void getModbus(){ + if(!taskEnabled){ + return; + } modbusCommunicateService.getInfoByModbus(); } @Scheduled(cron = "${task.data.readPerSecond}") public void readPerSecond(){ + if(!taskEnabled){ + return; + } modbusCommunicateService.readPerSecond(); } @Scheduled(cron = "${loraurl.getLoraWatchTime}") //@Scheduled(cron = "0/30 * * * * ?") - public void getLoraWatchMessage(){eamService.getLoraWatch();}; + public void getLoraWatchMessage(){ + if(!taskEnabled){ + return; + } + eamService.getLoraWatch();}; //@Scheduled(cron = "${loraurl.sendLoraWatchTime}") - public void sendLoraWatchMessage(){eamService.sendLoraWatch();}; + public void sendLoraWatchMessage(){ + if(!taskEnabled){ + return; + } + eamService.sendLoraWatch();}; //@Scheduled(cron = "${loraurl.sendThreeColourTime}") - public void sendThreeColourLight(){eamService.sendThreeColourLight();}; + public void sendThreeColourLight(){ + if(!taskEnabled){ + return; + } + eamService.sendThreeColourLight();}; @Scheduled(cron = "${loraurl.sendRedColourTime}") //@Scheduled(cron = "0/10 * * * * ?") - public void sendLoraRedLight(){eamService.sendLoraRedLight();} + public void sendLoraRedLight(){ + if(!taskEnabled){ + return; + } + eamService.sendLoraRedLight();} /** * 创建质量任务 */ @Scheduled(cron = "${task.data.createQCInspection}") public void createQCInspection() { + + if(!taskEnabled){ + return; + } qcService.createQCInspection(); } diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 0f671e5a..eba0d6e5 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -6,6 +6,7 @@ spring: type: com.alibaba.druid.pool.DruidDataSource #url: jdbc:sqlserver://192.168.1.90:1433;databaseName=CKT_MES_II_REAL url: jdbc:sqlserver://xujiesoft.vicp.net:11515;databaseName=CKT_MES_II_REAL +# url: jdbc:sqlserver://xujiesoft.vicp.net:11515;databaseName=ckp-srm username: sa password: XJsoft123 initial-size: 10 @@ -50,6 +51,7 @@ task: readPerSecond: 0 0 0 * * ? #每天执行一次 sendEmail: 0 0 12 ? * MON-FRI #发送邮件 createQCInspection: 0 01 17 * * ? # 创建质量任务 + enabled: false #--------------------------------------------接口地址和开关控制-------------------------------------------------