diff --git a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionParcelListClient.java b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionParcelListClient.java index 0a006ab58..4afae622e 100644 --- a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionParcelListClient.java +++ b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionParcelListClient.java @@ -300,5 +300,9 @@ public interface IDistributionParcelListClient { @PostMapping(API_PREFIX + "/findIdAndWarehouseIdListByOrderCodes") List findIdAndWarehouseIdListByOrderCodes(@RequestBody Set orderCodeSet); + + @PostMapping(API_PREFIX + "/findListByOrderPackageCodes") + List findListByOrderPackageCodes(@RequestBody List orderPackageCodes); + } diff --git a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionStockArticleClient.java b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionStockArticleClient.java index 49fa97fda..13a9c469b 100644 --- a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionStockArticleClient.java +++ b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionStockArticleClient.java @@ -33,6 +33,7 @@ import org.springframework.web.bind.annotation.RequestParam; import java.util.List; import java.util.Map; +import java.util.Set; /** * 配送在库订单 Feign接口类 @@ -219,4 +220,6 @@ public interface IDistributionStockArticleClient { @PostMapping(value = API_PREFIX + "/deleteZeroOrderByWaybillNoList",consumes = MediaType.APPLICATION_JSON_VALUE) void deleteZeroOrderByWaybillNoList(@RequestBody List waybillNoList); + @PostMapping(API_PREFIX + "/findWaybillNoByOrderIds") + List findWaybillNoByOrderIds(@RequestBody Set stockArticleIds); } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionParcelListClient.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionParcelListClient.java index a49876954..3d8b9ada3 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionParcelListClient.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionParcelListClient.java @@ -636,4 +636,9 @@ public class DistributionParcelListClient implements IDistributionParcelListClie return distributionParcelListService.findIdAndWarehouseIdListByOrderCodes(orderCodeSet); } + @Override + public List findListByOrderPackageCodes(List orderPackageCodes) { + return distributionParcelListService.findListByOrderPackageCodes(orderPackageCodes); + } + } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionStockArticleClient.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionStockArticleClient.java index 635b38b6a..83fbaaa69 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionStockArticleClient.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionStockArticleClient.java @@ -446,4 +446,9 @@ public class DistributionStockArticleClient implements IDistributionStockArticle } + @Override + public List findWaybillNoByOrderIds(Set stockArticleIds) { + return distributionParcelListService.findWaybillNoByOrderIds(stockArticleIds); + } + } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.java index 04b1ff7bf..4588f2d8c 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.java @@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.logpm.distribution.dto.DistributionParcelListDTO; import com.logpm.distribution.dto.app.StockupDTO; import com.logpm.distribution.entity.DistributionParcelListEntity; +import com.logpm.distribution.entity.DistributionStockArticleEntity; import com.logpm.distribution.excel.DistributionParcelListExcel; import com.logpm.distribution.vo.*; import org.apache.ibatis.annotations.Param; @@ -334,4 +335,7 @@ public interface DistributionParcelListMapper extends BaseMapper findIdAndWarehouseIdListByOrderCodes(@Param("orderCodeSet") Set orderCodeSet); + List findListByOrderPackageCodes(@Param("orderPackageCodes") List orderPackageCodes); + + List findWaybillNoByOrderIds(@Param("stockArticleIds") Set stockArticleIds); } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.xml b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.xml index d01490a49..96056d7b0 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.xml +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.xml @@ -2243,4 +2243,29 @@ and ldpl.is_deleted = 0 + + + + + diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionParcelListService.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionParcelListService.java index c81662043..c2d3fa8a5 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionParcelListService.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionParcelListService.java @@ -20,6 +20,7 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.metadata.IPage; import com.logpm.distribution.dto.app.StockupDTO; import com.logpm.distribution.entity.DistributionParcelListEntity; +import com.logpm.distribution.entity.DistributionStockArticleEntity; import com.logpm.distribution.excel.DistributionParcelListExcel; import com.logpm.distribution.vo.*; import org.springblade.core.mp.base.BaseService; @@ -305,4 +306,8 @@ public interface IDistributionParcelListService extends BaseService findIdAndWarehouseIdListByAdvanceIds(List advanceIds); List findIdAndWarehouseIdListByOrderCodes(Set orderCodeSet); + + List findListByOrderPackageCodes(List orderPackageCodes); + + List findWaybillNoByOrderIds(Set stockArticleIds); } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionParcelListServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionParcelListServiceImpl.java index 26cf45986..636520b12 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionParcelListServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionParcelListServiceImpl.java @@ -1567,4 +1567,14 @@ public class DistributionParcelListServiceImpl extends BaseServiceImpl findIdAndWarehouseIdListByOrderCodes(Set orderCodeSet) { return baseMapper.findIdAndWarehouseIdListByOrderCodes(orderCodeSet); } + + @Override + public List findListByOrderPackageCodes(List orderPackageCodes) { + return baseMapper.findListByOrderPackageCodes(orderPackageCodes); + } + + @Override + public List findWaybillNoByOrderIds(Set stockArticleIds) { + return baseMapper.findWaybillNoByOrderIds(stockArticleIds); + } } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.java index 8038cf6a7..9b5673a24 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.java @@ -189,4 +189,6 @@ public interface TrunklineCarsLoadScanMapper extends BaseMapper findListByLoadId(@Param("loadId") Long loadId); } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.xml b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.xml index 1724be3b5..677661a7b 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.xml +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.xml @@ -1020,4 +1020,11 @@ and scan_status = #{scanStatus} + + + diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsOrderMapper.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsOrderMapper.java index 7b67f4e03..70c92b75f 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsOrderMapper.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsOrderMapper.java @@ -71,4 +71,5 @@ public interface TrunklineCarsOrderMapper extends BaseMapper findSignZeroOrderListBySignOrderId(@Param("signOrderId") Long signOrderId); + List findListByLoadId(@Param("loadId") Long loadId); } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsOrderMapper.xml b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsOrderMapper.xml index 516d74160..59b15218e 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsOrderMapper.xml +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsOrderMapper.xml @@ -385,4 +385,10 @@ and ltco.is_customer = '1' + + diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadScanService.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadScanService.java index 7c436c60b..8ff964f5e 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadScanService.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadScanService.java @@ -185,4 +185,6 @@ public interface ITrunklineCarsLoadScanService extends BaseService findListByLoadId(Long loadId); } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsOrderService.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsOrderService.java index 6b7e7f700..9dd25a642 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsOrderService.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsOrderService.java @@ -68,4 +68,6 @@ public interface ITrunklineCarsOrderService extends BaseService findSignZeroOrderListBySignOrderId(Long signOrderId); + List findListByLoadId(Long loadId); + } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java index e9e7d9a6d..6014e2b74 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java @@ -23,7 +23,6 @@ import com.logpm.distribution.feign.IDistributionParcelListClient; import com.logpm.distribution.feign.IDistributionParcelNumberClient; import com.logpm.distribution.feign.IDistributionReservationStockarticleClient; import com.logpm.distribution.feign.IDistributionStockArticleClient; -import com.logpm.distribution.vo.UpdateOrderDTO; import com.logpm.statistics.feign.IOrderInfoClient; import com.logpm.trunkline.dto.*; import com.logpm.trunkline.entity.*; @@ -684,24 +683,46 @@ public class OpenOrderServiceImpl implements IOpenOrderService { advanceService.updateBatchById(advanceEntityList); //更新暂存单包件的运单信息 - if(CollUtil.isNotEmpty(advanceIds)){ - advanceDetailService.updateWaybillNoByAdvanceIds(advanceIds, waybillNo, waybillId); - List list = advanceDetailService.findListByAdvanceIds(advanceIds); - trunklineWaybillPackageService.saveList(list, waybillEntity); - UpdateOrderDTO updateOrderDTO = new UpdateOrderDTO(); - updateOrderDTO.setAdvanceIds(advanceIds); - updateOrderDTO.setWaybillId(waybillId); - distributionParcelListClient.updateEntityByOpenOrderByAdvanceIds(updateOrderDTO); + + List list = advanceDetailService.findListByAdvanceIds(advanceIds); + trunklineWaybillPackageService.saveList(list, waybillEntity); + + //把updateAdvanceDetailList转化成以id为key的Map + Map updateAdvanceDetailMap = list.stream() + .collect(Collectors.toMap(TrunklineAdvanceDetailVO::getId, detail -> detail)); + + List updateAdvanceDetailList = openOrderDTO.getUpdateAdvanceDetailList(); + + List orderPackageCodes = new ArrayList<>(); + String finalWaybillNo = waybillNo; + + updateAdvanceDetailList.forEach(detail -> { + Long id = detail.getId(); + TrunklineAdvanceDetailEntity trunklineAdvanceDetailEntity = updateAdvanceDetailMap.get(id); + detail.setWaybillId(waybillId); + detail.setWaybillNo(finalWaybillNo); + detail.setCostCategoryId(trunklineAdvanceDetailEntity.getCostCategoryId()); + detail.setCostCategoryName(trunklineAdvanceDetailEntity.getCostCategoryName()); + detail.setIncomeCategoryId(trunklineAdvanceDetailEntity.getIncomeCategoryId()); + detail.setIncomeCategoryName(trunklineAdvanceDetailEntity.getIncomeCategoryName()); + orderPackageCodes.add(detail.getOrderPackageCode()); + }); + + if(CollUtil.isNotEmpty(orderPackageCodes)){ + + //把orderPackageCodes每500条分为一组 + List> orderPackageCodeList = CollUtil.split(orderPackageCodes, 500); + List parcelListEntities = new ArrayList<>(); + orderPackageCodeList.forEach(orderPackageCodeList1 -> { + parcelListEntities.addAll(distributionParcelListClient.findListByOrderPackageCodes(orderPackageCodeList1)); + }); String departureWarehouseName = waybillEntity.getDepartureWarehouseName(); String destinationWarehouseName = waybillEntity.getDestinationWarehouseName(); Long consigneeId1 = waybillEntity.getConsigneeId(); BasicdataClientEntity basicdataClientEntity = basicdataClientClient.findEntityById(consigneeId1); -// List parcelListEntities = distributionParcelListClient.findIdAndWarehouseIdListByAdvanceIds(advanceIds); - List parcelListEntities = distributionParcelListClient.findIdAndWarehouseIdListByOrderCodes(orderCodeSet); Set stockArticleIds = new TreeSet<>(); - String finalWaybillNo = waybillNo; parcelListEntities.forEach(parcelListEntity -> { Long packageWarehouseId = parcelListEntity.getWarehouseId(); parcelListEntity.setWaybillId(waybillId); @@ -724,11 +745,11 @@ public class OpenOrderServiceImpl implements IOpenOrderService { distributionParcelListClient.updateList(parcelListEntities); - List updateList = new ArrayList<>(); - stockArticleIds.forEach(stockArticleId -> { - DistributionStockArticleEntity stockArticleEntity = new DistributionStockArticleEntity(); - stockArticleEntity.setId(stockArticleId); - stockArticleEntity.setWaybillNumber(finalWaybillNo); + //根据订单id获取每个订单的运单拼接数据 + + List stockArticleEntities = distributionStockArticleClient.findWaybillNoByOrderIds(stockArticleIds); + + stockArticleEntities.forEach(stockArticleEntity -> { stockArticleEntity.setMallId(consigneeId1); stockArticleEntity.setMallCode(basicdataClientEntity.getClientCode()); stockArticleEntity.setMallName(basicdataClientEntity.getClientName()); @@ -737,20 +758,20 @@ public class OpenOrderServiceImpl implements IOpenOrderService { stockArticleEntity.setConsigneeMobile(waybillEntity.getConsigneeMobile()); stockArticleEntity.setConsigneeAddress(waybillEntity.getConsigneeAddress()); stockArticleEntity.setConsigneeUnit(basicdataClientEntity.getClientName()); - updateList.add(stockArticleEntity); }); - if(CollUtil.isNotEmpty(updateList)){ - distributionStockArticleClient.updateByBatchId(updateList); + if(CollUtil.isNotEmpty(stockArticleEntities)){ + distributionStockArticleClient.updateByBatchId(stockArticleEntities); } - } - trunklineWaybillPackageService.updateWaybillStatus(waybillEntity); + } //修改暂存单明细的结算品类 - List updateAdvanceDetailList = openOrderDTO.getUpdateAdvanceDetailList(); advanceDetailService.updateBatchById(updateAdvanceDetailList); + trunklineWaybillPackageService.updateWaybillStatus(waybillEntity); + + //计算扫码入库的包件是否需要把运单和提货单挂上 openOrderAsyncService.dealwithBillladingInfo(advanceIds,warehouseId,warehouseName,waybillId,waybillNo); diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadScanServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadScanServiceImpl.java index a1667db4b..7414f48d0 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadScanServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadScanServiceImpl.java @@ -474,4 +474,9 @@ public class TrunklineCarsLoadScanServiceImpl extends BaseServiceImpl findListByLoadId(Long loadId) { + return baseMapper.findListByLoadId(loadId); + } + } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java index 84b2848a0..5d158c32d 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java @@ -1580,59 +1580,78 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl nodeNumDataVOS = trunklineCarsOrderService.findNodeDataByLoadId(loadId); - for (NodeNumDataVO nodeNumDataVO : nodeNumDataVOS) { - Long loadLineId = nodeNumDataVO.getLoadLineId(); - Integer planNum = nodeNumDataVO.getPlanNum(); - loadPlanNum = loadPlanNum + planNum; - trunklineCarsLoadLineService.updatePlanLoadingNumberByLoadLineId(planNum, loadLineId); - } - carsLoadEntity.setPlanLoadingNumber(loadPlanNum); -// updateById(carsLoadEntity); + //把nodeNumDataVOS中所有元素的planNum求和 + loadPlanNum = nodeNumDataVOS.stream().mapToInt(NodeNumDataVO::getPlanNum).sum(); - //装车 卸车数量 - Integer realLoadingNum = trunklineCarsLoadScanService.findNumByLoadId(loadId);//配载计划实际装车数量 - Integer realUnloadingNum = trunklineCarsLoadScanService.findUnloadNumByLoadId(loadId);//配载计划实际卸车数量 - Integer stockCarNum = trunklineCarsLoadScanService.findStockNumByLoadId(loadId);//配载计划在车件数 - Integer abnormalNum = trunklineCarsLoadScanService.findAbnormalNumByLoadId(loadId);//配载计划装车异常数量 -// Integer unloadAbnormalNum = trunklineCarsUnloadLogService.findAbnormalNumByLoadId(loadId);//配载计划卸车异常数量 - carsLoadEntity.setRealLoadingNumber(realLoadingNum); - carsLoadEntity.setUnloadNumber(realUnloadingNum); - carsLoadEntity.setStockNumber(stockCarNum); - carsLoadEntity.setAbnormalNum(abnormalNum); - updateById(carsLoadEntity); + //把nodeNumDataVOS转化成以loadLineId为key的Map + Map nodeNumDataVOMap = nodeNumDataVOS.stream().collect(Collectors.toMap(NodeNumDataVO::getLoadLineId, Function.identity())); + carsLoadEntity.setPlanLoadingNumber(loadPlanNum); + + //查询所有的装车明细数据 + List scanList = trunklineCarsLoadScanService.findListByLoadId(loadId); + //把scanList中warehouseId不为空的num值求和 为空则用0代替 + Integer realLoadingNum = scanList.stream().filter(scan -> !Objects.isNull(scan.getWarehouseId())).mapToInt(TrunklineCarsLoadScanEntity::getNum).sum(); + ///把scanList中scanStatus不为1的unloadNum值求和 为空则用0代替 + Integer realUnloadingNum = scanList.stream().filter(scan -> !Objects.isNull(scan.getScanStatus()) && !scan.getScanStatus().equals("1")).mapToInt(TrunklineCarsLoadScanEntity::getUnloadNum).sum(); + Integer stockCarNum = scanList.stream().filter(scan -> !Objects.isNull(scan.getScanStatus()) && scan.getScanStatus().equals("1")).mapToInt(TrunklineCarsLoadScanEntity::getUnloadNum).sum(); + + updateCarsLoadEntity.setPlanLoadingNumber(loadPlanNum); + updateCarsLoadEntity.setRealLoadingNumber(realLoadingNum); + updateCarsLoadEntity.setUnloadNumber(realUnloadingNum); + updateCarsLoadEntity.setStockNumber(stockCarNum); + updateById(updateCarsLoadEntity); + + //节点数据 List carsLoadLineList = trunklineCarsLoadLineService.findListByLoadId(loadId); - for (TrunklineCarsLoadLineEntity carsLoadLineEntity : carsLoadLineList) { + List updateLoadLineList = new ArrayList<>(); + carsLoadLineList.forEach(carsLoadLineEntity -> { + Long loadLingId = carsLoadLineEntity.getId(); Long nodeId = carsLoadLineEntity.getNodeId(); - Integer lineLoadingNum = trunklineCarsLoadScanService.findNumByLoadIdAndNodeId(loadId, nodeId);//节点实际装车数量 - Integer lineUnloadingNum = trunklineCarsLoadScanService.findUnloadNumByLoadIdAndNodeId(loadId, nodeId);//节点实际卸车数量 - Integer lineAbnormalNum = trunklineCarsLoadScanService.findAbnormalNumByLoadIdAndNodeId(loadId, nodeId);//节点实际装车异常数量 -// Integer lineUnloadingAbnormalNum = trunklineCarsUnloadLogService.findAbnormalNumByLoadIdAndNodeId(loadId,nodeId);//节点实际卸车异常数量 - carsLoadLineEntity.setRealLoadingNumber(lineLoadingNum); - carsLoadLineEntity.setUnloadNumber(lineUnloadingNum); - carsLoadLineEntity.setAbnormalNum(lineAbnormalNum); - trunklineCarsLoadLineService.updateById(carsLoadLineEntity); + NodeNumDataVO nodeNumDataVO = nodeNumDataVOMap.get(loadLingId); + Integer planNum = nodeNumDataVO.getPlanNum(); + Integer lineRealLoadingNum = scanList.stream().filter(scan -> NumberUtil.equals(nodeId,scan.getWarehouseId())).mapToInt(TrunklineCarsLoadScanEntity::getNum).sum(); + Integer lineRealUnloadingNum = scanList.stream().filter(scan -> !Objects.isNull(scan.getScanStatus()) && !scan.getScanStatus().equals("1") && NumberUtil.equals(nodeId,scan.getWarehouseId())).mapToInt(TrunklineCarsLoadScanEntity::getUnloadNum).sum(); + TrunklineCarsLoadLineEntity updateEntity = new TrunklineCarsLoadLineEntity(); + updateEntity.setPlanLoadingNumber(planNum); + updateEntity.setRealLoadingNumber(lineRealLoadingNum); + updateEntity.setUnloadNumber(lineRealUnloadingNum); + updateLoadLineList.add(updateEntity); + }); - //查询订单上 - List carsOrderEntities = trunklineCarsOrderService.findListByLoadIdAndNodeId(loadId, nodeId); - for (TrunklineCarsOrderEntity carsOrderEntity : carsOrderEntities) { - String orderCode = carsOrderEntity.getOrderCode(); - String waybillNo = carsOrderEntity.getWaybillNo(); - Integer orderLoadingNum = trunklineCarsLoadScanService.findNumByLoadIdAndNodeIdAndOrderCodeAndWaybillNo(loadId, nodeId, orderCode, waybillNo);//节点实际装车数量 - Integer orderUnloadingNum = trunklineCarsLoadScanService.findUnloadNumByLoadIdAndNodeIdAndOrderCodeAndWaybillNo(loadId, nodeId, orderCode, waybillNo);//节点实际卸车数量 - Integer orderSignNum = trunklineCarsLoadScanService.findSignNumByLoadIdAndNodeIdAndOrderCodeAndeWaybillNo(loadId, nodeId, orderCode, waybillNo); -// Integer orderLoadingAbnormalNum = trunklineCarsLoadScanService.findAbnormalNumByLoadIdAndNodeId(loadId,nodeId,orderCode,waybillNo);//节点实际装车异常数量 -// Integer orderUnloadingAbnormalNum = trunklineCarsUnloadLogService.findAbnormalNumByLoadIdAndNodeId(loadId,nodeId,orderCode,waybillNo);//节点实际卸车异常数量 - carsOrderEntity.setRealNum(orderLoadingNum); - carsOrderEntity.setUnloadNum(orderUnloadingNum); - carsOrderEntity.setSignNum(orderSignNum); - trunklineCarsOrderService.updateById(carsOrderEntity); - } + if(CollUtil.isNotEmpty(updateLoadLineList)){ + trunklineCarsLoadLineService.updateBatchById(updateLoadLineList); + } + + //订单数据 + List carsOrderList = trunklineCarsOrderService.findListByLoadId(loadId); + List updateOrderList = new ArrayList<>(); + carsOrderList.forEach(carsOrderEntity -> { + Long carsOrderId = carsOrderEntity.getId(); + Long nodeId = carsOrderEntity.getNodeId(); + String orderCode = carsOrderEntity.getOrderCode(); + String waybillNo = carsOrderEntity.getWaybillNo(); + Integer carsOrderRealLoadingNum = scanList.stream().filter(scan -> NumberUtil.equals(nodeId,scan.getWarehouseId()) && StringUtil.equals(orderCode,scan.getOrderCode()) && StringUtil.equals(waybillNo,scan.getWaybillNo())).mapToInt(TrunklineCarsLoadScanEntity::getNum).sum(); + Integer carsOrderRealUnloadingNum = scanList.stream().filter(scan -> !Objects.isNull(scan.getScanStatus()) && !scan.getScanStatus().equals("1") && NumberUtil.equals(nodeId,scan.getWarehouseId()) && StringUtil.equals(orderCode,scan.getOrderCode()) && StringUtil.equals(waybillNo,scan.getWaybillNo())).mapToInt(TrunklineCarsLoadScanEntity::getUnloadNum).sum(); + Integer carsOrderRealSignNum = scanList.stream().filter(scan -> !Objects.isNull(scan.getScanStatus()) && scan.getScanStatus().equals("3") && NumberUtil.equals(nodeId,scan.getWarehouseId()) && StringUtil.equals(orderCode,scan.getOrderCode()) && StringUtil.equals(waybillNo,scan.getWaybillNo())).mapToInt(TrunklineCarsLoadScanEntity::getUnloadNum).sum(); + TrunklineCarsOrderEntity updateCarsOrderEntity = new TrunklineCarsOrderEntity(); + updateCarsOrderEntity.setId(carsOrderId); + updateCarsOrderEntity.setRealNum(carsOrderRealLoadingNum); + updateCarsOrderEntity.setUnloadNum(carsOrderRealUnloadingNum); + updateCarsOrderEntity.setSignNum(carsOrderRealSignNum); + updateOrderList.add(updateCarsOrderEntity); + }); + + if(CollUtil.isNotEmpty(updateOrderList)){ + trunklineCarsOrderService.updateBatchById(updateOrderList); } + log.info("#########updateNumByLoadId: 更新配载计划数量 完成"); } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsOrderEntityServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsOrderEntityServiceImpl.java index ddb8887b8..cbf3cb2bb 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsOrderEntityServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsOrderEntityServiceImpl.java @@ -12,6 +12,7 @@ import lombok.extern.slf4j.Slf4j; import org.springblade.core.mp.base.BaseServiceImpl; import org.springframework.stereotype.Service; +import java.util.Collections; import java.util.List; @Slf4j @@ -163,4 +164,9 @@ public class TrunklineCarsOrderEntityServiceImpl extends BaseServiceImpl findListByLoadId(Long loadId) { + return baseMapper.findListByLoadId(loadId); + } + }