From 02cb4a13b2f7bba15a5eca9353a2e458efe2c602 Mon Sep 17 00:00:00 2001
From: eight <641137800@qq.com>
Date: 星期四, 07 十一月 2024 11:33:50 +0800
Subject: [PATCH] 排队序号表的初始化
---
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/config/EcgConfigServiceImpl.java | 26 +++++++++++++++++++++-----
1 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/config/EcgConfigServiceImpl.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/config/EcgConfigServiceImpl.java
index f9b2738..a6d505b 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/config/EcgConfigServiceImpl.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/config/EcgConfigServiceImpl.java
@@ -2,10 +2,13 @@
import cn.lihu.jh.module.ecg.Utils;
import cn.lihu.jh.module.ecg.config.DynamicSchedulingConfig;
+import cn.lihu.jh.module.ecg.dal.mysql.queuesequence.QueueSequenceMapper;
import cn.lihu.jh.module.ecg.service.queue.QueueService;
+import cn.lihu.jh.module.ecg.service.queuesequence.QueueSequenceService;
import cn.lihu.jh.module.ecg.service.room.RoomService;
import cn.lihu.jh.module.infra.api.config.ConfigApi;
import lombok.extern.slf4j.Slf4j;
+import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.config.CronTask;
import org.springframework.scheduling.config.ScheduledTask;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
@@ -15,6 +18,8 @@
import javax.annotation.Resource;
import java.time.LocalTime;
import java.util.List;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
import static cn.lihu.jh.module.ecg.Constants.ECG_OPENING_TIME_KEY;
import static cn.lihu.jh.module.ecg.Constants.ECG_ROOM_RESET_TIME_KEY;
@@ -33,10 +38,20 @@
@Resource
private QueueService queueService;
+ @Resource
+ private QueueSequenceService queueSequenceService;
+
+ ScheduledTask startBizTask = null;
+ ScheduledTask closeBizTask = null;
+ ScheduledTask resetRoomTask = null;
+
@Override
public void resetScheduler() {
ScheduledTaskRegistrar taskRegistrar = DynamicSchedulingConfig.static_scheduledTaskRegistrar;
- taskRegistrar.getScheduledTasks().forEach(ScheduledTask::cancel);
+
+ if (null != startBizTask) startBizTask.cancel();
+ if (null != closeBizTask) closeBizTask.cancel();
+ if (null != resetRoomTask) resetRoomTask.cancel();
String strOpenCloseTime = configApi.getConfigValueByKey(ECG_OPENING_TIME_KEY);
List<LocalTime> list = Utils.parseOpeningTime(strOpenCloseTime);
@@ -49,19 +64,20 @@
LocalTime roomResetTime = Utils.parseTime(strRoomResetTime);
String roomResetCronExpression = String.format("0 %d %d * * ?", roomResetTime.getMinute(), roomResetTime.getHour());
- taskRegistrar.scheduleCronTask(new CronTask(() -> {
+ startBizTask = taskRegistrar.scheduleCronTask(new CronTask(() -> {
System.out.println("Opening Task executed at: " + System.currentTimeMillis());
queueService.startBiz();
}, openCronExpression));
- taskRegistrar.scheduleCronTask(new CronTask(() -> {
+ closeBizTask = taskRegistrar.scheduleCronTask(new CronTask(() -> {
System.out.println("Close Task executed at: " + System.currentTimeMillis());
queueService.closeBiz();
}, closeCronExpression));
- taskRegistrar.scheduleCronTask(new CronTask(() -> {
+ resetRoomTask = taskRegistrar.scheduleCronTask(new CronTask(() -> {
System.out.println("Room Reset Task executed at: " + System.currentTimeMillis());
- roomService.resetRoom();
+ roomService.resetRoom(false);
+ queueSequenceService.resetQueueSequence();
}, roomResetCronExpression));
taskRegistrar.afterPropertiesSet();
--
Gitblit v1.9.3