From fc8c86e7a365d5c6bdc37c2b05b9f83115ac2bc3 Mon Sep 17 00:00:00 2001 From: shiyunteng <shiyunteng@example.com> Date: 星期三, 23 四月 2025 17:30:52 +0800 Subject: [PATCH] 巡检任务 设备维修新增是否生成工单 --- platformx-device-biz/src/main/java/com/by4cloud/platformx/device/controller/DeviceInventoryController.java | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 104 insertions(+), 11 deletions(-) diff --git a/platformx-device-biz/src/main/java/com/by4cloud/platformx/device/controller/DeviceInventoryController.java b/platformx-device-biz/src/main/java/com/by4cloud/platformx/device/controller/DeviceInventoryController.java index 0856eae..f6b9bc9 100644 --- a/platformx-device-biz/src/main/java/com/by4cloud/platformx/device/controller/DeviceInventoryController.java +++ b/platformx-device-biz/src/main/java/com/by4cloud/platformx/device/controller/DeviceInventoryController.java @@ -2,12 +2,16 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ArrayUtil; +import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.by4cloud.platformx.common.core.util.R; import com.by4cloud.platformx.common.excel.annotation.ResponseExcel; import com.by4cloud.platformx.common.log.annotation.SysLog; +import com.by4cloud.platformx.device.entity.DeviceDemandPlan; import com.by4cloud.platformx.device.entity.DeviceInventory; import com.by4cloud.platformx.device.service.DeviceInventoryService; import io.swagger.v3.oas.annotations.Operation; @@ -34,7 +38,7 @@ @SecurityRequirement(name = HttpHeaders.AUTHORIZATION) public class DeviceInventoryController { - private final DeviceInventoryService DeviceInventoryService; + private final DeviceInventoryService deviceInventoryService; /** * 鍒嗛〉鏌ヨ @@ -46,7 +50,12 @@ @GetMapping("/page" ) public R getDeviceInventoryPage(@ParameterObject Page page, @ParameterObject DeviceInventory deviceInventory) { LambdaQueryWrapper<DeviceInventory> wrapper = Wrappers.lambdaQuery(); - return R.ok(DeviceInventoryService.page(page, wrapper)); + wrapper.like(StringUtils.isNotBlank(deviceInventory.getDeviceNumber()),DeviceInventory::getDeviceNumber,deviceInventory.getDeviceNumber()); + wrapper.like(StringUtils.isNotBlank(deviceInventory.getSerialNo()),DeviceInventory::getSerialNo,deviceInventory.getSerialNo()); + wrapper.like(StringUtils.isNotBlank(deviceInventory.getName()),DeviceInventory::getName,deviceInventory.getName()); + wrapper.eq(StringUtils.checkValNotNull(deviceInventory.getInventoryStatus()),DeviceInventory::getInventoryStatus,deviceInventory.getInventoryStatus()); + wrapper.orderByDesc(DeviceInventory::getCreateTime); + return R.ok(deviceInventoryService.page(page, wrapper)); } @@ -58,30 +67,59 @@ @Operation(summary = "閫氳繃id鏌ヨ" , description = "閫氳繃id鏌ヨ" ) @GetMapping("/{id}" ) public R getById(@PathVariable("id" ) Long id) { - return R.ok(DeviceInventoryService.getById(id)); + return R.ok(deviceInventoryService.getById(id)); } /** * 鏂板搴撳瓨娴佹按琛� - * @param DeviceInventory 搴撳瓨琛� + * @param deviceInventory 搴撳瓨琛� * @return R */ @Operation(summary = "鏂板搴撳瓨琛�" , description = "鏂板搴撳瓨琛�" ) @SysLog("鏂板搴撳瓨娴佹按琛�" ) @PostMapping - public R save(@RequestBody DeviceInventory DeviceInventory) { - return R.ok(DeviceInventoryService.save(DeviceInventory)); + public R save(@RequestBody DeviceInventory deviceInventory) { + if(deviceInventory.getDeviceId()==null){ + return R.failed("璇烽�夋嫨璁惧娓呭崟"); + } + if(deviceInventory.getSerialNo()==null){ + return R.failed("璇峰~鍐欒澶囧簭鍒楀彿"); + } + QueryWrapper<DeviceInventory> wrapper = new QueryWrapper<>(); + wrapper.lambda().eq(DeviceInventory::getDeviceId,deviceInventory.getDeviceId()) + .eq(DeviceInventory::getSerialNo,deviceInventory.getSerialNo()); + List<DeviceInventory> list = deviceInventoryService.list(wrapper); + if(list !=null && list.size()>0){ + return R.failed("宸插瓨鍦ㄨ搴忓垪鍙凤紝璇烽噸鏂版坊鍔�"); + } + return R.ok(deviceInventoryService.save(deviceInventory)); } /** * 淇敼搴撳瓨琛� - * @param DeviceInventory 搴撳瓨琛� + * @param deviceInventory 搴撳瓨琛� * @return R */ @SysLog("淇敼搴撳瓨琛�" ) @PutMapping - public R updateById(@RequestBody DeviceInventory DeviceInventory) { - return R.ok(DeviceInventoryService.updateById(DeviceInventory)); + public R updateById(@RequestBody DeviceInventory deviceInventory) { + if(deviceInventory.getDeviceId()==null){ + return R.failed("璇烽�夋嫨璁惧娓呭崟"); + } + if(deviceInventory.getSerialNo()==null){ + return R.failed("璇峰~鍐欒澶囧簭鍒楀彿"); + } + QueryWrapper<DeviceInventory> wrapper = new QueryWrapper<>(); + wrapper.lambda().eq(DeviceInventory::getDeviceId,deviceInventory.getDeviceId()) + .eq(DeviceInventory::getSerialNo,deviceInventory.getSerialNo()); + List<DeviceInventory> list = deviceInventoryService.list(wrapper); + if(list !=null && list.size()>0){ + DeviceInventory deviceInventory1 = list.get(0); + if(!deviceInventory1.getId().equals(deviceInventory.getId())){ + return R.failed("宸插瓨鍦ㄨ搴忓垪鍙凤紝璇烽噸鏂版坊鍔�"); + } + } + return R.ok(deviceInventoryService.updateById(deviceInventory)); } /** @@ -93,7 +131,7 @@ @SysLog("閫氳繃id鍒犻櫎搴撳瓨娴佹按琛�" ) @DeleteMapping public R removeById(@RequestBody Long[] ids) { - return R.ok(DeviceInventoryService.removeBatchByIds(CollUtil.toList(ids))); + return R.ok(deviceInventoryService.removeBatchByIds(CollUtil.toList(ids))); } @@ -107,6 +145,61 @@ @GetMapping("/export") @PreAuthorize("@pms.hasPermission('platformx_DeviceInventory_export')" ) public List<DeviceInventory> export(DeviceInventory deviceInventory,Long[] ids) { - return DeviceInventoryService.list(Wrappers.lambdaQuery(deviceInventory).in(ArrayUtil.isNotEmpty(ids), DeviceInventory::getId, ids)); + return deviceInventoryService.list(Wrappers.lambdaQuery(deviceInventory).in(ArrayUtil.isNotEmpty(ids), DeviceInventory::getId, ids)); } + + /** + * 璁惧涓嬫墍鏈夊彲鐢ㄥ簭鍒楀彿涓嬫媺 + * @return + */ + @GetMapping("/getDropdowmList/{deviceId}" ) + public R getDeviceList(@PathVariable("deviceId")Long deviceId) { + QueryWrapper<DeviceInventory> queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("device_id",deviceId); + queryWrapper.eq("inventory_status","1"); + return R.ok(deviceInventoryService.list(queryWrapper)); + } + + /** + * 璁惧涓嬫墍鏈夋姤搴熷簭鍒楀彿涓嬫媺 + * @return + */ + @GetMapping("/getDropdowmScrapList/{deviceId}" ) + public R getDropdowmScrapList(@PathVariable("deviceId")Long deviceId) { + QueryWrapper<DeviceInventory> queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("device_id",deviceId); + queryWrapper.eq("inventory_status","4"); + return R.ok(deviceInventoryService.list(queryWrapper)); + } + + /** + * 绉熻祦鐘舵�佷笅鐨勮澶囩璧佽鎯� + * @return + */ + @GetMapping("/getReleaseDetail/{id}" ) + public R getReleaseDetail(@PathVariable("id")Long id) { + return deviceInventoryService.getReleaseDetail(id); + } + + /** + * 璁惧鏇存柊鐓х墖 + * @param deviceInventory 搴撳瓨琛� + * @return R + */ + @SysLog("璁惧鏇存柊鐓х墖" ) + @PutMapping("/uploadPic") + public R uploadPic(@RequestBody DeviceInventory deviceInventory) { + return R.ok(deviceInventoryService.updateById(deviceInventory)); + } + + /** + * 淇敼搴撳瓨琛� + * @param id 搴撳瓨琛� + * @return R + */ + @SysLog("璁惧褰掕繕鍏ュ簱" ) + @GetMapping("/return/{id}") + public R returnDevice(@PathVariable("id")Long id) { + return deviceInventoryService.returnDevice(id); + } } -- Gitblit v1.9.1