|
|
|
@ -50,6 +50,118 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public String saveOuPaiPackageStatusByCode(String orderCode,Integer event) { |
|
|
|
|
//
|
|
|
|
|
String url = ouPaiProperties.getUri() + "tims_odata_api/api/odata/Package?$filter=Code eq '"+orderCode+"'&select=Code,PdaNumber," + |
|
|
|
|
"FirstClassCode,FirstClassName,SecondClassCode,SecondClassName,ThirdClassCode,ThirdClassName,BuyIn,CosourcingCode," + |
|
|
|
|
"CosourcingUnit,SortingCenter,DistributionCenter,Length,Width,Height,Weight,OrderDetail,Order," + |
|
|
|
|
"PathIndex,PathDetail,DeliveryOrders,ReceivingOrders,LPN,LpnSerialNum,IsEntruck,ReservationOrder," + |
|
|
|
|
"OutGoingOrderDetail,SignBill,IsInventory,Inventories,InventoryInDetails,Freeze," + |
|
|
|
|
"OutGoingOrderDetailInventoryDetail,From,Creator,CreateTime,ShipTime,CarNumber,DeliveryMethod," + |
|
|
|
|
"DeliveryReceiver,DeliveryReceiverPhone,ReturnNumber,GroupType,CarrierCode,CarrierName,PackageDetailNames," + |
|
|
|
|
"ReceivingTime,SendTime,ExceptionSignRemark,Descript,SignTime,OutOrder,IsReceiveByHand,PackageStatus,PackageDetailNames"; |
|
|
|
|
|
|
|
|
|
handlePackageData(url,event); |
|
|
|
|
return orderCode; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public String saveOuPaiOutGoingOrderByCode(String orderCode, Integer event) { |
|
|
|
|
//
|
|
|
|
|
String url = ouPaiProperties.getUri() + "tims_odata_api/api/odata/OutGoingOrder?$filter=Code eq 'PS20230802-6'" + |
|
|
|
|
"&$select=Code,Status,Truck,DriverPhone,Platform,DeliveryDate,Creator,CreateTime,IsAdjust,SendTime," + |
|
|
|
|
"Customers,Volume" + |
|
|
|
|
"&$expand=Warehouse($select=Code,Name)" + |
|
|
|
|
"&$expand=Truck($select=Plate,Type)" + |
|
|
|
|
"&$expand=Driver($select=Contact,Phone)" + |
|
|
|
|
"&$expand=ExpressCompany($select=CompanyName,CompanyCode)" + |
|
|
|
|
"&$expand=OutGoingOrderDetails($select=Customer,IsPickUp,CustomerPhone,Province,City,CustomerAddress," + |
|
|
|
|
"InstallationDate,DeliveryDate,ActualDeliveryDate,TimeFrame,Remark,CarrierRemark,Creator,CreateTime;" + |
|
|
|
|
"$expand=Packages($select=Code,PdaNumber,FirstClassCode,FirstClassName,SecondClassCode,SecondClassName," + |
|
|
|
|
"ThirdClassCode,ThirdClassName,BuyIn,CosourcingCode,CosourcingUnit,SortingCenter,DistributionCenter," + |
|
|
|
|
"Length,Width,Height,Weight,OrderDetail,Order,PathIndex,PathDetail,DeliveryOrders,ReceivingOrders," + |
|
|
|
|
"LPN,LpnSerialNum,IsEntruck,ReservationOrder,OutGoingOrderDetail,SignBill,IsInventory,Inventories," + |
|
|
|
|
"InventoryInDetails,Freeze,OutGoingOrderDetailInventoryDetail,From,Creator,CreateTime," + |
|
|
|
|
"ShipTime,CarNumber,DeliveryMethod,DeliveryReceiver,DeliveryReceiverPhone,ReturnNumber,GroupType," + |
|
|
|
|
"CarrierCode,CarrierName,PackageDetailNames,ReceivingTime,SendTime,ExceptionSignRemark,Descript," + |
|
|
|
|
"SignTime,OutOrder,IsReceiveByHand,PackageStatus,PackageDetailNames);" + |
|
|
|
|
"$expand=OutGoingOrderDetailInventoryDetails($select=SendQty;" + |
|
|
|
|
"$expand=ReservationOrderInventoryDetail($select=Qty;$expand=Inventory($select=SerialNumber,BatchCode," + |
|
|
|
|
"Code,Name,Unit,Qty,HoldQty,SelectedQty,Location))))"; |
|
|
|
|
|
|
|
|
|
handleOutGoingOrderData(url,event); |
|
|
|
|
return orderCode; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void handleOutGoingOrderData(String url, Integer event) { |
|
|
|
|
OpOrderStatusLogEntity opOrderStatusLogEntity = sendRequestData(url,event); |
|
|
|
|
|
|
|
|
|
// 保存需要解析的数据
|
|
|
|
|
// 获取返回内容
|
|
|
|
|
try { |
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(opOrderStatusLogEntity.getArgs()); |
|
|
|
|
JSONArray resultArray = jsonObject.getJSONArray("value"); |
|
|
|
|
log.info("############handlePackageData: 数据处理开始"); |
|
|
|
|
|
|
|
|
|
//TODO 这里需要添加处理配送发运单的逻辑
|
|
|
|
|
|
|
|
|
|
opOrderStatusLogEntity.setDataStatus(1); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
log.error("############handlePackageData: {}", e.getMessage()); |
|
|
|
|
opOrderStatusLogEntity.setDataStatus(2); |
|
|
|
|
} |
|
|
|
|
opOrderStatusLogService.saveOrUpdate(opOrderStatusLogEntity); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void handlePackageData(String url,Integer event) { |
|
|
|
|
|
|
|
|
|
OpOrderStatusLogEntity opOrderStatusLogEntity = sendRequestData(url,event); |
|
|
|
|
|
|
|
|
|
// 保存需要解析的数据
|
|
|
|
|
// 获取返回内容
|
|
|
|
|
try { |
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(opOrderStatusLogEntity.getArgs()); |
|
|
|
|
JSONArray resultArray = jsonObject.getJSONArray("value"); |
|
|
|
|
log.info("############handlePackageData: 数据处理开始"); |
|
|
|
|
|
|
|
|
|
//TODO 这里需要添加处理包件状态的逻辑
|
|
|
|
|
|
|
|
|
|
opOrderStatusLogEntity.setDataStatus(1); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
log.error("############handlePackageData: {}", e.getMessage()); |
|
|
|
|
opOrderStatusLogEntity.setDataStatus(2); |
|
|
|
|
} |
|
|
|
|
opOrderStatusLogService.saveOrUpdate(opOrderStatusLogEntity); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private OpOrderStatusLogEntity sendRequestData(String url, Integer event) { |
|
|
|
|
log.info("#################sendRequestData: 请求地址 url={}", url); |
|
|
|
|
|
|
|
|
|
String token = buildToken(); |
|
|
|
|
// log.info(">>> Authorization token {}",token);
|
|
|
|
|
|
|
|
|
|
HttpResponse httpResponse = HttpRequest.get(url).header("Authorization", token).execute(); |
|
|
|
|
|
|
|
|
|
String result = httpResponse.body(); |
|
|
|
|
log.info("#################sendRequestData: 返回数据 result={}", result); |
|
|
|
|
|
|
|
|
|
OpOrderStatusLogEntity orderStatusLog = new OpOrderStatusLogEntity(); |
|
|
|
|
orderStatusLog.setArgs(result); |
|
|
|
|
orderStatusLog.setStatus(1); |
|
|
|
|
orderStatusLog.setType(event); |
|
|
|
|
orderStatusLog.setDataStatus(0); |
|
|
|
|
orderStatusLog.setBrand("欧派"); |
|
|
|
|
opOrderStatusLogService.save(orderStatusLog); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return orderStatusLog; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 处理返回的JSON数据 |
|
|
|
|
* |
|
|
|
@ -401,7 +513,7 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
OpOrderStatusLogEntity orderStatusLog = new OpOrderStatusLogEntity(); |
|
|
|
|
orderStatusLog.setArgs(result); |
|
|
|
|
orderStatusLog.setStatus(1); |
|
|
|
|
orderStatusLog.setType(1); |
|
|
|
|
orderStatusLog.setType(3); |
|
|
|
|
orderStatusLog.setDataStatus(0); |
|
|
|
|
orderStatusLog.setBrand("欧派"); |
|
|
|
|
opOrderStatusLogService.save(orderStatusLog); |
|
|
|
|