|
@@ -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("当前流程已流转到最终步骤");
|
|
|
|
|
@@ -413,7 +428,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
//todo 计算办理工作时长
|
|
|
|
|
|
//更新当前办理节点信息
|
|
|
- workflow.UpdateWorkflowCurrentStepInfo(dto.IsStartCountersign, currentStep, nextSteps?.First());
|
|
|
+ workflow.UpdateWorkflowCurrentStepInfo(dto.IsStartCountersign, currentStep, nextSteps?.FirstOrDefault());
|
|
|
|
|
|
//发起会签时记录顶层会签节点
|
|
|
if (dto.IsStartCountersign && !workflow.IsInCountersign())
|
|
@@ -459,18 +474,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
&& !workflow.Steps.Any(d => d.IsCountersignEndStep && d.CountersignStartStepId == countersignStartStep.Id))
|
|
|
{
|
|
|
//todo 创建会签汇总节点
|
|
|
- var countersignEndStep = _mapper.Map<WorkflowStep>(countersignStartStep);
|
|
|
- countersignEndStep.IsCountersignEndStep = true;
|
|
|
- countersignEndStep.CountersignStartStepId = countersignStartStep.Id;
|
|
|
- countersignEndStep.CountersignPosition = ECountersignPosition.Outer;
|
|
|
- countersignEndStep.CountersignId = countersignStartStep.StartCountersignId;
|
|
|
- countersignEndStep.Handlers = new List<Kv>
|
|
|
- { new(countersignStartStep.HandlerId, countersignStartStep.HandlerName) };
|
|
|
- countersignEndStep.TimeLimit = GetTimeLimit(""); //todo 过期时间
|
|
|
- //countersignEndStep.Name = $"{countersignStartStep.Name}汇总";
|
|
|
- countersignEndStep.Name = dto.NextStepName;
|
|
|
-
|
|
|
- await _workflowStepRepository.AddAsync(countersignEndStep, cancellationToken);
|
|
|
+ var countersignEndStep = await CreateCountersignEndStepAsync(countersignStartStep, dto, cancellationToken);
|
|
|
nextSteps = new List<WorkflowStep> { countersignEndStep };
|
|
|
|
|
|
//create trace
|
|
@@ -485,7 +489,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
//考虑没有下级部门情况
|
|
|
nextSteps = await CreateStepsAsync(workflow, nextStepDefine, currentStep, dto, dto.NextHandlers,
|
|
|
EWorkflowStepStatus.WaitForAccept, currentStep.GetNextStepCountersignPosition(),
|
|
|
- expiredTime, cancellationToken);
|
|
|
+ expiredTime, false, cancellationToken);
|
|
|
}
|
|
|
}
|
|
|
else if (dto.IsStartCountersign)
|
|
@@ -493,14 +497,14 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
//todo 依据会签策略创建会签下一级节点
|
|
|
nextSteps = await CreateStepsAsync(workflow, nextStepDefine, currentStep, dto, dto.NextHandlers,
|
|
|
EWorkflowStepStatus.WaitForAccept, currentStep.GetNextStepCountersignPosition(),
|
|
|
- expiredTime, cancellationToken);
|
|
|
+ expiredTime, false, cancellationToken);
|
|
|
}
|
|
|
else if (currentStep.InstanceMode is EInstanceMode.Dynamic && !currentStep.DynamicShouldTerminal())
|
|
|
{
|
|
|
//todo 创建动态下一级节点
|
|
|
nextSteps = await CreateStepsAsync(workflow, nextStepDefine, currentStep, dto, dto.NextHandlers,
|
|
|
EWorkflowStepStatus.WaitForAccept, ECountersignPosition.None,
|
|
|
- expiredTime, cancellationToken);
|
|
|
+ expiredTime, false, cancellationToken);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -511,6 +515,31 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
return nextSteps;
|
|
|
}
|
|
|
|
|
|
+ private async Task<WorkflowStep> CreateCountersignEndStepAsync(WorkflowStep countersignStartStep,
|
|
|
+ BasicWorkflowDto dto, CancellationToken cancellationToken)
|
|
|
+ {
|
|
|
+ var csEndStep = _mapper.Map<WorkflowStep>(countersignStartStep);
|
|
|
+ _mapper.Map(dto, csEndStep);
|
|
|
+ csEndStep.Status = EWorkflowStepStatus.WaitForAccept;
|
|
|
+ csEndStep.NextSteps = new();
|
|
|
+ csEndStep.PrevStepId = null;
|
|
|
+ csEndStep.PrevStepCode = null;
|
|
|
+ csEndStep.IsOrigin = false;
|
|
|
+ csEndStep.CountersignId = countersignStartStep.StartCountersignId;
|
|
|
+ csEndStep.CountersignPosition = ECountersignPosition.Outer;
|
|
|
+ csEndStep.CountersignSteps = new();
|
|
|
+ csEndStep.IsCountersignEndStep = true;
|
|
|
+ csEndStep.CountersignStartStepId = countersignStartStep.Id;
|
|
|
+ csEndStep.Name = dto.NextStepName;
|
|
|
+ csEndStep.Handlers = new List<Kv> { new(countersignStartStep.HandlerId, countersignStartStep.HandlerName) };
|
|
|
+ csEndStep.TimeLimit = GetTimeLimit(""); //todo 过期时间
|
|
|
+
|
|
|
+ csEndStep.Reset();
|
|
|
+
|
|
|
+ await _workflowStepRepository.AddAsync(csEndStep, cancellationToken);
|
|
|
+ return csEndStep;
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 退回(返回前一节点)
|
|
|
/// </summary>
|
|
@@ -756,7 +785,6 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
return new(new Kv(workflow.ActualHandleOrgCode, workflow.ActualHandleOrgName), new List<Kv>());
|
|
|
var steps = workflow.Steps
|
|
|
.Where(d => d.StepType is EStepType.Normal && d.BusinessType is EBusinessType.Department)
|
|
|
- .SelectMany(d => d.Steps)
|
|
|
.ToList();
|
|
|
var items = steps.Select(d => new Kv(d.HandlerOrgId, d.HandlerOrgName)).ToList();
|
|
|
return (new Kv(workflow.ActualHandleOrgCode, workflow.ActualHandleOrgName), items);
|
|
@@ -1015,7 +1043,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
newStep.Status = EWorkflowStepStatus.WaitForAccept;
|
|
|
newStep.PrevStepId = step.PrevStepId;
|
|
|
newStep.IsMain = step.IsMain;
|
|
|
- newStep.ParentId = step.ParentId;
|
|
|
+ //newStep.ParentId = step.ParentId;
|
|
|
newStep.Handlers = step.Handlers;
|
|
|
newStep.StartCountersignId = step.StartCountersignId;
|
|
|
newStep.CountersignId = step.CountersignId;
|
|
@@ -1057,30 +1085,6 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
}
|
|
|
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// 更新下级汇总节点可办理状态
|
|
|
- /// </summary>
|
|
|
- /// <param name="nextStepBox"></param>
|
|
|
- /// <param name="currentStep"></param>
|
|
|
- /// <param name="cancellationToken"></param>
|
|
|
- /// <returns></returns>
|
|
|
- private async Task SetNextCountersignEndAssignedAsync(WorkflowStep nextStepBox, WorkflowStep currentStep, CancellationToken cancellationToken)
|
|
|
- {
|
|
|
- var nextSteps = currentStep.CountersignPosition is ECountersignPosition.Inner
|
|
|
- ? nextStepBox.Steps.Where(d => d.CountersignId == currentStep.CountersignId).ToList()
|
|
|
- : nextStepBox.Steps.Where(d => d.PrevStepId == currentStep.Id).ToList();
|
|
|
-
|
|
|
- if (!nextSteps.Any())
|
|
|
- throw new UserFriendlyException($"未查询到下一节点, currentStepId: {currentStep.Id}");
|
|
|
-
|
|
|
- foreach (var nextStep in nextSteps)
|
|
|
- {
|
|
|
- nextStep.SetAssigned();
|
|
|
- }
|
|
|
-
|
|
|
- await _workflowStepRepository.UpdateRangeAsync(nextSteps, cancellationToken);
|
|
|
- }
|
|
|
-
|
|
|
private async Task JumpTraceAsync(string workflowId, RecallDto dto, CancellationToken cancellationToken)
|
|
|
{
|
|
|
//未办理的traces
|
|
@@ -1325,7 +1329,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
|
|
|
var step = CreateStep(endStepDefine, prevStep, workflow.Id, new List<Kv> { handler },
|
|
|
null, null, null,
|
|
|
- EWorkflowStepStatus.WaitForAccept, ECountersignPosition.None, DateTime.Now, endStepDefine.Name);
|
|
|
+ EWorkflowStepStatus.WaitForAccept, ECountersignPosition.None, DateTime.Now, endStepDefine.Name, true);
|
|
|
|
|
|
//step.Accept(_sessionContext.RequiredUserId, _sessionContext.UserName,
|
|
|
// _sessionContext.RequiredOrgId, _sessionContext.OrgName,
|
|
@@ -1410,7 +1414,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
|
|
|
return await CreateStepsAsync(workflow, stepDefine, prevStep, dto, handlers,
|
|
|
EWorkflowStepStatus.WaitForAccept, ECountersignPosition.None,
|
|
|
- expiredTime, cancellationToken);
|
|
|
+ expiredTime, true, cancellationToken);
|
|
|
}
|
|
|
|
|
|
//new
|
|
@@ -1424,6 +1428,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
EWorkflowStepStatus stepStatus,
|
|
|
ECountersignPosition csPosition,
|
|
|
DateTime expiredTime,
|
|
|
+ bool isOrigin,
|
|
|
CancellationToken cancellationToken
|
|
|
)
|
|
|
{
|
|
@@ -1436,7 +1441,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
{
|
|
|
var step = CreateStep(stepDefine, prevStep, workflow.Id, new List<Kv> { handler },
|
|
|
dto.NextStepCode, dto.NextMainHandler, countersignId,
|
|
|
- stepStatus, csPosition, expiredTime, dto.NextStepName);
|
|
|
+ stepStatus, csPosition, expiredTime, dto.NextStepName, isOrigin);
|
|
|
|
|
|
steps.Add(step);
|
|
|
}
|
|
@@ -1445,7 +1450,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
{
|
|
|
var step = CreateStep(stepDefine, prevStep, workflow.Id, handlers,
|
|
|
dto.NextStepCode, dto.NextMainHandler, countersignId,
|
|
|
- stepStatus, csPosition, expiredTime, dto.NextStepName);
|
|
|
+ stepStatus, csPosition, expiredTime, dto.NextStepName, isOrigin);
|
|
|
|
|
|
steps.Add(step);
|
|
|
}
|
|
@@ -1700,7 +1705,8 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
EWorkflowStepStatus stepStatus,
|
|
|
ECountersignPosition countersignPosition,
|
|
|
DateTime expiredTime,
|
|
|
- string stepName
|
|
|
+ string stepName,
|
|
|
+ bool isOrigin
|
|
|
)
|
|
|
{
|
|
|
if (!handlers.Any())
|
|
@@ -1720,7 +1726,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
step.CountersignPosition = countersignPosition;
|
|
|
step.StepExpiredTime = expiredTime;
|
|
|
step.TimeLimit = GetTimeLimit("");//todo 过期时间
|
|
|
- step.IsOrigin = true;
|
|
|
+ step.IsOrigin = isOrigin;
|
|
|
step.Name = stepName;
|
|
|
|
|
|
return step;
|