From a4112a5d31fa3a66daafdc009ff3b3047bb98f67 Mon Sep 17 00:00:00 2001 From: zjj <3272660260@qq.com> Date: 星期六, 24 五月 2025 17:14:04 +0800 Subject: [PATCH] #巷道 --- rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocServiceImpl.java | 47 ++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 40 insertions(+), 7 deletions(-) diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocServiceImpl.java index 15f42fa..378e1ac 100644 --- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocServiceImpl.java +++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocServiceImpl.java @@ -17,6 +17,7 @@ import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Objects; @@ -49,9 +50,9 @@ throw new CoolException("淇敼搴撲綅淇℃伅涓嶈兘涓虹┖锛侊紒"); } - String join = locs.getLoc().getType(); - if (!Objects.isNull(locs.getTypeIds()) && !locs.getTypeIds().isEmpty()) { - join = StringUtils.join(locs.getTypeIds(), ","); + String join = loc.getType(); + if (!Objects.isNull(loc.getTypeIds()) && !loc.getTypeIds().isEmpty()) { + join = StringUtils.join(loc.getTypeIds(), ","); } boolean update = this.update(new LambdaUpdateWrapper<Loc>() .in(Loc::getId, locs.getId()) @@ -59,7 +60,7 @@ .set(!Objects.isNull(loc.getAreaId()), Loc::getAreaId, loc.getAreaId()) .set(!Objects.isNull(loc.getWarehouseId()), Loc::getWarehouseId, loc.getWarehouseId()) .set(!Objects.isNull(loc.getUseStatus()), Loc::getUseStatus, loc.getUseStatus()) - .set(!Objects.isNull(loc.getType()), Loc::getType, join) + .set(!Objects.isNull(loc.getTypeIds()) && !loc.getTypeIds().isEmpty(), Loc::getType, join) .set(!Objects.isNull(loc.getLength()), Loc::getLength, loc.getLength()) .set(!Objects.isNull(loc.getWidth()), Loc::getWidth, loc.getWidth()) .set(!Objects.isNull(loc.getHeight()), Loc::getHeight, loc.getHeight()) @@ -77,8 +78,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())); @@ -87,18 +94,32 @@ } 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<>(); + Integer chanl = 0; //榛樿绗竴宸烽亾 for (int r = param.getStartRow(); r <= param.getEndRow(); r++) { + if (r % param.getChannel() == 1) { + chanl ++; + } 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") .setRow(r) .setCol(b) .setLev(l) + .setChannel(chanl) .setType(join) .setAreaId(param.getAreaId()) .setUpdateBy(loginUserId) @@ -108,9 +129,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("鍒濆鍖栨垚鍔燂紒锛�"); } -- Gitblit v1.9.1