| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.by4cloud.platformx.common.core.util.R; |
| | | import com.by4cloud.platformx.common.log.annotation.SysLog; |
| | | import com.by4cloud.platformx.device.constant.MaxSizeContant; |
| | | import com.by4cloud.platformx.device.entity.DeviceClass; |
| | | import com.by4cloud.platformx.device.entity.DeviceInventory; |
| | | import com.by4cloud.platformx.device.entity.MaxSize; |
| | | import com.by4cloud.platformx.device.service.DeviceClassService; |
| | | 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; |
| | |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.constraints.Max; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | |
| | | public class DeviceClassController { |
| | | |
| | | private final DeviceClassService deviceClassService; |
| | | private final JcMaxSizeService maxSizeService; |
| | | |
| | | /** |
| | | * 分页查询 |
| | |
| | | if(deviceClass.getParentId()==null){ |
| | | return R.failed("上级分类未选择!"); |
| | | } |
| | | QueryWrapper<DeviceClass> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda().eq(DeviceClass::getNumber,deviceClass.getNumber()); |
| | | List<DeviceClass> list = deviceClassService.list(wrapper); |
| | | if(list!=null&&list.size()>0){ |
| | | return R.failed("该编号已存在"); |
| | | } |
| | | deviceClass.setNumber(maxSizeService.nextNo(MaxSizeContant.DEVICE_CLASS_NUM)); |
| | | deviceClass.setPId(deviceClass.getParentId().longValue()); |
| | | return R.ok(deviceClassService.save(deviceClass)); |
| | | } |
| | |
| | | public R updateById(@RequestBody DeviceClass deviceClass) { |
| | | if(deviceClass.getParentId()==null){ |
| | | return R.failed("上级分类未选择!"); |
| | | } |
| | | QueryWrapper<DeviceClass> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda().eq(DeviceClass::getNumber,deviceClass.getNumber()); |
| | | List<DeviceClass> list = deviceClassService.list(wrapper); |
| | | if(list!=null&&list.size()>0){ |
| | | DeviceClass deviceClass1 = list.get(0); |
| | | if(!deviceClass1.getId().equals(deviceClass.getId())){ |
| | | return R.failed("已存在该序列号,请重新添加"); |
| | | } |
| | | } |
| | | deviceClass.setPId(deviceClass.getParentId().longValue()); |
| | | return R.ok(deviceClassService.updateById(deviceClass)); |