|
@@ -238,55 +238,6 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
/// <summary>
|
|
|
/// 受理(接办)
|
|
|
/// </summary>
|
|
|
- //public async Task AcceptAsync(Workflow workflow, string userId, string userName, string orgCode, string orgName, CancellationToken cancellationToken)
|
|
|
- //{
|
|
|
- // if (!workflow.CanHandle(_sessionContext.RequiredUserId, _sessionContext.RequiredOrgId)) return;
|
|
|
- // //工单完成以后查看的场景
|
|
|
- // if (workflow.Status != EWorkflowStatus.Runnable) return;
|
|
|
-
|
|
|
- // var (currentStepBox, currentStep) = GetUnCompleteStepOrDefault(workflow.Steps, orgCode, userId);
|
|
|
- // if (currentStep is null) return;
|
|
|
- // if (currentStep.Status is EWorkflowStepStatus.WaitForHandle) return;
|
|
|
- // if (currentStep.HandlerType is EHandlerType.AssignedUser or EHandlerType.Role)
|
|
|
- // {
|
|
|
- // //userId
|
|
|
- // if (currentStep.Handlers.All(d => d.Id != userId)) return;
|
|
|
- // }
|
|
|
- // else
|
|
|
- // {
|
|
|
- // //orgId
|
|
|
- // if (currentStep.Handlers.All(d => d.Id != orgCode)) return;
|
|
|
- // }
|
|
|
- // if (currentStep.StepType is EStepType.End)
|
|
|
- // throw new UserFriendlyException("当前流程已流转到最终步骤");
|
|
|
-
|
|
|
- // var changedSteps = new List<WorkflowStep> { currentStep };
|
|
|
- // if (currentStepBox.Status is EWorkflowStepStatus.WaitForAccept)
|
|
|
- // {
|
|
|
- // currentStepBox.Status = EWorkflowStepStatus.WaitForHandle;
|
|
|
- // changedSteps.Add(currentStepBox);
|
|
|
- // }
|
|
|
- // currentStep.Accept(userId, userName, _sessionContext.RequiredOrgId, _sessionContext.OrgName);
|
|
|
-
|
|
|
- // //接办时非会签并且有多个接办部门时需更新接办部门
|
|
|
- // if (!workflow.IsInCountersign())
|
|
|
- // {
|
|
|
- // var assigns = await _workflowAssignRepository.QueryAsync(d => d.WorkflowId == workflow.Id);
|
|
|
- // if (assigns.Count > 1)
|
|
|
- // {
|
|
|
- // await _workflowAssignRepository.RemoveRangeAsync(assigns, cancellationToken);
|
|
|
-
|
|
|
- // var assign = WorkflowAssign.Create(workflow.Id, orgCode, orgName);
|
|
|
- // await _workflowAssignRepository.AddAsync(assign, cancellationToken);
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
- // await _workflowStepRepository.UpdateRangeAsync(changedSteps, cancellationToken);
|
|
|
-
|
|
|
- // await AcceptTraceAsync(workflow, currentStep, cancellationToken);
|
|
|
-
|
|
|
- // await _mediator.Publish(new AcceptWorkflowNotify(workflow), cancellationToken);
|
|
|
- //}
|
|
|
|
|
|
//new
|
|
|
public async Task AcceptAsync(Workflow workflow,
|
|
@@ -349,160 +300,6 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
/// <summary>
|
|
|
/// 办理(流转至下一节点)
|
|
|
/// </summary>
|
|
|
- //public async Task NextAsync(Workflow workflow, NextWorkflowDto dto, StepDefine nextStepDefine,
|
|
|
- //FlowAssignInfo flowAssignInfo, DateTime expiredTime, CancellationToken cancellationToken)
|
|
|
- //{
|
|
|
- // ValidatePermission(workflow);
|
|
|
- // CheckWhetherRunnable(workflow.Status);
|
|
|
-
|
|
|
- // #region 办理当前节点
|
|
|
-
|
|
|
- // var (currentStepBox, currentStep) = GetUnCompleteStep(workflow.Steps, _sessionContext.RequiredOrgId, _sessionContext.RequiredUserId);
|
|
|
-
|
|
|
- // var counterSignType = GetCounterSignType(currentStep.BusinessType);
|
|
|
-
|
|
|
- // await HandleStepAsync(workflow, dto, currentStepBox, currentStep, counterSignType, cancellationToken);
|
|
|
-
|
|
|
- // //update realhandle info
|
|
|
- // _mapper.Map(dto, workflow);
|
|
|
-
|
|
|
- // var updateSteps = new List<WorkflowStep> { currentStepBox, currentStep };
|
|
|
- // //结束当前会签流程
|
|
|
- // if (currentStep.StepType is EStepType.Summary && currentStep.IsInCountersign)
|
|
|
- // {
|
|
|
- // var currentCountersign = workflow.Countersigns.FirstOrDefault(d => d.Id == currentStep.CountersignId);
|
|
|
- // if (currentCountersign is null)
|
|
|
- // throw new UserFriendlyException(
|
|
|
- // $"未查询到对应会签信息,workflowId:{workflow.Id}, countersignId:{currentStep.CountersignId}", "无效会签编号");
|
|
|
-
|
|
|
- // //1.根据当前节点配置查找结束节点对应开始节点 2.如该开始节点与当前会签开始节点吻合说明可以结束
|
|
|
-
|
|
|
- // //如果!=,说明未发起会签而是继承的外层会签
|
|
|
- // if (currentStepBox.CountersignStartStepCode == currentCountersign.StartStepCode)
|
|
|
- // {
|
|
|
- // //结束step会签信息
|
|
|
- // var countersignStartStepBox =
|
|
|
- // workflow.Steps.FirstOrDefault(d => d.Code == currentCountersign.StartStepCode);
|
|
|
- // if (countersignStartStepBox is null)
|
|
|
- // throw new UserFriendlyException(
|
|
|
- // $"未查询到会签开始stepBox, workflowId: {workflow.Id}, startStepCode: {currentCountersign.StartStepCode}", "未查询到会签开始节点");
|
|
|
- // var countersignStartStep =
|
|
|
- // countersignStartStepBox.Steps.FirstOrDefault(d => d.HasStartedCountersign && d.Id == currentCountersign.StartStepId);
|
|
|
- // if (countersignStartStep is null)
|
|
|
- // throw new UserFriendlyException(
|
|
|
- // $"未查询到会签开始step, workflowId: {workflow.Id}, startStepId: {currentCountersign.StartStepId}", "未查询到会签开始节点");
|
|
|
- // countersignStartStep.CountersignEnd();
|
|
|
- // updateSteps.Add(countersignStartStep);
|
|
|
-
|
|
|
- // //结束会签
|
|
|
- // currentCountersign.End(currentStep.Id, currentStep.Code, currentStep.BusinessType);
|
|
|
- // await _workflowCountersignRepository.UpdateAsync(currentCountersign, cancellationToken);
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
- // await _workflowStepRepository.UpdateRangeAsync(updateSteps, cancellationToken);
|
|
|
-
|
|
|
- // await NextTraceAsync(workflow, dto, currentStep, cancellationToken);
|
|
|
-
|
|
|
- // #endregion
|
|
|
-
|
|
|
- // #region 处理流程
|
|
|
-
|
|
|
- // //检查会签是否结束,并更新当前会签节点字段
|
|
|
- // var isCountersignOver = false;
|
|
|
- // if (workflow.IsInCountersign() && currentStep.StepType is EStepType.Summary)
|
|
|
- // {
|
|
|
- // isCountersignOver = workflow.CheckIfCountersignOver();
|
|
|
- // if (isCountersignOver)
|
|
|
- // workflow.EndCountersign();
|
|
|
- // }
|
|
|
-
|
|
|
- // //检查是否流转到流程终点
|
|
|
- // if (nextStepDefine.StepType is EStepType.End && !workflow.IsInCountersign())
|
|
|
- // {
|
|
|
- // var endTrace = await WorkflowEndAsync(workflow, dto, nextStepDefine, currentStepBox, currentStep, cancellationToken);
|
|
|
- // return;
|
|
|
- // }
|
|
|
-
|
|
|
- // //是否从中心流转出去,重新计算expiredTime
|
|
|
- // var isCenterToOrg = CheckIfFlowFromCenterToOrg(currentStepBox, nextStepDefine);
|
|
|
- // if (isCenterToOrg)
|
|
|
- // workflow.CenterToOrg(CalculateExpiredTime(workflow.WorkflowDefinition.Code));//todo 过期时间
|
|
|
-
|
|
|
- // //创建下一节点(会签汇总节点不重复创建)
|
|
|
- // var nextStepBox = await CreateStepAsync(workflow, nextStepDefine, dto, EWorkflowStepStatus.Created,
|
|
|
- // currentStepBox, currentStep, EWorkflowTraceStatus.Normal, expiredTime, cancellationToken);
|
|
|
-
|
|
|
- // //下一节点为汇总节点时,检查下一节点是否可办理
|
|
|
- // var nextStepCanHandle = true;
|
|
|
- // if (nextStepBox.StepType is EStepType.Summary && currentStep.IsInCountersign)
|
|
|
- // {
|
|
|
- // //同一会签Id,非汇总节点
|
|
|
- // var steps = await _workflowStepRepository.QueryAsync(d =>
|
|
|
- // d.WorkflowId == workflow.Id
|
|
|
- // && d.CountersignId == currentStep.CountersignId
|
|
|
- // && d.StepType == EStepType.Normal
|
|
|
- // && !string.IsNullOrEmpty(d.ParentId));
|
|
|
- // //(当前办理节点所处同一会签内的所有step全都办理完成并且如果开启了会签的step,必须会签结束)
|
|
|
- // var unComplete = steps.Any(d =>
|
|
|
- // d.Status != EWorkflowStepStatus.Handled ||
|
|
|
- // (d.HasStartedCountersign && !(d.IsStartedCountersignSummary ?? false)));
|
|
|
- // nextStepCanHandle = !unComplete;
|
|
|
- // }
|
|
|
-
|
|
|
- // //更新办理人
|
|
|
- // workflow.UpdateHandlers(_sessionContext.RequiredUserId, _sessionContext.RequiredOrgId,
|
|
|
- // flowAssignInfo.FlowAssignType, flowAssignInfo.HandlerObjects);
|
|
|
-
|
|
|
- // if (nextStepCanHandle)
|
|
|
- // {
|
|
|
- // //将下一节点处理为已指派/可接办
|
|
|
- // await SetNextCountersignEndAssignedAsync(nextStepBox, currentStep, cancellationToken);
|
|
|
-
|
|
|
- // await _mediator.Publish(new CountersignEndAssigned(workflow), cancellationToken);
|
|
|
- // }
|
|
|
-
|
|
|
- // //更新实际办理节点名称、时间
|
|
|
- // workflow.UpdateWorkflowActualHandleInfo(currentStepBox, currentStep,
|
|
|
- // _sessionContext.RequiredUserId, _sessionContext.UserName,
|
|
|
- // _sessionContext.RequiredOrgId, _sessionContext.OrgName,
|
|
|
- // _sessionContext.OrgAreaCode, _sessionContext.OrgAreaName);
|
|
|
-
|
|
|
- // //todo 计算办理工作时长
|
|
|
-
|
|
|
- // //更新当前办理节点信息
|
|
|
- // workflow.UpdateWorkflowCurrentStepInfo(dto.IsStartCountersign, currentStep, nextStepBox.Steps.First());
|
|
|
-
|
|
|
- // //发起会签时记录顶层会签节点
|
|
|
- // if (dto.IsStartCountersign && !workflow.IsInCountersign())
|
|
|
- // workflow.StartCountersign(currentStepBox.Code, counterSignType);
|
|
|
-
|
|
|
- // //更新指派信息
|
|
|
- // workflow.Assign(flowAssignInfo.FlowAssignType, flowAssignInfo.GetHandlerIds());
|
|
|
-
|
|
|
- // await _workflowRepository.UpdateAsync(workflow, cancellationToken);
|
|
|
-
|
|
|
- // #endregion
|
|
|
-
|
|
|
- // #region 流转记录
|
|
|
-
|
|
|
- // var trace = await NextTraceAsync(workflow, dto, currentStep, cancellationToken);
|
|
|
-
|
|
|
- // #endregion
|
|
|
-
|
|
|
- // #region 处理额外参数(短信通知、办理时限、省延期)
|
|
|
-
|
|
|
- // //需统一处理的放在这里,与业务关联的放在业务中去处理,如:省延期
|
|
|
- // //todo
|
|
|
-
|
|
|
- // #endregion
|
|
|
-
|
|
|
- // await _mediator.Publish(new NextStepNotify(workflow, dto, trace,
|
|
|
- // isCenterToOrg, isCountersignOver,
|
|
|
- // _sessionContext.RequiredOrgId, flowAssignInfo), cancellationToken);
|
|
|
- //}
|
|
|
-
|
|
|
- //new
|
|
|
public async Task NextAsync(Workflow workflow, NextWorkflowDto dto, StepDefine nextStepDefine,
|
|
|
FlowAssignInfo flowAssignInfo, DateTime expiredTime, CancellationToken cancellationToken)
|
|
|
{
|