|
|
|
@ -68,7 +68,9 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
import java.math.RoundingMode; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.function.Function; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
@Slf4j |
|
|
|
@ -2908,16 +2910,117 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
|
|
|
|
|
|
|
|
|
|
List<CarsLoadOrderInfoVO> carsLoadOrderInfoList = trunklineCarsOrderService.findCarsLoadOrderInfoList(loadId, waybillNo); |
|
|
|
|
|
|
|
|
|
List<CarsLoadOrderInfoVO> carsLoadOrderInfoListPlan = trunklineCarsOrderService.findCarsLoadOrderInfoListPlan(loadId, waybillNo); |
|
|
|
|
// List<CarsLoadOrderInfoVO> carsLoadOrderInfoListPlan = trunklineCarsOrderService.findCarsLoadOrderInfoListPlan(loadId, waybillNo);
|
|
|
|
|
|
|
|
|
|
carsLoadOrderInfoList.forEach(carsLoadOrderInfoVO -> { |
|
|
|
|
carsLoadOrderInfoVO.setUnloadIncome(carsLoadOrderInfoVO.getUnloadIncome().setScale(2, BigDecimal.ROUND_HALF_UP)); |
|
|
|
|
carsLoadOrderInfoVO.setOrderFreight(carsLoadOrderInfoVO.getOrderFreight().setScale(2, BigDecimal.ROUND_HALF_UP)); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
carsLoadWaybillInfoVO.setCarsLoadOrderInfoList(carsLoadOrderInfoList); |
|
|
|
|
carsLoadWaybillInfoVO.setCarsLoadOrderInfoListPlan(carsLoadOrderInfoListPlan); |
|
|
|
|
// carsLoadWaybillInfoVO.setCarsLoadOrderInfoListPlan(carsLoadOrderInfoListPlan);
|
|
|
|
|
|
|
|
|
|
TrunklineCostShareRecordEntity costShareRecordEntity = trunklineCostShareRecordService.findTotalUnloadNumByLoadAndWaybillNo(loadId, waybillNo); |
|
|
|
|
carsLoadWaybillInfoVO.setCostPiece(costShareRecordEntity.getCostPiece()); |
|
|
|
|
carsLoadWaybillInfoVO.setCostZhang(costShareRecordEntity.getCostZhang()); |
|
|
|
|
carsLoadWaybillInfoVO.setCostNum(costShareRecordEntity.getNum()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//查询异常的数据
|
|
|
|
|
List<CarsLoadScanAbnormalVO> carsLoadScanAbnormalList = trunklineCarsLoadScanService.findAbnormalData(loadId); |
|
|
|
|
if(!carsLoadScanAbnormalList.isEmpty()){ |
|
|
|
|
//把carsLoadScanAbnormalList过滤waybillNo等于--的数据后把waybillNo放入一个Set
|
|
|
|
|
Set<String> waybillNoSet = carsLoadScanAbnormalList.stream().filter(carsLoadScanAbnormalVO -> !"--".equals(carsLoadScanAbnormalVO.getWaybillNo())) |
|
|
|
|
.map(CarsLoadScanAbnormalVO::getWaybillNo) |
|
|
|
|
.collect(Collectors.toSet()); |
|
|
|
|
|
|
|
|
|
List<WarehouseWaybillEntity> waybillEntityList = warehouseWaybillClient.findWaybillBilllByWaybillNos(new ArrayList<>(waybillNoSet)); |
|
|
|
|
//把waybillEntityList转化成以waybillNo为key的map
|
|
|
|
|
Map<String, WarehouseWaybillEntity> waybillEntityMap = waybillEntityList.stream().collect(Collectors.toMap(WarehouseWaybillEntity::getWaybillNo, Function.identity())); |
|
|
|
|
|
|
|
|
|
//把carsLoadScanAbnormalList通过waybillNo分组
|
|
|
|
|
Map<String, List<CarsLoadScanAbnormalVO>> carsLoadScanAbnormalMap = carsLoadScanAbnormalList.stream().collect(Collectors.groupingBy(CarsLoadScanAbnormalVO::getWaybillNo)); |
|
|
|
|
carsLoadScanAbnormalMap.keySet().forEach(waybillNo -> { |
|
|
|
|
List<CarsLoadScanAbnormalVO> carsLoadScanAbnormalVOS = carsLoadScanAbnormalMap.get(waybillNo); |
|
|
|
|
WarehouseWaybillEntity warehouseWaybillEntity = waybillEntityMap.get(waybillNo); |
|
|
|
|
BigDecimal freightPrice = BigDecimal.ZERO; |
|
|
|
|
CarsLoadWaybillInfoVO carsLoadWaybillInfoVO = new CarsLoadWaybillInfoVO(); |
|
|
|
|
carsLoadWaybillInfoVO.setWaybillNo(waybillNo); |
|
|
|
|
if(!"--".equals(waybillNo)){ |
|
|
|
|
if(!Objects.isNull(warehouseWaybillEntity)){ |
|
|
|
|
carsLoadWaybillInfoVO.setCreateTime(warehouseWaybillEntity.getCreateTime()); |
|
|
|
|
carsLoadWaybillInfoVO.setDestination(warehouseWaybillEntity.getDestination()); |
|
|
|
|
carsLoadWaybillInfoVO.setDestinationWarehouseName(warehouseWaybillEntity.getDestinationWarehouseName()); |
|
|
|
|
carsLoadWaybillInfoVO.setShipper(warehouseWaybillEntity.getShipper()); |
|
|
|
|
carsLoadWaybillInfoVO.setShipperName(warehouseWaybillEntity.getShipperName()); |
|
|
|
|
carsLoadWaybillInfoVO.setConsignee(warehouseWaybillEntity.getConsignee()); |
|
|
|
|
carsLoadWaybillInfoVO.setConsigneeName(warehouseWaybillEntity.getConsigneeName()); |
|
|
|
|
carsLoadWaybillInfoVO.setWaybillNum(warehouseWaybillEntity.getTotalCount()); |
|
|
|
|
carsLoadWaybillInfoVO.setWaybillType(warehouseWaybillEntity.getWaybillType()); |
|
|
|
|
carsLoadWaybillInfoVO.setWaybillId(warehouseWaybillEntity.getId()); |
|
|
|
|
carsLoadWaybillInfoVO.setRemark(warehouseWaybillEntity.getRemark()); |
|
|
|
|
BigDecimal totalFreight = warehouseWaybillEntity.getTotalFreight(); |
|
|
|
|
BigDecimal deliveryFee = warehouseWaybillEntity.getDeliveryFee(); |
|
|
|
|
BigDecimal pickupFee = warehouseWaybillEntity.getPickupFee(); |
|
|
|
|
BigDecimal warehouseManagementFee = warehouseWaybillEntity.getWarehouseManagementFee(); |
|
|
|
|
BigDecimal storageFee = warehouseWaybillEntity.getStorageFee(); |
|
|
|
|
BigDecimal handlingFee = warehouseWaybillEntity.getHandlingFee(); |
|
|
|
|
BigDecimal otherFee = warehouseWaybillEntity.getOtherFee(); |
|
|
|
|
BigDecimal insuranceFee = warehouseWaybillEntity.getInsuranceFee(); |
|
|
|
|
carsLoadWaybillInfoVO.setTotalFreight(totalFreight); |
|
|
|
|
carsLoadWaybillInfoVO.setDeliveryFee(deliveryFee); |
|
|
|
|
carsLoadWaybillInfoVO.setPickupFee(pickupFee); |
|
|
|
|
carsLoadWaybillInfoVO.setWarehouseManagementFee(warehouseManagementFee); |
|
|
|
|
carsLoadWaybillInfoVO.setStorageFee(storageFee); |
|
|
|
|
carsLoadWaybillInfoVO.setHandlingFee(handlingFee); |
|
|
|
|
carsLoadWaybillInfoVO.setOtherFee(otherFee); |
|
|
|
|
carsLoadWaybillInfoVO.setInsuranceFee(insuranceFee); |
|
|
|
|
carsLoadWaybillInfoVO.setTotalFee(totalFreight.add(deliveryFee).add(pickupFee).add(warehouseManagementFee).add(storageFee).add(handlingFee).add(otherFee).add(insuranceFee)); |
|
|
|
|
TrunklineCostShareRecordEntity costShareRecordEntity = trunklineCostShareRecordService.findTotalUnloadNumByLoadAndWaybillNo(loadId, waybillNo); |
|
|
|
|
carsLoadWaybillInfoVO.setCostPiece(costShareRecordEntity.getCostPiece()); |
|
|
|
|
carsLoadWaybillInfoVO.setCostZhang(costShareRecordEntity.getCostZhang()); |
|
|
|
|
carsLoadWaybillInfoVO.setCostNum(costShareRecordEntity.getNum()); |
|
|
|
|
freightPrice = totalFreight.divide(BigDecimal.valueOf(warehouseWaybillEntity.getTotalCount()),4, RoundingMode.HALF_UP); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<CarsLoadOrderInfoVO> carsLoadOrderInfoList = new ArrayList<>(); |
|
|
|
|
BigDecimal finalFreightPrice = freightPrice; |
|
|
|
|
carsLoadScanAbnormalVOS.forEach(carsLoadScanAbnormalVO -> { |
|
|
|
|
CarsLoadOrderInfoVO carsLoadOrderInfoVO = new CarsLoadOrderInfoVO(); |
|
|
|
|
carsLoadOrderInfoVO.setOrderCode(carsLoadScanAbnormalVO.getOrderCode()); |
|
|
|
|
carsLoadOrderInfoVO.setLoadingNum(carsLoadScanAbnormalVO.getLoadingNum()); |
|
|
|
|
carsLoadOrderInfoVO.setUnloadNum(carsLoadScanAbnormalVO.getUnloadNum()); |
|
|
|
|
BigDecimal unloadIncome = finalFreightPrice.multiply(BigDecimal.valueOf(carsLoadScanAbnormalVO.getUnloadNum())); |
|
|
|
|
carsLoadOrderInfoVO.setUnloadIncome(unloadIncome.setScale(2)); |
|
|
|
|
carsLoadOrderInfoVO.setPlanNum(0); |
|
|
|
|
String orderCode = carsLoadScanAbnormalVO.getOrderCode(); |
|
|
|
|
if("--".equals(waybillNo) || "--".equals(orderCode)){ |
|
|
|
|
carsLoadOrderInfoVO.setOrderNum(0); |
|
|
|
|
carsLoadOrderInfoVO.setOrderFreight(BigDecimal.ZERO.setScale(2)); |
|
|
|
|
}else{ |
|
|
|
|
Integer num = trunklineWaybillOrderService.findTotalNumByWaybillAndOrderCode(waybillNo, orderCode); |
|
|
|
|
carsLoadOrderInfoVO.setOrderNum(num); |
|
|
|
|
carsLoadOrderInfoVO.setOrderFreight(finalFreightPrice.multiply(BigDecimal.valueOf(num)).setScale(2)); |
|
|
|
|
} |
|
|
|
|
TrunklineCostShareRecordEntity orderCostShareRecordEntity = trunklineCostShareRecordService.findTotalUnloadNumByLoadAndWaybillNoAndOrderCode(loadId,waybillNo,orderCode); |
|
|
|
|
carsLoadOrderInfoVO.setCostZhang(orderCostShareRecordEntity.getCostZhang()); |
|
|
|
|
carsLoadOrderInfoVO.setCostPiece(orderCostShareRecordEntity.getCostPiece()); |
|
|
|
|
// carsLoadOrderInfoVO.setWeight(BigDecimal.ZERO);
|
|
|
|
|
// carsLoadOrderInfoVO.setVolume(BigDecimal.ZERO);
|
|
|
|
|
carsLoadOrderInfoList.add(carsLoadOrderInfoVO); |
|
|
|
|
}); |
|
|
|
|
carsLoadWaybillInfoVO.setCarsLoadOrderInfoList(carsLoadOrderInfoList); |
|
|
|
|
|
|
|
|
|
carsLoadWaybillInfoList.add(carsLoadWaybillInfoVO); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//对元素中的waybillNo进行倒序排序
|
|
|
|
|
carsLoadWaybillInfoList.sort(Comparator.comparing(CarsLoadWaybillInfoVO::getWaybillNo).reversed()); |
|
|
|
|
|
|
|
|
|
trunklineCarsLoadVO.setCarsLoadWaybillInfoList(carsLoadWaybillInfoList); |
|
|
|
|
|
|
|
|
|
return R.data(trunklineCarsLoadVO); |
|
|
|
|