|
|
|
@ -64,6 +64,7 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
|
|
|
|
|
private final ITrayScanDesClient trayScanDesClient; |
|
|
|
|
private final ITrayScanClient trayScanClient; |
|
|
|
|
private final IWarehouseTrayTypeClient warehouseTrayTypeClient; |
|
|
|
|
private final IInventoryDetailClient inventoryDetailClient; |
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
@Override |
|
|
|
@ -76,83 +77,143 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
|
|
|
|
|
log.info("#############handleData: 订单orderCode={}已存在",orderCode); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
//查询订单是零担还是订制品
|
|
|
|
|
Integer goodsType = orderClient.getGoodsTypeByOrderCode(orderCode,oldWarehouseId); |
|
|
|
|
if(1 == goodsType){ |
|
|
|
|
//包件
|
|
|
|
|
//查询订单是否在盘点任务中有被盘点到
|
|
|
|
|
InventoryDetailEntity inventoryDetailEntity = inventoryDetailClient.findOrderIsExist(orderCode); |
|
|
|
|
if(!Objects.isNull(inventoryDetailEntity)){ |
|
|
|
|
//定单
|
|
|
|
|
saveOrderInfo(orderCode,oldWarehouseId,newWarehouseId); |
|
|
|
|
}else if(2 == goodsType){ |
|
|
|
|
//运单
|
|
|
|
|
saveZeroOrderInfo(orderCode,oldWarehouseId,newWarehouseId); |
|
|
|
|
}else{ |
|
|
|
|
log.error("#############handleData: 未知的订单类型goodsType={} orderCode={} oldWarehouseId={}",goodsType,orderCode,oldWarehouseId); |
|
|
|
|
throw new CustomerException(403,"未知的订单类型"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//存入打托信息
|
|
|
|
|
saveTrayTypeInfo(orderCode,goodsType,oldWarehouseId,newWarehouseId); |
|
|
|
|
|
|
|
|
|
//存入打托信息
|
|
|
|
|
saveTrayTypeInfoPackage(orderCode,oldWarehouseId,newWarehouseId); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void saveTrayTypeInfo(String orderCode, Integer goodsType,Integer oldWarehouseId,Long newWarehouseId) { |
|
|
|
|
|
|
|
|
|
//1.根绝goodsType判断是订制品订单还是零担订单
|
|
|
|
|
if(1 == goodsType){ |
|
|
|
|
//如果是订制品就先查询该订单有哪些包件打了托
|
|
|
|
|
List<TrayScanDesEntity> list = trayScanDesClient.findListByOrderCodeAndWarehouseId(orderCode,oldWarehouseId); |
|
|
|
|
for (TrayScanDesEntity trayScanDesEntity:list){ |
|
|
|
|
Integer trayScanId = trayScanDesEntity.getTrayScanId(); |
|
|
|
|
String unitNo = trayScanDesEntity.getUnitNo();//包条码
|
|
|
|
|
//查询打托方式信息
|
|
|
|
|
TrayScanEntity trayScanEntity = trayScanClient.getEntityByTrayScanId(trayScanId); |
|
|
|
|
Integer type = trayScanEntity.getType(); |
|
|
|
|
Integer trayId = trayScanEntity.getTrayId(); |
|
|
|
|
String customerName = trayScanEntity.getCustomerName(); |
|
|
|
|
String customerPhone = trayScanEntity.getCustomerPhone(); |
|
|
|
|
|
|
|
|
|
//方式:1=仓,2=商场,3=客户,4=其他,5=服务号,6=合同号
|
|
|
|
|
//方式:60=仓,30=商场,50=客户,100=其他,10=服务号,20=合同号
|
|
|
|
|
String newTrayType = "100"; |
|
|
|
|
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"; |
|
|
|
|
} |
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
@Override |
|
|
|
|
public void handleDataZero(List<String> orderCodeList,Integer oldWarehouseId,Long newWarehouseId) { |
|
|
|
|
log.info("#############handleData: 处理订单开始"); |
|
|
|
|
for (String orderCode:orderCodeList){ |
|
|
|
|
log.info("#############handleData: 当前处理orderCode={}的订单",orderCode); |
|
|
|
|
DistributionStockArticleEntity stockArticleEntity = distributionStockArticleClient.findStockArticleByOrderCode(orderCode); |
|
|
|
|
if(!Objects.isNull(stockArticleEntity)){ |
|
|
|
|
log.info("#############handleData: 订单orderCode={}已存在",orderCode); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
// //查询订单是零担还是订制品
|
|
|
|
|
// Integer goodsType = orderClient.getGoodsTypeByOrderCode(orderCode,oldWarehouseId);
|
|
|
|
|
// if(1 == goodsType){
|
|
|
|
|
// //包件
|
|
|
|
|
// saveOrderInfo(orderCode,oldWarehouseId,newWarehouseId);
|
|
|
|
|
// }else if(2 == goodsType){
|
|
|
|
|
// //运单
|
|
|
|
|
// saveZeroOrderInfo(orderCode,oldWarehouseId,newWarehouseId);
|
|
|
|
|
// }else{
|
|
|
|
|
// log.error("#############handleData: 未知的订单类型goodsType={} orderCode={} oldWarehouseId={}",goodsType,orderCode,oldWarehouseId);
|
|
|
|
|
// throw new CustomerException(403,"未知的订单类型");
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
//运单
|
|
|
|
|
saveZeroOrderInfo(orderCode,oldWarehouseId,newWarehouseId); |
|
|
|
|
|
|
|
|
|
Map<String,Object> map = new HashMap<>(); |
|
|
|
|
map.put("trayType",newTrayType); |
|
|
|
|
map.put("trayCode","T"+trayId); |
|
|
|
|
map.put("warehouseId",newWarehouseId); |
|
|
|
|
map.put("orderPackageCode",unitNo); |
|
|
|
|
//存入打托信息
|
|
|
|
|
saveTrayTypeInfoZero(orderCode,oldWarehouseId,newWarehouseId); |
|
|
|
|
|
|
|
|
|
//新系统保存打托方式
|
|
|
|
|
boolean b = warehouseTrayTypeClient.orderScanOrderPackageCode(map); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(!b){ |
|
|
|
|
log.error("################saveTrayTypeInfo: 包件打托失败 unitNo={} trayCode={}",unitNo,"T"+trayId); |
|
|
|
|
throw new CustomerException(403,"包件打托失败"); |
|
|
|
|
} |
|
|
|
|
private void saveTrayTypeInfoPackage(String orderCode,Integer oldWarehouseId,Long newWarehouseId) { |
|
|
|
|
|
|
|
|
|
//如果是订制品就先查询该订单有哪些包件打了托
|
|
|
|
|
List<TrayScanDesEntity> list = trayScanDesClient.findListByOrderCodeAndWarehouseId(orderCode,oldWarehouseId); |
|
|
|
|
for (TrayScanDesEntity trayScanDesEntity:list){ |
|
|
|
|
Integer trayScanId = trayScanDesEntity.getTrayScanId(); |
|
|
|
|
String unitNo = trayScanDesEntity.getUnitNo();//包条码
|
|
|
|
|
//查询打托方式信息
|
|
|
|
|
TrayScanEntity trayScanEntity = trayScanClient.getEntityByTrayScanId(trayScanId); |
|
|
|
|
Integer type = trayScanEntity.getType(); |
|
|
|
|
Integer trayId = trayScanEntity.getTrayId(); |
|
|
|
|
String customerName = trayScanEntity.getCustomerName(); |
|
|
|
|
String customerPhone = trayScanEntity.getCustomerPhone(); |
|
|
|
|
|
|
|
|
|
//方式:1=仓,2=商场,3=客户,4=其他,5=服务号,6=合同号
|
|
|
|
|
//方式:60=仓,30=商场,50=客户,100=其他,10=服务号,20=合同号
|
|
|
|
|
String newTrayType = "100"; |
|
|
|
|
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"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Map<String,Object> map = new HashMap<>(); |
|
|
|
|
map.put("trayType",newTrayType); |
|
|
|
|
map.put("trayCode","T"+trayId); |
|
|
|
|
map.put("warehouseId",newWarehouseId); |
|
|
|
|
map.put("orderPackageCode",unitNo); |
|
|
|
|
|
|
|
|
|
}else if(2 == goodsType){ |
|
|
|
|
//新系统保存打托方式
|
|
|
|
|
boolean b = warehouseTrayTypeClient.orderScanOrderPackageCode(map); |
|
|
|
|
|
|
|
|
|
if(!b){ |
|
|
|
|
log.error("################saveTrayTypeInfo: 包件打托失败 unitNo={} trayCode={}",unitNo,"T"+trayId); |
|
|
|
|
throw new CustomerException(403,"包件打托失败"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void saveTrayTypeInfoZero(String orderCode,Integer oldWarehouseId,Long newWarehouseId) { |
|
|
|
|
|
|
|
|
|
//如果是订制品就先查询该订单有哪些包件打了托
|
|
|
|
|
List<TrayScanDesEntity> list = trayScanDesClient.findZeroListByOrderCodeAndWarehouseId(orderCode,oldWarehouseId); |
|
|
|
|
for (TrayScanDesEntity trayScanDesEntity:list){ |
|
|
|
|
Integer trayScanId = trayScanDesEntity.getTrayScanId(); |
|
|
|
|
Integer trayId = trayScanDesEntity.getTrayId(); |
|
|
|
|
Integer num = trayScanDesEntity.getNum(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//方式:1=仓,2=商场,3=客户,4=其他,5=服务号,6=合同号
|
|
|
|
|
//方式:60=仓,30=商场,50=客户,100=其他,10=服务号,20=合同号
|
|
|
|
|
String newTrayType = "100"; |
|
|
|
|
// 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";
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
Map<String,Object> map = new HashMap<>(); |
|
|
|
|
map.put("trayType",newTrayType); |
|
|
|
|
map.put("trayCode","T"+trayId); |
|
|
|
|
map.put("warehouseId",newWarehouseId); |
|
|
|
|
map.put("orderCode",orderCode); |
|
|
|
|
map.put("num",num); |
|
|
|
|
|
|
|
|
|
//新系统保存打托方式
|
|
|
|
|
boolean b = warehouseTrayTypeClient.enterZeroOrderByTrayCode(map); |
|
|
|
|
|
|
|
|
|
if(!b){ |
|
|
|
|
log.error("################saveTrayTypeInfo: 零担打托失败 orderCode={} trayCode={} num={}",orderCode,"T"+trayId,num); |
|
|
|
|
throw new CustomerException(403,"零担打托失败"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void saveZeroOrderInfo(String orderCode, Integer oldWarehouseId, Long newWarehouseId) { |
|
|
|
|
|
|
|
|
|
OrderCountEntity orderCountEntity = orderCountClient.getEntityByOrderCode(orderCode,oldWarehouseId); |
|
|
|
@ -184,25 +245,6 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
|
|
|
|
|
// }
|
|
|
|
|
warehouseWaybill = saveWayBillData(wayBillEntity, inNum); |
|
|
|
|
// waybillId = warehouseWaybill.getId();
|
|
|
|
|
|
|
|
|
|
//新增的时候存入所有的订单详情
|
|
|
|
|
List<WaybillDesEntity> des = waybillDesClient.getDesList(waybillNo); |
|
|
|
|
List<WarehouseWayBillDetail> ls = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
for (WaybillDesEntity waybillDesEntity : des) { |
|
|
|
|
WarehouseWayBillDetail warehouseWayBillDetail = new WarehouseWayBillDetail(); |
|
|
|
|
warehouseWayBillDetail.setWaybillId(warehouseWaybill.getId()); |
|
|
|
|
warehouseWayBillDetail.setWaybillNo(waybillNo); |
|
|
|
|
warehouseWayBillDetail.setProductName(waybillDesEntity.getName()); |
|
|
|
|
warehouseWayBillDetail.setNum(waybillDesEntity.getNum()); |
|
|
|
|
warehouseWayBillDetail.setStatus(1); |
|
|
|
|
warehouseWayBillDetail.setIsDeleted(0); |
|
|
|
|
warehouseWayBillDetail.setCreateTime(date); |
|
|
|
|
warehouseWayBillDetail.setUpdateTime(date); |
|
|
|
|
ls.add(warehouseWayBillDetail); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
warehouseWaybillDetailClient.addList(ls); |
|
|
|
|
//createStockArticle(warehouseWaybill);
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
@ -243,6 +285,9 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
|
|
|
|
|
distributionStockArticleEntity.setWarehouseEntryTime(date); |
|
|
|
|
distributionStockArticleEntity.setTotalNumber(totalCount); |
|
|
|
|
distributionStockArticleEntity.setHandQuantity(stockCount); |
|
|
|
|
distributionStockArticleEntity.setDealerName(consignee); |
|
|
|
|
distributionStockArticleEntity.setDealerCode(clientEntity.getClientCode()); |
|
|
|
|
|
|
|
|
|
//零担订单默认齐套
|
|
|
|
|
distributionStockArticleEntity.setCompleteSet(1); |
|
|
|
|
|
|
|
|
@ -319,6 +364,8 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
|
|
|
|
|
entity.setCreateDept(distributionStockArticleEntity.getCreateDept()); |
|
|
|
|
entity.setWarehouseId(distributionStockArticleEntity.getWarehouseId()); |
|
|
|
|
entity.setWarehouse(distributionStockArticleEntity.getWarehouse()); |
|
|
|
|
entity.setDealerName(distributionStockArticleEntity.getDealerName()); |
|
|
|
|
entity.setDealerCode(distributionStockArticleEntity.getDealerCode()); |
|
|
|
|
entity.setQuantity(warehouseWayBillDetail.getNum()); |
|
|
|
|
entity.setConditions(1); |
|
|
|
|
entity.setStockArticleId(id); |
|
|
|
@ -335,14 +382,14 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
|
|
|
|
|
entity.setSendWarehouseName(warehouseWaybill.getDepartureWarehouseName()); |
|
|
|
|
entity.setAcceptWarehouseId(warehouseWaybill.getDestinationWarehouseId()); |
|
|
|
|
entity.setAcceptWarehouseName(warehouseWaybill.getDestinationWarehouseName()); |
|
|
|
|
Long packageId = distributionParcelListClient.addReturnId(entity); |
|
|
|
|
entity.setId(packageId); |
|
|
|
|
ls.add(entity); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
boolean b = distributionParcelListClient.addBatch(ls); |
|
|
|
|
if (!b) { |
|
|
|
|
log.warn("#################createStockArticle: 保存包件信息失败 orderSelfNum={}", waybillNo); |
|
|
|
|
throw new CustomerException(405, "保存包件信息失败"); |
|
|
|
|
} |
|
|
|
|
// if (!b) {
|
|
|
|
|
// log.warn("#################createStockArticle: 保存包件信息失败 orderSelfNum={}", waybillNo);
|
|
|
|
|
// throw new CustomerException(405, "保存包件信息失败");
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
List<DistributionParcelNumberEntity> parcelNumberList = new ArrayList<>(); |
|
|
|
|
for (DistributionParcelListEntity entity:ls){ |
|
|
|
@ -467,7 +514,29 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
|
|
|
|
|
Date date = new Date(); |
|
|
|
|
warehouseWaybill.setCreateTime(date); |
|
|
|
|
warehouseWaybill.setUpdateTime(date); |
|
|
|
|
warehouseWaybillClient.addEnntity(warehouseWaybill); |
|
|
|
|
Long waybillId = warehouseWaybillClient.addEnntity(warehouseWaybill); |
|
|
|
|
|
|
|
|
|
warehouseWaybill.setId(waybillId); |
|
|
|
|
//新增的时候存入所有的订单详情
|
|
|
|
|
List<WaybillDesEntity> des = waybillDesClient.getDesList(wayBillEntity.getWaybillNo()); |
|
|
|
|
List<WarehouseWayBillDetail> ls = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
for (WaybillDesEntity waybillDesEntity : des) { |
|
|
|
|
WarehouseWayBillDetail warehouseWayBillDetail = new WarehouseWayBillDetail(); |
|
|
|
|
warehouseWayBillDetail.setWaybillId(waybillId); |
|
|
|
|
warehouseWayBillDetail.setWaybillNo(wayBillEntity.getWaybillNo()); |
|
|
|
|
warehouseWayBillDetail.setProductName(waybillDesEntity.getName()); |
|
|
|
|
warehouseWayBillDetail.setNum(waybillDesEntity.getNum()); |
|
|
|
|
warehouseWayBillDetail.setStatus(1); |
|
|
|
|
warehouseWayBillDetail.setIsDeleted(0); |
|
|
|
|
warehouseWayBillDetail.setCreateTime(date); |
|
|
|
|
warehouseWayBillDetail.setUpdateTime(date); |
|
|
|
|
ls.add(warehouseWayBillDetail); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
warehouseWaybillDetailClient.addList(ls); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return warehouseWaybill; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
@ -518,7 +587,8 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
distributionStockArticleEntity.setWarehouseEntryTime(date); |
|
|
|
|
distributionStockArticleEntity.setWarehouseEntryTime(orderCountEntity.getCreateTime()); |
|
|
|
|
distributionStockArticleEntity.setWarehouseEntryTimeEnd(orderCountEntity.getLatestInTime()); |
|
|
|
|
distributionStockArticleEntity.setTotalNumber(total); |
|
|
|
|
distributionStockArticleEntity.setHandQuantity(orderCountEntity.getInNum()); |
|
|
|
|
distributionStockArticleEntity.setTenantId(TenantNum.HUITONGCODE);// 对应租户ID
|
|
|
|
@ -684,6 +754,12 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService {
|
|
|
|
|
List<OrderDetailEntity> orderDetailList = orderDetailClient.findByOrderCode(orderCode,oldWarehouseId); |
|
|
|
|
for (OrderDetailEntity orderDetailEntity:orderDetailList){ |
|
|
|
|
String unitNo = orderDetailEntity.getUnitNo(); |
|
|
|
|
InventoryDetailEntity inventoryDetailEntity = inventoryDetailClient.findUnitNoIsExist(unitNo); |
|
|
|
|
if(Objects.isNull(inventoryDetailEntity)){ |
|
|
|
|
log.info("###########saveOrderPackage: 包条不在盘点任务中存在,不同步 unitNo={}",unitNo); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Integer status = orderDetailEntity.getStatus(); |
|
|
|
|
Integer carsType = orderDetailEntity.getCarsType(); |
|
|
|
|
Integer signState = orderDetailEntity.getSignState(); |
|
|
|
|