| 
					
				 | 
			
			
				@@ -1,25 +1,23 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package com.ym.mec.biz.service.impl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.ArrayList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.transaction.annotation.Transactional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.auth.api.dto.MusicScoreQueryInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.auth.api.entity.SysMenu; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.dao.SysMusicScoreCategoriesDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.dao.SysMusicScoreDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.entity.SysMusicScoreCategories; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.dal.page.SysExamSongQueryInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.service.SysMusicScoreCategoriesService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.common.dal.BaseDAO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.common.exception.BizException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.common.page.PageInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.common.service.impl.BaseServiceImpl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.springframework.transaction.annotation.Transactional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.ArrayList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Service 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 public class SysMusicScoreCategoriesServiceImpl extends BaseServiceImpl<Integer, SysMusicScoreCategories> implements SysMusicScoreCategoriesService { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -47,6 +45,38 @@ public class SysMusicScoreCategoriesServiceImpl extends BaseServiceImpl<Integer, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	@Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	public List<SysMusicScoreCategories> queryCategoriesTreeList(String categoryIds) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		categoryIds = categoryIds.endsWith(",") ? categoryIds.substring(0, categoryIds.length() - 1) : categoryIds; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		List<SysMusicScoreCategories> rows = new ArrayList<SysMusicScoreCategories>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		List<SysMusicScoreCategories> categoryList = sysMusicScoreCategoriesDao.queryByIds(categoryIds); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		SysMusicScoreCategories parentCategory = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		SysMusicScoreCategories subCategory = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		for(SysMusicScoreCategories smsc : categoryList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if(smsc == null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			parentCategory = getParentTree(smsc); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			subCategory = getChildTree(smsc); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if(parentCategory == null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				insertSubToParent(rows, subCategory); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			}else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				parentCategory.getSysMusicScoreCategoriesList().add(subCategory); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				insertSubToParent(rows, parentCategory); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return rows; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	@Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	@Transactional(rollbackFor = Exception.class) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	public void save(SysMusicScoreCategories musicScoreCategories) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		String organId = musicScoreCategories.getOrganId(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -210,4 +240,42 @@ public class SysMusicScoreCategoriesServiceImpl extends BaseServiceImpl<Integer, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return categories; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private SysMusicScoreCategories getChildTree(SysMusicScoreCategories sysMusicScoreCategories){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    	List<SysMusicScoreCategories> subCategoryList = sysMusicScoreCategoriesDao.findByParentId(sysMusicScoreCategories.getId(), null, null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    	if(subCategoryList != null && subCategoryList.size() > 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    		sysMusicScoreCategories.setSysMusicScoreCategoriesList(subCategoryList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    		for(SysMusicScoreCategories sc : subCategoryList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    			getChildTree(sc); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    	return sysMusicScoreCategories; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	private SysMusicScoreCategories getParentTree(SysMusicScoreCategories sysMusicScoreCategories) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if (sysMusicScoreCategories != null && sysMusicScoreCategories.getParentId() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			SysMusicScoreCategories parentCategories = sysMusicScoreCategoriesDao.queryByParentId(sysMusicScoreCategories.getParentId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if (parentCategories != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				if(parentCategories.getParentId() > 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					return getParentTree(parentCategories); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				return parentCategories; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	private void insertSubToParent(List<SysMusicScoreCategories> parentTree, SysMusicScoreCategories targetCategory) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		for (SysMusicScoreCategories target : parentTree) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if (targetCategory.getId().intValue() == target.getId()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				insertSubToParent(target.getSysMusicScoreCategoriesList(),targetCategory.getSysMusicScoreCategoriesList().get(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		parentTree.add(targetCategory); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |