|  | @ -1,7 +1,10 @@
 | 
	
		
			
				|  |  | package com.yihu.jw.hospital.service.consult;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.article.KnowledgeArticleDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.article.KnowledgeArticleDeptDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.survey.WlyySurveyDeptDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.dao.consult.KnowledgeArticleDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.dao.consult.KnowledgeArticleDeptDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.utils.EntityUtils;
 | 
	
		
			
				|  |  | import com.yihu.mysql.query.BaseJpaService;
 | 
	
		
			
				|  |  | import org.apache.commons.lang.StringUtils;
 | 
	
	
		
			
				|  | @ -9,6 +12,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import java.util.Date;
 | 
	
		
			
				|  |  | import java.util.List;
 | 
	
		
			
				|  |  | import java.util.Map;
 | 
	
		
			
				|  |  | import java.util.UUID;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | /**
 | 
	
	
		
			
				|  | @ -22,6 +27,9 @@ public class KnowledgeArticleService extends BaseJpaService<KnowledgeArticleDO,
 | 
	
		
			
				|  |  | 	@Autowired
 | 
	
		
			
				|  |  | 	private KnowledgeArticleDao knowledgeArticleDao;
 | 
	
		
			
				|  |  | 	
 | 
	
		
			
				|  |  | 	@Autowired
 | 
	
		
			
				|  |  | 	private KnowledgeArticleDeptDao knowledgeArticleDeptDao;
 | 
	
		
			
				|  |  | 	
 | 
	
		
			
				|  |  | 	/**
 | 
	
		
			
				|  |  | 	 * 删除,支持批量
 | 
	
		
			
				|  |  | 	 * @param id
 | 
	
	
		
			
				|  | @ -77,4 +85,67 @@ public class KnowledgeArticleService extends BaseJpaService<KnowledgeArticleDO,
 | 
	
		
			
				|  |  | 			return  knowledgeArticleDO;
 | 
	
		
			
				|  |  | 		}
 | 
	
		
			
				|  |  | 	}
 | 
	
		
			
				|  |  | 	
 | 
	
		
			
				|  |  | 	/**
 | 
	
		
			
				|  |  | 	 * 保存文章科室关系
 | 
	
		
			
				|  |  | 	 * @param articleId
 | 
	
		
			
				|  |  | 	 * @param sdJsons
 | 
	
		
			
				|  |  | 	 * @return
 | 
	
		
			
				|  |  | 	 * @throws Exception
 | 
	
		
			
				|  |  | 	 */
 | 
	
		
			
				|  |  | 	public Boolean saveArticleDept(String articleId,String sdJsons)throws Exception{
 | 
	
		
			
				|  |  | 		
 | 
	
		
			
				|  |  | 		//删除之前关系
 | 
	
		
			
				|  |  | 		List<KnowledgeArticleDeptDO> list = knowledgeArticleDeptDao.findByArticleId(articleId);
 | 
	
		
			
				|  |  | 		if(list!=null&&list.size()>0){
 | 
	
		
			
				|  |  | 			knowledgeArticleDeptDao.delete(list);
 | 
	
		
			
				|  |  | 		}
 | 
	
		
			
				|  |  | 		
 | 
	
		
			
				|  |  | 		if(org.apache.commons.lang3.StringUtils.isNotBlank(sdJsons)){
 | 
	
		
			
				|  |  | 			List<KnowledgeArticleDeptDO> _list = EntityUtils.jsonToList(sdJsons,KnowledgeArticleDeptDO.class);
 | 
	
		
			
				|  |  | 			if(_list!=null&&_list.size()>0){
 | 
	
		
			
				|  |  | 				knowledgeArticleDeptDao.save(list);
 | 
	
		
			
				|  |  | 			}
 | 
	
		
			
				|  |  | 		}
 | 
	
		
			
				|  |  | 		return true;
 | 
	
		
			
				|  |  | 	}
 | 
	
		
			
				|  |  | 	
 | 
	
		
			
				|  |  | 	/**
 | 
	
		
			
				|  |  | 	 * 查询文章下科室
 | 
	
		
			
				|  |  | 	 * @param articleId
 | 
	
		
			
				|  |  | 	 * @return
 | 
	
		
			
				|  |  | 	 */
 | 
	
		
			
				|  |  | 	public List<Map<String,Object>> findDeptByArticle(String articleId){
 | 
	
		
			
				|  |  | 		String sql ="SELECT " +
 | 
	
		
			
				|  |  | 				" d.article_id AS articleId," +
 | 
	
		
			
				|  |  | 				" d.dept, " +
 | 
	
		
			
				|  |  | 				" d.dept_name AS deptName " +
 | 
	
		
			
				|  |  | 				" FROM " +
 | 
	
		
			
				|  |  | 				" wlyy_knowledge_article t " +
 | 
	
		
			
				|  |  | 				" JOIN wlyy_knowledge_article_dept d ON t.id = d.article_id " +
 | 
	
		
			
				|  |  | 				" WHERE " +
 | 
	
		
			
				|  |  | 				" t.id = '"+articleId+"'";
 | 
	
		
			
				|  |  | 		List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  | 		return list;
 | 
	
		
			
				|  |  | 	}
 | 
	
		
			
				|  |  | 	
 | 
	
		
			
				|  |  | 	/**
 | 
	
		
			
				|  |  | 	 * 查询部门下的文章
 | 
	
		
			
				|  |  | 	 * @param dept
 | 
	
		
			
				|  |  | 	 * @return
 | 
	
		
			
				|  |  | 	 */
 | 
	
		
			
				|  |  | 	public List<Map<String,Object>> findArticleByDept(String dept){
 | 
	
		
			
				|  |  | 		String sql = "SELECT " +
 | 
	
		
			
				|  |  | 				" t.id, " +
 | 
	
		
			
				|  |  | 				" t.title, " +
 | 
	
		
			
				|  |  | 				" t.create_time AS create_time ," +
 | 
	
		
			
				|  |  | 				" t.image AS image " +
 | 
	
		
			
				|  |  | 				" FROM " +
 | 
	
		
			
				|  |  | 				" wlyy_knowledge_article t " +
 | 
	
		
			
				|  |  | 				" JOIN wlyy_knowledge_article_dept d ON t.id = d.article_id " +
 | 
	
		
			
				|  |  | 				" WHERE " +
 | 
	
		
			
				|  |  | 				" d.dept = '"+dept+"'";
 | 
	
		
			
				|  |  | 		List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  | 		return list;
 | 
	
		
			
				|  |  | 	}
 | 
	
		
			
				|  |  | }
 |