From 0fd05805e138bcd29f75a17f0fbde15a8292238c Mon Sep 17 00:00:00 2001
From: eight <641137800@qq.com>
Date: 星期三, 11 九月 2024 15:02:56 +0800
Subject: [PATCH] update
---
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 | 16 +++++
sql/mysql/jh.sql | 5 -
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/devrent/DevRentController.java | 36 ++++++++++++
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/jobrecord/vo/JobRecordSaveReqVO.java | 2
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/devrent/DevRentServiceImpl.java | 57 +++++++++++++++++++
jh-framework/jh-common/src/main/java/cn/lihu/jh/framework/common/util/exception/ExceptionUtils.java | 17 +++++
7 files changed, 131 insertions(+), 4 deletions(-)
diff --git a/jh-framework/jh-common/src/main/java/cn/lihu/jh/framework/common/util/exception/ExceptionUtils.java b/jh-framework/jh-common/src/main/java/cn/lihu/jh/framework/common/util/exception/ExceptionUtils.java
new file mode 100644
index 0000000..81d9a12
--- /dev/null
+++ b/jh-framework/jh-common/src/main/java/cn/lihu/jh/framework/common/util/exception/ExceptionUtils.java
@@ -0,0 +1,17 @@
+package cn.lihu.jh.framework.common.util.exception;
+
+import java.text.MessageFormat;
+
+public class ExceptionUtils {
+
+ public static String formatException(Exception e) {
+ // 鑾峰彇寮傚父淇℃伅锛岃褰曟棩蹇�
+// StackTraceElement stackTraceElement = e.getStackTrace()[0];
+// String className = stackTraceElement.getClassName();
+// String fileName = stackTraceElement.getFileName();
+// int lineNumber = stackTraceElement.getLineNumber();
+// String methodName = stackTraceElement.getMethodName();
+// return MessageFormat.format("绫诲悕:{0},鏂囦欢鍚�:{1},琛屾暟:{2},鍔炴硶鍚�:{3}", className, fileName, lineNumber, methodName);
+ return e.getLocalizedMessage();
+ }
+}
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 4ae3b8c..24d25af 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
@@ -26,6 +26,8 @@
ErrorCode DEV_MODEL_NOT_EXISTS = new ErrorCode(1_010_005_000, "璁惧鍨嬪彿涓嶅瓨鍦�");
ErrorCode DEVICE_NOT_EXISTS = new ErrorCode(1_010_005_001, "璁惧涓嶅瓨鍦�");
ErrorCode DEV_RENT_NOT_EXISTS = new ErrorCode(1_010_005_002, "绉熷�熶笉瀛樺湪");
+ ErrorCode DEV_INSTALL_EXCEPTION = new ErrorCode(1_010_005_003, "瑁呮満鍐呴儴閿欒");
+ ErrorCode DEV_DISMANTLE_EXCEPTION = new ErrorCode(1_010_005_004, "鎷嗘満鍐呴儴閿欒");
ErrorCode JOB_RECORD_NOT_EXISTS = new ErrorCode(1_010_006_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 485a506..8e2dc08 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
@@ -1,5 +1,7 @@
package cn.lihu.jh.module.ecg.controller.admin.devrent;
+import cn.lihu.jh.framework.common.util.exception.ExceptionUtils;
+import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -14,12 +16,17 @@
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.error;
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 static cn.lihu.jh.framework.common.util.exception.ExceptionUtils.formatException;
+import static cn.lihu.jh.module.ecg.enums.ErrorCodeConstants.DEV_DISMANTLE_EXCEPTION;
+import static cn.lihu.jh.module.ecg.enums.ErrorCodeConstants.DEV_INSTALL_EXCEPTION;
import cn.lihu.jh.module.ecg.controller.admin.devrent.vo.*;
import cn.lihu.jh.module.ecg.dal.dataobject.devrent.DevRentDO;
@@ -33,11 +40,40 @@
@RestController
@RequestMapping("/ecg/dev-rent")
@Validated
+@Slf4j
public class DevRentController {
@Resource
private DevRentService devRentService;
+ @PostMapping("/dev-install")
+ @Operation(summary = "瑁呮満")
+ @PreAuthorize("@ss.hasPermission('ecg:doctor:task')")
+ public CommonResult<Long> devInstall(@Valid @RequestBody DevRentSaveReqVO createReqVO) {
+ try {
+ Long rent_id = devRentService.installOperation(createReqVO);
+ return success(rent_id);
+ } catch ( RuntimeException runtimeException ) {
+ String err = ExceptionUtils.formatException( runtimeException );
+ log.error("devInstall: " + err);
+ return error(DEV_INSTALL_EXCEPTION);
+ }
+ }
+
+ @PostMapping("/dev-dismantle")
+ @Operation(summary = "鎷嗘満")
+ @PreAuthorize("@ss.hasPermission('ecg:doctor:task')")
+ public CommonResult<Long> devDismantle(@Valid @RequestBody DevRentSaveReqVO createReqVO) {
+ try {
+ devRentService.dismantleOperation(createReqVO);
+ return success(0L);
+ } catch ( RuntimeException runtimeException ) {
+ String err = ExceptionUtils.formatException( runtimeException );
+ log.error("devDismantle: " + err);
+ return error(DEV_DISMANTLE_EXCEPTION);
+ }
+ }
+
@PostMapping("/create")
@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/controller/admin/jobrecord/vo/JobRecordSaveReqVO.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/jobrecord/vo/JobRecordSaveReqVO.java
index 4351c82..76f545d 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/jobrecord/vo/JobRecordSaveReqVO.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/jobrecord/vo/JobRecordSaveReqVO.java
@@ -37,7 +37,7 @@
private LocalDateTime jobTime;
@Schema(description = "浣滀笟姒傝")
- private Integer summary;
+ private String summary;
@Schema(description = "澶囨敞", example = "浣犵寽")
private String remark;
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 e6d2f31..4b1e791 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
@@ -16,6 +16,22 @@
public interface DevRentService {
/**
+ * 瑁呮満
+ *
+ * @param createReqVO 鍒涘缓淇℃伅
+ * @return 缂栧彿
+ */
+ Long installOperation(@Valid DevRentSaveReqVO createReqVO);
+
+ /**
+ * 鎷嗘満
+ *
+ * @param createReqVO 鍒涘缓淇℃伅
+ * @return 缂栧彿
+ */
+ Long dismantleOperation(@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 e59d14c..e4a0a2c 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
@@ -1,5 +1,9 @@
package cn.lihu.jh.module.ecg.service.devrent;
+import cn.lihu.jh.framework.security.core.util.SecurityFrameworkUtils;
+import cn.lihu.jh.module.ecg.controller.admin.jobrecord.vo.JobRecordSaveReqVO;
+import cn.lihu.jh.module.ecg.dal.dataobject.jobrecord.JobRecordDO;
+import cn.lihu.jh.module.ecg.dal.mysql.jobrecord.JobRecordMapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
@@ -30,6 +34,59 @@
@Resource
private DevRentMapper devRentMapper;
+ @Resource
+ private JobRecordMapper jobRecordMapper;
+
+ @Override
+ @Transactional
+ public Long installOperation(DevRentSaveReqVO createReqVO) {
+ Long rent_id = createDevRent( createReqVO );
+
+ Long userId = SecurityFrameworkUtils.getLoginUserId();
+ String userNickname = SecurityFrameworkUtils.getLoginUserNickname();
+
+ 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( 0 );
+ jobRecordSaveReqVO.setRemark( createReqVO.getRemark() );
+ jobRecordSaveReqVO.setSummary( "" );
+
+ JobRecordDO jobRecord = BeanUtils.toBean(jobRecordSaveReqVO, JobRecordDO.class);
+ jobRecordMapper.insert(jobRecord);
+ return rent_id;
+ }
+
+ @Override
+ @Transactional
+ public Long dismantleOperation(DevRentSaveReqVO updateReqVO) {
+ updateDevRent( updateReqVO );
+
+ Long userId = SecurityFrameworkUtils.getLoginUserId();
+ String userNickname = SecurityFrameworkUtils.getLoginUserNickname();
+
+ JobRecordSaveReqVO jobRecordSaveReqVO = new JobRecordSaveReqVO();
+ jobRecordSaveReqVO.setRentId( updateReqVO.getId() );
+ jobRecordSaveReqVO.setDevId( updateReqVO.getDevId() );
+ jobRecordSaveReqVO.setDocId( userId );
+ jobRecordSaveReqVO.setDocName( userNickname );
+ jobRecordSaveReqVO.setPatId( updateReqVO.getPatId() );
+ jobRecordSaveReqVO.setPatName( updateReqVO.getPatName() );
+ jobRecordSaveReqVO.setJobTime( updateReqVO.getReturnTime() );
+ jobRecordSaveReqVO.setJobType( 1 );
+ jobRecordSaveReqVO.setRemark( updateReqVO.getRemark() );
+ jobRecordSaveReqVO.setSummary( updateReqVO.getInterference() + " " + updateReqVO.getBaseline() + " " + updateReqVO.getDetachment() );
+
+ JobRecordDO jobRecord = BeanUtils.toBean(jobRecordSaveReqVO, JobRecordDO.class);
+ jobRecordMapper.insert(jobRecord);
+ return 0L;
+ }
+
@Override
public Long createDevRent(DevRentSaveReqVO createReqVO) {
//
diff --git a/sql/mysql/jh.sql b/sql/mysql/jh.sql
index 7ef5784..06cc27a 100644
--- a/sql/mysql/jh.sql
+++ b/sql/mysql/jh.sql
@@ -174,7 +174,7 @@
`pat_id` varchar(45) DEFAULT NULL COMMENT '鎮h�呯紪鍙�',
`pat_name` varchar(45) DEFAULT NULL COMMENT '鎮h�呭悕绉�',
`job_time` datetime DEFAULT NULL COMMENT '浣滀笟鏃堕棿',
- `summary` int DEFAULT NULL COMMENT '浣滀笟姒傝',
+ `summary` varchar(200) DEFAULT NULL COMMENT '浣滀笟姒傝',
`remark` varchar(100) DEFAULT NULL COMMENT '澶囨敞',
`tenant_id` int DEFAULT '1' COMMENT '绉熸埛缂栧彿',
`creator` varchar(10) DEFAULT '' COMMENT '鍒涘缓鑰�',
@@ -183,5 +183,4 @@
`update_time` datetime NOT NULL COMMENT '鏇存柊鏃堕棿',
`deleted` bit(1) DEFAULT b'0' COMMENT '鍒犻櫎鏍囪',
PRIMARY KEY (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='宸ヤ綔璁板綍琛�'
-
+) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='宸ヤ綔璁板綍琛�';
--
Gitblit v1.9.3