From bcd9cb83cbbb36217cb99ced7bf1fa3cb26bd53c Mon Sep 17 00:00:00 2001 From: zjj <3272660260@qq.com> Date: 星期一, 28 四月 2025 16:59:51 +0800 Subject: [PATCH] #wms端生成任务优化 --- rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocServiceImpl.java | 52 +++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 37 insertions(+), 15 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 6cb941a..259612b 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 @@ -1,6 +1,5 @@ package com.vincent.rsf.server.manager.service.impl; -import com.alibaba.fastjson.JSONArray; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.vincent.rsf.framework.common.R; @@ -12,16 +11,14 @@ import com.vincent.rsf.server.manager.mapper.LocTypeRelaMapper; import com.vincent.rsf.server.manager.service.*; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import springfox.documentation.annotations.ApiIgnore; import java.util.ArrayList; -import java.util.Date; import java.util.List; import java.util.Objects; -import java.util.stream.Collectors; @Service("locService") public class LocServiceImpl extends ServiceImpl<LocMapper, Loc> implements LocService { @@ -52,13 +49,17 @@ throw new CoolException("淇敼搴撲綅淇℃伅涓嶈兘涓虹┖锛侊紒"); } + 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()) .eq(Loc::getStatus, 1) .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, loc.getType()) + .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()) @@ -74,15 +75,23 @@ @Override @Transactional(rollbackFor = Exception.class) - public R initLocs(LocMastInitParam param) { + public R initLocs(LocMastInitParam param, Long loginUserId) { //娓呯┖琛� - if (this.baseMapper.delete(new LambdaUpdateWrapper<>()) < 0) { - throw new CoolException("鏁版嵁搴撳垵濮嬪寲澶辫触锛氳�佹暟鎹垹闄ゅけ璐ワ紒锛�"); +// 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.getById(param.getAreaId()); + WarehouseAreas warehouseAreas = warehouseAreasService.getOne(new LambdaQueryWrapper<WarehouseAreas>() + .eq(WarehouseAreas::getWarehouseId, param.getWarehouseId()) + .eq(WarehouseAreas::getId, param.getAreaId())); if (Objects.isNull(warehouseAreas)) { throw new CoolException("搴撳尯涓嶅瓨鍦紒锛�"); } + String join = StringUtils.join(param.getTypeIds(), ","); List<Loc> list = new ArrayList<>(); for (int r = param.getStartRow(); r <= param.getEndRow(); r++) { @@ -96,16 +105,29 @@ .setRow(r) .setCol(b) .setLev(l) + .setType(join) .setAreaId(param.getAreaId()) - .setWarehouseId(warehouseAreas.getWarehouseId()) - .setType(param.getType()); - + .setUpdateBy(loginUserId) + .setCreateBy(loginUserId) + .setWarehouseId(warehouseAreas.getWarehouseId()); list.add(loc); } } } + 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("鍒濆鍖栨垚鍔燂紒锛�"); } @@ -146,8 +168,7 @@ if (locs.getId().isEmpty()) { throw new CoolException("搴撲綅ID涓嶈兘涓虹┖锛侊紒"); } - Loc loc = locs.getLoc(); - if (Objects.isNull(loc)) { + if (Objects.isNull(locs.getLocAreaId())) { throw new CoolException("淇敼搴撲綅淇℃伅涓嶈兘涓虹┖锛侊紒"); } List<LocArea> locAreas = locAreaService.list(new LambdaQueryWrapper<LocArea>().eq(LocArea::getId, locs.getLocAreaId())); @@ -157,7 +178,8 @@ List<LocAreaRela> relas = new ArrayList<>(); locs.getId().forEach(id -> { LocAreaRela locAreaRela = new LocAreaRela(); - locAreaRela.setLocId(id).setLocAreaId(locs.getLocAreaId()); + locAreaRela.setLocId(id) + .setLocAreaId(locs.getLocAreaId()); relas.add(locAreaRela); }); if (!locAreaRelaService.saveBatch(relas)) { -- Gitblit v1.9.1