From a156ddbb26693b8040f9dbbd7582a12c1fc8d61b Mon Sep 17 00:00:00 2001
From: eight <641137800@qq.com>
Date: 星期四, 07 十一月 2024 17:04:47 +0800
Subject: [PATCH] 预约序号
---
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/queuesequence/QueueSequenceMapper.java | 16 ++++-
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/appointment/vo/AppointmentConfirmReqVO.java | 2
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queuesequence/QueueSequenceServiceImpl.java | 32 ++++++++++
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/config/EcgConfigServiceImpl.java | 7 ++
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/config/MySpringEventListener.java | 2
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/appointment/AppointmentServiceImpl.java | 24 +++++++-
jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/enums/ErrorCodeConstants.java | 4 +
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/queue/QueueDO.java | 8 ++
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/queue/vo/QueueSaveReqVO.java | 8 ++
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/appointment/AppointmentController.java | 16 ++++-
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/config/EcgConfigService.java | 1
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queuesequence/QueueSequenceService.java | 3 +
13 files changed, 115 insertions(+), 10 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 45783c6..d3549ec 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
@@ -56,4 +56,8 @@
ErrorCode CHECK_TYPE_NOT_EXISTS = new ErrorCode(1_010_009_000, "妫�鏌ョ被鍨嬩笉瀛樺湪");
ErrorCode QUEUE_SEQUENCE_NOT_EXISTS = new ErrorCode(1_010_010_000, "褰撳ぉ搴忓彿涓嶅瓨鍦�");
+ ErrorCode QUEUE_SEQUENCE_TIMESLOT_FULL = new ErrorCode(1_010_010_002, "鏈椂娈靛簭鍙峰凡婊�");
+ ErrorCode QUEUE_SEQUENCE_TIMESLOT_EXCEPTION = new ErrorCode(1_010_010_002, "鏈椂娈靛簭鍙峰紓甯�");
+ ErrorCode QUEUE_SEQUENCE_TIMESLOT_VIP_FULL = new ErrorCode(1_010_010_003, "鏈椂娈礦IP搴忓彿宸叉弧");
+ ErrorCode QUEUE_SEQUENCE_TIMESLOT_VIP_EXCEPTION = new ErrorCode(1_010_010_003, "鏈椂娈礦IP搴忓彿寮傚父");
}
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/config/MySpringEventListener.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/config/MySpringEventListener.java
index fc93fb4..a0adc27 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/config/MySpringEventListener.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/config/MySpringEventListener.java
@@ -43,6 +43,8 @@
queueService.initCheckType();
+ ecgConfigService.readTimeSlotConfig();
+
BigScreenConfig bigScreenConfig = new BigScreenConfig();
// Integer waitingSize = Integer.valueOf(configApi.getConfigValueByKey(ECG_SCREEN_PANE_WAITING_KEY));
// Integer passedSize = Integer.valueOf(configApi.getConfigValueByKey(ECG_SCREEN_PANE_PASSED_KEY));
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 fa03b89..4bc8001 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
@@ -143,9 +143,19 @@
@PostMapping("/confirm")
@Operation(summary = "棰勭害纭")
@PreAuthorize("@ss.hasPermission('ecg:appointment:confirm')")
- public CommonResult<String> appointmentConfirm(@RequestBody AppointmentConfirmReqVO confirmReqVO) {
- appointmentService.appoitmentConfirm( confirmReqVO );
- return success("纭鎴愬姛");
+ public CommonResult<Integer> appointmentConfirm(@RequestBody AppointmentConfirmReqVO confirmReqVO) {
+ confirmReqVO.setIsVip(0);
+ Integer newSeqNo = appointmentService.appoitmentConfirm( confirmReqVO );
+ return success(newSeqNo);
+ }
+
+ @PostMapping("/confirm-vip")
+ @Operation(summary = "VIP棰勭害纭")
+ @PreAuthorize("@ss.hasPermission('ecg:appointment:confirm')")
+ public CommonResult<Integer> appointmentConfirmVip(@RequestBody AppointmentConfirmReqVO confirmReqVO) {
+ confirmReqVO.setIsVip(1);
+ 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/AppointmentConfirmReqVO.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/appointment/vo/AppointmentConfirmReqVO.java
index 945a197..c56e10d 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/appointment/vo/AppointmentConfirmReqVO.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/appointment/vo/AppointmentConfirmReqVO.java
@@ -42,4 +42,6 @@
//@NotNull(message = "棰勭害妫�鏌ョ被鍨嬩笉鑳戒负绌�")
private Integer bookCheckType;
+ private Integer isVip;
+
}
\ 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/queue/vo/QueueSaveReqVO.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/queue/vo/QueueSaveReqVO.java
index 964746e..e8b7809 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/queue/vo/QueueSaveReqVO.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/queue/vo/QueueSaveReqVO.java
@@ -40,6 +40,14 @@
@Schema(description = "棰勭害妫�鏌ョ被鍨�", example = "1")
private Integer bookCheckType;
+ @Schema(description = "棰勭害搴忓彿", requiredMode = Schema.RequiredMode.REQUIRED)
+ //@NotNull(message = "棰勭害搴忓彿涓嶈兘涓虹┖")
+ private Integer bookSeqNum;
+
+ @Schema(description = "鏄惁VIP", requiredMode = Schema.RequiredMode.REQUIRED)
+ //@NotNull(message = "鏄惁VIP")
+ private Integer isVip;
+
@Schema(description = "鎺掗槦搴忓彿", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "鎺掗槦搴忓彿涓嶈兘涓虹┖")
private Integer seqNum;
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/queue/QueueDO.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/queue/QueueDO.java
index 125292b..3fde382 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/queue/QueueDO.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/queue/QueueDO.java
@@ -55,6 +55,14 @@
*/
private Integer bookCheckType;
/**
+ * 棰勭害搴忓彿
+ */
+ private Integer bookSeqNum;
+ /**
+ * 鏄惁VIP
+ */
+ private Integer isVip;
+ /**
* 鎺掗槦搴忓彿
*/
private Integer seqNum;
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/queuesequence/QueueSequenceMapper.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/queuesequence/QueueSequenceMapper.java
index de7fafc..28c6e84 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/queuesequence/QueueSequenceMapper.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/queuesequence/QueueSequenceMapper.java
@@ -6,9 +6,8 @@
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.queuesequence.QueueSequenceDO;
-import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.*;
import cn.lihu.jh.module.ecg.controller.admin.queuesequence.vo.*;
-import org.apache.ibatis.annotations.Update;
/**
* 褰撳ぉ搴忓彿 Mapper
@@ -33,4 +32,15 @@
@Update("truncate table lihu.queue_sequence")
void clearQueueSequenceTable();
-}
\ No newline at end of file
+ @Select("select queue_no from lihu.queue_sequence where check_type=#{checkType} and time_slot=#{timeslot} and queue_no < queue_full for update; ")
+ Integer selectQueueNoForUpdate(@Param("checkType") Integer checkType, @Param("timeslot") Integer timeslot);
+
+ @Update("update lihu.queue_sequence set queue_no = queue_no + 1 where check_type=#{checkType} and time_slot=#{timeslot} and queue_no=#{curQueueNo} and queue_no < queue_full; ")
+ Integer updateGivenCheckTypeTimeslotSeqNo(@Param("checkType") Integer checkType, @Param("timeslot") Integer timeslot, @Param("curQueueNo") Integer curQueueNo);
+
+ @Select("select queue_vip_no from lihu.queue_sequence where check_type=#{checkType} and time_slot=#{timeslot} and queue_no < queue_full for update; ")
+ Integer selectQueueVipNoForUpdate(@Param("checkType") Integer checkType, @Param("timeslot") Integer timeslot);
+
+ @Update("update lihu.queue_sequence set queue_vip_no = queue_vip_no + 1 where check_type=#{checkType} and time_slot=#{timeslot} and queue_vip_no=#{curQueueVipNo} and queue_vip_no < queue_vip_full; ")
+ Integer updateGivenCheckTypeTimeslotVipSeqNo(@Param("checkType") Integer checkType, @Param("timeslot") Integer timeslot, @Param("curQueueVipNo") Integer curQueueVipNo);
+}
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 06a5461..945f967 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
@@ -70,5 +70,5 @@
List<AppointmentDO> getAppointmentExtermal(String patId);
- String appoitmentConfirm(AppointmentConfirmReqVO appointmentConfirmReqVO);
+ Integer 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 8c4c396..fb405e9 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
@@ -7,7 +7,9 @@
import cn.lihu.jh.module.ecg.feign.RestApiReqBodyVo;
import cn.lihu.jh.module.ecg.feign.RestApiResult;
import cn.lihu.jh.module.ecg.feign.dto.AppointmentExternal;
+import cn.lihu.jh.module.ecg.service.config.EcgConfigService;
import cn.lihu.jh.module.ecg.service.queue.QueueService;
+import cn.lihu.jh.module.ecg.service.queuesequence.QueueSequenceService;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -42,7 +44,13 @@
public class AppointmentServiceImpl implements AppointmentService {
@Resource
+ private EcgConfigService ecgConfigService;
+
+ @Resource
private RemoteDataService remoteDataService;
+
+ @Resource
+ private QueueSequenceService queueSequenceService;
@Resource
private QueueService queueService;
@@ -175,7 +183,7 @@
if (null != appointmentExternal.getReqExtBooktime() ) {
appointmentDO.setBookDate(DateUtils.ofUTC(appointmentExternal.getReqExtBooktime()).toLocalDate());
LocalDateTime bookStartTime = DateUtils.ofUTC(appointmentExternal.getReqExtBooktime());
- LocalDateTime bookEndTime = bookStartTime.plusMinutes(30);
+ LocalDateTime bookEndTime = bookStartTime.plusMinutes( ecgConfigService.getTimeslotLength());
appointmentDO.setBookTimeslot((bookStartTime.getHour() * 100 + bookStartTime.getMinute()) * 10000 + bookEndTime.getHour() * 100 + bookEndTime.getMinute());
}
@@ -190,13 +198,21 @@
@Override
@Transactional(rollbackFor = Exception.class)
- public String appoitmentConfirm(AppointmentConfirmReqVO confirmReqVO) {
+ public Integer appoitmentConfirm(AppointmentConfirmReqVO confirmReqVO) {
AppointmentDO appointment = getAppointment(confirmReqVO.getId());
if (null == appointment)
throw exception(PATIENT_NOT_EXISTS);
if ( !DateUtils.isToday(appointment.getBookDate()) )
throw exception( APPOINTMENT_NOT_TODAY);
+
+
+ Integer newSeqNo = null;
+ if (confirmReqVO.getIsVip() == 0) {
+ newSeqNo = queueSequenceService.distributeSeqNo(confirmReqVO.getBookCheckType(), confirmReqVO.getBookTimeslot());
+ } else {
+ newSeqNo = queueSequenceService.distributeVipSeqNo(confirmReqVO.getBookCheckType(), confirmReqVO.getBookTimeslot());
+ }
try {
QueueSaveReqVO queueSaveReqVO = new QueueSaveReqVO();
@@ -206,6 +222,8 @@
queueSaveReqVO.setBookDate(appointment.getBookDate());
queueSaveReqVO.setBookTimeslot(appointment.getBookTimeslot());
queueSaveReqVO.setBookCheckType(appointment.getBookCheckType());
+ queueSaveReqVO.setBookSeqNum( newSeqNo );
+ queueSaveReqVO.setIsVip( confirmReqVO.getIsVip() );
queueSaveReqVO.setPassed((byte) 0);
queueSaveReqVO.setExpired((byte) 0);
queueSaveReqVO.setPatDetails( appointment.getPatDeptDesc() + "-" + appointment.getPatWardDesc() + "-" + appointment.getPatBedNo());
@@ -214,7 +232,7 @@
throw exception(APPOINTMENT_HAVE_QUEUED);
}
- return "纭鎴愬姛";
+ return newSeqNo;
}
private Integer getCorrespondingCheckType(String strPlanDefItemcode) {
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/config/EcgConfigService.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/config/EcgConfigService.java
index 94e885e..02fcf3d 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/config/EcgConfigService.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/config/EcgConfigService.java
@@ -7,4 +7,5 @@
void resetScheduler();
void readTimeSlotConfig();
List<LocalTime> listTimeslot();
+ Integer getTimeslotLength();
}
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/config/EcgConfigServiceImpl.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/config/EcgConfigServiceImpl.java
index 2ed3279..3f969ff 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/config/EcgConfigServiceImpl.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/config/EcgConfigServiceImpl.java
@@ -39,6 +39,7 @@
private QueueSequenceService queueSequenceService;
List<LocalTime> timeslotList = null;
+ Integer timeslotLength = 0;
ScheduledTask startBizTask = null;
ScheduledTask closeBizTask = null;
@@ -85,6 +86,7 @@
@Override
public void readTimeSlotConfig() {
String strBookTimeslotLength = configApi.getConfigValueByKey(BOOK_TIMESLOT_LENGTH);
+ timeslotLength = Integer.valueOf(strBookTimeslotLength);
//String strBookTimeslotList = configApi.getConfigValueByKey(BOOK_TIMESLOT_LIST);
//timeslotList = Utils.parseTimeSlotList(strBookTimeslotList, Integer.valueOf(strBookTimeslotLength));
}
@@ -94,4 +96,9 @@
return timeslotList;
}
+ @Override
+ public Integer getTimeslotLength() {
+ return timeslotLength;
+ }
+
}
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queuesequence/QueueSequenceService.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queuesequence/QueueSequenceService.java
index 508784b..dccae89 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queuesequence/QueueSequenceService.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queuesequence/QueueSequenceService.java
@@ -54,4 +54,7 @@
PageResult<QueueSequenceDO> getQueueSequencePage(QueueSequencePageReqVO pageReqVO);
void resetQueueSequence();
+
+ Integer distributeSeqNo(Integer checkType, Integer timeslot);
+ Integer distributeVipSeqNo(Integer checkType, Integer timeslot);
}
\ 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/queuesequence/QueueSequenceServiceImpl.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queuesequence/QueueSequenceServiceImpl.java
index d99ebbd..ec1e59b 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queuesequence/QueueSequenceServiceImpl.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queuesequence/QueueSequenceServiceImpl.java
@@ -119,5 +119,37 @@
});
}
+ @Override
+ @Transactional
+ public Integer distributeSeqNo(Integer checkType, Integer timeslot) {
+ Integer curSeqNo = queueSequenceMapper.selectQueueNoForUpdate(checkType, timeslot);
+ if (null == curSeqNo) {
+ throw exception(QUEUE_SEQUENCE_TIMESLOT_FULL);
+ }
+
+ Integer updateRowNum = queueSequenceMapper.updateGivenCheckTypeTimeslotSeqNo(checkType, timeslot, curSeqNo);
+ if (null == updateRowNum || updateRowNum == 0) {
+ throw exception(QUEUE_SEQUENCE_TIMESLOT_EXCEPTION);
+ }
+
+ return curSeqNo + 1;
+ }
+
+ @Override
+ @Transactional
+ public Integer distributeVipSeqNo(Integer checkType, Integer timeslot) {
+ Integer curVipSeqNo = queueSequenceMapper.selectQueueVipNoForUpdate(checkType, timeslot);
+ if (null == curVipSeqNo) {
+ throw exception(QUEUE_SEQUENCE_TIMESLOT_FULL);
+ }
+
+ Integer updateRowNum = queueSequenceMapper.updateGivenCheckTypeTimeslotVipSeqNo(checkType, timeslot, curVipSeqNo);
+ if (null == updateRowNum || updateRowNum == 0) {
+ throw exception(QUEUE_SEQUENCE_TIMESLOT_EXCEPTION);
+ }
+
+ return curVipSeqNo + 1;
+ }
+
}
--
Gitblit v1.9.3