cjy 3 months ago
commit 2822c8a5cc

@ -24,9 +24,9 @@ public class InfoClient : SharedOrgModel<long>
public string ShortName { get; set; }
/// <summary>
/// Desc:客户中文名称或描述信息
/// Desc:客户全称
/// </summary>
[SugarColumn(ColumnDescription = "客户中文名称或描述信息", IsNullable = true, Length = 50)]
[SugarColumn(ColumnDescription = "客户全称", IsNullable = true, Length = 50)]
public string? Description { get; set; }
/// <summary>

@ -55,6 +55,21 @@
/// </summary>
public Contact? Document { get; set; }
/// <summary>
/// 订舱口全称
/// </summary>
public string? ForwarderName { get; set; }
/// <summary>
/// 国内发货人全称
/// </summary>
public string? DomesticShipperName { get; set; }
/// <summary>
/// 委托单位全称
/// </summary>
public string? CustomerName { get; set; }
/// <summary>
/// 主要数据项
/// </summary>

@ -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
/// <returns></returns>
Task<dynamic?> GetBusinessDataAsync(long businessId, BusinessType businessType, params string[] fields);
/// <summary>
/// 返回用户查询对象
/// </summary>
/// <param name="ids">用户ID</param>
/// <returns></returns>
ISugarQueryable<SysUser> GetUserQueryable(params long[] ids);
/// <summary>
/// 执行特定动作
/// </summary>

@ -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)
{

@ -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)
{

@ -327,9 +327,5 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
}
}
public ISugarQueryable<SysUser> GetUserQueryable(params long[] ids)
{
return Db.Queryable<SysUser>().Where(x => ids.Contains(x.Id));
}
}
}

@ -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
/// <param name="bsId">业务ID</param>
/// <param name="businessType">业务类型</param>
/// <returns></returns>
public static async Task<MailTemplateModel> GetTemplateModelAsync(IActionManagerService actionManager,
public async Task<MailTemplateModel> 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<Tuple<long, string>> 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<long, string>(order.OperatorId, "op"));
list.Add(new Tuple<long, string>(order.CustomerService, "cs"));
list.Add(new Tuple<long, string>(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, string>((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<InfoClient>().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<SysUser>().Where(x => ids.Contains(x.Id)).Select(x => new Contact
{
Id = x.Id,
Email = x.Email,

@ -13,7 +13,8 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
/// </summary>
public class TaskMailService : ServiceBase, ITaskMailService
{
Lazy<IActionManagerService> actionService;
readonly Lazy<IActionManagerService> actionService;
readonly MailService mailService;
/// <summary>
/// 初始化
@ -22,6 +23,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
public TaskMailService(IServiceProvider provider) : base(provider)
{
actionService = new Lazy<IActionManagerService>(provider.GetRequiredService<IActionManagerService>());
mailService = new(provider);
}
/// <summary>
@ -40,8 +42,8 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
return DataResult<string>.FailedWithDesc(MultiLanguageConst.EmptyData);
if (string.IsNullOrEmpty(taskMail.Content))
return DataResult<string>.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<string>.FailedWithDesc(MultiLanguageConst.EmptyData);
@ -65,7 +67,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
return DataResult<Tuple<string, string>>.FailedWithDesc(MultiLanguageConst.EmptyData);
var bsId = await TenantDb.Queryable<SeaExport>().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);

Loading…
Cancel
Save