电放提交接口调整

master
zhangxiaofeng 8 months ago
parent ce833c625a
commit 9f0be5494d

@ -12038,7 +12038,6 @@ namespace Myshipping.Application
{
throw Oops.Bah("大简云电放服务接口Secret未配置请联系管理员");
}
url += "/v1/submit";
var webAccount = _webAccountConfig.GetAccountConfig("MSKWeb", UserManager.UserId).Result;
if (webAccount == null)
@ -12050,6 +12049,8 @@ namespace Myshipping.Application
var mappingIssueType = _cache.GetAllMappingIssueType().Result;
List<SubmitTelexResultDto> result = new();
List<(long Id, string MBLNO, string CarrierId)> pushList = new();
foreach (var order in orderList)
{
try
@ -12088,14 +12089,97 @@ namespace Myshipping.Application
continue;
}
pushList.Add((order.Id, order.MBLNO, carrierId));
}
catch (Exception ex)
{
_logger.LogError("请求电放条件判断的过程中发生未知异常mblno={mblno}, ex={ex}", order.MBLNO, ex);
result.Add(new SubmitTelexResultDto(order.MBLNO, false, $"提交错误:{ex.Message}"));
continue;
}
}
if (pushList.Count == 0)
{
return result;
}
if (ids.Length > 1)
{
url += "/v1/tasks";
var mblnos = string.Concat(',', pushList.Select(x => x.MBLNO));
try
{
// 提交电放
var data = pushList.Select(x => new
{
web_code = x.CarrierId,
web_user = webAccount.Account,
web_psw = webAccount.Password,
bno = x.MBLNO,
email = UserManager.Email
});
var body = new
{
user_key = key,
user_secret = secret,
data = data
};
_logger.LogInformation("请求电放提交接口开始mblnos={mblnos}, url={url}, body={body}", mblnos, url, body);
var rtn = await url.SetBody(body).PostAsStringAsync();
_logger.LogInformation("请求电放提交接口结束rtn={rtn}", rtn);
var jsonRtn = JObject.Parse(rtn);
if (jsonRtn.GetIntValue("code") == 200)
{
_logger.LogInformation("请求电放提交接口成功mblnos={mblnos}", mblnos);
foreach (var item in pushList)
{
// 推送 电放已安排 状态
var pushModel = new ModifyServiceProjectStatusDto
{
BookingId = item.Id,
SourceType = TrackingSourceTypeEnum.MANUAL,
StatusCodes = new List<ModifyServiceProjectStatusDetailDto> {
new ModifyServiceProjectStatusDetailDto { StatusCode = "DFYAP" } }
};
var saveStatusRlt = await bookingValueAddedService.SaveServiceStatus(pushModel);
_logger.LogInformation("请求电放提交接口成功后推送 电放已安排 状态mblno={mblno}JSON={json} ,结果={rlt}",
item.MBLNO, JSON.Serialize(pushModel), JSON.Serialize(saveStatusRlt));
result.Add(new SubmitTelexResultDto(item.MBLNO, true, null));
}
}
else
{
var msg = jsonRtn.GetStringValue("msg")?.Replace("爬虫", "");
_logger.LogInformation("请求电放提交接口失败mblnos={mblnos}, 电放服务返回:{msg}", mblnos, msg);
result.AddRange(pushList.Select(x => new SubmitTelexResultDto(x.MBLNO, false, $"电放服务返回:{msg}")));
}
}
catch (Exception ex)
{
_logger.LogError("请求电放服务的过程中发生未知异常mblnos={mblnos}, ex={ex}", mblnos, ex);
result.AddRange(pushList.Select(x => new SubmitTelexResultDto(x.MBLNO, false, $"错误:{ex.Message}")));
}
}
else
{
url += "/v1/submit";
var order = pushList[0];
try
{
// 提交电放
var body = new
{
user_key = key,
user_secret = secret,
web_code = carrierId,
web_user = webAccount.Account,
web_psw = webAccount.Password,
web_code = order.CarrierId,
bno = order.MBLNO
};
@ -12130,11 +12214,11 @@ namespace Myshipping.Application
}
catch (Exception ex)
{
_logger.LogError("请求电放提交接口过程中发生未知异常mblno={mblno}, ex={ex}", order.MBLNO, ex);
_logger.LogError("请求电放服务的过程中发生未知异常mblno={mblno}, ex={ex}", order.MBLNO, ex);
result.Add(new SubmitTelexResultDto(order.MBLNO, false, $"错误:{ex.Message}"));
continue;
}
}
return result;
}
#endregion

Loading…
Cancel
Save