diff --git a/ds-wms-service/DS.WMS.Core/TaskPlat/Entity/TaskFlowConfig.cs b/ds-wms-service/DS.WMS.Core/TaskPlat/Entity/TaskFlowConfig.cs
index f2780a11..dfe4f160 100644
--- a/ds-wms-service/DS.WMS.Core/TaskPlat/Entity/TaskFlowConfig.cs
+++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Entity/TaskFlowConfig.cs
@@ -40,17 +40,17 @@ namespace DS.WMS.Core.TaskPlat.Entity
[SugarColumn(ColumnDescription = "所属主入口流程主键", IsNullable = true)]
public long? MainConfigId { get; set; }
- /////
- ///// 下一流程主键
- /////
- //[SugarColumn(ColumnDescription = "下一流程主键", IsNullable = true)]
- //public long? NextConfigId { get; set; }
-
///
- /// 父项流程主键
+ /// 下一流程主键列表(使用,分隔)
///
- [SugarColumn(ColumnDescription = "父项流程主键", IsNullable = true)]
- public long? ParentConfigId { get; set; }
+ [SugarColumn(ColumnDescription = "下一流程主键", IsNullable = true, Length = 255)]
+ public string? NextConfigId { get; set; }
+
+ /////
+ ///// 父项流程主键
+ /////
+ //[SugarColumn(ColumnDescription = "父项流程主键", IsNullable = true)]
+ //public long? ParentConfigId { get; set; }
///
/// 当执行过程中发生异常时是否继续执行下一个节点
diff --git a/ds-wms-service/DS.WMS.Core/TaskPlat/Other/TaskFlowRuner.cs b/ds-wms-service/DS.WMS.Core/TaskPlat/Other/TaskFlowRuner.cs
index ed7b07ee..ec30d31d 100644
--- a/ds-wms-service/DS.WMS.Core/TaskPlat/Other/TaskFlowRuner.cs
+++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Other/TaskFlowRuner.cs
@@ -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 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 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()
- .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();
- 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()
+ .Where(x => configIdList.Contains(x.ConfigId))
+ .ToListAsync();
+
+ var matchedConfigList = new List();
+ foreach (var item in waitMatchConfigList)
{
- var contitionContent = JsonConvert.DeserializeObject(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(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().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().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;
}
diff --git a/ds-wms-service/DS.WMS.TaskApi/Controllers/TaskAllocationController.cs b/ds-wms-service/DS.WMS.TaskApi/Controllers/TaskAllocationController.cs
index bde1b58e..c721c7c9 100644
--- a/ds-wms-service/DS.WMS.TaskApi/Controllers/TaskAllocationController.cs
+++ b/ds-wms-service/DS.WMS.TaskApi/Controllers/TaskAllocationController.cs
@@ -3,6 +3,7 @@ using DS.Module.Core.Data;
using DS.Module.SqlSugar;
using DS.Module.UserModule;
using DS.WMS.Core.Op.Entity;
+using DS.WMS.Core.TaskPlat;
using DS.WMS.Core.TaskPlat.Dtos;
using DS.WMS.Core.TaskPlat.Entity;
using DS.WMS.Core.TaskPlat.Interface;
@@ -70,10 +71,19 @@ public class TaskAllocationController : ApiController
(TaskFlowDataNameConst.Business, order)
);
- var result = taskAllocationService.GetAllotUserBySeaExportId(new List() {
- TaskBaseTypeEnum.INVOICE_BILL_MAIL,
- TaskBaseTypeEnum.NOT_LOADED,
- TaskBaseTypeEnum.NOT_SHIPMENG,
- }, 1816649497120477184, dataContext);
+ // 分配测试
+ //var result = taskAllocationService.GetAllotUserBySeaExportId(new List() {
+ // TaskBaseTypeEnum.INVOICE_BILL_MAIL,
+ // TaskBaseTypeEnum.NOT_LOADED,
+ // TaskBaseTypeEnum.NOT_SHIPMENG,
+ //}, 1816649497120477184, dataContext);
+
+ // 工作流节点测试
+ TaskFlowRuner runer = new TaskFlowRuner(tenantDb, serviceProvider);
+ //var result1 = await runer.GetWorkFlowNextConfig(dataContext, null); // 首位
+ //var result2 = await runer.GetWorkFlowNextConfig(dataContext, 20001); // 正常
+ //var result3 = await runer.GetWorkFlowNextConfig(dataContext, 20002); // 分支判断
+ //var result4 = await runer.GetWorkFlowNextConfig(dataContext, 20003); // 分支结尾判断
+ //var result5 = await runer.GetWorkFlowNextConfig(dataContext, 20007); // 末位
}
}
\ No newline at end of file