From e86481b3a32200d83fdcdbca826b72e3776ae5cd Mon Sep 17 00:00:00 2001
From: eight <641137800@qq.com>
Date: 星期六, 12 十月 2024 14:23:55 +0800
Subject: [PATCH] 装机功能 相关 待续
---
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/doctor/DoctorController.java | 4 ++
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceImpl.java | 33 +++++++++++++---
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/queue/QueueMapper.java | 15 +++++--
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/BedDoctorNextInstallPatientCallable.java | 32 ++++++++++++++++
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueService.java | 1
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceTxFunctions.java | 28 ++++++++++++--
6 files changed, 98 insertions(+), 15 deletions(-)
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/doctor/DoctorController.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/doctor/DoctorController.java
index a3b5fee..fdbc85f 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/doctor/DoctorController.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/doctor/DoctorController.java
@@ -300,6 +300,10 @@
List<Byte> queueStatusList = new ArrayList<>();
queueStatusList.add(QueueStatusEnum.RECEIVED.getStatus());
List<QueueDO> queueDOList = queueService.getRoomQueueByStatus(roomId, queueStatusList);
+
+ queueStatusList.clear();
+ queueStatusList.add(QueueStatusEnum.INSTALLING.getStatus());
+ queueDOList.addAll( queueService.getBedQueueByStatus(roomId, bedNo, queueStatusList) );
return success(BeanUtils.toBean(queueDOList, QueueRespVO.class));
}
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/queue/QueueMapper.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/queue/QueueMapper.java
index 5faf1d2..4da0f9c 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/queue/QueueMapper.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/queue/QueueMapper.java
@@ -110,18 +110,25 @@
@Update("update lihu.queue set status = #{newStatus} where seq_num = \n" +
"(select a.min_seq_num from \n" +
" (select min(seq_num) as min_seq_num from lihu.queue where room_id = #{roomId} and bed_no = #{bedNo} and status = #{curStatus}) a )")
- Integer updateQueueStatus(@Param("roomId")Long roomId, @Param("bedNo")String bedNo, @Param("curStatus")Byte curStatus, @Param("newStatus")Byte newStatus);
+ Integer updateBedQueueStatus(@Param("roomId")Long roomId, @Param("bedNo")String bedNo, @Param("curStatus")Byte curStatus, @Param("newStatus")Byte newStatus);
+
+ // 鏌愪釜璇婂鑼冨洿鍐� [宸查鐢╙浜哄憳 鎶㈠崰
+ @Update("update lihu.queue set status = #{newStatus}, bed_no = #{bedNo} where seq_num = \n" +
+ "(select a.min_seq_num from \n" +
+ " (select min(seq_num) as min_seq_num from lihu.queue where room_id = #{roomId} and status = #{curStatus}) a )")
+ Integer preemptReceivedPatient(@Param("roomId")Long roomId, @Param("bedNo")String bedNo, @Param("curStatus")Byte curStatus, @Param("newStatus")Byte newStatus);
@Update("update lihu.queue set status = #{newStatus} where pat_id = #{patId} and status = #{curStatus}")
Integer updatePatientQueueStatus(@Param("patId")String patId, @Param("curStatus")Byte curStatus, @Param("newStatus")Byte newStatus);
+ // 鏁翠釜绯荤粺鑼冨洿鍐� [鎺掗槦涓璢浜哄憳 鎶㈠崰
@Update("update lihu.queue set status = #{newStatus}, room_id = #{roomId}, room_name = #{roomName}, \n" +
" bed_no = #{bedNo}, seq_num = #{seqNum} where id = \n" +
" (select a.id from \n" +
" (select id from lihu.queue where status = #{curStatus} and book_check_type= #{checkType} order by jump_flag desc, book_timeslot, create_time limit 1) a)")
- Integer preemptPatient(@Param("roomId")Long roomId, @Param("roomName")String roomName, @Param("bedNo")String bedNo,
- @Param("seqNum")Integer seqNum, @Param("curStatus")Byte curStatus, @Param("newStatus")Byte newStatus,
- @Param("checkType")Integer checkType);
+ Integer preemptWaitingPatient(@Param("roomId")Long roomId, @Param("roomName")String roomName, @Param("bedNo")String bedNo,
+ @Param("seqNum")Integer seqNum, @Param("curStatus")Byte curStatus, @Param("newStatus")Byte newStatus,
+ @Param("checkType")Integer checkType);
@Update("update lihu.queue set status = #{newStatus}, seq_num = #{seqNum}, passed = 1 " +
" where id = " +
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/BedDoctorNextInstallPatientCallable.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/BedDoctorNextInstallPatientCallable.java
new file mode 100644
index 0000000..045c3c1
--- /dev/null
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/BedDoctorNextInstallPatientCallable.java
@@ -0,0 +1,32 @@
+package cn.lihu.jh.module.ecg.service.queue;
+
+import cn.lihu.jh.framework.common.exception.ErrorCode;
+import cn.lihu.jh.framework.common.exception.enums.GlobalErrorCodeConstants;
+
+import java.util.concurrent.Callable;
+
+public class BedDoctorNextInstallPatientCallable implements Callable<ErrorCode> {
+
+ QueueServiceTxFunctions queueService;
+ private Long roomId;
+ private String bedNo;
+
+ public BedDoctorNextInstallPatientCallable(QueueServiceTxFunctions queueService, Long roomId, String bedNo)
+ {
+ super();
+ this.roomId = roomId;
+ this.bedNo = bedNo;
+ this.queueService = queueService;
+ }
+
+ public ErrorCode call() throws Exception {
+ ErrorCode ec = queueService.nextInstallPatient(roomId, bedNo);
+ if (GlobalErrorCodeConstants.SUCCESS.equals(ec)) {
+ queueService.hurryupOneBed(roomId, bedNo);
+ }
+
+ queueService.monitorInfo();
+ return ec;
+ }
+
+}
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueService.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueService.java
index 73ea58f..f3cbfdb 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueService.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueService.java
@@ -63,6 +63,7 @@
ErrorCode startBedDoctorOn(Long roomId, String bedNo, Long docId, String docName);
ErrorCode startBedDoctorOff(Long roomId, String bedNo, Long docId, String docName);
ErrorCode startNextPatient(Long roomId, String bedNo);
+ ErrorCode startNextInstallPatient(Long roomId, String bedNo);
CommonResult<RoomRespVO> getRoom(Long roomId, String bedNo, Long docId);
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceImpl.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceImpl.java
index 1fcbd19..4fa8e7c 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceImpl.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceImpl.java
@@ -218,6 +218,25 @@
}
@Override
+ public ErrorCode startNextInstallPatient(Long roomId, String bedNo) {
+ Future<ErrorCode> future = singleThreadExecutor.submit(
+ new BedDoctorNextInstallPatientCallable(queueServiceTxFunctions, roomId, bedNo)
+ );
+
+ try {
+ ErrorCode ret = future.get();
+ return ret;
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ } catch (ExecutionException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("startNextInstallPatient ========");
+ return ECG_INNER_ERROR;
+ }
+
+ @Override
public void startHurryUpOneBed(Long roomId, String bedNo) {
singleThreadExecutor.execute( () -> {
queueServiceTxFunctions.hurryupOneBed(roomId, bedNo);
@@ -310,7 +329,7 @@
@Override
public void finishNextPatient(Long roomId, String bedNo) {
// 浠� DB 鎶� 灏辫瘖涓殑浜� 璁剧疆涓哄氨璇婂畬鎴�
- Integer ret = queueMapper.updateQueueStatus(roomId, bedNo,
+ Integer ret = queueMapper.updateBedQueueStatus(roomId, bedNo,
QueueStatusEnum.ONSTAGE.getStatus(), QueueStatusEnum.FINISH.getStatus());
startNextPatient(roomId, bedNo);
@@ -320,7 +339,7 @@
@Override
public void finishReceiveNextPatient(Long roomId, String bedNo) {
// 浠� DB 鎶� 灏辫瘖涓殑浜� 璁剧疆涓哄氨璇婂畬鎴�
- Integer ret = queueMapper.updateQueueStatus(roomId, bedNo,
+ Integer ret = queueMapper.updateBedQueueStatus(roomId, bedNo,
QueueStatusEnum.ONSTAGE.getStatus(), QueueStatusEnum.RECEIVED.getStatus());
startNextPatient(roomId, bedNo);
@@ -329,16 +348,16 @@
// 瑁呮満 鍙彿
@Override
public void finishInstallNextPatient(Long roomId, String bedNo) {
- // 浠� DB 鎶� 灏辫瘖涓殑浜� 璁剧疆涓哄氨璇婂畬鎴�
- Integer ret = queueMapper.updateQueueStatus(roomId, bedNo,
- QueueStatusEnum.ONSTAGE.getStatus(), QueueStatusEnum.FINISH.getStatus());
+ // 浠� DB 鎶� [瀹夎涓璢 鐨勪汉 璁剧疆涓� [宸插氨璇奭
+ Integer ret = queueMapper.updateBedQueueStatus(roomId, bedNo,
+ QueueStatusEnum.INSTALLING.getStatus(), QueueStatusEnum.FINISH.getStatus());
- startNextPatient(roomId, bedNo);
+ startNextInstallPatient(roomId, bedNo);
}
public void passNextPatient(Long roomId, String bedNo) {
// 浠� DB 鎶� 灏辫瘖涓殑浜� 璁剧疆涓鸿繃鍙�
- Integer ret = queueMapper.updateQueueStatus(roomId, bedNo,
+ Integer ret = queueMapper.updateBedQueueStatus(roomId, bedNo,
QueueStatusEnum.ONSTAGE.getStatus(), QueueStatusEnum.PASSED.getStatus());
startNextPatient(roomId, bedNo);
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceTxFunctions.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceTxFunctions.java
index ba0d10b..f044cb7 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceTxFunctions.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceTxFunctions.java
@@ -237,11 +237,12 @@
return GlobalErrorCodeConstants.SUCCESS;
}
+ // 甯歌 鎴栬�� 棰嗙敤 鏃� 鍖荤敓 鍙栦笅涓�浣嶆偅鑰�
public ErrorCode nextPatient(Long roomId, String bedNo) {
- // 浠� DB 鎶� 搴忓彿鏈�灏忕殑 灏辫瘖鍑嗗涓殑浜� 璁剧疆涓哄氨璇婁腑
- Integer updateNum = queueMapper.updateQueueStatus(roomId, bedNo,
+ // 浠� DB 鎶� 搴忓彿鏈�灏忕殑 [灏辫瘖鍑嗗涓璢 鐨勪汉 璁剧疆涓� [灏辫瘖涓璢 (鎴栭鐢ㄤ腑)
+ Integer updateNum = queueMapper.updateBedQueueStatus(roomId, bedNo,
QueueStatusEnum.READY.getStatus(), QueueStatusEnum.ONSTAGE.getStatus());
- // 璇ュ伐浣� 娌℃湁 灏辫瘖鍑嗗涓� 浜哄憳
+ // 璇ュ伐浣� 娌℃湁 [灏辫瘖鍑嗗涓璢 浜哄憳
if (null == updateNum || 0 == updateNum) {
return QUEUE_NOT_READY_PATIENT;
}
@@ -251,6 +252,25 @@
bo.queueNum.getAndDecrement(); // 鍙兘宸茬粡銆愬苟鍙戠殑銆戝湪 hurry-up 涓敼鍙樹簡鍊�
refreshPriorityQueue(bo);
+ return GlobalErrorCodeConstants.SUCCESS;
+ }
+
+ // 瑁呮満鏃� 鍖荤敓 鍙栦笅涓�浣嶆偅鑰�
+ public ErrorCode nextInstallPatient(Long roomId, String bedNo) {
+ // 浠� DB 鎶� 搴忓彿鏈�灏忕殑 [宸查鐢╙ 鐨勪汉 璁剧疆涓� [瀹夎涓璢
+ Integer updateNum = queueMapper.preemptReceivedPatient(roomId, bedNo,
+ QueueStatusEnum.RECEIVED.getStatus(), QueueStatusEnum.INSTALLING.getStatus());
+ // 璇ュ伐浣� 娌℃湁 [宸查鐢╙ 浜哄憳
+ if (null == updateNum || 0 == updateNum) {
+ return QUEUE_NOT_READY_PATIENT;
+ }
+
+ // 瑁呮満宸ヤ綅 鏃犱紭鍏堥槦鍒�
+ // 浼樺厛闃熷垪涓� 璇ュ伐浣� [宸查鐢╙浜虹殑鏁伴噺 鍑忎竴
+ //BedQueueBO bo = mapBedVsQueue.get(String.format("%09d%s", roomId, bedNo));
+ //bo.queueNum.getAndDecrement(); // 鍙兘宸茬粡銆愬苟鍙戠殑銆戝湪 hurry-up 涓敼鍙樹簡鍊�
+ //refreshPriorityQueue(bo);
+
return GlobalErrorCodeConstants.SUCCESS;
}
@@ -377,7 +397,7 @@
return;
// 鏌ョ湅 鏄惁鏈夋帓闃熶腑鐨勬偅鑰�
- Integer updateNum = queueMapper.preemptPatient(
+ Integer updateNum = queueMapper.preemptWaitingPatient(
bedQueueBO.getRoomId(),
bedQueueBO.getRoomName(),
bedQueueBO.getBedNo(),
--
Gitblit v1.9.3