|
@@ -1439,6 +1439,79 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
await _workflowStepRepository.UpdateAsync(prevStep, cancellationToken);
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 跳转至结束节点(无视流程模板配置以及当前办理对象,直接跳至结束节点)
|
|
|
+ /// </summary>
|
|
|
+ public async Task JumpToEndAsync(ISessionContext current, string workflowId, string opinion, List<FileDto> files, DateTime? expiredTime,
|
|
|
+ EReviewResult reviewResult = EReviewResult.Unknown, CancellationToken cancellationToken = default)
|
|
|
+ {
|
|
|
+ var workflow = await GetWorkflowAsync(workflowId, withDefine: true, withSteps: true, withTraces: true,
|
|
|
+ withCountersigns: true, cancellationToken: cancellationToken);
|
|
|
+ var endStepDefine = workflow.WorkflowDefinition.FindEndStepDefine();
|
|
|
+ if (endStepDefine is null)
|
|
|
+ throw new UserFriendlyException("未正确配置结束节点");
|
|
|
+
|
|
|
+ var dto = new BasicWorkflowDto
|
|
|
+ {
|
|
|
+ NextStepCode = endStepDefine.Code,
|
|
|
+ NextStepName = endStepDefine.Name,
|
|
|
+ FlowDirection = EFlowDirection.OrgToFile,
|
|
|
+ BusinessType = endStepDefine.BusinessType,
|
|
|
+ ReviewResult = reviewResult,
|
|
|
+ Opinion = opinion,
|
|
|
+ Files = files
|
|
|
+ };
|
|
|
+
|
|
|
+ var unhandleSteps = workflow.Steps
|
|
|
+ .Where(d => d.Status != EWorkflowStepStatus.Handled).ToList();
|
|
|
+ var unhandleTraces = workflow.Traces
|
|
|
+ .Where(d => d.Status != EWorkflowStepStatus.Handled).ToList();
|
|
|
+
|
|
|
+ //get currentStep
|
|
|
+ var currentStep = unhandleSteps.MaxBy(d => d.CreationTime)
|
|
|
+ ?? workflow.Steps.MaxBy(d => d.CreationTime);
|
|
|
+
|
|
|
+ foreach (var step in unhandleSteps)
|
|
|
+ {
|
|
|
+ await HandleStepAsync(step, workflow, dto, null, null, cancellationToken);
|
|
|
+ if (step.IsStartCountersign)
|
|
|
+ step.CountersignEnd();
|
|
|
+
|
|
|
+ var trace = unhandleTraces.First(d => d.StepId == step.Id);
|
|
|
+ _mapper.Map(dto, trace);
|
|
|
+ _mapper.Map(step, trace);
|
|
|
+ }
|
|
|
+
|
|
|
+ await _workflowStepRepository.UpdateRangeAsync(unhandleSteps, cancellationToken);
|
|
|
+ await _workflowTraceRepository.UpdateRangeAsync(unhandleTraces, cancellationToken);
|
|
|
+
|
|
|
+ //结束会签
|
|
|
+ var counstersigns = workflow.Countersigns
|
|
|
+ .Where(d => !d.EndTime.HasValue)
|
|
|
+ .ToList();
|
|
|
+ foreach (var counstersign in counstersigns)
|
|
|
+ {
|
|
|
+ //结束会签
|
|
|
+ counstersign.End(currentStep.Id, currentStep.Code, currentStep.BusinessType,
|
|
|
+ current.UserId, current.UserName,
|
|
|
+ current.OrgId, current.OrgName,
|
|
|
+ current.OrgAreaCode, current.OrgAreaName);
|
|
|
+ }
|
|
|
+
|
|
|
+ await _workflowCountersignRepository.UpdateRangeAsync(counstersigns, cancellationToken);
|
|
|
+
|
|
|
+
|
|
|
+ // //更新实际办理节点信息
|
|
|
+ // workflow.UpdateActualStepWhenHandle(currentStep, current.OrgAreaCode, current.OrgAreaName, current.OrgLevel);
|
|
|
+ //
|
|
|
+ // workflow.UpdateCurrentStepWhenHandle(currentStep, current.OrgAreaCode, current.OrgAreaName, current.OrgLevel);
|
|
|
+
|
|
|
+ if (workflow.Steps.All(d => d.StepType != EStepType.End))
|
|
|
+ {
|
|
|
+ await EndAsync(current, workflow, dto, endStepDefine, currentStep, expiredTime, cancellationToken);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 查找当前会签内所有节点(含start,end)
|
|
|
/// </summary>
|
|
@@ -1782,61 +1855,6 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
return (new Kv(workflow.ActualHandleOrgCode, workflow.ActualHandleOrgName), items);
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// 依据配置过滤下一节点
|
|
|
- /// </summary>
|
|
|
- public List<StepDefine> NextStepDefineFilter(EPathPolicy pathPolicy, List<StepDefine> nextStepDefines)
|
|
|
- {
|
|
|
- switch (pathPolicy)
|
|
|
- {
|
|
|
- case EPathPolicy.DirectUpper:
|
|
|
- break;
|
|
|
- case EPathPolicy.DirectUpperCenterIsTop:
|
|
|
- var currentOrgLevel = _sessionContextProvider.SessionContext.RequiredOrgId.CalcOrgLevel();
|
|
|
- if (currentOrgLevel == 1)
|
|
|
- {
|
|
|
- nextStepDefines = nextStepDefines.Where(d => d.IsCenter()).ToList();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- var upperLevel = (--currentOrgLevel).ToString();
|
|
|
- nextStepDefines = nextStepDefines
|
|
|
- .Where(d => d.HandlerType is EHandlerType.OrgLevel &&
|
|
|
- d.HandlerTypeItems.Any(x => x.Key == upperLevel))
|
|
|
- .ToList();
|
|
|
- }
|
|
|
-
|
|
|
- break;
|
|
|
- default:
|
|
|
- throw new ArgumentOutOfRangeException();
|
|
|
- }
|
|
|
-
|
|
|
- return nextStepDefines;
|
|
|
- }
|
|
|
-
|
|
|
- // /// <summary>
|
|
|
- // /// 撤销流程
|
|
|
- // /// </summary>
|
|
|
- // public async Task CancelAsync(CancelDto dto, DateTime? expiredTime, ISessionContext current,
|
|
|
- // CancellationToken cancellationToken)
|
|
|
- // {
|
|
|
- // var workflow = await GetWorkflowAsync(dto.WorkflowId, withDefine: true, withSteps: true,
|
|
|
- // cancellationToken: cancellationToken);
|
|
|
- //
|
|
|
- // var currentStep = GetUnHandleStep(workflow.Steps, _sessionContextProvider.SessionContext.RequiredOrgId,
|
|
|
- // _sessionContextProvider.SessionContext.RequiredUserId, _sessionContextProvider.SessionContext.Roles);
|
|
|
- // //var (currentStepBox, currentStep) = GetUnCompleteStep(workflow.Steps, _sessionContextProvider.SessionContext.RequiredOrgId, _sessionContextProvider.SessionContext.RequiredUserId);
|
|
|
- //
|
|
|
- // var endStepDefine = workflow.WorkflowDefinition.FindEndStepDefine();
|
|
|
- //
|
|
|
- // var basicDto = _mapper.Map<BasicWorkflowDto>(dto);
|
|
|
- // var endTrace = await EndAsync(workflow, basicDto, endStepDefine, currentStep,
|
|
|
- // expiredTime, cancellationToken: cancellationToken);
|
|
|
- //
|
|
|
- // await _publisher.PublishAsync(new CancelWorkflowNotify(workflow), PublishStrategy.ParallelWhenAll,
|
|
|
- // cancellationToken);
|
|
|
- // }
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 新增流程流转记录
|
|
|
/// </summary>
|