|
|
|
@ -231,174 +231,178 @@ public class FlowRuntime
|
|
|
|
|
public string GetNextConditionNodeId(FlowChild parent)
|
|
|
|
|
{
|
|
|
|
|
var conditionNodes = GetFlowConditions(parent);
|
|
|
|
|
string? conditionId = null;
|
|
|
|
|
if (conditionNodes.Count == 1)
|
|
|
|
|
conditionId = conditionNodes[0].Id;
|
|
|
|
|
|
|
|
|
|
var conditionId = string.Empty;
|
|
|
|
|
for (int i = 0; i < conditionNodes.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
var conditions = conditionNodes[i].Conditions;
|
|
|
|
|
var conditionalCollections = new List<ConditionalCollections>();
|
|
|
|
|
if (conditions.LogicalOperator == "and")
|
|
|
|
|
if (i == conditionNodes.Count - 1)
|
|
|
|
|
{
|
|
|
|
|
var conditionList = new List<KeyValuePair<WhereType, ConditionalModel>>();
|
|
|
|
|
foreach (var item in conditions.Conditions)
|
|
|
|
|
{
|
|
|
|
|
conditionList.Add(new KeyValuePair<WhereType, ConditionalModel>
|
|
|
|
|
(WhereType.And,
|
|
|
|
|
new ConditionalModel
|
|
|
|
|
{
|
|
|
|
|
FieldName = item.Field,
|
|
|
|
|
ConditionalType = GetConditionalType(item.Operator),
|
|
|
|
|
FieldValue = item.Value
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (conditionList.Count > 0)
|
|
|
|
|
// return ChildNodes.Where(x => x.Pid == conditionNodes[i].Id).First().Id;
|
|
|
|
|
conditionId = conditionNodes[i].Id;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var conditions = conditionNodes[i].Conditions;
|
|
|
|
|
var conditionalCollections = new List<ConditionalCollections>();
|
|
|
|
|
if (conditions.LogicalOperator == "and")
|
|
|
|
|
{
|
|
|
|
|
conditionalCollections.Add(new ConditionalCollections
|
|
|
|
|
var conditionList = new List<KeyValuePair<WhereType, ConditionalModel>>();
|
|
|
|
|
foreach (var item in conditions.Conditions)
|
|
|
|
|
{
|
|
|
|
|
ConditionalList = conditionList
|
|
|
|
|
conditionList.Add(new KeyValuePair<WhereType, ConditionalModel>
|
|
|
|
|
(WhereType.And,
|
|
|
|
|
new ConditionalModel
|
|
|
|
|
{
|
|
|
|
|
FieldName = item.Field,
|
|
|
|
|
ConditionalType = GetConditionalType(item.Operator),
|
|
|
|
|
FieldValue = item.Value
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var groupList = new List<KeyValuePair<WhereType, ConditionalModel>>();
|
|
|
|
|
foreach (var group in conditions.Groups)
|
|
|
|
|
{
|
|
|
|
|
if (group.LogicalOperator == "and")
|
|
|
|
|
if (conditionList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var item1 in group.Conditions)
|
|
|
|
|
conditionalCollections.Add(new ConditionalCollections
|
|
|
|
|
{
|
|
|
|
|
groupList.Add(new KeyValuePair<WhereType, ConditionalModel>
|
|
|
|
|
(WhereType.And,
|
|
|
|
|
new ConditionalModel
|
|
|
|
|
{
|
|
|
|
|
FieldName = item1.Field,
|
|
|
|
|
ConditionalType = GetConditionalType(item1.Operator),
|
|
|
|
|
FieldValue = item1.Value
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
ConditionalList = conditionList
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
|
|
|
|
|
var groupList = new List<KeyValuePair<WhereType, ConditionalModel>>();
|
|
|
|
|
foreach (var group in conditions.Groups)
|
|
|
|
|
{
|
|
|
|
|
foreach (var item1 in group.Conditions)
|
|
|
|
|
if (group.LogicalOperator == "and")
|
|
|
|
|
{
|
|
|
|
|
foreach (var item1 in group.Conditions)
|
|
|
|
|
{
|
|
|
|
|
groupList.Add(new KeyValuePair<WhereType, ConditionalModel>
|
|
|
|
|
(WhereType.And,
|
|
|
|
|
new ConditionalModel
|
|
|
|
|
{
|
|
|
|
|
FieldName = item1.Field,
|
|
|
|
|
ConditionalType = GetConditionalType(item1.Operator),
|
|
|
|
|
FieldValue = item1.Value
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
groupList.Add(new KeyValuePair<WhereType, ConditionalModel>
|
|
|
|
|
(WhereType.Or,
|
|
|
|
|
new ConditionalModel
|
|
|
|
|
{
|
|
|
|
|
FieldName = item1.Field,
|
|
|
|
|
ConditionalType = GetConditionalType(item1.Operator),
|
|
|
|
|
FieldValue = item1.Value
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
foreach (var item1 in group.Conditions)
|
|
|
|
|
{
|
|
|
|
|
groupList.Add(new KeyValuePair<WhereType, ConditionalModel>
|
|
|
|
|
(WhereType.Or,
|
|
|
|
|
new ConditionalModel
|
|
|
|
|
{
|
|
|
|
|
FieldName = item1.Field,
|
|
|
|
|
ConditionalType = GetConditionalType(item1.Operator),
|
|
|
|
|
FieldValue = item1.Value
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (groupList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
conditionalCollections.Add(new ConditionalCollections
|
|
|
|
|
if (groupList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
ConditionalList = groupList
|
|
|
|
|
conditionalCollections.Add(new ConditionalCollections
|
|
|
|
|
{
|
|
|
|
|
ConditionalList = groupList
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var conditionList = new List<KeyValuePair<WhereType, ConditionalModel>>();
|
|
|
|
|
foreach (var item in conditions.Conditions)
|
|
|
|
|
{
|
|
|
|
|
conditionList.Add(new KeyValuePair<WhereType, ConditionalModel>
|
|
|
|
|
(WhereType.Or,
|
|
|
|
|
new ConditionalModel
|
|
|
|
|
{
|
|
|
|
|
FieldName = item.Field,
|
|
|
|
|
ConditionalType = GetConditionalType(item.Operator),
|
|
|
|
|
FieldValue = item.Value
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (conditionList.Count > 0)
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
conditionalCollections.Add(new ConditionalCollections
|
|
|
|
|
var conditionList = new List<KeyValuePair<WhereType, ConditionalModel>>();
|
|
|
|
|
foreach (var item in conditions.Conditions)
|
|
|
|
|
{
|
|
|
|
|
ConditionalList = conditionList
|
|
|
|
|
conditionList.Add(new KeyValuePair<WhereType, ConditionalModel>
|
|
|
|
|
(WhereType.Or,
|
|
|
|
|
new ConditionalModel
|
|
|
|
|
{
|
|
|
|
|
FieldName = item.Field,
|
|
|
|
|
ConditionalType = GetConditionalType(item.Operator),
|
|
|
|
|
FieldValue = item.Value
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var groupList = new List<KeyValuePair<WhereType, ConditionalModel>>();
|
|
|
|
|
foreach (var group in conditions.Groups)
|
|
|
|
|
{
|
|
|
|
|
if (group.LogicalOperator == "and")
|
|
|
|
|
if (conditionList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var item1 in group.Conditions)
|
|
|
|
|
conditionalCollections.Add(new ConditionalCollections
|
|
|
|
|
{
|
|
|
|
|
groupList.Add(new KeyValuePair<WhereType, ConditionalModel>
|
|
|
|
|
(WhereType.And,
|
|
|
|
|
new ConditionalModel
|
|
|
|
|
{
|
|
|
|
|
FieldName = item1.Field,
|
|
|
|
|
ConditionalType = GetConditionalType(item1.Operator),
|
|
|
|
|
FieldValue = item1.Value
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
ConditionalList = conditionList
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
|
|
|
|
|
var groupList = new List<KeyValuePair<WhereType, ConditionalModel>>();
|
|
|
|
|
foreach (var group in conditions.Groups)
|
|
|
|
|
{
|
|
|
|
|
foreach (var item1 in group.Conditions)
|
|
|
|
|
if (group.LogicalOperator == "and")
|
|
|
|
|
{
|
|
|
|
|
foreach (var item1 in group.Conditions)
|
|
|
|
|
{
|
|
|
|
|
groupList.Add(new KeyValuePair<WhereType, ConditionalModel>
|
|
|
|
|
(WhereType.And,
|
|
|
|
|
new ConditionalModel
|
|
|
|
|
{
|
|
|
|
|
FieldName = item1.Field,
|
|
|
|
|
ConditionalType = GetConditionalType(item1.Operator),
|
|
|
|
|
FieldValue = item1.Value
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
groupList.Add(new KeyValuePair<WhereType, ConditionalModel>
|
|
|
|
|
(WhereType.Or,
|
|
|
|
|
new ConditionalModel
|
|
|
|
|
{
|
|
|
|
|
FieldName = item1.Field,
|
|
|
|
|
ConditionalType = GetConditionalType(item1.Operator),
|
|
|
|
|
FieldValue = item1.Value
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
foreach (var item1 in group.Conditions)
|
|
|
|
|
{
|
|
|
|
|
groupList.Add(new KeyValuePair<WhereType, ConditionalModel>
|
|
|
|
|
(WhereType.Or,
|
|
|
|
|
new ConditionalModel
|
|
|
|
|
{
|
|
|
|
|
FieldName = item1.Field,
|
|
|
|
|
ConditionalType = GetConditionalType(item1.Operator),
|
|
|
|
|
FieldValue = item1.Value
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (groupList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
conditionalCollections.Add(new ConditionalCollections
|
|
|
|
|
if (groupList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
ConditionalList = groupList
|
|
|
|
|
conditionalCollections.Add(new ConditionalCollections
|
|
|
|
|
{
|
|
|
|
|
ConditionalList = groupList
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var conditionalModels = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(JsonConvert.SerializeObject(conditionalCollections));
|
|
|
|
|
if (conditionalModels.Count == 0) //跳过默认条件
|
|
|
|
|
continue;
|
|
|
|
|
var conditionalModels = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(JsonConvert.SerializeObject(conditionalCollections));
|
|
|
|
|
if (conditionalModels.Count == 0) //跳过默认条件
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
ISqlSugarClient sugarClient = tenantDb ?? db;
|
|
|
|
|
var exists = sugarClient.Queryable<object>().AS(ColumnView).Where("Id=@Id", new { Id = BusinessId }).Where(conditionalModels).Any();
|
|
|
|
|
if (exists)
|
|
|
|
|
{
|
|
|
|
|
conditionId = conditionNodes[i].Id;
|
|
|
|
|
break;
|
|
|
|
|
ISqlSugarClient sugarClient = tenantDb ?? db;
|
|
|
|
|
var exists = sugarClient.Queryable<object>().AS(ColumnView).Where("Id=@Id", new { Id = BusinessId }).Where(conditionalModels).Any();
|
|
|
|
|
if (exists)
|
|
|
|
|
{
|
|
|
|
|
conditionId = conditionNodes[i].Id;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ChildNodes.Where(x => x.Pid == conditionId).First().Id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取下一个节点
|
|
|
|
|
/// </summary>
|
|
|
|
|