@ -3,8 +3,8 @@ package com.logpm.statistics.listener.mq;
import cn.hutool.json.JSONArray ;
import cn.hutool.json.JSONObject ;
import cn.hutool.json.JSONUtil ;
import com.logpm.statistics.entity.StatisticsPackageInfoEntity ;
import com.logpm.statistics.service.IStatisticsPackageInfoService ;
import com.logpm.statistics.entity.* ;
import com.logpm.statistics.service.* ;
import lombok.AllArgsConstructor ;
import lombok.extern.slf4j.Slf4j ;
import org.springblade.common.constant.broadcast.FanoutConstants ;
@ -18,6 +18,8 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList ;
import java.util.List ;
import java.util.Map ;
import java.util.Objects ;
import java.util.stream.Collectors ;
@Slf4j
@ -25,7 +27,11 @@ import java.util.stream.Collectors;
@AllArgsConstructor
public class WaybillFanoutListener {
private final IStatisticsPackageInfoService statisticsPackageInfoService ;
private final IStatisticsTrunklinePackageService statisticsTrunklinePackageService ;
private final IStatisticsWarehousePackageService statisticsWarehousePackageService ;
private final IStatisticsDistributionPackageService statisticsDistributionPackageService ;
private final IStatisticsOrderInfoService statisticsOrderInfoService ;
private final IStatisticsWaybillInfoService statisticsWaybillInfoService ;
@RabbitListener ( bindings = @QueueBinding (
value = @Queue ( name = FanoutConstants . trunkline . OPENWAYBILL . QUEUE . STATISTICSDATA_CREATEPACKAGEINFO ) ,
@ -34,113 +40,216 @@ public class WaybillFanoutListener {
@Transactional ( rollbackFor = Exception . class )
public void createPackageInfo ( String msg ) {
// if(StringUtil.isBlank(msg)){
// log.warn("############createPackageInfo: 接收参数为空 msg={}",msg);
//
// }
JSONObject jsonObject = JSONUtil . parseObj ( msg ) ;
Long warehouseId = jsonObject . getLong ( "warehouseId" ) ;
String warehouseName = jsonObject . getStr ( "warehouseName" ) ;
Long waybillId = jsonObject . getLong ( "waybillId" ) ;
String waybillNo = jsonObject . getStr ( "waybillNo" ) ;
String typeService = jsonObject . getStr ( "typeService" ) ; //服务类型
List < StatisticsTrunklinePackageEntity > statisticsTrunklinePackageEntities = new ArrayList < > ( ) ;
List < StatisticsWarehousePackageEntity > statisticsWarehousePackageEntities = new ArrayList < > ( ) ;
List < StatisticsDistributionPackageEntity > statisticsDistributionPackageEntities = new ArrayList < > ( ) ;
List < StatisticsPackageInfoEntity > ls = new ArrayList < > ( ) ;
JSONArray orderPackageCodes = jsonObject . getJSONArray ( "orderPackageCodes" ) ;
for ( int i = 0 ; i < orderPackageCodes . size ( ) ; i + + ) {
JSONObject json = orderPackageCodes . getJSONObject ( i ) ;
StatisticsPackageInfoEntity statisticsPackageInfoEntity = new StatisticsPackageInfoEntity ( ) ;
statisticsPackageInfoEntity . setWarehouseId ( warehouseId ) ;
statisticsPackageInfoEntity . setWarehouseName ( warehouseName ) ;
statisticsPackageInfoEntity . setTypeService ( json . getStr ( "typeService" ) ) ;
statisticsPackageInfoEntity . setWaybillId ( waybillId ) ;
statisticsPackageInfoEntity . setWaybillNo ( waybillNo ) ;
//干线
StatisticsTrunklinePackageEntity statisticsTrunklinePackageEntity = new StatisticsTrunklinePackageEntity ( ) ;
statisticsTrunklinePackageEntity . setWarehouseId ( warehouseId ) ;
statisticsTrunklinePackageEntity . setWarehouseName ( warehouseName ) ;
statisticsTrunklinePackageEntity . setTypeService ( typeService ) ;
statisticsTrunklinePackageEntity . setWaybillId ( waybillId ) ;
statisticsTrunklinePackageEntity . setWaybillNo ( waybillNo ) ;
Integer waybillType = json . getInt ( "waybillType" ) ;
if ( waybillType . equals ( 1 ) ) {
statisticsPackageInfoEntity . setGoodsType ( 1 ) ;
statisticsTrunklinePackageEntity . setGoodsType ( 1 ) ;
} else if ( waybillType . equals ( 2 ) ) {
statisticsTrunklinePackageEntity . setGoodsType ( 2 ) ;
} else {
statisticsTrunklinePackageEntity . setGoodsType ( 3 ) ;
}
statisticsTrunklinePackageEntity . setOrderCode ( json . getStr ( "orderCode" ) ) ;
statisticsTrunklinePackageEntity . setOrderPackageCode ( json . getStr ( "orderPackageCode" ) ) ;
statisticsTrunklinePackageEntity . setProductName ( json . getStr ( "productName" ) ) ;
statisticsTrunklinePackageEntity . setTotalNum ( json . getInt ( "totalNum" ) ) ;
statisticsTrunklinePackageEntity . setTotalWeight ( json . getBigDecimal ( "totalWeight" ) ) ;
statisticsTrunklinePackageEntity . setTotalVolume ( json . getBigDecimal ( "totalVolume" ) ) ;
statisticsTrunklinePackageEntity . setOpenPrice ( json . getBigDecimal ( "openPrice" ) ) ;
statisticsTrunklinePackageEntity . setTotalPrice ( json . getBigDecimal ( "openPrice" ) ) ;
statisticsTrunklinePackageEntity . setPickupFee ( json . getBigDecimal ( "pickupFee" ) ) ;
statisticsTrunklinePackageEntity . setRealPickupFee ( json . getBigDecimal ( "pickupFee" ) ) ;
statisticsTrunklinePackageEntity . setFreightFee ( json . getBigDecimal ( "freightFee" ) ) ;
statisticsTrunklinePackageEntity . setRealFreightFee ( json . getBigDecimal ( "freightFee" ) ) ;
statisticsTrunklinePackageEntity . setInstallFee ( json . getBigDecimal ( "installFee" ) ) ;
statisticsTrunklinePackageEntity . setRealInstallFee ( json . getBigDecimal ( "installFee" ) ) ;
statisticsTrunklinePackageEntity . setQuotationFee ( json . getBigDecimal ( "quotationFee" ) ) ;
statisticsTrunklinePackageEntity . setRealQuotationFee ( json . getBigDecimal ( "quotationFee" ) ) ;
statisticsTrunklinePackageEntity . setClaimingValue ( json . getBigDecimal ( "claimingValue" ) ) ;
statisticsTrunklinePackageEntity . setRealClaimingValue ( json . getBigDecimal ( "claimingValue" ) ) ;
statisticsTrunklinePackageEntity . setOtherFee ( json . getBigDecimal ( "otherFee" ) ) ;
statisticsTrunklinePackageEntity . setRealOtherFee ( json . getBigDecimal ( "otherFee" ) ) ;
statisticsTrunklinePackageEntity . setReturnFee ( json . getBigDecimal ( "returnFee" ) ) ;
statisticsTrunklinePackageEntity . setRealReturnFee ( json . getBigDecimal ( "returnFee" ) ) ;
statisticsTrunklinePackageEntity . setThirdOprationFee ( json . getBigDecimal ( "thirdOprationFee" ) ) ;
statisticsTrunklinePackageEntity . setRealThirdOprationFee ( json . getBigDecimal ( "thirdOprationFee" ) ) ;
statisticsTrunklinePackageEntity . setXPay ( json . getBigDecimal ( "xPay" ) ) ;
statisticsTrunklinePackageEntity . setRealXPay ( json . getBigDecimal ( "xPay" ) ) ;
statisticsTrunklinePackageEntity . setDPay ( json . getBigDecimal ( "dPay" ) ) ;
statisticsTrunklinePackageEntity . setRealDPay ( json . getBigDecimal ( "dPay" ) ) ;
statisticsTrunklinePackageEntity . setHPay ( json . getBigDecimal ( "hPay" ) ) ;
statisticsTrunklinePackageEntity . setRealHPay ( json . getBigDecimal ( "hPay" ) ) ;
statisticsTrunklinePackageEntity . setYPay ( json . getBigDecimal ( "yPay" ) ) ;
statisticsTrunklinePackageEntity . setRealYPay ( json . getBigDecimal ( "yPay" ) ) ;
statisticsTrunklinePackageEntities . add ( statisticsTrunklinePackageEntity ) ;
//仓库
StatisticsWarehousePackageEntity statisticsWarehousePackageEntity = new StatisticsWarehousePackageEntity ( ) ;
statisticsWarehousePackageEntity . setWarehouseId ( warehouseId ) ;
statisticsWarehousePackageEntity . setWarehouseName ( warehouseName ) ;
statisticsWarehousePackageEntity . setTypeService ( typeService ) ;
statisticsWarehousePackageEntity . setWaybillId ( waybillId ) ;
statisticsWarehousePackageEntity . setWaybillNo ( waybillNo ) ;
if ( waybillType . equals ( 1 ) ) {
statisticsWarehousePackageEntity . setGoodsType ( 1 ) ;
} else if ( waybillType . equals ( 2 ) ) {
statisticsWarehousePackageEntity . setGoodsType ( 2 ) ;
} else {
statisticsWarehousePackageEntity . setGoodsType ( 3 ) ;
}
statisticsWarehousePackageEntity . setOrderCode ( json . getStr ( "orderCode" ) ) ;
statisticsWarehousePackageEntity . setOrderPackageCode ( json . getStr ( "orderPackageCode" ) ) ;
statisticsWarehousePackageEntity . setProductName ( json . getStr ( "productName" ) ) ;
statisticsWarehousePackageEntity . setTotalNum ( json . getInt ( "totalNum" ) ) ;
statisticsWarehousePackageEntity . setTotalWeight ( json . getBigDecimal ( "totalWeight" ) ) ;
statisticsWarehousePackageEntity . setTotalVolume ( json . getBigDecimal ( "totalVolume" ) ) ;
statisticsWarehousePackageEntity . setWarehouseServiceFee ( json . getBigDecimal ( "warehouseServiceFee" ) ) ;
statisticsWarehousePackageEntity . setRealWarehouseServiceFee ( json . getBigDecimal ( "warehouseServiceFee" ) ) ;
statisticsWarehousePackageEntity . setWarehouseFee ( json . getBigDecimal ( "warehouseFee" ) ) ;
statisticsWarehousePackageEntity . setRealWarehouseFee ( json . getBigDecimal ( "warehouseFee" ) ) ;
statisticsWarehousePackageEntity . setWarehouseManageFee ( json . getBigDecimal ( "warehouseManageFee" ) ) ;
statisticsWarehousePackageEntity . setRealWarehouseManageFee ( json . getBigDecimal ( "warehouseManageFee" ) ) ;
statisticsWarehousePackageEntity . setWarehouseSortingFee ( json . getBigDecimal ( "warehouseSortingFee" ) ) ;
statisticsWarehousePackageEntity . setRealWarehouseSortingFee ( json . getBigDecimal ( "warehouseSortingFee" ) ) ;
statisticsWarehousePackageEntity . setWarehouseOperatingFee ( json . getBigDecimal ( "warehouseOperatingFee" ) ) ;
statisticsWarehousePackageEntity . setRealWarehouseOperatingFee ( json . getBigDecimal ( "warehouseOperatingFee" ) ) ;
statisticsWarehousePackageEntities . add ( statisticsWarehousePackageEntity ) ;
//配送
StatisticsDistributionPackageEntity statisticsDistributionPackageEntity = new StatisticsDistributionPackageEntity ( ) ;
statisticsDistributionPackageEntity . setWarehouseId ( warehouseId ) ;
statisticsDistributionPackageEntity . setWarehouseName ( warehouseName ) ;
statisticsDistributionPackageEntity . setTypeService ( typeService ) ;
statisticsDistributionPackageEntity . setWaybillId ( waybillId ) ;
statisticsDistributionPackageEntity . setWaybillNo ( waybillNo ) ;
if ( waybillType . equals ( 1 ) ) {
statisticsDistributionPackageEntity . setGoodsType ( 1 ) ;
} else if ( waybillType . equals ( 2 ) ) {
statisticsPackageInfoEntity . setGoodsType ( 2 ) ;
statisticsDistribution PackageEntity . setGoodsType ( 2 ) ;
} else {
statisticsPackageInfoEntity . setGoodsType ( 3 ) ;
statisticsDistribution PackageEntity . setGoodsType ( 3 ) ;
}
statisticsPackageInfoEntity . setOrderCode ( json . getStr ( "orderCode" ) ) ;
statisticsPackageInfoEntity . setOrderPackageCode ( json . getStr ( "orderPackageCode" ) ) ;
statisticsPackageInfoEntity . setProductName ( json . getStr ( "productName" ) ) ;
statisticsPackageInfoEntity . setTotalNum ( json . getInt ( "totalNum" ) ) ;
statisticsPackageInfoEntity . setTotalWeight ( json . getBigDecimal ( "totalWeight" ) ) ;
statisticsPackageInfoEntity . setTotalVolume ( json . getBigDecimal ( "totalVolume" ) ) ;
statisticsPackageInfoEntity . setOpenPrice ( json . getBigDecimal ( "openPrice" ) ) ;
statisticsPackageInfoEntity . setTotalPrice ( json . getBigDecimal ( "openPrice" ) ) ;
statisticsPackageInfoEntity . setPickupFee ( json . getBigDecimal ( "pickupFee" ) ) ;
statisticsPackageInfoEntity . setRealPickupFee ( json . getBigDecimal ( "pickupFee" ) ) ;
statisticsPackageInfoEntity . setFreightFee ( json . getBigDecimal ( "freightFee" ) ) ;
statisticsPackageInfoEntity . setRealFreightFee ( json . getBigDecimal ( "freightFee" ) ) ;
statisticsPackageInfoEntity . setWarehouseServiceFee ( json . getBigDecimal ( "warehouseServiceFee" ) ) ;
statisticsPackageInfoEntity . setRealWarehouseServiceFee ( json . getBigDecimal ( "warehouseServiceFee" ) ) ;
statisticsPackageInfoEntity . setWarehouseFee ( json . getBigDecimal ( "warehouseFee" ) ) ;
statisticsPackageInfoEntity . setRealWarehouseFee ( json . getBigDecimal ( "warehouseFee" ) ) ;
statisticsPackageInfoEntity . setWarehouseManageFee ( json . getBigDecimal ( "warehouseManageFee" ) ) ;
statisticsPackageInfoEntity . setRealWarehouseManageFee ( json . getBigDecimal ( "warehouseManageFee" ) ) ;
statisticsPackageInfoEntity . setWarehouseSortingFee ( json . getBigDecimal ( "warehouseSortingFee" ) ) ;
statisticsPackageInfoEntity . setRealWarehouseSortingFee ( json . getBigDecimal ( "warehouseSortingFee" ) ) ;
statisticsPackageInfoEntity . setWarehouseOperatingFee ( json . getBigDecimal ( "warehouseOperatingFee" ) ) ;
statisticsPackageInfoEntity . setRealWarehouseOperatingFee ( json . getBigDecimal ( "warehouseOperatingFee" ) ) ;
statisticsPackageInfoEntity . setDeliveryServiceFee ( json . getBigDecimal ( "deliveryServiceFee" ) ) ;
statisticsPackageInfoEntity . setRealDeliveryServiceFee ( json . getBigDecimal ( "deliveryServiceFee" ) ) ;
statisticsPackageInfoEntity . setDeliveryFee ( json . getBigDecimal ( "deliveryFee" ) ) ;
statisticsPackageInfoEntity . setRealDeliveryFee ( json . getBigDecimal ( "deliveryFee" ) ) ;
statisticsPackageInfoEntity . setDeliveryLoadingFee ( json . getBigDecimal ( "deliveryLoadingFee" ) ) ;
statisticsPackageInfoEntity . setRealDeliveryLoadingFee ( json . getBigDecimal ( "deliveryLoadingFee" ) ) ;
statisticsPackageInfoEntity . setDeliverySortingFee ( json . getBigDecimal ( "deliverySortingFee" ) ) ;
statisticsPackageInfoEntity . setRealDeliverySortingFee ( json . getBigDecimal ( "deliverySortingFee" ) ) ;
statisticsPackageInfoEntity . setDeliveryUpfloorFee ( json . getBigDecimal ( "deliveryUpfloorFee" ) ) ;
statisticsPackageInfoEntity . setRealDeliveryUpfloorFee ( json . getBigDecimal ( "deliveryUpfloorFee" ) ) ;
statisticsPackageInfoEntity . setDeliveryMoveFee ( json . getBigDecimal ( "deliveryMoveFee" ) ) ;
statisticsPackageInfoEntity . setRealDeliveryMoveFee ( json . getBigDecimal ( "deliveryMoveFee" ) ) ;
statisticsPackageInfoEntity . setDeliveryDistance ( json . getBigDecimal ( "deliveryDistance" ) ) ;
statisticsPackageInfoEntity . setRealDeliveryDistance ( json . getBigDecimal ( "deliveryDistance" ) ) ;
statisticsPackageInfoEntity . setDeliveryCrossingFee ( json . getBigDecimal ( "deliveryCrossingFee" ) ) ;
statisticsPackageInfoEntity . setRealDeliveryCrossingFee ( json . getBigDecimal ( "deliveryCrossingFee" ) ) ;
statisticsPackageInfoEntity . setInstallFee ( json . getBigDecimal ( "installFee" ) ) ;
statisticsPackageInfoEntity . setRealInstallFee ( json . getBigDecimal ( "installFee" ) ) ;
statisticsPackageInfoEntity . setQuotationFee ( json . getBigDecimal ( "quotationFee" ) ) ;
statisticsPackageInfoEntity . setRealQuotationFee ( json . getBigDecimal ( "quotationFee" ) ) ;
statisticsPackageInfoEntity . setClaimingValue ( json . getBigDecimal ( "claimingValue" ) ) ;
statisticsPackageInfoEntity . setRealClaimingValue ( json . getBigDecimal ( "claimingValue" ) ) ;
statisticsPackageInfoEntity . setOtherFee ( json . getBigDecimal ( "otherFee" ) ) ;
statisticsPackageInfoEntity . setRealOtherFee ( json . getBigDecimal ( "otherFee" ) ) ;
statisticsPackageInfoEntity . setReturnFee ( json . getBigDecimal ( "returnFee" ) ) ;
statisticsPackageInfoEntity . setRealReturnFee ( json . getBigDecimal ( "returnFee" ) ) ;
statisticsPackageInfoEntity . setThirdOprationFee ( json . getBigDecimal ( "thirdOprationFee" ) ) ;
statisticsPackageInfoEntity . setRealThirdOprationFee ( json . getBigDecimal ( "thirdOprationFee" ) ) ;
statisticsPackageInfoEntity . setXPay ( json . getBigDecimal ( "xPay" ) ) ;
statisticsPackageInfoEntity . setRealXPay ( json . getBigDecimal ( "xPay" ) ) ;
statisticsPackageInfoEntity . setDPay ( json . getBigDecimal ( "dPay" ) ) ;
statisticsPackageInfoEntity . setRealDPay ( json . getBigDecimal ( "dPay" ) ) ;
statisticsPackageInfoEntity . setHPay ( json . getBigDecimal ( "hPay" ) ) ;
statisticsPackageInfoEntity . setRealHPay ( json . getBigDecimal ( "hPay" ) ) ;
statisticsPackageInfoEntity . setYPay ( json . getBigDecimal ( "yPay" ) ) ;
statisticsPackageInfoEntity . setRealYPay ( json . getBigDecimal ( "yPay" ) ) ;
statisticsPackageInfoEntity . setIsAftersales ( 0 ) ;
statisticsPackageInfoEntity . setHasStatement ( 0 ) ;
ls . add ( statisticsPackageInfoEntity ) ;
statisticsDistributionPackageEntity . setOrderCode ( json . getStr ( "orderCode" ) ) ;
statisticsDistributionPackageEntity . setOrderPackageCode ( json . getStr ( "orderPackageCode" ) ) ;
statisticsDistributionPackageEntity . setProductName ( json . getStr ( "productName" ) ) ;
statisticsDistributionPackageEntity . setTotalNum ( json . getInt ( "totalNum" ) ) ;
statisticsDistributionPackageEntity . setTotalWeight ( json . getBigDecimal ( "totalWeight" ) ) ;
statisticsDistributionPackageEntity . setTotalVolume ( json . getBigDecimal ( "totalVolume" ) ) ;
statisticsDistributionPackageEntity . setDeliveryServiceFee ( json . getBigDecimal ( "deliveryServiceFee" ) ) ;
statisticsDistributionPackageEntity . setRealDeliveryServiceFee ( json . getBigDecimal ( "deliveryServiceFee" ) ) ;
statisticsDistributionPackageEntity . setDeliveryFee ( json . getBigDecimal ( "deliveryFee" ) ) ;
statisticsDistributionPackageEntity . setRealDeliveryFee ( json . getBigDecimal ( "deliveryFee" ) ) ;
statisticsDistributionPackageEntity . setDeliveryLoadingFee ( json . getBigDecimal ( "deliveryLoadingFee" ) ) ;
statisticsDistributionPackageEntity . setRealDeliveryLoadingFee ( json . getBigDecimal ( "deliveryLoadingFee" ) ) ;
statisticsDistributionPackageEntity . setDeliverySortingFee ( json . getBigDecimal ( "deliverySortingFee" ) ) ;
statisticsDistributionPackageEntity . setRealDeliverySortingFee ( json . getBigDecimal ( "deliverySortingFee" ) ) ;
statisticsDistributionPackageEntity . setDeliveryUpfloorFee ( json . getBigDecimal ( "deliveryUpfloorFee" ) ) ;
statisticsDistributionPackageEntity . setRealDeliveryUpfloorFee ( json . getBigDecimal ( "deliveryUpfloorFee" ) ) ;
statisticsDistributionPackageEntity . setDeliveryMoveFee ( json . getBigDecimal ( "deliveryMoveFee" ) ) ;
statisticsDistributionPackageEntity . setRealDeliveryMoveFee ( json . getBigDecimal ( "deliveryMoveFee" ) ) ;
statisticsDistributionPackageEntity . setDeliveryDistance ( json . getBigDecimal ( "deliveryDistance" ) ) ;
statisticsDistributionPackageEntity . setRealDeliveryDistance ( json . getBigDecimal ( "deliveryDistance" ) ) ;
statisticsDistributionPackageEntity . setDeliveryCrossingFee ( json . getBigDecimal ( "deliveryCrossingFee" ) ) ;
statisticsDistributionPackageEntity . setRealDeliveryCrossingFee ( json . getBigDecimal ( "deliveryCrossingFee" ) ) ;
statisticsDistributionPackageEntities . add ( statisticsDistributionPackageEntity ) ;
}
Long waybillInfoId = null ;
//生成运单维度
if ( ! "2" . equals ( typeService ) ) {
StatisticsWaybillInfoEntity statisticsWaybillInfoEntity = new StatisticsWaybillInfoEntity ( ) ;
statisticsWaybillInfoEntity . setWaybillNo ( waybillNo ) ;
statisticsWaybillInfoEntity . setWaybillId ( waybillId ) ;
statisticsWaybillInfoEntity . setTypeService ( typeService ) ;
statisticsWaybillInfoEntity . setConfirmStatisticsOrder ( 0 ) ;
statisticsWaybillInfoService . save ( statisticsWaybillInfoEntity ) ;
waybillInfoId = statisticsWaybillInfoEntity . getId ( ) ;
}
statisticsPackageInfoService . saveBatch ( ls ) ;
//把ls通过typeService=2过滤为一个新的list
List < StatisticsPackageInfoEntity > shipeiList = ls . stream ( ) . filter ( item - > item . getTypeService ( ) . equals ( "2" ) ) . collect ( Collectors . toList ( ) ) ;
//toC维度
//把statisticsPackageInfoEntities的orderCode作为key进行分组
Map < String , List < StatisticsTrunklinePackageEntity > > trunklineMap = statisticsTrunklinePackageEntities . stream ( ) . collect ( Collectors . groupingBy ( StatisticsTrunklinePackageEntity : : getOrderCode ) ) ;
Map < String , List < StatisticsWarehousePackageEntity > > warehouseMap = statisticsWarehousePackageEntities . stream ( ) . collect ( Collectors . groupingBy ( StatisticsWarehousePackageEntity : : getOrderCode ) ) ;
Map < String , List < StatisticsDistributionPackageEntity > > distributionMap = statisticsDistributionPackageEntities . stream ( ) . collect ( Collectors . groupingBy ( StatisticsDistributionPackageEntity : : getOrderCode ) ) ;
List < StatisticsOrderInfoEntity > orderInfoEntities = new ArrayList < > ( ) ;
Long finalWaybillInfoId = waybillInfoId ;
trunklineMap . keySet ( ) . forEach ( key - > {
StatisticsOrderInfoEntity statisticsOrderInfoEntity = new StatisticsOrderInfoEntity ( ) ;
statisticsOrderInfoEntity . setWaybillId ( waybillId ) ;
statisticsOrderInfoEntity . setWaybillNo ( waybillNo ) ;
statisticsOrderInfoEntity . setOrderCode ( key ) ;
statisticsOrderInfoEntity . setTypeService ( typeService ) ;
if ( ! Objects . isNull ( finalWaybillInfoId ) ) {
statisticsOrderInfoEntity . setWaybillInfoId ( finalWaybillInfoId ) ;
}
// statisticsOrderInfoEntity.setConfirmStatus(0);
orderInfoEntities . add ( statisticsOrderInfoEntity ) ;
} ) ;
statisticsOrderInfoService . saveBatch ( orderInfoEntities ) ;
List < StatisticsPackageInfoEntity > otherList = ls . stream ( ) . filter ( item - > ! item . getTypeService ( ) . equals ( "2" ) ) . collect ( Collectors . toList ( ) ) ;
//toB维度
List < StatisticsTrunklinePackageEntity > statisticsTrunklinePackageSaveList = new ArrayList < > ( ) ;
List < StatisticsWarehousePackageEntity > statisticsWarehousePackageSaveList = new ArrayList < > ( ) ;
List < StatisticsDistributionPackageEntity > statisticsDistributionPackageSaveList = new ArrayList < > ( ) ;
orderInfoEntities . forEach ( statisticsOrderInfoEntity - > {
String orderCode = statisticsOrderInfoEntity . getOrderCode ( ) ;
Long orderInfoId = statisticsOrderInfoEntity . getId ( ) ;
List < StatisticsTrunklinePackageEntity > statisticsTrunklinePackageEntityList = trunklineMap . get ( orderCode ) ;
statisticsTrunklinePackageEntityList . forEach ( statisticsTrunklinePackageEntity - > {
statisticsTrunklinePackageEntity . setOrderInfoId ( orderInfoId ) ;
} ) ;
statisticsTrunklinePackageSaveList . addAll ( statisticsTrunklinePackageEntityList ) ;
} ) ;
statisticsTrunklinePackageService . saveBatch ( statisticsTrunklinePackageSaveList ) ;
orderInfoEntities . forEach ( statisticsOrderInfoEntity - > {
String orderCode = statisticsOrderInfoEntity . getOrderCode ( ) ;
Long orderInfoId = statisticsOrderInfoEntity . getId ( ) ;
List < StatisticsWarehousePackageEntity > statisticsWarehousePackageEntityList = warehouseMap . get ( orderCode ) ;
statisticsWarehousePackageEntityList . forEach ( statisticsWarehousePackageEntity - > {
statisticsWarehousePackageEntity . setOrderInfoId ( orderInfoId ) ;
} ) ;
statisticsWarehousePackageSaveList . addAll ( statisticsWarehousePackageEntityList ) ;
} ) ;
statisticsWarehousePackageService . saveBatch ( statisticsWarehousePackageSaveList ) ;
orderInfoEntities . forEach ( statisticsOrderInfoEntity - > {
String orderCode = statisticsOrderInfoEntity . getOrderCode ( ) ;
Long orderInfoId = statisticsOrderInfoEntity . getId ( ) ;
List < StatisticsDistributionPackageEntity > statisticsDistributionPackageEntityList = distributionMap . get ( orderCode ) ;
statisticsDistributionPackageEntityList . forEach ( statisticsDistributionPackageEntity - > {
statisticsDistributionPackageEntity . setOrderInfoId ( orderInfoId ) ;
} ) ;
statisticsDistributionPackageSaveList . addAll ( statisticsDistributionPackageEntityList ) ;
} ) ;
statisticsDistributionPackageService . saveBatch ( statisticsDistributionPackageSaveList ) ;
log . info ( "处理完成:{}" , msg ) ;
@ -155,6 +264,84 @@ public class WaybillFanoutListener {
@Transactional ( rollbackFor = Exception . class )
public void updateWaybillData ( String msg ) {
log . info ( "接收到消息:{}" , msg ) ;
JSONObject jsonObject = JSONUtil . parseObj ( msg ) ;
Long warehouseId = jsonObject . getLong ( "warehouseId" ) ;
String warehouseName = jsonObject . getStr ( "warehouseName" ) ;
Long waybillId = jsonObject . getLong ( "waybillId" ) ;
String waybillNo = jsonObject . getStr ( "waybillNo" ) ;
String typeService = jsonObject . getStr ( "typeService" ) ; //服务类型
statisticsTrunklinePackageService . deleteListByWaybillId ( waybillId ) ;
List < StatisticsOrderInfoEntity > orderInfoEntities = statisticsOrderInfoService . findListByWaybillId ( waybillId ) ;
//把orderInfoEntities以orderCode未key,元素本身为value转成Map
Map < String , StatisticsOrderInfoEntity > orderInfoMap = orderInfoEntities . stream ( )
. collect ( Collectors . toMap (
StatisticsOrderInfoEntity : : getOrderCode ,
entity - > entity
) ) ;
List < StatisticsTrunklinePackageEntity > statisticsTrunklinePackageEntities = new ArrayList < > ( ) ;
JSONArray orderPackageCodes = jsonObject . getJSONArray ( "orderPackageCodes" ) ;
for ( int i = 0 ; i < orderPackageCodes . size ( ) ; i + + ) {
JSONObject json = orderPackageCodes . getJSONObject ( i ) ;
//干线
StatisticsTrunklinePackageEntity statisticsTrunklinePackageEntity = new StatisticsTrunklinePackageEntity ( ) ;
statisticsTrunklinePackageEntity . setWarehouseId ( warehouseId ) ;
statisticsTrunklinePackageEntity . setWarehouseName ( warehouseName ) ;
statisticsTrunklinePackageEntity . setTypeService ( typeService ) ;
statisticsTrunklinePackageEntity . setWaybillId ( waybillId ) ;
statisticsTrunklinePackageEntity . setWaybillNo ( waybillNo ) ;
Integer waybillType = json . getInt ( "waybillType" ) ;
if ( waybillType . equals ( 1 ) ) {
statisticsTrunklinePackageEntity . setGoodsType ( 1 ) ;
} else if ( waybillType . equals ( 2 ) ) {
statisticsTrunklinePackageEntity . setGoodsType ( 2 ) ;
} else {
statisticsTrunklinePackageEntity . setGoodsType ( 3 ) ;
}
String orderCode = json . getStr ( "orderCode" ) ;
StatisticsOrderInfoEntity statisticsOrderInfoEntity = orderInfoMap . get ( orderCode ) ;
statisticsTrunklinePackageEntity . setOrderInfoId ( statisticsOrderInfoEntity . getId ( ) ) ;
statisticsTrunklinePackageEntity . setOrderCode ( orderCode ) ;
statisticsTrunklinePackageEntity . setOrderPackageCode ( json . getStr ( "orderPackageCode" ) ) ;
statisticsTrunklinePackageEntity . setProductName ( json . getStr ( "productName" ) ) ;
statisticsTrunklinePackageEntity . setTotalNum ( json . getInt ( "totalNum" ) ) ;
statisticsTrunklinePackageEntity . setTotalWeight ( json . getBigDecimal ( "totalWeight" ) ) ;
statisticsTrunklinePackageEntity . setTotalVolume ( json . getBigDecimal ( "totalVolume" ) ) ;
statisticsTrunklinePackageEntity . setOpenPrice ( json . getBigDecimal ( "openPrice" ) ) ;
statisticsTrunklinePackageEntity . setTotalPrice ( json . getBigDecimal ( "openPrice" ) ) ;
statisticsTrunklinePackageEntity . setPickupFee ( json . getBigDecimal ( "pickupFee" ) ) ;
statisticsTrunklinePackageEntity . setRealPickupFee ( json . getBigDecimal ( "pickupFee" ) ) ;
statisticsTrunklinePackageEntity . setFreightFee ( json . getBigDecimal ( "freightFee" ) ) ;
statisticsTrunklinePackageEntity . setRealFreightFee ( json . getBigDecimal ( "freightFee" ) ) ;
statisticsTrunklinePackageEntity . setInstallFee ( json . getBigDecimal ( "installFee" ) ) ;
statisticsTrunklinePackageEntity . setRealInstallFee ( json . getBigDecimal ( "installFee" ) ) ;
statisticsTrunklinePackageEntity . setQuotationFee ( json . getBigDecimal ( "quotationFee" ) ) ;
statisticsTrunklinePackageEntity . setRealQuotationFee ( json . getBigDecimal ( "quotationFee" ) ) ;
statisticsTrunklinePackageEntity . setClaimingValue ( json . getBigDecimal ( "claimingValue" ) ) ;
statisticsTrunklinePackageEntity . setRealClaimingValue ( json . getBigDecimal ( "claimingValue" ) ) ;
statisticsTrunklinePackageEntity . setOtherFee ( json . getBigDecimal ( "otherFee" ) ) ;
statisticsTrunklinePackageEntity . setRealOtherFee ( json . getBigDecimal ( "otherFee" ) ) ;
statisticsTrunklinePackageEntity . setReturnFee ( json . getBigDecimal ( "returnFee" ) ) ;
statisticsTrunklinePackageEntity . setRealReturnFee ( json . getBigDecimal ( "returnFee" ) ) ;
statisticsTrunklinePackageEntity . setThirdOprationFee ( json . getBigDecimal ( "thirdOprationFee" ) ) ;
statisticsTrunklinePackageEntity . setRealThirdOprationFee ( json . getBigDecimal ( "thirdOprationFee" ) ) ;
statisticsTrunklinePackageEntity . setXPay ( json . getBigDecimal ( "xPay" ) ) ;
statisticsTrunklinePackageEntity . setRealXPay ( json . getBigDecimal ( "xPay" ) ) ;
statisticsTrunklinePackageEntity . setDPay ( json . getBigDecimal ( "dPay" ) ) ;
statisticsTrunklinePackageEntity . setRealDPay ( json . getBigDecimal ( "dPay" ) ) ;
statisticsTrunklinePackageEntity . setHPay ( json . getBigDecimal ( "hPay" ) ) ;
statisticsTrunklinePackageEntity . setRealHPay ( json . getBigDecimal ( "hPay" ) ) ;
statisticsTrunklinePackageEntity . setYPay ( json . getBigDecimal ( "yPay" ) ) ;
statisticsTrunklinePackageEntity . setRealYPay ( json . getBigDecimal ( "yPay" ) ) ;
statisticsTrunklinePackageEntities . add ( statisticsTrunklinePackageEntity ) ;
}
statisticsTrunklinePackageService . saveBatch ( statisticsTrunklinePackageEntities ) ;
}