|
@@ -13,6 +13,7 @@ using MapsterMapper;
|
|
|
using MediatR;
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
using SqlSugar;
|
|
|
+using System.Diagnostics;
|
|
|
using XF.Domain.Authentications;
|
|
|
using XF.Domain.Dependency;
|
|
|
using XF.Domain.Entities;
|
|
@@ -516,8 +517,11 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public async Task<EFlowDirection> PreviousAsync(Workflow workflow, PreviousWorkflowDto dto,
|
|
|
- string applicantId, string applicantOrgId, string[] applicantRoleIds,
|
|
|
- ISessionContext current, CancellationToken cancellationToken)
|
|
|
+ string applicantId, string applicantName,
|
|
|
+ string applicantOrgId, string applicantOrgName,
|
|
|
+ string applicantOrgAreaCode, string applicantOrgAreaName,
|
|
|
+ bool applicantIsCenter,
|
|
|
+ string[] applicantRoleIds, CancellationToken cancellationToken)
|
|
|
{
|
|
|
//ValidatePermission(workflow, operater.OrgId, operater.Id);
|
|
|
|
|
@@ -550,10 +554,15 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
//updateSteps.Add(countersignStartStep);
|
|
|
|
|
|
//结束会签
|
|
|
+ //currentCountersign.End(currentStep.Id, currentStep.Code, currentStep.BusinessType,
|
|
|
+ // current.RequiredUserId, current.UserName,
|
|
|
+ // current.RequiredOrgId, current.OrgName,
|
|
|
+ // current.OrgAreaCode, current.OrgAreaName);
|
|
|
currentCountersign.End(currentStep.Id, currentStep.Code, currentStep.BusinessType,
|
|
|
- current.RequiredUserId, current.UserName,
|
|
|
- current.RequiredOrgId, current.OrgName,
|
|
|
- current.OrgAreaCode, current.OrgAreaName);
|
|
|
+ applicantId, applicantName,
|
|
|
+ applicantOrgId, applicantOrgName,
|
|
|
+ applicantOrgAreaCode, applicantOrgAreaName);
|
|
|
+
|
|
|
await _workflowCountersignRepository.UpdateAsync(currentCountersign, cancellationToken);
|
|
|
|
|
|
//update workflow cs status
|
|
@@ -562,7 +571,11 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
}
|
|
|
|
|
|
//update trace
|
|
|
- var trace = await PreviousTraceAsync(workflow.Id, dto, currentStep, current, cancellationToken);
|
|
|
+ var trace = await PreviousTraceAsync(workflow.Id, dto, currentStep,
|
|
|
+ applicantId, applicantName,
|
|
|
+ applicantOrgId, applicantOrgName,
|
|
|
+ applicantOrgAreaCode, applicantOrgAreaName,
|
|
|
+ applicantIsCenter, cancellationToken);
|
|
|
|
|
|
//复制上一个节点为待接办
|
|
|
var newPrevStep = await DuplicateStepWithTraceAsync(workflow, prevStep, EWorkflowTraceType.Previous, cancellationToken);
|
|
@@ -573,6 +586,10 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
// .Include(d => d.StepHandlers)
|
|
|
// .ExecuteCommandAsync();
|
|
|
|
|
|
+ var stepIds = removeSteps.Select(d => d.Id).ToList();
|
|
|
+ var updateTraces = workflow.Traces.Where(d => stepIds.Contains(d.StepId)).ToList();
|
|
|
+ await UpdateTracesStateAsync(updateTraces, EWorkflowTraceState.StepRemoveByPrevious, cancellationToken);
|
|
|
+
|
|
|
if (workflow.Status is EWorkflowStatus.Completed)
|
|
|
workflow.SetStatusRunnable();
|
|
|
|
|
@@ -592,6 +609,16 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
return GetFlowDirection(currentStep.BusinessType, prevStep.BusinessType);
|
|
|
}
|
|
|
|
|
|
+ private async Task UpdateTracesStateAsync(List<WorkflowTrace> traces, EWorkflowTraceState traceState, CancellationToken cancellationToken)
|
|
|
+ {
|
|
|
+ foreach (var trace in traces)
|
|
|
+ {
|
|
|
+ trace.TraceState = traceState;
|
|
|
+ }
|
|
|
+
|
|
|
+ await _workflowTraceRepository.UpdateRangeAsync(traces, cancellationToken);
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 查询退回节点信息
|
|
|
/// </summary>
|
|
@@ -1333,7 +1360,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
|
|
|
await _workflowRepository.UpdateAsync(workflow, cancellationToken);
|
|
|
|
|
|
- await _mediator.Publish(new EndWorkflowNotify(workflow, endTrace, dto.External), cancellationToken);
|
|
|
+ await _mediator.Publish(new EndWorkflowNotify(workflow, endTrace, dto), cancellationToken);
|
|
|
|
|
|
return endTrace;
|
|
|
}
|
|
@@ -1886,12 +1913,23 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private async Task<WorkflowTrace> PreviousTraceAsync(string workflowId, PreviousWorkflowDto dto,
|
|
|
- WorkflowStep step, ISessionContext current, CancellationToken cancellationToken)
|
|
|
+ private async Task<WorkflowTrace> PreviousTraceAsync(string workflowId,
|
|
|
+ PreviousWorkflowDto dto, WorkflowStep step,
|
|
|
+ string applicantId, string applicantName,
|
|
|
+ string applicantOrgId, string applicantOrgName,
|
|
|
+ string applicantOrgAreaCode, string applicantOrgAreaName,
|
|
|
+ bool applicantIsCenter, CancellationToken cancellationToken)
|
|
|
{
|
|
|
var trace = await GetWorkflowTraceAsync(workflowId, step.Id, cancellationToken);
|
|
|
_mapper.Map(dto, trace);
|
|
|
- HandleTrace(trace, dto.Opinion, current);
|
|
|
+
|
|
|
+ //HandleTrace(trace, dto.Opinion, current);
|
|
|
+
|
|
|
+ trace.Handle(applicantId, applicantName,
|
|
|
+ applicantOrgId, applicantOrgName,
|
|
|
+ applicantOrgAreaCode, applicantOrgAreaName,
|
|
|
+ applicantIsCenter, dto.Opinion);
|
|
|
+
|
|
|
await _workflowTraceRepository.UpdateAsync(trace, cancellationToken);
|
|
|
return trace;
|
|
|
}
|
|
@@ -2002,6 +2040,11 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
// .Include(d => d.StepHandlers)
|
|
|
// .ExecuteCommandAsync();
|
|
|
workflow.Steps.RemoveAll(d => removeSteps.Contains(d));
|
|
|
+
|
|
|
+ //更新快照对应节点状态
|
|
|
+ var stepIds = removeSteps.Select(d => d.Id).ToList();
|
|
|
+ var updateTraces = workflow.Traces.Where(d => stepIds.Contains(d.StepId)).ToList();
|
|
|
+ await UpdateTracesStateAsync(updateTraces, EWorkflowTraceState.StepRemoveByRecall, cancellationToken);
|
|
|
}
|
|
|
|
|
|
workflow.EndCountersign();
|