From 5129ab36d10cbba2d480e5d5a87efe5bfa1c9838 Mon Sep 17 00:00:00 2001 From: zhenghaoyu Date: Mon, 2 Dec 2024 11:48:31 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=B9=B2=E7=BA=BFbug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/constant/WorkNodeEnums.java | 1 + .../controller/AdvanceDetailController.java | 7 +++ .../mapper/TrunklineAdvanceDetailMapper.java | 3 + .../mapper/TrunklineAdvanceDetailMapper.xml | 8 +++ .../TrunklineAdvanceDetailServiceImpl.java | 57 +++++++++++++------ 5 files changed, 59 insertions(+), 17 deletions(-) diff --git a/blade-biz-common/src/main/java/org/springblade/common/constant/WorkNodeEnums.java b/blade-biz-common/src/main/java/org/springblade/common/constant/WorkNodeEnums.java index e7f43c03e..20e21750d 100644 --- a/blade-biz-common/src/main/java/org/springblade/common/constant/WorkNodeEnums.java +++ b/blade-biz-common/src/main/java/org/springblade/common/constant/WorkNodeEnums.java @@ -13,6 +13,7 @@ import java.io.Serializable; @Getter public enum WorkNodeEnums implements Serializable { + DELETE_DATA_ENTRY(100000, "删除数据"), INITIAL_DATA_ENTRY(101010, "数据入库"), INITIAL_WAREHOUSE_ENTRY(101020, "始发仓入库"), diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/AdvanceDetailController.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/AdvanceDetailController.java index 637dbea38..7ede23f75 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/AdvanceDetailController.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/AdvanceDetailController.java @@ -93,6 +93,13 @@ public class AdvanceDetailController { return R.fail(405,"请选择删除的包件"); } + BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse(); + if(Objects.isNull(myCurrentWarehouse)){ + log.warn(method+"请选择仓库"); + return R.fail(405,"请选择仓库"); + } + advanceDetailDTO.setWarehouseId(myCurrentWarehouse.getId()); + advanceDetailDTO.setWarehouseName(myCurrentWarehouse.getName()); return advanceDetailService.deleteAdvanceDetail(advanceDetailDTO); }catch (CustomerException e){ diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.java index 2920b5aa3..4fa40dd7e 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.java @@ -102,4 +102,7 @@ public interface TrunklineAdvanceDetailMapper extends BaseMapper findCarsLoadScanInfoByOrderPackageCodes(@Param("orderPackageCodes") List orderPackageCodes); IPage findOrderDetailsAndTrunklineCarsNo(IPage page, @Param("param") OrderDetailsDTO orderDetailsDTO); + + void deleteListByIds(@Param("advanceDetailIdList") List advanceDetailIdList); + } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.xml b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.xml index 34abca19a..9c0ff6c2c 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.xml +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.xml @@ -735,4 +735,12 @@ AND cmax.cupdateTime = ltcls.create_time + + delete from logpm_trunkline_advance_detail + where id in + + #{item} + + + diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceDetailServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceDetailServiceImpl.java index 4c590d388..e7970b6a9 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceDetailServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceDetailServiceImpl.java @@ -20,6 +20,7 @@ import com.logpm.trunkline.entity.TrunklineAdvanceDetailEntity; import com.logpm.trunkline.entity.TrunklineAdvanceEntity; import com.logpm.trunkline.mapper.TrunklineAdvanceDetailMapper; import com.logpm.trunkline.mapper.TrunklineAdvanceMapper; +import com.logpm.trunkline.service.IPackageTrackLogAsyncService; import com.logpm.trunkline.service.ISendFanoutService; import com.logpm.trunkline.service.ITrunklineAdvanceDetailService; import com.logpm.trunkline.vo.*; @@ -43,6 +44,7 @@ import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.redis.cache.BladeRedis; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.StringUtil; import org.springframework.stereotype.Service; @@ -67,6 +69,8 @@ public class TrunklineAdvanceDetailServiceImpl extends BaseServiceImpl advanceDetailIds = advanceDetailDTO.getAdvanceDetailIds(); - for (Long advanceDetailId : advanceDetailIds) { - - TrunklineAdvanceDetailEntity advanceDetailEntity = getById(advanceDetailId); - Long advanceId = advanceDetailEntity.getAdvanceId(); - baseMapper.deleteAdvanceDetailById(advanceDetailId); - - //判断暂存单下还有没有包件 - List strings = baseMapper.findOrderPackageCodesByAdvanceId(advanceId); - if (0 == strings.size()) { - //删除暂存单 - List advanceIds = new ArrayList<>(); - advanceIds.add(advanceId); - advanceMapper.deletedAdvance(advanceIds); - } else { - //数量减一 - advanceMapper.subTotalNumByAdvanceId(advanceId); + + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.in("id", advanceDetailIds); + + List advanceDetailEntities = baseMapper.selectList(queryWrapper); + //把advanceDetailEntities通过advanceId进行分组 + Map> advanceDetailEntityMap = advanceDetailEntities.stream().collect(Collectors.groupingBy(TrunklineAdvanceDetailEntity::getAdvanceId)); + + List orderPackageCodes = new ArrayList<>(); + advanceDetailEntityMap.keySet().forEach(advanceId -> { + List advanceDetailEntities1 = advanceDetailEntityMap.get(advanceId); + + if(CollUtil.isNotEmpty(advanceDetailEntities1)){ + //把advanceDetailEntities1的id放入一个List + List advanceDetailIdList = advanceDetailEntities1.stream().map(TrunklineAdvanceDetailEntity::getId).collect(Collectors.toList()); + baseMapper.deleteListByIds(advanceDetailIdList); + + List strings = baseMapper.findOrderPackageCodesByAdvanceId(advanceId); + if (0 == strings.size()) { + //删除暂存单 + List advanceIds = new ArrayList<>(); + advanceIds.add(advanceId); + advanceMapper.deletedAdvance(advanceIds); + } else { + //数量减一 + advanceMapper.subTotalNumByAdvanceId(advanceId); + } + + //把advanceDetailEntities1所有元素的orderPackageCode放入一个List + List orderPackageCodeList = advanceDetailEntities1.stream().map(TrunklineAdvanceDetailEntity::getOrderPackageCode).collect(Collectors.toList()); + + orderPackageCodes.addAll(orderPackageCodeList); + } - } + }); + + packageTrackLogAsyncService.addPackageTrackLog(AuthUtil.getTenantId(), AuthUtil.getUserId(), Func.firstLong(AuthUtil.getDeptId()), AuthUtil.getNickName(), orderPackageCodes, advanceDetailDTO.getWarehouseId(), advanceDetailDTO.getWarehouseName(), WorkNodeEnums.DELETE_DATA_ENTRY.getCode(), "包件删除"); return R.success("删除成功"); }