skyouc
6 天以前 40d9cd510741a098bd52cbe22a5f9e5528f45abc
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocServiceImpl.java
@@ -77,8 +77,14 @@
    @Transactional(rollbackFor = Exception.class)
    public R initLocs(LocMastInitParam param, Long loginUserId) {
        //清空表
        this.baseMapper.deleteAll();
//        this.baseMapper.deleteAll();
        //清空当前库区库位
        List<Loc> locs = this.list(new LambdaQueryWrapper<Loc>().eq(Loc::getWarehouseId, param.getWarehouseId()).eq(Loc::getAreaId, param.getAreaId()));
        if (!locs.isEmpty()) {
            if (!this.remove(new LambdaQueryWrapper<Loc>().eq(Loc::getWarehouseId, param.getWarehouseId()).eq(Loc::getAreaId, param.getAreaId()))) {
                throw new CoolException("初始化失败:数据删除失败!!");
            }
        }
        WarehouseAreas warehouseAreas = warehouseAreasService.getOne(new LambdaQueryWrapper<WarehouseAreas>()
                .eq(WarehouseAreas::getWarehouseId, param.getWarehouseId())
                .eq(WarehouseAreas::getId, param.getAreaId()));
@@ -108,9 +114,21 @@
                }
            }
        }
        if (!this.saveBatch(list)) {
            throw new CoolException("库位初始化失败!!");
        }
        List<LocTypeRela> locTypeRelas = new ArrayList<>();
        for (Long typeId : param.getTypeIds()) {
            for (Loc loc : list) {
                LocTypeRela typeRela = new LocTypeRela();
                typeRela.setLocId(loc.getId()).setTypeId(typeId);
                locTypeRelas.add(typeRela);
            }
        }
        if (!locTypeRelaService.saveBatch(locTypeRelas)) {
            throw new CoolException("库位类型关联失败!!");
        }
        return R.ok("初始化成功!!");
    }