From 870576e285c0d60531184cbc4dc553f0b9102d62 Mon Sep 17 00:00:00 2001 From: zhenghaoyu Date: Fri, 28 Mar 2025 16:18:21 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=8F=96=E6=B6=88=E6=8F=90=E8=B4=A7=EF=BC=8C?= =?UTF-8?q?=E8=BF=90=E5=8D=95=E6=8F=90=E8=B4=A7=E4=BB=B6=E6=95=B0=E8=BF=98?= =?UTF-8?q?=E5=8E=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/TrunklineBillladingServiceImpl.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineBillladingServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineBillladingServiceImpl.java index 72adc876a..ebac0bfb7 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineBillladingServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineBillladingServiceImpl.java @@ -5,6 +5,7 @@ import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.logpm.basicdata.feign.*; @@ -33,6 +34,7 @@ import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; @Slf4j @@ -535,6 +537,45 @@ public class TrunklineBillladingServiceImpl extends BaseServiceImpl updateList = new ArrayList<>(); + + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("billlading_id",billladingId); + List trunklineBillladingWaybillEntities = billladingWaybillService.list(queryWrapper); + if(CollUtil.isNotEmpty(trunklineBillladingWaybillEntities)){ + //把trunklineBillladingWaybillEntities中所有的waybillId放入一个List,排除掉null的waybillId + List waybillIdList = trunklineBillladingWaybillEntities.stream().map(TrunklineBillladingWaybillEntity::getWaybillId).filter(Objects::nonNull).collect(Collectors.toList()); + List listByWaybillIds = warehouseWaybillClient.findListByWaybillIds(waybillIdList); + //把listByWaybillIds中的waybillId放入一个Map,key为waybillId,value为WarehouseWaybillEntity + Map map = listByWaybillIds.stream().collect(Collectors.toMap(WarehouseWaybillEntity::getId, Function.identity())); + + trunklineBillladingWaybillEntities.forEach(billladingWaybillEntity -> { + String waybillNo = billladingWaybillEntity.getWaybillNo(); + Long waybillId = billladingWaybillEntity.getWaybillId(); + Integer realNum = billladingWaybillEntity.getRealNum(); + billladingWaybillEntity.setRealNum(0); + if(!"--".equals(waybillNo)){ + WarehouseWaybillEntity warehouseWaybill = map.get(waybillId); + if(!Objects.isNull(warehouseWaybill)){ + Integer billladingNum = warehouseWaybill.getBillladingNum(); + + WarehouseWaybillEntity updateWaybillEntity = new WarehouseWaybillEntity(); + updateWaybillEntity.setId(billladingWaybillEntity.getWaybillId()); + updateWaybillEntity.setBillladingNum(billladingNum-realNum); + + updateList.add(updateWaybillEntity); + } + } + }); + + billladingWaybillService.updateBatchById(trunklineBillladingWaybillEntities); + + if(CollUtil.isNotEmpty(updateList)){ + warehouseWaybillClient.updateList(updateList); + } + + } break; default: log.warn("#############updateBillladingStatus: 未知的更新操作");