|
|
@ -100,58 +100,60 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
await scpAsnManager.GetUnreadAsnsAsync(siteCode, lastUid, _options.BatchSize); |
|
|
|
|
|
|
|
Logger.LogInformation($"{siteCode}: {scpAsns.Count} ASNs were Found"); |
|
|
|
var baseUrl = _options.BaseUrl; |
|
|
|
var username = _options.Username; |
|
|
|
var password = _options.Password; |
|
|
|
//var baseUrl = _options.BaseUrl;
|
|
|
|
//var username = _options.Username;
|
|
|
|
//var password = _options.Password;
|
|
|
|
foreach (var asn in scpAsns) |
|
|
|
{ |
|
|
|
var barcodes = await scpAsnManager.GetBarcodesAsync(siteCode, asn.AsnBillNum); |
|
|
|
|
|
|
|
var noPoAsn = CreateNoPoAsn(asn, barcodes); |
|
|
|
|
|
|
|
asnX12List.Add(noPoAsn); |
|
|
|
asn.IsPort = 1; |
|
|
|
var apiUrl = ""; |
|
|
|
//var apiUrl = "";
|
|
|
|
|
|
|
|
var jsonString = noPoAsn.JsonString; |
|
|
|
try |
|
|
|
{ |
|
|
|
var result = await _postService.PostAsync(baseUrl, apiUrl, jsonString, username, password); |
|
|
|
if (result == null) |
|
|
|
{ |
|
|
|
noPoAsn.SetError("Boomi", EnumExchangeDataErrorCode.None, "Boomi没有返回值","Boomi接口执行失败"); |
|
|
|
} |
|
|
|
if (result?.Status == "SUCCESS") |
|
|
|
{ |
|
|
|
noPoAsn.SetSuccess("Boomi", "Boomi接口执行成功"); |
|
|
|
} |
|
|
|
else if (result?.Status == "EXCEPTION") |
|
|
|
{ |
|
|
|
noPoAsn.SetError("Boomi", EnumExchangeDataErrorCode.Exception, "EXCEPTION" + result?.ErrorMessage, "Boomi接口执行失败"); |
|
|
|
} |
|
|
|
else if (result?.Status == "FAIL") |
|
|
|
{ |
|
|
|
noPoAsn.SetError("Boomi", EnumExchangeDataErrorCode.FAIL, "FAIL" + result?.ErrorMessage, "Boomi接口执行失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception e) |
|
|
|
{ |
|
|
|
Logger.LogException(e); |
|
|
|
e = e.GetBaseException(); |
|
|
|
noPoAsn.SetError("Boomi", EnumExchangeDataErrorCode.Exception, "接口程序异常"+e.Message, "Boomi接口执行失败"); |
|
|
|
} |
|
|
|
finally |
|
|
|
{ |
|
|
|
asnX12List.Add(noPoAsn); |
|
|
|
} |
|
|
|
//if (asn.AsnBillNum.StartsWith(_options.QadAsnPrefix))//ASN to QAD
|
|
|
|
#region
|
|
|
|
//try
|
|
|
|
//{
|
|
|
|
// //埃驰要求不传托盘信息 @20220905
|
|
|
|
// barcodes.ForEach(p => p.PalletCode = "");
|
|
|
|
// //埃驰要求不传托盘信息 @20220905
|
|
|
|
|
|
|
|
// var asnX12 = CreateX12Asn(site, asn, barcodes);
|
|
|
|
// asnX12List.Add(asnX12);
|
|
|
|
// var result = await _postService.PostAsync(baseUrl, apiUrl, jsonString, username, password);
|
|
|
|
// if (result == null)
|
|
|
|
// {
|
|
|
|
// noPoAsn.SetError("Boomi", EnumExchangeDataErrorCode.None, "Boomi没有返回值","Boomi接口执行失败");
|
|
|
|
// }
|
|
|
|
// if (result?.Status == "SUCCESS")
|
|
|
|
// {
|
|
|
|
// noPoAsn.SetSuccess("Boomi", "Boomi接口执行成功");
|
|
|
|
// }
|
|
|
|
// else if (result?.Status == "EXCEPTION")
|
|
|
|
// {
|
|
|
|
// noPoAsn.SetError("Boomi", EnumExchangeDataErrorCode.Exception, "EXCEPTION" + result?.ErrorMessage, "Boomi接口执行失败");
|
|
|
|
// }
|
|
|
|
// else if (result?.Status == "FAIL")
|
|
|
|
// {
|
|
|
|
// noPoAsn.SetError("Boomi", EnumExchangeDataErrorCode.FAIL, "FAIL" + result?.ErrorMessage, "Boomi接口执行失败");
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
//catch (Exception e)
|
|
|
|
//{
|
|
|
|
// Logger.LogException(e);
|
|
|
|
// e = e.GetBaseException();
|
|
|
|
// noPoAsn.SetError("Boomi", EnumExchangeDataErrorCode.Exception, "接口程序异常"+e.Message, "Boomi接口执行失败");
|
|
|
|
//}
|
|
|
|
//finally
|
|
|
|
//{
|
|
|
|
// asnX12List.Add(noPoAsn);
|
|
|
|
//}
|
|
|
|
#endregion
|
|
|
|
if (asn.AsnBillNum.StartsWith(_options.QadAsnPrefix))//ASN to QAD
|
|
|
|
{ |
|
|
|
//埃驰要求不传托盘信息 @20220905
|
|
|
|
barcodes.ForEach(p => p.PalletCode = ""); |
|
|
|
//埃驰要求不传托盘信息 @20220905
|
|
|
|
|
|
|
|
var asnX12 = CreateX12Asn(site, asn, barcodes); |
|
|
|
asnX12List.Add(asnX12); |
|
|
|
} |
|
|
|
|
|
|
|
Logger.LogInformation($"{siteCode}:{asn.Id} {asn.AsnBillNum} was loaded"); |
|
|
|
} |
|
|
@ -175,55 +177,54 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
|
|
|
|
var asnMstr = new AsnMstr() |
|
|
|
{ |
|
|
|
traceId = asn.Site+"-"+ asn.Id .ToString()+ "-"+ Guid.NewGuid().ToString(), |
|
|
|
uid = asn.Id, |
|
|
|
company = asn.Site, |
|
|
|
site = asn.Site, |
|
|
|
asnNbr = asn.AsnBillNum, |
|
|
|
rpNbr = asn.AskBillNum, |
|
|
|
poNbr = asn.PoBillNum, |
|
|
|
vendorCode = asn.VendId, |
|
|
|
contacts = asn.ReceiveUser, |
|
|
|
phone = "", |
|
|
|
truckNbr = asn.PlateNumber, |
|
|
|
whse = "", |
|
|
|
dock = asn.Dock, |
|
|
|
shipDate = asn.ShipTime, |
|
|
|
dueDate = asn.ReceiveTime, |
|
|
|
timeWindow = asn.ReceivedPort, |
|
|
|
remark = asn.Remark, |
|
|
|
subsite=asn.WebSubSite |
|
|
|
UID = asn.Id, |
|
|
|
Company = asn.Site, |
|
|
|
Site = asn.Site, |
|
|
|
AsnNbr = asn.AsnBillNum, |
|
|
|
RpNbr = asn.AskBillNum, |
|
|
|
PoNbr = asn.PoBillNum, |
|
|
|
VendorCode = asn.VendId, |
|
|
|
Contacts = asn.ReceiveUser, |
|
|
|
Phone = "", |
|
|
|
TruckNbr = asn.PlateNumber, |
|
|
|
Whse = "", |
|
|
|
Dock = asn.Dock, |
|
|
|
ShipDate = asn.ShipTime, |
|
|
|
DueDate = asn.ReceiveTime, |
|
|
|
TimeWindow = asn.ReceivedPort, |
|
|
|
Remark = asn.Remark, |
|
|
|
Subsite = asn.WebSubSite, |
|
|
|
}; |
|
|
|
if (string.IsNullOrEmpty(asnMstr.timeWindow)) |
|
|
|
if (string.IsNullOrEmpty(asnMstr.TimeWindow)) |
|
|
|
{ |
|
|
|
asnMstr.timeWindow = "00:00-00:00"; |
|
|
|
asnMstr.TimeWindow = "00:00-00:00"; |
|
|
|
} |
|
|
|
foreach (var barcode in barcodes) |
|
|
|
{ |
|
|
|
var det = new AsnDet() |
|
|
|
{ |
|
|
|
asnNbr = asn.AsnBillNum, |
|
|
|
poNbr = asn.PoBillNum, |
|
|
|
poLine = barcode.PoBillLine, |
|
|
|
partCode = barcode.PartCode, |
|
|
|
lot = barcode.Batch, |
|
|
|
qty = barcode.Qty, |
|
|
|
productionDate = barcode.ProduceDate, |
|
|
|
wareClass = "", |
|
|
|
wareCode = "", |
|
|
|
stdPackQty = barcode.PackQty, |
|
|
|
poUm = barcode.PoUnit, |
|
|
|
locUm = barcode.LocUnit, |
|
|
|
umConv = 1, |
|
|
|
partType = "", |
|
|
|
supplierlot = barcode.VendBatch, |
|
|
|
status = barcode.State.ToString(), |
|
|
|
labelCode = barcode.Extend2, |
|
|
|
entireBarCode = barcode.FullBarCode, |
|
|
|
palletLabelCode = barcode.PalletCode, |
|
|
|
remark = barcode.Remark, |
|
|
|
AsnNbr = asn.AsnBillNum, |
|
|
|
PoNbr = asn.PoBillNum, |
|
|
|
PoLine = barcode.PoBillLine, |
|
|
|
PartCode = barcode.PartCode, |
|
|
|
Lot = barcode.Batch, |
|
|
|
Qty = barcode.Qty, |
|
|
|
ProductionDate = barcode.ProduceDate, |
|
|
|
WareClass = "", |
|
|
|
WareCode = "", |
|
|
|
StdPackQty = barcode.PackQty, |
|
|
|
PoUm = barcode.PoUnit, |
|
|
|
LocUm = barcode.LocUnit, |
|
|
|
UmConv = 1, |
|
|
|
PartType = "", |
|
|
|
Supplierlot = barcode.VendBatch, |
|
|
|
Status = barcode.State.ToString(), |
|
|
|
LabelCode = barcode.Extend2, |
|
|
|
EntireBarCode = barcode.FullBarCode, |
|
|
|
PalletLabelCode = barcode.PalletCode, |
|
|
|
Remark = barcode.Remark, |
|
|
|
}; |
|
|
|
asnMstr.details.Add(det); |
|
|
|
asnMstr.Details.Add(det); |
|
|
|
} |
|
|
|
var jsonString = JsonSerializer.Serialize(asnMstr); |
|
|
|
var ediString = jsonString; |
|
|
|