优化子任务处理

dev
嵇文龙 3 weeks ago
parent 2987ead5e5
commit f0d196021b

@ -1570,6 +1570,8 @@ public static class MultiLanguageConst
public const string TypeOrName = "TypeOrName";
[Description("此任务尚有未完成的优先级别更高的子任务或前置条件")]
public const string HigherUnfinishedItems = "Higher_Unfinished_Items";
[Description("无法获取主任务信息")]
public const string MainTaskNotFound = "Main_Task_NotFound";
#endregion
#region 任务台相关

@ -42,7 +42,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
if (request.Steps?.Count > 0)
{
if (request.Steps.Where(x => x.Type != StepType.NotSpecified).GroupBy(x => x.Type).Select(x => x.Key).Count() == 1)
if (request.Steps.Where(x => x.Type != StepType.NotSpecified).GroupBy(x => x.Type).Select(x => x.Key).Count() > 1)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.DuplicateStepType));
if (request.Steps.Any(x => x.Type == StepType.NotSpecified && string.IsNullOrEmpty(x.Name)))

@ -474,7 +474,31 @@ namespace DS.WMS.Core.TaskInteraction.Method
x.UpdateTime
}).ExecuteCommandAsync();
DataResult result = await ManagerService.SetTaskStatusWithBsno(request.BusinessId, request.TaskType, request.TaskStatus, DateTime.Now, false, request.TaskDesc);
DataResult result;
if (request.ParentId.HasValue || request.ParentBusinessId.HasValue) //设置子任务状态
{
var parentTask = await TenantDb.Queryable<BusinessTask>().Where(x => x.BusinessType == request.BusinessType)
.WhereIF(request.ParentId.HasValue, x => x.Id == request.ParentId)
.WhereIF(request.ParentBusinessId.HasValue, x => x.BusinessId == request.ParentBusinessId && x.TaskType == request.ParentTaskType)
.Select(x => new
{
x.BusinessId,
x.TaskType
}).FirstAsync();
if (parentTask == null)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.MainTaskNotFound));
result = await ManagerService.SetTaskStatusWithBsno(
parentTask.BusinessId, parentTask.TaskType,
request.TaskStatus, DateTime.Now, false, request.TaskDesc,
childBsno: request.BusinessId,
childTaskBaseTypeEnum: request.TaskType);
}
else
{
result = await ManagerService.SetTaskStatusWithBsno(request.BusinessId, request.TaskType, request.TaskStatus, DateTime.Now, false, request.TaskDesc);
}
if (!result.Succeeded)
return DataResult.Failed(result.Message, result.MultiCode);
@ -538,17 +562,16 @@ namespace DS.WMS.Core.TaskInteraction.Method
if (request.Steps == null || request.Steps.Count == 0)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.SubTaskCannotNull));
if (useTransaction)
await TenantDb.Ado.BeginTranAsync();
try
{
BusinessTask task = await GetQuery(request.BusinessId, request.BusinessType, request.TaskType).FirstAsync();
if (task == null)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskNotExists));
if (task.TaskStatus == TaskStatusEnum.Complete)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskCompleted));
if (useTransaction)
await TenantDb.Ado.BeginTranAsync();
try
{
var allSteps = await TenantDb.Queryable<TaskStep>().Where(x => x.TaskId == task.Id && !x.IsCompleted).OrderBy(x => x.Priority)
.Select(x => new TaskStep
{
@ -598,10 +621,11 @@ namespace DS.WMS.Core.TaskInteraction.Method
if (request.AutoSync && allSteps.Count > 0 && allSteps.Count == allSteps.Count(x => x.IsCompleted))
{
var result = await SetTaskStatusAsync(new TaskUpdateRequest
DataResult result = await SetTaskStatusAsync(new TaskUpdateRequest
{
BusinessId = task.BusinessId,
BusinessType = task.BusinessType,
ParentId = request.ParentId,
BusinessId = request.BusinessId,
BusinessType = request.BusinessType,
TaskTypeName = request.TaskTypeName,
TaskStatus = TaskStatusEnum.Complete
}, false);

Loading…
Cancel
Save