运踪刷新接口分开

master
wanghaomei 8 months ago
parent a02d92633f
commit e68dd72df1

@ -147,6 +147,133 @@ namespace Myshipping.Application
} }
/// <summary>
/// 刷新运踪(场站)
/// </summary>
/// <param name="Ids"></param>
/// <returns></returns>
[HttpPost("/BookingYunZong/RefreshYard")]
public async Task RefreshYard(long[] Ids)
{
var order = await _rep.AsQueryable().Filter(null, true).Where(x => Ids.Contains(x.Id) && x.IsDeleted == false && x.ParentId == 0 && x.IsBookingYZ != "0").ToListAsync();
if (order == null || order.Count == 0)
{
throw Oops.Bah("存在未订阅单据");
}
var key = _cache.GetAllSysConfig().Result.Where(x => x.Code == "billTraceNewUserKey").Select(x => x.Value).FirstOrDefault();
if (string.IsNullOrEmpty(key))
{
throw Oops.Bah("未获取到相关KEY请联系管理员");
}
var url = _cache.GetAllDictData().Result.Where(x => x.Code == "billTraceYgtUrl").Select(x => x.Value).FirstOrDefault();
var secret = _cache.GetAllSysConfig().Result.Where(x => x.Code == "billTraceNewUserSecret").Select(x => x.Value).FirstOrDefault();
if (string.IsNullOrEmpty(secret))
{
throw Oops.Bah("未获取到相关SECRET请联系管理员");
}
JArray jarrCZTemos = new JArray();
foreach (var item in order)
{
if (!string.IsNullOrEmpty(item.YARDID) && !string.IsNullOrEmpty(item.MBLNO))
{
var YARDID = _cache.GetAllMappingYard().Result.Where(x => x.Module == "BillTrace" && x.Code == item.YARDID).Select(x => x.MapCode).FirstOrDefault();
JObject jobjczTemp = new JObject();
jobjczTemp.Add("web_code", new JValue(YARDID));
jobjczTemp.Add("bno", new JValue(item.MBLNO.Trim()));
jarrCZTemos.Add(jobjczTemp);
}
}
if (jarrCZTemos.Count > 0)
{
JObject CZjobjSend = new JObject();
CZjobjSend.Add("user_key", new JValue(key));
CZjobjSend.Add("user_secret", new JValue(secret));
CZjobjSend.Add("customer_id", new JValue(UserManager.TENANT_ID));
CZjobjSend.Add("customer_name", new JValue(UserManager.TENANT_NAME));
CZjobjSend.Add("data_list", jarrCZTemos);
var json = CZjobjSend.ToJsonString();
_logger.LogInformation("运踪查询场站参数:" + json);
var rtn = await url.SetHttpMethod(HttpMethod.Post).SetBody(CZjobjSend.ToJsonString()).PostAsStringAsync();
_logger.LogInformation("运踪查询场站查询结果:" + rtn);
await ExecuteYard(rtn);
}
}
/// <summary>
/// 刷新运踪(互联网和云港通)
/// </summary>
/// <param name="Ids"></param>
/// <returns></returns>
[HttpPost("/BookingYunZong/RefreshYGT")]
public async Task RefreshYGT(long[] Ids)
{
var order = await _rep.AsQueryable().Filter(null, true).Where(x => Ids.Contains(x.Id) && x.IsDeleted == false && x.ParentId == 0 && x.IsBookingYZ != "0").ToListAsync();
if (order == null || order.Count == 0)
{
throw Oops.Bah("存在未订阅单据");
}
var key = _cache.GetAllSysConfig().Result.Where(x => x.Code == "billTraceNewUserKey").Select(x => x.Value).FirstOrDefault();
if (string.IsNullOrEmpty(key))
{
throw Oops.Bah("未获取到相关KEY请联系管理员");
}
var url = _cache.GetAllDictData().Result.Where(x => x.Code == "billTraceYgtUrl").Select(x => x.Value).FirstOrDefault();
var secret = _cache.GetAllSysConfig().Result.Where(x => x.Code == "billTraceNewUserSecret").Select(x => x.Value).FirstOrDefault();
if (string.IsNullOrEmpty(secret))
{
throw Oops.Bah("未获取到相关SECRET请联系管理员");
}
JArray jarrHLWTemos = new JArray();
JArray jarrYGTTemos = new JArray();
foreach (var item in order)
{
JObject jobjhlwTemp = new JObject();
jobjhlwTemp.Add("web_code", "HLW_CD");
jobjhlwTemp.Add("bno", new JValue(item.MBLNO.Trim()));
jarrHLWTemos.Add(jobjhlwTemp);
JObject jobjygtTemp = new JObject();
jobjygtTemp.Add("web_code", "YGT_YZ");
jobjygtTemp.Add("bno", new JValue(item.MBLNO.Trim()));
jarrYGTTemos.Add(jobjygtTemp);
}
if (jarrHLWTemos.Count > 0)
{
JObject HLWjobjSend = new JObject();
HLWjobjSend.Add("user_key", new JValue(key));
HLWjobjSend.Add("user_secret", new JValue(secret));
HLWjobjSend.Add("customer_id", new JValue(UserManager.TENANT_ID));
HLWjobjSend.Add("customer_name", new JValue(UserManager.TENANT_NAME));
HLWjobjSend.Add("data_list", jarrHLWTemos);
var json = HLWjobjSend.ToJsonString();
_logger.LogInformation("运踪查询HLW+参数:" + json);
var rtn = await url.SetHttpMethod(HttpMethod.Post).SetBody(HLWjobjSend.ToJsonString()).PostAsStringAsync();
_logger.LogInformation("运踪查询HLW+查询结果:" + rtn);
await ExecuteHLW(rtn);
}
if (jarrYGTTemos.Count > 0)
{
JObject YGTjobjSend = new JObject();
YGTjobjSend.Add("user_key", new JValue(key));
YGTjobjSend.Add("user_secret", new JValue(secret));
YGTjobjSend.Add("customer_id", new JValue(UserManager.TENANT_ID));
YGTjobjSend.Add("customer_name", new JValue(UserManager.TENANT_NAME));
YGTjobjSend.Add("data_list", jarrYGTTemos);
var json = YGTjobjSend.ToJsonString();
_logger.LogInformation("运踪查询YGT参数" + json);
var rtn = await url.SetHttpMethod(HttpMethod.Post).SetBody(YGTjobjSend.ToJsonString()).PostAsStringAsync();
_logger.LogInformation("运踪查询YGT查询结果" + rtn);
await ExecuteYGT(rtn);
}
}
[NonAction] [NonAction]
[SqlSugarUnitOfWork] [SqlSugarUnitOfWork]
public async Task ExecuteYard(string rtn) public async Task ExecuteYard(string rtn)

Loading…
Cancel
Save