|
@@ -837,39 +837,6 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
return startStep;
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// 结束会签
|
|
|
- /// </summary>
|
|
|
- public async Task EndCountersignAsync(string workflowId, CancellationToken cancellationToken)
|
|
|
- {
|
|
|
- var workflow = await GetWorkflowAsync(workflowId,
|
|
|
- withSteps: true, withCountersigns: true, cancellationToken: cancellationToken);
|
|
|
- var countersign = workflow.Countersigns.FirstOrDefault(d =>
|
|
|
- !d.IsCompleted() && d.StarterId == _sessionContext.RequiredUserId);
|
|
|
- if (countersign is null) return;
|
|
|
-
|
|
|
- //var countersignStartStep = workflow.Steps.FirstOrDefault(d => d.Id == countersign.StartStepId);
|
|
|
- //if (countersignStartStep is null)
|
|
|
- // throw new UserFriendlyException($"未查询到会签对应开始节点, workflowId: {workflowId}, csId: {countersign.Id}");
|
|
|
- ////结束step会签信息
|
|
|
- //countersignStartStep.CountersignEnd();
|
|
|
- ////todo
|
|
|
- //updateSteps.Add(countersignStartStep);
|
|
|
-
|
|
|
- ////结束会签
|
|
|
- //countersign.End(currentStep.Id, currentStep.Code, currentStep.BusinessType,
|
|
|
- // _sessionContext.RequiredUserId, _sessionContext.UserName,
|
|
|
- // _sessionContext.RequiredOrgId, _sessionContext.OrgName,
|
|
|
- // _sessionContext.OrgAreaCode, _sessionContext.OrgAreaName);
|
|
|
- //await _workflowCountersignRepository.UpdateAsync(currentCountersign, cancellationToken);
|
|
|
-
|
|
|
-
|
|
|
- //todo thk: 以发起人/发起部门结束会签必须对应以发起人/发起部门开启会签限制
|
|
|
- //todo 1.当前会签内未办节点处理为已办(默认办理意见xx结束会签)2.create new csEndStep(看做会签待办节点最后一个节点办理时)
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
#region private method
|
|
|
|
|
|
public async Task<WorkflowStep> CreateStartStepAsync(Workflow workflow, StepDefine startStepDefine,
|
|
@@ -1693,20 +1660,69 @@ namespace Hotline.FlowEngine.Workflows
|
|
|
if (countersign is null)
|
|
|
throw new UserFriendlyException("无效会签编号");
|
|
|
|
|
|
- //todo 1. 检查会签是否已结束 t: return 2.检查是否有嵌套会签 t: 一起结束 3.结束会签 4.trace 5.cp会签发起节点变为待办节点
|
|
|
+ //todo 1. 检查会签是否已结束 t: return 2.检查是否有嵌套会签 t: 一起结束 3.结束会签 4.trace 5.检查workflow会签状态,如果会签全结束需更新状态 6.cp会签发起节点变为待办节点
|
|
|
+ if (countersign.IsCompleted()) return;
|
|
|
|
|
|
- /*
|
|
|
- * //结束step会签信息
|
|
|
- countersignStartStep.CountersignEnd();
|
|
|
- updateSteps.Add(countersignStartStep);
|
|
|
+ countersign.Children = await _workflowCountersignRepository.Queryable()
|
|
|
+ .Where(d => d.WorkflowId == countersign.WorkflowId)
|
|
|
+ .ToTreeAsync(d => d.Children, d => d.ParentId, countersign.Id);
|
|
|
|
|
|
- //结束会签
|
|
|
- currentCountersign.End(currentStep.Id, currentStep.Code, currentStep.BusinessType,
|
|
|
- _sessionContext.RequiredUserId, _sessionContext.UserName,
|
|
|
- _sessionContext.RequiredOrgId, _sessionContext.OrgName,
|
|
|
- _sessionContext.OrgAreaCode, _sessionContext.OrgAreaName);
|
|
|
- await _workflowCountersignRepository.UpdateAsync(currentCountersign, cancellationToken);
|
|
|
- */
|
|
|
+ var updateCountersigns = new List<WorkflowCountersign>();
|
|
|
+ EndCountersignWithCascade(countersign, ref updateCountersigns);
|
|
|
+
|
|
|
+ if (updateCountersigns.Any())
|
|
|
+ {
|
|
|
+ await _workflowCountersignRepository.UpdateRangeAsync(updateCountersigns, cancellationToken);
|
|
|
+
|
|
|
+ var workflow = await GetWorkflowAsync(countersign.WorkflowId, withCountersigns: true,
|
|
|
+ cancellationToken: cancellationToken);
|
|
|
+
|
|
|
+ if (workflow.IsInCountersign && workflow.CheckIfCountersignOver())
|
|
|
+ workflow.EndCountersign();
|
|
|
+ await _workflowRepository.UpdateAsync(workflow, cancellationToken);
|
|
|
+ }
|
|
|
+
|
|
|
+ //6.
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 结束会签(包含子项)
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="countersign"></param>
|
|
|
+ /// <param name="updateCountersigns"></param>
|
|
|
+ private void EndCountersignWithCascade(WorkflowCountersign countersign, ref List<WorkflowCountersign> updateCountersigns)
|
|
|
+ {
|
|
|
+ if (countersign is null) return;
|
|
|
+ if (countersign.Children is not null && countersign.Children.Any())
|
|
|
+ {
|
|
|
+ foreach (var childCountersign in countersign.Children)
|
|
|
+ {
|
|
|
+ EndCountersignWithCascade(childCountersign, ref updateCountersigns);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ EndCountersign(countersign, ref updateCountersigns);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void EndCountersign(WorkflowCountersign countersign, ref List<WorkflowCountersign> updateCountersigns)
|
|
|
+ {
|
|
|
+ //todo 1. trace? 先确定展现形式 2. end cs
|
|
|
+
|
|
|
+ /*
|
|
|
+ * //结束step会签信息
|
|
|
+ countersignStartStep.CountersignEnd();
|
|
|
+ updateSteps.Add(countersignStartStep);
|
|
|
+
|
|
|
+ //结束会签
|
|
|
+ currentCountersign.End(currentStep.Id, currentStep.Code, currentStep.BusinessType,
|
|
|
+ _sessionContext.RequiredUserId, _sessionContext.UserName,
|
|
|
+ _sessionContext.RequiredOrgId, _sessionContext.OrgName,
|
|
|
+ _sessionContext.OrgAreaCode, _sessionContext.OrgAreaName);
|
|
|
+ await _workflowCountersignRepository.UpdateAsync(currentCountersign, cancellationToken);
|
|
|
+ */
|
|
|
+ throw new NotImplementedException();
|
|
|
}
|
|
|
|
|
|
private WorkflowStep? GetStep(List<WorkflowStep> steps, string orgCode, string userId,
|