From d40cde3bca854c21c869cb35d25ece4aa7dac265 Mon Sep 17 00:00:00 2001
From: eight <641137800@qq.com>
Date: 星期四, 10 四月 2025 16:43:34 +0800
Subject: [PATCH] 检查记录  排除 未检查的记录

---
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/devrent/DevRentServiceImpl.java |   65 ++++++++++++++++----------------
 1 files changed, 32 insertions(+), 33 deletions(-)

diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/devrent/DevRentServiceImpl.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/devrent/DevRentServiceImpl.java
index 69f3e1a..fde56f9 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/devrent/DevRentServiceImpl.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/devrent/DevRentServiceImpl.java
@@ -3,13 +3,11 @@
 import cn.lihu.jh.framework.common.pojo.CommonResult;
 import cn.lihu.jh.framework.security.core.util.SecurityFrameworkUtils;
 import cn.lihu.jh.module.ecg.controller.admin.jobrecord.vo.JobRecordSaveReqVO;
-import cn.lihu.jh.module.ecg.dal.dataobject.appointment.AppointmentDO;
 import cn.lihu.jh.module.ecg.dal.dataobject.checktype.CheckTypeDO;
 import cn.lihu.jh.module.ecg.dal.dataobject.devmanage.DeviceDO;
 import cn.lihu.jh.module.ecg.dal.dataobject.jobrecord.JobRecordDO;
 import cn.lihu.jh.module.ecg.dal.dataobject.patient.PatDetails;
 import cn.lihu.jh.module.ecg.dal.dataobject.queue.QueueDO;
-import cn.lihu.jh.module.ecg.dal.mysql.appointment.AppointmentMapper;
 import cn.lihu.jh.module.ecg.dal.mysql.checktype.CheckTypeMapper;
 import cn.lihu.jh.module.ecg.dal.mysql.devmanage.DeviceMapper;
 import cn.lihu.jh.module.ecg.dal.mysql.jobrecord.JobRecordMapper;
@@ -18,21 +16,16 @@
 import cn.lihu.jh.module.ecg.enums.DevStateEnum;
 import cn.lihu.jh.module.ecg.enums.QueueStatusEnum;
 import cn.lihu.jh.module.ecg.feign.*;
-import cn.lihu.jh.module.ecg.feign.dto.AppointmentExternal;
 import cn.lihu.jh.module.ecg.service.queue.QueueServiceTxFunctions;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.dataformat.xml.XmlMapper;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.io.Console;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 
 import cn.lihu.jh.module.ecg.controller.admin.devrent.vo.*;
 import cn.lihu.jh.module.ecg.dal.dataobject.devrent.DevRentDO;
@@ -44,7 +37,6 @@
 import javax.annotation.Resource;
 
 import static cn.lihu.jh.framework.common.exception.util.ServiceExceptionUtil.exception;
-import static cn.lihu.jh.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
 import static cn.lihu.jh.framework.common.util.date.DateUtils.getCurTimeString;
 import static cn.lihu.jh.module.ecg.enums.ErrorCodeConstants.*;
 
@@ -184,8 +176,8 @@
         }
 
         List<Integer> jobTypeList = new ArrayList<Integer>();
-        jobTypeList.add( DevRentStateEnum.READY.getState());
-        jobTypeList.add( DevRentStateEnum.READY_CANCELLED.getState());
+        jobTypeList.add( DevRentStateEnum.RECEIVED.getState());
+        jobTypeList.add( DevRentStateEnum.RECEIVED_CANCELLED.getState());
         JobRecordDO jobRecordDO = jobRecordMapper.selectByRentIdDocId(rent_id, userId, jobTypeList);
         if (null == jobRecordDO) {
             List<DevRentDO>  devRentDOList = devRentMapper.selectByPatAndChecktypeAndState(createReqVO.getPatId(), createReqVO.getCheckType(), DevRentStateEnum.FREE.getState());
@@ -197,7 +189,7 @@
 
             rent_id = devRentDOList.getFirst().getId();
             createReqVO.setId( rent_id );
-            createReqVO.setState( DevRentStateEnum.READY.getState() );
+            createReqVO.setState( DevRentStateEnum.RECEIVED.getState() );
             updateDevRent( createReqVO );
 
             JobRecordSaveReqVO jobRecordSaveReqVO = new JobRecordSaveReqVO();
@@ -208,7 +200,7 @@
             jobRecordSaveReqVO.setPatId(createReqVO.getPatId());
             jobRecordSaveReqVO.setPatName(createReqVO.getPatName());
             jobRecordSaveReqVO.setJobTime(createReqVO.getRentTime());
-            jobRecordSaveReqVO.setJobType( DevRentStateEnum.READY.getState() );
+            jobRecordSaveReqVO.setJobType( DevRentStateEnum.RECEIVED.getState() );
             jobRecordSaveReqVO.setRemark(createReqVO.getRemark());
             jobRecordSaveReqVO.setSummary("");
             jobRecordSaveReqVO.setCheckType( createReqVO.getCheckType() );
@@ -217,12 +209,12 @@
             jobRecordMapper.insert(jobRecord);
         } else {
             // 鎾ら攢 鏀惧純鎿嶄綔
-            createReqVO.setState( DevRentStateEnum.READY.getState() );
+            createReqVO.setState( DevRentStateEnum.RECEIVED.getState() );
 
             updateDevRent( createReqVO );
 
             jobRecordDO.setDevId(createReqVO.getDevId());
-            jobRecordDO.setJobType( DevRentStateEnum.READY.getState() );
+            jobRecordDO.setJobType( DevRentStateEnum.RECEIVED.getState() );
             jobRecordDO.setJobTime(createReqVO.getRentTime());
             jobRecordDO.setRemark(createReqVO.getRemark());
             jobRecordDO.setUpdater(String.valueOf(userId));
@@ -277,7 +269,7 @@
 
         // 绗竴娆� 瀹夎鎿嶄綔
         if (null == jobRecordDO) {
-            List<DevRentDO>  devRentDOList = devRentMapper.selectByPatAndChecktypeAndState(createReqVO.getPatId(), createReqVO.getCheckType(), DevRentStateEnum.READY.getState());
+            List<DevRentDO>  devRentDOList = devRentMapper.selectByPatAndChecktypeAndState(createReqVO.getPatId(), createReqVO.getCheckType(), DevRentStateEnum.RECEIVED.getState());
             if (devRentDOList.size() == 0)
                 throw exception(DEV_INSTALL_NOT_RECEIVED);
             else if (devRentDOList.size() != 1) {
@@ -488,13 +480,13 @@
 
         DevRentSaveReqVO createReqVO = BeanUtils.toBean(cancelReqVO, DevRentSaveReqVO.class);
         createReqVO.setDevId(null);
-        createReqVO.setState( DevRentStateEnum.READY_CANCELLED.getState());
+        createReqVO.setState( DevRentStateEnum.RECEIVED_CANCELLED.getState());
 
         Long rent_id = createReqVO.getId();
 
         List<Integer> jobTypeList = new ArrayList<Integer>();
-        jobTypeList.add( DevRentStateEnum.READY.getState());
-        jobTypeList.add( DevRentStateEnum.READY_CANCELLED.getState());
+        jobTypeList.add( DevRentStateEnum.RECEIVED.getState());
+        jobTypeList.add( DevRentStateEnum.RECEIVED_CANCELLED.getState());
         JobRecordDO jobRecordDO = jobRecordMapper.selectByRentIdDocId(rent_id, userId, jobTypeList);
         if (null == jobRecordDO) {
             List<DevRentDO>  devRentDOList = devRentMapper.selectByPatAndChecktypeAndState(createReqVO.getPatId(), createReqVO.getCheckType(), DevRentStateEnum.FREE.getState());
@@ -503,7 +495,7 @@
 
             rent_id = devRentDOList.getFirst().getId();
             createReqVO.setId( rent_id );
-            createReqVO.setState( DevRentStateEnum.READY_CANCELLED.getState() );
+            createReqVO.setState( DevRentStateEnum.RECEIVED_CANCELLED.getState() );
             updateDevRent( createReqVO );
 
             JobRecordSaveReqVO jobRecordSaveReqVO = new JobRecordSaveReqVO();
@@ -513,7 +505,7 @@
             jobRecordSaveReqVO.setDocName(userNickname);
             jobRecordSaveReqVO.setPatId(createReqVO.getPatId());
             jobRecordSaveReqVO.setPatName(createReqVO.getPatName());
-            jobRecordSaveReqVO.setJobType( DevRentStateEnum.READY_CANCELLED.getState() );
+            jobRecordSaveReqVO.setJobType( DevRentStateEnum.RECEIVED_CANCELLED.getState() );
             jobRecordSaveReqVO.setJobTime(createReqVO.getRentTime());
             jobRecordSaveReqVO.setRemark(createReqVO.getRemark());
             jobRecordSaveReqVO.setSummary("");
@@ -525,7 +517,7 @@
             updateDevRent( createReqVO );
 
             jobRecordDO.setDevId(null);
-            jobRecordDO.setJobType(DevRentStateEnum.READY_CANCELLED.getState());
+            jobRecordDO.setJobType(DevRentStateEnum.RECEIVED_CANCELLED.getState());
             jobRecordDO.setJobTime(createReqVO.getRentTime());
             jobRecordDO.setRemark(createReqVO.getRemark());
             jobRecordDO.setUpdater(String.valueOf(userId));
@@ -558,7 +550,7 @@
         jobTypeList.add( DevRentStateEnum.INSTALL_CANCELLED.getState());
         JobRecordDO jobRecordDO = jobRecordMapper.selectByRentIdDocId(rent_id, userId, jobTypeList);
         if (null == jobRecordDO) {
-            List<DevRentDO>  devRentDOList = devRentMapper.selectByPatAndChecktypeAndState(createReqVO.getPatId(), createReqVO.getCheckType(), DevRentStateEnum.READY.getState());
+            List<DevRentDO>  devRentDOList = devRentMapper.selectByPatAndChecktypeAndState(createReqVO.getPatId(), createReqVO.getCheckType(), DevRentStateEnum.RECEIVED.getState());
             if (devRentDOList.size() != 1)
                 throw exception(DEV_INSTALL_EXIST);
 
@@ -692,14 +684,15 @@
 
     @Override
     public PageResult<DevRentDO> getDevRentPage(DevRentPageReqVO pageReqVO) {
+        pageReqVO.setState(0);
         return devRentMapper.selectPage(pageReqVO);
     }
 
     @Override
-    public DevRentDO getInstalledOrCancelledRent(DevRentSearchReqVO searchReqVO) {
+    public DevRentDO getExistingRent(DevRentSearchReqVO searchReqVO) {
         List<Integer> stateList = new ArrayList<>();
         stateList.add( DevRentStateEnum.INSTALLED.getState() );
-        stateList.add( DevRentStateEnum.INSTALL_CANCELLED.getState());
+        stateList.add( DevRentStateEnum.RECEIVED.getState());
         searchReqVO.setStateList( stateList );
         return devRentMapper.getRentByState(searchReqVO);
     }
@@ -715,8 +708,8 @@
     @Override
     public DevRentDO getReadyOrCancelledRent(DevRentSearchReqVO searchReqVO) {
         List<Integer> stateList = new ArrayList<>();
-        stateList.add( DevRentStateEnum.READY.getState() );
-        stateList.add( DevRentStateEnum.READY_CANCELLED.getState());
+        stateList.add( DevRentStateEnum.RECEIVED.getState() );
+        stateList.add( DevRentStateEnum.RECEIVED_CANCELLED.getState());
         searchReqVO.setStateList( stateList );
         return devRentMapper.getRentByState(searchReqVO);
     }
@@ -838,7 +831,7 @@
     private void procAffinityWhenRoutineFinish(String patId, Integer[] affinityCheckTypes) {
         // 濡傛灉瀛樺湪 [浜插拰-鎺掗槦] 浜插拰椤癸紝鍒欓�夋嫨 鍏朵腑涓�涓翰鍜岄」 鎺ユ浛鍏� 澶勪簬 [灏辫瘖涓璢
         List<QueueDO> affinityAffinityWaitingItems = queueMapper.getCurPatGivenCheckTypesAndStatus(
-                                patId, affinityCheckTypes, QueueStatusEnum.AFFINITY_WAITING.getStatus());
+                                patId, affinityCheckTypes, QueueStatusEnum.AFFINITY.getStatus());
         if (!affinityAffinityWaitingItems.isEmpty()) {
             QueueDO tmpQueueDO = affinityAffinityWaitingItems.get(0);
             tmpQueueDO.setStatus(QueueStatusEnum.ONSTAGE.getStatus());
@@ -846,20 +839,25 @@
         }
     }
 
+    /**
+     * 棰嗙敤瀹屾垚锛屼富鍔ㄥ姹備緷闄�
+     */
     private void procAffinityWhenReadyFinish(/*IN,OUT*/QueueDO bedOnStageQueueItem, Integer[] affinityCheckTypes) {
-        // 濡傛灉瀛樺湪 [瀹夎涓璢 浜插拰椤癸紝鍒欒窡闅忓叾涓竴涓翰鍜岄」
-        List<QueueDO> affinityInstallingItems = queueMapper.getCurPatGivenCheckTypesAndStatus(
-                bedOnStageQueueItem.getPatId(), affinityCheckTypes, QueueStatusEnum.INSTALLING.getStatus());
+        // 濡傛灉瀛樺湪 [瀹夎涓璢 [瀹夎杩囧彿] [瀹夎鍙洖] 鑳借渚濋檮鐨勬鏌ラ」锛屽垯渚濋檮鍒板叾涓竴涓鏌ラ」
+        List<QueueDO> affinityInstallingItems = queueMapper.getCurPatGivenCheckTypesAndStatusList(
+                bedOnStageQueueItem.getPatId(), affinityCheckTypes,
+                List.of(QueueStatusEnum.INSTALLING.getStatus(), QueueStatusEnum.PASSED_INSTALL.getStatus(),
+                        QueueStatusEnum.RECALLED_INSTALL.getStatus()));
         if (!affinityInstallingItems.isEmpty()) {
             QueueDO affinityInstallingItem = affinityInstallingItems.get(0);
-            bedOnStageQueueItem.setStatus(QueueStatusEnum.AFFINITY_RECEIVED.getStatus()); // 浜插拰-棰嗙敤
+            bedOnStageQueueItem.setStatus(QueueStatusEnum.AFFINITY_INSTALL.getStatus()); // 浜插拰-棰嗙敤
             bedOnStageQueueItem.setRoomId( affinityInstallingItem.getRoomId() );
             bedOnStageQueueItem.setBedNo( affinityInstallingItem.getBedNo() );  // 棰嗙敤 鍒� 瀹夎 鍙兘浼氬湪涓嶅悓宸ヤ綅
         }
 
         // 濡傛灉瀛樺湪 [浜插拰-鎺掗槦] 浜插拰椤癸紝鍒欓�夋嫨 鍏朵腑涓�涓翰鍜岄」 鎺ユ浛鍏� 澶勪簬 [灏辫瘖涓璢
         List<QueueDO> affinityAffinityWaitingItems = queueMapper.getCurPatGivenCheckTypesAndStatus(
-                bedOnStageQueueItem.getPatId(), affinityCheckTypes, QueueStatusEnum.AFFINITY_WAITING.getStatus());
+                bedOnStageQueueItem.getPatId(), affinityCheckTypes, QueueStatusEnum.AFFINITY.getStatus());
         if (!affinityAffinityWaitingItems.isEmpty()) {
             QueueDO tmpQueueDO = affinityAffinityWaitingItems.get(0);
             tmpQueueDO.setStatus(QueueStatusEnum.ONSTAGE.getStatus());
@@ -867,9 +865,10 @@
         }
     }
 
+    // 濡傛灉瀛樺湪 [浜插拰-棰嗙敤] 浜插拰椤癸紝鍒欓�夋嫨 鍏朵腑涓�涓翰鍜岄」 鎺ユ浛鍏� 澶勪簬 [瀹夎涓璢
     private void procAffinityWhenInstallFinish(QueueDO bedInstallingQueueItem, Integer[] affinityCheckTypes) {
         List<QueueDO> affinityAffinityReceivedItems = queueMapper.getCurPatGivenCheckTypesAndStatus(
-                bedInstallingQueueItem.getPatId(), affinityCheckTypes, QueueStatusEnum.AFFINITY_RECEIVED.getStatus());
+                bedInstallingQueueItem.getPatId(), affinityCheckTypes, QueueStatusEnum.AFFINITY_INSTALL.getStatus());
         if (!affinityAffinityReceivedItems.isEmpty()) {
             QueueDO tmpQueueDO = affinityAffinityReceivedItems.get(0);
             tmpQueueDO.setStatus(QueueStatusEnum.INSTALLING.getStatus());

--
Gitblit v1.9.3