From 4924f5e98bfbc78693466b667e768092181112eb Mon Sep 17 00:00:00 2001
From: eight <641137800@qq.com>
Date: 星期三, 20 十一月 2024 16:22:19 +0800
Subject: [PATCH] 预约小票打印

---
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/appointment/vo/AppointmentRespVO.java |    4 ++++
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/queue/QueueDO.java                      |    4 ++++
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/queue/vo/QueueSaveReqVO.java          |    3 +++
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceImpl.java                    |    5 +++++
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/queue/QueueMapper.java                       |    7 +++++++
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueService.java                        |    2 ++
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/appointment/AppointmentDO.java          |    2 ++
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/appointment/AppointmentServiceImpl.java        |   19 ++++++++++++++++---
 8 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/appointment/vo/AppointmentRespVO.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/appointment/vo/AppointmentRespVO.java
index cc545f9..8b3152e 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/appointment/vo/AppointmentRespVO.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/appointment/vo/AppointmentRespVO.java
@@ -91,6 +91,10 @@
     @ExcelProperty(value = "棰勭害妫�鏌ョ被鍨�", converter = DictConvert.class)
     private Integer bookCheckType;
 
+    @Schema(description = "鍐呴儴棰勭害缂栧彿", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("鍐呴儴棰勭害缂栧彿")
+    private Integer bookSeqNum;
+
     @Schema(description = "棰勭害鏉ユ簮锛歑绯荤粺銆佹姢澹墜鍔ㄩ绾�", requiredMode = Schema.RequiredMode.REQUIRED)
     @ExcelProperty("棰勭害鏉ユ簮锛歑绯荤粺銆佹姢澹墜鍔ㄩ绾�")
     private Integer bookSrc;
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/queue/vo/QueueSaveReqVO.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/queue/vo/QueueSaveReqVO.java
index 553a2f1..ebd3c91 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/queue/vo/QueueSaveReqVO.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/queue/vo/QueueSaveReqVO.java
@@ -20,6 +20,9 @@
     @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "21320")
     private Integer id;
 
+    @Schema(description = "鍐呴儴棰勭害缂栧彿", requiredMode = Schema.RequiredMode.REQUIRED, example = "21320")
+    private Long appointId;
+
     @Schema(description = "鎮h�呯紪鍙�", requiredMode = Schema.RequiredMode.REQUIRED, example = "30473")
     @NotEmpty(message = "鎮h�呯紪鍙蜂笉鑳戒负绌�")
     private String patId;
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/appointment/AppointmentDO.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/appointment/AppointmentDO.java
index 74a488b..0bce16b 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/appointment/AppointmentDO.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/appointment/AppointmentDO.java
@@ -134,5 +134,7 @@
     private LocalDateTime syncTime;
 
 
+    @TableField(exist = false)
+    private Integer bookSeqNum;
 
 }
\ No newline at end of file
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/queue/QueueDO.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/queue/QueueDO.java
index e12bd5c..dd6789d 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/queue/QueueDO.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/queue/QueueDO.java
@@ -31,6 +31,10 @@
     @TableId
     private Integer id;
     /**
+     * 鍐呴儴棰勭害缂栧彿
+     */
+    private Long appointId;
+    /**
      * 鎮h�呯紪鍙�
      */
     private String patId;
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 057296c..47cd7ca 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
@@ -194,6 +194,13 @@
             "</script>" )
     QueueDO getFirstItemByRoomAndStatus(@Param("roomId")Long roomId, @Param("curStatusList")List<Integer> curStatusList);
 
+    @Select("<script> " +
+            "select * from lihu.queue where appoint_id in ( " +
+            "       <foreach collection='appointIdList' separator=',' item='appointId'>" +
+            "           #{appointId} " +
+            "       </foreach> )" +
+            "</script>" )
+    List<QueueDO> selectBookSeqNumByAppointIdList(@Param("appointIdList") List<Long> appointIdList);
 
 /*
     @Select("select * from lihu.queue where room_id = #{roomId} and bed_no = #{bedNo} " +
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/appointment/AppointmentServiceImpl.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/appointment/AppointmentServiceImpl.java
index ce7d60c..e6fdb12 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/appointment/AppointmentServiceImpl.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/appointment/AppointmentServiceImpl.java
@@ -5,6 +5,7 @@
 import cn.lihu.jh.module.ecg.controller.admin.queue.vo.QueueSaveReqVO;
 import cn.lihu.jh.module.ecg.dal.dataobject.checktype.CheckTypeDO;
 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.feign.RemoteDataService;
 import cn.lihu.jh.module.ecg.feign.RestApiReqBodyVo;
 import cn.lihu.jh.module.ecg.feign.RestApiResult;
@@ -35,6 +36,7 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 import static cn.lihu.jh.framework.common.exception.util.ServiceExceptionUtil.exception;
 import static cn.lihu.jh.framework.common.pojo.CommonResult.error;
@@ -124,7 +126,7 @@
      */
     @Override
     public List<AppointmentDO> queryAndCreateAppointmentByPatId(String patCode) {
-        // 鍏堜粠鍖婚櫌骞冲彴鏌ヨ
+        // 浠庡尰闄㈠钩鍙版煡璇�
         List<AppointmentDO> appointmentExtermalList = getAppointmentExtermal( patCode );
 
         for ( int appointmentIndex = 0; appointmentIndex < appointmentExtermalList.size(); appointmentIndex++ ) {
@@ -132,12 +134,22 @@
             if (null == appointmentExtermal )
                 continue;
 
-            // 浠嶥B鏌ュ埌棰勭害锛屾槸鍚﹀凡缁忓瓨鍦�
+            // 浠嶥B鏌ヨ棰勭害锛屾槸鍚﹀凡缁忓瓨鍦�
             AppointmentDO appointmentDO = appointmentMapper.getByPatAndCheckTypeAndBookDate(appointmentExtermal.getPatId(), appointmentExtermal.getBookCheckType(), appointmentExtermal.getBookDate());
             if (null == appointmentDO) {
                 appointmentMapper.insert(appointmentExtermal);
             } else {
-                appointmentExtermal.setId( appointmentDO.getId() ); // 纭繚 杩斿洖鍊间繚鎶� appointment id
+                appointmentExtermal.setId( appointmentDO.getId() ); // 纭繚 杩斿洖鍊煎寘鍚� appointment id
+            }
+        }
+
+        // 鏌ヨ[queue琛╙琛ュ厖 book_seq_num 鍒拌繑鍥炲�间腑
+        if (!appointmentExtermalList.isEmpty()) {
+            List<Long> appointIdlist = appointmentExtermalList.stream().map(appointmentDO -> appointmentDO.getId()).toList();
+            List<QueueDO> simpleQueueDOList = queueService.selectBookSeqNumByAppointIdList(appointIdlist);
+            if (!simpleQueueDOList.isEmpty()) {
+                Map<Long, Integer> mapAppointIdVsBookSeqNo = simpleQueueDOList.stream().collect(Collectors.toMap(QueueDO::getAppointId, QueueDO::getBookSeqNum));
+                appointmentExtermalList.forEach(appointmentExterma -> appointmentExterma.setBookSeqNum(mapAppointIdVsBookSeqNo.get(appointmentExterma.getId())));
             }
         }
 
@@ -234,6 +246,7 @@
 
         try {
             QueueSaveReqVO queueSaveReqVO = new QueueSaveReqVO();
+            queueSaveReqVO.setAppointId(appointment.getId());
             queueSaveReqVO.setPatId(appointment.getPatId());
             queueSaveReqVO.setPatName(appointment.getPatName());
             queueSaveReqVO.setPatGender(appointment.getPatGender());
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 4fe42ef..660ea09 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
@@ -89,6 +89,8 @@
      */
     void queue(QueueSaveReqVO queueSaveReqVO);
 
+    List<QueueDO> selectBookSeqNumByAppointIdList(List<Long> appointIdList);
+
     /**
      * 甯歌妫�鏌� 鍖荤敓鍙笅涓�浣嶆偅鑰�
      */
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 573d8a8..96a4c0f 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
@@ -339,6 +339,11 @@
         startHurryUpOneCheckType( queue.getBookCheckType() );
     }
 
+    @Override
+    public List<QueueDO> selectBookSeqNumByAppointIdList(List<Long> appointIdList) {
+        return queueMapper.selectBookSeqNumByAppointIdList( appointIdList );
+    }
+
     // 甯歌妫�鏌� 鍙彿
     @Override
     public void finishNextPatient(Long roomId, String bedNo) {

--
Gitblit v1.9.3