|  | @ -2,9 +2,9 @@ package com.yihu.jw.base.service.article;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSON;
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  | import com.yihu.jw.base.dao.article.KnowledgeArticleDictDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.base.dao.article.BaseNewsArticleDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.base.dao.article.KnowledgeArticleDeptDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.base.dao.article.KnowledgeArticleMenuDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.base.dao.article.KnowledgeArticleDictDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.base.dao.article.KnowledgeArticleUserDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.base.dao.menu.BaseMenuDictDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.base.dao.user.UserDao;
 | 
	
	
		
			
				|  | @ -15,19 +15,19 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.menu.BaseMenuDictDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.patient.BasePatientBusinessDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.user.UserDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.article.KnowledgeArticleDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.article.BaseNewsArticleDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.article.KnowledgeArticleDeptDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.article.KnowledgeArticleDictDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.article.KnowledgeArticleUserDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.survey.WlyySurveyTemplateDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.survey.WlyySurveyUserDO;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.survey.dao.SurveyTemplateDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.survey.dao.SurveyUserDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.patient.dao.BasePatientBusinessDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.web.MixEnvelop;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.web.PageEnvelop;
 | 
	
		
			
				|  |  | import com.yihu.jw.utils.EntityUtils;
 | 
	
		
			
				|  |  | import com.yihu.jw.utils.hibernate.HibenateUtils;
 | 
	
		
			
				|  |  | import com.yihu.mysql.query.BaseJpaService;
 | 
	
	
		
			
				|  | @ -73,6 +73,89 @@ public class KnowledgeArticleService extends BaseJpaService<KnowledgeArticleDict
 | 
	
		
			
				|  |  |     private HibenateUtils hibenateUtils;
 | 
	
		
			
				|  |  | 	@Autowired
 | 
	
		
			
				|  |  | 	private UserDao userDao;
 | 
	
		
			
				|  |  | 	@Autowired
 | 
	
		
			
				|  |  | 	private BaseNewsArticleDao baseNewsArticleDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 	/**
 | 
	
		
			
				|  |  | 	 * 新闻动态分页
 | 
	
		
			
				|  |  | 	 * @return
 | 
	
		
			
				|  |  | 	 */
 | 
	
		
			
				|  |  | 	public PageEnvelop<List<Map<String,Object>>> findPageByArticleName(String articleName, Integer page, Integer size){
 | 
	
		
			
				|  |  | 		String sql = "SELECT a.id,a.sort,cast(a.status as char) status,a.article_id articleId,LEFT(a.create_time,19) createTime,IF(a.status=1,'生效','失效') statusName" +
 | 
	
		
			
				|  |  | 				",d.title articleName,d.image from base_news_article a,wlyy_knowledge_article_dict d " +
 | 
	
		
			
				|  |  | 				"WHERE a.article_id = d.id " ;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 		String sqlCount = "SELECT count(a.id) from base_news_article a,wlyy_knowledge_article_dict d  " +
 | 
	
		
			
				|  |  | 				" WHERE a.article_id = d.id ";
 | 
	
		
			
				|  |  | 		String filter = " ";
 | 
	
		
			
				|  |  | 		String limit = " limit "+(page-1)*size+","+size;
 | 
	
		
			
				|  |  | 		if (StringUtils.isNotBlank(articleName)){
 | 
	
		
			
				|  |  | 			filter +="and d.title like '%"+articleName+"%'";
 | 
	
		
			
				|  |  | 		}
 | 
	
		
			
				|  |  | 		List<Map<String, Object>> list = jdbcTemplate.queryForList(sql + filter+limit);
 | 
	
		
			
				|  |  | 		for (Map<String,Object> map:list){
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 		}
 | 
	
		
			
				|  |  | 		Long count = jdbcTemplate.queryForObject(sqlCount+filter,Long.class);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 		return PageEnvelop.getSuccessListWithPage("success",list,page,size,count);
 | 
	
		
			
				|  |  | 	}
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 	/**
 | 
	
		
			
				|  |  | 	 * 删除新闻动态
 | 
	
		
			
				|  |  | 	 */
 | 
	
		
			
				|  |  | 	public void delNewsArticle(String id){
 | 
	
		
			
				|  |  | 		if(baseNewsArticleDao.exists(id)){
 | 
	
		
			
				|  |  | 			baseNewsArticleDao.delete(id);
 | 
	
		
			
				|  |  | 		}
 | 
	
		
			
				|  |  | 	}
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 	/**
 | 
	
		
			
				|  |  | 	 * 按id查找
 | 
	
		
			
				|  |  | 	 * @param id
 | 
	
		
			
				|  |  | 	 * @return
 | 
	
		
			
				|  |  | 	 */
 | 
	
		
			
				|  |  | 	public BaseNewsArticleDO findNewsArticle(String id){
 | 
	
		
			
				|  |  | 		BaseNewsArticleDO baseNewsArticleDO = baseNewsArticleDao.findOne(id);
 | 
	
		
			
				|  |  | 		if(baseNewsArticleDO!=null){
 | 
	
		
			
				|  |  | 			if(StringUtils.isNotBlank(baseNewsArticleDO.getArticleId())){
 | 
	
		
			
				|  |  | 				KnowledgeArticleDictDO dictDO = knowledgeArticleDictDao.findByIdAndDel(baseNewsArticleDO.getArticleId());
 | 
	
		
			
				|  |  | 				if(dictDO!=null){
 | 
	
		
			
				|  |  | 					baseNewsArticleDO.setArticleName(dictDO.getTitle());
 | 
	
		
			
				|  |  | 					baseNewsArticleDO.setImage(dictDO.getImage());
 | 
	
		
			
				|  |  | 				}
 | 
	
		
			
				|  |  | 			}
 | 
	
		
			
				|  |  | 			baseNewsArticleDO.setStatusName("1".equals(baseNewsArticleDO.getStatus())?"生效":"失效");
 | 
	
		
			
				|  |  | 		}
 | 
	
		
			
				|  |  | 		return baseNewsArticleDO;
 | 
	
		
			
				|  |  | 	}
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 	/**
 | 
	
		
			
				|  |  | 	 * 新增或修改新闻动态
 | 
	
		
			
				|  |  | 	 * @return
 | 
	
		
			
				|  |  | 	 */
 | 
	
		
			
				|  |  | 	public BaseNewsArticleDO addNewArticle(String id,String articleId,Integer sort,String status){
 | 
	
		
			
				|  |  | 		if(StringUtils.isNotBlank(id)){
 | 
	
		
			
				|  |  | 			BaseNewsArticleDO baseNewsArticleDO = baseNewsArticleDao.findOne(id);
 | 
	
		
			
				|  |  | 			baseNewsArticleDO.setArticleId(articleId);
 | 
	
		
			
				|  |  | 			baseNewsArticleDO.setSort(sort);
 | 
	
		
			
				|  |  | 			baseNewsArticleDO.setStatus(status);
 | 
	
		
			
				|  |  | 			baseNewsArticleDao.save(baseNewsArticleDO);
 | 
	
		
			
				|  |  | 			return baseNewsArticleDO;
 | 
	
		
			
				|  |  | 		}else {
 | 
	
		
			
				|  |  | 			BaseNewsArticleDO baseNewsArticleDO = new BaseNewsArticleDO();
 | 
	
		
			
				|  |  | 			baseNewsArticleDO.setArticleId(articleId);
 | 
	
		
			
				|  |  | 			baseNewsArticleDO.setSort(sort);
 | 
	
		
			
				|  |  | 			baseNewsArticleDO.setStatus(status);
 | 
	
		
			
				|  |  | 			baseNewsArticleDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  | 			baseNewsArticleDao.save(baseNewsArticleDO);
 | 
	
		
			
				|  |  | 			return baseNewsArticleDO;
 | 
	
		
			
				|  |  | 		}
 | 
	
		
			
				|  |  | 	}
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 	//查询文章列表
 | 
	
		
			
				|  |  | 	public List<Map<String,Object>> findArticleList(String first,String second ,String key,Integer page ,Integer pageSize){
 | 
	
		
			
				|  |  | 		String sql ="select b.id as \"id\", " +
 |