增加客户端参数

usertest
嵇文龙 3 months ago
parent 937811c3cc
commit 179dac6155

@ -72,5 +72,11 @@ namespace DS.Module.Core
/// </summary>
/// <remarks>类型long</remarks>
public const string BusinessId = "BusinessId";
/// <summary>
/// 客户端参数
/// </summary>
/// <remarks>类型Param{T}</remarks>
public const string ClientParam = "ClientParam";
}
}

@ -66,8 +66,9 @@ namespace DS.WMS.Core.Op.Interface.TaskInteraction
/// </summary>
/// <param name="businessTask">任务信息</param>
/// <param name="includeOrder">是否包含订单数据</param>
/// <param name="additionalData">附加参数</param>
/// <returns></returns>
Task TriggerActionAsync(BusinessTask businessTask, bool includeOrder = false);
Task TriggerActionAsync(BusinessTask businessTask, bool includeOrder = false, IDictionary<string, object>? additionalData = null);
Task<DataResult> TriggerTestAsync(TaskBaseTypeEnum taskType, long? id);
}

@ -185,15 +185,12 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
/// </summary>
/// <param name="businessTask">任务信息</param>
/// <param name="includeOrder">是否包含订单数据</param>
/// <param name="additionalData">附加参数</param>
/// <returns></returns>
public async Task TriggerActionAsync(BusinessTask businessTask, bool includeOrder = false)
public async Task TriggerActionAsync(BusinessTask businessTask, bool includeOrder = false, IDictionary<string, object>? additionalData = null)
{
ArgumentNullException.ThrowIfNull(businessTask, nameof(businessTask));
////目前只限制任务完成才触发
//if (businessTask.TaskStatus != TaskStatusEnum.Complete)
// return;
TaskFlowDataContext dataContext = new(
(TaskFlowDataNameConst.BusinessTask, businessTask)
);
@ -204,6 +201,11 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
dataContext[TaskFlowDataNameConst.Business] = biz;
}
if (additionalData != null)
{
foreach (var item in additionalData)
dataContext[item.Key] = item.Value;
}
TaskFlowRuner taskFlow = new(TenantDb, ServiceProvider);
await taskFlow.RunWithBsno(businessTask.TaskType, businessTask.BusinessId, dataContext);

@ -12,7 +12,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionSelector
/// </summary>
public class BookingSelector : IActionSelector
{
const string Booking_Route = "BookingRoute";
internal const string Booking_Route = "BookingRoute";
public async Task<IActionExecutor> GetActionExecutor(ActionExecutionContext context)
{

@ -1,10 +1,12 @@
using DS.Module.Core;
using System.Threading.Tasks;
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.Module.Core.Helpers;
using DS.WMS.Core.Flow.Dtos;
using DS.WMS.Core.Flow.Entity;
using DS.WMS.Core.Flow.Interface;
using DS.WMS.Core.Flow.Method;
using DS.WMS.Core.Info.Interface;
using DS.WMS.Core.Op.Dtos.TaskInteraction;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Op.Entity.TaskInteraction;
@ -19,6 +21,7 @@ using Masuit.Tools;
using Masuit.Tools.Systems;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
using static DS.WMS.Core.Op.Method.TaskInteraction.ActionSelector.BookingSelector;
namespace DS.WMS.Core.Op.Method.TaskInteraction
{
@ -65,6 +68,11 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
/// </summary>
protected ISeaExportService OpService { get; private set; }
/// <summary>
/// 客户端参数服务
/// </summary>
protected IClientParamService ClientParamService { get; private set; }
/// <summary>
/// 初始化
/// </summary>
@ -77,6 +85,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
FlowService = provider.GetRequiredService<IClientFlowInstanceService>();
ActionService = provider.GetRequiredService<IActionManagerService>();
OpService = provider.GetRequiredService<ISeaExportService>();
ClientParamService = provider.GetRequiredService<IClientParamService>();
TenantDb.QueryFilter.Clear<IOrgId>();
}
@ -373,7 +382,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
};
if (!task.NextType.HasValue)
task.NextType = await GetNextTypeAsync(task);
await TenantDb.Insertable(task).ExecuteCommandAsync();
//审核任务需创建工作流
@ -527,7 +536,20 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
if (useTransaction)
await TenantDb.Ado.CommitTranAsync();
ActionService.TriggerActionAsync(task);
if (task.TaskStatus == TaskStatusEnum.Complete)//目前限制任务完成才触发
{
Dictionary<string, object>? dic = null;
if (request.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT)
{
dic = new Dictionary<string, object>();
var param = await ClientParamService.GetParamAsync<string>(task.BusinessId, Booking_Route,
(x, y) => x.CustomerId == y.ForwarderId);
dic[TaskFlowDataNameConst.ClientParam] = param;
}
ActionService.TriggerActionAsync(task, additionalData: dic);
}
return DataResult<TaskBaseTypeEnum?>.Success(task.TaskStatus == TaskStatusEnum.Complete ? await GetNextTypeAsync(task) : null);
}
catch (Exception ex)

Loading…
Cancel
Save