|
|
|
@ -212,7 +212,12 @@ namespace DS.WMS.Core.TaskPlat
|
|
|
|
|
flowLogDetail.ConfigId = executeConfig.Id;
|
|
|
|
|
|
|
|
|
|
// 如果当前节点要执行(或者配置了默认执行节点)取出下一批要进行条件判断的节点列表
|
|
|
|
|
waitMatchConfigList = configList.Where(x => x.ParentConfigId == executeConfig.Id).ToList();
|
|
|
|
|
waitMatchConfigList.Clear();
|
|
|
|
|
if (!string.IsNullOrEmpty(executeConfig.NextConfigId))
|
|
|
|
|
{
|
|
|
|
|
var ids = executeConfig.NextConfigId.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => Convert.ToInt64(x));
|
|
|
|
|
waitMatchConfigList = configList.Where(x => ids.Contains(x.Id)).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 注入参数
|
|
|
|
|
var paramItemList = paramList.Where(x => x.ConfigId == executeConfig.Id).ToList();
|
|
|
|
@ -373,66 +378,89 @@ namespace DS.WMS.Core.TaskPlat
|
|
|
|
|
|
|
|
|
|
if (allConfigList.Count == 0) return null;
|
|
|
|
|
|
|
|
|
|
List<TaskFlowConfig> waitMatchConfigList = new();
|
|
|
|
|
long configId;
|
|
|
|
|
if (currentConfigId == null)
|
|
|
|
|
{
|
|
|
|
|
waitMatchConfigList.Add(allConfigList.First(x => x.IsMain));
|
|
|
|
|
configId = allConfigList.First(x => x.IsMain).Id;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var currentConfig = allConfigList.FirstOrDefault(x => x.Id == currentConfigId);
|
|
|
|
|
if (currentConfig == null) return null;
|
|
|
|
|
|
|
|
|
|
waitMatchConfigList.AddRange(allConfigList.Where(x => x.ParentConfigId == currentConfig.Id));
|
|
|
|
|
configId = currentConfigId.Value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (waitMatchConfigList.Count == 0) return null;
|
|
|
|
|
List<TaskFlowConfig> waitMatchConfigList = new();
|
|
|
|
|
for (int i = 0; i < allConfigList.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
var currentConfig = allConfigList.FirstOrDefault(x => x.Id == configId);
|
|
|
|
|
if (currentConfig == null || string.IsNullOrEmpty(currentConfig.NextConfigId))
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
var configIdList = waitMatchConfigList.Select(x => x.Id);
|
|
|
|
|
var conditionList = await tenantDb.Queryable<TaskFlowCondition>()
|
|
|
|
|
.Where(x => configIdList.Contains(x.ConfigId))
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
var nextIds = currentConfig.NextConfigId.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => Convert.ToInt64(x));
|
|
|
|
|
waitMatchConfigList = allConfigList.Where(x => nextIds.Contains(x.Id)).ToList();
|
|
|
|
|
|
|
|
|
|
var matchedConfigList = new List<TaskFlowConfig>();
|
|
|
|
|
foreach (var item in waitMatchConfigList)
|
|
|
|
|
{
|
|
|
|
|
var condition = conditionList.FirstOrDefault(x => x.ConfigId == item.Id);
|
|
|
|
|
if (condition == null || string.IsNullOrEmpty(condition.Content))
|
|
|
|
|
{
|
|
|
|
|
matchedConfigList.Add(item);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (waitMatchConfigList.Count == 0) return null; // 如果走了这一步的return,说明配置有问题:配置了下一节点的id,但是却查不到
|
|
|
|
|
|
|
|
|
|
var configIdList = waitMatchConfigList.Select(x => x.Id);
|
|
|
|
|
var conditionList = await tenantDb.Queryable<TaskFlowCondition>()
|
|
|
|
|
.Where(x => configIdList.Contains(x.ConfigId))
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
|
|
|
|
|
var matchedConfigList = new List<TaskFlowConfig>();
|
|
|
|
|
foreach (var item in waitMatchConfigList)
|
|
|
|
|
{
|
|
|
|
|
var contitionContent = JsonConvert.DeserializeObject<ConditionContent>(condition.Content)!;
|
|
|
|
|
if (ConditionHelper.IsPass(contitionContent, dataContext))
|
|
|
|
|
var condition = conditionList.FirstOrDefault(x => x.ConfigId == item.Id);
|
|
|
|
|
if (condition == null || string.IsNullOrEmpty(condition.Content))
|
|
|
|
|
{
|
|
|
|
|
matchedConfigList.Add(item);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var contitionContent = JsonConvert.DeserializeObject<ConditionContent>(condition.Content)!;
|
|
|
|
|
if (ConditionHelper.IsPass(contitionContent, dataContext))
|
|
|
|
|
{
|
|
|
|
|
matchedConfigList.Add(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TaskFlowConfig? executeConfig = null;
|
|
|
|
|
if (matchedConfigList.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
executeConfig = matchedConfigList[0];
|
|
|
|
|
}
|
|
|
|
|
else if (matchedConfigList.Count > 1)
|
|
|
|
|
{
|
|
|
|
|
executeConfig = matchedConfigList.FirstOrDefault(x => x.IsMoreMatchDefault);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (executeConfig == null)
|
|
|
|
|
{
|
|
|
|
|
executeConfig = waitMatchConfigList.FirstOrDefault(x => x.IsUnMatchDefault);
|
|
|
|
|
}
|
|
|
|
|
TaskFlowConfig? executeConfig = null;
|
|
|
|
|
if (matchedConfigList.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
executeConfig = matchedConfigList[0];
|
|
|
|
|
}
|
|
|
|
|
else if (matchedConfigList.Count > 1)
|
|
|
|
|
{
|
|
|
|
|
executeConfig = matchedConfigList.FirstOrDefault(x => x.IsMoreMatchDefault);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (executeConfig == null) return null;
|
|
|
|
|
if (executeConfig == null)
|
|
|
|
|
{
|
|
|
|
|
executeConfig = waitMatchConfigList.FirstOrDefault(x => x.IsUnMatchDefault);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var taskType = await tenantDb.Queryable<TaskFlowModule>().Where(x => x.Id == executeConfig.ExecuteModuleId).Select(x => x.TaskType).FirstAsync();
|
|
|
|
|
if (executeConfig == null)
|
|
|
|
|
{
|
|
|
|
|
// 如果最终还是没有匹配到,则需要判断情况
|
|
|
|
|
// 如果待匹配的分支只有1个,则继续循环判断下一节点;否则如果待匹配的分支有多个,则无法判断下一节点
|
|
|
|
|
if (waitMatchConfigList.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
configId = waitMatchConfigList[0].Id;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var taskType = await tenantDb.Queryable<TaskFlowModule>().Where(x => x.Id == executeConfig.ExecuteModuleId).Select(x => x.TaskType).FirstAsync();
|
|
|
|
|
|
|
|
|
|
if (taskType != null && Enum.TryParse(typeof(TaskBaseTypeEnum), taskType, out object? temp))
|
|
|
|
|
{
|
|
|
|
|
return ((TaskBaseTypeEnum)temp, executeConfig.Id);
|
|
|
|
|
if (taskType != null && Enum.TryParse(typeof(TaskBaseTypeEnum), taskType, out object? temp))
|
|
|
|
|
{
|
|
|
|
|
return ((TaskBaseTypeEnum)temp, executeConfig.Id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|