|
|
@ -243,6 +243,210 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void supplementOrderInfo(String orderCode, Long newWarehouseId, Integer oldWarehouseId) { |
|
|
|
|
|
|
|
//通过订单号查询暂存单
|
|
|
|
|
|
|
|
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.findByAdvanceId(advanceId); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
// 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 orderId; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String wayBillNo = null; |
|
|
|
|
|
|
|
if (Objects.isNull(distributionStockArticleEntity)) { |
|
|
|
|
|
|
|
Date date = new Date(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.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()); |
|
|
|
|
|
|
|
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()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO 这里存在问题 后需要知道当前作业仓库
|
|
|
|
|
|
|
|
// distributionStockArticleEntity.setWarehouse(t.getName());
|
|
|
|
|
|
|
|
// distributionStockArticleEntity.setWarehouseId(t.getId());
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String customerName = wayBillEntity.getTakeCompany();//客户名称
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.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());
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// 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.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()); //签收件数
|
|
|
|
|
|
|
|
//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); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
orderId = distributionStockArticleClient.addData(distributionStockArticleEntity); |
|
|
|
|
|
|
|
distributionStockArticleEntity.setId(orderId); |
|
|
|
|
|
|
|
if (orderId == 0) { |
|
|
|
|
|
|
|
log.warn("#################handleDataToPlatform: 保存订单信息失败 orderCode={}", orderCode); |
|
|
|
|
|
|
|
throw new CustomerException(405, "保存订单信息失败"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
orderId = distributionStockArticleEntity.getId(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//通过订单号更新所有包件下面的关联订单id
|
|
|
|
|
|
|
|
distributionParcelListClient.updateStockArticleIdByOrderCode(orderId,orderCode); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void saveTrayTypeInfoPackage(String orderCode,Integer oldWarehouseId,Long newWarehouseId) { |
|
|
|
private void saveTrayTypeInfoPackage(String orderCode,Integer oldWarehouseId,Long newWarehouseId) { |
|
|
|
|
|
|
|
|
|
|
|
//如果是订制品就先查询该订单有哪些包件打了托
|
|
|
|
//如果是订制品就先查询该订单有哪些包件打了托
|
|
|
|