xf 2 years ago
parent
commit
28257403ff

+ 2 - 2
src/Hotline/FlowEngine/Workflows/EStepCountersignStatus.cs

@@ -11,12 +11,12 @@ public enum EStepCountersignStatus
     None = 0,
     None = 0,
 
 
     /// <summary>
     /// <summary>
-    /// 会签中
+    /// 会签中(上级节点直接开启会签)
     /// </summary>
     /// </summary>
     InCountersign = 1,
     InCountersign = 1,
 
 
     /// <summary>
     /// <summary>
-    /// 本身不处于会签流程中,但外层有会签流程嵌套
+    /// 本身不直接处于会签流程中,但外层有会签流程嵌套(非上级节点开启会签,当前节点会签并未结束)
     /// </summary>
     /// </summary>
     OuterCountersign = 2,
     OuterCountersign = 2,
 }
 }

+ 33 - 4
src/Hotline/FlowEngine/Workflows/WorkflowDomainService.cs

@@ -715,12 +715,41 @@ namespace Hotline.FlowEngine.Workflows
             trace.ExpiredTime = workflow.ExpiredTime;
             trace.ExpiredTime = workflow.ExpiredTime;
             trace.TimeLimit = workflow.TimeLimit;
             trace.TimeLimit = workflow.TimeLimit;
 
 
-            //处于会签中的节点,其对应的trace.parentId赋值上级trace.Id
-            if (currentStep.StepCountersignStatus is EStepCountersignStatus.InCountersign)
+            //todo 1.如果是汇总节点,trace.parentId=会签开始节点对应的trace.parentId(即与会签开始节点trace同级)
+            //todo 2.普通节点:2.1: in 判断上级节点是否发起会签,有则赋值parentId为上级trace.Id, 2.2: outer 与上级节点trace保持同级,取值上级节点对应trace.parentId
+
+            if (currentStep.StepType is EStepType.CountersignEnd)
             {
             {
-                var parentTrace = await GetWorkflowTraceAsync(workflow.Id, currentStep.PreviousId, cancellationToken);
-                trace.ParentId = parentTrace.Id;
+                if (currentStep.IsInCountersign)
+                {
+                    var countersign =
+                        await _workflowCountersignRepository.GetAsync(currentStep.CountersignId!, cancellationToken);
+                    if (countersign == null)
+                        throw new UserFriendlyException(
+                            $"汇总节点处于会签中,未查询到对应会签,countersignId: {currentStep.CountersignId}");
+                    var startTrace = await GetWorkflowTraceAsync(workflow.Id, countersign.StartStepId, cancellationToken);
+                    trace.ParentId = startTrace.ParentId;
+                }
+            }
+            else if (currentStep.StepType is EStepType.Normal)
+            {
+                if (currentStep.StepCountersignStatus is EStepCountersignStatus.InCountersign)
+                {
+                    var prevTrace = await GetWorkflowTraceAsync(workflow.Id, currentStep.PreviousId, cancellationToken);
+                    trace.ParentId = prevTrace.Id;
+                }
+                else if (currentStep.StepCountersignStatus is EStepCountersignStatus.OuterCountersign)
+                {
+                    var prevTrace = await GetWorkflowTraceAsync(workflow.Id, currentStep.PreviousId, cancellationToken);
+                    trace.ParentId = prevTrace.ParentId;
+                }
             }
             }
+            ////处于会签中的节点,其对应的trace.parentId赋值上级trace.Id
+            //if (currentStep.StepCountersignStatus is EStepCountersignStatus.InCountersign)
+            //{
+            //    var parentTrace = await GetWorkflowTraceAsync(workflow.Id, currentStep.PreviousId, cancellationToken);
+            //    trace.ParentId = parentTrace.Id;
+            //}
 
 
             await _workflowTraceRepository.AddAsync(trace, cancellationToken);
             await _workflowTraceRepository.AddAsync(trace, cancellationToken);
         }
         }