skyouc
2025-03-25 eb8ded2565e746a360985f702c556b26f750d35a
rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/WarehouseController.java
@@ -73,6 +73,14 @@
        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)) {
@@ -92,6 +100,22 @@
            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");
        }
@@ -105,7 +129,8 @@
        if (ids.length < 1) {
            throw new CoolException("查询id不能为空!!");
        }
        List<WarehouseAreas> warehouseAreas = warehouseAreasService.list(new LambdaQueryWrapper<WarehouseAreas>().in(WarehouseAreas::getWareId, ids));
        List<WarehouseAreas> warehouseAreas = warehouseAreasService.list(new LambdaQueryWrapper<WarehouseAreas>()
                .in(WarehouseAreas::getWarehouseId, ids));
        if (!warehouseAreas.isEmpty()) {
            throw new CoolException("当前仓库下有未删除库区, 不可操作删除!!");
        }