Commit c0abff62 authored by wanghao's avatar wanghao

1 定时任务写时间功能代码重构,主要针对在线程使用方面及使用modbus4j方面

parent f799feed
package com.zehong.quartz.config; package com.zehong.quartz.config;
import org.quartz.spi.TriggerFiredBundle;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.quartz.SchedulerFactoryBean; import org.springframework.scheduling.quartz.SchedulerFactoryBean;
import org.springframework.scheduling.quartz.SpringBeanJobFactory; import org.springframework.scheduling.quartz.SpringBeanJobFactory;
import javax.annotation.Resource;
import javax.sql.DataSource; import javax.sql.DataSource;
import java.util.Properties; import java.util.Properties;
......
...@@ -37,7 +37,8 @@ public class SysJobServiceImpl implements ISysJobService ...@@ -37,7 +37,8 @@ public class SysJobServiceImpl implements ISysJobService
@PostConstruct @PostConstruct
public void init() throws SchedulerException, TaskException public void init() throws SchedulerException, TaskException
{ {
scheduler.clear(); //20251021 wh 调整
//scheduler.clear();
List<SysJob> jobList = jobMapper.selectJobAll(); List<SysJob> jobList = jobMapper.selectJobAll();
for (SysJob job : jobList) for (SysJob job : jobList)
{ {
......
package com.zehong.system.task; package com.zehong.system.task;
import com.zehong.quartz.config.QuartzTaskMonitor; import com.zehong.quartz.config.QuartzTaskMonitor;
import com.zehong.system.task.DeviceCommJob.*; import com.zehong.system.task.DeviceCommJob.DeviceComm501Device1Job;
import com.zehong.system.task.DeviceCommJob.DeviceComm501Device2Job;
import com.zehong.system.task.DeviceCommJob.DeviceComm501Device3Job;
import org.quartz.*; import org.quartz.*;
import org.quartz.impl.matchers.GroupMatcher; import org.quartz.impl.matchers.GroupMatcher;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.terracotta.quartz.wrappers.TriggerWrapper;
import javax.annotation.PostConstruct;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.Instant; import java.time.Instant;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
...@@ -153,6 +153,7 @@ public class DeviceTaskScheduler { ...@@ -153,6 +153,7 @@ public class DeviceTaskScheduler {
SimpleTrigger trigger = TriggerBuilder.newTrigger() SimpleTrigger trigger = TriggerBuilder.newTrigger()
.withIdentity(triggerKey) .withIdentity(triggerKey)
.forJob(jobKey) .forJob(jobKey)
.withDescription("设备" + fStoreyId + "最终任务触发器,触发时间是:" + triggerTime)
.startAt(triggerTime) .startAt(triggerTime)
.withSchedule(SimpleScheduleBuilder.simpleSchedule() .withSchedule(SimpleScheduleBuilder.simpleSchedule()
.withRepeatCount(0) // 只执行一次 .withRepeatCount(0) // 只执行一次
...@@ -268,7 +269,7 @@ public class DeviceTaskScheduler { ...@@ -268,7 +269,7 @@ public class DeviceTaskScheduler {
SimpleTrigger trigger = TriggerBuilder.newTrigger() SimpleTrigger trigger = TriggerBuilder.newTrigger()
.withIdentity(triggerKey) .withIdentity(triggerKey)
.forJob(jobKey) .forJob(jobKey)
.withDescription("设备" + fStoreyId + "最终任务触发器") .withDescription("设备" + fStoreyId + "最终任务触发器,触发时间是:" + executeTime)
.startAt(executeTime) .startAt(executeTime)
.withSchedule(SimpleScheduleBuilder.simpleSchedule() .withSchedule(SimpleScheduleBuilder.simpleSchedule()
.withMisfireHandlingInstructionFireNow() // 错过立即执行 .withMisfireHandlingInstructionFireNow() // 错过立即执行
......
...@@ -126,7 +126,11 @@ export default { ...@@ -126,7 +126,11 @@ export default {
this.selectedMenu = index; this.selectedMenu = index;
}, },
goToAdmin() { goToAdmin() {
this.$router.push('/index') // 或者 '/dashboard' 如果已经登录 // 先跳转到目标页面
this.$router.push('/index').then(() => {
// 跳转成功后刷新页面
window.location.reload()
})
}, },
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment