|
@@ -1143,10 +1143,145 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
|
- /// 查询下一节点办理对象类型(user or org)及实际办理对象
|
|
|
|
- /// </summary>
|
|
|
|
- public async Task<FlowAssignInfo> GetNextStepFlowAssignInfoAsync(Workflow workflow, WorkflowStep currentStep,
|
|
|
|
|
|
+
|
|
|
|
+ private async Task<NextStepOption> GetDynamicStepAsync(
|
|
|
|
+ EDynamicPolicyCountersign policy, EStepType stepType,
|
|
|
|
+ EBusinessType currentBusinessType, CancellationToken cancellationToken)
|
|
|
|
+ {
|
|
|
|
+ int orgLevel;
|
|
|
|
+ List<FlowStepHandler> items;
|
|
|
|
+ string upperOrgId;
|
|
|
|
+ EBusinessType businessType;
|
|
|
|
+ EFlowDirection? flowDirection = null;
|
|
|
|
+ switch (policy)
|
|
|
|
+ {
|
|
|
|
+ case EDynamicPolicyCountersign.OrgUpCenterTop:
|
|
|
|
+ orgLevel = _sessionContext.OrgLevel - 1;
|
|
|
|
+ if (orgLevel < 0) orgLevel = 0;
|
|
|
|
+
|
|
|
|
+ if (orgLevel == 0)
|
|
|
|
+ {
|
|
|
|
+ businessType = EBusinessType.Send;
|
|
|
|
+ if (currentBusinessType == EBusinessType.Department)
|
|
|
|
+ flowDirection = EFlowDirection.OrgToCenter;
|
|
|
|
+
|
|
|
|
+ items = await _organizeRepository.Queryable()
|
|
|
|
+ .Where(d => d.IsCenter)
|
|
|
|
+ .Select(d => new FlowStepHandler
|
|
|
|
+ {
|
|
|
|
+ Key = d.Id,
|
|
|
|
+ Value = d.Name,
|
|
|
|
+ OrgId = d.Id,
|
|
|
|
+ OrgName = d.Name
|
|
|
|
+ })
|
|
|
|
+ .ToListAsync(cancellationToken);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ businessType = EBusinessType.Department;
|
|
|
|
+
|
|
|
|
+ //上级部门Id
|
|
|
|
+ upperOrgId = _sessionContext.RequiredOrgId.GetHigherOrgId(orgLevel);
|
|
|
|
+ items = await _organizeRepository.Queryable()
|
|
|
|
+ .Where(d => d.Id == upperOrgId)
|
|
|
|
+ .Select(d => new FlowStepHandler
|
|
|
|
+ {
|
|
|
|
+ Key = d.Id,
|
|
|
|
+ Value = d.Name,
|
|
|
|
+ OrgId = d.Id,
|
|
|
|
+ OrgName = d.Name
|
|
|
|
+ })
|
|
|
|
+ .ToListAsync(cancellationToken);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ break;
|
|
|
|
+ case EDynamicPolicyCountersign.OrgUp:
|
|
|
|
+ businessType = _sessionContext.OrgIsCenter
|
|
|
|
+ ? EBusinessType.Send
|
|
|
|
+ : _sessionContext.RequiredOrgId.CalcOrgLevel() == 1
|
|
|
|
+ ? EBusinessType.Send
|
|
|
|
+ : EBusinessType.Department;
|
|
|
|
+ orgLevel = _sessionContext.OrgLevel - 1;
|
|
|
|
+ if (orgLevel <= 0) orgLevel = 1;
|
|
|
|
+ //上级部门Id
|
|
|
|
+ upperOrgId = _sessionContext.RequiredOrgId.GetHigherOrgId(orgLevel);
|
|
|
|
+ items = await _organizeRepository.Queryable()
|
|
|
|
+ .Where(d => d.Id == upperOrgId)
|
|
|
|
+ .Select(d => new FlowStepHandler
|
|
|
|
+ {
|
|
|
|
+ Key = d.Id,
|
|
|
|
+ Value = d.Name,
|
|
|
|
+ OrgId = d.Id,
|
|
|
|
+ OrgName = d.Name
|
|
|
|
+ })
|
|
|
|
+ .ToListAsync(cancellationToken);
|
|
|
|
+ break;
|
|
|
|
+ case EDynamicPolicyCountersign.OrgDownCenterTop:
|
|
|
|
+ businessType = EBusinessType.Department;
|
|
|
|
+ if (_sessionContext.OrgIsCenter)
|
|
|
|
+ {
|
|
|
|
+ orgLevel = 1;
|
|
|
|
+ items = await _organizeRepository.Queryable()
|
|
|
|
+ .Where(d => !d.IsCenter && d.Level == orgLevel)
|
|
|
|
+ .Select(d => new FlowStepHandler
|
|
|
|
+ {
|
|
|
|
+ Key = d.Id,
|
|
|
|
+ Value = d.Name,
|
|
|
|
+ OrgId = d.Id,
|
|
|
|
+ OrgName = d.Name
|
|
|
|
+ })
|
|
|
|
+ .ToListAsync(cancellationToken);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ orgLevel = _sessionContext.OrgLevel + 1;
|
|
|
|
+ items = await _organizeRepository.Queryable()
|
|
|
|
+ .Where(d => !d.IsCenter && d.Level == orgLevel &&
|
|
|
|
+ d.Id.StartsWith(_sessionContext.RequiredOrgId))
|
|
|
|
+ .Select(d => new FlowStepHandler
|
|
|
|
+ {
|
|
|
|
+ Key = d.Id,
|
|
|
|
+ Value = d.Name,
|
|
|
|
+ OrgId = d.Id,
|
|
|
|
+ OrgName = d.Name
|
|
|
|
+ })
|
|
|
|
+ .ToListAsync(cancellationToken);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ break;
|
|
|
|
+ case EDynamicPolicyCountersign.OrgDown:
|
|
|
|
+ businessType = EBusinessType.Department;
|
|
|
|
+ orgLevel = _sessionContext.OrgLevel + 1;
|
|
|
|
+ items = await _organizeRepository.Queryable()
|
|
|
|
+ .Where(d => d.Level == orgLevel && d.Id.StartsWith(_sessionContext.RequiredOrgId))
|
|
|
|
+ .Select(d => new FlowStepHandler
|
|
|
|
+ {
|
|
|
|
+ Key = d.Id,
|
|
|
|
+ Value = d.Name,
|
|
|
|
+ OrgId = d.Id,
|
|
|
|
+ OrgName = d.Name
|
|
|
|
+ })
|
|
|
|
+ .ToListAsync(cancellationToken);
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ throw new ArgumentOutOfRangeException(nameof(policy), policy, null);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return new NextStepOption
|
|
|
|
+ {
|
|
|
|
+ Key = orgLevel.ToString(),
|
|
|
|
+ Value = orgLevel == 0 ? "市民热线服务中心" : $"{orgLevel.ToChinese()}级部门",
|
|
|
|
+ FlowDirection = flowDirection,
|
|
|
|
+ StepType = stepType,
|
|
|
|
+ BusinessType = businessType,
|
|
|
|
+ HandlerType = EHandlerType.OrgLevel, //目前所有动态策略均属于部门等级
|
|
|
|
+ Items = items
|
|
|
|
+ };
|
|
|
|
+ }
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 查询下一节点办理对象类型(user or org)及实际办理对象
|
|
|
|
+ /// </summary>
|
|
|
|
+ public async Task<FlowAssignInfo> GetNextStepFlowAssignInfoAsync(Workflow workflow, WorkflowStep currentStep,
|
|
BasicWorkflowDto dto, StepDefine nextStepDefine, bool isNextDynamic, CancellationToken cancellationToken)
|
|
BasicWorkflowDto dto, StepDefine nextStepDefine, bool isNextDynamic, CancellationToken cancellationToken)
|
|
{
|
|
{
|
|
if (nextStepDefine.StepType is EStepType.End) return new();
|
|
if (nextStepDefine.StepType is EStepType.End) return new();
|