@ -19,9 +19,11 @@ import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component ;
import org.springframework.transaction.annotation.Transactional ;
import java.math.BigDecimal ;
import java.util.ArrayList ;
import java.util.List ;
import java.util.Map ;
import java.util.Objects ;
import java.util.stream.Collectors ;
@Slf4j
@ -48,6 +50,7 @@ public class WaybillFanoutListener {
Long waybillId = jsonObject . getLong ( "waybillId" ) ;
String waybillNo = jsonObject . getStr ( "waybillNo" ) ;
String typeService = jsonObject . getStr ( "typeService" ) ; //服务类型
Integer waybillType = jsonObject . getInt ( "waybillType" ) ;
List < StatisticsTrunklinePackageEntity > statisticsTrunklinePackageEntities = new ArrayList < > ( ) ;
List < StatisticsWarehousePackageEntity > statisticsWarehousePackageEntities = new ArrayList < > ( ) ;
@ -56,6 +59,14 @@ public class WaybillFanoutListener {
JSONArray orderPackageCodes = jsonObject . getJSONArray ( "orderPackageCodes" ) ;
for ( int i = 0 ; i < orderPackageCodes . size ( ) ; i + + ) {
JSONObject json = orderPackageCodes . getJSONObject ( i ) ;
BigDecimal totalWeight = json . getBigDecimal ( "totalWeight" ) ;
if ( Objects . isNull ( totalWeight ) ) {
totalWeight = BigDecimal . ZERO ;
}
BigDecimal totalVolume = json . getBigDecimal ( "totalVolume" ) ;
if ( Objects . isNull ( totalVolume ) ) {
totalVolume = BigDecimal . ZERO ;
}
//干线
StatisticsTrunklinePackageEntity statisticsTrunklinePackageEntity = new StatisticsTrunklinePackageEntity ( ) ;
@ -64,7 +75,6 @@ public class WaybillFanoutListener {
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 ) ) {
@ -76,8 +86,8 @@ public class WaybillFanoutListener {
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 . setTotalWeight ( totalWeight ) ;
statisticsTrunklinePackageEntity . setTotalVolume ( totalVolume ) ;
statisticsTrunklinePackageEntity . setOpenPrice ( json . getBigDecimal ( "openPrice" ) ) ;
statisticsTrunklinePackageEntity . setTotalPrice ( json . getBigDecimal ( "openPrice" ) ) ;
statisticsTrunklinePackageEntity . setPickupFee ( json . getBigDecimal ( "pickupFee" ) ) ;
@ -124,8 +134,10 @@ public class WaybillFanoutListener {
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 . setTotalWeight ( totalWeight ) ;
statisticsWarehousePackageEntity . setTotalVolume ( totalVolume ) ;
statisticsWarehousePackageEntity . setOpenPrice ( json . getBigDecimal ( "warehouseServiceFee" ) ) ;
statisticsWarehousePackageEntity . setTotalPrice ( json . getBigDecimal ( "warehouseServiceFee" ) ) ;
statisticsWarehousePackageEntity . setWarehouseServiceFee ( json . getBigDecimal ( "warehouseServiceFee" ) ) ;
statisticsWarehousePackageEntity . setRealWarehouseServiceFee ( json . getBigDecimal ( "warehouseServiceFee" ) ) ;
statisticsWarehousePackageEntity . setWarehouseFee ( json . getBigDecimal ( "warehouseFee" ) ) ;
@ -157,8 +169,10 @@ public class WaybillFanoutListener {
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 . setTotalWeight ( totalWeight ) ;
statisticsDistributionPackageEntity . setTotalVolume ( totalVolume ) ;
statisticsDistributionPackageEntity . setOpenPrice ( json . getBigDecimal ( "deliveryServiceFee" ) ) ;
statisticsDistributionPackageEntity . setTotalPrice ( json . getBigDecimal ( "deliveryServiceFee" ) ) ;
statisticsDistributionPackageEntity . setDeliveryServiceFee ( json . getBigDecimal ( "deliveryServiceFee" ) ) ;
statisticsDistributionPackageEntity . setRealDeliveryServiceFee ( json . getBigDecimal ( "deliveryServiceFee" ) ) ;
statisticsDistributionPackageEntity . setDeliveryFee ( json . getBigDecimal ( "deliveryFee" ) ) ;
@ -204,6 +218,9 @@ public class WaybillFanoutListener {
statisticsOrderInfoEntity . setWaybillNo ( waybillNo ) ;
statisticsOrderInfoEntity . setOrderCode ( key ) ;
statisticsOrderInfoEntity . setTypeService ( typeService ) ;
statisticsOrderInfoEntity . setSignStatus ( 0 ) ;
statisticsOrderInfoEntity . setConfirmStatisticsOrder ( 0 ) ;
statisticsOrderInfoEntity . setChangesFee ( BigDecimal . ZERO ) ;
orderInfoEntities . add ( statisticsOrderInfoEntity ) ;
} ) ;
@ -220,33 +237,46 @@ public class WaybillFanoutListener {
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 ) ;
} ) ;
} ) ;
statisticsTrunklinePackageService . saveBatch ( statisticsTrunklinePackageSaveList ) ;
statisticsWarehousePackageService . saveBatch ( statisticsWarehousePackageSaveList ) ;
statisticsDistributionPackageService . saveBatch ( statisticsDistributionPackageSaveList ) ;
// 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 ) ;
}