|
|
|
@ -1,6 +1,9 @@
|
|
|
|
|
using DS.Module.Core;
|
|
|
|
|
using DS.WMS.Core.Op.Dtos.TaskInteraction;
|
|
|
|
|
using DS.WMS.Core.Op.Entity;
|
|
|
|
|
using DS.WMS.Core.Op.Entity.TaskInteraction;
|
|
|
|
|
using DS.WMS.Core.Op.Interface.TaskInteraction;
|
|
|
|
|
using Masuit.Tools.Systems;
|
|
|
|
|
|
|
|
|
|
namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor
|
|
|
|
|
{
|
|
|
|
@ -25,5 +28,57 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor
|
|
|
|
|
{
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 如果指定类型的任务不存在则创建
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="bsId">业务ID</param>
|
|
|
|
|
/// <param name="type">业务类型</param>
|
|
|
|
|
/// <param name="taskType">任务类型</param>
|
|
|
|
|
/// <param name="taskService">任务服务</param>
|
|
|
|
|
/// <param name="logService">任务日志服务</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
protected async Task<DataResult> CreateTaskIfNotExistAsync(long bsId, BusinessType type, TaskBaseTypeEnum taskType,
|
|
|
|
|
ITaskService taskService, ITaskLogService? logService = null)
|
|
|
|
|
{
|
|
|
|
|
ArgumentNullException.ThrowIfNull(taskService, nameof(taskService));
|
|
|
|
|
|
|
|
|
|
var result = await taskService.ExistsAsync(bsId, type, taskType);
|
|
|
|
|
//任务已存在,跳过创建步骤
|
|
|
|
|
if (result.Data)
|
|
|
|
|
return DataResult.Success;
|
|
|
|
|
|
|
|
|
|
return await taskService.CreateTaskAsync(new TaskCreationRequest
|
|
|
|
|
{
|
|
|
|
|
BusinessId = bsId,
|
|
|
|
|
BusinessType = type,
|
|
|
|
|
TaskTypeName = taskType.ToString()
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 设置任务状态为完成
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="task">任务对象</param>
|
|
|
|
|
/// <param name="taskService">任务服务</param>
|
|
|
|
|
/// <param name="logService">任务日志服务</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
protected virtual async Task SetTaskCompleteAsync(BusinessTask task, ITaskService taskService, ITaskLogService? logService = null)
|
|
|
|
|
{
|
|
|
|
|
ArgumentNullException.ThrowIfNull(task, nameof(task));
|
|
|
|
|
ArgumentNullException.ThrowIfNull(taskService, nameof(taskService));
|
|
|
|
|
|
|
|
|
|
var result = await taskService.SetTaskStatusAsync(new TaskUpdateRequest
|
|
|
|
|
{
|
|
|
|
|
BusinessId = task.BusinessId,
|
|
|
|
|
BusinessType = task.BusinessType,
|
|
|
|
|
TaskTypeName = task.TaskType.ToString(),
|
|
|
|
|
TaskStatus = TaskStatusEnum.Complete,
|
|
|
|
|
AutoCreateNext = true
|
|
|
|
|
});
|
|
|
|
|
if (!result.Succeeded && logService != null)
|
|
|
|
|
await logService.WriteLogAsync(task, $"未能设置任务【{task.NextType?.GetDescription()}】完成,返回结果:{result.Message}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|