xf 1 year ago
parent
commit
3a2be7cc66
1 changed files with 23 additions and 7 deletions
  1. 23 7
      src/Hotline/FlowEngine/Workflows/WorkflowDomainService.cs

+ 23 - 7
src/Hotline/FlowEngine/Workflows/WorkflowDomainService.cs

@@ -253,18 +253,33 @@ namespace Hotline.FlowEngine.Workflows
             var currentStep = GetUnHandleStep(workflow.Steps, _sessionContext.RequiredOrgId, _sessionContext.RequiredUserId);
             if (currentStep.Status is not EWorkflowStepStatus.WaitForAccept) return;
 
-            if (currentStep.HandlerType is EHandlerType.AssignedUser or EHandlerType.Role
-            && !currentStep.IsInCountersign()
-            && currentStep.InstanceMode is EInstanceMode.Config)
+            if(currentStep.HandlerType is EHandlerType.AssignedOrg or EHandlerType.OrgLevel or EHandlerType.OrgType
+               || (currentStep.InstanceMode is EInstanceMode.Dynamic && !currentStep.DynamicShouldTerminal())//动态并且非结束节点
+                   || (currentStep.IsInCountersign() && !currentStep.IsCountersignEndStep)//会签并且非会签节点
+                   )
             {
-                //userId
-                if (currentStep.Handlers.All(d => d.Key != userId)) return;
+                //orgId
+                if (currentStep.Handlers.All(d => d.Key != orgId)) return;
             }
             else
             {
-                //orgId
-                if (currentStep.Handlers.All(d => d.Key != orgId)) return;
+                //userId
+                if (currentStep.Handlers.All(d => d.Key != userId)) return;
             }
+
+            //if (currentStep.HandlerType is EHandlerType.AssignedUser or EHandlerType.Role
+            //&& !currentStep.IsInCountersign()
+            //&& currentStep.InstanceMode is EInstanceMode.Config
+            //)
+            //{
+            //    //userId
+            //    if (currentStep.Handlers.All(d => d.Key != userId)) return;
+            //}
+            //else
+            //{
+            //    //orgId
+            //    if (currentStep.Handlers.All(d => d.Key != orgId)) return;
+            //}
             if (currentStep.StepType is EStepType.End)
                 throw new UserFriendlyException("当前流程已流转到最终步骤");
 
@@ -505,6 +520,7 @@ namespace Hotline.FlowEngine.Workflows
         {
             var csEndStep = _mapper.Map<WorkflowStep>(countersignStartStep);
             _mapper.Map(dto, csEndStep);
+            csEndStep.Status = EWorkflowStepStatus.WaitForAccept;
             csEndStep.NextSteps = new();
             csEndStep.PrevStepId = null;
             csEndStep.PrevStepCode = null;