|
@@ -1651,38 +1651,72 @@ namespace Hotline.FlowEngine.Workflows
|
|
/// 终止会签
|
|
/// 终止会签
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="countersignId"></param>
|
|
/// <param name="countersignId"></param>
|
|
- /// <param name="workflowId"></param>
|
|
|
|
/// <param name="cancellationToken"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
- public async Task TerminalCountersignAsync(string countersignId, string? workflowId = null, CancellationToken cancellationToken = default)
|
|
|
|
|
|
+ public async Task TerminalCountersignAsync(string countersignId, CancellationToken cancellationToken)
|
|
{
|
|
{
|
|
var countersign = await _workflowCountersignRepository.GetAsync(countersignId, cancellationToken);
|
|
var countersign = await _workflowCountersignRepository.GetAsync(countersignId, cancellationToken);
|
|
if (countersign is null)
|
|
if (countersign is null)
|
|
throw new UserFriendlyException("无效会签编号");
|
|
throw new UserFriendlyException("无效会签编号");
|
|
|
|
|
|
//todo 1. 检查会签是否已结束 t: return 2.检查是否有嵌套会签 t: 一起结束 3.结束会签 4.trace 5.检查workflow会签状态,如果会签全结束需更新状态 6.cp会签发起节点变为待办节点
|
|
//todo 1. 检查会签是否已结束 t: return 2.检查是否有嵌套会签 t: 一起结束 3.结束会签 4.trace 5.检查workflow会签状态,如果会签全结束需更新状态 6.cp会签发起节点变为待办节点
|
|
- if (countersign.IsCompleted()) return;
|
|
|
|
|
|
+ if (countersign.IsCompleted())
|
|
|
|
+ throw new UserFriendlyException("该会签已结束");
|
|
|
|
|
|
- countersign.Children = await _workflowCountersignRepository.Queryable()
|
|
|
|
- .Where(d => d.WorkflowId == countersign.WorkflowId)
|
|
|
|
- .ToTreeAsync(d => d.Children, d => d.ParentId, countersign.Id);
|
|
|
|
|
|
+ var workflow = await GetWorkflowAsync(countersign.WorkflowId, withSteps: true, withTraces: true,
|
|
|
|
+ withCountersigns: true, cancellationToken: cancellationToken);
|
|
|
|
|
|
|
|
+ var startStep = workflow.Steps.Find(d => d.StartCountersignId == countersignId);
|
|
|
|
+ if (startStep is null)
|
|
|
|
+ throw new UserFriendlyException("未查询到发起会签节点");
|
|
|
|
+ if (startStep.IsStartedCountersignEnd)
|
|
|
|
+ throw new UserFriendlyException("该会签已汇总");
|
|
|
|
+
|
|
var updateCountersigns = new List<WorkflowCountersign>();
|
|
var updateCountersigns = new List<WorkflowCountersign>();
|
|
- EndCountersignWithCascade(countersign, ref updateCountersigns);
|
|
|
|
|
|
+ EndCountersignWithCascade(countersign, workflow.Countersigns, ref updateCountersigns);
|
|
|
|
|
|
if (updateCountersigns.Any())
|
|
if (updateCountersigns.Any())
|
|
{
|
|
{
|
|
- await _workflowCountersignRepository.UpdateRangeAsync(updateCountersigns, cancellationToken);
|
|
|
|
-
|
|
|
|
- var workflow = await GetWorkflowAsync(countersign.WorkflowId, withCountersigns: true,
|
|
|
|
- cancellationToken: cancellationToken);
|
|
|
|
|
|
+ var updateSteps = new List<WorkflowStep>();
|
|
|
|
+ var updateTraces = new List<WorkflowTrace>();
|
|
|
|
+ HandleStepsWithCascade(startStep, workflow.Steps, workflow.Traces, ref updateSteps, ref updateTraces);
|
|
|
|
+ if (updateSteps.Any())
|
|
|
|
+ await _workflowStepRepository.UpdateRangeAsync(updateSteps, cancellationToken);
|
|
|
|
+ if (updateTraces.Any())
|
|
|
|
+ await _workflowTraceRepository.UpdateRangeAsync(updateTraces, cancellationToken);
|
|
|
|
|
|
if (workflow.IsInCountersign && workflow.CheckIfCountersignOver())
|
|
if (workflow.IsInCountersign && workflow.CheckIfCountersignOver())
|
|
workflow.EndCountersign();
|
|
workflow.EndCountersign();
|
|
await _workflowRepository.UpdateAsync(workflow, cancellationToken);
|
|
await _workflowRepository.UpdateAsync(workflow, cancellationToken);
|
|
|
|
+
|
|
|
|
+ await _workflowCountersignRepository.UpdateRangeAsync(updateCountersigns, cancellationToken);
|
|
}
|
|
}
|
|
|
|
|
|
- //6.
|
|
|
|
|
|
+ //cp会签发起节点变为待办节点
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void HandleStepsWithCascade(WorkflowStep step, List<WorkflowStep> steps, List<WorkflowTrace> traces, ref List<WorkflowStep> updateSteps, ref List<WorkflowTrace> updateTraces)
|
|
|
|
+ {
|
|
|
|
+ if (step == null) return;
|
|
|
|
+ var nextSteps = steps.Where(d => d.PrevStepId == step.Id && d.Status != EWorkflowStepStatus.Handled).ToList();
|
|
|
|
+ if (nextSteps.Any())
|
|
|
|
+ {
|
|
|
|
+ foreach (var nextStep in nextSteps)
|
|
|
|
+ {
|
|
|
|
+ HandleStepsWithCascade(nextStep, steps, traces, ref updateSteps, ref updateTraces);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ EndStep(step, ref updateSteps, ref updateTraces);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void EndStep(WorkflowStep step, ref List<WorkflowStep> updateSteps, ref List<WorkflowTrace> updateTraces)
|
|
|
|
+ {
|
|
|
|
+ //todo 1. traces 2. status 3. csStatus
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -1690,14 +1724,16 @@ namespace Hotline.FlowEngine.Workflows
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="countersign"></param>
|
|
/// <param name="countersign"></param>
|
|
/// <param name="updateCountersigns"></param>
|
|
/// <param name="updateCountersigns"></param>
|
|
- private void EndCountersignWithCascade(WorkflowCountersign countersign, ref List<WorkflowCountersign> updateCountersigns)
|
|
|
|
|
|
+ private void EndCountersignWithCascade(WorkflowCountersign countersign, List<WorkflowCountersign> countersigns, ref List<WorkflowCountersign> updateCountersigns)
|
|
{
|
|
{
|
|
if (countersign is null) return;
|
|
if (countersign is null) return;
|
|
- if (countersign.Children is not null && countersign.Children.Any())
|
|
|
|
|
|
+
|
|
|
|
+ var childCountersigns = countersigns.Where(d => d.ParentId == countersign.Id).ToList();
|
|
|
|
+ if (childCountersigns.Any())
|
|
{
|
|
{
|
|
- foreach (var childCountersign in countersign.Children)
|
|
|
|
|
|
+ foreach (var childCountersign in childCountersigns)
|
|
{
|
|
{
|
|
- EndCountersignWithCascade(childCountersign, ref updateCountersigns);
|
|
|
|
|
|
+ EndCountersignWithCascade(childCountersign, countersigns, ref updateCountersigns);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
else
|
|
@@ -1722,6 +1758,8 @@ namespace Hotline.FlowEngine.Workflows
|
|
_sessionContext.OrgAreaCode, _sessionContext.OrgAreaName);
|
|
_sessionContext.OrgAreaCode, _sessionContext.OrgAreaName);
|
|
await _workflowCountersignRepository.UpdateAsync(currentCountersign, cancellationToken);
|
|
await _workflowCountersignRepository.UpdateAsync(currentCountersign, cancellationToken);
|
|
*/
|
|
*/
|
|
|
|
+
|
|
|
|
+ updateCountersigns.Add();
|
|
throw new NotImplementedException();
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
|
|
|