From a940b56e9781e2b4e56dbe05a896dba33a6905c6 Mon Sep 17 00:00:00 2001
From: eight <641137800@qq.com>
Date: 星期四, 19 九月 2024 17:13:25 +0800
Subject: [PATCH] 重叫功能 完成

---
 jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/enums/ErrorCodeConstants.java                 |    2 
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/call/vo/CallSaveReqVO.java   |   51 ++++
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/doctor/DoctorController.java |   56 +++++
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/call/CallController.java     |   83 +++++++
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/call/CallMapper.java                |   44 ++++
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/call/CallService.java                 |   70 ++++++
 sql/mysql/jh.sql                                                                                                  |   26 ++
 jh-module-ecg/jh-module-ecg-biz/src/main/resources/mapper/call/CallMapper.xml                                     |   12 +
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/call/vo/CallRespVO.java      |   67 ++++++
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/call/vo/CallPageReqVO.java   |   55 +++++
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/call/CallServiceImpl.java             |   86 +++++++
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/call/CallDO.java               |   75 ++++++
 12 files changed, 627 insertions(+), 0 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 429bdf9..df34a44 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
@@ -34,4 +34,6 @@
     ErrorCode DEV_DISMANTLE_EXIST = new ErrorCode(1_010_005_006, "褰撳ぉ宸叉湁鎷嗘満");
 
     ErrorCode JOB_RECORD_NOT_EXISTS = new ErrorCode(1_010_006_000, "宸ヤ綔璁板綍涓嶅瓨鍦�");
+
+    ErrorCode CALL_NOT_EXISTS = new ErrorCode(1_010_007_000, "鍙彿涓嶅瓨鍦�");
 }
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/call/CallController.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/call/CallController.java
new file mode 100644
index 0000000..3f238d7
--- /dev/null
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/call/CallController.java
@@ -0,0 +1,83 @@
+package cn.lihu.jh.module.ecg.controller.admin.call;
+
+import org.springframework.web.bind.annotation.*;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.security.access.prepost.PreAuthorize;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.Operation;
+
+import java.util.*;
+import java.io.IOException;
+
+import cn.lihu.jh.framework.common.pojo.PageParam;
+import cn.lihu.jh.framework.common.pojo.PageResult;
+import cn.lihu.jh.framework.common.pojo.CommonResult;
+import cn.lihu.jh.framework.common.util.object.BeanUtils;
+import static cn.lihu.jh.framework.common.pojo.CommonResult.success;
+
+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 cn.lihu.jh.module.ecg.controller.admin.call.vo.*;
+import cn.lihu.jh.module.ecg.dal.dataobject.call.CallDO;
+import cn.lihu.jh.module.ecg.service.call.CallService;
+
+import javax.annotation.Resource;
+import javax.annotation.security.PermitAll;
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.Valid;
+
+@Tag(name = "绠$悊鍚庡彴 - 鍙彿")
+@RestController
+@RequestMapping("/ecg/call")
+@Validated
+public class CallController {
+
+    @Resource
+    private CallService callService;
+
+    @PostMapping("/create")
+    @Operation(summary = "鍒涘缓鍙彿")
+    @PreAuthorize("@ss.hasPermission('ecg:call:create')")
+    public CommonResult<Integer> createCall(@Valid @RequestBody CallSaveReqVO createReqVO) {
+        return success(callService.createCall(createReqVO));
+    }
+
+    @PutMapping("/update")
+    @Operation(summary = "鏇存柊鍙彿")
+    @PreAuthorize("@ss.hasPermission('ecg:call:update')")
+    public CommonResult<Boolean> updateCall(@Valid @RequestBody CallSaveReqVO updateReqVO) {
+        callService.updateCall(updateReqVO);
+        return success(true);
+    }
+
+    @DeleteMapping("/delete")
+    @Operation(summary = "鍒犻櫎鍙彿")
+    @Parameter(name = "id", description = "缂栧彿", required = true)
+    @PreAuthorize("@ss.hasPermission('ecg:call:delete')")
+    public CommonResult<Boolean> deleteCall(@RequestParam("id") Integer id) {
+        callService.deleteCall(id);
+        return success(true);
+    }
+
+    @GetMapping("/get")
+    @Operation(summary = "鑾峰緱鍙彿")
+    @Parameter(name = "id", description = "缂栧彿", required = true, example = "1024")
+    @PreAuthorize("@ss.hasPermission('ecg:call:query')")
+    public CommonResult<CallRespVO> getCall(@RequestParam("id") Integer id) {
+        CallDO call = callService.getCall(id);
+        return success(BeanUtils.toBean(call, CallRespVO.class));
+    }
+
+    @GetMapping("/next")
+    @Operation(summary = "鑾峰緱涓嬩竴涓彨鍙�")
+    @PermitAll
+    public CommonResult<CallRespVO> nextCall() {
+        CallDO call = callService.getNextCall();
+        return success(BeanUtils.toBean(call, CallRespVO.class));
+    }
+
+}
\ No newline at end of file
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/call/vo/CallPageReqVO.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/call/vo/CallPageReqVO.java
new file mode 100644
index 0000000..9eb7e52
--- /dev/null
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/call/vo/CallPageReqVO.java
@@ -0,0 +1,55 @@
+package cn.lihu.jh.module.ecg.controller.admin.call.vo;
+
+import lombok.*;
+import java.util.*;
+import io.swagger.v3.oas.annotations.media.Schema;
+import cn.lihu.jh.framework.common.pojo.PageParam;
+import org.springframework.format.annotation.DateTimeFormat;
+import java.time.LocalDateTime;
+
+import static cn.lihu.jh.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@Schema(description = "绠$悊鍚庡彴 - 鍙彿鍒嗛〉 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class CallPageReqVO extends PageParam {
+
+    @Schema(description = "鎮h�呯紪鍙�", example = "1991")
+    private String patId;
+
+    @Schema(description = "鎮h�呭鍚�", example = "鏉庡洓")
+    private String patName;
+
+    @Schema(description = "鎮h�呮�у埆")
+    private Integer patGender;
+
+    @Schema(description = "鎺掗槦搴忓彿")
+    private Integer seqNum;
+
+    @Schema(description = "杩囧彿鏍囪")
+    private Integer passed;
+
+    @Schema(description = "棰勭害杩囨湡鏍囪")
+    private Integer expired;
+
+    @Schema(description = "鍙彿鐘舵�� 0 鏈挱 1 宸叉挱 ")
+    private Integer called;
+
+    @Schema(description = "鎻掗槦鏍囪")
+    private Integer jumpFlag;
+
+    @Schema(description = "璇婂缂栧彿", example = "30859")
+    private Long roomId;
+
+    @Schema(description = "璇婂鍚嶇О", example = "鏉庡洓")
+    private String roomName;
+
+    @Schema(description = "璇婄枟搴婄紪鍙�")
+    private String bedNo;
+
+    @Schema(description = "鍒涘缓鏃堕棿")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] createTime;
+
+}
\ No newline at end of file
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/call/vo/CallRespVO.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/call/vo/CallRespVO.java
new file mode 100644
index 0000000..ed0d51f
--- /dev/null
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/call/vo/CallRespVO.java
@@ -0,0 +1,67 @@
+package cn.lihu.jh.module.ecg.controller.admin.call.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.*;
+import java.util.*;
+import org.springframework.format.annotation.DateTimeFormat;
+import java.time.LocalDateTime;
+import com.alibaba.excel.annotation.*;
+
+@Schema(description = "绠$悊鍚庡彴 - 鍙彿 Response VO")
+@Data
+@ExcelIgnoreUnannotated
+public class CallRespVO {
+
+    @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "20296")
+    @ExcelProperty("id")
+    private Integer id;
+
+    @Schema(description = "鎮h�呯紪鍙�", requiredMode = Schema.RequiredMode.REQUIRED, example = "1991")
+    @ExcelProperty("鎮h�呯紪鍙�")
+    private String patId;
+
+    @Schema(description = "鎮h�呭鍚�", requiredMode = Schema.RequiredMode.REQUIRED, example = "鏉庡洓")
+    @ExcelProperty("鎮h�呭鍚�")
+    private String patName;
+
+    @Schema(description = "鎮h�呮�у埆")
+    @ExcelProperty("鎮h�呮�у埆")
+    private Integer patGender;
+
+    @Schema(description = "鎺掗槦搴忓彿")
+    @ExcelProperty("鎺掗槦搴忓彿")
+    private Integer seqNum;
+
+    @Schema(description = "杩囧彿鏍囪")
+    @ExcelProperty("杩囧彿鏍囪")
+    private Integer passed;
+
+    @Schema(description = "棰勭害杩囨湡鏍囪")
+    @ExcelProperty("棰勭害杩囨湡鏍囪")
+    private Integer expired;
+
+    @Schema(description = "鍙彿鐘舵�� 0 鏈挱 1 宸叉挱 ")
+    @ExcelProperty("鍙彿鐘舵�� 0 鏈挱 1 宸叉挱 ")
+    private Integer called;
+
+    @Schema(description = "鎻掗槦鏍囪")
+    @ExcelProperty("鎻掗槦鏍囪")
+    private Integer jumpFlag;
+
+    @Schema(description = "璇婂缂栧彿", example = "30859")
+    @ExcelProperty("璇婂缂栧彿")
+    private Long roomId;
+
+    @Schema(description = "璇婂鍚嶇О", example = "鏉庡洓")
+    @ExcelProperty("璇婂鍚嶇О")
+    private String roomName;
+
+    @Schema(description = "璇婄枟搴婄紪鍙�")
+    @ExcelProperty("璇婄枟搴婄紪鍙�")
+    private String bedNo;
+
+    @Schema(description = "鍒涘缓鏃堕棿", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("鍒涘缓鏃堕棿")
+    private LocalDateTime createTime;
+
+}
\ No newline at end of file
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/call/vo/CallSaveReqVO.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/call/vo/CallSaveReqVO.java
new file mode 100644
index 0000000..0320cb6
--- /dev/null
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/call/vo/CallSaveReqVO.java
@@ -0,0 +1,51 @@
+package cn.lihu.jh.module.ecg.controller.admin.call.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.*;
+
+import javax.validation.constraints.NotEmpty;
+import java.util.*;
+
+@Schema(description = "绠$悊鍚庡彴 - 鍙彿鏂板/淇敼 Request VO")
+@Data
+public class CallSaveReqVO {
+
+    @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "20296")
+    private Integer id;
+
+    @Schema(description = "鎮h�呯紪鍙�", requiredMode = Schema.RequiredMode.REQUIRED, example = "1991")
+    @NotEmpty(message = "鎮h�呯紪鍙蜂笉鑳戒负绌�")
+    private String patId;
+
+    @Schema(description = "鎮h�呭鍚�", requiredMode = Schema.RequiredMode.REQUIRED, example = "鏉庡洓")
+    @NotEmpty(message = "鎮h�呭鍚嶄笉鑳戒负绌�")
+    private String patName;
+
+    @Schema(description = "鎮h�呮�у埆")
+    private Integer patGender;
+
+    @Schema(description = "鎺掗槦搴忓彿")
+    private Integer seqNum;
+
+    @Schema(description = "杩囧彿鏍囪")
+    private Integer passed;
+
+    @Schema(description = "棰勭害杩囨湡鏍囪")
+    private Integer expired;
+
+    @Schema(description = "鍙彿鐘舵�� 0 鏈挱 1 宸叉挱 ")
+    private Integer called;
+
+    @Schema(description = "鎻掗槦鏍囪")
+    private Integer jumpFlag;
+
+    @Schema(description = "璇婂缂栧彿", example = "30859")
+    private Long roomId;
+
+    @Schema(description = "璇婂鍚嶇О", example = "鏉庡洓")
+    private String roomName;
+
+    @Schema(description = "璇婄枟搴婄紪鍙�")
+    private String bedNo;
+
+}
\ No newline at end of file
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/doctor/DoctorController.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/doctor/DoctorController.java
index 4036f2f..9bfa6fc 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/doctor/DoctorController.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/doctor/DoctorController.java
@@ -4,15 +4,18 @@
 import cn.lihu.jh.framework.common.pojo.CommonResult;
 import cn.lihu.jh.framework.common.util.object.BeanUtils;
 import cn.lihu.jh.framework.security.core.util.SecurityFrameworkUtils;
+import cn.lihu.jh.module.ecg.controller.admin.call.vo.CallSaveReqVO;
 import cn.lihu.jh.module.ecg.controller.admin.queue.vo.PatientStatisticVO;
 import cn.lihu.jh.module.ecg.controller.admin.queue.vo.QueueRespVO;
 import cn.lihu.jh.module.ecg.controller.admin.room.vo.RoomRespVO;
 import cn.lihu.jh.module.ecg.dal.dataobject.queue.QueueDO;
 import cn.lihu.jh.module.ecg.enums.QueueStatusEnum;
+import cn.lihu.jh.module.ecg.service.call.CallService;
 import cn.lihu.jh.module.ecg.service.queue.QueueService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
 import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
@@ -20,19 +23,25 @@
 import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
 
 import static cn.lihu.jh.framework.common.exception.enums.GlobalErrorCodeConstants.SUCCESS;
 import static cn.lihu.jh.framework.common.pojo.CommonResult.error;
 import static cn.lihu.jh.framework.common.pojo.CommonResult.success;
+import static cn.lihu.jh.module.ecg.enums.ErrorCodeConstants.ECG_INNER_ERROR;
 
 @Tag(name = "绠$悊鍚庡彴 - 鍖荤敓鍙彿")
 @RestController
 @RequestMapping("/ecg/doctor")
 @Validated
+@Slf4j
 public class DoctorController {
 
     @Resource
     private QueueService queueService;
+
+    @Resource
+    private CallService callService;
 
     @GetMapping("/bed-doctor-pause")
     @Operation(summary = "鍖荤敓鏆傚仠")
@@ -131,6 +140,15 @@
         queueStatusList.add(QueueStatusEnum.ONSTAGE.getStatus());
         queueStatusList.add(QueueStatusEnum.PASSED.getStatus());
         List<QueueDO> queueDOList = queueService.getDoctorQueueByStatus(roomId, bedNo, queueStatusList);
+
+        // 杩囨护鍑�  灏辫瘖涓殑锛屽噯澶囧彨鍙�
+        QueueDO onStageItem = queueDOList.stream().filter(item -> Objects.equals(item.getStatus(), QueueStatusEnum.ONSTAGE.getStatus())).findFirst().orElse(null);
+        if (null != onStageItem) {
+            CallSaveReqVO callSaveReqVO = BeanUtils.toBean(onStageItem, CallSaveReqVO.class);
+            callSaveReqVO.setId(null);
+            callService.createCall(callSaveReqVO);
+        }
+
         return success(BeanUtils.toBean(queueDOList, QueueRespVO.class));
     }
 
@@ -150,9 +168,47 @@
         queueStatusList.add(QueueStatusEnum.ONSTAGE.getStatus());
         queueStatusList.add(QueueStatusEnum.PASSED.getStatus());
         List<QueueDO> queueDOList = queueService.getDoctorQueueByStatus(roomId, bedNo, queueStatusList);
+
+        // 杩囨护鍑�  灏辫瘖涓殑锛屽噯澶囧彨鍙�
+        QueueDO onStageItem = queueDOList.stream().filter(item -> Objects.equals(item.getStatus(), QueueStatusEnum.ONSTAGE.getStatus())).findFirst().orElse(null);
+        if (null != onStageItem) {
+            CallSaveReqVO callSaveReqVO = BeanUtils.toBean(onStageItem, CallSaveReqVO.class);
+            callSaveReqVO.setId(null);
+            callService.createCall(callSaveReqVO);
+        }
+
         return success(BeanUtils.toBean(queueDOList, QueueRespVO.class));
     }
 
+    @GetMapping("/call-again")
+    @Operation(summary = "閲嶅彨銆佹偅鑰�")
+    @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "116")
+    @Parameter(name = "bedNo", description = "宸ヤ綅缂栧彿", required = true, example = "B2")
+    @PreAuthorize("@ss.hasPermission('ecg:doctor:task')")
+    public CommonResult<String> callAgainPatient(
+            @RequestParam("roomId") Long roomId,
+            @RequestParam("bedNo") String bedNo)
+    {
+        List<Byte> queueStatusList = new ArrayList<>();
+        queueStatusList.add(QueueStatusEnum.ONSTAGE.getStatus());
+        List<QueueDO> queueDOList = queueService.getDoctorQueueByStatus(roomId, bedNo, queueStatusList);
+
+        if (queueDOList.isEmpty())
+            return success("鏃犲氨璇婁腑鎮h��");
+
+        if (queueDOList.size() > 1) {
+            log.error("room {} bed {} have {} 灏辫瘖涓偅鑰�", roomId, bedNo, queueDOList.size());
+            return error(ECG_INNER_ERROR);
+        }
+
+        QueueDO onStageItem = queueDOList.get(0);
+        CallSaveReqVO callSaveReqVO = BeanUtils.toBean(onStageItem, CallSaveReqVO.class);
+        callSaveReqVO.setId(null);
+        callService.callAgain(callSaveReqVO);
+
+        return success("鎿嶄綔鎴愬姛");
+    }
+
     @GetMapping("/get-patient-list")
     @Operation(summary = "鍙栨偅鑰呭垪琛�")
     @Parameter(name = "roomId", description = "璇婂缂栧彿", required = true, example = "116")
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/call/CallDO.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/call/CallDO.java
new file mode 100644
index 0000000..b75619d
--- /dev/null
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/call/CallDO.java
@@ -0,0 +1,75 @@
+package cn.lihu.jh.module.ecg.dal.dataobject.call;
+
+import lombok.*;
+import java.util.*;
+import java.time.LocalDateTime;
+import java.time.LocalDateTime;
+import com.baomidou.mybatisplus.annotation.*;
+import cn.lihu.jh.framework.mybatis.core.dataobject.BaseDO;
+
+/**
+ * 鍙彿 DO
+ *
+ * @author 椹墤娉�
+ */
+@TableName("call_patient")
+@KeySequence("call_seq") // 鐢ㄤ簬 Oracle銆丳ostgreSQL銆並ingbase銆丏B2銆丠2 鏁版嵁搴撶殑涓婚敭鑷銆傚鏋滄槸 MySQL 绛夋暟鎹簱锛屽彲涓嶅啓銆�
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class CallDO extends BaseDO {
+
+    /**
+     * id
+     */
+    @TableId
+    private Integer id;
+    /**
+     * 鎮h�呯紪鍙�
+     */
+    private String patId;
+    /**
+     * 鎮h�呭鍚�
+     */
+    private String patName;
+    /**
+     * 鎮h�呮�у埆
+     */
+    private Integer patGender;
+    /**
+     * 鎺掗槦搴忓彿
+     */
+    private Integer seqNum;
+    /**
+     * 杩囧彿鏍囪
+     */
+    private Integer passed;
+    /**
+     * 棰勭害杩囨湡鏍囪
+     */
+    private Integer expired;
+    /**
+     * 鍙彿鐘舵�� 0 鏈挱 1 宸叉挱 
+     */
+    private Integer called;
+    /**
+     * 鎻掗槦鏍囪
+     */
+    private Integer jumpFlag;
+    /**
+     * 璇婂缂栧彿
+     */
+    private Long roomId;
+    /**
+     * 璇婂鍚嶇О
+     */
+    private String roomName;
+    /**
+     * 璇婄枟搴婄紪鍙�
+     */
+    private String bedNo;
+
+}
\ 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/mysql/call/CallMapper.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/call/CallMapper.java
new file mode 100644
index 0000000..952896d
--- /dev/null
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/call/CallMapper.java
@@ -0,0 +1,44 @@
+package cn.lihu.jh.module.ecg.dal.mysql.call;
+
+import java.util.*;
+
+import cn.lihu.jh.framework.common.pojo.PageResult;
+import cn.lihu.jh.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.lihu.jh.framework.mybatis.core.mapper.BaseMapperX;
+import cn.lihu.jh.module.ecg.dal.dataobject.call.CallDO;
+import org.apache.ibatis.annotations.Mapper;
+import cn.lihu.jh.module.ecg.controller.admin.call.vo.*;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+/**
+ * 鍙彿 Mapper
+ *
+ * @author 椹墤娉�
+ */
+@Mapper
+public interface CallMapper extends BaseMapperX<CallDO> {
+
+    default PageResult<CallDO> selectPage(CallPageReqVO reqVO) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<CallDO>()
+                .eqIfPresent(CallDO::getPatId, reqVO.getPatId())
+                .likeIfPresent(CallDO::getPatName, reqVO.getPatName())
+                .eqIfPresent(CallDO::getPatGender, reqVO.getPatGender())
+                .eqIfPresent(CallDO::getSeqNum, reqVO.getSeqNum())
+                .eqIfPresent(CallDO::getPassed, reqVO.getPassed())
+                .eqIfPresent(CallDO::getExpired, reqVO.getExpired())
+                .eqIfPresent(CallDO::getCalled, reqVO.getCalled())
+                .eqIfPresent(CallDO::getJumpFlag, reqVO.getJumpFlag())
+                .eqIfPresent(CallDO::getRoomId, reqVO.getRoomId())
+                .likeIfPresent(CallDO::getRoomName, reqVO.getRoomName())
+                .eqIfPresent(CallDO::getBedNo, reqVO.getBedNo())
+                .betweenIfPresent(CallDO::getCreateTime, reqVO.getCreateTime())
+                .orderByDesc(CallDO::getId));
+    }
+
+    @Select("select * from lihu.call_patient where pat_id = #{patId} order by id desc limit 1")
+    CallDO getLatestPatientCall(@Param("patId") String patId);
+
+    @Select("select * from lihu.call_patient where called = 0 order by id limit 1")
+    CallDO getNextCall();
+}
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/call/CallService.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/call/CallService.java
new file mode 100644
index 0000000..119d4be
--- /dev/null
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/call/CallService.java
@@ -0,0 +1,70 @@
+package cn.lihu.jh.module.ecg.service.call;
+
+import java.util.*;
+import cn.lihu.jh.module.ecg.controller.admin.call.vo.*;
+import cn.lihu.jh.module.ecg.dal.dataobject.call.CallDO;
+import cn.lihu.jh.framework.common.pojo.PageResult;
+import cn.lihu.jh.framework.common.pojo.PageParam;
+
+import javax.validation.Valid;
+
+/**
+ * 鍙彿 Service 鎺ュ彛
+ *
+ * @author 椹墤娉�
+ */
+public interface CallService {
+
+    /**
+     * 鍒涘缓鍙彿
+     *
+     * @param createReqVO 鍒涘缓淇℃伅
+     * @return 缂栧彿
+     */
+    Integer createCall(@Valid CallSaveReqVO createReqVO);
+
+    /**
+     * 鏇存柊鍙彿
+     *
+     * @param updateReqVO 鏇存柊淇℃伅
+     */
+    void updateCall(@Valid CallSaveReqVO updateReqVO);
+
+    /**
+     * 鍒犻櫎鍙彿
+     *
+     * @param id 缂栧彿
+     */
+    void deleteCall(Integer id);
+
+    /**
+     * 鑾峰緱鍙彿
+     *
+     * @param id 缂栧彿
+     * @return 鍙彿
+     */
+    CallDO getCall(Integer id);
+
+    /**
+     * 鑾峰緱涓嬩竴涓彨鍙�
+     *
+     * @return 鍙彿
+     */
+    CallDO getNextCall();
+
+    /**
+     * 鑾峰緱鍙彿鍒嗛〉
+     *
+     * @param pageReqVO 鍒嗛〉鏌ヨ
+     * @return 鍙彿鍒嗛〉
+     */
+    PageResult<CallDO> getCallPage(CallPageReqVO pageReqVO);
+
+    /**
+     * 閲嶅彨
+     *
+     * @param createReqVO 鍒涘缓淇℃伅
+     * @return 缂栧彿
+     */
+    Integer callAgain(@Valid CallSaveReqVO createReqVO);
+}
\ No newline at end of file
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/call/CallServiceImpl.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/call/CallServiceImpl.java
new file mode 100644
index 0000000..08f348c
--- /dev/null
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/call/CallServiceImpl.java
@@ -0,0 +1,86 @@
+package cn.lihu.jh.module.ecg.service.call;
+
+import org.springframework.stereotype.Service;
+import org.springframework.validation.annotation.Validated;
+
+import cn.lihu.jh.module.ecg.controller.admin.call.vo.*;
+import cn.lihu.jh.module.ecg.dal.dataobject.call.CallDO;
+import cn.lihu.jh.framework.common.pojo.PageResult;
+import cn.lihu.jh.framework.common.util.object.BeanUtils;
+
+import cn.lihu.jh.module.ecg.dal.mysql.call.CallMapper;
+
+import javax.annotation.Resource;
+
+import static cn.lihu.jh.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.lihu.jh.module.ecg.enums.ErrorCodeConstants.*;
+
+/**
+ * 鍙彿 Service 瀹炵幇绫�
+ *
+ * @author 椹墤娉�
+ */
+@Service
+@Validated
+public class CallServiceImpl implements CallService {
+
+    @Resource
+    private CallMapper callMapper;
+
+    @Override
+    public Integer createCall(CallSaveReqVO createReqVO) {
+        // 鎻掑叆
+        CallDO call = BeanUtils.toBean(createReqVO, CallDO.class);
+        callMapper.insert(call);
+        // 杩斿洖
+        return call.getId();
+    }
+
+    @Override
+    public void updateCall(CallSaveReqVO updateReqVO) {
+        // 鏍¢獙瀛樺湪
+        validateCallExists(updateReqVO.getId());
+        // 鏇存柊
+        CallDO updateObj = BeanUtils.toBean(updateReqVO, CallDO.class);
+        callMapper.updateById(updateObj);
+    }
+
+    @Override
+    public void deleteCall(Integer id) {
+        // 鏍¢獙瀛樺湪
+        validateCallExists(id);
+        // 鍒犻櫎
+        callMapper.deleteById(id);
+    }
+
+    private void validateCallExists(Integer id) {
+        if (callMapper.selectById(id) == null) {
+            throw exception(CALL_NOT_EXISTS);
+        }
+    }
+
+    @Override
+    public CallDO getCall(Integer id) {
+        return callMapper.selectById(id);
+    }
+
+    @Override
+    public CallDO getNextCall() {
+        CallDO callDO = callMapper.getNextCall();
+        return callDO;
+    }
+
+    @Override
+    public PageResult<CallDO> getCallPage(CallPageReqVO pageReqVO) {
+        return callMapper.selectPage(pageReqVO);
+    }
+
+    @Override
+    public Integer callAgain(CallSaveReqVO createReqVO) {
+        CallDO callDO = callMapper.getLatestPatientCall(createReqVO.getPatId());
+        if (null != callDO && callDO.getCalled() == 0)
+            return 0;
+
+        return createCall(createReqVO);
+    }
+}
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/resources/mapper/call/CallMapper.xml b/jh-module-ecg/jh-module-ecg-biz/src/main/resources/mapper/call/CallMapper.xml
new file mode 100644
index 0000000..080faaf
--- /dev/null
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/resources/mapper/call/CallMapper.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.lihu.jh.module.ecg.dal.mysql.call.CallMapper">
+
+    <!--
+        涓�鑸儏鍐典笅锛屽敖鍙兘浣跨敤 Mapper 杩涜 CRUD 澧炲垹鏀规煡鍗冲彲銆�
+        鏃犳硶婊¤冻鐨勫満鏅紝渚嬪璇村琛ㄥ叧鑱旀煡璇紝鎵嶄娇鐢� XML 缂栧啓 SQL銆�
+        浠g爜鐢熸垚鍣ㄦ殏鏃跺彧鐢熸垚 Mapper XML 鏂囦欢鏈韩锛屾洿澶氭帹鑽� MybatisX 蹇�熷紑鍙戞彃浠舵潵鐢熸垚鏌ヨ銆�
+        鏂囨。鍙锛歨ttps://www.iocoder.cn/MyBatis/x-plugins/
+     -->
+
+</mapper>
\ No newline at end of file
diff --git a/sql/mysql/jh.sql b/sql/mysql/jh.sql
index 6c5e132..6ac4975 100644
--- a/sql/mysql/jh.sql
+++ b/sql/mysql/jh.sql
@@ -189,3 +189,29 @@
   KEY `idx_rent_id` (`rent_id`)
 ) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='宸ヤ綔璁板綍琛�';
 
+-- ----------------------------
+-- Table structure for call
+-- ----------------------------
+DROP TABLE IF EXISTS `call_patient`;
+SELECT * FROM lihu.call_patient;CREATE TABLE `call_patient` (
+  `id` int NOT NULL AUTO_INCREMENT COMMENT 'id',
+  `pat_id` varchar(30) NOT NULL COMMENT '鎮h�呯紪鍙�',
+  `pat_name` varchar(10) NOT NULL COMMENT '鎮h�呭鍚�',
+  `pat_gender` int DEFAULT NULL COMMENT '鎮h�呮�у埆',
+  `seq_num` int DEFAULT NULL COMMENT '鎺掗槦搴忓彿',
+  `passed` int DEFAULT '0' COMMENT '杩囧彿鏍囪',
+  `expired` int DEFAULT '0' COMMENT '棰勭害杩囨湡鏍囪',
+  `called` int DEFAULT '0' COMMENT '鍙彿鐘舵�� 0 鏈挱 1 宸叉挱 ',
+  `jump_flag` int DEFAULT '0' COMMENT '鎻掗槦鏍囪',
+  `room_id` bigint DEFAULT '0' COMMENT '璇婂缂栧彿',
+  `room_name` varchar(10) DEFAULT '' COMMENT '璇婂鍚嶇О',
+  `bed_no` varchar(10) DEFAULT '' COMMENT '璇婄枟搴婄紪鍙�',
+  `creator` varchar(10) DEFAULT '' COMMENT '鍒涘缓鑰�',
+  `create_time` datetime NOT NULL COMMENT '鍒涘缓鏃堕棿',
+  `updater` varchar(10) DEFAULT '' COMMENT '鏇存柊鑰�',
+  `update_time` datetime NOT NULL COMMENT '鏇存柊鏃堕棿',
+  `deleted` bit(1) DEFAULT b'0' COMMENT '鍒犻櫎鏍囪',
+  PRIMARY KEY (`id`),
+  KEY `idx_pat` (`pat_id`) USING BTREE,
+  KEY `idx_called` (`called`) USING BTREE
+) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='鍙彿琛�';

--
Gitblit v1.9.3