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/service/appointment/AppointmentServiceImpl.java |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)

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());

--
Gitblit v1.9.3