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