From 3d10cfa8882afcfa28a7623b45232aef54fe033d Mon Sep 17 00:00:00 2001
From: eight <641137800@qq.com>
Date: 星期五, 25 十月 2024 15:51:08 +0800
Subject: [PATCH] 设备表 增加 rent_id
---
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/service/devrent/DevRentService.java | 2
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/devmanage/DeviceDO.java | 3 +
jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/enums/DevStateEnum.java | 5 ++
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/devrent/DevRentController.java | 12 +++++
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/devrent/DevRentServiceImpl.java | 62 +++++++++++++++++++++----------
6 files changed, 64 insertions(+), 26 deletions(-)
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 4cdd1da..f2fce67 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
@@ -18,7 +18,10 @@
FREE(0, "绌洪棽"),
RECEIVED(5, "宸查鍙�"),
INUSE(10, "浣跨敤涓�"),
- LOST(20, "宸查仐澶�");
+ LOST(20, "宸查仐澶�"),
+ DAMAGED(30, "宸叉崯鍧�"),
+ UNDER_MAINTENANCE(40, "缁翠慨涓�"),
+ SCRAPPED(50, "宸叉姤搴�");
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DevStateEnum::getState).toArray();
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 79d042e..673858b 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
@@ -42,9 +42,9 @@
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 ROUTINE_CHECK_EXIST = new ErrorCode(1_010_006_009, "褰撳ぉ宸叉湁妫�鏌�");
+ ErrorCode DEV_INSTALL_NOT_APPOINTMENT = new ErrorCode(1_010_006_014, "璇峰厛棰勭害纭");
+ ErrorCode DEV_INSTALL_NOT_RECEIVED = new ErrorCode(1_010_006_018, "璇峰厛棰嗙敤璁惧");
+ ErrorCode ROUTINE_CHECK_EXIST = new ErrorCode(1_010_006_022, "褰撳ぉ宸叉湁妫�鏌�");
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 05e731b..7de494e 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
@@ -2,6 +2,7 @@
import cn.lihu.jh.framework.common.util.exception.ExceptionUtils;
import cn.lihu.jh.module.ecg.dal.dataobject.devmanage.DeviceDO;
+import cn.lihu.jh.module.ecg.enums.DevStateEnum;
import cn.lihu.jh.module.ecg.service.devmanage.DeviceService;
import cn.lihu.jh.module.ecg.service.queue.QueueService;
import lombok.extern.slf4j.Slf4j;
@@ -115,7 +116,16 @@
@Operation(summary = "閬楀け")
@PreAuthorize("@ss.hasPermission('ecg:doctor:task')")
public CommonResult<Long> devLose(@Valid @RequestBody DevRentSaveReqVO loseReqVO) {
- return devRentService.loseOperation(loseReqVO);
+ loseReqVO.setState( DevStateEnum.LOST.getState() );
+ return devRentService.dismantleExceptionOperation(loseReqVO);
+ }
+
+ @PostMapping("/dev-damage")
+ @Operation(summary = "鎹熷潖")
+ @PreAuthorize("@ss.hasPermission('ecg:doctor:task')")
+ public CommonResult<Long> devDamage(@Valid @RequestBody DevRentSaveReqVO damageReqVO) {
+ damageReqVO.setState( DevStateEnum.DAMAGED.getState() );
+ return devRentService.dismantleExceptionOperation(damageReqVO);
}
@PostMapping("/create")
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/devmanage/DeviceDO.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/devmanage/DeviceDO.java
index 7a7a1b4..68c86f6 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/devmanage/DeviceDO.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/devmanage/DeviceDO.java
@@ -72,4 +72,7 @@
* 0 - 绌洪棽 10 - 浣跨敤涓� 20 - 宸查仐澶�
*/
private Integer state;
+
+ @TableField(updateStrategy = FieldStrategy.ALWAYS)
+ private Long rentId;
}
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 7d53ae2..d358b4b 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
@@ -93,7 +93,7 @@
* @param createReqVO 鍒涘缓淇℃伅
* @return 缂栧彿
*/
- CommonResult<Long> loseOperation(@Valid DevRentSaveReqVO createReqVO);
+ CommonResult<Long> dismantleExceptionOperation(@Valid DevRentSaveReqVO 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 30f77c7..a22dacf 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
@@ -128,14 +128,13 @@
public CommonResult<Long> readyOperation(DevRentSaveReqVO createReqVO) {
Long userId = SecurityFrameworkUtils.getLoginUserId();
String userNickname = SecurityFrameworkUtils.getLoginUserNickname();
+ Long rent_id = createReqVO.getId();
// 鏍囨敞璁惧 宸查鍙�
- Integer ret = markDevRecieved(createReqVO.getDevId());
+ Integer ret = markDevRecieved(createReqVO.getDevId(), rent_id);
if (null == ret || 0 == ret) {
throw exception(DEVICE_NOT_FREE);
}
-
- Long rent_id = createReqVO.getId();
List<Integer> jobTypeList = new ArrayList<Integer>();
jobTypeList.add( DevRentStateEnum.READY.getState());
@@ -195,14 +194,13 @@
public CommonResult<Long> installOperation(DevRentSaveReqVO createReqVO) {
Long userId = SecurityFrameworkUtils.getLoginUserId();
String userNickname = SecurityFrameworkUtils.getLoginUserNickname();
+ Long rent_id = createReqVO.getId();
// 璁剧疆璁惧 浣跨敤涓�
- Integer ret = markDevInUse(createReqVO.getDevId());
+ Integer ret = markDevInUse(createReqVO.getDevId(), rent_id);
if (null == ret || 0 == ret) {
throw exception(DEVICE_NOT_RECEIVED);
}
-
- Long rent_id = createReqVO.getId();
// 妫�鏌� job_record 鐢ㄤ簬纭鏄惁鏄涓�娆″畨瑁呮搷浣�
List<Integer> jobTypeList = new ArrayList<Integer>();
@@ -264,12 +262,13 @@
public Long dismantleOperation(DevRentSaveReqVO updateReqVO) {
updateReqVO.setState( DevRentStateEnum.DISMANTLED.getState() );
updateDevRent( updateReqVO );
+ Long rentId = updateReqVO.getId();
Long userId = SecurityFrameworkUtils.getLoginUserId();
String userNickname = SecurityFrameworkUtils.getLoginUserNickname();
// 璁惧鎭㈠鍒扮┖闂�
- resumeDevFree( updateReqVO.getDevId() );
+ markDevFree( updateReqVO.getDevId(), rentId );
List<Integer> jobTypeList = new ArrayList<Integer>();
jobTypeList.add( DevRentStateEnum.DISMANTLED.getState());
@@ -397,10 +396,11 @@
public CommonResult<Long> cancelReadyOperation(DevCancelReqVO cancelReqVO) {
Long userId = SecurityFrameworkUtils.getLoginUserId();
String userNickname = SecurityFrameworkUtils.getLoginUserNickname();
+ Long rentId = cancelReqVO.getId();
// 鑻ヤ粠 瑁呮満 鏀逛负 鍙栨秷瑁呮満锛屾仮澶嶈澶囩姸鎬�
if (null != cancelReqVO.getDevId()) {
- resumeDevFree( cancelReqVO.getDevId() );
+ markDevFree( cancelReqVO.getDevId(), rentId );
}
DevRentSaveReqVO createReqVO = BeanUtils.toBean(cancelReqVO, DevRentSaveReqVO.class);
@@ -456,10 +456,11 @@
public CommonResult<Long> cancelInstallOperation(DevCancelReqVO cancelReqVO) {
Long userId = SecurityFrameworkUtils.getLoginUserId();
String userNickname = SecurityFrameworkUtils.getLoginUserNickname();
+ Long rentId = cancelReqVO.getId();
// 鑻ヤ粠 瑁呮満 鏀逛负 鍙栨秷瑁呮満锛屾仮澶嶈澶囩姸鎬�
if (null != cancelReqVO.getDevId()) {
- resumeDevFree( cancelReqVO.getDevId() );
+ markDevFree( cancelReqVO.getDevId(), rentId );
}
DevRentSaveReqVO createReqVO = BeanUtils.toBean(cancelReqVO, DevRentSaveReqVO.class);
@@ -512,9 +513,17 @@
@Override
@Transactional(rollbackFor = Exception.class)
- public CommonResult<Long> loseOperation(DevRentSaveReqVO updateReqVO) {
+ public CommonResult<Long> dismantleExceptionOperation(DevRentSaveReqVO updateReqVO) {
+ DevStateEnum devStateEnum = null;
+ if (updateReqVO.getState() == DevStateEnum.DAMAGED.getState())
+ devStateEnum = DevStateEnum.DAMAGED;
+ else if (updateReqVO.getState() == DevStateEnum.LOST.getState())
+ devStateEnum = DevStateEnum.LOST;
+ else
+ throw exception(DEV_DISMANTLE_EXCEPTION);
+
// 璁惧閬楀け鏃�, 鏍囨敞閬楀け
- markDevLost( updateReqVO.getDevId(), updateReqVO.getReturnTime().toLocalDate() );
+ markDevDismantleException( updateReqVO.getDevId(), updateReqVO.getId(), updateReqVO.getReturnTime().toLocalDate(), devStateEnum );
updateReqVO.setState( DevRentStateEnum.LOST.getState() );
updateDevRent( updateReqVO );
@@ -628,11 +637,13 @@
return devRentMapper.getRentByState(searchReqVO);
}
- private Integer markDevRecieved(String devId) {
+ // 鏍囪 璁惧宸茶棰嗗彇
+ private Integer markDevRecieved(String devId, Long rentId) {
// 璁惧鏍囨敞 宸查鍙�
DeviceDO deviveDO = deviceMapper.getDeviceByDevId(devId);
if (null != deviveDO && deviveDO.getState() == DevStateEnum.FREE.getState()) {
deviveDO.setState( DevStateEnum.RECEIVED.getState() );
+ deviveDO.setRentId( rentId );
deviveDO.setStateDate( LocalDate.now() );
return deviceMapper.updateById(deviveDO);
}
@@ -640,23 +651,33 @@
return 0;
}
- private Integer markDevInUse(String devId) {
- // 璁惧鏍囨敞 鍦ㄤ娇鐢�
+ // 鏍囪 璁惧宸茶浣跨敤
+ private Integer markDevInUse(String devId, Long rentId) {
DeviceDO deviveDO = deviceMapper.getDeviceByDevId(devId);
- if (null != deviveDO && (deviveDO.getState() == DevStateEnum.RECEIVED.getState() || deviveDO.getState() == DevStateEnum.FREE.getState())) {
+ if (null == deviveDO)
+ return 0;
+
+ if (deviveDO.getState() == DevStateEnum.RECEIVED.getState() && deviveDO.getRentId() == rentId) {
deviveDO.setState( DevStateEnum.INUSE.getState() );
deviveDO.setStateDate( LocalDate.now() );
return deviceMapper.updateById(deviveDO);
}
+ if (deviveDO.getState() == DevStateEnum.FREE.getState()) {
+ deviveDO.setState( DevStateEnum.INUSE.getState() );
+ deviveDO.setStateDate( LocalDate.now() );
+ deviveDO.setRentId( rentId );
+ return deviceMapper.updateById(deviveDO);
+ }
+
return 0;
}
- private Integer markDevLost(String devId, LocalDate localDate) {
+ private Integer markDevDismantleException(String devId, Long rentId, LocalDate localDate, DevStateEnum devStateEnum) {
// 璁惧鏍囨敞閬楀け
DeviceDO deviveDO = deviceMapper.getDeviceByDevId(devId);
- if (null != deviveDO) {
- deviveDO.setState( DevStateEnum.LOST.getState() );
+ if (null != deviveDO && deviveDO.getState() == DevStateEnum.INUSE.getState() && deviveDO.getRentId() == rentId) {
+ deviveDO.setState( devStateEnum.getState() );
deviveDO.setStateDate( localDate );
return deviceMapper.updateById(deviveDO);
}
@@ -664,12 +685,13 @@
return 0;
}
- private Integer resumeDevFree(String devId) {
+ private Integer markDevFree(String devId, Long rentId) {
// 璁惧鏍囨敞閬楀け 鎭㈠涓虹┖闂�
DeviceDO deviveDO = deviceMapper.getDeviceByDevId( devId );
- if (null != deviveDO) {
+ if (null != deviveDO && deviveDO.getRentId() == rentId) {
deviveDO.setState( DevStateEnum.FREE.getState() );
deviveDO.setStateDate( LocalDate.now() );
+ deviveDO.setRentId(null);
return deviceMapper.updateById(deviveDO);
}
--
Gitblit v1.9.3