From 9297cc4820d91a655cc56501ecaf013a4b9b08a3 Mon Sep 17 00:00:00 2001 From: eight <641137800@qq.com> Date: 星期日, 29 九月 2024 14:05:35 +0800 Subject: [PATCH] 设备统计 --- jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/devrent/DevRentController.java | 88 ++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 81 insertions(+), 7 deletions(-) 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 c6cf8dc..bbfc4ab 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,7 +2,6 @@ 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.DevRentStateEnum; import cn.lihu.jh.module.ecg.service.devmanage.DeviceService; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.*; @@ -47,6 +46,19 @@ @Resource private DeviceService deviceService; + @PostMapping("/dev-ready") + @Operation(summary = "璁惧鍑嗗") + @PreAuthorize("@ss.hasPermission('ecg:doctor:task')") + public CommonResult<Long> devReady(@Valid @RequestBody DevRentSaveReqVO createReqVO) { + try { + return devRentService.readyOperation(createReqVO); + } catch ( RuntimeException runtimeException ) { + String err = ExceptionUtils.formatException( runtimeException ); + log.error("devInstall: " + err); + return CommonResult.error(DEV_INSTALL_EXCEPTION); + } + } + @PostMapping("/dev-install") @Operation(summary = "瑁呮満") @PreAuthorize("@ss.hasPermission('ecg:doctor:task')") @@ -66,6 +78,20 @@ 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); + } + } + + @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 ); @@ -130,7 +156,16 @@ @PreAuthorize("@ss.hasPermission('ecg:doctor:task')") public CommonResult<DevRentRespVO> getDevRent(@RequestParam("id") Long id) { DevRentDO devRent = devRentService.getDevRent(id); - return CommonResult.success(BeanUtils.toBean(devRent, DevRentRespVO.class)); + + DevRentRespVO devRentRespVO = BeanUtils.toBean(devRent, DevRentRespVO.class); + + DeviceDO deviceDO = deviceService.getDevice( devRent.getDevId() ); + if (null != deviceDO) { + devRentRespVO.setCategory(deviceDO.getCategory()); + devRentRespVO.setBrand(deviceDO.getBrand()); + devRentRespVO.setModel(deviceDO.getModel()); + } + return CommonResult.success(devRentRespVO); } @GetMapping("/page") @@ -154,13 +189,52 @@ BeanUtils.toBean(list, DevRentRespVO.class)); } - @GetMapping("/get-dismantle-rent") - @Operation(summary = "鑾峰彇鎮h�呰澶囩殑鏈�杩戠璧佹儏鍐�") + @GetMapping("/get-ready-rent") + @Operation(summary = "鑾峰彇宸查鍙栫璧佹儏鍐�") @PreAuthorize("@ss.hasPermission('ecg:doctor:task')") - public CommonResult<DevRentRespVO> getLatestRent( @Valid DevRentSearchReqVO searchReqVO ) + public CommonResult<DevRentRespVO> getReadyRent( @Valid DevRentSearchReqVO searchReqVO ) { - searchReqVO.setState( DevRentStateEnum.INSTALLED.getState() ); - DevRentDO devRent = devRentService.getDismantleRent( searchReqVO ); + DevRentDO devRent = devRentService.getReadyOrCancelledRent( searchReqVO ); + if (null == devRent) { + return CommonResult.success(null); + } + + DevRentRespVO devRentRespVO = BeanUtils.toBean(devRent, DevRentRespVO.class); + + DeviceDO deviceDO = deviceService.getDevice( devRent.getDevId() ); + if (null != deviceDO) { + devRentRespVO.setCategory(deviceDO.getCategory()); + devRentRespVO.setBrand(deviceDO.getBrand()); + devRentRespVO.setModel(deviceDO.getModel()); + } + return CommonResult.success(devRentRespVO); + } + + @GetMapping("/get-installed-rent") + @Operation(summary = "鑾峰彇宸插畨瑁呯璧佹儏鍐�") + @PreAuthorize("@ss.hasPermission('ecg:doctor:task')") + public CommonResult<DevRentRespVO> getInstalledRent( @Valid DevRentSearchReqVO searchReqVO ) + { + DevRentDO devRent = devRentService.getInstalledOrCancelledRent( searchReqVO ); + if (null == devRent) { + return CommonResult.success(null); + } + + DeviceDO deviceDO = deviceService.getDevice( devRent.getDevId() ); + + DevRentRespVO devRentRespVO = BeanUtils.toBean(devRent, DevRentRespVO.class); + devRentRespVO.setCategory( deviceDO.getCategory() ); + devRentRespVO.setBrand( deviceDO.getBrand() ); + devRentRespVO.setModel( deviceDO.getModel() ); + return CommonResult.success(devRentRespVO); + } + + @GetMapping("/get-dismantled-rent") + @Operation(summary = "鑾峰彇宸叉媶鍗哥璧佹儏鍐�") + @PreAuthorize("@ss.hasPermission('ecg:doctor:task')") + public CommonResult<DevRentRespVO> getDismantledRent( @Valid DevRentSearchReqVO searchReqVO ) + { + DevRentDO devRent = devRentService.getDismantledRent( searchReqVO ); if (null == devRent) { return CommonResult.success(null); } -- Gitblit v1.9.3