jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/devrent/DevRentController.java
@@ -34,7 +34,7 @@ import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; @Tag(name = "管理后台 - 装机拆机") @Tag(name = "装机拆机") @RestController @RequestMapping("/ecg/dev-rent") @Validated @@ -55,122 +55,67 @@ @Operation(summary = "") @PreAuthorize("@ss.hasPermission('ecg:doctor:task')") public CommonResult<Long> routineFinish(@Valid @RequestBody RoutineFinishReqVO routineFinishReqVO) { try { CommonResult<Long> result = devRentService.routineFinishOperation(routineFinishReqVO); return result; } catch ( RuntimeException runtimeException ) { String err = ExceptionUtils.formatException( runtimeException ); log.error("routineFinish: " + err); return CommonResult.error(DEV_INSTALL_EXCEPTION); } CommonResult<Long> result = devRentService.routineFinishOperation(routineFinishReqVO); return result; } @PostMapping("/dev-ready") @Operation(summary = "设备领用") @PreAuthorize("@ss.hasPermission('ecg:doctor:task')") public CommonResult<Long> devReady(@Valid @RequestBody DevRentSaveReqVO createReqVO) { try { CommonResult<Long> result = devRentService.readyOperation(createReqVO); return result; } catch ( RuntimeException runtimeException ) { String err = ExceptionUtils.formatException( runtimeException ); log.error("devReady: " + err); return CommonResult.error(DEV_INSTALL_EXCEPTION); } CommonResult<Long> result = devRentService.readyOperation(createReqVO); return result; } @PostMapping("/dev-install") @Operation(summary = "装机") @PreAuthorize("@ss.hasPermission('ecg:doctor:task')") public CommonResult<Long> devInstall(@Valid @RequestBody DevRentSaveReqVO createReqVO) { try { return devRentService.installOperation(createReqVO); } catch ( RuntimeException runtimeException ) { String err = ExceptionUtils.formatException( runtimeException ); log.error("devInstall: " + err); return CommonResult.error(DEV_INSTALL_EXCEPTION); } return devRentService.installOperation(createReqVO); } @PostMapping("/dev-dismantle") @Operation(summary = "拆机") @PreAuthorize("@ss.hasPermission('ecg:doctor:task')") public CommonResult<Long> devDismantle(@Valid @RequestBody DevRentSaveReqVO createReqVO) { try { devRentService.dismantleOperation(createReqVO); return CommonResult.success(0L); } catch ( RuntimeException runtimeException ) { String err = ExceptionUtils.formatException( runtimeException ); log.error("devDismantle: " + err); return CommonResult.error(DEV_DISMANTLE_EXCEPTION); } devRentService.dismantleOperation(createReqVO); return CommonResult.success(0L); } @PostMapping("/dev-data-entry") @Operation(summary = "数据录入") @PreAuthorize("@ss.hasPermission('ecg:doctor:task')") public CommonResult<Long> devDataEntry(@Valid @RequestBody DevRentSaveReqVO createReqVO) { try { devRentService.dataEntryOperation(createReqVO); return CommonResult.success(0L); } catch ( RuntimeException runtimeException ) { String err = ExceptionUtils.formatException( runtimeException ); log.error("devDismantle: " + err); return CommonResult.error(DEV_DISMANTLE_EXCEPTION); } devRentService.dataEntryOperation(createReqVO); return CommonResult.success(0L); } @PostMapping("/routine-check-cancel") @Operation(summary = "取消常规检查") @PreAuthorize("@ss.hasPermission('ecg:doctor:task')") public CommonResult<Long> routineCheckCancel(@Valid @RequestBody DevCancelReqVO cancelReqVO) { try { return devRentService.cancelRoutineOperation(cancelReqVO); } catch ( RuntimeException runtimeException ) { String err = ExceptionUtils.formatException( runtimeException ); log.error("routineCheckCancel: " + err); return CommonResult.error(ROUTINE_CANCEL_EXCEPTION); } return devRentService.cancelRoutineOperation(cancelReqVO); } @PostMapping("/dev-ready-cancel") @Operation(summary = "取消领用") @PreAuthorize("@ss.hasPermission('ecg:doctor:task')") public CommonResult<Long> devReadyCancel(@Valid @RequestBody DevCancelReqVO cancelReqVO) { try { return devRentService.cancelReadyOperation(cancelReqVO); } catch ( RuntimeException runtimeException ) { String err = ExceptionUtils.formatException( runtimeException ); log.error("devReadyCancel: " + err); return CommonResult.error(DEV_RECEIVE_CANCEL_EXCEPTION); } return devRentService.cancelReadyOperation(cancelReqVO); } @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("devInstallCancel: " + err); return CommonResult.error(DEV_INSTALL_CANCEL_EXCEPTION); } return devRentService.cancelInstallOperation(cancelReqVO); } @PostMapping("/dev-lose") @Operation(summary = "遗失") @PreAuthorize("@ss.hasPermission('ecg:doctor:task')") public CommonResult<Long> devLose(@Valid @RequestBody DevRentSaveReqVO loseReqVO) { try { return devRentService.loseOperation(loseReqVO); } catch ( RuntimeException runtimeException ) { String err = ExceptionUtils.formatException( runtimeException ); log.error("devLose: " + err); return CommonResult.error(DEV_LOSE_EXCEPTION); } return devRentService.loseOperation(loseReqVO); } @PostMapping("/create") @@ -237,7 +182,7 @@ } @GetMapping("/get-free-rent") @Operation(summary = "获取已领取租赁情况") @Operation(summary = "根据患者或设备, 获取已领取租赁情况") @PreAuthorize("@ss.hasPermission('ecg:doctor:task')") public CommonResult<DevRentRespVO> getFreeRent( @Valid DevRentSearchReqVO searchReqVO ) { jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/devrent/DevRentServiceImpl.java
@@ -60,6 +60,7 @@ } @Override @Transactional(rollbackFor = Exception.class) public CommonResult<Long> routineFinishOperation(RoutineFinishReqVO routineFinishReqVO) { DevRentSaveReqVO createReqVO = BeanUtils.toBean(routineFinishReqVO, DevRentSaveReqVO.class); @@ -71,9 +72,9 @@ 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); throw exception(DEV_INSTALL_NOT_APPOINTMENT); else if (devRentDOList.size() != 1) { return CommonResult.error(DEV_INSTALL_EXCEPTION); throw exception(DEV_INSTALL_EXCEPTION); } rent_id = devRentDOList.getFirst().getId(); @@ -124,7 +125,7 @@ } @Override @Transactional @Transactional(rollbackFor = Exception.class) public CommonResult<Long> readyOperation(DevRentSaveReqVO createReqVO) { Long userId = SecurityFrameworkUtils.getLoginUserId(); String userNickname = SecurityFrameworkUtils.getLoginUserNickname(); @@ -132,16 +133,16 @@ // 标注设备 已领取 Integer ret = markDevRecieved(createReqVO.getDevId()); if (null == ret || 0 == ret) { return CommonResult.error(DEVICE_NOT_FREE); throw exception(DEVICE_NOT_FREE); } 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); throw exception(DEV_INSTALL_NOT_APPOINTMENT); else if (devRentDOList.size() != 1) { return CommonResult.error(DEV_INSTALL_EXCEPTION); throw exception(DEV_INSTALL_EXCEPTION); } rent_id = devRentDOList.getFirst().getId(); @@ -192,7 +193,7 @@ } @Override @Transactional @Transactional(rollbackFor = Exception.class) public CommonResult<Long> installOperation(DevRentSaveReqVO createReqVO) { Long userId = SecurityFrameworkUtils.getLoginUserId(); String userNickname = SecurityFrameworkUtils.getLoginUserNickname(); @@ -200,7 +201,7 @@ // 设置设备 使用中 Integer ret = markDevInUse(createReqVO.getDevId()); if (null == ret || 0 == ret) { return CommonResult.error(DEVICE_NOT_RECEIVED); throw exception(DEVICE_NOT_RECEIVED); } Long rent_id = createReqVO.getId(); @@ -215,9 +216,9 @@ if (null == jobRecordDO) { List<DevRentDO> devRentDOList = devRentMapper.selectByPatIdAndState(createReqVO.getPatId(), DevRentStateEnum.READY.getState()); if (devRentDOList.size() == 0) return CommonResult.error(DEV_INSTALL_NOT_RECEIVED); throw exception(DEV_INSTALL_NOT_RECEIVED); else if (devRentDOList.size() != 1) { return CommonResult.error(DEV_INSTALL_EXCEPTION); throw exception(DEV_INSTALL_EXCEPTION); } rent_id = devRentDOList.getFirst().getId(); @@ -261,7 +262,7 @@ } @Override @Transactional @Transactional(rollbackFor = Exception.class) public Long dismantleOperation(DevRentSaveReqVO updateReqVO) { updateReqVO.setState( DevRentStateEnum.DISMANTLED.getState() ); updateDevRent( updateReqVO ); @@ -302,7 +303,7 @@ } @Override @Transactional @Transactional(rollbackFor = Exception.class) public Long dataEntryOperation(DevRentSaveReqVO updateReqVO) { updateReqVO.setState( DevRentStateEnum.DATAENTERED.getState() ); updateDevRent( updateReqVO ); @@ -340,7 +341,7 @@ // 常规检查 取消 @Override @Transactional @Transactional(rollbackFor = Exception.class) public CommonResult<Long> cancelRoutineOperation(DevCancelReqVO cancelReqVO) { Long userId = SecurityFrameworkUtils.getLoginUserId(); String userNickname = SecurityFrameworkUtils.getLoginUserNickname(); @@ -353,7 +354,7 @@ if (null == rent_id) { List<DevRentDO> devRentDOList = devRentMapper.selectByPatIdAndState(createReqVO.getPatId(), DevRentStateEnum.FREE.getState()); if (devRentDOList.size() != 1) return CommonResult.error(ROUTINE_CHECK_EXIST); throw exception(ROUTINE_CHECK_EXIST); rent_id = devRentDOList.getFirst().getId(); createReqVO.setId( rent_id ); @@ -395,7 +396,7 @@ } @Override @Transactional @Transactional(rollbackFor = Exception.class) public CommonResult<Long> cancelReadyOperation(DevCancelReqVO cancelReqVO) { Long userId = SecurityFrameworkUtils.getLoginUserId(); String userNickname = SecurityFrameworkUtils.getLoginUserNickname(); @@ -413,7 +414,7 @@ if (null == rent_id) { List<DevRentDO> devRentDOList = devRentMapper.selectByPatIdAndState(createReqVO.getPatId(), DevRentStateEnum.FREE.getState()); if (devRentDOList.size() != 1) return CommonResult.error(DEV_INSTALL_EXIST); throw exception(DEV_INSTALL_EXIST); rent_id = devRentDOList.getFirst().getId(); createReqVO.setId( rent_id ); @@ -455,7 +456,7 @@ } @Override @Transactional @Transactional(rollbackFor = Exception.class) public CommonResult<Long> cancelInstallOperation(DevCancelReqVO cancelReqVO) { Long userId = SecurityFrameworkUtils.getLoginUserId(); String userNickname = SecurityFrameworkUtils.getLoginUserNickname(); @@ -478,7 +479,7 @@ if (null == jobRecordDO) { List<DevRentDO> devRentDOList = devRentMapper.selectByPatIdAndState(createReqVO.getPatId(), DevRentStateEnum.READY.getState()); if (devRentDOList.size() != 1) return CommonResult.error(DEV_INSTALL_EXIST); throw exception(DEV_INSTALL_EXIST); rent_id = devRentDOList.getFirst().getId(); createReqVO.setId( rent_id ); @@ -514,7 +515,7 @@ } @Override @Transactional @Transactional(rollbackFor = Exception.class) public CommonResult<Long> loseOperation(DevRentSaveReqVO updateReqVO) { // 设备遗失时, 标注遗失 markDevLost( updateReqVO.getDevId(), updateReqVO.getReturnTime().toLocalDate() ); @@ -557,8 +558,6 @@ @Override public Long createDevRent(DevRentSaveReqVO createReqVO) { // // 插入 DevRentDO devRent = BeanUtils.toBean(createReqVO, DevRentDO.class); devRentMapper.insert(devRent);