Commit 5ee584e4 authored by wanghao's avatar wanghao

1测试上电断电操作

parent 7576b766
...@@ -34,6 +34,7 @@ public class DeviceTaskScheduler { ...@@ -34,6 +34,7 @@ public class DeviceTaskScheduler {
*/ */
public void scheduleDeviceMonitoring(Long fStoreyId,String fPowerOutageIp,Integer fPowerOutagePort) throws SchedulerException { public void scheduleDeviceMonitoring(Long fStoreyId,String fPowerOutageIp,Integer fPowerOutagePort) throws SchedulerException {
log.info("创建设备监控任务:{}", fStoreyId);
// 2. 创建每小时通信任务 // 2. 创建每小时通信任务
createHourlyCommunicationJob(fStoreyId); createHourlyCommunicationJob(fStoreyId);
...@@ -46,6 +47,7 @@ public class DeviceTaskScheduler { ...@@ -46,6 +47,7 @@ public class DeviceTaskScheduler {
*/ */
private void createHourlyCommunicationJob(Long fStoreyId) throws SchedulerException { private void createHourlyCommunicationJob(Long fStoreyId) throws SchedulerException {
// 1. 构建任务唯一标识(JobKey = jobId + 任务组名) // 1. 构建任务唯一标识(JobKey = jobId + 任务组名)
log.info("创建每小时通信任务:{}", fStoreyId);
String jobId = "COMM_" + fStoreyId; String jobId = "COMM_" + fStoreyId;
JobKey jobKey = new JobKey(jobId, JOB_GROUP); JobKey jobKey = new JobKey(jobId, JOB_GROUP);
// 构建触发器唯一标识(TriggerKey = jobId + "_TRIGGER" + 触发器组名) // 构建触发器唯一标识(TriggerKey = jobId + "_TRIGGER" + 触发器组名)
...@@ -70,7 +72,10 @@ public class DeviceTaskScheduler { ...@@ -70,7 +72,10 @@ public class DeviceTaskScheduler {
// 4. 分场景处理:存在则更新,不存在则创建 // 4. 分场景处理:存在则更新,不存在则创建
if (scheduler.checkExists(jobKey)) { if (scheduler.checkExists(jobKey)) {
// 先删除旧触发器再添加新触发器 // 先删除旧触发器再添加新触发器
scheduler.unscheduleJob(triggerKey); // 删除旧触发器,避免冲突
if (scheduler.checkExists(triggerKey)) {
scheduler.unscheduleJob(triggerKey);
}
scheduler.scheduleJob(newTrigger); scheduler.scheduleJob(newTrigger);
log.info("每小时通信任务[{}]已存在,成功更新触发器", jobId); log.info("每小时通信任务[{}]已存在,成功更新触发器", jobId);
} else { } else {
...@@ -85,6 +90,7 @@ public class DeviceTaskScheduler { ...@@ -85,6 +90,7 @@ public class DeviceTaskScheduler {
*/ */
private void createFinalExecutionJob(Long fStoreyId,String fPowerOutageIp,Integer fPowerOutagePort) throws SchedulerException { private void createFinalExecutionJob(Long fStoreyId,String fPowerOutageIp,Integer fPowerOutagePort) throws SchedulerException {
log.info("创建71小时后执行任务:{}", fStoreyId);
String jobId = "FINAL_" + fStoreyId; String jobId = "FINAL_" + fStoreyId;
JobKey jobKey = new JobKey(jobId, JOB_GROUP); JobKey jobKey = new JobKey(jobId, JOB_GROUP);
TriggerKey triggerKey = new TriggerKey(jobId + "_TRIGGER", TRIGGER_GROUP); TriggerKey triggerKey = new TriggerKey(jobId + "_TRIGGER", TRIGGER_GROUP);
......
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