| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public CommonResult<Long> routineFinishOperation(RoutineFinishReqVO routineFinishReqVO) { |
| | | DevRentSaveReqVO createReqVO = BeanUtils.toBean(routineFinishReqVO, DevRentSaveReqVO.class); |
| | | |
| | |
| | | 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(); |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | 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_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(); |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public CommonResult<Long> installOperation(DevRentSaveReqVO createReqVO) { |
| | | Long userId = SecurityFrameworkUtils.getLoginUserId(); |
| | | String userNickname = SecurityFrameworkUtils.getLoginUserNickname(); |
| | |
| | | // 设置设备 使用中 |
| | | 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(); |
| | |
| | | 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(); |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Long dismantleOperation(DevRentSaveReqVO updateReqVO) { |
| | | updateReqVO.setState( DevRentStateEnum.DISMANTLED.getState() ); |
| | | updateDevRent( updateReqVO ); |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Long dataEntryOperation(DevRentSaveReqVO updateReqVO) { |
| | | updateReqVO.setState( DevRentStateEnum.DATAENTERED.getState() ); |
| | | updateDevRent( updateReqVO ); |
| | |
| | | |
| | | // 常规检查 取消 |
| | | @Override |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public CommonResult<Long> cancelRoutineOperation(DevCancelReqVO cancelReqVO) { |
| | | Long userId = SecurityFrameworkUtils.getLoginUserId(); |
| | | String userNickname = SecurityFrameworkUtils.getLoginUserNickname(); |
| | |
| | | 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 ); |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public CommonResult<Long> cancelReadyOperation(DevCancelReqVO cancelReqVO) { |
| | | Long userId = SecurityFrameworkUtils.getLoginUserId(); |
| | | String userNickname = SecurityFrameworkUtils.getLoginUserNickname(); |
| | |
| | | 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 ); |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public CommonResult<Long> cancelInstallOperation(DevCancelReqVO cancelReqVO) { |
| | | Long userId = SecurityFrameworkUtils.getLoginUserId(); |
| | | String userNickname = SecurityFrameworkUtils.getLoginUserNickname(); |
| | |
| | | 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 ); |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public CommonResult<Long> loseOperation(DevRentSaveReqVO updateReqVO) { |
| | | // 设备遗失时, 标注遗失 |
| | | markDevLost( updateReqVO.getDevId(), updateReqVO.getReturnTime().toLocalDate() ); |
| | |
| | | |
| | | @Override |
| | | public Long createDevRent(DevRentSaveReqVO createReqVO) { |
| | | // |
| | | |
| | | // 插入 |
| | | DevRentDO devRent = BeanUtils.toBean(createReqVO, DevRentDO.class); |
| | | devRentMapper.insert(devRent); |