|
|
|
@ -126,7 +126,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
/// 大简云服务状态服务
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected Lazy<IDjyServiceStatusService> djyStatusService { get; private set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 初始化
|
|
|
|
|
/// </summary>
|
|
|
|
@ -190,14 +190,15 @@ namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
if (!await HasAuthorizedAsync())
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.ModuleUnauthorized));
|
|
|
|
|
|
|
|
|
|
if (request.Steps?.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
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?.Count > 0)
|
|
|
|
|
//{
|
|
|
|
|
// 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)))
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TypeOrName));
|
|
|
|
|
}
|
|
|
|
|
// if (request.Steps.Any(x => x.Type == StepType.NotSpecified && string.IsNullOrEmpty(x.Name)))
|
|
|
|
|
// return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TypeOrName));
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
if (request.HasCabin.GetValueOrDefault() && request.BusinessType.HasValue)
|
|
|
|
|
{
|
|
|
|
@ -448,13 +449,13 @@ namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
if (request.TaskStatus == TaskStatusEnum.Complete && await TenantDb.Queryable<BusinessTask>().AnyAsync(x => x.ParentId == task.Id && x.TaskStatus != request.TaskStatus))
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.UnfinishedItems));
|
|
|
|
|
|
|
|
|
|
//检查是否有未完成的任务步骤
|
|
|
|
|
var steps = await TenantDb.Queryable<TaskStep>().Where(x => x.TaskId == task.Id && !x.IsCompleted)
|
|
|
|
|
.Select(x => new { x.Type, x.Name }).ToListAsync();
|
|
|
|
|
if (steps.Count > 0)
|
|
|
|
|
return DataResult.Failed(
|
|
|
|
|
MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.UnfinishedItems)) + ":" + string.Join("|", steps.Select(x => x.Type == StepType.NotSpecified ? x.Name : x.Type.GetDescription())),
|
|
|
|
|
nameof(MultiLanguageConst.UnfinishedItems));
|
|
|
|
|
////检查是否有未完成的任务步骤
|
|
|
|
|
//var steps = await TenantDb.Queryable<TaskStep>().Where(x => x.TaskId == task.Id && !x.IsCompleted)
|
|
|
|
|
// .Select(x => new { x.Type, x.Name }).ToListAsync();
|
|
|
|
|
//if (steps.Count > 0)
|
|
|
|
|
// return DataResult.Failed(
|
|
|
|
|
// MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.UnfinishedItems)) + ":" + string.Join("|", steps.Select(x => x.Type == StepType.NotSpecified ? x.Name : x.Type.GetDescription())),
|
|
|
|
|
// nameof(MultiLanguageConst.UnfinishedItems));
|
|
|
|
|
|
|
|
|
|
//触发任务状态变更通知
|
|
|
|
|
if (task.TaskStatus != request.TaskStatus)
|
|
|
|
@ -548,7 +549,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
if (task.TaskStatus == TaskStatusEnum.Complete)
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskCompleted));
|
|
|
|
|
|
|
|
|
|
var allSteps = await TenantDb.Queryable<TaskStep>().Where(x => x.TaskId == task.Id).OrderBy(x => x.Priority)
|
|
|
|
|
var allSteps = await TenantDb.Queryable<TaskStep>().Where(x => x.TaskId == task.Id && !x.IsCompleted).OrderBy(x => x.Priority)
|
|
|
|
|
.Select(x => new TaskStep
|
|
|
|
|
{
|
|
|
|
|
Id = x.Id,
|
|
|
|
@ -557,7 +558,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
IsCompleted = x.IsCompleted,
|
|
|
|
|
Priority = x.Priority
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
if (allSteps.All(x => x.IsCompleted))
|
|
|
|
|
if (allSteps.Count == 0)
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskCompleted));
|
|
|
|
|
|
|
|
|
|
//获取未完成的优先级最高的步骤
|
|
|
|
@ -569,7 +570,9 @@ namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
DateTime dtNow = DateTime.Now;
|
|
|
|
|
foreach (var item in allSteps)
|
|
|
|
|
{
|
|
|
|
|
var reqStep = request.Steps.Find(x => x.Type == item.Type || (x.Type == StepType.NotSpecified && x.Name == item.Name));
|
|
|
|
|
var reqStep = item.Id == 0 ?
|
|
|
|
|
request.Steps.Find(x => x.Type == item.Type || (x.Type == StepType.NotSpecified && x.Name == item.Name)) :
|
|
|
|
|
request.Steps.Find(x => x.Id == item.Id);
|
|
|
|
|
if (reqStep == null)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
@ -593,21 +596,18 @@ namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
x.UpdateTime
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
if (request.AutoSync)
|
|
|
|
|
if (request.AutoSync && allSteps.Count > 0 && allSteps.Count == allSteps.Count(x => x.IsCompleted))
|
|
|
|
|
{
|
|
|
|
|
if (allSteps.Count > 0 && allSteps.Count == allSteps.Count(x => x.IsCompleted))
|
|
|
|
|
var result = await SetTaskStatusAsync(new TaskUpdateRequest
|
|
|
|
|
{
|
|
|
|
|
var result = await SetTaskStatusAsync(new TaskUpdateRequest
|
|
|
|
|
{
|
|
|
|
|
BusinessId = task.BusinessId,
|
|
|
|
|
BusinessType = task.BusinessType,
|
|
|
|
|
TaskTypeName = request.TaskTypeName,
|
|
|
|
|
TaskStatus = TaskStatusEnum.Complete
|
|
|
|
|
}, false);
|
|
|
|
|
BusinessId = task.BusinessId,
|
|
|
|
|
BusinessType = task.BusinessType,
|
|
|
|
|
TaskTypeName = request.TaskTypeName,
|
|
|
|
|
TaskStatus = TaskStatusEnum.Complete
|
|
|
|
|
}, false);
|
|
|
|
|
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (useTransaction)
|
|
|
|
|