Commit 2a32153a authored by wanghao's avatar wanghao

1测试上电断电操作

parent 373b4d94
...@@ -45,69 +45,35 @@ public class DeviceTaskScheduler { ...@@ -45,69 +45,35 @@ public class DeviceTaskScheduler {
* 创建每小时通信任务 * 创建每小时通信任务
*/ */
private void createHourlyCommunicationJob(Long fStoreyId) throws SchedulerException { private void createHourlyCommunicationJob(Long fStoreyId) throws SchedulerException {
// // 1. 构建任务唯一标识(JobKey = jobId + 任务组名) // 1. 构建任务唯一标识(JobKey = jobId + 任务组名)
// String jobId = "COMM_" + fStoreyId;
// JobKey jobKey = new JobKey(jobId, JOB_GROUP);
// // 构建触发器唯一标识(TriggerKey = jobId + "_TRIGGER" + 触发器组名)
// TriggerKey triggerKey = new TriggerKey(jobId + "_TRIGGER", TRIGGER_GROUP);
//
// // 2. 准备JobDetail(与原有逻辑一致,仅初始化不提交)
// String fStoreyIdStr = fStoreyId.toString();
// JobDetail job = JobBuilder.newJob(DeviceCommunicationJob.class)
// .withIdentity(jobKey) // 直接用构建好的JobKey,避免重复编码
// .usingJobData("fStoreyId", fStoreyIdStr)
// .storeDurably() // 保留原有持久化配置
// .build();
//
// // 3. 准备新触发器(Cron调度,与原有逻辑一致)
// Trigger newTrigger = TriggerBuilder.newTrigger()
// .withIdentity(triggerKey) // 用构建好的TriggerKey
// .withSchedule(CronScheduleBuilder.cronSchedule("0 0/2 * * * ?")) // 测试每2分钟执行,后续可改回0 0 * * * ?
// .build();
//
// // 4. 分场景处理:存在则更新,不存在则创建
// if (scheduler.checkExists(jobKey)) {
// // 任务已存在:更新触发器(替换旧触发器为新触发器)
// Date updatedTime = scheduler.rescheduleJob(triggerKey, newTrigger);
// log.info("每小时通信任务[{}]已存在,成功更新触发器,下次执行时间:{}", jobId, updatedTime);
// } else {
// // 任务不存在:创建JobDetail和触发器
// scheduler.scheduleJob(job, newTrigger);
// log.info("每小时通信任务[{}]不存在,成功创建任务及触发器", jobId);
// }
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 triggerKey = new TriggerKey(jobId + "_TRIGGER", TRIGGER_GROUP); TriggerKey triggerKey = new TriggerKey(jobId + "_TRIGGER", TRIGGER_GROUP);
// 构建JobDetail // 2. 准备JobDetail(与原有逻辑一致,仅初始化不提交)
String fStoreyIdStr = fStoreyId.toString(); String fStoreyIdStr = fStoreyId.toString();
JobDetail job = JobBuilder.newJob(DeviceCommunicationJob.class) JobDetail job = JobBuilder.newJob(DeviceCommunicationJob.class)
.withIdentity(jobKey) .withIdentity(jobKey) // 直接用构建好的JobKey,避免重复编码
.usingJobData("fStoreyId", fStoreyIdStr) .usingJobData("fStoreyId", fStoreyIdStr)
.storeDurably() .storeDurably() // 保留原有持久化配置
.build(); .build();
// 构建Cron触发器(核心优化 // 3. 准备新触发器(Cron调度,与原有逻辑一致
Trigger newTrigger = TriggerBuilder.newTrigger() Trigger newTrigger = TriggerBuilder.newTrigger()
.withIdentity(triggerKey) .withIdentity(triggerKey) // 用构建好的TriggerKey
.withSchedule(CronScheduleBuilder.cronSchedule("0 0/2 * * * ?") .withSchedule(CronScheduleBuilder.cronSchedule("0 0/2 * * * ?")) // 测试每2分钟执行,后续可改回0 0 * * * ?
// 处理错过的触发:立即执行一次,然后按原计划继续
.withMisfireHandlingInstructionFireAndProceed())
// 显式设置永不结束(避免意外终止)
.endAt(Date.from(Instant.MAX))
.build(); .build();
// 打印未来5次执行时间,验证是否每2分钟一次 // 4. 分场景处理:存在则更新,不存在则创建
List<Date> nextFireTimes = TriggerUtils.computeFireTimes((OperableTrigger) newTrigger, null, 5);
log.info("任务[{}]的Cron表达式:0 0/2 * * * ?,未来5次执行时间:{}", jobId, nextFireTimes);
// 存在则更新,不存在则创建
if (scheduler.checkExists(jobKey)) { if (scheduler.checkExists(jobKey)) {
// 任务已存在:更新触发器(替换旧触发器为新触发器)
Date updatedTime = scheduler.rescheduleJob(triggerKey, newTrigger); Date updatedTime = scheduler.rescheduleJob(triggerKey, newTrigger);
log.info("任务[{}]已存在,更新触发器,下次执行时间:{}", jobId, updatedTime); log.info("每小时通信任务[{}]已存在,成功更新触发器,下次执行时间:{}", jobId, updatedTime);
} else { } else {
// 任务不存在:创建JobDetail和触发器
scheduler.scheduleJob(job, newTrigger); scheduler.scheduleJob(job, newTrigger);
log.info("任务[{}]创建成功,首次执行时间:{}", jobId, nextFireTimes.get(0)); log.info("每小时通信任务[{}]不存在,成功创建任务及触发器", jobId);
} }
} }
......
...@@ -98,6 +98,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -98,6 +98,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="fStatus != null">f_status = #{fStatus},</if> <if test="fStatus != null">f_status = #{fStatus},</if>
<if test="fBindingTime != null">f_binding_time = #{fBindingTime},</if> <if test="fBindingTime != null">f_binding_time = #{fBindingTime},</if>
<if test="fUnbindingTime != null">f_unbinding_time = #{fUnbindingTime},</if> <if test="fUnbindingTime != null">f_unbinding_time = #{fUnbindingTime},</if>
<if test="fUnbindingTime == null">f_unbinding_time = null,</if>
<if test="fCreateTime != null">f_create_time = #{fCreateTime},</if> <if test="fCreateTime != null">f_create_time = #{fCreateTime},</if>
</trim> </trim>
where f_tray_id = #{fTrayId} where f_tray_id = #{fTrayId}
......
...@@ -397,6 +397,7 @@ export default { ...@@ -397,6 +397,7 @@ export default {
<style scoped> <style scoped>
/* 标题区域样式 */ /* 标题区域样式 */
.panel-title { .panel-title {
position: absolute; position: absolute;
top: 20px; top: 20px;
......
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