|
|
|
@ -1580,59 +1580,78 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
|
|
|
|
|
log.warn("###########updateNumByLoadId: 配载计划数据不存在 loadId={}", loadId); |
|
|
|
|
throw new CustomerException(400, "配载计划数据不存在"); |
|
|
|
|
} |
|
|
|
|
TrunklineCarsLoadEntity updateCarsLoadEntity = new TrunklineCarsLoadEntity(); |
|
|
|
|
updateCarsLoadEntity.setId(loadId); |
|
|
|
|
|
|
|
|
|
//计划件数
|
|
|
|
|
//计划件数
|
|
|
|
|
Integer loadPlanNum = 0; |
|
|
|
|
List<NodeNumDataVO> 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<Long, NodeNumDataVO> nodeNumDataVOMap = nodeNumDataVOS.stream().collect(Collectors.toMap(NodeNumDataVO::getLoadLineId, Function.identity())); |
|
|
|
|
|
|
|
|
|
carsLoadEntity.setPlanLoadingNumber(loadPlanNum); |
|
|
|
|
|
|
|
|
|
//查询所有的装车明细数据
|
|
|
|
|
List<TrunklineCarsLoadScanEntity> 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<TrunklineCarsLoadLineEntity> carsLoadLineList = trunklineCarsLoadLineService.findListByLoadId(loadId); |
|
|
|
|
for (TrunklineCarsLoadLineEntity carsLoadLineEntity : carsLoadLineList) { |
|
|
|
|
List<TrunklineCarsLoadLineEntity> 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<TrunklineCarsOrderEntity> 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<TrunklineCarsOrderEntity> carsOrderList = trunklineCarsOrderService.findListByLoadId(loadId); |
|
|
|
|
List<TrunklineCarsOrderEntity> 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: 更新配载计划数量 完成"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|