From 3629b1b4b917e15cae2247c1ade8815182412bea Mon Sep 17 00:00:00 2001
From: eight <641137800@qq.com>
Date: 星期三, 25 九月 2024 14:31:52 +0800
Subject: [PATCH] 设备准备 - 领用
---
jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/enums/DevRentStateEnum.java | 1
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/service/devrent/DevRentService.java | 8 ++++
jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/enums/DevStateEnum.java | 1
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/devrent/DevRentController.java | 13 ++++++
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/devrent/DevRentServiceImpl.java | 79 ++++++++++++++++++++++++++++++++++++++-
6 files changed, 101 insertions(+), 3 deletions(-)
diff --git a/jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/enums/DevRentStateEnum.java b/jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/enums/DevRentStateEnum.java
index a3f085a..67f6a74 100644
--- a/jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/enums/DevRentStateEnum.java
+++ b/jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/enums/DevRentStateEnum.java
@@ -16,6 +16,7 @@
@AllArgsConstructor
public enum DevRentStateEnum implements IntArrayValuable {
FREE(0, "寰呰鏈�"),
+ RECEIVED(5, "宸查鍙�"),
INSTALLED(10, "宸茶鏈�"),
DISMANTLED(20, "宸叉媶鏈�"),
CANCELLED(30, "宸叉斁寮�"),
diff --git a/jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/enums/DevStateEnum.java b/jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/enums/DevStateEnum.java
index 24d45d1..4cdd1da 100644
--- a/jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/enums/DevStateEnum.java
+++ b/jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/enums/DevStateEnum.java
@@ -16,6 +16,7 @@
@AllArgsConstructor
public enum DevStateEnum implements IntArrayValuable {
FREE(0, "绌洪棽"),
+ RECEIVED(5, "宸查鍙�"),
INUSE(10, "浣跨敤涓�"),
LOST(20, "宸查仐澶�");
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 f8ccfd3..1060f9f 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
@@ -36,6 +36,8 @@
ErrorCode DEV_LOSE_EXCEPTION = new ErrorCode(1_010_006_004, "閬楀け鍐呴儴閿欒");
ErrorCode DEV_INSTALL_EXIST = new ErrorCode(1_010_006_005, "褰撳ぉ宸叉湁瑁呮満");
ErrorCode DEV_DISMANTLE_EXIST = new ErrorCode(1_010_006_006, "褰撳ぉ宸叉湁鎷嗘満");
+ ErrorCode DEV_INSTALL_NOT_APPOINTMENT = new ErrorCode(1_010_006_007, "璇峰厛棰勭害纭");
+ ErrorCode DEV_INSTALL_NOT_RECEIVED = new ErrorCode(1_010_006_008, "璇峰厛棰嗙敤璁惧");
ErrorCode JOB_RECORD_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/devrent/DevRentController.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/devrent/DevRentController.java
index c6cf8dc..62016f1 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/devrent/DevRentController.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/devrent/DevRentController.java
@@ -47,6 +47,19 @@
@Resource
private DeviceService deviceService;
+ @PostMapping("/dev-ready")
+ @Operation(summary = "璁惧鍑嗗")
+ @PreAuthorize("@ss.hasPermission('ecg:doctor:task')")
+ public CommonResult<Long> devReady(@Valid @RequestBody DevRentSaveReqVO createReqVO) {
+ try {
+ return devRentService.readyOperation(createReqVO);
+ } catch ( RuntimeException runtimeException ) {
+ String err = ExceptionUtils.formatException( runtimeException );
+ log.error("devInstall: " + err);
+ return CommonResult.error(DEV_INSTALL_EXCEPTION);
+ }
+ }
+
@PostMapping("/dev-install")
@Operation(summary = "瑁呮満")
@PreAuthorize("@ss.hasPermission('ecg:doctor:task')")
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/devrent/DevRentService.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/devrent/DevRentService.java
index 239a208..3a8d70a 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/devrent/DevRentService.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/devrent/DevRentService.java
@@ -23,6 +23,14 @@
CommonResult<Long> registerOperation(@Valid DevRentSaveReqVO createReqVO);
/**
+ * 璁惧鍑嗗
+ *
+ * @param createReqVO 鍒涘缓淇℃伅
+ * @return 缂栧彿
+ */
+ CommonResult<Long> readyOperation(@Valid DevRentSaveReqVO createReqVO);
+
+ /**
* 瑁呮満
*
* @param createReqVO 鍒涘缓淇℃伅
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/devrent/DevRentServiceImpl.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/devrent/DevRentServiceImpl.java
index bbb01f7..549f067 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/devrent/DevRentServiceImpl.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/devrent/DevRentServiceImpl.java
@@ -54,6 +54,65 @@
}
@Override
+ public CommonResult<Long> readyOperation(DevRentSaveReqVO createReqVO) {
+ Long userId = SecurityFrameworkUtils.getLoginUserId();
+ String userNickname = SecurityFrameworkUtils.getLoginUserNickname();
+
+ // 鏍囨敞璁惧 宸查鍙�
+ Integer ret = markDevRecieved(createReqVO.getDevId());
+ if (null == ret || 0 == ret) {
+ return CommonResult.error(DEVICE_NOT_EXISTS);
+ }
+
+ Long rent_id = createReqVO.getId();
+ if (null == rent_id) {
+ List<DevRentDO> devRentDOList = devRentMapper.selectByPatIdAndState(createReqVO.getPatId(), DevRentStateEnum.FREE.getState());
+ if (devRentDOList.size() == 0)
+ return CommonResult.error(DEV_INSTALL_NOT_APPOINTMENT);
+ else if (devRentDOList.size() != 1) {
+ return CommonResult.error(DEV_INSTALL_EXCEPTION);
+ }
+
+ rent_id = devRentDOList.getFirst().getId();
+ createReqVO.setId( rent_id );
+ createReqVO.setState( DevRentStateEnum.RECEIVED.getState() );
+ updateDevRent( createReqVO );
+
+ JobRecordSaveReqVO jobRecordSaveReqVO = new JobRecordSaveReqVO();
+ jobRecordSaveReqVO.setRentId(rent_id);
+ jobRecordSaveReqVO.setDevId(createReqVO.getDevId());
+ jobRecordSaveReqVO.setDocId(userId);
+ jobRecordSaveReqVO.setDocName(userNickname);
+ jobRecordSaveReqVO.setPatId(createReqVO.getPatId());
+ jobRecordSaveReqVO.setPatName(createReqVO.getPatName());
+ jobRecordSaveReqVO.setJobTime(createReqVO.getRentTime());
+ jobRecordSaveReqVO.setJobType( DevRentStateEnum.RECEIVED.getState() );
+ jobRecordSaveReqVO.setRemark(createReqVO.getRemark());
+ jobRecordSaveReqVO.setSummary("");
+
+ JobRecordDO jobRecord = BeanUtils.toBean(jobRecordSaveReqVO, JobRecordDO.class);
+ jobRecordMapper.insert(jobRecord);
+ } else {
+ // 鎾ら攢 鏀惧純鎿嶄綔
+ createReqVO.setState( DevRentStateEnum.RECEIVED.getState() );
+
+ updateDevRent( createReqVO );
+
+ JobRecordDO jobRecordDO = jobRecordMapper.selectByRentIdDocId(rent_id, userId);
+ if (null != jobRecordDO) {
+ jobRecordDO.setDevId(createReqVO.getDevId());
+ jobRecordDO.setJobType( DevRentStateEnum.RECEIVED.getState() );
+ jobRecordDO.setJobTime(createReqVO.getRentTime());
+ jobRecordDO.setRemark(createReqVO.getRemark());
+ jobRecordDO.setUpdater(String.valueOf(userId));
+ jobRecordDO.setUpdateTime(LocalDateTime.now());
+ jobRecordMapper.updateById(jobRecordDO);
+ }
+ }
+ return CommonResult.success(rent_id);
+ }
+
+ @Override
@Transactional
public CommonResult<Long> installOperation(DevRentSaveReqVO createReqVO) {
Long userId = SecurityFrameworkUtils.getLoginUserId();
@@ -67,9 +126,12 @@
Long rent_id = createReqVO.getId();
if (null == rent_id) {
- List<DevRentDO> devRentDOList = devRentMapper.selectByPatIdAndState(createReqVO.getPatId(), DevRentStateEnum.FREE.getState());
- if (devRentDOList.size() != 1)
- return CommonResult.error(DEV_INSTALL_EXIST);
+ List<DevRentDO> devRentDOList = devRentMapper.selectByPatIdAndState(createReqVO.getPatId(), DevRentStateEnum.RECEIVED.getState());
+ if (devRentDOList.size() == 0)
+ return CommonResult.error(DEV_INSTALL_NOT_RECEIVED);
+ else if (devRentDOList.size() != 1) {
+ return CommonResult.error(DEV_INSTALL_EXCEPTION);
+ }
rent_id = devRentDOList.getFirst().getId();
createReqVO.setId( rent_id );
@@ -296,6 +358,17 @@
return devRentMapper.getDismantleRentByState(searchReqVO);
}
+ private Integer markDevRecieved(String devId) {
+ // 璁惧鏍囨敞 宸查鍙�
+ DeviceDO deviveDO = deviceMapper.getDeviceByDevId(devId);
+ if (null != deviveDO) {
+ deviveDO.setState( DevStateEnum.RECEIVED.getState() );
+ return deviceMapper.updateById(deviveDO);
+ }
+
+ return 0;
+ }
+
private Integer markDevInUse(String devId) {
// 璁惧鏍囨敞 鍦ㄤ娇鐢�
DeviceDO deviveDO = deviceMapper.getDeviceByDevId(devId);
--
Gitblit v1.9.3