wet 2 years ago
commit 5a615847dd

@ -22,31 +22,45 @@ namespace Myshipping.Application.Helper
var cacheService = App.GetService<ISysCacheService>();
var webAccService = App.GetService<IDjyWebsiteAccountConfigService>();
var sysConfig = await cacheService.GetAllSysConfig();
var userKey = sysConfig.FirstOrDefault(x => x.Code == "spiderUserKeyBilltrace");
var userSecret = sysConfig.FirstOrDefault(x => x.Code == "spiderUserSecretBilltrace");
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 = "";
var qdpwd = "";
if (yardid == "YGT" || yardid == "CHANGRONG" || yardid == "GLR" || yardid == "JZLG")
if (needLhtAccountList.Count(x => x.Code == yardid) > 0)
{
//从租户参数中获取网站青岛港账号密码
//从租户参数中获取网站云港通账号密码
var tenantParam = await cacheService.GetAllTenantParam();
var qdPortAcc = await webAccService.GetAccountConfig("QingDaoPort", 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");
var ygtAcc = await webAccService.GetAccountConfig("LuHaiTong", userId);
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;
qdpwd = qdPortAcc.Password;
webAcc = ygtAcc.Account;
webPwd = ygtAcc.Password;
}
var yardMappings = await cacheService.GetAllMappingYard();
@ -65,8 +79,8 @@ namespace Myshipping.Application.Helper
web_code = ym.MapCode,
bno = mblno,
req_type = isWeb ? "1" : "0",
web_user = qduname,
web_psw = qdpwd,
web_user = webAcc,
web_psw = webPwd,
};
var urlYard = spiderServerUrl.Value;

@ -2209,22 +2209,22 @@ namespace Myshipping.Application
throw Oops.Bah("放舱信息未找到,请先保存数据");
}
var mailAcc = await _repUserMail.FirstOrDefaultAsync(x => x.CreatedUserId == user.Id && x.SmtpPort > 0 && x.SmtpServer != null && x.SmtpServer != "");
if (mailAcc == null)
if (string.IsNullOrEmpty(letterYard.AttnMail))
{
throw Oops.Bah("用户邮箱未设置或smtp未正确配置");
throw Oops.Bah("ATTN MAIL未正确填写");
}
var orderUrl = await _repOrderUrl.FirstOrDefaultAsync(u => u.BookingId == bookingId);
if (orderUrl == null)
var mailAcc = await _repUserMail.FirstOrDefaultAsync(x => x.CreatedUserId == user.Id && x.MailAccount == letterYard.AttnMail && x.SmtpPort > 0 && x.SmtpServer != null && x.SmtpServer != "");
if (mailAcc == null)
{
throw Oops.Bah("未生成链接信息,请重新保存数据");
throw Oops.Bah("用户邮箱未设置或smtp未正确配置");
}
if (string.IsNullOrEmpty(letterYard.AttnMail))
{
throw Oops.Bah("ATTN MAIL未正确填写");
}
var orderUrl = await _repOrderUrl.FirstOrDefaultAsync(u => u.BookingId == bookingId);
//if (orderUrl == null)
//{
// throw Oops.Bah("未生成链接信息,请重新保存数据");
//}
#region 保存放舱文件,并挂载到订舱附件
var fileBytes = await GetReportFile(bookingId, "fangcang");
@ -2285,6 +2285,13 @@ namespace Myshipping.Application
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/>
{order.MBLNO}<br/>
{order.VESSEL}/{order.VOYNO}<br/>
@ -2297,8 +2304,7 @@ namespace Myshipping.Application
VGM{order.CLOSEVGMDATE}<br/>
{extContent}
{order.YARDREMARK}<br/>
<a href='{orderUrl.UrlTxxp}'>{orderUrl.UrlTxxp}</a><br/>
VGM<a href='{orderUrl.UrlVgm}'>{orderUrl.UrlVgm}</a><br/>
{linkContent}
<br/>
<span style='color:red;'></span><br/>
<span style='color:red;'></span><br/>
@ -2310,7 +2316,7 @@ namespace Myshipping.Application
{user.Email}
<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)
{
_logger.LogError($"放舱邮件发送失败:从{mailAcc.MailAccount}到{letterYard.AttnMail},主题 {mailSubject}");
@ -4275,6 +4281,13 @@ namespace Myshipping.Application
primaryModel.wNCM = ediExtModel.WNCM;
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;
_logger.LogInformation("批次={no} 提取箱完成 数量={total}", batchNo, contaList.Count);
@ -5629,7 +5642,8 @@ namespace Myshipping.Application
}
var CtnDayNumlist = await GetGoodsStatusList(item.Id);
if (CtnDayNumlist!=null) {
if (CtnDayNumlist != null)
{
item.CtnDayNum = CtnDayNumlist.Where(x => x.StatusName == "申请箱使").Select(x => x.ExtData).FirstOrDefault();
}

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

@ -21,7 +21,8 @@ namespace Myshipping.Core.Helper
/// <param name="subject"></param>
/// <param name="body"></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;
try
@ -58,16 +59,33 @@ namespace Myshipping.Core.Helper
}
message.Subject = subject;
message.Sender = MailboxAddress.Parse(acc.MailAccount);
var html = new TextPart("html")
{
Text = body
};
MimeEntity entity = html;
if (attachList != null && attachList.Length > 0)
{
var mult = new Multipart("mixed") { html };
message.Sender = MailboxAddress.Parse(acc.MailAccount);
message.Body = entity;
foreach (var item in attachList)
{
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())
{

@ -5557,7 +5557,7 @@
<param name="title">标题</param>
<param name="content">内容</param>
</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>
@ -5565,6 +5565,7 @@
<param name="subject"></param>
<param name="body"></param>
<param name="sendTo"></param>
<param name="attachList">附件列表key为附件名称value为文件字节数组</param>
</member>
<member name="M:Myshipping.Core.Helper.NpoiExcelExportHelper.CreateRow(NPOI.SS.UserModel.ISheet,System.Int32)">
<summary>

Loading…
Cancel
Save