|
@@ -523,7 +523,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public async Task PreviousAsync(Workflow workflow, PreviousWorkflowDto dto, User operater,
|
|
|
- CancellationToken cancellationToken)
|
|
|
+ ISessionContext current, CancellationToken cancellationToken)
|
|
|
{
|
|
|
ValidatePermission(workflow, operater.OrgId, operater.Id);
|
|
|
|
|
@@ -557,9 +557,9 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
|
|
|
//结束会签
|
|
|
currentCountersign.End(currentStep.Id, currentStep.Code, currentStep.BusinessType,
|
|
|
- _sessionContext.RequiredUserId, _sessionContext.UserName,
|
|
|
- _sessionContext.RequiredOrgId, _sessionContext.OrgName,
|
|
|
- _sessionContext.OrgAreaCode, _sessionContext.OrgAreaName);
|
|
|
+ current.RequiredUserId, current.UserName,
|
|
|
+ current.RequiredOrgId, current.OrgName,
|
|
|
+ current.OrgAreaCode, current.OrgAreaName);
|
|
|
await _workflowCountersignRepository.UpdateAsync(currentCountersign, cancellationToken);
|
|
|
|
|
|
//update workflow cs status
|
|
@@ -568,7 +568,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
}
|
|
|
|
|
|
//update trace
|
|
|
- var trace = await PreviousTraceAsync(workflow.Id, dto, currentStep, cancellationToken);
|
|
|
+ var trace = await PreviousTraceAsync(workflow.Id, dto, currentStep, current, cancellationToken);
|
|
|
|
|
|
//复制上一个节点为待接办
|
|
|
var newPrevStep = await DuplicateStepWithTraceAsync(workflow, prevStep, EWorkflowTraceType.Previous,
|
|
@@ -799,14 +799,14 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
/// </summary>
|
|
|
public async Task RecallAsync(Workflow workflow, RecallDto dto, StepDefine targetStepDefine,
|
|
|
FlowAssignInfo flowAssignInfo, List<WorkflowStepHandler> stepHandlers, DateTime? expiredTime,
|
|
|
- CancellationToken cancellationToken)
|
|
|
+ ISessionContext current, CancellationToken cancellationToken)
|
|
|
{
|
|
|
var targetStep = workflow.Steps.FirstOrDefault(d => d.Code == dto.NextStepCode && d.IsOrigin);
|
|
|
if (targetStep is null)
|
|
|
throw UserFriendlyException.SameMessage("该流程尚未流转至该节点");
|
|
|
|
|
|
//update uncompleted traces
|
|
|
- await RecallTraceAsync(workflow.Id, dto.Opinion, cancellationToken);
|
|
|
+ await RecallTraceAsync(workflow.Id, dto.Opinion, current, cancellationToken);
|
|
|
|
|
|
var isOrgToCenter = await RecallAsync(workflow, dto, flowAssignInfo, targetStepDefine, targetStep,
|
|
|
EWorkflowTraceType.Recall, stepHandlers, expiredTime, cancellationToken);
|
|
@@ -821,13 +821,13 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
/// <summary>
|
|
|
/// 撤回至开始节点
|
|
|
/// </summary>
|
|
|
- public async Task RecallToStartStepAsync(string workflowId, string opinion, CancellationToken cancellationToken)
|
|
|
+ public async Task RecallToStartStepAsync(string workflowId, string opinion, ISessionContext current, CancellationToken cancellationToken)
|
|
|
{
|
|
|
//todo 1.当前待办节点删掉 2.当前待办trace更新(status, opinion) 3.复制startStep为待办 4.更新workflow(status, csStatus, handlers) 5.publish event
|
|
|
var workflow = await GetWorkflowAsync(workflowId, withDefine: true, withSteps: true,
|
|
|
cancellationToken: cancellationToken);
|
|
|
//update uncompleted traces
|
|
|
- await RecallTraceAsync(workflow.Id, opinion, cancellationToken);
|
|
|
+ await RecallTraceAsync(workflow.Id, opinion, current, cancellationToken);
|
|
|
|
|
|
var startStep = workflow.Steps.First(d => d.StepType == EStepType.Start);
|
|
|
workflow.Steps.RemoveAll(d => true);
|
|
@@ -1106,7 +1106,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
/// <summary>
|
|
|
/// 撤销流程
|
|
|
/// </summary>
|
|
|
- public async Task CancelAsync(CancelDto dto, CancellationToken cancellationToken)
|
|
|
+ public async Task CancelAsync(CancelDto dto, ISessionContext current, CancellationToken cancellationToken)
|
|
|
{
|
|
|
var workflow = await GetWorkflowAsync(dto.WorkflowId, withDefine: true, withSteps: true,
|
|
|
cancellationToken: cancellationToken);
|
|
@@ -1118,7 +1118,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
var endStepDefine = workflow.WorkflowDefinition.FindEndStepDefine();
|
|
|
|
|
|
var basicDto = _mapper.Map<BasicWorkflowDto>(dto);
|
|
|
- var endTrace = await EndAsync(workflow, basicDto, endStepDefine, currentStep, EReviewResult.Unknown,
|
|
|
+ var endTrace = await EndAsync(workflow, basicDto, endStepDefine, currentStep, current,
|
|
|
cancellationToken: cancellationToken);
|
|
|
|
|
|
await _mediator.Publish(new CancelWorkflowNotify(workflow), cancellationToken);
|
|
@@ -1173,12 +1173,12 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
return new Kv(workflow.ActualHandleOrgCode, workflow.ActualHandleOrgName);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 流程结束
|
|
|
/// </summary>
|
|
|
public async Task<WorkflowTrace> EndAsync(Workflow workflow, BasicWorkflowDto dto,
|
|
|
- StepDefine endStepDefine, WorkflowStep currentStep, ISessionContext current, CancellationToken cancellationToken = default)
|
|
|
+ StepDefine endStepDefine, WorkflowStep currentStep, ISessionContext current,
|
|
|
+ CancellationToken cancellationToken)
|
|
|
{
|
|
|
var endStepHandles = new List<WorkflowStepHandler>
|
|
|
{
|
|
@@ -1557,15 +1557,10 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
/// </summary>
|
|
|
private void HandleStep(ISessionContext current, WorkflowStep step, string opinion, string nextStepCode)
|
|
|
{
|
|
|
- string userId = isProvince ? "08daa5f2-1878-4cfa-8764-1244f0229994" : _sessionContext.RequiredOrgId;
|
|
|
- string userName = isProvince ? "省平台" : _sessionContext.UserName;
|
|
|
- string orgId = isProvince ? "001" : _sessionContext.RequiredOrgId;
|
|
|
- string OrgName = isProvince ? "市民热线服务系统" : _sessionContext.OrgName;
|
|
|
-
|
|
|
step.Handle(current.RequiredUserId, current.UserName,
|
|
|
- current.RequiredOrgId, current.OrgName,
|
|
|
- current.OrgAreaCode, current.OrgAreaName,
|
|
|
- current.OrgIsCenter, opinion, nextStepCode);
|
|
|
+ current.RequiredOrgId, current.OrgName,
|
|
|
+ current.OrgAreaCode, current.OrgAreaName,
|
|
|
+ current.OrgIsCenter, opinion, nextStepCode);
|
|
|
|
|
|
var handler = step.FindActualHandler(current.Roles, current.RequiredUserId, current.RequiredOrgId);
|
|
|
if (handler is not null)
|
|
@@ -1714,30 +1709,30 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
return countersign;
|
|
|
}
|
|
|
|
|
|
- private async Task JumpTraceAsync(string workflowId, RecallDto dto, CancellationToken cancellationToken)
|
|
|
- {
|
|
|
- //未办理的traces
|
|
|
- var uncompleteTraces =
|
|
|
- await _workflowTraceRepository.QueryAsync(d =>
|
|
|
- d.WorkflowId == workflowId && string.IsNullOrEmpty(d.HandlerId));
|
|
|
- foreach (var trace in uncompleteTraces)
|
|
|
- {
|
|
|
- HandleTrace(trace, dto.Opinion);
|
|
|
- }
|
|
|
+ //private async Task JumpTraceAsync(string workflowId, RecallDto dto, CancellationToken cancellationToken)
|
|
|
+ //{
|
|
|
+ // //未办理的traces
|
|
|
+ // var uncompleteTraces =
|
|
|
+ // await _workflowTraceRepository.QueryAsync(d =>
|
|
|
+ // d.WorkflowId == workflowId && string.IsNullOrEmpty(d.HandlerId));
|
|
|
+ // foreach (var trace in uncompleteTraces)
|
|
|
+ // {
|
|
|
+ // HandleTrace(trace, dto.Opinion);
|
|
|
+ // }
|
|
|
|
|
|
- await _workflowTraceRepository.UpdateRangeAsync(uncompleteTraces, cancellationToken);
|
|
|
- }
|
|
|
+ // await _workflowTraceRepository.UpdateRangeAsync(uncompleteTraces, cancellationToken);
|
|
|
+ //}
|
|
|
|
|
|
- private void HandleTrace(WorkflowTrace trace, string opinion)
|
|
|
+ private void HandleTrace(WorkflowTrace trace, string opinion, ISessionContext current)
|
|
|
{
|
|
|
trace.Handle(
|
|
|
- _sessionContext.RequiredUserId, _sessionContext.UserName,
|
|
|
- _sessionContext.RequiredOrgId, _sessionContext.OrgName,
|
|
|
- _sessionContext.OrgAreaCode, _sessionContext.OrgAreaName,
|
|
|
- _sessionContext.OrgIsCenter, opinion);
|
|
|
+ current.RequiredUserId, current.UserName,
|
|
|
+ current.RequiredOrgId, current.OrgName,
|
|
|
+ current.OrgAreaCode, current.OrgAreaName,
|
|
|
+ current.OrgIsCenter, opinion);
|
|
|
}
|
|
|
|
|
|
- private async Task RecallTraceAsync(string workflowId, string opinion, CancellationToken cancellationToken)
|
|
|
+ private async Task RecallTraceAsync(string workflowId, string opinion, ISessionContext current, CancellationToken cancellationToken)
|
|
|
{
|
|
|
//未办理的traces
|
|
|
var uncompleteTraces =
|
|
@@ -1748,7 +1743,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
{
|
|
|
foreach (var trace in uncompleteTraces)
|
|
|
{
|
|
|
- HandleTrace(trace, opinion);
|
|
|
+ HandleTrace(trace, opinion, current);
|
|
|
}
|
|
|
|
|
|
await _workflowTraceRepository.UpdateRangeAsync(uncompleteTraces, cancellationToken);
|
|
@@ -1756,11 +1751,11 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
}
|
|
|
|
|
|
private async Task<WorkflowTrace> PreviousTraceAsync(string workflowId, PreviousWorkflowDto dto,
|
|
|
- WorkflowStep step, CancellationToken cancellationToken)
|
|
|
+ WorkflowStep step, ISessionContext current, CancellationToken cancellationToken)
|
|
|
{
|
|
|
var trace = await GetWorkflowTraceAsync(workflowId, step.Id, cancellationToken);
|
|
|
_mapper.Map(dto, trace);
|
|
|
- HandleTrace(trace, dto.Opinion);
|
|
|
+ HandleTrace(trace, dto.Opinion, current);
|
|
|
await _workflowTraceRepository.UpdateAsync(trace, cancellationToken);
|
|
|
return trace;
|
|
|
}
|