| | |
| | | if (Objects.isNull(warehouse.getName())) { |
| | | throw new CoolException("仓库名称不能为空!!"); |
| | | } |
| | | List<Warehouse> warehouses = warehouseService.list(new LambdaQueryWrapper<Warehouse>().eq(Warehouse::getName, warehouse.getName())); |
| | | if (!warehouses.isEmpty()) { |
| | | throw new CoolException("仓库名称已存在!!"); |
| | | } |
| | | if (!warehouseService.list(new LambdaQueryWrapper<Warehouse>().eq(Warehouse::getCode, warehouse.getCode())).isEmpty()) { |
| | | throw new CoolException("仓库编码已存在!!"); |
| | | } |
| | | |
| | | warehouse.setCreateBy(getLoginUserId()); |
| | | warehouse.setUpdateBy(getLoginUserId()); |
| | | if (!warehouseService.save(warehouse)) { |
| | |
| | | throw new CoolException("仓库名称不能为空!!"); |
| | | } |
| | | warehouse.setUpdateBy(getLoginUserId()); |
| | | |
| | | Warehouse warehouse1 = warehouseService.getById(warehouse.getId()); |
| | | if (!warehouse.getName().equals(warehouse1.getName())) { |
| | | List<Warehouse> areasList = warehouseService.list(new LambdaQueryWrapper<Warehouse>().eq(Warehouse::getName, warehouse1.getName())); |
| | | if (!areasList.isEmpty()) { |
| | | throw new CoolException("仓库名已存在!!"); |
| | | } |
| | | } |
| | | if (!warehouse.getCode().equals(warehouse1.getCode())) { |
| | | List<Warehouse> areasList = warehouseService.list(new LambdaQueryWrapper<Warehouse>().eq(Warehouse::getCode, warehouse1.getCode())); |
| | | if (!areasList.isEmpty()) { |
| | | throw new CoolException("仓库编码已存在!!"); |
| | | } |
| | | } |
| | | |
| | | |
| | | if (!warehouseService.updateById(warehouse)) { |
| | | return R.error("Update Fail"); |
| | | } |