Ver código fonte

动态策略 经办人 领导

田爽 6 meses atrás
pai
commit
86eeea0250

+ 65 - 63
src/Hotline.Application/FlowEngine/WorkflowApplication.cs

@@ -1305,68 +1305,66 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
                     .ToListAsync(cancellationToken);
                 break;
             case EDynamicPolicy.OrgUpLeadCenterTop:
-                orgLevel = _sessionContextProvider.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;
-                    upperOrgId = _sessionContextProvider.SessionContext.RequiredOrgId.GetHigherOrgId(_sessionContextProvider.SessionContext.OrgLevel);
-                    isLead = _sessionContextProvider.SessionContext.Roles.Any(x => x == leadRoleCode);
-                    if (!isLead)
-                    {
-                        isSkip = await _userRepository.Queryable()
-                            .AnyAsync(
-                                x => x.OrgId == _sessionContextProvider.SessionContext.RequiredOrgId && x.Roles.Any(r => r.Name == leadRoleCode),
-                                cancellationToken);
-                        if (isSkip)
-                        {
-                            roleId = leadRoleCode;
-                            roleName = leadRoleName;
-                        }
-                    }
-
-                    if (isLead || !isSkip)
-                    {
-                        //上级部门Id
-                        upperOrgId = _sessionContextProvider.SessionContext.RequiredOrgId.GetHigherOrgId(orgLevel);
-                        roleId = handleRoleCode;
-                        roleName = handleRoleName;
-                    }
-
-                    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,
-                            RoleId = roleId,
-                            RoleName = roleName
-                        })
-                        .ToListAsync(cancellationToken);
-                }
-
-                break;
-            case EDynamicPolicy.OrgUpLead:
+				orgLevel = _sessionContextProvider.SessionContext.OrgLevel - 1;
+				if (orgLevel < 0) orgLevel = 0;
+				isLead = _sessionContextProvider.SessionContext.Roles.Any(x => x == leadRoleCode);
+				isSkip = await _userRepository.Queryable().AnyAsync(x => x.OrgId == _sessionContextProvider.SessionContext.RequiredOrgId && x.Roles.Any(r => r.Name == leadRoleCode), cancellationToken);
+				if (orgLevel == 0 && (isLead || !isSkip))
+				{
+					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;
+					upperOrgId = _sessionContextProvider.SessionContext.RequiredOrgId.GetHigherOrgId(_sessionContextProvider.SessionContext.OrgLevel);
+					if (!isLead)
+					{
+						if (isSkip)
+						{
+							roleId = leadRoleCode;
+							roleName = leadRoleName;
+						}
+					}
+					if (isLead || !isSkip)
+					{
+						//上级部门Id
+						upperOrgId = _sessionContextProvider.SessionContext.RequiredOrgId.GetHigherOrgId(orgLevel);
+						roleId = handleRoleCode;
+						roleName = handleRoleName;
+					}
+					else
+					{
+						orgLevel += 1;
+					}
+					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,
+							RoleId = roleId,
+							RoleName = roleName
+						})
+						.ToListAsync(cancellationToken);
+				}
+
+				break;
+			case EDynamicPolicy.OrgUpLead:
                 businessType = _sessionContextProvider.SessionContext.OrgIsCenter
                     ? EBusinessType.Send
                     : _sessionContextProvider.SessionContext.RequiredOrgId.CalcOrgLevel() == 1
@@ -1395,8 +1393,12 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
                     roleId = handleRoleCode;
                     roleName = handleRoleName;
                 }
+                else
+                {
+	                orgLevel += 1;
+                }
 
-                items = await _organizeRepository.Queryable()
+				items = await _organizeRepository.Queryable()
                     .Where(d => d.Id == upperOrgId)
                     .Select(d => new FlowStepHandler
                     {