| | |
| | | import com.by4cloud.platformx.common.core.util.R; |
| | | import com.by4cloud.platformx.common.log.annotation.SysLog; |
| | | import com.by4cloud.platformx.common.security.util.SecurityUtils; |
| | | import com.by4cloud.platformx.device.constant.MaxSizeContant; |
| | | import com.by4cloud.platformx.device.entity.Device; |
| | | import com.by4cloud.platformx.device.entity.DeviceInventory; |
| | | import com.by4cloud.platformx.device.service.DeviceInventoryService; |
| | | import com.by4cloud.platformx.device.service.DeviceService; |
| | | import com.by4cloud.platformx.device.service.JcMaxSizeService; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import com.by4cloud.platformx.common.excel.annotation.ResponseExcel; |
| | | import io.swagger.v3.oas.annotations.security.SecurityRequirement; |
| | |
| | | |
| | | private final DeviceService deviceService; |
| | | private final DeviceInventoryService inventoryService; |
| | | private final JcMaxSizeService maxSizeService; |
| | | |
| | | /** |
| | | * 分页查询 |
| | |
| | | if(StringUtils.isBlank(device.getNumber())){ |
| | | return R.failed("请填写设备编号"); |
| | | } |
| | | QueryWrapper<Device> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda().eq(Device::getNumber,device.getNumber()); |
| | | List<Device> list = deviceService.list(wrapper); |
| | | if(list !=null && list.size()>0){ |
| | | Device device1 = list.get(0); |
| | | if(!device1.getId().equals(device.getId())){ |
| | | return R.failed("已存在该编号"); |
| | | } |
| | | } |
| | | device.setNumber(maxSizeService.nextNo(MaxSizeContant.DEVICE_NUM)); |
| | | device.setReqStatus(1); |
| | | deviceService.updateById(device); |
| | | return R.ok(); |
| | |
| | | if(device.getReqStatus()==0){ |
| | | return R.ok(deviceService.save(device)); |
| | | } |
| | | if(StringUtils.isBlank(device.getNumber())){ |
| | | return R.failed("请填写设备编号"); |
| | | } |
| | | QueryWrapper<Device> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda().eq(Device::getNumber,device.getNumber()); |
| | | List<Device> list = deviceService.list(wrapper); |
| | | if(list !=null && list.size()>0){ |
| | | return R.failed("已存在该编号"); |
| | | } |
| | | device.setNumber(maxSizeService.nextNo(MaxSizeContant.DEVICE_NUM)); |
| | | return R.ok(deviceService.save(device)); |
| | | } |
| | | |
| | |
| | | @PutMapping |
| | | @PreAuthorize("@pms.hasPermission('platformx_device_edit')" ) |
| | | public R updateById(@RequestBody Device device) { |
| | | QueryWrapper<Device> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda().eq(Device::getNumber,device.getNumber()); |
| | | List<Device> list = deviceService.list(wrapper); |
| | | if(list !=null && list.size()>0){ |
| | | Device device1 = list.get(0); |
| | | if(!device1.getId().equals(device.getId())){ |
| | | return R.failed("已存在该编号"); |
| | | } |
| | | } |
| | | return R.ok(deviceService.updateById(device)); |
| | | } |
| | | |