| 
					
				 | 
			
			
				@@ -1,10 +1,15 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package com.yonge.cooleshow.biz.dal.service.impl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.concurrent.TimeUnit; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.yonge.cooleshow.biz.dal.entity.TeacherTotal; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.yonge.cooleshow.common.enums.CacheNameEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.toolset.base.page.PageInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.yonge.toolset.base.util.StringUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.toolset.mybatis.service.impl.BaseServiceImpl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.redisson.api.RedissonClient; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -22,6 +27,8 @@ public class SubjectServiceImpl extends BaseServiceImpl<Long, Subject> implement 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private SubjectDao subjectDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private RedissonClient redissonClient; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public BaseDAO<Long, Subject> getDAO() { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -81,16 +88,36 @@ public class SubjectServiceImpl extends BaseServiceImpl<Long, Subject> implement 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public List<Subject> subjectSelect() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        List<Subject> allList = subjectDao.findAll(new HashMap<>()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public List<Subject> subjectSelect(String type) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Object cacheRes = redissonClient.getBucket(CacheNameEnum.SUBJECT_ITEM.getRedisKey(type)).get(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (null != cacheRes) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<Subject> resList = (List<Subject>) cacheRes; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (!CollectionUtils.isEmpty(resList)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return resList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<Subject> parents; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<Subject> subjects; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(StringUtil.isEmpty(type)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<Subject> allList = subjectDao.findAll(new HashMap<>()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        List<Subject> parents = allList.stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                .filter(o -> (null == o.getParentSubjectId() || o.getParentSubjectId().equals(0L))) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                .collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            parents = allList.stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .filter(o -> (null == o.getParentSubjectId() || o.getParentSubjectId().equals(0L))) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            subjects = allList.stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .filter(o -> !(null == o.getParentSubjectId() || o.getParentSubjectId().equals(0L))) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            subjects = subjectDao.subjectSelect(type); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<Long> parentIds = subjects.stream().map(Subject::getParentSubjectId).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            parents = findBySubjectByIdList(parentIds); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        List<Subject> subjects = allList.stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                .filter(o -> !(null == o.getParentSubjectId() || o.getParentSubjectId().equals(0L))) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                .collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         for (Subject parent : parents) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (null == parent.getId()) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -110,6 +137,9 @@ public class SubjectServiceImpl extends BaseServiceImpl<Long, Subject> implement 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        redissonClient.getBucket(CacheNameEnum.SUBJECT_ITEM.getRedisKey(type)).set(parents, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                CacheNameEnum.STUDENT_SUBJECT_ITEM.getDuration().toHours(),TimeUnit.HOURS); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return parents; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 |