From 1a7b7c276a56d96573aa814fe19532469e366908 Mon Sep 17 00:00:00 2001
From: eight <641137800@qq.com>
Date: 星期六, 12 十月 2024 18:02:40 +0800
Subject: [PATCH] 领用&装机 信息统计
---
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceImpl.java | 129 ++++++++++++++++++++++++++++++++++++++++--
1 files changed, 121 insertions(+), 8 deletions(-)
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 7e18a19..da4e17e 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
@@ -4,10 +4,10 @@
import java.util.concurrent.*;
import javax.annotation.Resource;
+import cn.lihu.jh.module.ecg.Utils;
import cn.lihu.jh.module.ecg.controller.admin.room.vo.MonitorInfoVO;
import cn.lihu.jh.module.ecg.dal.dataobject.devrent.DevRentDO;
import cn.lihu.jh.module.ecg.dal.mysql.call.CallMapper;
-import cn.lihu.jh.module.ecg.dal.mysql.checktype.CheckTypeMapper;
import cn.lihu.jh.module.ecg.dal.mysql.devrent.DevRentMapper;
import cn.lihu.jh.module.ecg.enums.DevRentStateEnum;
import cn.lihu.jh.module.system.api.oauth2.OAuth2TokenApi;
@@ -27,7 +27,7 @@
import cn.lihu.jh.module.ecg.dal.dataobject.queue.QueueDO;
import cn.lihu.jh.framework.common.pojo.PageResult;
import cn.lihu.jh.framework.common.util.object.BeanUtils;
-import cn.lihu.jh.module.ecg.dal.mysql.queue.queueMapper;
+import cn.lihu.jh.module.ecg.dal.mysql.queue.QueueMapper;
import static cn.lihu.jh.module.ecg.enums.ErrorCodeConstants.*;
import static cn.lihu.jh.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.lihu.jh.framework.common.pojo.CommonResult.error;
@@ -50,7 +50,7 @@
private OAuth2TokenApi oAuth2TokenApi;
@Resource
- private queueMapper queueMapper;
+ private QueueMapper queueMapper;
@Resource
private RoomMapper roomMapper;
@@ -62,6 +62,8 @@
private DevRentMapper devRentMapper;
ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor();
+
+ ConcurrentHashMap<String, RoomDO> mapRoomBed = new ConcurrentHashMap<>();
@Override
public Integer createqueue(QueueSaveReqVO createReqVO) {
@@ -219,6 +221,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);
@@ -304,27 +325,69 @@
devRent.setState( DevRentStateEnum.FREE.getState() );
devRentMapper.insert(devRent);
- startHurryUpOneCheckType(Integer.valueOf(queue.getBookCheckType()));
+ startHurryUpOneCheckType( queue.getBookCheckType() );
}
+ // 甯歌妫�鏌� 鍙彿
+ @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);
}
+ // 棰嗙敤 鍙彿
+ @Override
+ public void finishReceiveNextPatient(Long roomId, String bedNo) {
+ // 浠� DB 鎶� [灏辫瘖涓璢 鐨勪汉 璁剧疆涓� 銆愬凡棰嗙敤銆�
+ //Integer ret = queueMapper.updateBedQueueStatus(roomId, bedNo,
+ // QueueStatusEnum.ONSTAGE.getStatus(), QueueStatusEnum.RECEIVED.getStatus());
+
+ // 浠� DB 妫�鏌� 璇ュ伐浣� 鏄惁鏈� [灏辫瘖涓璢 浜哄憳锛岃嫢鏈夊氨.鏀惧純.鍙栦笅涓�浣�
+ List<Byte> queueStatusList = new ArrayList<>();
+ queueStatusList.add(QueueStatusEnum.ONSTAGE.getStatus());
+ Integer num = queueMapper.bedQueueStatisticByStatus(roomId, bedNo, queueStatusList);
+ if ( num != null && num > 0)
+ return;
+
+ startNextPatient(roomId, bedNo);
+ }
+
+ // 瑁呮満 鍙彿
+ @Override
+ public void finishInstallNextPatient(Long roomId, String bedNo) {
+ // 浠� DB 鎶� [瀹夎涓璢 鐨勪汉 璁剧疆涓� [宸插氨璇奭
+ //Integer ret = queueMapper.updateBedQueueStatus(roomId, bedNo,
+ // QueueStatusEnum.INSTALLING.getStatus(), QueueStatusEnum.FINISH.getStatus());
+
+ // 浠� DB 妫�鏌� 璇ュ伐浣� 鏄惁鏈� [灏辫瘖涓璢 浜哄憳锛岃嫢鏈夊氨.鏀惧純.鍙栦笅涓�浣�
+ List<Byte> queueStatusList = new ArrayList<>();
+ queueStatusList.add(QueueStatusEnum.INSTALLING.getStatus());
+ Integer num = queueMapper.bedQueueStatisticByStatus(roomId, bedNo, queueStatusList);
+ if ( num != null && num > 0)
+ return;
+
+ 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);
}
- public List<QueueDO> getDoctorQueueByStatus(Long roomId, String bedNo, List<Byte> statusList) {
- List<QueueDO> queueDOList = queueMapper.getDoctorQueueByStatus(roomId, bedNo, statusList);
+ public List<QueueDO> getBedQueueByStatus(Long roomId, String bedNo, List<Byte> statusList) {
+ List<QueueDO> queueDOList = queueMapper.getBedQueueByStatus(roomId, bedNo, statusList);
+ return queueDOList;
+ }
+
+ @Override
+ public List<QueueDO> getRoomQueueByStatus(Long roomId, List<Byte> statusList) {
+ List<QueueDO> queueDOList = queueMapper.getRoomQueueByStatus(roomId, statusList);
return queueDOList;
}
@@ -344,6 +407,48 @@
List<Byte> statusList = new ArrayList<>();
statusList.add(QueueStatusEnum.WAITING.getStatus());
Integer num = queueMapper.statusStatistic(statusList);
+ patientStatisticVO.setQueuingNum(num);
+
+ return patientStatisticVO;
+ }
+
+ public PatientStatisticVO getBedDevInstallStatistic(Long roomId, String bedNo) {
+ PatientStatisticVO patientStatisticVO = new PatientStatisticVO();
+ List<BedQueueStatisticDO> bedQueueStatisticDOList = queueMapper.bedQueueStatistic(roomId, bedNo);
+ bedQueueStatisticDOList.forEach(item -> {
+ if (QueueStatusEnum.RECEIVED.getStatus() == item.getStatus()) {
+ patientStatisticVO.setReceivedNum(item.getTotalInStatus());
+ } else if (QueueStatusEnum.FINISH.getStatus() == item.getStatus()) {
+ patientStatisticVO.setFinishedNum(item.getTotalInStatus());
+ }
+ });
+
+ return patientStatisticVO;
+ }
+
+ public PatientStatisticVO getBedDevReadyStatistic(Long roomId, String bedNo) {
+ PatientStatisticVO patientStatisticVO = new PatientStatisticVO();
+ patientStatisticVO.setFinishedNum(0);
+ List<BedQueueStatisticDO> bedQueueStatisticDOList = queueMapper.bedQueueStatistic(roomId, bedNo);
+ bedQueueStatisticDOList.forEach(item -> {
+ if (QueueStatusEnum.READY.getStatus() == item.getStatus()) {
+ patientStatisticVO.setReadyNum(item.getTotalInStatus());
+ } else if (QueueStatusEnum.PASSED.getStatus() == item.getStatus()) {
+ patientStatisticVO.setPassedNum(item.getTotalInStatus());
+ } else if (QueueStatusEnum.RECEIVED.getStatus() == item.getStatus()) {
+ patientStatisticVO.setFinishedNum( item.getTotalInStatus() + patientStatisticVO.getFinishedNum() );
+ } else if (QueueStatusEnum.INSTALLING.getStatus() == item.getStatus()) {
+ patientStatisticVO.setFinishedNum( item.getTotalInStatus() + patientStatisticVO.getFinishedNum() );
+ } else if (QueueStatusEnum.FINISH.getStatus() == item.getStatus()) {
+ patientStatisticVO.setFinishedNum(item.getTotalInStatus() + patientStatisticVO.getFinishedNum());
+ }
+ });
+
+ RoomDO roomDO = getRoomDO(roomId, bedNo);
+ Integer[] checkTypes = roomDO.getCheckTypes();
+ List<Byte> statusList = new ArrayList<>();
+ statusList.add(QueueStatusEnum.WAITING.getStatus());
+ Integer num = queueMapper.checkTypeAndStatusStatistic(roomId, bedNo, checkTypes, statusList);
patientStatisticVO.setQueuingNum(num);
return patientStatisticVO;
@@ -388,4 +493,12 @@
return roomMapper.getRoomByDocId(docId);
}
+ private RoomDO getRoomDO(Long roomId, String bedNo) {
+ RoomDO roomDO = mapRoomBed.get( Utils.formatRoomBed(roomId, bedNo) );
+ if ( null == roomDO)
+ roomDO = roomMapper.getRoom(roomId, bedNo);
+
+ return roomDO;
+ }
+
}
--
Gitblit v1.9.3