|
@@ -401,7 +401,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- await HandleStepAsync(currentStep, workflow, dto, counterSignType, expiredTime, cancellationToken);
|
|
|
+ await HandleStepAsync(currentStep, workflow, dto, counterSignType, expiredTime, EHandleMode.Normal, cancellationToken);
|
|
|
|
|
|
currentStep.IsActualHandled = CheckIsActualHandle(workflow, currentStep, nextStepDefine, dto);
|
|
|
|
|
@@ -989,7 +989,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
trace.Handle(applicantId, applicantName,
|
|
|
applicantOrgId, applicantOrgName,
|
|
|
applicantOrgAreaCode, applicantOrgAreaName,
|
|
|
- applicantIsCenter, dto.Opinion);
|
|
|
+ applicantIsCenter, EHandleMode.Previous, dto.Opinion);
|
|
|
|
|
|
//await _workflowTraceRepository.UpdateAsync(trace, cancellationToken);
|
|
|
|
|
@@ -1484,7 +1484,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
await _workflowStepRepository.UpdateAsync(prevStep, cancellationToken);
|
|
|
|
|
|
var endTrace = workflow.Traces.FirstOrDefault(p => p.Id == prevStep.Id);
|
|
|
- if (endTrace!=null)
|
|
|
+ if (endTrace != null)
|
|
|
{
|
|
|
endTrace.Opinion = prevStep.Opinion;
|
|
|
endTrace.FileJson = prevStep.FileJson;
|
|
@@ -1535,7 +1535,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
|
|
|
foreach (var step in unhandleSteps)
|
|
|
{
|
|
|
- await HandleStepAsync(step, workflow, dto, null, null, cancellationToken);
|
|
|
+ await HandleStepAsync(step, workflow, dto, null, null, EHandleMode.Normal, cancellationToken);
|
|
|
if (step.IsStartCountersign)
|
|
|
step.CountersignEnd();
|
|
|
|
|
@@ -1604,7 +1604,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
/// </summary>
|
|
|
public async Task RecallAsync(Workflow workflow, RecallDto dto, StepDefine targetStepDefine,
|
|
|
FlowAssignInfo flowAssignInfo, EWorkflowTraceType traceType, DateTime? expiredTime, bool isOrderFiled,
|
|
|
- CancellationToken cancellationToken)
|
|
|
+ EHandleMode handleMode, CancellationToken cancellationToken)
|
|
|
{
|
|
|
var targetStep = workflow.Steps.FirstOrDefault(d => d.Code == dto.NextStepCode && d.IsOrigin);
|
|
|
if (targetStep is null)
|
|
@@ -1614,7 +1614,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
//await RecallTraceAsync(workflow.Traces, dto.Opinion, _sessionContext, cancellationToken);
|
|
|
|
|
|
var isOrgToCenter = await RecallAsync(workflow, dto, flowAssignInfo, targetStepDefine, targetStep,
|
|
|
- traceType, expiredTime, isOrderFiled, cancellationToken);
|
|
|
+ traceType, expiredTime, isOrderFiled, handleMode, cancellationToken);
|
|
|
|
|
|
await _workflowRepository.UpdateAsync(workflow, cancellationToken);
|
|
|
|
|
@@ -1626,7 +1626,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
/// 撤回至开始节点
|
|
|
/// </summary>
|
|
|
public async Task RecallToStartStepAsync(string workflowId, string opinion, bool isOrderFiled, DateTime? expiredTime,
|
|
|
- CancellationToken cancellationToken)
|
|
|
+ EHandleMode handleMode, 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, withTraces: true, withCountersigns: true,
|
|
@@ -1665,14 +1665,14 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
dto.NextHandlers.Select(d => new Kv(d.Key, d.Value)).ToList(), cancellationToken);
|
|
|
//flowAssignInfo.FlowAssignType = EFlowAssignType.Role;
|
|
|
await RecallAsync(workflow, dto, targetStepDefine, flowAssignInfo, EWorkflowTraceType.Recall, expiredTime, isOrderFiled,
|
|
|
- cancellationToken);
|
|
|
+ handleMode, cancellationToken);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 撤回至派单节点
|
|
|
/// </summary>
|
|
|
public async Task RecallToSendStepAsync(string workflowId, string opinion, bool isOrderFiled, DateTime? expiredTime,
|
|
|
- CancellationToken cancellationToken)
|
|
|
+ EHandleMode handleMode, CancellationToken cancellationToken)
|
|
|
{
|
|
|
var workflow = await GetWorkflowAsync(workflowId, withDefine: true, withSteps: true, withTraces: true, withCountersigns: true,
|
|
|
cancellationToken: cancellationToken);
|
|
@@ -1710,7 +1710,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
dto.NextHandlers.Select(d => new Kv(d.Key, d.Value)).ToList(), cancellationToken);
|
|
|
//flowAssignInfo.FlowAssignType = EFlowAssignType.Role;
|
|
|
await RecallAsync(workflow, dto, targetStepDefine, flowAssignInfo, EWorkflowTraceType.Recall, expiredTime, isOrderFiled,
|
|
|
- cancellationToken);
|
|
|
+ handleMode, cancellationToken);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -1718,7 +1718,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
/// </summary>
|
|
|
/// <returns>true 派单组 false 话务部</returns>
|
|
|
public async Task<(bool, Workflow workflow)> RecallToCenterFirstToSendAsync(string workflowId, string opinion, bool isOrderFiled,
|
|
|
- DateTime? expiredTime, List<FlowStepHandler>? handlers, CancellationToken cancellationToken)
|
|
|
+ DateTime? expiredTime, List<FlowStepHandler>? handlers, EHandleMode handleMode, CancellationToken cancellationToken)
|
|
|
{
|
|
|
bool isPaiDan = true;
|
|
|
var workflow = await GetWorkflowAsync(workflowId, withDefine: true, withSteps: true, withTraces: true, withCountersigns: true,
|
|
@@ -1758,7 +1758,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
var flowAssignInfo = await GetNextStepFlowAssignInfoByDefineAsync(targetStepDefine, dto.HandlerType, dto.IsStartCountersign,
|
|
|
dto.NextHandlers.Select(d => new Kv(d.Key, d.Value)).ToList(), cancellationToken);
|
|
|
await RecallAsync(workflow, dto, targetStepDefine, flowAssignInfo, EWorkflowTraceType.Recall, expiredTime, isOrderFiled,
|
|
|
- cancellationToken);
|
|
|
+ handleMode, cancellationToken);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -1796,7 +1796,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
dto.NextHandlers.Select(d => new Kv(d.Key, d.Value)).ToList(), cancellationToken);
|
|
|
//flowAssignInfo.FlowAssignType = EFlowAssignType.Role;
|
|
|
await RecallAsync(workflow, dto, targetStepDefine, flowAssignInfo, EWorkflowTraceType.Recall, expiredTime, isOrderFiled,
|
|
|
- cancellationToken);
|
|
|
+ handleMode, cancellationToken);
|
|
|
isPaiDan = false;
|
|
|
}
|
|
|
|
|
@@ -2058,7 +2058,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
/// </summary>
|
|
|
public async Task HandleStepAsync(WorkflowStep step, Workflow workflow,
|
|
|
BasicWorkflowDto dto, ECounterSignType? counterSignType,
|
|
|
- DateTime? expiredTime, CancellationToken cancellationToken)
|
|
|
+ DateTime? expiredTime, EHandleMode handleMode, CancellationToken cancellationToken)
|
|
|
{
|
|
|
if (step.Status is EWorkflowStepStatus.Handled)
|
|
|
throw UserFriendlyException.SameMessage("当前节点状态已办理");
|
|
@@ -2079,7 +2079,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
step.Remark = dto.Remark;
|
|
|
|
|
|
//step办理状态
|
|
|
- HandleStep(step, dto.Opinion, dto.NextStepCode);
|
|
|
+ HandleStep(step, handleMode, dto.Opinion, dto.NextStepCode);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -2573,13 +2573,13 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
/// <summary>
|
|
|
/// 办理节点(赋值节点的办理对象信息)
|
|
|
/// </summary>
|
|
|
- private void HandleStep(WorkflowStep step, string opinion, string nextStepCode)
|
|
|
+ private void HandleStep(WorkflowStep step, EHandleMode handleMode, string opinion, string nextStepCode)
|
|
|
{
|
|
|
//todo 重构:ISessionContext传入
|
|
|
step.Handle(_sessionContextProvider.SessionContext.RequiredUserId, _sessionContextProvider.SessionContext.UserName,
|
|
|
_sessionContextProvider.SessionContext.RequiredOrgId, _sessionContextProvider.SessionContext.OrgName,
|
|
|
_sessionContextProvider.SessionContext.OrgAreaCode, _sessionContextProvider.SessionContext.OrgAreaName,
|
|
|
- _sessionContextProvider.SessionContext.OrgIsCenter, opinion, nextStepCode);
|
|
|
+ _sessionContextProvider.SessionContext.OrgIsCenter, handleMode, opinion, nextStepCode);
|
|
|
|
|
|
//var handler = step.FindActualHandler(current.Roles, current.RequiredUserId, current.RequiredOrgId);
|
|
|
//if (handler is not null)
|
|
@@ -2776,51 +2776,51 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
// await _workflowTraceRepository.UpdateRangeAsync(uncompleteTraces, cancellationToken);
|
|
|
//}
|
|
|
|
|
|
- private async Task RecallTraceAsync(List<WorkflowTrace> traces, string opinion, ISessionContext current,
|
|
|
- CancellationToken cancellationToken)
|
|
|
- {
|
|
|
- //未办理的traces
|
|
|
- //var uncompleteTraces =
|
|
|
- // await _workflowTraceRepository.QueryAsync(d =>
|
|
|
- // d.WorkflowId == workflowId && string.IsNullOrEmpty(d.HandlerId));
|
|
|
+ //private async Task RecallTraceAsync(List<WorkflowTrace> traces, string opinion, ISessionContext current,
|
|
|
+ // CancellationToken cancellationToken)
|
|
|
+ //{
|
|
|
+ // //未办理的traces
|
|
|
+ // //var uncompleteTraces =
|
|
|
+ // // await _workflowTraceRepository.QueryAsync(d =>
|
|
|
+ // // d.WorkflowId == workflowId && string.IsNullOrEmpty(d.HandlerId));
|
|
|
|
|
|
- var uncompleteTraces = traces.Where(d => d.Status != EWorkflowStepStatus.Handled).ToList();
|
|
|
+ // var uncompleteTraces = traces.Where(d => d.Status != EWorkflowStepStatus.Handled).ToList();
|
|
|
|
|
|
- if (uncompleteTraces.Any())
|
|
|
- {
|
|
|
- foreach (var trace in uncompleteTraces)
|
|
|
- {
|
|
|
- trace.Handle(
|
|
|
- current.RequiredUserId, current.UserName,
|
|
|
- current.RequiredOrgId, current.OrgName,
|
|
|
- current.OrgAreaCode, current.OrgAreaName,
|
|
|
- current.OrgIsCenter, opinion);
|
|
|
- }
|
|
|
+ // if (uncompleteTraces.Any())
|
|
|
+ // {
|
|
|
+ // foreach (var trace in uncompleteTraces)
|
|
|
+ // {
|
|
|
+ // trace.Handle(
|
|
|
+ // current.RequiredUserId, current.UserName,
|
|
|
+ // current.RequiredOrgId, current.OrgName,
|
|
|
+ // current.OrgAreaCode, current.OrgAreaName,
|
|
|
+ // current.OrgIsCenter, opinion);
|
|
|
+ // }
|
|
|
|
|
|
- await _workflowTraceRepository.UpdateRangeAsync(uncompleteTraces, cancellationToken);
|
|
|
- }
|
|
|
- }
|
|
|
+ // await _workflowTraceRepository.UpdateRangeAsync(uncompleteTraces, 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);
|
|
|
+ //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);
|
|
|
+ // trace.Handle(applicantId, applicantName,
|
|
|
+ // applicantOrgId, applicantOrgName,
|
|
|
+ // applicantOrgAreaCode, applicantOrgAreaName,
|
|
|
+ // applicantIsCenter, dto.Opinion);
|
|
|
|
|
|
- await _workflowTraceRepository.UpdateAsync(trace, cancellationToken);
|
|
|
- return trace;
|
|
|
- }
|
|
|
+ // await _workflowTraceRepository.UpdateAsync(trace, cancellationToken);
|
|
|
+ // return trace;
|
|
|
+ //}
|
|
|
|
|
|
//private async Task EndTraceAsync(Workflow workflow, BasicWorkflowDto dto, WorkflowStep step, CancellationToken cancellationToken)
|
|
|
//{
|
|
@@ -2916,7 +2916,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
|
|
|
private async Task<bool> RecallAsync(Workflow workflow, BasicWorkflowDto dto, FlowAssignInfo flowAssignInfo,
|
|
|
StepDefine targetStepDefine, WorkflowStep targetStep, EWorkflowTraceType traceType,
|
|
|
- DateTime? expiredTime, bool isOrderFiled, CancellationToken cancellationToken)
|
|
|
+ DateTime? expiredTime, bool isOrderFiled, EHandleMode handleMode, CancellationToken cancellationToken)
|
|
|
{
|
|
|
var targetIsStartStep = targetStepDefine.StepType is EStepType.Start;
|
|
|
var updateTraces = new List<WorkflowTrace>();
|
|
@@ -2931,7 +2931,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
_sessionContextProvider.SessionContext.RequiredUserId, _sessionContextProvider.SessionContext.UserName,
|
|
|
_sessionContextProvider.SessionContext.RequiredOrgId, _sessionContextProvider.SessionContext.OrgName,
|
|
|
_sessionContextProvider.SessionContext.OrgAreaCode, _sessionContextProvider.SessionContext.OrgAreaName,
|
|
|
- _sessionContextProvider.SessionContext.OrgIsCenter, dto.Opinion);
|
|
|
+ _sessionContextProvider.SessionContext.OrgIsCenter, handleMode, dto.Opinion);
|
|
|
}
|
|
|
|
|
|
//await _workflowTraceRepository.UpdateRangeAsync(uncompleteTraces, cancellationToken);
|
|
@@ -3111,7 +3111,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
// _sessionContextProvider.SessionContext.RequiredOrgId, _sessionContextProvider.SessionContext.OrgName,
|
|
|
// _sessionContextProvider.SessionContext.OrgAreaCode, _sessionContextProvider.SessionContext.OrgAreaName);
|
|
|
|
|
|
- HandleStep(step, "流程归档", string.Empty);
|
|
|
+ HandleStep(step, EHandleMode.Normal, "流程归档", string.Empty);
|
|
|
|
|
|
await _workflowStepRepository.AddAsync(step, cancellationToken);
|
|
|
workflow.Steps.Add(step);
|
|
@@ -3520,7 +3520,7 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
step.Handle(_sessionContextProvider.SessionContext.RequiredUserId, _sessionContextProvider.SessionContext.UserName,
|
|
|
_sessionContextProvider.SessionContext.RequiredOrgId, _sessionContextProvider.SessionContext.OrgName,
|
|
|
_sessionContextProvider.SessionContext.OrgAreaCode, _sessionContextProvider.SessionContext.OrgAreaName,
|
|
|
- _sessionContextProvider.SessionContext.OrgIsCenter, opinion);
|
|
|
+ _sessionContextProvider.SessionContext.OrgIsCenter, EHandleMode.Normal, opinion);
|
|
|
}
|
|
|
|
|
|
updateSteps.Add(step);
|