| | |
| | | |
| | | 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; |
| | |
| | | @SecurityRequirement(name = HttpHeaders.AUTHORIZATION) |
| | | public class DeviceInventoryController { |
| | | |
| | | private final DeviceInventoryService DeviceInventoryService; |
| | | private final DeviceInventoryService deviceInventoryService; |
| | | |
| | | /** |
| | | * 分页查询 |
| | |
| | | @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)); |
| | | } |
| | | |
| | | |
| | |
| | | @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)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @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))); |
| | | } |
| | | |
| | | |
| | |
| | | @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); |
| | | } |
| | | } |