diff --git a/ds-wms-service/DS.WMS.Core/Info/Entity/InfoClient.cs b/ds-wms-service/DS.WMS.Core/Info/Entity/InfoClient.cs index 8a9d9c5d..d3f67fcc 100644 --- a/ds-wms-service/DS.WMS.Core/Info/Entity/InfoClient.cs +++ b/ds-wms-service/DS.WMS.Core/Info/Entity/InfoClient.cs @@ -24,9 +24,9 @@ public class InfoClient : SharedOrgModel public string ShortName { get; set; } /// - /// Desc:客户中文名称或描述信息 + /// Desc:客户全称 /// - [SugarColumn(ColumnDescription = "客户中文名称或描述信息", IsNullable = true, Length = 50)] + [SugarColumn(ColumnDescription = "客户全称", IsNullable = true, Length = 50)] public string? Description { get; set; } /// diff --git a/ds-wms-service/DS.WMS.Core/Op/Entity/TaskInteraction/MailTemplateModel.cs b/ds-wms-service/DS.WMS.Core/Op/Entity/TaskInteraction/MailTemplateModel.cs index 73970582..27e286f7 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Entity/TaskInteraction/MailTemplateModel.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Entity/TaskInteraction/MailTemplateModel.cs @@ -55,6 +55,21 @@ /// public Contact? Document { get; set; } + /// + /// 订舱口全称 + /// + public string? ForwarderName { get; set; } + + /// + /// 国内发货人全称 + /// + public string? DomesticShipperName { get; set; } + + /// + /// 委托单位全称 + /// + public string? CustomerName { get; set; } + /// /// 主要数据项 /// diff --git a/ds-wms-service/DS.WMS.Core/Op/Interface/TaskInteraction/IActionManagerService.cs b/ds-wms-service/DS.WMS.Core/Op/Interface/TaskInteraction/IActionManagerService.cs index dccdbbe7..01cc16bb 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Interface/TaskInteraction/IActionManagerService.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Interface/TaskInteraction/IActionManagerService.cs @@ -3,8 +3,6 @@ using DS.Module.Core.Condition; using DS.Module.Core.Data; using DS.WMS.Core.Op.Entity; using DS.WMS.Core.Op.Entity.TaskInteraction; -using DS.WMS.Core.Sys.Entity; -using SqlSugar; namespace DS.WMS.Core.Op.Interface.TaskInteraction { @@ -48,13 +46,6 @@ namespace DS.WMS.Core.Op.Interface.TaskInteraction /// Task GetBusinessDataAsync(long businessId, BusinessType businessType, params string[] fields); - /// - /// 返回用户查询对象 - /// - /// 用户ID - /// - ISugarQueryable GetUserQueryable(params long[] ids); - /// /// 执行特定动作 /// diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionExecutor/Booking/MailActionExecutor.cs b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionExecutor/Booking/MailActionExecutor.cs index 355d28ab..0815526c 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionExecutor/Booking/MailActionExecutor.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionExecutor/Booking/MailActionExecutor.cs @@ -58,14 +58,14 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor.Booking return; } - var model = await MailService.GetTemplateModelAsync(context.ActionManager, context.TaskInfo.BusinessId, context.TaskInfo.BusinessType); + MailService mailService = new(context.ServiceProvider); + var model = await mailService.GetTemplateModelAsync(context.ActionManager, context.TaskInfo.BusinessId, context.TaskInfo.BusinessType); if (model.Primary == null) { await LogService.WriteLogAsync(context.TaskInfo, $"未能获取Id={context.TaskInfo.BusinessId} {context.TaskInfo.BusinessType.GetDescription()}的订单数据"); return; } - MailService mailService = new(context.ServiceProvider); var result = await mailService.SendAsync(mailConfig, model); if (!result.Succeeded) { diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionExecutor/SpaceRelease/SpaceReleaseActionExecutor.cs b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionExecutor/SpaceRelease/SpaceReleaseActionExecutor.cs index 0c7cbbfb..94fee54d 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionExecutor/SpaceRelease/SpaceReleaseActionExecutor.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionExecutor/SpaceRelease/SpaceReleaseActionExecutor.cs @@ -74,7 +74,8 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor.SpaceRelease return; } - var model = await MailService.GetTemplateModelAsync(context.ActionManager, context.TaskInfo.BusinessId, context.TaskInfo.BusinessType); + MailService mailService = new MailService(context.ServiceProvider); + var model = await mailService.GetTemplateModelAsync(context.ActionManager, context.TaskInfo.BusinessId, context.TaskInfo.BusinessType); if (model.Primary == null) { await logService.WriteLogAsync(context.TaskInfo, $"未能获取Id={context.TaskInfo.BusinessId} {context.TaskInfo.BusinessType.GetDescription()}的订单数据"); @@ -90,8 +91,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor.SpaceRelease } model.Primary.YardInfo = result.Data; - - MailService mailService = new MailService(context.ServiceProvider); var result3 = await mailService.SendAsync(mailConfig, model); if (!result3.Succeeded) { 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 e39de6d3..9e1ecb05 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 @@ -327,9 +327,5 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction } } - public ISugarQueryable GetUserQueryable(params long[] ids) - { - return Db.Queryable().Where(x => ids.Contains(x.Id)); - } } } diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/MailService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/MailService.cs index fde36812..920af40d 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/MailService.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/MailService.cs @@ -3,6 +3,7 @@ using DS.Module.Core; using DS.Module.Core.Data; using DS.Module.PrintModule; using DS.WMS.Core.Code.Entity; +using DS.WMS.Core.Info.Entity; using DS.WMS.Core.Op.Dtos; using DS.WMS.Core.Op.Dtos.TaskInteraction; using DS.WMS.Core.Op.Entity; @@ -64,7 +65,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction /// 业务ID /// 业务类型 /// - public static async Task GetTemplateModelAsync(IActionManagerService actionManager, + public async Task GetTemplateModelAsync(IActionManagerService actionManager, long bsId, BusinessType? businessType = null) { ArgumentNullException.ThrowIfNull(actionManager, nameof(actionManager)); @@ -80,7 +81,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction return model; List> list = []; - + long? forwarderId = null, shipperCNId = null, customerId = null; var order = model.Primary as SeaExportRes; if (order != null) { @@ -88,6 +89,10 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction list.Add(new Tuple(order.OperatorId, "op")); list.Add(new Tuple(order.CustomerService, "cs")); list.Add(new Tuple(order.Doc, "doc")); + + forwarderId = order.ForwarderId; + shipperCNId = order.ShipperCnId; + customerId = order.CustomerId; } else { @@ -106,12 +111,28 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction if (dic.TryGetValue(nameof(SeaExport.Doc), out object? doc)) list.Add(new Tuple((long)doc, nameof(doc))); + + if (dic.TryGetValue(nameof(SeaExport.ForwarderId), out object? forwarder) && forwarder != null) + forwarderId = (long)forwarder; + + if (dic.TryGetValue(nameof(SeaExport.ShipperCnId), out object? shipperCN) && shipperCN != null) + shipperCNId = (long)shipperCN; + + if (dic.TryGetValue(nameof(SeaExport.CustomerId), out object? customer) && customer != null) + customerId = (long)customer; } + long?[] custIds = [forwarderId, shipperCNId, customerId]; + var custList = await TenantDb.Queryable().Where(x => custIds.Contains(x.Id)) + .Select(x => new { x.Id,x.Description }).ToListAsync(); + model.ForwarderName = custList.Find(x => x.Id == forwarderId)?.Description; + model.DomesticShipperName = custList.Find(x => x.Id == shipperCNId)?.Description; + model.CustomerName = custList.Find(x => x.Id == customerId)?.Description; + if (list.Count > 0) { var ids = list.Select(x => x.Item1).ToArray(); - var userList = await actionManager.GetUserQueryable(ids).Select(x => new Contact + var userList = await Db.Queryable().Where(x => ids.Contains(x.Id)).Select(x => new Contact { Id = x.Id, Email = x.Email, diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskMailService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskMailService.cs index 49e10468..8be83e31 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskMailService.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskMailService.cs @@ -13,7 +13,8 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction /// public class TaskMailService : ServiceBase, ITaskMailService { - Lazy actionService; + readonly Lazy actionService; + readonly MailService mailService; /// /// 初始化 @@ -22,6 +23,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction public TaskMailService(IServiceProvider provider) : base(provider) { actionService = new Lazy(provider.GetRequiredService()); + mailService = new(provider); } /// @@ -40,8 +42,8 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction return DataResult.FailedWithDesc(MultiLanguageConst.EmptyData); if (string.IsNullOrEmpty(taskMail.Content)) return DataResult.Success(taskMail.Content); - - var model = await MailService.GetTemplateModelAsync(actionService.Value, bsId, BusinessType.OceanShippingExport); + + var model = await mailService.GetTemplateModelAsync(actionService.Value, bsId, BusinessType.OceanShippingExport); if (model.Primary == null) return DataResult.FailedWithDesc(MultiLanguageConst.EmptyData); @@ -65,7 +67,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction return DataResult>.FailedWithDesc(MultiLanguageConst.EmptyData); var bsId = await TenantDb.Queryable().Where(x => x.CustomerNo.Contains(customerNO)).Select(x => x.Id).FirstAsync(); - var model = await MailService.GetTemplateModelAsync(actionService.Value, bsId, BusinessType.OceanShippingExport); + var model = await mailService.GetTemplateModelAsync(actionService.Value, bsId, BusinessType.OceanShippingExport); string title = await MailService.RenderTemplateAsync(taskMail.Title, model); string content = await MailService.RenderTemplateAsync(taskMail.Content, model);