| 
					
				 | 
			
			
				@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.alibaba.fastjson.JSONPObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.edu.entity.RoleWithAuthorityCheck; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.es.entity.FollowupContentESDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.es.entity.HealthEduArticleES; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.es.entity.HealthEduArticlePatient; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.es.entity.RoleVo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.config.es.ElasticFactory; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -14,6 +15,7 @@ import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.entity.education.HealthEduArticle; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.entity.patient.Patient; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.repository.doctor.DoctorDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.repository.patient.PatientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.BaseService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.app.account.DoctorInfoService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -27,8 +29,7 @@ import com.yihu.wlyy.web.third.gateway.service.GcLabelService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.web.third.gateway.vo.DictModel; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.web.third.gateway.vo.HealthEduArticlePatientModel; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import io.searchbox.client.JestClient; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import io.searchbox.core.Search; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import io.searchbox.core.SearchResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import io.searchbox.core.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.elasticsearch.index.query.BoolQueryBuilder; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.elasticsearch.index.query.QueryBuilders; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.elasticsearch.search.builder.SearchSourceBuilder; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -57,6 +58,8 @@ public class JMJkEduArticleService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private String esType; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Value("${es.index.HealthEduArticlePatient}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private String esIndex; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private AdminTeamService adminTeamService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private ElasticFactory elasticFactory; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -69,6 +72,8 @@ public class JMJkEduArticleService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private DoctorDao doctorDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PatientDao patientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private ElastricSearchSave elastricSearchSave; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private GcLabelService labelService; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -104,17 +109,17 @@ public class JMJkEduArticleService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            sendCode = resultMap.size()>0?resultMap.get(0).get("roleCode").toString():sendCode; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        StringBuffer sql2 = new StringBuffer("select *  from   " + esType + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        StringBuffer sql2 = new StringBuffer("select articleId,articleTitle,firstLevelCategoryName,secondLevelCategoryName,articleSource,createTime  from   " + esType + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " where  doctorCode='" + sendCode + "'"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(sendType==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql2.append(" and sendType='"+sendType+"' "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(!StringUtils.isEmpty(firstLevelCategoryId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql2.append("and level1Type="+firstLevelCategoryId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql2.append("and firstLevelCategoryId="+firstLevelCategoryId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(!StringUtils.isEmpty(secondLevelCategoryId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql2.append("and level2Type="+secondLevelCategoryId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql2.append("and secondLevelCategoryId="+secondLevelCategoryId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(myArticle==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql2.append(" and operatorId="+sendCode); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -132,8 +137,8 @@ public class JMJkEduArticleService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sendTimeEnd = elasticsearchUtil.changeTime(sendTimeEnd); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql2.append(" and createTime <='"+sendTimeEnd+"'"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql2.append("  order by createTime limit " + page + "," + pagesize); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<com.yihu.es.entity.HealthEduArticlePatient> esList = elasticsearchUtil.excute(sql2.toString(), com.yihu.es.entity.HealthEduArticlePatient.class, esIndex, esType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql2.append(" group by articleId,articleTitle,firstLevelCategoryName,secondLevelCategoryName,articleSource,createTime  order by createTime limit " + page + "," + pagesize); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<HealthEduArticleES> esList = elasticsearchUtil.excute(sql2.toString(), HealthEduArticleES.class, esIndex, esType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String, HealthEduArticlePatientModel> result = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        HealthEduArticlePatientModel heapm = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        com.alibaba.fastjson.JSONObject article = null; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -141,7 +146,7 @@ public class JMJkEduArticleService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<HealthEduArticlePatientModel> resultList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (HealthEduArticlePatient one : esList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (HealthEduArticleES one : esList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            article = thirdJkEduArticleService.getArticalById(one.getArticleId(),""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (result.get(one.getArticleId()) != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                heapm = result.get(one.getArticleId()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -156,28 +161,43 @@ public class JMJkEduArticleService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            heapm.setAttachedTitle(article.getString("articleTitle")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            heapm.setAttachedContent(article.getString("articleContent")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            heapm.setArticleType(article.getString("articleType")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            heapm.setLevel1Type(article.getString("firstLevelCategoryId")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            heapm.setLevel2Type(article.getString("secondLevelCategoryId")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            heapm.setLevel1Type(one.getFirstLevelCategoryId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            heapm.setLevel1TypeName(one.getFirstLevelCategoryName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            heapm.setLevel2Type(one.getSecondLevelCategoryId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            heapm.setLevel2TypeName(one.getSecondLevelCategoryName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            heapm.setLevel(article.getString("articlelevel")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            heapm.setAllCount(heapm.getAllCount() + one.getPatients().size()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(article.getString("browseNumber") != null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            heapm.setAllCount(heapm.getAllCount() + one.getPatients().size()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(!StringUtils.isEmpty(article.getString("browseNumber"))){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                heapm.setBrowseNumbere(Integer.valueOf(article.getString("browseNumber")));//文章浏览数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                heapm.setBrowseNumbere(0);//文章浏览数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(article.getString("commentNumber") != null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(!StringUtils.isEmpty(article.getString("commentNumber"))){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                heapm.setCommentNumber(Integer.valueOf(article.getString("commentNumber")));//文章评论数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                heapm.setCommentNumber(0);//文章评论数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(article.getString("pointNumber") != null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(!StringUtils.isEmpty(article.getString("pointNumber"))){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                heapm.setPointNumber(Integer.valueOf(article.getString("pointNumber")));//文章点赞数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                heapm.setPointNumber(0);//文章点赞数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(!StringUtils.isEmpty(article.getString("collectionNumberCount"))){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                heapm.setCollectionNumber(Integer.valueOf(article.getString("collectionNumberCount")));//文章点赞数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                heapm.setCollectionNumber(0);//文章点赞数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            heapm.setArticleCover(article.getString("articleCover"));//封面 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(article.getString("insertTime")!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                heapm.setComputeTime(computeTime(article.getString("insertTime"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            doctor = doctorDao.findByCode(one.getDoctorCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            doctor = doctorDao.findByCode(sendCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            heapm.setPhoto(doctor.getPhoto()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            heapm.setOperatorName(article.getString("operatorName")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            heapm.setArticleSource(one.getArticleSource()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            // heapm.setTime();//时间  xx小时前  2017-10-11 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            resultList.add(heapm); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put(one.getArticleId(), heapm); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -195,20 +215,20 @@ public class JMJkEduArticleService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<HealthEduArticlePatient> pushArticleListCount(String sendCode,  String firstLevelCategoryId,String secondLevelCategoryId,Integer myArticle,Integer sendType,String currentUserRole, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<HealthEduArticleES> pushArticleListCount(String sendCode,  String firstLevelCategoryId,String secondLevelCategoryId,Integer myArticle,Integer sendType,String currentUserRole, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                              String currentUserRoleLevel,String articleTitle,String sendTimeStart,String sendTimeEnd) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        StringBuffer sql2 = new StringBuffer("select *  from   " + esType + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " where  doctorCode='" + sendCode + "'"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        StringBuffer sql2 = new StringBuffer("select articleId,articleTitle,firstLevelCategoryName,secondLevelCategoryName,articleSource,createTime  from   " + esType + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " where  sendCode='" + sendCode + "'"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(sendType==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql2.append(" and sendType='"+sendType+"' "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(!StringUtils.isEmpty(firstLevelCategoryId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql2.append("and level1Type="+firstLevelCategoryId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql2.append("and firstLevelCategoryId="+firstLevelCategoryId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(!StringUtils.isEmpty(secondLevelCategoryId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql2.append("and level2Type="+secondLevelCategoryId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql2.append("and secondLevelCategoryId="+secondLevelCategoryId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(myArticle==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql2.append(" and operatorId="+sendCode); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -226,7 +246,8 @@ public class JMJkEduArticleService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sendTimeEnd = elasticsearchUtil.changeTime(sendTimeEnd); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql2.append(" and createTime <='"+sendTimeEnd+"'"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<HealthEduArticlePatient> esList = elasticsearchUtil.excute(sql2.toString(), com.yihu.es.entity.HealthEduArticlePatient.class, esIndex, esType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql2.append(" group by articleId,articleTitle,firstLevelCategoryName,secondLevelCategoryName,articleSource,createTime"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<HealthEduArticleES> esList = elasticsearchUtil.excute(sql2.toString(),HealthEduArticleES.class, esIndex, esType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return esList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -415,7 +436,7 @@ public class JMJkEduArticleService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param articleId   文章列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Transactional 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public HealthEduArticlePatient savePCPushArticle(Set<String> patientSet, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<HealthEduArticleES> savePCPushArticle(Set<String> patientSet, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                     String sendCode, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                                                  String sendName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                     Integer sendType, 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -427,17 +448,95 @@ public class JMJkEduArticleService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                     String currentUserRoleLevel) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String batchNo = UUID.randomUUID().toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Patient> patientList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        String batchNo = UUID.randomUUID().toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        List<Patient> patientList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        for (String patient : patientSet) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            patientList.add(new Patient(patient)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        HealthEduArticlePatient healthEduArticlePatient = new HealthEduArticlePatient(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        Doctor doctor = doctorDao.findByCode(sendCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        String sendName = doctor.getName(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        //1、普通医生,2、管理员 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        if(sendType==2){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            String resultSql =""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            String whereSql =""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            switch (currentUserRoleLevel){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                case "1":{resultSql +=" DISTINCT (province_name) as name"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    whereSql+=" and province ='"+currentUserRoleCode+"'";break;} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                case "2":{resultSql +=" DISTINCT (city_name) as name"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    whereSql+=" and city ='"+currentUserRoleCode+"'";break;} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                case "3":{resultSql +=" DISTINCT (town_name) as name"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    whereSql+=" and town ='"+currentUserRoleCode+"'";break;} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                case "4":{resultSql +=" DISTINCT (name) as name"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    whereSql+=" and code ='"+currentUserRoleCode+"'";break;} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            String sql = "select "+resultSql+" from dm_hospital  where level=2 "+whereSql ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            List<Map<String, Object>> returnList = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            sendName = returnList.get(0).get("name")+""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            Map<String,Object> resultMap = labelService.fetchUserHighestAuthority(sendCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            List<String> roleList = (List<String>)resultMap.get("roleList"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            List<RoleVo> roleVoLists= new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            for(String one:roleList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                RoleVo roleVo = new RoleVo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                roleVo.setCode(one); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                roleVoLists.add(roleVo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            healthEduArticlePatient.setRoleList(roleVoLists); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            healthEduArticlePatient.setCurrentUserRoleCode(currentUserRoleCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            healthEduArticlePatient.setCurrentUserRoleLevel(currentUserRoleLevel); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            healthEduArticlePatient.setCurrentUserRoleCode(doctor.getHospital()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            healthEduArticlePatient.setCurrentUserRoleLevel("4"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        healthEduArticlePatient.setSendType(sendType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        healthEduArticlePatient.setDoctorCode(sendCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        healthEduArticlePatient.setSendName(sendName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        healthEduArticlePatient.setAdminTeamCode(teamId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        healthEduArticlePatient.setLeaveWords(leaveWords); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        if (doctor != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            healthEduArticlePatient.setDoctorName(doctor.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            healthEduArticlePatient.setHospital(doctor.getHospital()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            healthEduArticlePatient.setHospitalName(doctor.getHospitalName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            healthEduArticlePatient.setTown(doctor.getTown()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            healthEduArticlePatient.setTownName(doctor.getTownName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            healthEduArticlePatient.setSendLevel(doctor.getLevel() != null ? String.valueOf(doctor.getLevel()) : ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            healthEduArticlePatient.setSendPic(doctor.getPhoto()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            healthEduArticlePatient.setSendSex(doctor.getSex() != null ? String.valueOf(doctor.getSex()) : ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        healthEduArticlePatient.setBatchNo(batchNo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        healthEduArticlePatient.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        //通过文章id 获取文章详情 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        JSONObject article = thirdJkEduArticleService.getArticalById(articleId,""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        healthEduArticlePatient.setArticleId(article.get("articleId") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        healthEduArticlePatient.setAttachedTitle(article.get("articleTitle") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        healthEduArticlePatient.setAttachedPic(article.get("articleCover") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        healthEduArticlePatient.setAttachedContent(article.get("articleContent") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        healthEduArticlePatient.setAttachedMessage(sendMessage); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        healthEduArticlePatient.setArticleType(article.get("articleType") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        healthEduArticlePatient.setLevel(article.get("articlelevel") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        healthEduArticlePatient.setLevel1Type(article.get("firstLevelCategoryId") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        healthEduArticlePatient.setLevel2Type(article.get("secondLevelCategoryId") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        healthEduArticlePatient.setType("1");//文章 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				////        healthEduArticlePatient.setArticleUrl(articleBaseUrl+"JkEduWeb/web/jkEdu/articleDetail.html?behavior=4&articleId="+articleId+"&userId="+); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        healthEduArticlePatient.setPatients(patientList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (String patient : patientSet) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patientList.add(new Patient(patient)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        HealthEduArticlePatient healthEduArticlePatient = new HealthEduArticlePatient(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<HealthEduArticleES> healthEduArticleESList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Doctor doctor = doctorDao.findByCode(sendCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sendName = doctor.getName(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //1、普通医生,2、管理员 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        AdminTeam adminTeam =null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(teamId!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            adminTeam = adminTeamService.getTeam(teamId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Patient one = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String batchNo = UUID.randomUUID().toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sendName = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(sendType==2){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String resultSql =""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String whereSql =""; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -454,60 +553,73 @@ public class JMJkEduArticleService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String sql = "select "+resultSql+" from dm_hospital  where level=2 "+whereSql ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String, Object>> returnList = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sendName = returnList.get(0).get("name")+""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Map<String,Object> resultMap = labelService.fetchUserHighestAuthority(sendCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<String> roleList = (List<String>)resultMap.get("roleList"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<RoleVo> roleVoLists= new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for(String one:roleList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                RoleVo roleVo = new RoleVo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                roleVo.setCode(one); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                roleVoLists.add(roleVo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticlePatient.setRoleList(roleVoLists); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticlePatient.setCurrentUserRoleCode(currentUserRoleCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticlePatient.setCurrentUserRoleLevel(currentUserRoleLevel); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticlePatient.setCurrentUserRoleCode(doctor.getHospital()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticlePatient.setCurrentUserRoleLevel("4"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        healthEduArticlePatient.setSendType(sendType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        healthEduArticlePatient.setDoctorCode(sendCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        healthEduArticlePatient.setSendName(sendName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        healthEduArticlePatient.setAdminTeamCode(teamId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        healthEduArticlePatient.setLeaveWords(leaveWords); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (doctor != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticlePatient.setDoctorName(doctor.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticlePatient.setHospital(doctor.getHospital()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticlePatient.setHospitalName(doctor.getHospitalName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticlePatient.setTown(doctor.getTown()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticlePatient.setTownName(doctor.getTownName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticlePatient.setSendLevel(doctor.getLevel() != null ? String.valueOf(doctor.getLevel()) : ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticlePatient.setSendPic(doctor.getPhoto()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticlePatient.setSendSex(doctor.getSex() != null ? String.valueOf(doctor.getSex()) : ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String,Object> resultMap = labelService.fetchUserHighestAuthority(sendCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<String> roleList = (List<String>)resultMap.get("roleList"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<RoleVo> roleVoLists= new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for(String temp:roleList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            RoleVo roleVo = new RoleVo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            roleVo.setCode(temp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            roleVoLists.add(roleVo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        healthEduArticlePatient.setBatchNo(batchNo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        healthEduArticlePatient.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject article = thirdJkEduArticleService.getArticalById(articleId,""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (String patient : patientSet) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            one = patientDao.findByCode(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            HealthEduArticleES healthEduArticleES = new HealthEduArticleES(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setDoctorCode(doctor.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setDoctorName(doctor.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setBatchNo(batchNo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setPatientCode(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setPatientName(one.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(sendType==2){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                healthEduArticleES.setSendName(sendName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                healthEduArticleES.setSendLevel("4"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                healthEduArticleES.setSendName(doctor.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                healthEduArticleES.setSendLevel(doctor.getLevel()+""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //通过文章id 获取文章详情 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject article = thirdJkEduArticleService.getArticalById(articleId,""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setSendPic(doctor.getPhoto()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setSendSex(doctor.getSex()+""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(adminTeam!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        healthEduArticlePatient.setArticleId(article.get("articleId") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        healthEduArticlePatient.setAttachedTitle(article.get("articleTitle") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        healthEduArticlePatient.setAttachedPic(article.get("articleCover") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        healthEduArticlePatient.setAttachedContent(article.get("articleContent") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        healthEduArticlePatient.setAttachedMessage(sendMessage); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        healthEduArticlePatient.setArticleType(article.get("articleType") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        healthEduArticlePatient.setLevel(article.get("articlelevel") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        healthEduArticlePatient.setLevel1Type(article.get("firstLevelCategoryId") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        healthEduArticlePatient.setLevel2Type(article.get("secondLevelCategoryId") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        healthEduArticlePatient.setType("1");//文章 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        healthEduArticlePatient.setArticleUrl(articleBaseUrl+"JkEduWeb/web/jkEdu/articleDetail.html?behavior=4&articleId="+articleId+"&userId="+); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        healthEduArticlePatient.setPatients(patientList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                healthEduArticleES.setAdminTeamCode(adminTeam.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                healthEduArticleES.setAdminTeamName(adminTeam.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setHospital(doctor.getHospital()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setHospitalName(doctor.getHospitalName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setTown(doctor.getTown()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setTownName(doctor.getTownName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setSendType(sendType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setArticleId(article.get("articleId") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setArticleTitle(article.get("articleTitle") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setArticleCover(article.get("articleCover") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setArticleContent(article.get("articleContent") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setArticleCategoryId(article.get("articleCategoryId") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setFirstLevelCategoryId(article.get("firstLevelCategoryId") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setFirstLevelCategoryName(article.get("firstLevelCategoryName") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setSecondLevelCategoryId(article.get("secondLevelCategoryId") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setSecondLevelCategoryName(article.get("secondLevelCategoryName") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setOperatorId(article.get("operatorId") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setArticleSource(article.get("articleSource") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setRoleList(roleVoLists); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setLeaveWords(leaveWords); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setCurrentUserRoleCode(currentUserRoleCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setCurrentUserRoleLevel(currentUserRoleLevel); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            healthEduArticleES.setSendSource(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setAllCount(patientSet.size()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleESList.add(healthEduArticleES); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //保存到ES中 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        elastricSearchSave.save(healthEduArticlePatient, esIndex, esType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return healthEduArticlePatient; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        elastricSearchSave.save(healthEduArticleESList, esIndex, esType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return healthEduArticleESList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject pushArticleConfirm(String articleId, String labelUnit, String labelSex, String labelServe, String labelDisease, String labelHealth,String userCode,String currentUserRole, String currentUserRoleLevel) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject article = thirdJkEduArticleService.getArticalById(articleId,""); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -953,31 +1065,111 @@ public class JMJkEduArticleService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 一键修改居民推送文章的文章为已读 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param patient 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void readAllArticleNew(String patient,String firstLevelCategoryId){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JestClient jestClient = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            jestClient = elasticFactory.getJestClient(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            searchSourceBuilder.query( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    new BoolQueryBuilder() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            .must(QueryBuilders.matchQuery("patientCode", patient)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            .must(QueryBuilders.matchQuery("firstLevelCategoryId", firstLevelCategoryId)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType).build(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            SearchResult result = jestClient.execute(search); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<HealthEduArticleES> dataList = result.getSourceAsObjectList(HealthEduArticleES.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(!dataList.isEmpty()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //根据id批量删除 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (HealthEduArticleES obj : dataList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    Delete index = new Delete.Builder(obj.getId()).build(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    bulk.addAction(index); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                BulkResult br = jestClient.execute(bulk.build()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (HealthEduArticleES healthEduArticleES:dataList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                healthEduArticleES.setIsRead(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            elastricSearchSave.save(dataList,esIndex,esType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            jestClient.shutdownClient(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } finally { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (jestClient != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                jestClient.shutdownClient(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 居民单条文章增加已读状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param patient 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param articleId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void readPatientArticle(String patient,String articleId){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JestClient jestClient = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            jestClient = elasticFactory.getJestClient(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            searchSourceBuilder.query( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    new BoolQueryBuilder() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            .must(QueryBuilders.matchQuery("patientCode", patient)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            .must(QueryBuilders.matchQuery("articleId", articleId)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType).build(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            SearchResult result = jestClient.execute(search); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<HealthEduArticleES> dataList = result.getSourceAsObjectList(HealthEduArticleES.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(!dataList.isEmpty()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //根据id批量删除 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (HealthEduArticleES obj : dataList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    Delete index = new Delete.Builder(obj.getId()).build(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    bulk.addAction(index); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                BulkResult br = jestClient.execute(bulk.build()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (HealthEduArticleES healthEduArticleES:dataList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                healthEduArticleES.setIsRead(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            elastricSearchSave.save(dataList,esIndex,esType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            jestClient.shutdownClient(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } finally { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (jestClient != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                jestClient.shutdownClient(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONArray pushArticleLogs(int page, int pagesize, String patientCode,String level1Type) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        pagesize = page * pagesize; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        page = (page - 1) * pagesize; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        StringBuffer sql2 = new StringBuffer("select *  from   " + esType + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                " where  sendCode='" + sendCode + "' "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        sql2.append("  order by createTime limit " + page + "," + pagesize); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "SELECT * FROM " + esType + "  where nested(patients.code)= '" + patientCode + "' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "SELECT * FROM " + esType + "  where patientCode= '" + patientCode + "' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(!StringUtils.isEmpty(level1Type)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql= sql + " and level1Type = '"+level1Type+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql= sql + " and firstLevelCategoryId = '"+level1Type+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(page !=0 && pagesize !=0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql= sql+  " order by createTime desc limit " + page + "," + pagesize; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<com.yihu.es.entity.HealthEduArticlePatient> esList = elasticsearchUtil.excute(sql, com.yihu.es.entity.HealthEduArticlePatient.class, esIndex, esType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<HealthEduArticleES> esList = elasticsearchUtil.excute(sql, HealthEduArticleES.class, esIndex, esType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        HealthEduArticlePatientModel heapm = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        com.alibaba.fastjson.JSONObject article = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<HealthEduArticlePatientModel> result = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Doctor doctor = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (HealthEduArticlePatient one : esList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (HealthEduArticleES one : esList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            article = thirdJkEduArticleService.getArticalById(one.getArticleId(),""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            heapm = new HealthEduArticlePatientModel(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            heapm.setSendName(one.getSendName()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -990,7 +1182,7 @@ public class JMJkEduArticleService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            heapm.setLevel1Type(article.getString("firstLevelCategoryId")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            heapm.setLevel2Type(article.getString("secondLevelCategoryId")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            heapm.setLevel(article.getString("articlelevel")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            heapm.setAllCount(heapm.getAllCount() + one.getPatients().size()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            heapm.setAllCount(heapm.getAllCount() + one.getPatients().size()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            heapm.setBrowseNumbere(Integer.valueOf(article.getString("browseNumber")));//文章浏览数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            heapm.setCommentNumber(Integer.valueOf(article.getString("commentNumber")));//文章评论数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            heapm.setPointNumber(Integer.valueOf(article.getString("pointNumber")));//文章点赞数 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -998,8 +1190,8 @@ public class JMJkEduArticleService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            heapm.setComputeTime(computeTime(article.getString("insertTime"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            heapm.setOperatorName(article.getString("operatorName")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            heapm.setSendType(one.getSendType());//发送类型 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            heapm.setIsread(one.getIsread());//已读未读标识,1已读,2未读 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            heapm.setLeaveWords(one.getLeaveWords()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            heapm.setIsread(String.valueOf(one.getIsRead()));//已读未读标识,1已读,2未读 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            heapm.setLeaveWords(one.getLeaveWords());//医生留言 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            doctor = doctorDao.findByCode(one.getDoctorCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            heapm.setPhoto(doctor.getPhoto()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.add(heapm); 
			 |