From a4c8c09a33ae26a460c7422f59b4d2f93d0f6dc5 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期一, 16 六月 2025 19:38:09 +0800
Subject: [PATCH] 代码提交

---
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/appointment/AppointmentServiceImpl.java |   81 +++++++++++++++++++++++++++++++++++-----
 1 files changed, 71 insertions(+), 10 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 d43196c..8060822 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
@@ -11,13 +11,17 @@
 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.enums.AppointmentTypeEnum;
 import cn.lihu.jh.module.ecg.enums.HisCheckCodeEnum;
 import cn.lihu.jh.module.ecg.feign.RemoteDataService;
 import cn.lihu.jh.module.ecg.service.config.EcgConfigService;
+import cn.lihu.jh.module.ecg.service.devrent.ApplicationTemplate;
 import cn.lihu.jh.module.ecg.service.queue.QueueService;
 import cn.lihu.jh.module.ecg.service.queuesequence.QueueSequenceService;
+import cn.lihu.jh.module.ecg.webservice.WebServiceClient;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.ibatis.annotations.Param;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.dao.DuplicateKeyException;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -61,6 +65,9 @@
     @Resource
     private AppointmentMapper appointmentMapper;
 
+    @Autowired
+    private WebServiceClient webServiceClient;
+
     @Override
     public Long createAppointment(AppointmentSaveReqVO createReqVO) {
         // 鎻掑叆
@@ -83,6 +90,56 @@
         // 鏇存柊
         AppointmentDO updateObj = BeanUtils.toBean(updateReqVO, AppointmentDO.class);
         appointmentMapper.updateById(updateObj);
+    }
+
+    @Override
+    public void updateAppointmentStatus(AppointmentSaveReqVO updateReqVO) {
+        // 鏍¢獙瀛樺湪
+        validateAppointmentExists(updateReqVO.getId());
+
+        // 鑾峰彇瀹屾暣鐨勯绾︿俊鎭�
+        AppointmentDO appointment = appointmentMapper.selectById(updateReqVO.getId());
+        if (appointment == null) {
+            throw exception(APPOINTMENT_NOT_EXISTS);
+        }
+
+        // 鏇存柊鐘舵��
+        appointment.setStatus(updateReqVO.getStatus());
+
+        // 璋冪敤HIS绯荤粺鏇存柊鐘舵��
+        String action = "S0405";
+        ApplicationTemplate app = new ApplicationTemplate();
+        String statusName = AppointmentTypeEnum.getByType(appointment.getStatus());
+        String message = app.getXML(
+            appointment.getApplyNo(),
+            appointment.getStatus(),
+            statusName,
+            null,
+            appointment.getPatDeptCode(),
+            appointment.getPatDeptDesc(),
+            appointment.getPatWardCode(),
+            appointment.getPatWardDesc(),
+            appointment.getPatBedNo(),
+            appointment.getEpisodeId(),
+            String.valueOf(appointment.getBookSrc()),
+            appointment.getPatId(),
+            appointment.getPatName()
+        );
+
+        try {
+            String response = webServiceClient.callJHFWTYRK(action, "", message);
+            if (response.contains("鏇存柊鎴愬姛")) {
+                // 鏇存柊鏈湴鏁版嵁搴�
+                appointmentMapper.updateById(appointment);
+
+
+            } else {
+                throw exception(APPOINTMENT_UPDATE_FAIL);
+            }
+        } catch (Exception e) {
+            log.error("[updateAppointmentStatus][鏇存柊棰勭害鐘舵�佸け璐� appointment({})]", appointment, e);
+            throw exception(APPOINTMENT_UPDATE_FAIL);
+        }
     }
 
     @Override
@@ -371,7 +428,6 @@
 
             // 灏咥ppointmentDO杞崲涓篈ppointmentSaveReqVO骞朵繚瀛�
             AppointmentSaveReqVO saveReqVO = BeanUtils.toBean(appointment, AppointmentSaveReqVO.class);
-            saveReqVO.setStatus("1");
             return createAppointment(saveReqVO);
         } catch (Exception e) {
             log.error("[handleAppointmentCreate][澶勭悊棰勭害鍒涘缓澶辫触 dataMap({})]", dataMap, e);
@@ -559,22 +615,27 @@
         // 瑙f瀽棰勭害鏃堕棿
         LocalDateTime bookTime = LocalDateTime.parse(bookTimeStr, DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
         LocalDate bookDate = bookTime.toLocalDate();
+        Integer bookTimeslot = null;
 
         // 鑾峰彇鏃堕棿娈�
-        String timeRange = (String) ((Map<String, Object>) actAppointment.get("ZDY")).get("time");
-        String[] time1 = timeRange.split(" ");
-        String[] times = time1[1].split("-");
-        String startTime = times[0].trim();
-        String endTime = times[1].trim();
-
-        // 杞崲鏃堕棿娈垫牸寮忎负hhmmhhmm
-        int bookTimeslot = Integer.parseInt(startTime.replace(":", "")) * 10000 + Integer.parseInt(endTime.replace(":", ""));
-
+        try {
+//            String timeRange = (String) ((Map<String, Object>) actAppointment.get("ZDY")).get("time");杩欒濡傛灉鏄洿鏂版搷浣滅殑鏃跺�欙紝鏈夊彲鑳芥姤绌烘寚閽�(浣嗕笉褰卞搷锛屽彲浠ヤ笉鐢ㄧ)
+            String timeRange = (String) ((Map<String, Object>) actAppointment.get("ZDY")).get("time");
+            String[] time1 = timeRange.split(" ");
+            String[] times = time1[1].split("-");
+            String startTime = times[0].trim();
+            String endTime = times[1].trim();
+            // 杞崲鏃堕棿娈垫牸寮忎负hhmmhhmm
+            bookTimeslot = Integer.parseInt(startTime.replace(":", "")) * 10000 + Integer.parseInt(endTime.replace(":", ""));
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
         // 鏇存柊棰勭害淇℃伅
         appointment.setBookDate(bookDate);
         appointment.setBookTimeslot(bookTimeslot);
         appointment.setBookTime(bookTime);
         appointment.setBookSrc(Integer.parseInt(bookSrc));
+        appointment.setStatus((String) ((Map<String, Object>) actAppointment.get("ZDY")).get("statusCode"));
 
         // 淇濆瓨鏇存柊
         appointmentMapper.updateById(appointment);

--
Gitblit v1.9.3