| 
					
				 | 
			
			
				@@ -1,26 +1,9 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package com.ym.mec.biz.service.impl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import static com.ym.mec.biz.dal.enums.SysUserRoleEnum.EDUCATION; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.HashMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.Objects; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.service.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.springframework.context.annotation.Lazy; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.springframework.transaction.annotation.Transactional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.auth.api.client.SysUserFeignService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.auth.api.entity.SysUser; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.dao.EmployeeDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.dao.OrganizationDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.dao.TeacherDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.dal.dao.TenantContractTemplateDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.dao.TenantInfoDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.entity.Employee; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.entity.Organization; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -30,10 +13,24 @@ import com.ym.mec.biz.dal.enums.FivePlusGradeEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.enums.GradeTypeEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.enums.SixPlusGradeEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.page.EducationBaseQueryInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.service.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.common.dal.BaseDAO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.common.exception.BizException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.common.service.impl.BaseServiceImpl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.common.tenant.TenantContextHolder; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.context.annotation.Lazy; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.transaction.annotation.Transactional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.HashMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.Objects; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import static com.ym.mec.biz.dal.enums.SysUserRoleEnum.EDUCATION; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Service 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 public class OrganizationServiceImpl extends BaseServiceImpl<Integer, Organization> implements OrganizationService { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -47,7 +44,7 @@ public class OrganizationServiceImpl extends BaseServiceImpl<Integer, Organizati 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	@Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	private EmployeeDao employeeDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	@Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	private SysUserFeignService sysUserFeignService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	private SysUserService sysUserService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	@Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	private SysEmployeePositionService employeePositionService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	@Autowired 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -66,10 +63,7 @@ public class OrganizationServiceImpl extends BaseServiceImpl<Integer, Organizati 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	@Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	public List<Organization> queryEmployeeOrgan(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		SysUser sysUser = sysUserFeignService.queryUserInfo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if(sysUser == null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			throw new BizException("获取用户信息失败"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		SysUser sysUser = sysUserService.getUser(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		String organIds = this.getEmployeeOrgan(sysUser.getId(), "", sysUser.getIsSuperAdmin()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return organizationDao.queryEmployeeOrgan(organIds); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -139,20 +133,13 @@ public class OrganizationServiceImpl extends BaseServiceImpl<Integer, Organizati 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	@Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	public String getEmployeeOrgan(Object organIds) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		SysUser sysUser = sysUserFeignService.queryUserInfo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if (sysUser == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			throw new BizException("用户信息获取失败"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		SysUser sysUser = sysUserService.getUser(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return this.getEmployeeOrgan(sysUser.getId(),organIds == null?"":organIds.toString(),sysUser.getIsSuperAdmin()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	@Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	public String getTeacherOrgan() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		SysUser sysUser = sysUserFeignService.queryUserInfo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if (sysUser == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			throw new BizException("用户信息获取失败"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		Teacher teacher = teacherDao.get(sysUser.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		Teacher teacher = teacherDao.get(sysUserService.getUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		String organIds = teacher.getTeacherOrganId() + ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if(StringUtils.isNotBlank(teacher.getFlowOrganRange())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			organIds = organIds + "," + teacher.getFlowOrganRange(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -177,10 +164,7 @@ public class OrganizationServiceImpl extends BaseServiceImpl<Integer, Organizati 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	@Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public <T extends EducationBaseQueryInfo> T onlyEducation(T queryInfo) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		SysUser sysUser = sysUserFeignService.queryUserInfo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if (sysUser == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			throw new BizException("用户信息获取失败"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		SysUser sysUser = sysUserService.getUser(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		queryInfo.setOrganIds(this.getEmployeeOrgan(sysUser.getId(),queryInfo.getOrganIds(),sysUser.getIsSuperAdmin())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		Boolean onlyForRole = employeePositionService.onlyForRole(EDUCATION, sysUser.getId(), sysUser.getIsSuperAdmin()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		//如果当前用户只有教务老师角色,那么只能看到他所管理的课程组的信息 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -223,11 +207,11 @@ public class OrganizationServiceImpl extends BaseServiceImpl<Integer, Organizati 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public Long add(Organization organization) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		long insert = organizationDao.insert(organization); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		TenantInfo tenantInfo = tenantInfoDao.selectById(organization.getTenantId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		SysUser sysUser = sysUserFeignService.queryUserInfo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if(!sysUser.getId().equals(tenantInfo.getUserId())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		Integer userId = sysUserService.getUserId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if(!userId.equals(tenantInfo.getUserId())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			updateOrganId(tenantInfo.getUserId(),organization.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		updateOrganId(sysUser.getId(),organization.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		updateOrganId(userId,organization.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return insert; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 |