|
@@ -253,7 +253,7 @@ 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.AssignedOrg or EHandlerType.OrgLevel or EHandlerType.OrgType
|
|
|
+ if (currentStep.HandlerType is EHandlerType.AssignedOrg or EHandlerType.OrgLevel or EHandlerType.OrgType
|
|
|
|| (currentStep.InstanceMode is EInstanceMode.Dynamic && !currentStep.DynamicShouldTerminal())//动态并且非结束节点
|
|
|
|| (currentStep.IsInCountersign() && !currentStep.IsCountersignEndStep)//会签并且非会签节点
|
|
|
)
|
|
@@ -368,7 +368,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
var countersignStartStep = workflow.Steps.FirstOrDefault(d => d.Id == currentStep.PrevStepId);
|
|
|
if (countersignStartStep is null)
|
|
|
throw new UserFriendlyException("未查询到会签开始节点");
|
|
|
- if (!countersignStartStep.HasStartedCountersign())
|
|
|
+ if (!countersignStartStep.IsStartCountersign)
|
|
|
throw new UserFriendlyException("查询到会签开始节点状态异常");
|
|
|
|
|
|
countersignStartStep.CountersignSteps.First(d => d.StepId == currentStep.Id).Completed = true;
|
|
@@ -415,7 +415,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
var nextSteps = await CreateNextStepsAsync(workflow, nextStepDefine, currentStep, dto, expiredTime, cancellationToken);
|
|
|
|
|
|
//赋值当前节点的下级办理节点
|
|
|
- if (dto.IsStartCountersign)
|
|
|
+ if (currentStep.IsInCountersign())
|
|
|
{
|
|
|
currentStep.CreateCountersignSteps(nextSteps);
|
|
|
await _workflowStepRepository.UpdateAsync(currentStep, cancellationToken);
|
|
@@ -462,34 +462,107 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
List<WorkflowStep> nextSteps = new();
|
|
|
if (currentStep.IsInCountersign())
|
|
|
{
|
|
|
- if (dto.BackToCountersignEnd)
|
|
|
- {
|
|
|
- var countersignStartStep = workflow.Steps.FirstOrDefault(d => d.Id == currentStep.PrevStepId);
|
|
|
- if (countersignStartStep is null)
|
|
|
- throw new UserFriendlyException("未查询到会签开始节点");
|
|
|
- if (!countersignStartStep.HasStartedCountersign())
|
|
|
- throw new UserFriendlyException("查询到会签开始节点状态异常");
|
|
|
- //会签未全部办理则不创建汇总节点
|
|
|
- if (countersignStartStep.StartedCountersignHasAllHandled()
|
|
|
- && !workflow.Steps.Any(d => d.IsCountersignEndStep && d.CountersignStartStepId == countersignStartStep.Id))
|
|
|
- {
|
|
|
- //todo 创建会签汇总节点
|
|
|
- var countersignEndStep = await CreateCountersignEndStepAsync(countersignStartStep, dto, cancellationToken);
|
|
|
- nextSteps = new List<WorkflowStep> { countersignEndStep };
|
|
|
+ //if (dto.BackToCountersignEnd)
|
|
|
+ //{
|
|
|
+ // var countersignStartStep = workflow.Steps.FirstOrDefault(d => d.Id == currentStep.PrevStepId);
|
|
|
+ // if (countersignStartStep is null)
|
|
|
+ // throw new UserFriendlyException("未查询到会签开始节点");
|
|
|
+ // if (!countersignStartStep.HasStartedCountersign())
|
|
|
+ // throw new UserFriendlyException("查询到会签开始节点状态异常");
|
|
|
+ // //会签未全部办理则不创建汇总节点
|
|
|
+ // if (countersignStartStep.StartedCountersignHasAllHandled()
|
|
|
+ // && !workflow.Steps.Any(d => d.IsCountersignEndStep && d.CountersignStartStepId == countersignStartStep.Id))
|
|
|
+ // {
|
|
|
+ // //todo 创建会签汇总节点
|
|
|
+ // var countersignEndStep = await CreateCountersignEndStepAsync(countersignStartStep, dto, cancellationToken);
|
|
|
+ // nextSteps = new List<WorkflowStep> { countersignEndStep };
|
|
|
|
|
|
- //create trace
|
|
|
- await CreateTraceAsync(workflow, countersignEndStep, EWorkflowTraceStatus.Normal, cancellationToken);
|
|
|
+ // //create trace
|
|
|
+ // await CreateTraceAsync(workflow, countersignEndStep, EWorkflowTraceStatus.Normal, cancellationToken);
|
|
|
|
|
|
- await _mediator.Publish(new CountersignEndAssigned(workflow), cancellationToken);
|
|
|
+ // await _mediator.Publish(new CountersignEndAssigned(workflow), cancellationToken);
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ // //todo 依据会签策略创建会签下一级节点
|
|
|
+ // //考虑没有下级部门情况
|
|
|
+ // nextSteps = await CreateStepsAsync(workflow, nextStepDefine, currentStep, dto, dto.NextHandlers,
|
|
|
+ // EWorkflowStepStatus.WaitForAccept, currentStep.GetNextStepCountersignPosition(),
|
|
|
+ // expiredTime, false, cancellationToken);
|
|
|
+ //}
|
|
|
+
|
|
|
+ if (currentStep.IsCountersignEndStep)
|
|
|
+ {
|
|
|
+ //todo check if current is topend f: csStartStep.prev
|
|
|
+ //todo t: check if dto.StartCs t: csconfig f: config
|
|
|
+ if (currentStep.CountersignStartStepId == workflow.TopCountersignStepId)
|
|
|
+ {
|
|
|
+ if (dto.IsStartCountersign)
|
|
|
+ {
|
|
|
+ //todo 依据会签策略创建会签下一级节点
|
|
|
+ nextSteps = await CreateStepsAsync(workflow, nextStepDefine, currentStep, dto, dto.NextHandlers,
|
|
|
+ EWorkflowStepStatus.WaitForAccept, currentStep.GetNextStepCountersignPosition(),
|
|
|
+ expiredTime, false, cancellationToken);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //todo 创建普通节点(根据配置)
|
|
|
+ nextSteps = await CreateStepsByDefineAsync(workflow, nextStepDefine, currentStep, dto, expiredTime, cancellationToken);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //todo csStartStep.prev
|
|
|
+ var csStartStep =
|
|
|
+ workflow.Steps.FirstOrDefault(d => d.Id == currentStep.CountersignStartStepId);
|
|
|
+ if (csStartStep is null)
|
|
|
+ throw new UserFriendlyException("未查询到会签节点");
|
|
|
+ var prevStep = workflow.Steps.FirstOrDefault(d => d.Id == csStartStep.PrevStepId);
|
|
|
+ if (prevStep is null)
|
|
|
+ throw new UserFriendlyException("未查询到当前节点上级节点");
|
|
|
+ //会签未全部办理则不创建汇总节点
|
|
|
+ if (prevStep.StartedCountersignHasAllHandled())
|
|
|
+ {
|
|
|
+ //todo 创建会签汇总节点
|
|
|
+ var countersignEndStep = await CreateCountersignEndStepAsync(prevStep, dto, cancellationToken);
|
|
|
+ nextSteps = new List<WorkflowStep> { countersignEndStep };
|
|
|
+
|
|
|
+ //create trace
|
|
|
+ await CreateTraceAsync(workflow, countersignEndStep, EWorkflowTraceStatus.Normal, cancellationToken);
|
|
|
+
|
|
|
+ await _mediator.Publish(new CountersignEndAssigned(workflow), cancellationToken);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- //todo 依据会签策略创建会签下一级节点
|
|
|
- //考虑没有下级部门情况
|
|
|
- nextSteps = await CreateStepsAsync(workflow, nextStepDefine, currentStep, dto, dto.NextHandlers,
|
|
|
- EWorkflowStepStatus.WaitForAccept, currentStep.GetNextStepCountersignPosition(),
|
|
|
- expiredTime, false, cancellationToken);
|
|
|
+ if (dto.BackToCountersignEnd)
|
|
|
+ {
|
|
|
+ //todo check if cs all complete, create next
|
|
|
+ var prevStep = workflow.Steps.FirstOrDefault(d => d.Id == currentStep.PrevStepId);
|
|
|
+ if (prevStep is null)
|
|
|
+ throw new UserFriendlyException("未查询到当前节点上级节点");
|
|
|
+ //会签未全部办理则不创建汇总节点
|
|
|
+ if (prevStep.StartedCountersignHasAllHandled())
|
|
|
+ {
|
|
|
+ //todo 创建会签汇总节点
|
|
|
+ var countersignEndStep = await CreateCountersignEndStepAsync(prevStep, dto, cancellationToken);
|
|
|
+ nextSteps = new List<WorkflowStep> { countersignEndStep };
|
|
|
+
|
|
|
+ //create trace
|
|
|
+ await CreateTraceAsync(workflow, countersignEndStep, EWorkflowTraceStatus.Normal, cancellationToken);
|
|
|
+
|
|
|
+ await _mediator.Publish(new CountersignEndAssigned(workflow), cancellationToken);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //todo 依据会签策略创建会签下一级节点
|
|
|
+ nextSteps = await CreateStepsAsync(workflow, nextStepDefine, currentStep, dto, dto.NextHandlers,
|
|
|
+ EWorkflowStepStatus.WaitForAccept, currentStep.GetNextStepCountersignPosition(),
|
|
|
+ expiredTime, false, cancellationToken);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
else if (dto.IsStartCountersign)
|
|
@@ -519,7 +592,6 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
BasicWorkflowDto dto, CancellationToken cancellationToken)
|
|
|
{
|
|
|
var csEndStep = _mapper.Map<WorkflowStep>(countersignStartStep);
|
|
|
- _mapper.Map(dto, csEndStep);
|
|
|
csEndStep.Status = EWorkflowStepStatus.WaitForAccept;
|
|
|
csEndStep.NextSteps = new();
|
|
|
csEndStep.PrevStepId = null;
|
|
@@ -535,6 +607,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
csEndStep.TimeLimit = GetTimeLimit(""); //todo 过期时间
|
|
|
|
|
|
csEndStep.Reset();
|
|
|
+ csEndStep.ResetParameters();
|
|
|
|
|
|
await _workflowStepRepository.AddAsync(csEndStep, cancellationToken);
|
|
|
return csEndStep;
|
|
@@ -1432,7 +1505,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
CancellationToken cancellationToken
|
|
|
)
|
|
|
{
|
|
|
- var countersignId = prevStep.HasStartedCountersign() ? prevStep.StartCountersignId : prevStep.CountersignId;
|
|
|
+ var countersignId = prevStep.IsStartCountersign ? prevStep.StartCountersignId : prevStep.CountersignId;
|
|
|
|
|
|
List<WorkflowStep> steps = new();
|
|
|
if (dto.IsStartCountersign)
|