From 12c97309b50530c8c7f9c6d48641c79d07a44b2b Mon Sep 17 00:00:00 2001
From: eight <641137800@qq.com>
Date: 星期三, 30 十月 2024 17:18:49 +0800
Subject: [PATCH] update

---
 jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/enums/ErrorCodeConstants.java                           |    6 ++++--
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/appointment/AppointmentController.java |   11 +++++++++++
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/appointment/AppointmentService.java             |    2 +-
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/appointment/AppointmentServiceImpl.java         |   13 ++++++++++---
 4 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/enums/ErrorCodeConstants.java b/jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/enums/ErrorCodeConstants.java
index a212cfb..0469332 100644
--- a/jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/enums/ErrorCodeConstants.java
+++ b/jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/enums/ErrorCodeConstants.java
@@ -13,8 +13,10 @@
     ErrorCode ECG_CONFIG_ERROR = new ErrorCode(1_010_000_001, "蹇冪數妫�鏌ョ被鍨嬬殑鏈�澶у噯澶囦汉鏁伴厤缃笉涓�鑷�");
 
     ErrorCode APPOINTMENT_NOT_EXISTS = new ErrorCode(1_010_001_000, "棰勭害涓嶅瓨鍦�");
-    ErrorCode APPOINTMENT_NOT_TODAY = new ErrorCode(1_010_001_001, "涓嶆槸褰撳ぉ棰勭害");
-    ErrorCode APPOINTMENT_HAVE_QUEUED = new ErrorCode(1_010_001_002, "鎮ㄥ凡缁忓湪鎺掗槦涓簡");
+    ErrorCode APPOINTMENT_NOT_TODAY = new ErrorCode(1_010_001_010, "涓嶆槸褰撳ぉ棰勭害");
+    ErrorCode APPOINTMENT_EXIST_TODAY = new ErrorCode(1_010_001_020, "褰撳ぉ棰勭害宸插瓨鍦�");
+    ErrorCode APPOINTMENT_HAVE_QUEUED = new ErrorCode(1_010_001_030, "鎮ㄥ凡缁忓湪鎺掗槦涓簡");
+    ErrorCode APPOINTMENT_NOT_BILLING = new ErrorCode(1_010_001_040, "鏌ヨ涓嶅埌寮�鍗曚俊鎭�");
 
     ErrorCode ROOM_NOT_EXISTS = new ErrorCode(1_010_002_000, "璇婂鍜岃瘖鐤楀簥涓嶅瓨鍦�");
     ErrorCode ROOM_NOT_SIT = new ErrorCode(1_010_002_001, "璇烽噸鏂板氨搴�");
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 f3f1a93..b496554 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
@@ -116,6 +116,17 @@
         return success(BeanUtils.toBean(appointment, AppointmentRespVO.class));
     }
 
+    @GetMapping("/query-his-by-patient")
+    @Operation(summary = "浠嶩IS.鏌ヨ鎮h�呴绾�/寮�鍗曚俊鎭�")
+    @Parameter(name = "id", description = "缂栧彿", required = true, example = "1024")
+    @PreAuthorize("@ss.hasPermission('ecg:appointment:query')")
+    public CommonResult<AppointmentRespVO> queryHisByPatient(@RequestParam("patId") String patId) {
+        AppointmentDO appointment = appointmentService.getAppointmentExtermal( patId );
+        if ( null == appointment)
+            return error(APPOINTMENT_NOT_BILLING);
+        return success(BeanUtils.toBean(appointment, AppointmentRespVO.class));
+    }
+
     @GetMapping("/page")
     @Operation(summary = "鑾峰緱棰勭害鍒嗛〉")
     @PreAuthorize("@ss.hasPermission('ecg:appointment:query')")
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 0e0e198..24c35fc 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
@@ -61,7 +61,7 @@
      */
     PageResult<AppointmentDO> getAppointmentPage(AppointmentPageReqVO pageReqVO);
 
-    AppointmentDO getAppointmentExtermal(String mzzyh);
+    AppointmentDO getAppointmentExtermal(String patId);
 
     String appoitmentConfirm(AppointmentConfirmReqVO appointmentConfirmReqVO);
 }
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 ab08704..782f1a9 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
@@ -56,7 +56,12 @@
         appointment.setBookTime( LocalDateTime.now() );
         appointment.setBookSrc( 1 );
 
-        appointmentMapper.insert(appointment);
+        try {
+            appointmentMapper.insert(appointment);
+        } catch (DuplicateKeyException e) {
+            throw exception(APPOINTMENT_EXIST_TODAY);
+        }
+
         // 杩斿洖
         return appointment.getId();
     }
@@ -94,7 +99,7 @@
         // 鍏堜粠鍖婚櫌骞冲彴鏌ヨ
         AppointmentDO appointmentExtermal = getAppointmentExtermal( patId );
         if (null != appointmentExtermal && null != appointmentExtermal.getBookDate() && appointmentExtermal.getBookDate().isEqual(LocalDate.now()) ) {
-            // 鏌ヨDB涓� 鏄惁宸茬粡瀛樺湪
+            // 鏌ュ埌褰撳ぉ鐨勯绾﹀悗锛屾煡璇B涓� 鏄惁宸茬粡瀛樺湪
             AppointmentDO appointmentDO = appointmentMapper.getCurrentPatId( patId );
             if (null == appointmentDO ) {
                 appointmentExtermal.setBookSrc(0);
@@ -120,7 +125,9 @@
 
         // QueryRisReportList   queryEcgRequest
         RestApiResult<AppointmentExternal> result = remoteDataService.httpApi("queryEcgRequest", "ECG", "ECG", reqBodyVo);
-        result.getCode();
+        if (0 == result.getRow().size()) {
+            return null;
+        }
 
         AppointmentExternal appointmentExternal = result.getRow().get(0);
         AppointmentDO appointmentDO = BeanUtils.toBean( appointmentExternal, AppointmentDO.class );

--
Gitblit v1.9.3