From cd9b85533a35ae804fde9b1ee7af51ebb1630aeb Mon Sep 17 00:00:00 2001
From: eight <641137800@qq.com>
Date: 星期四, 29 八月 2024 17:32:07 +0800
Subject: [PATCH] 问诊重置功能
---
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/Constants.java | 1 +
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/config/DynamicSchedulingConfig.java | 14 ++++++++++++++
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/room/RoomController.java | 8 ++++++++
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/room/RoomMapper.java | 7 +++++--
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/Utils.java | 21 +++++++++++++++++++++
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/room/RoomServiceImpl.java | 5 +++--
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/room/RoomService.java | 2 ++
7 files changed, 54 insertions(+), 4 deletions(-)
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/Constants.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/Constants.java
index 2dbd8a4..2d66d97 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/Constants.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/Constants.java
@@ -3,5 +3,6 @@
public interface Constants {
static final String ECG_OPENING_TIME_KEY = "ecg.openingtime";
static final String ECG_QUEUE_READY_MAX_KEY = "ecg.queue.ready.max";
+ static final String ECG_ROOM_RESET_TIME_KEY = "ecg.room.reset.time";
}
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/Utils.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/Utils.java
index 4b40db7..09727ea 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/Utils.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/Utils.java
@@ -9,6 +9,27 @@
import java.util.regex.Pattern;
public class Utils {
+ public static LocalTime parseTime(String strTime) {
+ String regex = "(\\d+)[:锛歖(\\d+)";
+ Pattern pattern = Pattern.compile(regex);
+ Matcher matcher = pattern.matcher(strTime);
+
+ if (!matcher.find())
+ return null;
+
+ // 鑾峰彇鏁翠釜鍖归厤鐨勫瓧绗︿覆
+ String fullMatch = matcher.group();
+
+ // 鑾峰彇绗竴涓崟鑾风粍锛堝皬鏃讹級
+ String strOpenHour = matcher.group(1);
+
+ // 鑾峰彇绗簩涓崟鑾风粍锛堝垎閽燂級
+ String strOpenMinute = matcher.group(2);
+
+ LocalTime localTime = LocalTime.of(Integer.valueOf(strOpenHour), Integer.valueOf(strOpenMinute));
+ return localTime;
+ }
+
public static List<LocalTime> parseOpeningTime(String strOpeningTime) {
String regex = "(\\d+)[:锛歖(\\d+)~(\\d+)[:锛歖(\\d+)";
Pattern pattern = Pattern.compile(regex);
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/config/DynamicSchedulingConfig.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/config/DynamicSchedulingConfig.java
index 55279a1..0c5d10c 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/config/DynamicSchedulingConfig.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/config/DynamicSchedulingConfig.java
@@ -2,6 +2,7 @@
import cn.lihu.jh.module.ecg.Utils;
import cn.lihu.jh.module.ecg.service.queue.QueueService;
+import cn.lihu.jh.module.ecg.service.room.RoomService;
import cn.lihu.jh.module.infra.api.config.ConfigApi;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
@@ -15,6 +16,7 @@
import java.util.concurrent.Executors;
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;
@Configuration
@EnableScheduling
@@ -25,6 +27,9 @@
@Resource
private QueueService queueService;
+
+ @Resource
+ private RoomService roomService;
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
@@ -37,6 +42,10 @@
String openCronExpression = String.format("0 %d %d * * ?", openingTime.getMinute(), openingTime.getHour());
String closeCronExpression = String.format("0 %d %d * * ?", closeTime.getMinute(), closeTime.getHour());
+ String strRoomResetTime = configApi.getConfigValueByKey(ECG_ROOM_RESET_TIME_KEY);
+ LocalTime roomResetTime = Utils.parseTime(strRoomResetTime);
+ String roomResetCronExpression = String.format("0 %d %d * * ?", roomResetTime.getMinute(), roomResetTime.getHour());
+
taskRegistrar.addCronTask(() -> {
System.out.println("Opening Task executed at: " + System.currentTimeMillis());
queueService.startBiz();
@@ -46,6 +55,11 @@
System.out.println("Close Task executed at: " + System.currentTimeMillis());
queueService.closeBiz();
}, closeCronExpression);
+
+ taskRegistrar.addCronTask(() -> {
+ System.out.println("Room Reset Task executed at: " + System.currentTimeMillis());
+ roomService.resetRoom();
+ }, roomResetCronExpression);
}
}
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/room/RoomController.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/room/RoomController.java
index f23ac57..483972c 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/room/RoomController.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/room/RoomController.java
@@ -152,4 +152,12 @@
Map<String, List<RoomRespVO>> map = list2.stream().collect(Collectors.groupingBy(RoomRespVO::getRoomName));
return success(map);
}
+
+ @GetMapping(value = {"/reset-room"})
+ @Operation(summary = "閲嶇疆闂ㄨ瘖瀹�", description = "涓昏鐢ㄤ簬姣忓ぉ鍏抽棴宸ヤ綅")
+ public CommonResult<String> resetRoom() {
+ roomService.resetRoom();
+ return success("reset room ok");
+ }
+
}
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/room/RoomMapper.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/room/RoomMapper.java
index c0c1837..4a5e580 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/room/RoomMapper.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/room/RoomMapper.java
@@ -31,8 +31,11 @@
.orderByDesc(RoomDO::getId));
}
- @Update(" update lihu.clinic_room set status=#{newStatus.status}, doc_id=null, doc_name=null")
- Integer resetRoom(@Param("newStatus") BedStatusEnum newStatus);
+ @Update("<script> " +
+ "update lihu.clinic_room set status=#{newStatus}, doc_id=null, doc_name=null " +
+ " where 1 = 1 " +
+ "</script>")
+ Integer resetRoom(@Param("newStatus") Integer newStatus);
@Select({ "SELECT room_id, room_name, count(1) as bed_num FROM lihu.clinic_room group by room_id;" })
List<RoomStatisticsDO> roomStatistic();
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/room/RoomService.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/room/RoomService.java
index f8b0323..e35bbb4 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/room/RoomService.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/room/RoomService.java
@@ -58,4 +58,6 @@
List<RoomDO> simpleRoomList();
+ void resetRoom();
+
}
\ No newline at end of file
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/room/RoomServiceImpl.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/room/RoomServiceImpl.java
index 6820d71..bd488c9 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/room/RoomServiceImpl.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/room/RoomServiceImpl.java
@@ -91,13 +91,14 @@
return roomMapper.simpleRoomList(bedStatusEnumList);
}
- private void resetRoom() {
+ @Override
+ public void resetRoom() {
List<BedStatusEnum> bedStatusEnumList = new ArrayList<BedStatusEnum>();
bedStatusEnumList.add(BedStatusEnum.DOCTOR_ON);
bedStatusEnumList.add(BedStatusEnum.PAUSE);
List<RoomDO> roomDOList = roomMapper.simpleRoomList(bedStatusEnumList);
- Integer ret = roomMapper.resetRoom(BedStatusEnum.CLOSED);
+ Integer ret = roomMapper.resetRoom(BedStatusEnum.CLOSED.getStatus());
//
List<Long> userIdList = roomDOList.stream().map(roomDO -> roomDO.getDocId()).toList();
--
Gitblit v1.9.3