@ -4,14 +4,8 @@ import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils ;
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.basicdata.entity.* ;
import com.logpm.basicdata.feign.* ;
import com.logpm.distribution.entity.DistributionParcelListEntity ;
import com.logpm.distribution.entity.DistributionParcelNumberEntity ;
import com.logpm.distribution.entity.DistributionStockArticleEntity ;
@ -25,6 +19,7 @@ import com.logpm.patch.service.ISyncOrderInfoService;
import com.logpm.warehouse.entity.WarehouseWayBillDetail ;
import com.logpm.warehouse.entity.WarehouseWaybillEntity ;
import com.logpm.warehouse.feign.IWarehouseTrayTypeClient ;
import com.logpm.warehouse.feign.IWarehouseUpdownTypeClient ;
import com.logpm.warehouse.feign.IWarehouseWaybillClient ;
import com.logpm.warehouse.feign.IWarehouseWaybillDetailClient ;
import lombok.AllArgsConstructor ;
@ -69,29 +64,32 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
private final IInventoryDetailClient inventoryDetailClient ;
private final IBasicdataTrayClient basicdataTrayClient ;
private final ITrayClient trayClient ;
private final IBasicdataGoodsAllocationClient basicdataGoodsAllocationClient ;
private final IOrderLocationClient orderLocationClient ;
private final IWarehouseUpdownTypeClient warehouseUpdownTypeClient ;
@Transactional ( rollbackFor = Exception . class )
@Override
public void handleData ( List < String > orderCodeList , Integer oldWarehouseId , Long newWarehouseId , Integer inventoryId ) {
public void handleData ( List < String > orderCodeList , Integer oldWarehouseId , Long newWarehouseId ) {
log . info ( "#############handleData: 处理订单开始" ) ;
for ( String orderCode : orderCodeList ) {
log . info ( "#############handleData: 当前处理orderCode={}的订单 盘点任务 inventoryId={} " , orderCode , inventoryId ) ;
log . info ( "#############handleData: 当前处理orderCode={}的订单 " , orderCode ) ;
// DistributionStockArticleEntity stockArticleEntity = distributionStockArticleClient.findStockArticleByOrderCode(orderCode);
// if(!Objects.isNull(stockArticleEntity)){
// log.info("#############handleData: 订单orderCode={}已存在",orderCode);
// continue;
// }
//查询订单是否在盘点任务中有被盘点到
InventoryDetailEntity inventoryDetailEntity = inventoryDetailClient . findOrderIsExist ( orderCode , inventoryId ) ;
if ( ! Objects . isNull ( inventoryDetailEntity ) ) {
// InventoryDetailEntity inventoryDetailEntity = inventoryDetailClient.findOrderIsExist(orderCode,inventoryId);
// if(!Objects.isNull(inventoryDetailEntity)){
try {
//定单
saveOrderInfo ( orderCode , oldWarehouseId , newWarehouseId , inventoryId ) ;
saveOrderInfo ( orderCode , oldWarehouseId , newWarehouseId ) ;
//存入打托信息
// saveTrayTypeInfoPackage(orderCode,oldWarehouseId,newWarehouseId);
saveTrayTypeInfoPackageNew ( orderCode , oldWarehouseId , newWarehouseId , inventory Id ) ;
saveTrayTypeInfoPackage ( orderCode , oldWarehouseId , newWarehouseId ) ;
} catch ( CustomerException e ) {
log . error ( "同步订单" + orderCode + "失败: " + e . message , e ) ;
@ -99,10 +97,84 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
log . error ( "同步订单" + orderCode + "失败" , e ) ;
}
// }
}
}
@Transactional ( rollbackFor = Exception . class )
@Override
public void handleDataAndInventoryId ( List < String > orderCodeList , Integer oldWarehouseId , Long newWarehouseId , Integer inventoryId ) {
log . info ( "#############handleData: 处理订单开始" ) ;
for ( String orderCode : orderCodeList ) {
log . info ( "#############handleData: 当前处理orderCode={}的订单 盘点任务 inventoryId={}" , orderCode , inventoryId ) ;
// DistributionStockArticleEntity stockArticleEntity = distributionStockArticleClient.findStockArticleByOrderCode(orderCode);
// if(!Objects.isNull(stockArticleEntity)){
// log.info("#############handleData: 订单orderCode={}已存在",orderCode);
// continue;
// }
//查询订单是否在盘点任务中有被盘点到
// InventoryDetailEntity inventoryDetailEntity = inventoryDetailClient.findOrderIsExist(orderCode,inventoryId);
// if(!Objects.isNull(inventoryDetailEntity)){
try {
//定单
saveOrderInfoAndInventoryId ( orderCode , oldWarehouseId , newWarehouseId , inventoryId ) ;
//存入打托信息
// saveTrayTypeInfoPackage(orderCode,oldWarehouseId,newWarehouseId);
saveTrayTypeInfoPackageNew ( orderCode , oldWarehouseId , newWarehouseId , inventoryId ) ;
} catch ( CustomerException e ) {
log . error ( "同步订单" + orderCode + "失败: " + e . message , e ) ;
} catch ( Exception e ) {
log . error ( "同步订单" + orderCode + "失败" , e ) ;
}
// }
}
}
@Override
public void syncUpdownData ( Integer oldWarehouseId , Long newWarehouseId ) {
//先查询有多少个货位
List < BasicdataGoodsAllocationEntity > ls = basicdataGoodsAllocationClient . findListByNewWarehouseId ( newWarehouseId ) ;
for ( BasicdataGoodsAllocationEntity basicdataGoodsAllocationEntity : ls ) {
Long locationId = basicdataGoodsAllocationEntity . getId ( ) ;
List < OrderLocationEntity > orderLocationEntityList = orderLocationClient . findListByLocationId ( locationId . intValue ( ) ) ;
for ( OrderLocationEntity orderLocationEntity : orderLocationEntityList ) {
Integer type = orderLocationEntity . getType ( ) ;
if ( type = = 4 ) {
//整托上架
Integer trayId = orderLocationEntity . getTrayId ( ) ;
String trayCode = "T" + trayId ;
boolean a = warehouseUpdownTypeClient . upShelfTray ( trayCode , locationId , newWarehouseId ) ;
if ( a ) {
log . info ( "#############syncUpdownData: 上架托盘成功 trayCode={} locationId={}" , trayCode , locationId ) ;
} else {
log . error ( "#############syncUpdownData: XXXX上架托盘失败 trayCode={} locationId={}" , trayCode , locationId ) ;
}
} else {
String orderPackageCode = orderLocationEntity . getUnitNo ( ) ;
boolean a = warehouseUpdownTypeClient . upShelfPackage ( orderPackageCode , locationId , newWarehouseId ) ;
if ( a ) {
log . info ( "#############syncUpdownData: 上架包件成功 orderPackageCode={} locationId={}" , orderPackageCode , locationId ) ;
} else {
log . error ( "#############syncUpdownData: XXXX上架包件失败 orderPackageCode={} locationId={}" , orderPackageCode , locationId ) ;
}
}
}
}
}
@Transactional ( rollbackFor = Exception . class )
@Override
public void handleDataZero ( List < String > orderCodeList , Integer oldWarehouseId , Long newWarehouseId ) {
@ -459,15 +531,31 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
Integer trayScanId = trayScanDesEntity . getTrayScanId ( ) ;
String unitNo = trayScanDesEntity . getUnitNo ( ) ; //包条码
// InventoryDetailEntity inventoryDetailEntity = inventoryDetailClient.findUnitNoIsExist(unitNo);
// if(Objects.isNull(inventoryDetailEntity)){
// log.info("###########saveTrayTypeInfoPackage: 包条不在盘点任务中存在,不同步 unitNo={}",unitNo);
// continue;
// }
//查询打托方式信息
TrayScanEntity trayScanEntity = trayScanClient . getEntityByTrayScanId ( trayScanId ) ;
Integer type = trayScanEntity . getType ( ) ;
Integer trayId = trayScanEntity . getTrayId ( ) ;
BasicdataTrayEntity basicdataTrayEntity = basicdataTrayClient . getTrayByTrayCode ( "T" + trayId ) ;
if ( Objects . isNull ( basicdataTrayEntity ) ) {
log . info ( "############syncTrayTypeData: 托盘信息不存在" ) ;
//如果托盘不存在就去同步该托盘
TrayEntity trayEntity = trayClient . getTrayById ( trayId ) ;
basicdataTrayEntity = new BasicdataTrayEntity ( ) ;
basicdataTrayEntity . setTenantId ( "627683" ) ;
basicdataTrayEntity . setCreateUser ( 1714696768639311873L ) ;
basicdataTrayEntity . setUpdateUser ( 1714696768639311873L ) ;
basicdataTrayEntity . setCreateDept ( 1649331096241836033L ) ;
basicdataTrayEntity . setPalletName ( trayEntity . getTrayNo ( ) ) ;
basicdataTrayEntity . setPalletCode ( "T" + trayId ) ;
basicdataTrayEntity . setWarehouseId ( newWarehouseId ) ;
basicdataTrayEntity . setTrayStatus ( trayEntity . getStatus ( ) + "" ) ;
basicdataTrayEntity . setType ( 1 ) ;
basicdataTrayEntity . setOldId ( trayId ) ;
// basicdataTrayEntity.setNowWarehouseId(nowNewWarehouseId);
basicdataTrayClient . addTray ( basicdataTrayEntity ) ;
}
String customerName = trayScanEntity . getCustomerName ( ) ;
String customerPhone = trayScanEntity . getCustomerPhone ( ) ;
@ -880,7 +968,7 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
}
private void saveOrderInfo ( String orderCode , Integer oldWarehouseId , Long newWarehouseId , Integer inventoryId ) {
private void saveOrderInfoAndInventoryId ( String orderCode , Integer oldWarehouseId , Long newWarehouseId , Integer inventoryId ) {
//通过订单号查询暂存单
AdvanceEntity advanceEntity = advanceClient . getQueryDataOne ( orderCode ) ;
@ -890,7 +978,7 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
}
Integer advanceId = advanceEntity . getId ( ) ;
//判断新系统是否有这条订单数据
DistributionStockArticleEntity distributionStockArticleEntity = distributionStockArticleClient . findByAdvanceId ( advanc eId ) ;
DistributionStockArticleEntity distributionStockArticleEntity = distributionStockArticleClient . findStockArticleByOrderCodeAndWarehouseId ( orderCode , newWarehous eId ) ;
OrderCountEntity orderCountEntity = orderCountClient . getEntityByOrderCode ( orderCode , oldWarehouseId ) ;
if ( Objects . isNull ( orderCountEntity ) ) {
@ -900,17 +988,12 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
Integer total = orderCountEntity . getTotal ( ) ;
WayBillEntity wayBillEntity = wayBillClient . getByWayBillByAdvanceId ( advanceId ) ;
// if(Objects.isNull(wayBillEntity)){
// log.warn("#################saveOrderInfo: 未查询到运单信息 advanceId={}",advanceId);
// throw new CustomerException(403,"未查询到运单信息");
// }
BasicdataWarehouseEntity basicdataWarehouseEntity = basicdataWarehouseClient . getEntityWarehouseId ( newWarehouseId ) ;
if ( Objects . isNull ( basicdataWarehouseEntity ) ) {
log . warn ( "#################saveOrderInfo: 未查询到仓库信息 newWarehouseId={}" , newWarehouseId ) ;
throw new CustomerException ( 403 , "未查询到仓库信息" ) ;
}
Long id ;
String wayBillNo = null ;
@ -919,34 +1002,15 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
distributionStockArticleEntity = new DistributionStockArticleEntity ( ) ;
distributionStockArticleEntity . setOrderCode ( orderCode ) ;
// 其实是客户
// distributionStockArticleEntity.setMallName(advanceEntity.getDealerName());
distributionStockArticleEntity . setWarehouseEntryTime ( orderCountEntity . getCreateTime ( ) ) ;
distributionStockArticleEntity . setWarehouseEntryTimeEnd ( orderCountEntity . getLatestInTime ( ) ) ;
distributionStockArticleEntity . setTotalNumber ( total ) ;
distributionStockArticleEntity . setHandQuantity ( orderCountEntity . getInNum ( ) ) ;
distributionStockArticleEntity . setHandQuantity ( 0 ) ;
distributionStockArticleEntity . setTenantId ( TenantNum . HUITONGCODE ) ; // 对应租户ID
// distributionStockArticleEntity.setWaybillNumber();// 运单号
//判断是否齐套 查询该订单自编号下面的包件是都全部都交由汇通了
Integer allNum = advanceDetailClient . getAllNumByOrderNo ( orderCode ) ;
if ( total . equals ( allNum ) ) {
//如果数据库中的数据和订单上的数量相等就是齐套
distributionStockArticleEntity . setCompleteSet ( 1 ) ;
} else {
distributionStockArticleEntity . setCompleteSet ( 0 ) ;
}
log . info ( "############saveOrderInfo {}" , basicdataWarehouseEntity ) ;
distributionStockArticleEntity . setCreateDept ( basicdataWarehouseEntity . getDepartment ( ) ) ;
distributionStockArticleEntity . setConsigneeUnit ( advanceEntity . getDealerName ( ) ) ; //收货单位(经销商)
distributionStockArticleEntity . setConsigneePerson ( advanceEntity . getCustomerName ( ) ) ; //收货人
distributionStockArticleEntity . setConsigneeAddress ( advanceEntity . getCustomerRoad ( ) ) ; //收货人地址
distributionStockArticleEntity . setConsigneeMobile ( advanceEntity . getCustomerPhone ( ) ) ; //收货人电话
distributionStockArticleEntity . setWarehouse ( basicdataWarehouseEntity . getName ( ) ) ;
distributionStockArticleEntity . setWarehouseId ( basicdataWarehouseEntity . getId ( ) ) ;
distributionStockArticleEntity . setDealerCode ( advanceEntity . getDealerCode ( ) ) ;
@ -975,14 +1039,11 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
if ( ObjectUtils . isNotNull ( t ) ) {
distributionStockArticleEntity . setAcceptWarehouseName ( t . getName ( ) ) ;
distributionStockArticleEntity . setAcceptWarehouseId ( t . getId ( ) ) ;
// TODO 这里存在问题 后需要知道当前作业仓库
// distributionStockArticleEntity.setWarehouse(t.getName());
// distributionStockArticleEntity.setWarehouseId(t.getId());
}
String customerName = wayBillEntity . getTakeCompany ( ) ; //客户名称
distributionStockArticleEntity . setTypeService ( "1" ) ; //默认商配
BasicdataClientEntity basicdataClientEntity = basicdataClientClient . findByName ( customerName ) ;
log . info ( "订单同步出现的客户编号{} 匹配的客户" , basicdataClientEntity ) ;
if ( ! Objects . isNull ( basicdataClientEntity ) ) {
@ -991,11 +1052,6 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
distributionStockArticleEntity . setMallName ( basicdataClientEntity . getClientName ( ) ) ;
distributionStockArticleEntity . setMallCode ( basicdataClientEntity . getClientCode ( ) ) ;
// distributionStockArticleEntity.setDealerCode(basicdataClientEntity.getClientCode());
// distributionStockArticleEntity.setDealerName(basicdataClientEntity.getClientName());
// todo 这里需要去查询门店 和新系统的门店ID 进行绑定
String peisongType = getPeisongTypeByClientId ( basicdataClientEntity . getId ( ) ) ;
log . info ( "订单同步peisongType {} " , peisongType ) ;
@ -1004,69 +1060,270 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
}
}
}
distributionStockArticleEntity . setGenre ( 1 ) ;
distributionStockArticleEntity . setAdvanceId ( advanceId ) ;
//--------------2023-07-06 新增字段处理
// 增加订单 经销商信息 和门店信息
buildDealerAndStore ( distributionStockArticleEntity , advanceEntity ) ;
//通过客户名称去查询客户的服务类型、
distributionStockArticleEntity . setTypeService ( "1" ) ; //默认商配
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 ( ) ) ; //上架状态
// BasicdataClientEntity basicdataClientEntity = basicdataClientClient.findByName(customerName);
// log.info("订单同步出现的客户编号{} 匹配的客户", basicdataClientEntity);
// if (!Objects.isNull(basicdataClientEntity)) {
// //商城
// distributionStockArticleEntity.setMallId(basicdataClientEntity.getId());
// distributionStockArticleEntity.setMallName(basicdataClientEntity.getClientName());
// distributionStockArticleEntity.setMallCode(basicdataClientEntity.getClientCode());
//
// distributionStockArticleEntity.setDealerCode(basicdataClientEntity.getClientCode());
// distributionStockArticleEntity.setDealerName(basicdataClientEntity.getClientName());
//
//
// // todo 这里需要去查询门店 和新系统的门店ID 进行绑定
// String peisongType = getPeisongTypeByClientId(basicdataClientEntity.getId());
// log.info("订单同步peisongType {} ", peisongType);
//
// if (StringUtil.isNoneBlank(peisongType)) {
// distributionStockArticleEntity.setTypeService(peisongType);
// }
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 ( ) ;
}
//保存包件信息
saveOrderPackageAndInventoryId ( distributionStockArticleEntity , basicdataWarehouseEntity , wayBillNo , CommonUtil . dateToString ( new Date ( ) ) , oldWarehouseId , inventoryId ) ;
}
private void saveOrderPackageAndInventoryId ( DistributionStockArticleEntity distributionStockArticleEntity , BasicdataWarehouseEntity basicdataWarehouseEntity , String waybillNo , String operationTime , Integer oldWarehouseId , Integer inventoryId ) {
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 ( "###########saveOrderPackageAndInventoryId: 包条已存在,不同步 unitNo={}" , unitNo ) ;
continue ;
}
InventoryDetailEntity inventoryDetailEntity = inventoryDetailClient . findUnitNoIsExist ( unitNo , inventoryId ) ;
if ( Objects . isNull ( inventoryDetailEntity ) ) {
log . info ( "###########saveOrderPackageAndInventoryId: 包条不在盘点任务中存在,不同步 unitNo={}" , unitNo ) ;
continue ;
}
Integer status = orderDetailEntity . getStatus ( ) ;
Integer carsType = orderDetailEntity . getCarsType ( ) ;
Integer signState = orderDetailEntity . getSignState ( ) ;
waybillNo = orderDetailEntity . getWaybillNo ( ) ;
//存入运单信息
WayBillEntity waybillEntity = saveWaybillEntity ( waybillNo ) ;
DistributionParcelListEntityVO vo = advanceDetailClient . getByUnitNoAndWarehouseId ( unitNo , oldWarehouseId ) ;
DistributionParcelListEntity entity = new DistributionParcelListEntity ( ) ;
BeanUtil . copyProperties ( vo , entity ) ;
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 ( ) ) ;
}
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 ( CommonUtil . StringToDate ( operationTime ) ) ;
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 ( "#################saveOrderPackageAndInventoryId: 保存包件信息失败 orderCode={}" , entity . getOrderCode ( ) ) ;
} else {
log . info ( "################saveOrderPackageAndInventoryId: 保存包件成功 OrderPackageCode={}" , vo . getPacketBarCode ( ) ) ;
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 ( ) ) ;
}
distributionStockArticleClient . saveOrUpdate ( distributionStockArticleEntity ) ;
}
}
}
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 = orderCountEntity . 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 ( ) ) ;
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 ( 1123598821738675201L ) ;
distributionStockArticleEntity . setSortingQuantity ( orderCountEntity . getSorting ( ) ) ; //分拣件数
distributionStockArticleEntity . setDeliveryQuantity ( orderCountEntity . getDeliveNum ( ) ) ; //配送件数
distributionStockArticleEntity . setTransferQuantity ( orderCountEntity . getTransNum ( ) ) ; //中转件数
distributionStockArticleEntity . setSigninQuantity ( orderCountEntity . getSignNum ( ) ) ; //签收件数
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 ( ) ) ; //上架状态
Integer status = orderCountEntity . getStatus ( ) ;
if ( 1 = = status ) {
distributionStockArticleEntity . setOrderStatus ( OrderStatusConstant . bufenruku . getValue ( ) ) ;
} else if ( 2 = = status ) {
distributionStockArticleEntity . setOrderStatus ( OrderStatusConstant . ruku . getValue ( ) ) ;
} else if ( 3 = = status | | 10 = = status ) {
distributionStockArticleEntity . setOrderStatus ( OrderStatusConstant . chuku . getValue ( ) ) ;
} else if ( 4 = = status ) {
distributionStockArticleEntity . setOrderStatus ( OrderStatusConstant . bufenqianshou . getValue ( ) ) ;
} else if ( 8 = = status | | 9 = = status ) {
distributionStockArticleEntity . setOrderStatus ( OrderStatusConstant . bufenchuku . getValue ( ) ) ;
} else if ( 11 = = status ) {
distributionStockArticleEntity . setOrderStatus ( OrderStatusConstant . qianshou . getValue ( ) ) ;
} else {
distributionStockArticleEntity . setOrderStatus ( "100" ) ;
}
distributionStockArticleEntity . setOrderReceiveStatus ( OrderReceiveStatusConstant . yishouhuo . getValue ( ) ) ;
distributionStockArticleEntity . setWarehouseEntryTime ( date ) ;
id = distributionStockArticleClient . addData ( distributionStockArticleEntity ) ;
@ -1080,11 +1337,11 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
}
//保存包件信息
saveOrderPackage ( distributionStockArticleEntity , basicdataWarehouseEntity , wayBillNo , CommonUtil . dateToString ( new Date ( ) ) , oldWarehouseId , inventoryId ) ;
saveOrderPackage ( distributionStockArticleEntity , basicdataWarehouseEntity , wayBillNo , CommonUtil . dateToString ( new Date ( ) ) , oldWarehouseId ) ;
}
private void saveOrderPackage ( DistributionStockArticleEntity distributionStockArticleEntity , BasicdataWarehouseEntity basicdataWarehouseEntity , String waybillNo , String operationTime , Integer oldWarehouseId , Integer inventoryId ) {
private void saveOrderPackage ( DistributionStockArticleEntity distributionStockArticleEntity , BasicdataWarehouseEntity basicdataWarehouseEntity , String waybillNo , String operationTime , Integer oldWarehouseId ) {
String orderCode = distributionStockArticleEntity . getOrderCode ( ) ;
@ -1098,11 +1355,11 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
continue ;
}
InventoryDetailEntity inventoryDetailEntity = inventoryDetailClient . findUnitNoIsExist ( unitNo , inventoryId ) ;
if ( Objects . isNull ( inventoryDetailEntity ) ) {
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 ( ) ;
@ -1121,13 +1378,14 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
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(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 ( ) ) ;
}
@ -1138,12 +1396,8 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
entity . setOrderCode ( distributionStockArticleEntity . getOrderCode ( ) ) ;
entity . setServiceNumber ( distributionStockArticleEntity . getServiceNumber ( ) ) ;
entity . setWaybillNumber ( waybillNo ) ;
// if(ObjectUtil.isNotEmpty(warehouseWaybill)){
// entity.setWarehouseId(warehouseWaybill.getId());
// }
// 增加 进销商 名称 编码 发站仓
entity . setSendWarehouseName ( distributionStockArticleEntity . getSendWarehouseName ( ) ) ;
entity . setSendWarehouseId ( distributionStockArticleEntity . getSendWarehouseId ( ) ) ;
@ -1154,22 +1408,17 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
//进销售
entity . setDealerCode ( distributionStockArticleEntity . getDealerCode ( ) ) ;
entity . setDealerName ( distributionStockArticleEntity . getDealerName ( ) ) ;
// if(Objects.isNull(waybillEntity)){
// entity.setDealerCode(distributionStockArticleEntity.getDealerCode());
// entity.setDealerName(distributionStockArticleEntity.getDealerName());
// }else{
// entity.setDealerCode(distributionStockArticleEntity.getDealerCode());
// entity.setDealerName(waybillEntity.getTakeCompany());
// }
entity . setWarehouseEntryTimeEnd ( CommonUtil . StringToDate ( operationTime ) ) ;
// 绑定部门--仓库
if ( ! Objects . isNull ( basicdataWarehouseEntity ) ) {
entity . setCreateDept ( basicdataWarehouseEntity . getDepartment ( ) ) ;
}
entity . setCreateUser ( 1123598821738675201L ) ;
entity . setMaterialCode ( vo . getMaterialCode ( ) ) ;
entity . setMaterialName ( vo . getMaterialName ( ) ) ;
entity . setCreateUser ( 1714696768639311873L ) ;
entity . setUpdateUser ( 1714696768639311873L ) ;
entity . setCreateDept ( 1649331096241836033L ) ;
entity . setTenantId ( TenantNum . HUITONGCODE ) ;
if ( StringUtil . isNone Blank ( entity . getMaterialName ( ) ) & & StringUtil . isNone Blank ( entity . getMaterialCode ( ) ) ) {
if ( StringUtil . isNot Blank ( entity . getMaterialName ( ) ) & & StringUtil . isNot Blank ( entity . getMaterialCode ( ) ) ) {
// 查询物料信息
String sku = "" ;
BasicMaterialEntity basicMaterialEntity = basicMaterialClient . getMaterialOwn ( entity . getMaterialCode ( ) , entity . getMaterialName ( ) , sku ) ;
@ -1182,6 +1431,21 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
boolean b = distributionParcelListClient . add ( entity ) ;
if ( ! b ) {
log . warn ( "#################handleDataToPlatform: 保存包件信息失败 orderCode={}" , entity . getOrderCode ( ) ) ;
} else {
log . info ( "################handleDataToPlatform: 保存包件成功 OrderPackageCode={}" , vo . getPacketBarCode ( ) ) ;
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 ( ) ) ;
}
distributionStockArticleClient . saveOrUpdate ( distributionStockArticleEntity ) ;
}
}
@ -1196,9 +1460,6 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
distributionStockArticleEntity . setStoreName ( advanceEntity . getStoreName ( ) ) ;
distributionStockArticleEntity . setStoreCode ( advanceEntity . getStoreNo ( ) ) ;
// distributionStockArticleEntity.setDealerCode(advanceEntity.getDealerCode());
// distributionStockArticleEntity.setDealerName(advanceEntity.getDealerName());
// 最终客户
distributionStockArticleEntity . setCustomerName ( advanceEntity . getCustomerName ( ) ) ;
distributionStockArticleEntity . setCustomerAddress ( advanceEntity . getCustomerRoad ( ) ) ;
@ -1211,7 +1472,7 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
// 品牌
distributionStockArticleEntity . setBrand ( advanceEntity . getType ( ) ) ;
distributionStockArticleEntity . setResource ( advanceEntity . getType ( ) ) ;
distributionStockArticleEntity . setResource ( advanceEntity . getSystem Type ( ) ) ;
}