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/dal/dataobject/patient/PatDetails.java                    |    2 
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/appointment/AppointmentController.java   |   34 ++++++-----
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/appointment/AppointmentService.java               |    9 ++
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/appointment/vo/AppointmentPageReqVO.java |    2 
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/appointment/AppointmentMapper.java              |    2 
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/enums/AppointmentTypeEnum.java                            |   46 +++++++++++++++
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/appointment/AppointmentServiceImpl.java           |   81 +++++++++++++++++++++++---
 7 files changed, 147 insertions(+), 29 deletions(-)

diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/appointment/AppointmentController.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/appointment/AppointmentController.java
index 11bc862..a91ea71 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/appointment/AppointmentController.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/appointment/AppointmentController.java
@@ -26,6 +26,7 @@
 import cn.lihu.jh.framework.excel.core.util.ExcelUtils;
 
 import cn.lihu.jh.framework.apilog.core.annotation.ApiAccessLog;
+
 import static cn.lihu.jh.framework.apilog.core.enums.OperateTypeEnum.*;
 import static cn.lihu.jh.module.ecg.enums.ErrorCodeConstants.*;
 
@@ -73,6 +74,14 @@
         return success(true);
     }
 
+    @PostMapping("/updateStatus")
+    @Operation(summary = "鏇存柊鐢宠鐘舵��")
+    @PreAuthorize("@ss.hasPermission('ecg:appointment:update')")
+    public CommonResult<Boolean> updateAppointmentStatus(@Valid @RequestBody AppointmentSaveReqVO updateReqVO) {
+        appointmentService.updateAppointmentStatus(updateReqVO);
+        return success(true);
+    }
+
     @DeleteMapping("/delete")
     @Operation(summary = "鍒犻櫎棰勭害")
     @Parameter(name = "id", description = "缂栧彿", required = true)
@@ -95,9 +104,8 @@
     @Operation(summary = "鏍规嵁鎮h�呯紪鍙�.鏌ヨ褰撳ぉ棰勭害")
     @Parameter(name = "id", description = "缂栧彿", required = true, example = "1024")
     @PreAuthorize("@ss.hasPermission('ecg:appointment:query')")
-    public CommonResult<AppointmentRespVO> getCurAppointmentByPatId(@RequestParam("patId") String patId,
-                                                                    @RequestParam("checkType") Integer checkType) {
-        AppointmentDO appointment = appointmentService.getCurAppointmentByPatIdAndCheckType( patId, checkType );
+    public CommonResult<AppointmentRespVO> getCurAppointmentByPatId(@RequestParam("patId") String patId, @RequestParam("checkType") Integer checkType) {
+        AppointmentDO appointment = appointmentService.getCurAppointmentByPatIdAndCheckType(patId, checkType);
         return success(BeanUtils.toBean(appointment, AppointmentRespVO.class));
     }
 
@@ -106,7 +114,7 @@
     @Parameter(name = "id", description = "缂栧彿", required = true, example = "1024")
     @PreAuthorize("@ss.hasPermission('ecg:appointment:query')")
     public CommonResult<List<AppointmentRespVO>> queryAndCreateAppointmentByPatId(@RequestParam("patId") String patId) {
-        List<AppointmentDO> appointmentDOList = appointmentService.queryAndCreateAppointmentByPatId( patId );
+        List<AppointmentDO> appointmentDOList = appointmentService.queryAndCreateAppointmentByPatId(patId);
         return success(BeanUtils.toBean(appointmentDOList, AppointmentRespVO.class));
     }
 
@@ -115,9 +123,8 @@
     @Parameter(name = "id", description = "缂栧彿", required = true, example = "1024")
     @PreAuthorize("@ss.hasPermission('ecg:appointment:query')")
     public CommonResult<AppointmentRespVO> queryHisByPatient(@RequestParam("patId") String patId) {
-        List<AppointmentDO> appointmentList = appointmentService.getAppointmentExtermal( patId );
-        if ( 0 == appointmentList.size() )
-            return error(APPOINTMENT_NOT_BILLING);
+        List<AppointmentDO> appointmentList = appointmentService.getAppointmentExtermal(patId);
+        if (0 == appointmentList.size()) return error(APPOINTMENT_NOT_BILLING);
         return success(BeanUtils.toBean(appointmentList.get(0), AppointmentRespVO.class));
     }
 
@@ -125,7 +132,6 @@
     @Operation(summary = "鑾峰緱棰勭害鍒嗛〉")
     @PreAuthorize("@ss.hasPermission('ecg:appointment:query')")
     public CommonResult<PageResult<AppointmentRespVO>> getAppointmentPage(@Valid AppointmentPageReqVO pageReqVO) {
-        pageReqVO.setStatus("1");
         PageResult<AppointmentDO> pageResult = appointmentService.getAppointmentPage(pageReqVO);
         return success(BeanUtils.toBean(pageResult, AppointmentRespVO.class));
     }
@@ -134,13 +140,11 @@
     @Operation(summary = "瀵煎嚭棰勭害 Excel")
     @PreAuthorize("@ss.hasPermission('ecg:appointment:export')")
     @ApiAccessLog(operateType = EXPORT)
-    public void exportAppointmentExcel(@Valid AppointmentPageReqVO pageReqVO,
-              HttpServletResponse response) throws IOException {
+    public void exportAppointmentExcel(@Valid AppointmentPageReqVO pageReqVO, HttpServletResponse response) throws IOException {
         pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
         List<AppointmentDO> list = appointmentService.getAppointmentPage(pageReqVO).getList();
         // 瀵煎嚭 Excel
-        ExcelUtils.write(response, "棰勭害.xls", "鏁版嵁", AppointmentRespVO.class,
-                        BeanUtils.toBean(list, AppointmentRespVO.class));
+        ExcelUtils.write(response, "棰勭害.xls", "鏁版嵁", AppointmentRespVO.class, BeanUtils.toBean(list, AppointmentRespVO.class));
     }
 
     @PostMapping("/confirm")
@@ -148,7 +152,7 @@
     @PreAuthorize("@ss.hasPermission('ecg:appointment:confirm')")
     public CommonResult<Integer> appointmentConfirm(@RequestBody AppointmentConfirmReqVO confirmReqVO) {
         confirmReqVO.setIsVip(0);
-        Integer newSeqNo = appointmentService.appoitmentConfirm( confirmReqVO );
+        Integer newSeqNo = appointmentService.appoitmentConfirm(confirmReqVO);
         return success(newSeqNo);
     }
 
@@ -157,8 +161,8 @@
     @PreAuthorize("@ss.hasPermission('ecg:appointment:confirm')")
     public CommonResult<Integer> appointmentConfirmVip(@RequestBody AppointmentConfirmReqVO confirmReqVO) {
         confirmReqVO.setIsVip(1);
-        confirmReqVO.setBookDate( LocalDate.now() );
-        Integer newSeqNo = appointmentService.appoitmentConfirm( confirmReqVO );
+        confirmReqVO.setBookDate(LocalDate.now());
+        Integer newSeqNo = appointmentService.appoitmentConfirm(confirmReqVO);
         return success(newSeqNo);
     }
 
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/appointment/vo/AppointmentPageReqVO.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/appointment/vo/AppointmentPageReqVO.java
index 99c449b..b37b303 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/appointment/vo/AppointmentPageReqVO.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/appointment/vo/AppointmentPageReqVO.java
@@ -80,7 +80,7 @@
     private String bookSrc;
 
     @Schema(description = "鐢宠鍗曠姸鎬�")
-    private String status;
+    private String[] status;
 
     @Schema(description = "宸蹭粯娆�")
     private Integer paid;
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/patient/PatDetails.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/patient/PatDetails.java
index fc4c9ff..8d339f5 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/patient/PatDetails.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/patient/PatDetails.java
@@ -1,5 +1,6 @@
 package cn.lihu.jh.module.ecg.dal.dataobject.patient;
 
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import lombok.AllArgsConstructor;
 import lombok.Builder;
 import lombok.Data;
@@ -9,6 +10,7 @@
 @Builder
 @NoArgsConstructor
 @AllArgsConstructor
+@JsonIgnoreProperties(ignoreUnknown = true)
 public class PatDetails {
     String Id;
     String Name;
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/appointment/AppointmentMapper.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/appointment/AppointmentMapper.java
index d864a17..0065aa4 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/appointment/AppointmentMapper.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/appointment/AppointmentMapper.java
@@ -40,7 +40,7 @@
                 .eqIfPresent(AppointmentDO::getBookCheckType, reqVO.getBookCheckType())
                 .eqIfPresent(AppointmentDO::getBookSrc, reqVO.getBookSrc())
                 .eqIfPresent(AppointmentDO::getPaid, reqVO.getPaid())
-                .eqIfPresent(AppointmentDO::getStatus, reqVO.getStatus())
+                .inIfPresent(AppointmentDO::getStatus, reqVO.getStatus())
                 .orderByDesc(AppointmentDO::getId));
     }
 
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/enums/AppointmentTypeEnum.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/enums/AppointmentTypeEnum.java
new file mode 100644
index 0000000..a46587a
--- /dev/null
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/enums/AppointmentTypeEnum.java
@@ -0,0 +1,46 @@
+package cn.lihu.jh.module.ecg.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * Action绫诲瀷鏋氫妇
+ */
+@Getter
+@AllArgsConstructor
+public enum AppointmentTypeEnum {
+    SQDKL("   1", "	鐢宠鍗曞紑绔�"),
+    SQDCX("  2", "鐢宠鍗曟挙閿�"),
+    JCDJ("  3	", "妫�鏌ョ櫥璁�"),
+    QXJC("  4", "	鍙栨秷妫�鏌�"),
+    JCKS("  5", "	妫�鏌ュ紑濮�"),
+    GZYJ("  6", "	缁欓�犲奖鍓�"),
+    JCJS("  7", "	妫�鏌ョ粨鏉�"),
+    BGSC("  8", "	鎶ュ憡鐢熸垚"),
+    BGCX("  9", "	鎶ュ憡鎾ら攢"),
+    BGSH("  10", "	鎶ュ憡瀹℃牳");
+
+    /**
+     * 绫诲瀷
+     */
+    private final String type;
+    /**
+     * 鎻忚堪
+     */
+    private final String description;
+
+    /**
+     * 鏍规嵁绫诲瀷鑾峰彇鏋氫妇
+     *
+     * @param type 绫诲瀷
+     * @return 鏋氫妇
+     */
+    public static String getByType(String type) {
+        for (AppointmentTypeEnum value : values()) {
+            if (value.getType().equals(type)) {
+                return value.getDescription();
+            }
+        }
+        return null;
+    }
+}
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/appointment/AppointmentService.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/appointment/AppointmentService.java
index 8d4b3d7..b8bf763 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/appointment/AppointmentService.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/appointment/AppointmentService.java
@@ -33,6 +33,13 @@
     void updateAppointment(@Valid AppointmentSaveReqVO updateReqVO);
 
     /**
+     * 鏇存柊棰勭害鐘舵��
+     *
+     * @param updateReqVO 鏇存柊淇℃伅
+     */
+    void updateAppointmentStatus(@Valid AppointmentSaveReqVO updateReqVO);
+
+    /**
      * 鍒犻櫎棰勭害
      *
      * @param id 缂栧彿
@@ -47,7 +54,6 @@
      */
     AppointmentDO getAppointment(Long id);
 
-
     /**
      * 鑾峰緱棰勭害鍒嗛〉
      *
@@ -55,7 +61,6 @@
      * @return 棰勭害鍒嗛〉
      */
     PageResult<AppointmentDO> getAppointmentPage(AppointmentPageReqVO pageReqVO);
-
 
     /**
      * 鐢宠鍗曞垱寤�
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