From ddf772bc079de92ff4bcba8c0f1624b6398e0dad Mon Sep 17 00:00:00 2001
From: eight <641137800@qq.com>
Date: 星期二, 08 十月 2024 15:14:30 +0800
Subject: [PATCH] update
---
jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/enums/DevRentStateEnum.java | 3
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/devrent/DevRentMapper.java | 2
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/devrent/DevRentService.java | 12 +++
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/devrent/DevRentController.java | 19 +++++-
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/devrent/DevRentServiceImpl.java | 126 +++++++++++++++++++++++++++++++++--------
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/jobrecord/JobRecordMapper.java | 11 +++
6 files changed, 138 insertions(+), 35 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 9913f0d..241470c 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
@@ -20,7 +20,8 @@
INSTALLED(10, "宸茶鏈�"),
DISMANTLED(20, "宸叉媶鏈�"),
DATAENTERED(25, "宸插綍鍏�"),
- CANCELLED(30, "宸叉斁寮�"),
+ READY_CANCELLED(30, "棰嗙敤鏀惧純"),
+ INSTALL_CANCELLED(35, "瀹夎鏀惧純"),
LOST(40, "宸查仐澶�");
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DevRentStateEnum::getState).toArray();
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 bbfc4ab..3b15946 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
@@ -100,12 +100,25 @@
}
}
- @PostMapping("/dev-cancel")
+ @PostMapping("/dev-ready-cancel")
@Operation(summary = "鍙栨秷瑁呮満")
@PreAuthorize("@ss.hasPermission('ecg:doctor:task')")
- public CommonResult<Long> devCancel(@Valid @RequestBody DevCancelReqVO cancelReqVO) {
+ public CommonResult<Long> devReadyCancel(@Valid @RequestBody DevCancelReqVO cancelReqVO) {
try {
- return devRentService.cancelOperation(cancelReqVO);
+ return devRentService.cancelReadyOperation(cancelReqVO);
+ } catch ( RuntimeException runtimeException ) {
+ String err = ExceptionUtils.formatException( runtimeException );
+ log.error("devCancel: " + err);
+ return CommonResult.error(DEV_CANCEL_EXCEPTION);
+ }
+ }
+
+ @PostMapping("/dev-install-cancel")
+ @Operation(summary = "鍙栨秷瑁呮満")
+ @PreAuthorize("@ss.hasPermission('ecg:doctor:task')")
+ public CommonResult<Long> devInstallCancel(@Valid @RequestBody DevCancelReqVO cancelReqVO) {
+ try {
+ return devRentService.cancelInstallOperation(cancelReqVO);
} catch ( RuntimeException runtimeException ) {
String err = ExceptionUtils.formatException( runtimeException );
log.error("devCancel: " + err);
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/devrent/DevRentMapper.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/devrent/DevRentMapper.java
index fa98d89..360b2d3 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/devrent/DevRentMapper.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/devrent/DevRentMapper.java
@@ -37,7 +37,7 @@
DevRentDO getRentByState(DevRentSearchReqVO reqVO );
- @Select("select * from lihu.dev_rent where state=#{state} and pat_id=#{patId}")
+ @Select("select * from lihu.dev_rent where state=#{state} and pat_id=#{patId} and to_days(create_time)=to_days(now())")
List<DevRentDO> selectByPatIdAndState(@Param("patId") String patId, @Param("state") Integer state);
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/jobrecord/JobRecordMapper.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/jobrecord/JobRecordMapper.java
index a366038..bc3d90b 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/jobrecord/JobRecordMapper.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/jobrecord/JobRecordMapper.java
@@ -38,8 +38,15 @@
.orderByDesc(JobRecordDO::getId));
}
- @Select("SELECT * FROM lihu.job_record where rent_id=#{rentId} and doc_id=#{docId} limit 1")
- JobRecordDO selectByRentIdDocId(@Param("rentId") Long rentId, @Param("docId") Long docId );
+ @Select("<script> " +
+ "SELECT * FROM lihu.job_record " +
+ " where rent_id=#{rentId} and doc_id=#{docId} and job_type in (" +
+ " <foreach collection='jobTypeList' separator=',' item='jobType'>" +
+ " #{jobType} " +
+ " </foreach> )" +
+ " limit 1;" +
+ " </script>")
+ JobRecordDO selectByRentIdDocId(@Param("rentId") Long rentId, @Param("docId") Long docId, @Param("jobTypeList") List<Integer> jobTypeList );
@Select("SELECT count(1) FROM lihu.job_record where pat_id=#{patId} and TO_DAYS(job_time)=TO_DAYS(#{jobTime}) and job_type=#{jobType} ")
Integer getPatientJobNum(@Param("patId") String patId, @Param("jobTime") LocalDateTime jobTime, @Param("jobType") Integer jobType );
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 b26af12..9cafa3f 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
@@ -55,12 +55,20 @@
Long dataEntryOperation(@Valid DevRentSaveReqVO createReqVO);
/**
- * 瑁呮満
+ * 鍙栨秷棰嗙敤
*
* @param cancelReqVO 鍒涘缓淇℃伅
* @return 缂栧彿
*/
- CommonResult<Long> cancelOperation(@Valid DevCancelReqVO cancelReqVO);
+ CommonResult<Long> cancelReadyOperation(@Valid DevCancelReqVO cancelReqVO);
+
+ /**
+ * 鍙栨秷瑁呮満
+ *
+ * @param cancelReqVO 鍒涘缓淇℃伅
+ * @return 缂栧彿
+ */
+ CommonResult<Long> cancelInstallOperation(@Valid DevCancelReqVO cancelReqVO);
/**
* 閬楀け
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 c6485dd..35499bc 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
@@ -100,7 +100,10 @@
updateDevRent( createReqVO );
- JobRecordDO jobRecordDO = jobRecordMapper.selectByRentIdDocId(rent_id, userId);
+ List<Integer> jobTypeList = new ArrayList<Integer>();
+ jobTypeList.add( DevRentStateEnum.READY.getState());
+ jobTypeList.add( DevRentStateEnum.READY_CANCELLED.getState());
+ JobRecordDO jobRecordDO = jobRecordMapper.selectByRentIdDocId(rent_id, userId, jobTypeList);
if (null != jobRecordDO) {
jobRecordDO.setDevId(createReqVO.getDevId());
jobRecordDO.setJobType( DevRentStateEnum.READY.getState() );
@@ -127,7 +130,15 @@
}
Long rent_id = createReqVO.getId();
- if (null == rent_id) {
+
+ // 妫�鏌� job_record 鐢ㄤ簬纭鏄惁鏄涓�娆″畨瑁呮搷浣�
+ List<Integer> jobTypeList = new ArrayList<Integer>();
+ jobTypeList.add( DevRentStateEnum.INSTALLED.getState());
+ jobTypeList.add( DevRentStateEnum.INSTALL_CANCELLED.getState());
+ JobRecordDO jobRecordDO = jobRecordMapper.selectByRentIdDocId(rent_id, userId, jobTypeList);
+
+ // 绗竴娆� 瀹夎鎿嶄綔
+ if (null == jobRecordDO) {
List<DevRentDO> devRentDOList = devRentMapper.selectByPatIdAndState(createReqVO.getPatId(), DevRentStateEnum.READY.getState());
if (devRentDOList.size() == 0)
return CommonResult.error(DEV_INSTALL_NOT_RECEIVED);
@@ -157,19 +168,15 @@
} else {
// 鎾ら攢 鏀惧純鎿嶄綔
createReqVO.setState( DevRentStateEnum.INSTALLED.getState() );
-
updateDevRent( createReqVO );
- JobRecordDO jobRecordDO = jobRecordMapper.selectByRentIdDocId(rent_id, userId);
- if (null != jobRecordDO) {
- jobRecordDO.setDevId(createReqVO.getDevId());
- jobRecordDO.setJobType( DevRentStateEnum.INSTALLED.getState() );
- jobRecordDO.setJobTime(createReqVO.getRentTime());
- jobRecordDO.setRemark(createReqVO.getRemark());
- jobRecordDO.setUpdater(String.valueOf(userId));
- jobRecordDO.setUpdateTime(LocalDateTime.now());
- jobRecordMapper.updateById(jobRecordDO);
- }
+ jobRecordDO.setDevId(createReqVO.getDevId());
+ jobRecordDO.setJobType( DevRentStateEnum.INSTALLED.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);
}
@@ -186,7 +193,9 @@
// 璁惧鎭㈠鍒扮┖闂�
resumeDevFree( updateReqVO.getDevId() );
- JobRecordDO jobRecordDO = jobRecordMapper.selectByRentIdDocId(updateReqVO.getId(), userId);
+ List<Integer> jobTypeList = new ArrayList<Integer>();
+ jobTypeList.add( DevRentStateEnum.DISMANTLED.getState());
+ JobRecordDO jobRecordDO = jobRecordMapper.selectByRentIdDocId(updateReqVO.getId(), userId, jobTypeList);
if (jobRecordDO == null) {
JobRecordSaveReqVO jobRecordSaveReqVO = new JobRecordSaveReqVO();
jobRecordSaveReqVO.setRentId( updateReqVO.getId() );
@@ -222,7 +231,9 @@
Long userId = SecurityFrameworkUtils.getLoginUserId();
String userNickname = SecurityFrameworkUtils.getLoginUserNickname();
- JobRecordDO jobRecordDO = jobRecordMapper.selectByRentIdDocId(updateReqVO.getId(), userId);
+ List<Integer> jobTypeList = new ArrayList<Integer>();
+ jobTypeList.add( DevRentStateEnum.DATAENTERED.getState());
+ JobRecordDO jobRecordDO = jobRecordMapper.selectByRentIdDocId(updateReqVO.getId(), userId, jobTypeList);
if (jobRecordDO == null) {
JobRecordSaveReqVO jobRecordSaveReqVO = new JobRecordSaveReqVO();
jobRecordSaveReqVO.setRentId( updateReqVO.getId() );
@@ -250,7 +261,7 @@
@Override
@Transactional
- public CommonResult<Long> cancelOperation(DevCancelReqVO cancelReqVO) {
+ public CommonResult<Long> cancelReadyOperation(DevCancelReqVO cancelReqVO) {
Long userId = SecurityFrameworkUtils.getLoginUserId();
String userNickname = SecurityFrameworkUtils.getLoginUserNickname();
@@ -261,18 +272,17 @@
DevRentSaveReqVO createReqVO = BeanUtils.toBean(cancelReqVO, DevRentSaveReqVO.class);
createReqVO.setDevId(null);
- createReqVO.setState( DevRentStateEnum.CANCELLED.getState() );
+ createReqVO.setState( DevRentStateEnum.READY_CANCELLED.getState());
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);
rent_id = devRentDOList.getFirst().getId();
createReqVO.setId( rent_id );
- createReqVO.setState( DevRentStateEnum.CANCELLED.getState() );
+ createReqVO.setState( DevRentStateEnum.READY_CANCELLED.getState() );
updateDevRent( createReqVO );
JobRecordSaveReqVO jobRecordSaveReqVO = new JobRecordSaveReqVO();
@@ -282,7 +292,7 @@
jobRecordSaveReqVO.setDocName(userNickname);
jobRecordSaveReqVO.setPatId(createReqVO.getPatId());
jobRecordSaveReqVO.setPatName(createReqVO.getPatName());
- jobRecordSaveReqVO.setJobType( DevRentStateEnum.CANCELLED.getState() );
+ jobRecordSaveReqVO.setJobType( DevRentStateEnum.READY_CANCELLED.getState() );
jobRecordSaveReqVO.setJobTime(createReqVO.getRentTime());
jobRecordSaveReqVO.setRemark(createReqVO.getRemark());
jobRecordSaveReqVO.setSummary("");
@@ -292,16 +302,78 @@
} else {
updateDevRent( createReqVO );
- JobRecordDO jobRecordDO = jobRecordMapper.selectByRentIdDocId(rent_id, userId);
+ List<Integer> jobTypeList = new ArrayList<Integer>();
+ jobTypeList.add( DevRentStateEnum.READY.getState());
+ jobTypeList.add( DevRentStateEnum.READY_CANCELLED.getState());
+ JobRecordDO jobRecordDO = jobRecordMapper.selectByRentIdDocId(rent_id, userId, jobTypeList);
if (null != jobRecordDO) {
jobRecordDO.setDevId(null);
- jobRecordDO.setJobType( DevRentStateEnum.CANCELLED.getState() );
+ jobRecordDO.setJobType(DevRentStateEnum.READY_CANCELLED.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> cancelInstallOperation(DevCancelReqVO cancelReqVO) {
+ Long userId = SecurityFrameworkUtils.getLoginUserId();
+ String userNickname = SecurityFrameworkUtils.getLoginUserNickname();
+
+ // 鑻ヤ粠 瑁呮満 鏀逛负 鍙栨秷瑁呮満锛屾仮澶嶈澶囩姸鎬�
+ if (null != cancelReqVO.getDevId()) {
+ resumeDevFree( cancelReqVO.getDevId() );
+ }
+
+ DevRentSaveReqVO createReqVO = BeanUtils.toBean(cancelReqVO, DevRentSaveReqVO.class);
+ createReqVO.setDevId(null);
+ createReqVO.setState( DevRentStateEnum.INSTALL_CANCELLED.getState() );
+
+ Long rent_id = createReqVO.getId();
+
+ List<Integer> jobTypeList = new ArrayList<Integer>();
+ jobTypeList.add( DevRentStateEnum.INSTALLED.getState());
+ jobTypeList.add( DevRentStateEnum.INSTALL_CANCELLED.getState());
+ JobRecordDO jobRecordDO = jobRecordMapper.selectByRentIdDocId(rent_id, userId, jobTypeList);
+ if (null == jobRecordDO) {
+ List<DevRentDO> devRentDOList = devRentMapper.selectByPatIdAndState(createReqVO.getPatId(), DevRentStateEnum.READY.getState());
+ if (devRentDOList.size() != 1)
+ return CommonResult.error(DEV_INSTALL_EXIST);
+
+ rent_id = devRentDOList.getFirst().getId();
+ createReqVO.setId( rent_id );
+ createReqVO.setState( DevRentStateEnum.INSTALL_CANCELLED.getState() );
+ updateDevRent( createReqVO );
+
+ JobRecordSaveReqVO jobRecordSaveReqVO = new JobRecordSaveReqVO();
+ jobRecordSaveReqVO.setRentId(rent_id);
+ jobRecordSaveReqVO.setDevId(null);
+ jobRecordSaveReqVO.setDocId(userId);
+ jobRecordSaveReqVO.setDocName(userNickname);
+ jobRecordSaveReqVO.setPatId(createReqVO.getPatId());
+ jobRecordSaveReqVO.setPatName(createReqVO.getPatName());
+ jobRecordSaveReqVO.setJobType( DevRentStateEnum.INSTALL_CANCELLED.getState() );
+ jobRecordSaveReqVO.setJobTime(createReqVO.getRentTime());
+ jobRecordSaveReqVO.setRemark(createReqVO.getRemark());
+ jobRecordSaveReqVO.setSummary("");
+
+ JobRecordDO jobRecord = BeanUtils.toBean(jobRecordSaveReqVO, JobRecordDO.class);
+ jobRecordMapper.insert(jobRecord);
+ } else {
+ updateDevRent( createReqVO );
+
+ jobRecordDO.setDevId(null);
+ jobRecordDO.setJobType( DevRentStateEnum.INSTALL_CANCELLED.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);
}
@@ -318,7 +390,9 @@
Long userId = SecurityFrameworkUtils.getLoginUserId();
String userNickname = SecurityFrameworkUtils.getLoginUserNickname();
- JobRecordDO jobRecordDO = jobRecordMapper.selectByRentIdDocId(updateReqVO.getId(), userId);
+ List<Integer> jobTypeList = new ArrayList<Integer>();
+ jobTypeList.add( DevRentStateEnum.LOST.getState());
+ JobRecordDO jobRecordDO = jobRecordMapper.selectByRentIdDocId(updateReqVO.getId(), userId, jobTypeList);
if (jobRecordDO == null) {
JobRecordSaveReqVO jobRecordSaveReqVO = new JobRecordSaveReqVO();
jobRecordSaveReqVO.setRentId( updateReqVO.getId() );
@@ -394,7 +468,7 @@
public DevRentDO getInstalledOrCancelledRent(DevRentSearchReqVO searchReqVO) {
List<Integer> stateList = new ArrayList<>();
stateList.add( DevRentStateEnum.INSTALLED.getState() );
- stateList.add( DevRentStateEnum.CANCELLED.getState() );
+ stateList.add( DevRentStateEnum.INSTALL_CANCELLED.getState());
searchReqVO.setStateList( stateList );
return devRentMapper.getRentByState(searchReqVO);
}
@@ -403,7 +477,7 @@
public DevRentDO getReadyOrCancelledRent(DevRentSearchReqVO searchReqVO) {
List<Integer> stateList = new ArrayList<>();
stateList.add( DevRentStateEnum.READY.getState() );
- stateList.add( DevRentStateEnum.CANCELLED.getState() );
+ stateList.add( DevRentStateEnum.READY_CANCELLED.getState());
searchReqVO.setStateList( stateList );
return devRentMapper.getRentByState(searchReqVO);
}
@@ -431,7 +505,7 @@
private Integer markDevInUse(String devId) {
// 璁惧鏍囨敞 鍦ㄤ娇鐢�
DeviceDO deviveDO = deviceMapper.getDeviceByDevId(devId);
- if (null != deviveDO && deviveDO.getState() == DevStateEnum.RECEIVED.getState()) {
+ if (null != deviveDO && (deviveDO.getState() == DevStateEnum.RECEIVED.getState() || deviveDO.getState() == DevStateEnum.FREE.getState())) {
deviveDO.setState( DevStateEnum.INUSE.getState() );
deviveDO.setStateDate( LocalDate.now() );
return deviceMapper.updateById(deviveDO);
--
Gitblit v1.9.3