修改BC任务台生成订舱的联系人处理,增加校验判断

master
jianghaiqing 7 months ago
parent 68ac09740d
commit f2f2cd8754

@ -1336,6 +1336,8 @@ namespace Myshipping.Application
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError($"任务BC MBLNO:{taskBCInfo.MBL_NO} 生成舱位异常,原因:{ex.Message}"); _logger.LogError($"任务BC MBLNO:{taskBCInfo.MBL_NO} 生成舱位异常,原因:{ex.Message}");
throw Oops.Oh($"MBLNO:{taskBCInfo.MBL_NO} 生成舱位异常,原因:{ex.Message}");
} }
return id; return id;
@ -1434,12 +1436,13 @@ namespace Myshipping.Application
//这里如果指定了委托单位的邮件联系人,则推送订舱联系人 //这里如果指定了委托单位的邮件联系人,则推送订舱联系人
if (generateModel.CustomerContactList != null && generateModel.CustomerContactList.Count > 0) if (generateModel.CustomerContactList != null && generateModel.CustomerContactList.Count > 0)
{ {
var bookingContactList = _bookingOrderContactRepository.AsQueryable() var bookingContactList = _bookingOrderContactRepository.AsQueryable()
.Where(a => a.BookingId == id && !a.IsDeleted).ToList(); .Where(a => a.BookingId == id && a.IsDeleted == false).ToList();
var djyCustomerInfo = _djyCustomerService.Detail(new GetDjyCustomerInput { Id = generateModel.CustomerId.Value }) var djyCustomerInfo = _djyCustomerService.Detail(new GetDjyCustomerInput { Id = generateModel.CustomerId.Value })
.GetAwaiter().GetResult(); .GetAwaiter().GetResult();
Dictionary<long, Tuple<string, string>> finalContactDict = new Dictionary<long, Tuple<string, string>>();
generateModel.CustomerContactList.ForEach(contact => generateModel.CustomerContactList.ForEach(contact =>
{ {
@ -1451,6 +1454,8 @@ namespace Myshipping.Application
a.Id == contact.CustomerContactId); a.Id == contact.CustomerContactId);
} }
finalContactDict.Add(contact.CustomerContactId, new Tuple<string, string>(djyCustomerContactMan?.Email, contact.CustomerContactName));
if (djyCustomerContactMan != null) if (djyCustomerContactMan != null)
{ {
var bookingContact = bookingContactList var bookingContact = bookingContactList
@ -1493,7 +1498,45 @@ namespace Myshipping.Application
} }
} }
}); });
//这里对于入库后的联系人再做一下比对,如果有差异需要邮件推送消息
var checkbookingContactList = _bookingOrderContactRepository.AsQueryable()
.Where(a => a.BookingId == id && a.IsDeleted == false).ToList();
if (finalContactDict.Any(x => string.IsNullOrWhiteSpace(x.Value.Item1)))
{
//推送邮件提醒
new EmailNoticeHelper().SendEmailNotice($"MBLNO={taskBCInfo.MBL_NO} 生成订舱的联系人失败"
, $"MBLNO={taskBCInfo.MBL_NO} 生成订舱的联系人失败,有联系人没有关联到邮箱信息 {string.Join(",",finalContactDict.Where(x => string.IsNullOrWhiteSpace(x.Value.Item1)).ToArray())}", App.Configuration["EmailNoticeDefaultUser"].GetUserEmailList());
}
var checkRlt = generateModel.CustomerContactList.GroupJoin(finalContactDict, l => l.CustomerContactId, r => r.Key,
(l, r) =>
{
var currArg = r.ToList();
if(currArg.Count > 0)
{
var currModel = currArg.FirstOrDefault();
if (string.IsNullOrWhiteSpace(currModel.Value.Item1))
{
return new { UName = currModel.Value.Item2, IsNoEmail = true };
}
return new { UName = currModel.Value.Item2, IsNoEmail = false };
}
return new { UName = l.CustomerContactName, IsNoEmail = true };
}).ToList();
if (checkRlt.Any(t => t.IsNoEmail))
{
//推送邮件提醒
new EmailNoticeHelper().SendEmailNotice($"MBLNO={taskBCInfo.MBL_NO} 生成订舱的联系人失败"
, $"MBLNO={taskBCInfo.MBL_NO} 生成订舱的联系人失败,有联系人没有关联到邮箱信息 {string.Join(",", checkRlt.Where(x => x.IsNoEmail).Select(x => x.UName).ToArray())}", App.Configuration["EmailNoticeDefaultUser"].GetUserEmailList());
}
} }
if (generateModel.ProjectList != null && generateModel.ProjectList.Count > 0) if (generateModel.ProjectList != null && generateModel.ProjectList.Count > 0)
@ -3648,7 +3691,7 @@ namespace Myshipping.Application
DjyCustomerContactOutput djyCustomerContactMan = djyCustomerInfo.Contacts DjyCustomerContactOutput djyCustomerContactMan = djyCustomerInfo.Contacts
.FirstOrDefault(a => a.Id == contact.CustomerContactId); .FirstOrDefault(a => a.Id == contact.CustomerContactId);
if (contact == null) if (djyCustomerContactMan == null)
{ {
_logger.LogInformation($"委托单位{model.CustomerName} 联系人 {contact.CustomerContactName}获取失败,联系人不存在或已作废 taskid={model.BCTaskId}"); _logger.LogInformation($"委托单位{model.CustomerName} 联系人 {contact.CustomerContactName}获取失败,联系人不存在或已作废 taskid={model.BCTaskId}");

Loading…
Cancel
Save