diff --git a/ds-wms-service/DS.Module.Core/Enums/FeeStatus.cs b/ds-wms-service/DS.Module.Core/Enums/FeeStatus.cs index b750c764..29bc55d3 100644 --- a/ds-wms-service/DS.Module.Core/Enums/FeeStatus.cs +++ b/ds-wms-service/DS.Module.Core/Enums/FeeStatus.cs @@ -261,9 +261,9 @@ namespace DS.Module.Core SeaExport = 6, /// - /// 海运出口退单 + /// 海运出口退舱 /// - [Description("海运出口退单")] + [Description("海运出口退舱")] SeaExportReturn = 7 } } diff --git a/ds-wms-service/DS.Module.Core/Helpers/GenericHelper.cs b/ds-wms-service/DS.Module.Core/Helpers/GenericHelper.cs index 95072939..83a35ba5 100644 --- a/ds-wms-service/DS.Module.Core/Helpers/GenericHelper.cs +++ b/ds-wms-service/DS.Module.Core/Helpers/GenericHelper.cs @@ -5,32 +5,32 @@ namespace DS.Module.Core; /// public static class GenericHelper { - /// - /// 把数组转为逗号连接的字符串 - /// - /// - /// - /// - public static string ArrayToString(dynamic data, string Str) - { - string resStr = Str; - foreach (var item in data) - { - if (resStr != "") - { - resStr += ","; - } + ///// + ///// 把数组转为逗号连接的字符串 + ///// + ///// + ///// + ///// + //public static string ArrayToString(dynamic data, string Str) + //{ + // string resStr = Str; + // foreach (var item in data) + // { + // if (resStr != "") + // { + // resStr += ","; + // } - if (item is string) - { - resStr += item; - } - else - { - resStr += item.Value; + // if (item is string) + // { + // resStr += item; + // } + // else + // { + // resStr += item.Value; - } - } - return resStr; - } + // } + // } + // return resStr; + //} } \ No newline at end of file diff --git a/ds-wms-service/DS.Module.PrintModule/OpenJsonPrintReq.cs b/ds-wms-service/DS.Module.PrintModule/OpenJsonPrintReq.cs index f890de5c..6cea97a9 100644 --- a/ds-wms-service/DS.Module.PrintModule/OpenJsonPrintReq.cs +++ b/ds-wms-service/DS.Module.PrintModule/OpenJsonPrintReq.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace DS.Module.PrintModule +namespace DS.Module.PrintModule { /// /// Json打印请求数据 @@ -26,4 +20,32 @@ namespace DS.Module.PrintModule /// public string PrintType { get; set; } = "1"; } + + /// + /// Json打印请求数据 + /// + public class OpenPrintReq + { + public long TenantId { get; set; } + + /// + /// 模板Id + /// + public long? TemplateId { get; set; } + + /// + /// 模板代码 + /// + public string? TemplateCode { get; set; } + + /// + /// 查询语句SQL参数 + /// + public string ParamJsonStr { get; set; } = string.Empty; + + /// + /// 打印类型 1. PDF 2.EXCEL 3.WORD + /// + public string PrintType { get; set; } = "1"; + } } diff --git a/ds-wms-service/DS.WMS.Core/DS.WMS.Core.csproj b/ds-wms-service/DS.WMS.Core/DS.WMS.Core.csproj index 707b4119..61f2521f 100644 --- a/ds-wms-service/DS.WMS.Core/DS.WMS.Core.csproj +++ b/ds-wms-service/DS.WMS.Core/DS.WMS.Core.csproj @@ -22,6 +22,17 @@ + + + + + + + + true + PreserveNewest + + diff --git a/ds-wms-service/DS.WMS.Core/Flow/Method/ClientFlowInstanceService.cs b/ds-wms-service/DS.WMS.Core/Flow/Method/ClientFlowInstanceService.cs index c5bec760..62d90162 100644 --- a/ds-wms-service/DS.WMS.Core/Flow/Method/ClientFlowInstanceService.cs +++ b/ds-wms-service/DS.WMS.Core/Flow/Method/ClientFlowInstanceService.cs @@ -61,7 +61,7 @@ public class ClientFlowInstanceService : FlowInstanceService, IClientFlowInstanc var users = Db.Queryable().Where(x => nextConditionNode.Roles.Contains(x.RoleId.ToString())) .Select(x => x.UserId).Distinct().ToList(); - makerList = GenericHelper.ArrayToString(users, makerList); + makerList = string.Join(",", users); } else if (nextConditionNode.AssigneeType == "user") { diff --git a/ds-wms-service/DS.WMS.Core/Flow/Method/ClientFlowTemplateService.cs b/ds-wms-service/DS.WMS.Core/Flow/Method/ClientFlowTemplateService.cs index 0d868921..2e9577a0 100644 --- a/ds-wms-service/DS.WMS.Core/Flow/Method/ClientFlowTemplateService.cs +++ b/ds-wms-service/DS.WMS.Core/Flow/Method/ClientFlowTemplateService.cs @@ -47,18 +47,36 @@ public class ClientFlowTemplateService : IClientFlowTemplateService public DataResult EditClientFlowTemplate(FlowTemplateReq req) { + //if (req.Id == 0) + //{ + // return DataResult.Failed("非法请求!",MultiLanguageConst.IllegalRequest); + //} + //else + //{ + // var info = db.Queryable().Where(x => x.Id == req.Id).First(); + + // info = req.Adapt(info); + + // db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand(); + // return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess); + //} + if (req.Id == 0) { - return DataResult.Failed("非法请求!",MultiLanguageConst.IllegalRequest); + var isExist = db.Queryable().Where(x => x.Name == req.Name).First(); + if (isExist != null) + return DataResult.Failed("流程模板名称已存在!"); + + var data = req.Adapt(); + var entity = db.Insertable(data).ExecuteReturnEntity(); + return DataResult.Successed("添加成功!", entity.Id); } else { var info = db.Queryable().Where(x => x.Id == req.Id).First(); - info = req.Adapt(info); - db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand(); - return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess); + return DataResult.Successed("更新成功!"); } } diff --git a/ds-wms-service/DS.WMS.Core/Flow/Method/FlowInstanceService.cs b/ds-wms-service/DS.WMS.Core/Flow/Method/FlowInstanceService.cs index 695a7aa1..eca8327d 100644 --- a/ds-wms-service/DS.WMS.Core/Flow/Method/FlowInstanceService.cs +++ b/ds-wms-service/DS.WMS.Core/Flow/Method/FlowInstanceService.cs @@ -631,7 +631,7 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService var users = Db.Queryable().Where(x => wfruntime.NextNode.Roles.Contains(x.RoleId.ToString())) .Select(x => x.UserId).Distinct().ToList(); - makerList = GenericHelper.ArrayToString(users, makerList); + makerList = string.Join(",", users); } else if (wfruntime.NextNode.AssigneeType == "user") { @@ -667,7 +667,7 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService var users = Db.Queryable().Where(x => nextConditionNode.Roles.Contains(x.RoleId.ToString())) .Select(x => x.UserId).Distinct().ToList(); - makerList = GenericHelper.ArrayToString(users, makerList); + makerList = string.Join(",", users); } else if (nextConditionNode.AssigneeType == "user") { @@ -706,7 +706,7 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService var users = Db.Queryable().Where(x => node.Roles.Contains(x.RoleId.ToString())) .Select(x => x.UserId).Distinct().ToList(); - makerList = GenericHelper.ArrayToString(users, makerList); + makerList = string.Join(",", users); } else if (node.AssigneeType == "user") { diff --git a/ds-wms-service/DS.WMS.Core/Op/Dtos/TaskInteraction/ActionExecutionContext.cs b/ds-wms-service/DS.WMS.Core/Op/Dtos/TaskInteraction/ActionExecutionContext.cs index c324bf65..80928c35 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Dtos/TaskInteraction/ActionExecutionContext.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Dtos/TaskInteraction/ActionExecutionContext.cs @@ -1,5 +1,4 @@ using DS.WMS.Core.Op.Entity.TaskInteraction; -using SqlSugar; namespace DS.WMS.Core.Op.Dtos.TaskInteraction { @@ -12,8 +11,6 @@ namespace DS.WMS.Core.Op.Dtos.TaskInteraction public IServiceProvider ServiceProvider { get; internal set; } - public ISqlSugarClient TenantDb { get; internal set; } - public IDictionary AdditionalData { get; set; } = new Dictionary(); } } diff --git a/ds-wms-service/DS.WMS.Core/Op/Dtos/TaskInteraction/MailTemplateModel.cs b/ds-wms-service/DS.WMS.Core/Op/Dtos/TaskInteraction/MailTemplateModel.cs new file mode 100644 index 00000000..f4345689 --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Op/Dtos/TaskInteraction/MailTemplateModel.cs @@ -0,0 +1,14 @@ +namespace DS.WMS.Core.Op.Dtos.TaskInteraction +{ + /// + /// 邮件模板模型 + /// + /// 数据类型 + public class MailTemplateModel + { + /// + /// 主要数据项 + /// + public T? Primary { get; internal set; } + } +} diff --git a/ds-wms-service/DS.WMS.Core/Op/Dtos/TaskInteraction/PrintResult.cs b/ds-wms-service/DS.WMS.Core/Op/Dtos/TaskInteraction/PrintResult.cs new file mode 100644 index 00000000..ec27e895 --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Op/Dtos/TaskInteraction/PrintResult.cs @@ -0,0 +1,20 @@ +namespace DS.WMS.Core.Op.Dtos.TaskInteraction +{ + public class PrintResult + { + /// + /// 是否成功 + /// + public bool Succeeded { get; set; } + + /// + /// 返回消息 + /// + public string Message { get; set; } + + /// + /// 返回结果 + /// + public string Data { get; set; } + } +} diff --git a/ds-wms-service/DS.WMS.Core/Op/Entity/TaskInteraction/BusinessTaskAttachment.cs b/ds-wms-service/DS.WMS.Core/Op/Entity/TaskInteraction/BusinessTaskAttachment.cs index 15ba4385..e43fd789 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Entity/TaskInteraction/BusinessTaskAttachment.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Entity/TaskInteraction/BusinessTaskAttachment.cs @@ -19,5 +19,11 @@ namespace DS.WMS.Core.Op.Entity.TaskInteraction /// [SugarColumn(IsPrimaryKey = true)] public long TemplateId { get; set; } + + /// + /// 附件获取接口的URL + /// + [SugarColumn(ColumnDescription = "附件获取接口的URL", Length = 255, IsNullable = false)] + public string RequestURL { get; set; } = string.Empty; } } diff --git a/ds-wms-service/DS.WMS.Core/Op/Entity/TaskInteraction/BusinessTaskMailReceiver.cs b/ds-wms-service/DS.WMS.Core/Op/Entity/TaskInteraction/BusinessTaskMailReceiver.cs index d78af92a..e3b07618 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Entity/TaskInteraction/BusinessTaskMailReceiver.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Entity/TaskInteraction/BusinessTaskMailReceiver.cs @@ -44,100 +44,100 @@ namespace DS.WMS.Core.Op.Entity.TaskInteraction [SugarColumn(ColumnDescription = "是否委托单位", DefaultValue = "0")] public bool IsController { get; set; } - /// - /// Desc:是否报关行 - /// - [SugarColumn(ColumnDescription = "是否报关行", DefaultValue = "0")] - public bool IsCustom { get; set; } - - /// - /// Desc:是否代理(国外) - /// - [SugarColumn(ColumnDescription = "是否代理(国外)", DefaultValue = "0")] - public bool IsAgent { get; set; } - - /// - /// Desc:是否代理(国内) - /// - [SugarColumn(ColumnDescription = "是否代理(国内)", DefaultValue = "0")] - public bool IsAgentCn { get; set; } - - /// - /// Desc:是否快递公司 - /// - [SugarColumn(ColumnDescription = "是否快递公司", DefaultValue = "0")] - public bool IsExpress { get; set; } - - /// - /// Desc:是否航空公司 - /// - [SugarColumn(ColumnDescription = "是否航空公司", DefaultValue = "0")] - public bool IsAirLines { get; set; } - - /// - /// Desc:是否发货人 - /// - [SugarColumn(ColumnDescription = "是否发货人", DefaultValue = "0")] - public bool IsShipper { get; set; } - - /// - /// Desc:是否收货人 - /// - [SugarColumn(ColumnDescription = "是否收货人", DefaultValue = "0")] - public bool IsConsignee { get; set; } - - /// - /// Desc:是否通知人 - /// - [SugarColumn(ColumnDescription = "是否通知人", DefaultValue = "0")] - public bool IsNotifyParty { get; set; } - - /// - /// Desc:是否仓库 - /// - [SugarColumn(ColumnDescription = "是否仓库", DefaultValue = "0")] - public bool IsWareHouse { get; set; } - - /// - /// Desc:是否码头 - /// - [SugarColumn(ColumnDescription = "是否码头", DefaultValue = "0")] - public bool IsWharf { get; set; } - - /// - /// Desc:是否保险公司 - /// - [SugarColumn(ColumnDescription = "是否保险公司", DefaultValue = "0")] - public bool IsInsurer { get; set; } - - /// - /// Desc:是否租箱公司 - /// - [SugarColumn(ColumnDescription = "是否租箱公司", DefaultValue = "0")] - public bool IsLeasing { get; set; } - - /// - /// Desc:是否贸易代理 - /// - [SugarColumn(ColumnDescription = "是否贸易代理", DefaultValue = "0")] - public bool IsTradingAgency { get; set; } - - /// - /// Desc:是否船代 - /// - [SugarColumn(ColumnDescription = "是否船代", DefaultValue = "0")] - public bool IsShipAgency { get; set; } - - /// - /// Desc:是否经营单位 - /// - [SugarColumn(ColumnDescription = "是否经营单位", DefaultValue = "0")] - public bool IsEnterprise { get; set; } - - /// - /// Desc:是否国内发货人 - /// - [SugarColumn(ColumnDescription = "是否国内发货人", DefaultValue = "0")] - public bool IsShipperCn { get; set; } + ///// + ///// Desc:是否报关行 + ///// + //[SugarColumn(ColumnDescription = "是否报关行", DefaultValue = "0")] + //public bool IsCustom { get; set; } + + ///// + ///// Desc:是否代理(国外) + ///// + //[SugarColumn(ColumnDescription = "是否代理(国外)", DefaultValue = "0")] + //public bool IsAgent { get; set; } + + ///// + ///// Desc:是否代理(国内) + ///// + //[SugarColumn(ColumnDescription = "是否代理(国内)", DefaultValue = "0")] + //public bool IsAgentCn { get; set; } + + ///// + ///// Desc:是否快递公司 + ///// + //[SugarColumn(ColumnDescription = "是否快递公司", DefaultValue = "0")] + //public bool IsExpress { get; set; } + + ///// + ///// Desc:是否航空公司 + ///// + //[SugarColumn(ColumnDescription = "是否航空公司", DefaultValue = "0")] + //public bool IsAirLines { get; set; } + + ///// + ///// Desc:是否发货人 + ///// + //[SugarColumn(ColumnDescription = "是否发货人", DefaultValue = "0")] + //public bool IsShipper { get; set; } + + ///// + ///// Desc:是否收货人 + ///// + //[SugarColumn(ColumnDescription = "是否收货人", DefaultValue = "0")] + //public bool IsConsignee { get; set; } + + ///// + ///// Desc:是否通知人 + ///// + //[SugarColumn(ColumnDescription = "是否通知人", DefaultValue = "0")] + //public bool IsNotifyParty { get; set; } + + ///// + ///// Desc:是否仓库 + ///// + //[SugarColumn(ColumnDescription = "是否仓库", DefaultValue = "0")] + //public bool IsWareHouse { get; set; } + + ///// + ///// Desc:是否码头 + ///// + //[SugarColumn(ColumnDescription = "是否码头", DefaultValue = "0")] + //public bool IsWharf { get; set; } + + ///// + ///// Desc:是否保险公司 + ///// + //[SugarColumn(ColumnDescription = "是否保险公司", DefaultValue = "0")] + //public bool IsInsurer { get; set; } + + ///// + ///// Desc:是否租箱公司 + ///// + //[SugarColumn(ColumnDescription = "是否租箱公司", DefaultValue = "0")] + //public bool IsLeasing { get; set; } + + ///// + ///// Desc:是否贸易代理 + ///// + //[SugarColumn(ColumnDescription = "是否贸易代理", DefaultValue = "0")] + //public bool IsTradingAgency { get; set; } + + ///// + ///// Desc:是否船代 + ///// + //[SugarColumn(ColumnDescription = "是否船代", DefaultValue = "0")] + //public bool IsShipAgency { get; set; } + + ///// + ///// Desc:是否经营单位 + ///// + //[SugarColumn(ColumnDescription = "是否经营单位", DefaultValue = "0")] + //public bool IsEnterprise { get; set; } + + ///// + ///// Desc:是否国内发货人 + ///// + //[SugarColumn(ColumnDescription = "是否国内发货人", DefaultValue = "0")] + //public bool IsShipperCn { get; set; } } } diff --git a/ds-wms-service/DS.WMS.Core/Op/Entity/TaskInteraction/BusinessTaskMailServer.cs b/ds-wms-service/DS.WMS.Core/Op/Entity/TaskInteraction/BusinessTaskMailServer.cs index 28e5f08d..288b0809 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Entity/TaskInteraction/BusinessTaskMailServer.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Entity/TaskInteraction/BusinessTaskMailServer.cs @@ -13,7 +13,7 @@ namespace DS.WMS.Core.Op.Entity.TaskInteraction /// 服务器地址 /// [SugarColumn(ColumnDescription = "服务器地址", Length = 200, IsNullable = false)] - public string Server { get; set; } = string.Empty; + public string Host { get; set; } = string.Empty; /// /// 端口号 diff --git a/ds-wms-service/DS.WMS.Core/Op/MailTemplate.cshtml b/ds-wms-service/DS.WMS.Core/Op/MailTemplate.cshtml new file mode 100644 index 00000000..bb6c5272 --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Op/MailTemplate.cshtml @@ -0,0 +1,16 @@ +@model DS.WMS.Core.Op.Dtos.TaskInteraction.MailTemplateModel + +@{ + var item = Model.Primary; +} + +

测试邮件-@item.MBLNO@item.CustomerNo

+ +
+ 预计开船日期:@item.ETD + 预计抵达日期:@item.ETA +
+
+
+ 订单创建时间:@item.CreateTime.ToString("yyyy年MM月dd日 HH:mm:ss") +
diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionManagerService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionManagerService.cs index 6bd174b6..b323c407 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionManagerService.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionManagerService.cs @@ -55,8 +55,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction var context = new ActionExecutionContext { TaskInfo = dataContext.Get(TaskFlowDataNameConst.BusinessTask), - ServiceProvider = ServiceProvider, - TenantDb = TenantDb + ServiceProvider = ServiceProvider }; foreach (var key in dataContext.Keys) { diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/MailActionExecutor.cs b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/MailActionExecutor.cs index 1b7ab530..1810fdac 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/MailActionExecutor.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/MailActionExecutor.cs @@ -1,9 +1,21 @@ -using DS.Module.Core.Extensions; +using DS.Module.Core; +using DS.Module.PrintModule; +using DS.Module.SqlSugar; +using DS.Module.UserModule; +using DS.WMS.Core.Info.Entity; +using DS.WMS.Core.Op.Dtos; using DS.WMS.Core.Op.Dtos.TaskInteraction; +using DS.WMS.Core.Op.Interface; using DS.WMS.Core.Op.Interface.TaskInteraction; +using DS.WMS.Core.Sys.Entity; +using MailKit.Net.Smtp; +using Masuit.Tools; using Masuit.Tools.Systems; using Microsoft.Extensions.DependencyInjection; +using MimeKit; +using Newtonsoft.Json; using RazorEngineCore; +using SqlSugar; namespace DS.WMS.Core.Op.Method.TaskInteraction { @@ -12,6 +24,13 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction ///
public class MailActionExecutor : IActionExecutor { + static readonly ApiFox api; + + static MailActionExecutor() + { + api = new ApiFox(); + } + /// /// 发送邮件 /// @@ -19,8 +38,14 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction /// public async Task ExecuteAsync(ActionExecutionContext context) { + var db = context.ServiceProvider.GetRequiredService(); + var saasService = context.ServiceProvider.GetRequiredService(); + var user = context.ServiceProvider.GetRequiredService(); + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + var service = context.ServiceProvider.GetRequiredService(); var logService = context.ServiceProvider.GetRequiredService(); + var seService = context.ServiceProvider.GetRequiredService(); var mailName = context.AdditionalData["MailName"] as string; if (mailName.IsNullOrEmpty()) @@ -35,9 +60,141 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction return; } + var result = seService.GetSeaExportInfo(context.TaskInfo.BusinessId.ToString()); + if (!result.Succeeded) + { + await logService.WriteLogAsync(context.TaskInfo, $"未能获取Id={context.TaskInfo.BusinessId}的{context.TaskInfo.BusinessType.GetDescription()}数据"); + return; + } + + var templateModel = new MailTemplateModel { Primary = result.Data }; IRazorEngine razorEngine = new RazorEngine(); - IRazorEngineCompiledTemplate titleTemplate = razorEngine.Compile(mailConfig.Title); - IRazorEngineCompiledTemplate contentTemplate = razorEngine.Compile(mailConfig.Content); + var titleTemplate = razorEngine.Compile>>(mailConfig.Title); + string title = titleTemplate.Run(x => + { + x.Model = templateModel; + }); + var contentTemplate = razorEngine.Compile>>(mailConfig.Content); + string content = contentTemplate.Run(x => + { + x.Model = templateModel; + }); + var textPart = new TextPart("plain") { Text = content }; + var message = new MimeMessage + { + Subject = title, + }; + + //设置发件人 + List senderIds = new List(); + if (mailConfig.Sender.IsSale) + { + senderIds.Add(templateModel.Primary.SaleId); + } + if (mailConfig.Sender.IsOperator) + { + senderIds.Add(templateModel.Primary.OperatorId); + } + if (mailConfig.Sender.IsCustomerService) + { + senderIds.Add(templateModel.Primary.CustomerService); + } + if (mailConfig.Sender.IsVouchingClerk) + { + senderIds.Add(templateModel.Primary.Doc); + } + var senderList = await db.Queryable().Where(x => senderIds.Contains(x.Id) && x.Email != null && x.Email != string.Empty) + .Select(x => new { x.UserName, x.UserEnName, x.Email }).ToListAsync(); + foreach (var sender in senderList) + message.From.Add(new MailboxAddress(sender.UserName, sender.Email)); + + //设置收件人 + List receiverIds = new List(); + if (mailConfig.Receiver.IsCarrier) + { + receiverIds.Add(templateModel.Primary.CarrierId); + } + if (mailConfig.Receiver.IsBooking) + { + //receiverIds.Add(templateModel.Primary.CarrierId); + } + if (mailConfig.Receiver.IsYard) + { + receiverIds.Add(templateModel.Primary.YardId); + } + if (mailConfig.Receiver.IsTruck) + { + receiverIds.Add(templateModel.Primary.TruckerId); + } + if (mailConfig.Receiver.IsController) + { + receiverIds.Add(templateModel.Primary.CustomerId); + } + var receiverList = await tenantDb.Queryable().Where(x => receiverIds.Contains(x.Id) && x.Email != null && x.Email != string.Empty) + .Select(x => new { x.ShortName, x.EnShortName, x.Email }).ToListAsync(); + foreach (var item in receiverList) + message.To.Add(new MailboxAddress(item.ShortName, item.Email)); + + //需要上传附件 + if (mailConfig.Attachments?.Count > 0) + { + var multipart = new Multipart("mixed"); + multipart.Add(textPart); + + if (api.DefaultHeaders.Contains("Authorization")) + api.DefaultHeaders.Remove("Authorization"); + + api.DefaultHeaders.Add("Authorization", "Bearer " + user.GetToken()); + + long tenantId = long.Parse(user.TenantId); + foreach (var item in mailConfig.Attachments) + { + var req = new OpenPrintReq + { + ParamJsonStr = JsonConvert.SerializeObject(new { Id = context.TaskInfo.BusinessId }), + PrintType = "1", + TemplateId = item.TemplateId, + TenantId = tenantId + }; + var reqResult = await api.PostAsync(item.RequestURL, req); + if (reqResult.Succeeded) + { + + } + //var attachment = new MimePart("image", "gif") + //{ + // Content = new MimeContent(File.OpenRead(path), ContentEncoding.Default), + // ContentDisposition = new ContentDisposition(ContentDisposition.Attachment), + // ContentTransferEncoding = ContentEncoding.Base64, + // FileName = Path.GetFileName(path) + //}; + } + } + else + { + message.Body = textPart; + } + + var client = new SmtpClient(); + try + { + client.Connect(mailConfig.Server.Host, mailConfig.Server.Port, mailConfig.Server.UseSSL); + if (!mailConfig.Server.LoginName.IsNullOrEmpty() && !mailConfig.Server.Password.IsNullOrEmpty()) + { + client.Authenticate(mailConfig.Server.LoginName, mailConfig.Server.Password); + } + + client.Send(message); + client.Disconnect(true); + } + catch (Exception ex) + { + await ex.LogAsync(db); + } + finally + { + client?.Dispose(); + } } } } diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskService.cs index 2189f5c0..854f4de8 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskService.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskService.cs @@ -468,7 +468,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction if (useTransaction) await TenantDb.Ado.CommitTranAsync(); - ActionService.Value.TriggerAction(task); + //ActionService.Value.TriggerAction(task); return DataResult.Success(task.TaskStatus == TaskStatusEnum.Complete ? GetNextType(task) : null); } catch (Exception ex) diff --git a/ds-wms-service/DS.WMS.MainApi/DS.WMS.MainApi.csproj.user b/ds-wms-service/DS.WMS.MainApi/DS.WMS.MainApi.csproj.user index 996c16b7..73975b0c 100644 --- a/ds-wms-service/DS.WMS.MainApi/DS.WMS.MainApi.csproj.user +++ b/ds-wms-service/DS.WMS.MainApi/DS.WMS.MainApi.csproj.user @@ -1,6 +1,6 @@  - D:\Code\DS\ds8-solution-pro\ds-wms-service\DS.WMS.MainApi\Properties\PublishProfiles\FolderProfile.pubxml + D:\Source\Repos\DS8\ds-wms-service\DS.WMS.MainApi\Properties\PublishProfiles\FolderProfile.pubxml \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.OpApi/DS.WMS.OpApi.csproj.user b/ds-wms-service/DS.WMS.OpApi/DS.WMS.OpApi.csproj.user index da141c5a..fb7be066 100644 --- a/ds-wms-service/DS.WMS.OpApi/DS.WMS.OpApi.csproj.user +++ b/ds-wms-service/DS.WMS.OpApi/DS.WMS.OpApi.csproj.user @@ -1,7 +1,7 @@  - E:\MyCode\Dongsheng8\ds-wms-service\DS.WMS.OpApi\Properties\PublishProfiles\FolderProfile.pubxml + D:\Source\Repos\DS8\ds-wms-service\DS.WMS.OpApi\Properties\PublishProfiles\FolderProfile.pubxml MvcControllerEmptyScaffolder root/Common/MVC/Controller