| | |
| | | @Autowired |
| | | private WarehouseAreasService warehouseAreasService; |
| | | |
| | | @Autowired |
| | | private LocService locService; |
| | | |
| | | @PreAuthorize("hasAuthority('manager:warehouseAreas:list')") |
| | |
| | | @OperationLog("Create 库区信息表") |
| | | @PostMapping("/warehouseAreas/save") |
| | | public R save(@RequestBody WarehouseAreas warehouseAreas) { |
| | | |
| | | if (Objects.isNull(warehouseAreas)) { |
| | | throw new CoolException("参数不能为空!!"); |
| | | } |
| | | if (Objects.isNull(warehouseAreas.getName())) { |
| | | throw new CoolException("库区名称不能为空!!"); |
| | | } |
| | | if (Objects.isNull(warehouseAreas.getCode())) { |
| | | throw new CoolException("库区编码不能为空!!"); |
| | | } |
| | | |
| | | List<WarehouseAreas> list = warehouseAreasService.list(new LambdaQueryWrapper<WarehouseAreas>().eq(WarehouseAreas::getName, warehouseAreas.getName())); |
| | | if (!list.isEmpty()) { |
| | | throw new CoolException("库区名称已存在!!"); |
| | | } |
| | | if (!warehouseAreasService.list(new LambdaQueryWrapper<WarehouseAreas>().eq(WarehouseAreas::getCode, warehouseAreas.getCode())).isEmpty()) { |
| | | throw new CoolException("库区编码已存在!!"); |
| | | } |
| | | |
| | | warehouseAreas.setCreateBy(getLoginUserId()); |
| | | warehouseAreas.setUpdateBy(getLoginUserId()); |
| | | if (!warehouseAreasService.save(warehouseAreas)) { |
| | |
| | | @PostMapping("/warehouseAreas/update") |
| | | public R update(@RequestBody WarehouseAreas warehouseAreas) { |
| | | warehouseAreas.setUpdateBy(getLoginUserId()); |
| | | warehouseAreas.setUpdateTime(new Date()); |
| | | WarehouseAreas areas = warehouseAreasService.getById(warehouseAreas.getWarehouseId()); |
| | | if (Objects.isNull(areas)) { |
| | | throw new CoolException("数据错误:仓库库区不存在!!"); |
| | | } |
| | | if (!warehouseAreas.getName().equals(areas.getName())) { |
| | | List<WarehouseAreas> areasList = warehouseAreasService.list(new LambdaQueryWrapper<WarehouseAreas>().eq(WarehouseAreas::getName, areas.getName())); |
| | | if (!areasList.isEmpty()) { |
| | | throw new CoolException("仓库名已存在!!"); |
| | | } |
| | | } |
| | | if (!warehouseAreas.getCode().equals(areas.getCode())) { |
| | | List<WarehouseAreas> areasList = warehouseAreasService.list(new LambdaQueryWrapper<WarehouseAreas>().eq(WarehouseAreas::getCode, areas.getCode())); |
| | | if (!areasList.isEmpty()) { |
| | | throw new CoolException("仓库编码已存在!!"); |
| | | } |
| | | } |
| | | |
| | | if (!warehouseAreasService.updateById(warehouseAreas)) { |
| | | return R.error("Update Fail"); |
| | | } |