wet 2 years ago
commit 5a615847dd

@ -22,31 +22,45 @@ namespace Myshipping.Application.Helper
var cacheService = App.GetService<ISysCacheService>(); var cacheService = App.GetService<ISysCacheService>();
var webAccService = App.GetService<IDjyWebsiteAccountConfigService>(); var webAccService = App.GetService<IDjyWebsiteAccountConfigService>();
var sysConfig = await cacheService.GetAllSysConfig(); var sysConfig = await cacheService.GetAllSysConfig();
var userKey = sysConfig.FirstOrDefault(x => x.Code == "spiderUserKeyBilltrace"); var userKey = sysConfig.FirstOrDefault(x => x.Code == "spiderUserKeyBilltrace");
var userSecret = sysConfig.FirstOrDefault(x => x.Code == "spiderUserSecretBilltrace"); var userSecret = sysConfig.FirstOrDefault(x => x.Code == "spiderUserSecretBilltrace");
var spiderServerUrl = sysConfig.FirstOrDefault(x => x.Code == "spiderServerUrlBillTraceNew"); var spiderServerUrl = sysConfig.FirstOrDefault(x => x.Code == "spiderServerUrlBillTraceNew");
if (yardid == "YIHANG" || yardid == "YZH") yardid = "GLJ"; var needYgtAccountList = cacheService.GetAllDictData().Result.Where(x => x.TypeCode == "YardListNeedYgtAccount").ToList();//需要云港通账号的场站
var needLhtAccountList = cacheService.GetAllDictData().Result.Where(x => x.TypeCode == "YardListNeedLhtAccount").ToList();//需要陆海通账号的场站
var webAcc = "";
var webPwd = "";
if (needYgtAccountList.Count(x => x.Code == yardid) > 0)
{
//从租户参数中获取网站云港通账号密码
var tenantParam = await cacheService.GetAllTenantParam();
var ygtAcc = await webAccService.GetAccountConfig("YunGangTong", userId);
if (ygtAcc == null || string.IsNullOrEmpty(ygtAcc.Account) || string.IsNullOrEmpty(ygtAcc.Password))
{
return new KeyValuePair<bool, string>(false, "未找到云港通账号、密码配置,请到账号维护模块中添加");
}
webAcc = ygtAcc.Account;
webPwd = ygtAcc.Password;
}
var qduname = ""; if (needLhtAccountList.Count(x => x.Code == yardid) > 0)
var qdpwd = "";
if (yardid == "YGT" || yardid == "CHANGRONG" || yardid == "GLR" || yardid == "JZLG")
{ {
//从租户参数中获取网站青岛港账号密码 //从租户参数中获取网站云港通账号密码
var tenantParam = await cacheService.GetAllTenantParam(); var tenantParam = await cacheService.GetAllTenantParam();
var qdPortAcc = await webAccService.GetAccountConfig("QingDaoPort", userId); var ygtAcc = await webAccService.GetAccountConfig("LuHaiTong", userId);
//var tenantUserName = tenantParam.FirstOrDefault(x => x.TenantId == tenantId && x.ParaCode == "QDPORT_USERNAME");
//var tenantPwd = tenantParam.FirstOrDefault(x => x.TenantId == tenantId && x.ParaCode == "QDPORT_PWD");
if (qdPortAcc == null || string.IsNullOrEmpty(qdPortAcc.Account) || string.IsNullOrEmpty(qdPortAcc.Password)) if (ygtAcc == null || string.IsNullOrEmpty(ygtAcc.Account) || string.IsNullOrEmpty(ygtAcc.Password))
{ {
return new KeyValuePair<bool, string>(false, "未找到青岛港用户名、密码配置,请到账号维护模块中添加"); return new KeyValuePair<bool, string>(false, "未找到陆海通账号、密码配置,请到账号维护模块中添加");
} }
qduname = qdPortAcc.Account; webAcc = ygtAcc.Account;
qdpwd = qdPortAcc.Password; webPwd = ygtAcc.Password;
} }
var yardMappings = await cacheService.GetAllMappingYard(); var yardMappings = await cacheService.GetAllMappingYard();
@ -65,8 +79,8 @@ namespace Myshipping.Application.Helper
web_code = ym.MapCode, web_code = ym.MapCode,
bno = mblno, bno = mblno,
req_type = isWeb ? "1" : "0", req_type = isWeb ? "1" : "0",
web_user = qduname, web_user = webAcc,
web_psw = qdpwd, web_psw = webPwd,
}; };
var urlYard = spiderServerUrl.Value; var urlYard = spiderServerUrl.Value;

@ -2209,22 +2209,22 @@ namespace Myshipping.Application
throw Oops.Bah("放舱信息未找到,请先保存数据"); throw Oops.Bah("放舱信息未找到,请先保存数据");
} }
var mailAcc = await _repUserMail.FirstOrDefaultAsync(x => x.CreatedUserId == user.Id && x.SmtpPort > 0 && x.SmtpServer != null && x.SmtpServer != ""); if (string.IsNullOrEmpty(letterYard.AttnMail))
if (mailAcc == null)
{ {
throw Oops.Bah("用户邮箱未设置或smtp未正确配置"); throw Oops.Bah("ATTN MAIL未正确填写");
} }
var orderUrl = await _repOrderUrl.FirstOrDefaultAsync(u => u.BookingId == bookingId); var mailAcc = await _repUserMail.FirstOrDefaultAsync(x => x.CreatedUserId == user.Id && x.MailAccount == letterYard.AttnMail && x.SmtpPort > 0 && x.SmtpServer != null && x.SmtpServer != "");
if (orderUrl == null) if (mailAcc == null)
{ {
throw Oops.Bah("未生成链接信息,请重新保存数据"); throw Oops.Bah("用户邮箱未设置或smtp未正确配置");
} }
if (string.IsNullOrEmpty(letterYard.AttnMail)) var orderUrl = await _repOrderUrl.FirstOrDefaultAsync(u => u.BookingId == bookingId);
{ //if (orderUrl == null)
throw Oops.Bah("ATTN MAIL未正确填写"); //{
} // throw Oops.Bah("未生成链接信息,请重新保存数据");
//}
#region 保存放舱文件,并挂载到订舱附件 #region 保存放舱文件,并挂载到订舱附件
var fileBytes = await GetReportFile(bookingId, "fangcang"); var fileBytes = await GetReportFile(bookingId, "fangcang");
@ -2285,6 +2285,13 @@ namespace Myshipping.Application
extContent = $"危险品等级:{order.DCLASS} <br/>危险品编号:{order.DUNNO}<br/>"; extContent = $"危险品等级:{order.DCLASS} <br/>危险品编号:{order.DUNNO}<br/>";
} }
var linkContent = string.Empty;
if (orderUrl != null)
{
linkContent = $@"提箱小票链接:<a href='{orderUrl.UrlTxxp}'>{orderUrl.UrlTxxp}</a><br/>
VGM<a href='{orderUrl.UrlVgm}'>{orderUrl.UrlVgm}</a><br/>";
}
var mailContent = $@"TO:{order.CUSTOMERNAME} 贵司委托我司代理订舱出口的货物信息如下,详情请见附件,谢谢!<br/> var mailContent = $@"TO:{order.CUSTOMERNAME} 贵司委托我司代理订舱出口的货物信息如下,详情请见附件,谢谢!<br/>
{order.MBLNO}<br/> {order.MBLNO}<br/>
{order.VESSEL}/{order.VOYNO}<br/> {order.VESSEL}/{order.VOYNO}<br/>
@ -2297,8 +2304,7 @@ namespace Myshipping.Application
VGM{order.CLOSEVGMDATE}<br/> VGM{order.CLOSEVGMDATE}<br/>
{extContent} {extContent}
{order.YARDREMARK}<br/> {order.YARDREMARK}<br/>
<a href='{orderUrl.UrlTxxp}'>{orderUrl.UrlTxxp}</a><br/> {linkContent}
VGM<a href='{orderUrl.UrlVgm}'>{orderUrl.UrlVgm}</a><br/>
<br/> <br/>
<span style='color:red;'></span><br/> <span style='color:red;'></span><br/>
<span style='color:red;'></span><br/> <span style='color:red;'></span><br/>
@ -2310,7 +2316,7 @@ namespace Myshipping.Application
{user.Email} {user.Email}
<br/>"; <br/>";
var sendResult = await MailSendHelper.SendMail(mailAcc, mailSubject, mailContent, letterYard.AttnMail); var sendResult = await MailSendHelper.SendMail(mailAcc, mailSubject, mailContent, letterYard.AttnMail, new KeyValuePair<string, byte[]>(fileSaveName, fileBytes));
if (!sendResult.Key) if (!sendResult.Key)
{ {
_logger.LogError($"放舱邮件发送失败:从{mailAcc.MailAccount}到{letterYard.AttnMail},主题 {mailSubject}"); _logger.LogError($"放舱邮件发送失败:从{mailAcc.MailAccount}到{letterYard.AttnMail},主题 {mailSubject}");
@ -4275,6 +4281,13 @@ namespace Myshipping.Application
primaryModel.wNCM = ediExtModel.WNCM; primaryModel.wNCM = ediExtModel.WNCM;
primaryModel.ORDERREMARK = ediExtModel.OrderRemark; primaryModel.ORDERREMARK = ediExtModel.OrderRemark;
//2023-05-10 (PIL)订舱的预抵日期不提供输入框,按照和川操作要求取开船日期填写到预抵日期
if (string.IsNullOrWhiteSpace(primaryModel.ETA) && !string.IsNullOrWhiteSpace(primaryModel.ETD) &&
ediRouteEnum == EDIRouteEnum.PIL)
{
primaryModel.ETA = primaryModel.ETD;
}
primaryModel.KINGTAREWEIGHT = ediExtModel.KingTareweight.HasValue ? ediExtModel.KingTareweight.Value : 0; primaryModel.KINGTAREWEIGHT = ediExtModel.KingTareweight.HasValue ? ediExtModel.KingTareweight.Value : 0;
_logger.LogInformation("批次={no} 提取箱完成 数量={total}", batchNo, contaList.Count); _logger.LogInformation("批次={no} 提取箱完成 数量={total}", batchNo, contaList.Count);
@ -5629,7 +5642,8 @@ namespace Myshipping.Application
} }
var CtnDayNumlist = await GetGoodsStatusList(item.Id); var CtnDayNumlist = await GetGoodsStatusList(item.Id);
if (CtnDayNumlist!=null) { if (CtnDayNumlist != null)
{
item.CtnDayNum = CtnDayNumlist.Where(x => x.StatusName == "申请箱使").Select(x => x.ExtData).FirstOrDefault(); item.CtnDayNum = CtnDayNumlist.Where(x => x.StatusName == "申请箱使").Select(x => x.ExtData).FirstOrDefault();
} }

@ -328,7 +328,7 @@ namespace Myshipping.Application
try try
{ {
var res = await url.SetHttpMethod(HttpMethod.Post) var res = await url.SetClientTimeout(180).SetHttpMethod(HttpMethod.Post)
.SetBody(JSON.Serialize(info), "application/json") .SetBody(JSON.Serialize(info), "application/json")
.SetContentEncoding(Encoding.UTF8) .SetContentEncoding(Encoding.UTF8)
.PostAsync(); .PostAsync();

@ -21,7 +21,8 @@ namespace Myshipping.Core.Helper
/// <param name="subject"></param> /// <param name="subject"></param>
/// <param name="body"></param> /// <param name="body"></param>
/// <param name="sendTo"></param> /// <param name="sendTo"></param>
public static async Task<KeyValuePair<bool, string>> SendMail(DjyUserMailAccount acc, string subject, string body, string sendTo) /// <param name="attachList">附件列表key为附件名称value为文件字节数组</param>
public static async Task<KeyValuePair<bool, string>> SendMail(DjyUserMailAccount acc, string subject, string body, string sendTo, params KeyValuePair<string, byte[]>[] attachList)
{ {
SmtpClient client = null; SmtpClient client = null;
try try
@ -58,16 +59,33 @@ namespace Myshipping.Core.Helper
} }
message.Subject = subject; message.Subject = subject;
message.Sender = MailboxAddress.Parse(acc.MailAccount);
var html = new TextPart("html") var html = new TextPart("html")
{ {
Text = body Text = body
}; };
MimeEntity entity = html; if (attachList != null && attachList.Length > 0)
{
var mult = new Multipart("mixed") { html };
message.Sender = MailboxAddress.Parse(acc.MailAccount); foreach (var item in attachList)
message.Body = entity; {
var attPart = new MimePart();
attPart.Content = new MimeContent(new MemoryStream(item.Value));
attPart.ContentDisposition = new ContentDisposition(ContentDisposition.Attachment);
attPart.ContentTransferEncoding = ContentEncoding.Base64;
attPart.FileName = "=?UTF-8?B?" + Convert.ToBase64String(Encoding.UTF8.GetBytes(item.Key)) + "?=";
mult.Add(attPart);
}
message.Body = mult;
}
else
{
message.Body = html;
}
using (client = new SmtpClient()) using (client = new SmtpClient())
{ {

@ -5557,7 +5557,7 @@
<param name="title">标题</param> <param name="title">标题</param>
<param name="content">内容</param> <param name="content">内容</param>
</member> </member>
<member name="M:Myshipping.Core.Helper.MailSendHelper.SendMail(Myshipping.Core.Entity.DjyUserMailAccount,System.String,System.String,System.String)"> <member name="M:Myshipping.Core.Helper.MailSendHelper.SendMail(Myshipping.Core.Entity.DjyUserMailAccount,System.String,System.String,System.String,System.Collections.Generic.KeyValuePair{System.String,System.Byte[]}[])">
<summary> <summary>
使用用户邮箱配置发送邮件 使用用户邮箱配置发送邮件
</summary> </summary>
@ -5565,6 +5565,7 @@
<param name="subject"></param> <param name="subject"></param>
<param name="body"></param> <param name="body"></param>
<param name="sendTo"></param> <param name="sendTo"></param>
<param name="attachList">附件列表key为附件名称value为文件字节数组</param>
</member> </member>
<member name="M:Myshipping.Core.Helper.NpoiExcelExportHelper.CreateRow(NPOI.SS.UserModel.ISheet,System.Int32)"> <member name="M:Myshipping.Core.Helper.NpoiExcelExportHelper.CreateRow(NPOI.SS.UserModel.ISheet,System.Int32)">
<summary> <summary>

Loading…
Cancel
Save