| 
						
						
							
								
							
						
						
					 | 
					@ -139,7 +139,7 @@ public class AccessServiceImpl implements AccessService { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        // 生成开关范围的sql过滤器
 | 
					 | 
					 | 
					        // 生成开关范围的sql过滤器
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        if (!CollectionUtil.isEmpty(switchScopes)) { | 
					 | 
					 | 
					        if (!CollectionUtil.isEmpty(switchScopes)) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					            genSwitchScopeSqlFilter(switchScopes, sb, form.getTableAlias(), userDetails.getUserId(), form.getGridId(), form.getDepartmentId()); | 
					 | 
					 | 
					            genSwitchScopeSqlFilter(switchScopes, sb, form.getTableAlias(), userDetails.getUserId(), form.getGridIds(), form.getDepartmentIds()); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					        } | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        return sb.toString(); | 
					 | 
					 | 
					        return sb.toString(); | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -153,29 +153,29 @@ public class AccessServiceImpl implements AccessService { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                                         StringBuilder sb, | 
					 | 
					 | 
					                                         StringBuilder sb, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                                         String tableAlias, | 
					 | 
					 | 
					                                         String tableAlias, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                                         String userId, | 
					 | 
					 | 
					                                         String userId, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					                                         String gridId, | 
					 | 
					 | 
					                                         Set<String> gridIds, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                                         String departmentId) { | 
					 | 
					 | 
					                                         Set<String> departmentIds) { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        if (switchScopes.contains(OperationScopeConstant.SCOPE_I_CREATED)) { | 
					 | 
					 | 
					        if (switchScopes.contains(OperationScopeConstant.SCOPE_I_CREATED)) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            genICreatedSql(sb, userId, tableAlias); | 
					 | 
					 | 
					            genICreatedSql(sb, userId, tableAlias); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        } | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        if (switchScopes.contains(OperationScopeConstant.SCOPE_IN_GRID)) { | 
					 | 
					 | 
					        if (switchScopes.contains(OperationScopeConstant.SCOPE_IN_GRID)) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					            if (StringUtils.isBlank(gridId)) { | 
					 | 
					 | 
					            if (CollectionUtils.isEmpty(gridIds)) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                String error = String.format("DataFilter:拼接SQL语句出错:需要in grid权限,但是代码中没有获取到,GridId:%s", gridId); | 
					 | 
					 | 
					                String error = String.format("DataFilter:拼接SQL语句出错:需要in grid权限,但是代码中没有获取到gridIds"); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					                logger.error(error); | 
					 | 
					 | 
					                logger.error(error); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                throw new RenException(error); | 
					 | 
					 | 
					                throw new RenException(error); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            } | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					            genInGrid(sb, gridId, tableAlias); | 
					 | 
					 | 
					            genInGrid(sb, gridIds, tableAlias); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					        } | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        if (switchScopes.contains(OperationScopeConstant.SCOPE_IN_DEPARTMENT)) { | 
					 | 
					 | 
					        if (switchScopes.contains(OperationScopeConstant.SCOPE_IN_DEPARTMENT)) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					            if (StringUtils.isBlank(departmentId)) { | 
					 | 
					 | 
					            if (CollectionUtils.isEmpty(departmentIds)) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                String error = String.format("DataFilter:拼接SQL语句出错:需要in department权限,但是代码中没有获取到, departmentId:%s", departmentId); | 
					 | 
					 | 
					                String error = String.format("DataFilter:拼接SQL语句出错:需要in department权限,但是代码中没有获取到, departmentIds"); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					                logger.error(error); | 
					 | 
					 | 
					                logger.error(error); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                throw new RenException(error); | 
					 | 
					 | 
					                throw new RenException(error); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            } | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					            genDepartmentFilterSql(sb, departmentId, tableAlias); | 
					 | 
					 | 
					            genDepartmentFilterSql(sb, departmentIds, tableAlias); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					        } | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    } | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -199,18 +199,25 @@ public class AccessServiceImpl implements AccessService { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					     * @param sb | 
					 | 
					 | 
					     * @param sb | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					     * @param tableAlias | 
					 | 
					 | 
					     * @param tableAlias | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					     */ | 
					 | 
					 | 
					     */ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					    private void genInGrid(StringBuilder sb, String gridId, String tableAlias) { | 
					 | 
					 | 
					    private void genInGrid(StringBuilder sb, Set<String> gridIds, String tableAlias) { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					        if (hasConditions.get()) { | 
					 | 
					 | 
					        if (hasConditions.get()) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            // 之前没有条件
 | 
					 | 
					 | 
					            // 之前没有条件
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            sb.append(" OR "); | 
					 | 
					 | 
					            sb.append(" OR "); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        } | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        // OR     GRID_ID = 'XXX' OR GRID_ID = 'QQQ'
 | 
					 | 
					 | 
					        // OR     GRID_ID = 'XXX' OR GRID_ID = 'QQQ' OR
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        if (StringUtils.isBlank(tableAlias)) { | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            sb.append(" GRID_ID = '").append(gridId).append("' "); | 
					 | 
					 | 
					        for (String gridId : gridIds) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        } else { | 
					 | 
					 | 
					            if (StringUtils.isBlank(tableAlias)) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            sb.append(" ").append(tableAlias).append(".GRID_ID ='").append(gridId).append("' "); | 
					 | 
					 | 
					                sb.append(" GRID_ID = '").append(gridId).append("' OR "); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            } else { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                sb.append(" ").append(tableAlias).append(".GRID_ID ='").append(gridId).append("' OR "); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        } | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        int lastOrIndex = sb.lastIndexOf("OR"); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        sb.replace(lastOrIndex, lastOrIndex + "OR".length(), "" ); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        hasConditions.set(true); | 
					 | 
					 | 
					        hasConditions.set(true); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    } | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -219,17 +226,24 @@ public class AccessServiceImpl implements AccessService { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					     * | 
					 | 
					 | 
					     * | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					     * @param sb | 
					 | 
					 | 
					     * @param sb | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					     */ | 
					 | 
					 | 
					     */ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					    private void genDepartmentFilterSql(StringBuilder sb, String deptId, String tableAlias) { | 
					 | 
					 | 
					    private void genDepartmentFilterSql(StringBuilder sb, Set<String> deptIds, String tableAlias) { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					        //Result<List<DepartmentListResultDTO>> deptListResult = govOrgFeignClient.getDepartmentListByStaffId(staffId);
 | 
					 | 
					 | 
					        //Result<List<DepartmentListResultDTO>> deptListResult = govOrgFeignClient.getDepartmentListByStaffId(staffId);
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        if (hasConditions.get()) { | 
					 | 
					 | 
					        if (hasConditions.get()) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            // 之前没有条件
 | 
					 | 
					 | 
					            // 之前没有条件
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            sb.append(" OR "); | 
					 | 
					 | 
					            sb.append(" OR "); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        } | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        if (StringUtils.isBlank(tableAlias)) { | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            sb.append(" DEPARTMENT_ID = '").append(deptId).append("' "); | 
					 | 
					 | 
					        for (String deptId : deptIds) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        } else { | 
					 | 
					 | 
					            if (StringUtils.isBlank(tableAlias)) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            sb.append(" ").append(tableAlias).append(".DEPARTMENT_ID ='").append(deptId).append("' "); | 
					 | 
					 | 
					                sb.append(" DEPARTMENT_ID = '").append(deptId).append("' OR "); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            } else { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                sb.append(" ").append(tableAlias).append(".DEPARTMENT_ID ='").append(deptId).append("' OR "); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        } | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        int lastOrIndex = sb.lastIndexOf("OR"); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        sb.replace(lastOrIndex, lastOrIndex + "OR".length(), "" ); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        hasConditions.set(true); | 
					 | 
					 | 
					        hasConditions.set(true); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    } | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					
  |