| 
					
				 | 
			
			
				@ -359,9 +359,9 @@ public class EduArticleService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<NewCategoryModel> secondList = jkeduCategoryDao.findCategory(2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String firstId = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String firstName = "健康文章"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (firstList!=null && firstList.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (NewCategoryModel newCategoryModel : firstList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (newCategoryModel.getCategoryName().contains(firstName)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (firstList != null && firstList.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (NewCategoryModel newCategoryModel : firstList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (newCategoryModel.getCategoryName().contains(firstName)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        firstId = newCategoryModel.getCategoryId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -745,6 +745,7 @@ public class EduArticleService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 根据批次号batchNo删除es数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param batchNo 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private void deleteEsDataByBatch(String batchNo) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -782,7 +783,7 @@ public class EduArticleService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private int saveByBatch(String batchNo)throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private int saveByBatch(String batchNo) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //1.查询出所有的文章列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<HealthEduArticle> healthEduArticleList = healthEduArticleDao.findAllArticle(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String, HealthEduArticle> articleMap = new HashedMap();//key是文章code 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -869,7 +870,7 @@ public class EduArticleService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    healthEduArticleES.setCzrq(null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    healthEduArticleES.setIsRead(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (adminTeam!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (adminTeam != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    healthEduArticleES.setAdminTeamName(adminTeam.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    healthEduArticleES.setAdminTeamCode(adminTeam.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -919,7 +920,7 @@ public class EduArticleService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JestClient jestClient = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            jestClient = elasticFactory.getJestClient(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Integer i=0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Integer i = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //先根据条件查找出来 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String sql = "select id from " + esIndex + " where doctorCode='" + doctorCode + "'"; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -970,16 +971,16 @@ public class EduArticleService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //3.查询所有一级类别、二级类别 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<NewCategoryModel> firstList = jkeduCategoryDao.findCategory(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<NewCategoryModel> secondList = jkeduCategoryDao.findCategory(2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String firstIdStr=""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String firstIdStr = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String firstName = "健康文章"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (firstList!=null && firstList.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (NewCategoryModel newCategoryModel : firstList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (newCategoryModel.getCategoryName().contains(firstName)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (firstList != null && firstList.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (NewCategoryModel newCategoryModel : firstList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (newCategoryModel.getCategoryName().contains(firstName)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    firstIdStr = newCategoryModel.getCategoryId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        final String firstId= firstIdStr; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        final String firstId = firstIdStr; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //4.获取医生的推送记录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "select * from wlyy_health_edu_article_patient_copy where admin_team_code IS NOT NULL AND batch_no IS NOT NULL AND doctor='" + doctorCode + "'"; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1022,9 +1023,9 @@ public class EduArticleService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                healthEduArticleES.setSendLevel(doctor.getLevel() != null ? String.valueOf(doctor.getLevel()) : ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                healthEduArticleES.setSendSource(1);//旧数据都是1 i健康发送 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                healthEduArticleES.setCurrentUserRoleCode(doctor.getHospital()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if(roleMaps!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    healthEduArticleES.setCurrentUserRoleLevel(roleMaps.get("level")+""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (roleMaps != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    healthEduArticleES.setCurrentUserRoleLevel(roleMaps.get("level") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    healthEduArticleES.setCurrentUserRoleLevel("4"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1077,9 +1078,9 @@ public class EduArticleService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            HealthEduArticle healthEduArticle = articleMap.get(healthEduArticlePatientTemps.get(0).getArticle()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setArticleId(healthEduArticle.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (healthEduArticle.getContent().length()>=100){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                healthEduArticleES.setArticleContent(healthEduArticle.getContent().substring(0,100)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (healthEduArticle.getContent().length() >= 100) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                healthEduArticleES.setArticleContent(healthEduArticle.getContent().substring(0, 100)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                healthEduArticleES.setArticleContent(healthEduArticle.getContent()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setArticleTitle(healthEduArticle.getTitle()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1088,25 +1089,25 @@ public class EduArticleService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setArticleSource("厦门市卫生与计划生育委员会");//文章来源 旧数据默认是卫计委 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setFirstLevelCategoryId(firstId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setFirstLevelCategoryName(firstName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (secondList!=null && secondList.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (NewCategoryModel newCategoryModel : secondList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (newCategoryModel.getCategoryName().equals(healthEduArticle.getKeyword())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (secondList != null && secondList.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (NewCategoryModel newCategoryModel : secondList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (newCategoryModel.getCategoryName().equals(healthEduArticle.getKeyword())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        healthEduArticleES.setSecondLevelCategoryId(newCategoryModel.getCategoryId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        healthEduArticleES.setSecondLevelCategoryName(newCategoryModel.getCategoryName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (adminTeam!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (adminTeam != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                healthEduArticleES.setAdminTeamCode(adminTeam.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                healthEduArticleES.setAdminTeamName(adminTeam.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setUserType(2); //医生 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setAllCount(healthEduArticlePatientTemps.size()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setCurrentUserRoleCode(doctor.getHospital()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(roleMaps!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                healthEduArticleES.setCurrentUserRoleLevel(roleMaps.get("level")+""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (roleMaps != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                healthEduArticleES.setCurrentUserRoleLevel(roleMaps.get("level") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                healthEduArticleES.setCurrentUserRoleLevel("4"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthEduArticleES.setCreateTime(new Date()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1127,40 +1128,19 @@ public class EduArticleService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Map<String, Object> deleteEsOldArticlePatient() throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String, Object> returnMap = new HashedMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        int resultSize = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String countSql ="SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " COUNT(DISTINCT(batch_no)) AS batchCount " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " wlyy_health_edu_article_patient_copy " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " admin_team_code IS NOT NULL " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND batch_no IS NOT NULL"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String,Object> countMap = jdbcTemplate.queryForMap(countSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (countMap!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            int size = 1024; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            int batchCount = Integer.valueOf(String.valueOf(countMap.get("batchCount"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            double pageCount = Math.ceil(Double.valueOf(batchCount) / Double.valueOf(size)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (pageCount > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String sql = "SELECT batch_no AS batchNo,COUNT(1) batchCount " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "FROM wlyy_health_edu_article_patient_copy " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        "WHERE admin_team_code IS NOT NULL AND batch_no IS NOT NULL GROUP BY batch_no limit ?,?"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (int i = 1; i <= pageCount; i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    List<String> batchNoList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    int start = (i - 1) * size; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    List<Map<String,Object>> batchMapList = jdbcTemplate.queryForList(sql,new Object[]{start,size}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (batchMapList!=null && batchMapList.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        for (Map<String,Object> map : batchMapList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            batchNoList.add(String.valueOf(map.get("batchNo"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        resultSize += deleteEsByBatchNo(batchNoList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String, Object> returnMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "select batch_no code from wlyy_health_edu_article_patient_copy group by batch_no"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> queryids = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<String> ids = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (Map<String, Object> idMap : queryids) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (idMap.containsKey("code") && !org.springframework.util.StringUtils.isEmpty(idMap.get("code"))) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ids.add(idMap.get("code").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        returnMap.put("deleteCount",Integer.valueOf(resultSize)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        int count = deleteEsByBatchNo(ids); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        returnMap.put("deleteBatch", ids.size()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        returnMap.put("deleteCount", Integer.valueOf(count)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return returnMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1173,14 +1153,14 @@ public class EduArticleService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            jestClient = elasticFactory.getJestClient(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (String batchNo : list) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String sql = "select id from " + esIndex + " where batchNo='" + batchNo + "'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String sql = "select id from " + esIndex + " where batchNo='" + batchNo + "' limit 0,50000"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                List<Map<String, Object>> returnList = elasticsearchUtil.excuteDataModel(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //根据id批量删除 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (Map<String, Object> obj : returnList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (obj.containsKey("id")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        i++; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        Delete index = new Delete.Builder(obj.get("id").toString()).build(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        bulk.addAction(index); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        i++; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 |