自动订舱

master
wanghaomei 7 months ago
parent a75ca0db88
commit 60035b0708

@ -80,7 +80,7 @@ namespace Myshipping.Application.EDI
//2.根据找到的客户及联系人信息,查找中远订舱模板
if (custOrder.BookingUserId > 0 && custOrder.BookingTenantId > 0)
{
custContact = await repCustomer.AsQueryable()
custContact = await repCustomer.AsQueryable().Filter(null, true)
.InnerJoin<DjyCustomerContact>((cust, contact) => cust.Id == contact.CustomerId)
.Where((cust, contact) => cust.CustSysId == custOrder.BookingTenantId && contact.CustSysId == custOrder.BookingUserId)
.Select((cust, contact) => contact)
@ -91,7 +91,7 @@ namespace Myshipping.Application.EDI
}
//根据:用户+船司+船司账号+约号,找到启用的模板
template = await repTemplate.AsQueryable().FirstAsync(x => x.CarrierId == custOrder.CARRIERID && x.UserId == custContact.Id && x.ContractNO == custOrder.CONTRACTNO && x.BookingAccount == postModel.webAccount && x.IsEnable);
template = await repTemplate.AsQueryable().Filter(null, true).FirstAsync(x => x.CarrierId == custOrder.CARRIERID && x.UserId == custContact.Id && x.ContractNO == custOrder.CONTRACTNO && x.BookingAccount == postModel.webAccount && x.IsEnable);
if (template == null)
{
return new KeyValuePair<bool, string>(false, "未找到订舱模板");
@ -322,7 +322,7 @@ namespace Myshipping.Application.EDI
hsCode = custOrder.HSCODE,
};
var ctns = await repCtn.AsQueryable().Where(x => x.BILLID == custOrder.Id).ToListAsync();
var ctns = await repCtn.AsQueryable().Filter(null, true).Where(x => x.BILLID == custOrder.Id).ToListAsync();
postModel.boxInfos = new List<ZhongYuanSoApiBoxInfo>();
foreach (var ctn in ctns)
{

@ -1673,21 +1673,39 @@ namespace Myshipping.Application
if (rtnList.Count(x => x.Success == false) == 0)
{
var tCustId = list.First().BookingTenantId;
_logger.LogInformation($"提交成功,准备自动订舱和审核");
//自动订舱和自动审核
var cust = await _repCustomer.AsQueryable().FirstAsync(x => x.CustSysId == tCustId);
var cust = await _repCustomer.AsQueryable().Filter(null, true).FirstAsync(x => x.CustSysId == tCustId);
if (cust != null)
{
_logger.LogInformation($"找到客户端租户对应客户:{cust.FullName}");
var paraCallApiAuditAuto = await _repCustomerParamValue.AsQueryable().FirstAsync(x => x.CustomerId == cust.Id && x.ParaCode == "BookingCallApiAndAuditAuto");
if (paraCallApiAuditAuto != null && paraCallApiAuditAuto.ItemCode == "YES")
{
foreach (var ordId in ordIdList)
{
await PostApiSO(ordId);
await AuditBooking(ordId, true, "系统自动审核");
try
{
_logger.LogInformation($"自动订舱:{ordId}");
await PostApiSO(ordId);
_logger.LogInformation($"自动审核:{ordId}");
await AuditBooking(ordId, true, "系统自动审核");
}
catch (Exception ex)
{
_logger.LogWarning($"自动订舱失败:{ordId},错误信息:{ex.Message}");
await AuditBooking(ordId, false, ex.Message, notFeedback: true);
throw ex;
}
}
}
}
else
{
_logger.LogWarning($"未找到客户CustSysId{tCustId}");
}
}
return rtnList;
@ -1698,9 +1716,9 @@ namespace Myshipping.Application
/// </summary>
/// <returns></returns>
[HttpPost("/BookingCustomerOrder/AuditBooking")]
public async Task AuditBooking(long id, bool accept, string comment)
public async Task AuditBooking(long id, bool accept, string comment, bool notFeedback = false)
{
var model = _rep.FirstOrDefault(x => x.Id == id);
var model = await _rep.AsQueryable().Filter(null, true).FirstAsync(x => x.Id == id);
if (model == null)
{
throw Oops.Bah("未找到业务信息");
@ -1720,33 +1738,37 @@ namespace Myshipping.Application
model.BSSTATUS = "已驳回";
}
//回推回执
var feedbackData = new BookingCustomerRecAduitFeedbackDto()
JObject jobjRtn = null;
if (!notFeedback)
{
Id = model.BSNO,
Accept = accept,
Comment = comment
};
//回推回执
var feedbackData = new BookingCustomerRecAduitFeedbackDto()
{
Id = model.BSNO,
Accept = accept,
Comment = comment
};
var feedbackObj = new BookingFeedbackDto(BookingFeedbackType.Audit.ToString());
feedbackObj.JsonContent = feedbackData.ToJsonString();
var feedbackObj = new BookingFeedbackDto(BookingFeedbackType.Audit.ToString());
feedbackObj.JsonContent = feedbackData.ToJsonString();
_logger.LogInformation($"回推审核数据:{JsonConvert.SerializeObject(feedbackObj)}URL{model.FeedbackUrl}");
_logger.LogInformation($"回推审核数据:{JsonConvert.SerializeObject(feedbackObj)}URL{model.FeedbackUrl}");
var rtn = await model.FeedbackUrl
.SetHeaders(new Dictionary<string, object> {
var rtn = await model.FeedbackUrl
.SetHeaders(new Dictionary<string, object> {
{ CommonConst.API_USER_HEADER_KEY, model.FeedbackKey},
{ CommonConst.API_USER_HEADER_SECRET, model.FeedbackSecret}
})
.SetBody(feedbackObj, "application/x-www-form-urlencoded")
.PostAsStringAsync();
})
.SetBody(feedbackObj, "application/x-www-form-urlencoded")
.PostAsStringAsync();
_logger.LogInformation($"回推审核返回:{rtn}");
_logger.LogInformation($"回推审核返回:{rtn}");
var jobjRtn = JObject.Parse(rtn);
if (jobjRtn.GetIntValue("code") != 200)
{
throw Oops.Bah(jobjRtn.GetStringValue("message"));
jobjRtn = JObject.Parse(rtn);
if (jobjRtn.GetIntValue("code") != 200)
{
throw Oops.Bah(jobjRtn.GetStringValue("message"));
}
}
@ -1757,7 +1779,7 @@ namespace Myshipping.Application
//进入订舱台账
if (accept)
if (accept && jobjRtn != null)
{
var custBookId = jobjRtn.GetStringValue("data"); //返回的客户订舱系统的订舱数据id
var bkOrder = model.Adapt<BookingOrder>();

Loading…
Cancel
Save