@ -3,11 +3,16 @@ package com.logpm.warehouse.service.impl;
import com.alibaba.fastjson.JSONObject ;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper ;
import com.baomidou.mybatisplus.core.metadata.IPage ;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils ;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page ;
import com.logpm.basic.entity.BasicMaterialEntity ;
import com.logpm.basic.feign.IBasicMaterialClient ;
import com.logpm.basicdata.entity.BasicdataClientEntity ;
import com.logpm.basicdata.entity.BasicdataStoreBusinessEntity ;
import com.logpm.basicdata.entity.BasicdataTrayEntity ;
import com.logpm.basicdata.entity.BasicdataWarehouseEntity ;
import com.logpm.basicdata.feign.IBasicdataClientClient ;
import com.logpm.basicdata.feign.IBasicdataStoreBusinessClient ;
import com.logpm.basicdata.feign.IBasicdataTrayClient ;
import com.logpm.basicdata.feign.IBasicdataWarehouseClient ;
import com.logpm.distribution.entity.DistributionParcelListEntity ;
@ -16,6 +21,17 @@ import com.logpm.distribution.entity.DistributionStockListEntity;
import com.logpm.distribution.feign.IDistributionParcelListClient ;
import com.logpm.distribution.feign.IDistributionStockArticleClient ;
import com.logpm.distribution.feign.IDistributionStockListClient ;
import com.logpm.oldproject.entity.* ;
import com.logpm.oldproject.feign.* ;
import com.logpm.oldproject.vo.DistributionParcelListEntityVO ;
import com.logpm.trunkline.entity.TrunklineAdvanceDetailEntity ;
import com.logpm.trunkline.entity.TrunklineAdvanceEntity ;
import com.logpm.trunkline.entity.TrunklineDetailProductEntity ;
import com.logpm.trunkline.entity.TrunklineWaybillOrderEntity ;
import com.logpm.trunkline.feign.ITrunklineAdvanceClient ;
import com.logpm.trunkline.feign.ITrunklineAdvanceDetailClient ;
import com.logpm.trunkline.feign.ITrunklineDetailProductClient ;
import com.logpm.trunkline.feign.ITrunklineWaybillOrderClient ;
import com.logpm.warehouse.bean.Resp ;
import com.logpm.warehouse.dto.TrayTypeDTO ;
import com.logpm.warehouse.dto.ZeroOrderVO ;
@ -28,10 +44,17 @@ import lombok.extern.log4j.Log4j2;
import org.springblade.common.constant.DictBizConstant ;
import org.springblade.common.constant.TenantNum ;
import org.springblade.common.constant.apiwarehouse.PalletProductTypeConstant ;
import org.springblade.common.constant.order.OrderFreezeStatusConstant ;
import org.springblade.common.constant.order.OrderGroundingStatusConstant ;
import org.springblade.common.constant.order.OrderReservationStatusConstant ;
import org.springblade.common.constant.order.OrderStockupStatusConstant ;
import org.springblade.common.constant.orderpackage.* ;
import org.springblade.common.exception.CustomerException ;
import org.springblade.common.utils.CommonUtil ;
import org.springblade.core.mp.base.BaseServiceImpl ;
import org.springblade.core.tool.api.R ;
import org.springblade.core.tool.utils.BeanUtil ;
import org.springblade.core.tool.utils.ObjectUtil ;
import org.springblade.core.tool.utils.StringUtil ;
import org.springblade.system.cache.DictBizCache ;
import org.springframework.beans.factory.annotation.Autowired ;
@ -39,6 +62,7 @@ import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service ;
import org.springframework.transaction.annotation.Transactional ;
import java.math.BigDecimal ;
import java.util.* ;
@Log4j2
@ -66,6 +90,36 @@ public class WarehouseTrayTypeServiceImpl extends BaseServiceImpl<WarehouseTrayT
private IWarehouseUpdownGoodsService warehouseUpdownGoodsService ;
@Autowired
private IBasicdataWarehouseClient basicdataWarehouseClient ;
@Autowired
private ITrayScanDesClient trayScanDesClient ;
@Autowired
private ITrayScanClient trayScanClient ;
@Autowired
private IAdvanceClient advanceClient ;
@Autowired
private IOrderCountClient orderCountClient ;
@Autowired
private IWayBillClient wayBillClient ;
@Autowired
private IBasicdataClientClient basicdataClientClient ;
@Autowired
private IOrderDetailClient orderDetailClient ;
@Autowired
private IAdvanceDetailClient advanceDetailClient ;
@Autowired
private IBasicdataStoreBusinessClient basicdataStoreBusinessClient ;
@Autowired
private IWarehouseWaybillService warehouseWaybillService ;
@Autowired
private ITrunklineAdvanceDetailClient trunklineAdvanceDetailClient ;
@Autowired
private IDetailProductClient detailProductClient ;
@Autowired
private ITrunklineWaybillOrderClient waybillOrderClient ;
@Autowired
private ITrunklineDetailProductClient trunklineDetailProductClient ;
@Autowired
private ITrunklineAdvanceClient trunklineAdvanceClient ;
@Override
public IPage < WarehouseTrayTypeVO > orderPageList ( TrayTypeDTO trayTypeDTO , Long warehouseId ) {
@ -380,7 +434,7 @@ public class WarehouseTrayTypeServiceImpl extends BaseServiceImpl<WarehouseTrayT
String oldTrayCode = trayGoodsEntity . getTrayCode ( ) ;
if ( oldTrayCode . equals ( trayCode ) ) {
log . warn ( "##############orderScanOrderPackageCode: 该包条已打托 trayCode={}" , trayCode ) ;
return Resp . scanFail ( 2 001, "该包条已打托" , "已扫描" ) ;
return Resp . scanFail ( 4 001, "该包条已打托" , "已扫描" ) ;
}
log . warn ( "#########orderScanOrderPackageCode: 包件已打托 orderPackageCode={}" , orderPackageCode ) ;
@ -575,11 +629,11 @@ public class WarehouseTrayTypeServiceImpl extends BaseServiceImpl<WarehouseTrayT
String oldTrayCode = trayGoodsEntity . getTrayCode ( ) ;
if ( oldTrayCode . equals ( trayCode ) ) {
log . warn ( "##############orderScanOrderPackageCode: 该包条已打托 trayCode={}" , trayCode ) ;
return Resp . scanFail ( 2 001, "该包条已打托" , "已扫描" ) ;
return Resp . scanFail ( 4 001, "该包条已打托" , "已扫描" ) ;
}
log . warn ( "#########orderScanOrderPackageCode: 包件已打托 orderPackageCode={}" , orderPackageCode ) ;
return Resp . scanFail ( 2001 , "包件已打托" , "已在" + oldTrayCode + "托盘绑定" ) ;
return Resp . scanFail ( 4002 , "包件已打托" , "已在" + oldTrayCode + "托盘绑定" ) ;
}
QueryWrapper < WarehouseUpdownGoodsEntity > updownGoodsEntityQueryWrapper = new QueryWrapper < > ( ) ;
@ -589,7 +643,7 @@ public class WarehouseTrayTypeServiceImpl extends BaseServiceImpl<WarehouseTrayT
if ( ! Objects . isNull ( updownGoodsEntity ) ) {
String positionCode = updownGoodsEntity . getPositionCode ( ) ;
log . warn ( "#########orderScanOrderPackageCode: 包件已上架 orderPackageCode={}" , orderPackageCode ) ;
return Resp . scanFail ( 2001 , "包件已上架" , "包件已上架" + positionCode + ",请先下架或进行移库绑定" ) ;
return Resp . scanFail ( 4003 , "包件已上架" , "包件已上架" + positionCode + ",请先下架或进行移库绑定" ) ;
}
BasicdataTrayEntity basicdataTrayEntity = basicdataTrayClient . getTrayByTrayCode ( trayCode ) ;
@ -659,7 +713,7 @@ public class WarehouseTrayTypeServiceImpl extends BaseServiceImpl<WarehouseTrayT
if ( ! tt . equals ( trayType ) ) {
log . warn ( "##############orderScanOrderPackageCode: 打托方式不正确 {}={}" , trayType , tt ) ;
return Resp . scanFail ( 2001 , "打托方式不正确" , "打托方式不正确" ) ;
return Resp . scanFail ( 4004 , "打托方式不正确" , "打托方式不正确" ) ;
}
if ( StringUtil . isBlank ( filterValue ) ) {
@ -2740,6 +2794,757 @@ public class WarehouseTrayTypeServiceImpl extends BaseServiceImpl<WarehouseTrayT
}
@Override
public R findSyncTrayData ( String trayCode , Long warehouseId ) {
WarehouseTrayTypeVO trayTypeVO = new WarehouseTrayTypeVO ( ) ;
BasicdataTrayEntity trayEntity = basicdataTrayClient . getTrayByTrayCode ( trayCode ) ;
if ( Objects . isNull ( trayEntity ) ) {
log . warn ( "###########findSyncTrayData: 托盘信息不存在 trayCode={}" , trayCode ) ;
return R . fail ( 405 , "托盘信息不存在" ) ;
}
Long trayId = trayEntity . getId ( ) ;
Long allocationId = warehouseTaryAllocationService . getAllocationIdByTrayId ( trayId ) ;
if ( ! Objects . isNull ( allocationId ) ) {
log . warn ( "###########findSyncTrayData: 托盘还未下架 trayCode={}" , trayCode ) ;
return R . fail ( 405 , "托盘还未下架" ) ;
}
QueryWrapper < WarehouseTrayTypeEntity > queryWrapper = new QueryWrapper < > ( ) ;
queryWrapper . eq ( "tray_code" , trayCode )
. eq ( "is_deleted" , 0 ) ;
WarehouseTrayTypeEntity trayTypeEntity = baseMapper . selectOne ( queryWrapper ) ;
if ( Objects . isNull ( trayTypeEntity ) ) {
trayTypeVO . setTrayName ( trayEntity . getPalletName ( ) ) ;
trayTypeVO . setTrayCode ( trayCode ) ;
trayTypeVO . setTotalNum ( 0 ) ;
trayTypeVO . setOrderTotalNum ( 0 ) ;
trayTypeVO . setStockNum ( 0 ) ;
trayTypeVO . setStockTotalNum ( 0 ) ;
trayTypeVO . setTrayType ( "100" ) ;
trayTypeVO . setTrayTypeName ( "其他" ) ;
} else {
String trayType = trayTypeEntity . getTrayType ( ) ;
String value = DictBizCache . getValue ( "pallet_order_type" , trayType ) ;
BeanUtil . copy ( trayTypeEntity , trayTypeVO ) ;
trayTypeVO . setTrayName ( trayEntity . getPalletName ( ) ) ;
trayTypeVO . setTrayTypeName ( value ) ;
}
List < OrderPackageInfoVO > packageList = warehouseTrayGoodsService . findOrderPackageCodeInfoList ( trayCode ) ;
List < OrderPackageInfoVO > zeroList = warehouseTrayGoodsService . findZeroOrderInfoList ( trayCode ) ;
List < OrderPackageInfoVO > stockList = warehouseTrayGoodsService . findStockInfoList ( trayCode ) ;
packageList . addAll ( zeroList ) ;
packageList . addAll ( stockList ) ;
trayTypeVO . setPackageList ( packageList ) ;
return R . data ( trayTypeVO ) ;
}
@Override
public R findSyncOldTrayData ( String trayCode , Long warehouseId ) {
BasicdataWarehouseEntity basicdataWarehouseEntity = basicdataWarehouseClient . getEntityWarehouseId ( warehouseId ) ;
if ( Objects . isNull ( basicdataWarehouseEntity ) ) {
log . warn ( "###########findSyncTrayData: 仓库信息不存在 warehouseId={}" , warehouseId ) ;
return R . fail ( 405 , "仓库信息不存在" ) ;
}
Integer oldWarehouseId = basicdataWarehouseEntity . getOldId ( ) ;
BasicdataTrayEntity trayEntity = basicdataTrayClient . getTrayByTrayCode ( trayCode ) ;
if ( Objects . isNull ( trayEntity ) ) {
log . warn ( "###########findSyncTrayData: 托盘信息不存在 trayCode={}" , trayCode ) ;
return R . fail ( 405 , "托盘信息不存在" ) ;
}
Integer trayId = trayEntity . getOldId ( ) ;
Map < String , Object > map = new HashMap < > ( ) ;
//查询所有托盘包件信息
Set < String > set = new TreeSet < > ( ) ;
List < String > orderPackageList = new ArrayList < > ( ) ;
List < TrayScanDesEntity > trayScanDesEntityList = trayScanDesClient . findListByTrayId ( trayId , oldWarehouseId ) ;
if ( trayScanDesEntityList . size ( ) = = 0 ) {
return R . data ( map ) ;
}
Integer trayScanId = null ;
for ( TrayScanDesEntity trayScanDesEntity : trayScanDesEntityList ) {
String orderPackageCode = trayScanDesEntity . getUnitNo ( ) ;
trayScanId = trayScanDesEntity . getTrayScanId ( ) ;
DistributionParcelListEntity parcelListEntity = distributionParcelListClient . findByPacketBarCodeAndWarehouseId ( orderPackageCode , warehouseId ) ;
if ( Objects . isNull ( parcelListEntity ) ) {
set . add ( trayScanDesEntity . getOrderSelfNum ( ) ) ;
}
orderPackageList . add ( orderPackageCode ) ;
}
for ( String orderCode : set ) {
saveOrderInfo ( orderCode , oldWarehouseId , warehouseId ) ;
}
String newTrayType = "100" ;
TrayScanEntity trayScanEntity = trayScanClient . getEntityByTrayScanId ( trayScanId ) ;
if ( ! Objects . isNull ( trayScanEntity ) ) {
Integer type = trayScanEntity . getType ( ) ;
if ( 1 = = type ) {
newTrayType = "60" ;
} else if ( 2 = = type ) {
newTrayType = "30" ;
} else if ( 3 = = type ) {
newTrayType = "50" ;
} else if ( 4 = = type ) {
newTrayType = "100" ;
} else if ( 5 = = type ) {
newTrayType = "10" ;
} else if ( 6 = = type ) {
newTrayType = "20" ;
}
}
String value = DictBizCache . getValue ( "pallet_order_type" , newTrayType ) ;
List < OrderPackageInfoVO > list = baseMapper . findOrderPackageList ( orderPackageList ) ;
map . put ( "packageList" , list ) ;
map . put ( "trayType" , newTrayType ) ;
map . put ( "trayTypeName" , value ) ;
map . put ( "trayCode" , trayCode ) ;
map . put ( "trayName" , trayEntity . getPalletName ( ) ) ;
return R . data ( map ) ;
}
@Override
public R syncOldTrayData ( String trayCode , String trayType , List < String > orderPackageCodes , Long warehouseId ) {
//先空置托盘
trayToNull ( trayCode ) ;
//批量打托
for ( String orderPackageCode : orderPackageCodes ) {
orderScanOrderPackageCode ( trayType , trayCode , orderPackageCode , warehouseId ) ;
}
return R . success ( "打托成功" ) ;
}
private void saveOrderInfo ( String orderCode , Integer oldWarehouseId , Long newWarehouseId ) {
//通过订单号查询暂存单
AdvanceEntity advanceEntity = advanceClient . getQueryDataOne ( orderCode ) ;
if ( Objects . isNull ( advanceEntity ) ) {
log . warn ( "#################saveOrderInfo: 未查询单订单信息 orderCode={}" , orderCode ) ;
throw new CustomerException ( 403 , "未查询单订单信息" ) ;
}
Integer advanceId = advanceEntity . getId ( ) ;
//判断新系统是否有这条订单数据
DistributionStockArticleEntity distributionStockArticleEntity = distributionStockArticleClient . findStockArticleByOrderCodeAndWarehouseId ( orderCode , newWarehouseId ) ;
OrderCountEntity orderCountEntity = orderCountClient . getEntityByOrderCode ( orderCode , oldWarehouseId ) ;
if ( Objects . isNull ( orderCountEntity ) ) {
log . warn ( "#################saveOrderInfo: 未查询单订单信息 orderCode={}" , orderCode ) ;
throw new CustomerException ( 403 , "未查询单订单信息" ) ;
}
Integer total = 0 ;
List < AdvanceEntity > advanceList = advanceClient . getAdvanceList ( orderCode ) ;
for ( AdvanceEntity entity : advanceList ) {
total = total + entity . getTotal ( ) ;
}
WayBillEntity wayBillEntity = wayBillClient . getByWayBillByAdvanceId ( advanceId ) ;
BasicdataWarehouseEntity basicdataWarehouseEntity = basicdataWarehouseClient . getEntityWarehouseId ( newWarehouseId ) ;
if ( Objects . isNull ( basicdataWarehouseEntity ) ) {
log . warn ( "#################saveOrderInfo: 未查询到仓库信息 newWarehouseId={}" , newWarehouseId ) ;
throw new CustomerException ( 403 , "未查询到仓库信息" ) ;
}
Long id ;
String wayBillNo = null ;
if ( Objects . isNull ( distributionStockArticleEntity ) ) {
Date date = new Date ( ) ;
distributionStockArticleEntity = new DistributionStockArticleEntity ( ) ;
distributionStockArticleEntity . setOrderCode ( orderCode ) ;
distributionStockArticleEntity . setWarehouseEntryTime ( orderCountEntity . getCreateTime ( ) ) ;
distributionStockArticleEntity . setWarehouseEntryTimeEnd ( orderCountEntity . getLatestInTime ( ) ) ;
distributionStockArticleEntity . setTotalNumber ( total ) ;
distributionStockArticleEntity . setHandQuantity ( 0 ) ;
distributionStockArticleEntity . setTenantId ( TenantNum . HUITONGCODE ) ; // 对应租户ID
log . info ( "############saveOrderInfo {}" , basicdataWarehouseEntity ) ;
distributionStockArticleEntity . setCreateDept ( basicdataWarehouseEntity . getDepartment ( ) ) ;
distributionStockArticleEntity . setWarehouse ( basicdataWarehouseEntity . getName ( ) ) ;
distributionStockArticleEntity . setWarehouseId ( basicdataWarehouseEntity . getId ( ) ) ;
distributionStockArticleEntity . setDealerCode ( advanceEntity . getDealerCode ( ) ) ;
distributionStockArticleEntity . setDealerName ( advanceEntity . getDealerName ( ) ) ;
distributionStockArticleEntity . setMallName ( advanceEntity . getDealerName ( ) ) ;
distributionStockArticleEntity . setMallCode ( advanceEntity . getDealerCode ( ) ) ;
if ( ObjectUtils . isNotNull ( wayBillEntity ) ) {
distributionStockArticleEntity . setConsigneeUnit ( wayBillEntity . getTakeCompany ( ) ) ; //收货单位(经销商)
distributionStockArticleEntity . setConsigneePerson ( wayBillEntity . getTakePerson ( ) ) ; //收货人
distributionStockArticleEntity . setConsigneeAddress ( wayBillEntity . getTakeAddress ( ) ) ; //收货人地址
distributionStockArticleEntity . setConsigneeMobile ( wayBillEntity . getTakePhone ( ) ) ; //收货人电话
wayBillNo = wayBillEntity . getWaybillNo ( ) ;
distributionStockArticleEntity . setWaybillNumber ( wayBillNo ) ;
// 根据老运单上的仓库名称找寻新的仓库名称
// 发站
String warehouseName = wayBillEntity . getStartSite ( ) ;
BasicdataWarehouseEntity t = basicdataWarehouseClient . findByName ( warehouseName ) ;
if ( ObjectUtils . isNotNull ( t ) ) {
distributionStockArticleEntity . setSendWarehouseName ( t . getName ( ) ) ;
distributionStockArticleEntity . setSendWarehouseId ( t . getId ( ) ) ;
}
//收货仓库
warehouseName = wayBillEntity . getWarehouseName ( ) ;
t = basicdataWarehouseClient . findByName ( warehouseName ) ;
if ( ObjectUtils . isNotNull ( t ) ) {
distributionStockArticleEntity . setAcceptWarehouseName ( t . getName ( ) ) ;
distributionStockArticleEntity . setAcceptWarehouseId ( t . getId ( ) ) ;
}
String customerName = wayBillEntity . getTakeCompany ( ) ; //客户名称
distributionStockArticleEntity . setTypeService ( "1" ) ; //默认商配
BasicdataClientEntity basicdataClientEntity = basicdataClientClient . findByName ( customerName ) ;
log . info ( "订单同步出现的客户编号{} 匹配的客户" , basicdataClientEntity ) ;
if ( ! Objects . isNull ( basicdataClientEntity ) ) {
//商城
distributionStockArticleEntity . setMallId ( basicdataClientEntity . getId ( ) ) ;
distributionStockArticleEntity . setMallName ( basicdataClientEntity . getClientName ( ) ) ;
distributionStockArticleEntity . setMallCode ( basicdataClientEntity . getClientCode ( ) ) ;
String peisongType = getPeisongTypeByClientId ( basicdataClientEntity . getId ( ) ) ;
log . info ( "订单同步peisongType {} " , peisongType ) ;
if ( StringUtil . isNoneBlank ( peisongType ) ) {
distributionStockArticleEntity . setTypeService ( peisongType ) ;
}
}
}
distributionStockArticleEntity . setGenre ( 1 ) ;
distributionStockArticleEntity . setAdvanceId ( advanceId ) ;
//--------------2023-07-06 新增字段处理
// 增加订单 经销商信息 和门店信息
buildDealerAndStore ( distributionStockArticleEntity , advanceEntity ) ;
distributionStockArticleEntity . setCreateUser ( 1714696768639311873L ) ;
distributionStockArticleEntity . setUpdateUser ( 1714696768639311873L ) ;
distributionStockArticleEntity . setCreateDept ( 1649331096241836033L ) ;
distributionStockArticleEntity . setSortingQuantity ( 0 ) ; //分拣件数
distributionStockArticleEntity . setDeliveryQuantity ( 0 ) ; //配送件数
distributionStockArticleEntity . setTransferQuantity ( 0 ) ; //中转件数
distributionStockArticleEntity . setSigninQuantity ( 0 ) ; //签收件数
//1=部分入库,2=已入库,3=已出库,4=部分签收,5=待出库,6=已上架,7=已分拣,8=部分出库,9=部分装车,10=已装车,11=已签收,12=部分配送,13=已配送
distributionStockArticleEntity . setFreezeStatus ( OrderFreezeStatusConstant . weidongjie . getValue ( ) ) ; //冻结状态
distributionStockArticleEntity . setReservationStatus ( OrderReservationStatusConstant . daiyuyue . getValue ( ) ) ; //预约状态
distributionStockArticleEntity . setStockupStatus ( OrderStockupStatusConstant . daibeihuo . getValue ( ) ) ; //备货状态
distributionStockArticleEntity . setGroundingStatus ( OrderGroundingStatusConstant . daishangjia . getValue ( ) ) ; //上架状态
distributionStockArticleEntity . setWarehouseEntryTime ( date ) ;
id = distributionStockArticleClient . addData ( distributionStockArticleEntity ) ;
distributionStockArticleEntity . setId ( id ) ;
if ( id = = 0 ) {
log . warn ( "#################handleDataToPlatform: 保存订单信息失败 orderCode={}" , orderCode ) ;
throw new CustomerException ( 405 , "保存订单信息失败" ) ;
}
} else {
id = distributionStockArticleEntity . getId ( ) ;
distributionStockArticleEntity . setTotalNumber ( total ) ;
distributionStockArticleClient . saveOrUpdate ( distributionStockArticleEntity ) ;
}
//保存包件信息
saveOrderPackage ( distributionStockArticleEntity , basicdataWarehouseEntity , wayBillNo , CommonUtil . dateToString ( new Date ( ) ) , oldWarehouseId ) ;
}
private void saveOrderPackage ( DistributionStockArticleEntity distributionStockArticleEntity , BasicdataWarehouseEntity basicdataWarehouseEntity , String waybillNo , String operationTime , Integer oldWarehouseId ) {
String orderCode = distributionStockArticleEntity . getOrderCode ( ) ;
//查询订单下的所有包件
List < OrderDetailEntity > orderDetailList = orderDetailClient . findByOrderCode ( orderCode , oldWarehouseId ) ;
for ( OrderDetailEntity orderDetailEntity : orderDetailList ) {
String unitNo = orderDetailEntity . getUnitNo ( ) ;
DistributionParcelListEntity parcelListEntity = distributionParcelListClient . findByPacketBarCode ( unitNo ) ;
if ( ! Objects . isNull ( parcelListEntity ) ) {
log . info ( "###########saveOrderPackage: 包条已存在,不同步 unitNo={}" , unitNo ) ;
continue ;
}
// InventoryDetailEntity inventoryDetailEntity = inventoryDetailClient.findUnitNoIsExist(unitNo,inventoryId);
// if(Objects.isNull(inventoryDetailEntity)){
// log.info("###########saveOrderPackage: 包条不在盘点任务中存在,不同步 unitNo={}",unitNo);
// continue;
// }
Integer status = orderDetailEntity . getStatus ( ) ;
Integer carsType = orderDetailEntity . getCarsType ( ) ;
Integer signState = orderDetailEntity . getSignState ( ) ;
waybillNo = orderDetailEntity . getWaybillNo ( ) ;
Date rukuTime = orderDetailEntity . getCreateTime ( ) ;
if ( StringUtil . isBlank ( waybillNo ) ) {
Integer advanceId = orderDetailEntity . getAdvanceId ( ) ;
AdvanceEntity advanceEntity = advanceClient . fingById ( advanceId ) ;
if ( ! Objects . isNull ( advanceEntity ) ) {
waybillNo = advanceEntity . getWaybillNo ( ) ;
}
}
log . info ( "##########waybillNo: waybillNo={} " , waybillNo ) ;
if ( waybillNo . contains ( "," ) ) {
waybillNo = waybillNo . replaceAll ( "," , "" ) ;
}
//存入运单信息
WayBillEntity waybillEntity = saveWaybillEntity ( waybillNo ) ;
DistributionParcelListEntityVO vo = advanceDetailClient . getByUnitNoAndWarehouseId ( unitNo , oldWarehouseId ) ;
DistributionParcelListEntity entity = new DistributionParcelListEntity ( ) ;
cn . hutool . core . bean . BeanUtil . copyProperties ( vo , entity ) ;
entity . setQuantity ( 1 ) ;
entity . setOrderPackageCode ( vo . getPacketBarCode ( ) ) ;
entity . setConditions ( 1 ) ;
entity . setWarehouse ( distributionStockArticleEntity . getWarehouse ( ) ) ;
entity . setWarehouseId ( distributionStockArticleEntity . getWarehouseId ( ) ) ;
entity . setStockArticleId ( distributionStockArticleEntity . getId ( ) ) ;
entity . setOrderPackageStatus ( OrderPackageStatusConstant . yiruku . getValue ( ) ) ;
//状态:1到货,2分拣,3装车,4卸货,5出库,6配送
// if(1 == status){
// entity.setOrderPackageStatus(OrderPackageStatusConstant.yiruku.getValue());
// }
// if(3==carsType||4 == carsType){
// entity.setOrderPackageStatus(OrderPackageStatusConstant.yichuku.getValue());
// }
if ( 2 = = signState ) {
entity . setOrderPackageStatus ( OrderPackageStatusConstant . yiqianshou . getValue ( ) ) ;
} else {
entity . setOrderPackageStatus ( OrderPackageStatusConstant . zhongzhuanruku . getValue ( ) ) ;
if ( ! Objects . isNull ( waybillEntity ) ) {
String warehouseName = waybillEntity . getWarehouseName ( ) ; //目的仓
BasicdataWarehouseEntity endhouse = basicdataWarehouseClient . findByName ( warehouseName ) ;
Long endWarehouseId = endhouse . getId ( ) ;
Long warehouseId = distributionStockArticleEntity . getWarehouseId ( ) ;
if ( endWarehouseId . equals ( warehouseId ) ) {
entity . setOrderPackageStatus ( OrderPackageStatusConstant . yiruku . getValue ( ) ) ;
} else {
entity . setOrderPackageStatus ( OrderPackageStatusConstant . zhongzhuanruku . getValue ( ) ) ;
}
}
}
entity . setOrderPackageFreezeStatus ( OrderPackageFreezeStatusConstant . weidongjie . getValue ( ) ) ;
entity . setOrderPackageReservationStatus ( OrderPackageReservationStatusConstant . daiyuyue . getValue ( ) ) ;
entity . setOrderPackageGroundingStatus ( OrderPackageGroundingStatusConstant . daishangjia . getValue ( ) ) ;
entity . setOrderPackageStockupStatus ( OrderPackageStockupStatusConstant . daibeihuo . getValue ( ) ) ;
entity . setOrderCode ( distributionStockArticleEntity . getOrderCode ( ) ) ;
entity . setServiceNumber ( distributionStockArticleEntity . getServiceNumber ( ) ) ;
entity . setWaybillNumber ( waybillNo ) ;
// 增加 进销商 名称 编码 发站仓
entity . setSendWarehouseName ( distributionStockArticleEntity . getSendWarehouseName ( ) ) ;
entity . setSendWarehouseId ( distributionStockArticleEntity . getSendWarehouseId ( ) ) ;
//收货仓库
entity . setAcceptWarehouseName ( distributionStockArticleEntity . getAcceptWarehouseName ( ) ) ;
entity . setAcceptWarehouseId ( distributionStockArticleEntity . getAcceptWarehouseId ( ) ) ;
//进销售
entity . setDealerCode ( distributionStockArticleEntity . getDealerCode ( ) ) ;
entity . setDealerName ( distributionStockArticleEntity . getDealerName ( ) ) ;
entity . setWarehouseEntryTimeEnd ( rukuTime ) ;
entity . setMaterialCode ( vo . getMaterialCode ( ) ) ;
entity . setMaterialName ( vo . getMaterialName ( ) ) ;
entity . setCreateUser ( 1714696768639311873L ) ;
entity . setUpdateUser ( 1714696768639311873L ) ;
entity . setCreateDept ( 1649331096241836033L ) ;
entity . setTenantId ( TenantNum . HUITONGCODE ) ;
if ( StringUtil . isNotBlank ( entity . getMaterialName ( ) ) & & StringUtil . isNotBlank ( entity . getMaterialCode ( ) ) ) {
// 查询物料信息
String sku = "" ;
BasicMaterialEntity basicMaterialEntity = basicMaterialClient . getMaterialOwn ( entity . getMaterialCode ( ) , entity . getMaterialName ( ) , sku ) ;
if ( ObjectUtils . isNotNull ( basicMaterialEntity ) ) {
entity . setMaterialId ( basicMaterialEntity . getId ( ) ) ;
entity . setMaterialCode ( basicMaterialEntity . getProductCode ( ) ) ;
entity . setMaterialUnit ( basicMaterialEntity . getLogpmUnit ( ) ) ;
}
}
boolean b = distributionParcelListClient . add ( entity ) ;
if ( ! b ) {
log . warn ( "#################handleDataToPlatform: 保存包件信息失败 orderCode={}" , entity . getOrderCode ( ) ) ;
} else {
log . info ( "################handleDataToPlatform: 保存包件成功 OrderPackageCode={}" , vo . getPacketBarCode ( ) ) ;
// distributionStockArticleClient.updateOrderInfo(orderCode,distributionStockArticleEntity.getWarehouseId());
// Integer handQuantity = distributionStockArticleEntity.getHandQuantity();
// Integer totalNumber = distributionStockArticleEntity.getTotalNumber();
//
// if(handQuantity+1 >= totalNumber){
// distributionStockArticleEntity.setCompleteSet(1);
// distributionStockArticleEntity.setOrderReceiveStatus(OrderReceiveStatusConstant.yishouhuo.getValue());
// distributionStockArticleEntity.setOrderStatus(OrderStatusConstant.ruku.getValue());
// }else{
// distributionStockArticleEntity.setCompleteSet(0);
// distributionStockArticleEntity.setOrderReceiveStatus(OrderReceiveStatusConstant.bufenshouhuo.getValue());
// distributionStockArticleEntity.setOrderStatus(OrderStatusConstant.bufenruku.getValue());
// }
// distributionStockArticleEntity.setHandQuantity(handQuantity + 1);
// distributionStockArticleClient.saveOrUpdate(distributionStockArticleEntity);
}
}
}
private void buildDealerAndStore ( DistributionStockArticleEntity distributionStockArticleEntity , AdvanceEntity advanceEntity ) {
// 进销商信息从来系统获取
distributionStockArticleEntity . setStoreName ( advanceEntity . getStoreName ( ) ) ;
distributionStockArticleEntity . setStoreCode ( advanceEntity . getStoreNo ( ) ) ;
// 最终客户
distributionStockArticleEntity . setCustomerName ( advanceEntity . getCustomerName ( ) ) ;
distributionStockArticleEntity . setCustomerAddress ( advanceEntity . getCustomerRoad ( ) ) ;
distributionStockArticleEntity . setCustomerTelephone ( advanceEntity . getCustomerPhone ( ) ) ;
// 服务号
distributionStockArticleEntity . setServiceNumber ( advanceEntity . getServiceNum ( ) ) ;
distributionStockArticleEntity . setDescriptionGoods ( advanceEntity . getFirstPackName ( ) ) ;
// 品牌
distributionStockArticleEntity . setBrand ( advanceEntity . getType ( ) ) ;
distributionStockArticleEntity . setResource ( advanceEntity . getSystemType ( ) ) ;
}
private String getPeisongTypeByClientId ( Long id ) {
BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient . findByClientIdAndTypeService ( id , 3 ) ;
log . info ( ">>>>>>> 查询客户的配送类型{}" , basicdataStoreBusinessEntity ) ;
if ( ObjectUtil . isEmpty ( basicdataStoreBusinessEntity ) ) {
return null ;
}
return basicdataStoreBusinessEntity . getMold ( ) ;
}
private WayBillEntity saveWaybillEntity ( String waybillNo ) {
log . info ( "#################handleDataToPlatform.saveWaybillEntity: {}" , waybillNo ) ;
if ( StringUtil . isBlank ( waybillNo ) ) {
return null ;
}
//如果新系统中不存在这个运单,那么就去查询老系统的运单数据
WayBillEntity wayBillEntity = wayBillClient . getByWaybillNo ( waybillNo ) ;
//通过运单号先去查询新系统是否存在这个运单号
WarehouseWaybillEntity warehouseWaybill = warehouseWaybillService . findByWaybillNo ( waybillNo ) ;
log . info ( "#################handleDataToPlatform.warehouseWaybill: {}" , warehouseWaybill ) ;
if ( Objects . isNull ( warehouseWaybill ) ) {
log . info ( "#################handleDataToPlatform.wayBillEntity: {}" , wayBillEntity ) ;
if ( Objects . isNull ( wayBillEntity ) ) {
log . warn ( "##############saveWaybillEntity: 老系统中未找到对应运单waybillNo={}" , waybillNo ) ;
throw new CustomerException ( "老系统中未找到对应运单" ) ;
}
String startSite = wayBillEntity . getStartSite ( ) ; //始发仓名称
BasicdataWarehouseEntity starthouse = basicdataWarehouseClient . findByName ( startSite ) ;
String warehouseName = wayBillEntity . getWarehouseName ( ) ; //目的仓
BasicdataWarehouseEntity endhouse = basicdataWarehouseClient . findByName ( warehouseName ) ;
Integer number = wayBillEntity . getNumber ( ) ; //运单总数量
String packname = wayBillEntity . getPackname ( ) ;
String agent = wayBillEntity . getAgent ( ) ;
warehouseWaybill = new WarehouseWaybillEntity ( ) ;
warehouseWaybill . setWaybillNo ( waybillNo ) ;
warehouseWaybill . setOrderNo ( wayBillEntity . getOrderNo ( ) ) ;
warehouseWaybill . setDestinationWarehouseName ( warehouseName ) ;
warehouseWaybill . setDestinationWarehouseId ( Objects . isNull ( endhouse ) ? null : endhouse . getId ( ) ) ;
warehouseWaybill . setDepartureWarehouseName ( startSite ) ;
warehouseWaybill . setDepartureWarehouseId ( Objects . isNull ( starthouse ) ? null : starthouse . getId ( ) ) ;
warehouseWaybill . setCustomerTrain ( wayBillEntity . getCarNo ( ) ) ;
warehouseWaybill . setBrand ( wayBillEntity . getBrand ( ) ) ;
String sendCompany = wayBillEntity . getSendCompany ( ) ; //发货单位
String takeCompany = wayBillEntity . getTakeCompany ( ) ; //收货单位
BasicdataClientEntity sendClient = basicdataClientClient . findByName ( sendCompany ) ;
BasicdataClientEntity takeClient = basicdataClientClient . findByName ( takeCompany ) ;
if ( ! Objects . isNull ( sendClient ) ) {
Long clientEntityId = sendClient . getId ( ) ; //基础客户
warehouseWaybill . setShipperId ( clientEntityId ) ;
}
if ( ! Objects . isNull ( takeClient ) ) {
Long clientEntityId = takeClient . getId ( ) ; //基础客户
BasicdataStoreBusinessEntity basicdataStoreBusinessEntity = basicdataStoreBusinessClient . findByClientIdAndTypeService ( clientEntityId , 3 ) ;
if ( ! Objects . isNull ( basicdataStoreBusinessEntity ) ) {
warehouseWaybill . setServiceType ( Integer . parseInt ( basicdataStoreBusinessEntity . getMold ( ) ) ) ;
}
warehouseWaybill . setConsigneeId ( clientEntityId ) ;
}
warehouseWaybill . setShipper ( sendCompany ) ;
warehouseWaybill . setShipperName ( wayBillEntity . getSendPerson ( ) ) ;
warehouseWaybill . setShipperMobile ( wayBillEntity . getSendMobile ( ) ) ;
warehouseWaybill . setShipperAddress ( wayBillEntity . getSendAddress ( ) ) ;
warehouseWaybill . setConsignee ( takeCompany ) ;
warehouseWaybill . setConsigneeName ( wayBillEntity . getTakePerson ( ) ) ;
warehouseWaybill . setConsigneeMobile ( wayBillEntity . getTakeMobile ( ) ) ;
warehouseWaybill . setConsigneeAddress ( wayBillEntity . getTakeAddress ( ) ) ;
warehouseWaybill . setDestination ( wayBillEntity . getArriveSite ( ) ) ;
warehouseWaybill . setGoodsName ( packname ) ;
warehouseWaybill . setTotalCount ( number ) ;
warehouseWaybill . setStockCount ( number ) ;
warehouseWaybill . setTotalWeight ( wayBillEntity . getWeight ( ) ) ;
warehouseWaybill . setTotalVolume ( wayBillEntity . getVolume ( ) ) ;
warehouseWaybill . setDeliveryMethod ( wayBillEntity . getSendType ( ) ) ;
warehouseWaybill . setUrgency ( wayBillEntity . getUrgency ( ) + "" ) ;
warehouseWaybill . setReceiptCount ( wayBillEntity . getReceiptNum ( ) ) ;
warehouseWaybill . setReceiptRequirement ( wayBillEntity . getReceiptAsk ( ) ) ;
//--------------2023-07-28-------------
warehouseWaybill . setCollectPay ( wayBillEntity . getDPay ( ) ) ;
warehouseWaybill . setReceivedCollectPay ( BigDecimal . ZERO ) ;
warehouseWaybill . setReplacePrice ( wayBillEntity . getReplacePrice ( ) ) ;
warehouseWaybill . setReceivedReplacePrice ( BigDecimal . ZERO ) ;
warehouseWaybill . setReceivedTotalPrice ( BigDecimal . ZERO ) ;
warehouseWaybill . setWaybillType ( wayBillEntity . getType ( ) ) ;
warehouseWaybill . setReceivedStatus ( 0 ) ;
warehouseWaybill . setTotalFreight ( wayBillEntity . getFreight ( ) ) ;
warehouseWaybill . setDeliveryFee ( wayBillEntity . getDeliveryCost ( ) ) ;
warehouseWaybill . setPickupFee ( wayBillEntity . getTakeCost ( ) ) ;
warehouseWaybill . setWarehouseManagementFee ( wayBillEntity . getWarehouseManagementFee ( ) ) ;
warehouseWaybill . setStorageFee ( wayBillEntity . getWarehousingFee ( ) ) ;
warehouseWaybill . setHandlingFee ( wayBillEntity . getPretendCost ( ) ) ;
warehouseWaybill . setOtherFee ( wayBillEntity . getOtherFee ( ) ) ;
warehouseWaybill . setInsuranceFee ( wayBillEntity . getPriceProtectionFee ( ) ) ;
warehouseWaybill . setClaimingValue ( wayBillEntity . getValue ( ) ) ;
warehouseWaybill . setPayType ( wayBillEntity . getPayType ( ) + "" ) ;
warehouseWaybill . setPayWay ( wayBillEntity . getPaymentMethod ( ) + "" ) ;
warehouseWaybill . setXPay ( wayBillEntity . getXPay ( ) ) ;
warehouseWaybill . setDPay ( wayBillEntity . getDPay ( ) ) ;
warehouseWaybill . setHPay ( wayBillEntity . getHPay ( ) ) ;
warehouseWaybill . setYPay ( wayBillEntity . getYPay ( ) ) ;
warehouseWaybill . setThirdOperationFee ( wayBillEntity . getThreeHandleFee ( ) ) ;
warehouseWaybill . setDeliveryWay ( wayBillEntity . getSendType ( ) + "" ) ;
warehouseWaybill . setUrgency ( wayBillEntity . getUrgency ( ) + "" ) ;
warehouseWaybill . setReceipt ( wayBillEntity . getReceiptAsk ( ) ) ;
warehouseWaybill . setReceiptNum ( wayBillEntity . getReceiptNum ( ) ) ;
warehouseWaybill . setTransportType ( wayBillEntity . getShippingType ( ) + "" ) ;
warehouseWaybill . setRebate ( wayBillEntity . getRebate ( ) ) ;
BasicdataClientEntity agentClient = basicdataClientClient . findByName ( agent ) ;
if ( ! Objects . isNull ( agentClient ) ) {
Long clientEntityId = agentClient . getId ( ) ; //基础客户
warehouseWaybill . setAgentId ( clientEntityId ) ;
}
Date date = new Date ( ) ;
warehouseWaybill . setAgent ( agent ) ;
warehouseWaybill . setDocumentMakingTime ( wayBillEntity . getPreparationTime ( ) ) ;
warehouseWaybill . setRemark ( wayBillEntity . getMsg ( ) ) ;
warehouseWaybill . setBatchNo ( wayBillEntity . getStartCarsNo ( ) ) ;
warehouseWaybill . setFreezeStatus ( 0 ) ;
warehouseWaybill . setStatus ( 0 ) ;
warehouseWaybill . setIsDeleted ( 0 ) ;
warehouseWaybill . setCreateTime ( date ) ;
warehouseWaybill . setUpdateTime ( date ) ;
warehouseWaybillService . save ( warehouseWaybill ) ;
} else {
// warehouseWaybill.setStockCount(warehouseWaybill.getStockCount() + 1);
warehouseWaybill . setUpdateTime ( new Date ( ) ) ;
warehouseWaybillService . updateById ( warehouseWaybill ) ;
}
//暂存单与运单的关联
saveAdvanceData ( warehouseWaybill ) ;
return wayBillEntity ;
}
private void saveAdvanceData ( WarehouseWaybillEntity warehouseWaybill ) {
String waybillNo = warehouseWaybill . getWaybillNo ( ) ;
Long waybillId = warehouseWaybill . getId ( ) ;
//查看新系统是否有关联数据
List < TrunklineWaybillOrderEntity > waybillOrderList = waybillOrderClient . findListByWaybillNo ( waybillNo ) ;
if ( waybillOrderList . isEmpty ( ) ) {
//没有关联订单数据
//查老系统的运单关联哪些订单
List < Integer > advanceIds = wayBillClient . findAdvanceIdsByWaybillNo ( waybillNo ) ;
if ( advanceIds . isEmpty ( ) ) {
log . warn ( "#############saveAdvanceData: 老系统运单未有关联订单 waybillNo={}" , waybillNo ) ;
throw new CustomerException ( 405 , "老系统运单未有关联订单" ) ;
}
List < AdvanceEntity > advanceList = advanceClient . findListByAdvanceIds ( advanceIds ) ;
for ( AdvanceEntity advanceEntity : advanceList ) {
Integer advanceId = advanceEntity . getId ( ) ;
Integer oldWarehouseId = advanceEntity . getWarehouseId ( ) ;
String orderCode = advanceEntity . getOrderSelfNum ( ) ;
Integer totalNum = advanceEntity . getTotal ( ) ;
String brand = advanceEntity . getType ( ) ;
BasicdataWarehouseEntity basicdataWarehouseEntity = basicdataWarehouseClient . getWarehouseByOldId ( oldWarehouseId ) ;
Date date = new Date ( ) ;
TrunklineAdvanceEntity trunklineAdvanceEntity = new TrunklineAdvanceEntity ( ) ;
trunklineAdvanceEntity . setTenantId ( TenantNum . HUITONGCODE ) ;
trunklineAdvanceEntity . setCreateUser ( 1714696768639311873L ) ;
trunklineAdvanceEntity . setCreateTime ( date ) ;
trunklineAdvanceEntity . setUpdateUser ( 1714696768639311873L ) ;
trunklineAdvanceEntity . setUpdateTime ( date ) ;
trunklineAdvanceEntity . setStatus ( 1 ) ;
trunklineAdvanceEntity . setIsDeleted ( 0 ) ;
trunklineAdvanceEntity . setCreateDept ( 1649331096241836033L ) ;
trunklineAdvanceEntity . setWarehouseId ( basicdataWarehouseEntity . getId ( ) ) ;
trunklineAdvanceEntity . setWarehouseName ( basicdataWarehouseEntity . getName ( ) ) ;
trunklineAdvanceEntity . setOrderCode ( orderCode ) ;
trunklineAdvanceEntity . setSiteName ( advanceEntity . getSiteName ( ) ) ;
trunklineAdvanceEntity . setArea ( advanceEntity . getArea ( ) ) ;
trunklineAdvanceEntity . setOrderType ( advanceEntity . getOrderTypeName ( ) ) ;
trunklineAdvanceEntity . setBrand ( advanceEntity . getType ( ) ) ;
trunklineAdvanceEntity . setTotalNum ( totalNum ) ;
trunklineAdvanceEntity . setPackCode ( advanceEntity . getFirstPackCode ( ) ) ;
trunklineAdvanceEntity . setPackName ( advanceEntity . getFirstPackName ( ) ) ;
trunklineAdvanceEntity . setDealerCode ( advanceEntity . getDealerCode ( ) ) ;
trunklineAdvanceEntity . setDealerName ( advanceEntity . getDealerName ( ) ) ;
trunklineAdvanceEntity . setCarrierName ( advanceEntity . getCarrierName ( ) ) ;
trunklineAdvanceEntity . setCustomerName ( advanceEntity . getCustomerName ( ) ) ;
trunklineAdvanceEntity . setCustomerPhone ( advanceEntity . getCustomerPhone ( ) ) ;
trunklineAdvanceEntity . setCustomerAddress ( advanceEntity . getCustomerRoad ( ) ) ;
trunklineAdvanceEntity . setSystemType ( advanceEntity . getSystemType ( ) ) ;
trunklineAdvanceEntity . setStoreCode ( advanceEntity . getStoreNo ( ) ) ;
trunklineAdvanceEntity . setStoreName ( advanceEntity . getStoreName ( ) ) ;
trunklineAdvanceEntity . setServiceNum ( advanceEntity . getServiceNum ( ) ) ;
trunklineAdvanceEntity . setMatingType ( advanceEntity . getMatingCode ( ) ) ;
trunklineAdvanceEntity . setSenderName ( advanceEntity . getSenderName ( ) ) ;
trunklineAdvanceEntity . setSenderPhone ( advanceEntity . getSenderMobile ( ) ) ;
trunklineAdvanceEntity . setSenderAddress ( advanceEntity . getSenderAddress ( ) ) ;
Integer waybillStatus = advanceEntity . getWaybillStatus ( ) ;
if ( waybillStatus = = 1 ) {
trunklineAdvanceEntity . setWaybillStatus ( "0" ) ;
} else if ( waybillStatus = = 2 ) {
trunklineAdvanceEntity . setWaybillStatus ( "1" ) ;
}
trunklineAdvanceEntity . setWaybillNo ( advanceEntity . getWaybillNo ( ) ) ;
trunklineAdvanceEntity . setTrainNumber ( advanceEntity . getMctsTruck ( ) ) ;
Integer freeze = advanceEntity . getFreeze ( ) ;
if ( freeze = = 1 ) {
trunklineAdvanceEntity . setFreezeStatus ( "0" ) ;
} else if ( freeze = = 2 ) {
trunklineAdvanceEntity . setFreezeStatus ( "1" ) ;
}
String leaveBehind = advanceEntity . getLeaveBehind ( ) ;
if ( "N" . equals ( leaveBehind ) ) {
trunklineAdvanceEntity . setLegacyStatus ( "0" ) ;
} else if ( "Y" . equals ( leaveBehind ) ) {
trunklineAdvanceEntity . setLegacyStatus ( "1" ) ;
}
trunklineAdvanceEntity . setDeliveryDate ( CommonUtil . StringToDate ( advanceEntity . getDueDate ( ) ) ) ;
Long newAdvanceId = trunklineAdvanceClient . addAdvanceReturnId ( trunklineAdvanceEntity ) ;
if ( Objects . isNull ( newAdvanceId ) ) {
log . warn ( "#############saveAdvanceData: 保存暂存单失败 orderCode={}" , orderCode ) ;
continue ;
} else {
//生成对应的运单关联订单信息
TrunklineWaybillOrderEntity trunklineWaybillOrderEntity = new TrunklineWaybillOrderEntity ( ) ;
trunklineWaybillOrderEntity . setTenantId ( TenantNum . HUITONGCODE ) ;
trunklineWaybillOrderEntity . setCreateUser ( 1714696768639311873L ) ;
trunklineWaybillOrderEntity . setCreateTime ( date ) ;
trunklineWaybillOrderEntity . setUpdateUser ( 1714696768639311873L ) ;
trunklineWaybillOrderEntity . setUpdateTime ( date ) ;
trunklineWaybillOrderEntity . setStatus ( 1 ) ;
trunklineWaybillOrderEntity . setIsDeleted ( 0 ) ;
trunklineWaybillOrderEntity . setCreateDept ( 1649331096241836033L ) ;
trunklineWaybillOrderEntity . setWarehouseId ( basicdataWarehouseEntity . getId ( ) ) ;
trunklineWaybillOrderEntity . setWaybillNo ( basicdataWarehouseEntity . getName ( ) ) ;
trunklineWaybillOrderEntity . setWaybillId ( waybillId ) ;
trunklineWaybillOrderEntity . setWaybillNo ( waybillNo ) ;
trunklineWaybillOrderEntity . setAdvanceId ( newAdvanceId ) ;
trunklineWaybillOrderEntity . setOrderCode ( orderCode ) ;
trunklineWaybillOrderEntity . setTotalNumber ( totalNum ) ;
trunklineWaybillOrderEntity . setHandleNumber ( 0 ) ;
waybillOrderClient . addEntityReturnId ( trunklineWaybillOrderEntity ) ;
//查询暂存单包件
List < AdvanceDetailEntity > detailList = advanceDetailClient . findListByAdvanceId ( advanceId ) ;
List < TrunklineAdvanceDetailEntity > newPackageList = new ArrayList < > ( ) ;
for ( AdvanceDetailEntity advanceDetailEntity : detailList ) {
String unitNo = advanceDetailEntity . getUnitNo ( ) ;
TrunklineAdvanceDetailEntity trunklineAdvanceDetailEntity = new TrunklineAdvanceDetailEntity ( ) ;
trunklineAdvanceDetailEntity . setTenantId ( TenantNum . HUITONGCODE ) ;
trunklineAdvanceDetailEntity . setCreateUser ( 1714696768639311873L ) ;
trunklineAdvanceDetailEntity . setCreateTime ( date ) ;
trunklineAdvanceDetailEntity . setUpdateUser ( 1714696768639311873L ) ;
trunklineAdvanceDetailEntity . setUpdateTime ( date ) ;
trunklineAdvanceDetailEntity . setStatus ( 1 ) ;
trunklineAdvanceDetailEntity . setIsDeleted ( 0 ) ;
trunklineAdvanceDetailEntity . setCreateDept ( 1649331096241836033L ) ;
trunklineAdvanceDetailEntity . setWarehouseId ( basicdataWarehouseEntity . getId ( ) ) ;
trunklineAdvanceDetailEntity . setWarehouseName ( basicdataWarehouseEntity . getName ( ) ) ;
trunklineAdvanceDetailEntity . setAdvanceId ( newAdvanceId ) ;
trunklineAdvanceDetailEntity . setOrderCode ( advanceDetailEntity . getOrderSelfNum ( ) ) ;
trunklineAdvanceDetailEntity . setBrand ( advanceDetailEntity . getType ( ) ) ;
trunklineAdvanceDetailEntity . setSystemType ( advanceDetailEntity . getSystemType ( ) ) ;
trunklineAdvanceDetailEntity . setFirstPackName ( advanceDetailEntity . getFirstPackName ( ) ) ;
trunklineAdvanceDetailEntity . setSecondPackName ( advanceDetailEntity . getSecondPackName ( ) ) ;
trunklineAdvanceDetailEntity . setThirdPackName ( advanceDetailEntity . getThirdPackName ( ) ) ;
trunklineAdvanceDetailEntity . setSiteCode ( advanceDetailEntity . getSiteCode ( ) ) ;
trunklineAdvanceDetailEntity . setSiteName ( advanceDetailEntity . getSiteName ( ) ) ;
trunklineAdvanceDetailEntity . setQuantity ( new BigDecimal ( advanceDetailEntity . getMscsNum ( ) ) . intValue ( ) ) ;
trunklineAdvanceDetailEntity . setOrderPackageCode ( unitNo ) ;
trunklineAdvanceDetailEntity . setTrainNumber ( advanceDetailEntity . getMctsTruck ( ) ) ;
trunklineAdvanceDetailEntity . setServiceNum ( advanceDetailEntity . getServiceNum ( ) ) ;
trunklineAdvanceDetailEntity . setWaybillNo ( waybillNo ) ;
trunklineAdvanceDetailEntity . setPackageStatus ( "1" ) ;
trunklineAdvanceDetailEntity . setChargeType ( 1 ) ;
newPackageList . add ( trunklineAdvanceDetailEntity ) ;
//同步包内明细
List < DetailProductEntity > detailProductList = detailProductClient . findListByUnitNo ( unitNo ) ;
List < TrunklineDetailProductEntity > trunklineDetailProductEntities = new ArrayList < > ( ) ;
for ( DetailProductEntity detailProductEntity : detailProductList ) {
TrunklineDetailProductEntity trunklineDetailProductEntity = new TrunklineDetailProductEntity ( ) ;
trunklineDetailProductEntity . setTenantId ( TenantNum . HUITONGCODE ) ;
trunklineDetailProductEntity . setCreateUser ( 1714696768639311873L ) ;
trunklineDetailProductEntity . setCreateTime ( date ) ;
trunklineDetailProductEntity . setUpdateUser ( 1714696768639311873L ) ;
trunklineDetailProductEntity . setUpdateTime ( date ) ;
trunklineDetailProductEntity . setStatus ( 1 ) ;
trunklineDetailProductEntity . setIsDeleted ( 0 ) ;
trunklineDetailProductEntity . setCreateDept ( 1649331096241836033L ) ;
trunklineDetailProductEntity . setWarehouseId ( basicdataWarehouseEntity . getId ( ) ) ;
trunklineDetailProductEntity . setWarehouseName ( basicdataWarehouseEntity . getName ( ) ) ;
trunklineDetailProductEntity . setUnitNo ( detailProductEntity . getUnitNo ( ) ) ;
trunklineDetailProductEntity . setProductCode ( detailProductEntity . getProductcode ( ) ) ;
trunklineDetailProductEntity . setProductName ( detailProductEntity . getProductname ( ) ) ;
trunklineDetailProductEntity . setQuantity ( detailProductEntity . getDelivernum ( ) ) ;
trunklineDetailProductEntities . add ( trunklineDetailProductEntity ) ;
}
trunklineDetailProductClient . addListEntity ( trunklineDetailProductEntities ) ;
}
trunklineAdvanceDetailClient . addAdvanceBatch ( newPackageList ) ;
}
}
log . info ( "##############saveAdvanceData: 运单同步已完成 waybillNo={}" , waybillNo ) ;
} else {
log . info ( "##############saveAdvanceData: 运单已有关联订单 waybillNo={}" , waybillNo ) ;
}
}
private R moveTrayOrderPackageCode ( WarehouseTrayTypeEntity trayTypeEntity , String orderPackageCode ) {
Long wid = trayTypeEntity . getWarehouseId ( ) ;