| | |
| | | @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())); |
| | |
| | | } |
| | | String join = StringUtils.join(param.getTypeIds(), ","); |
| | | |
| | | String[] split = warehouseAreas.getCode().split("\\."); |
| | | if (split.length == 0){ |
| | | throw new CoolException("库区编码错误!!"); |
| | | } |
| | | StringBuilder locStar = new StringBuilder(); |
| | | for (int i = 0; i < split.length; i++) { |
| | | locStar.append(split[i]).append("-"); |
| | | } |
| | | |
| | | List<Loc> list = new ArrayList<>(); |
| | | for (int r = param.getStartRow(); r <= param.getEndRow(); r++) { |
| | | for (int b = param.getStartBay(); b <= param.getEndBay(); b++) { |
| | | for (int l = param.getStartLev(); l <= param.getEndLev(); l++) { |
| | | // 获取库位号 |
| | | String locNo = String.format("%02d", r) + String.format("%03d", b) + String.format("%02d", l); |
| | | String locNo = locStar + String.format("%d", r) + String.format("-%d", b) + String.format("-%d", l); |
| | | Loc loc = new Loc(); |
| | | loc.setCode(locNo) |
| | | .setUseStatus("O") |