|  | @ -455,8 +455,8 @@ public class JwPrescriptionService {
 | 
	
		
			
				|  |  | //            params.add(new BasicNameValuePair("IDENTITY_CARD_NO", "350221197506113526"));//身份证
 | 
	
		
			
				|  |  |             String response = httpClientUtil.post(url, params, "UTF-8");
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  |             //居民随访记录
 | 
	
		
			
				|  |  |             List<Followup> followups = new ArrayList<>();
 | 
	
		
			
				|  |  |             //随访ID,ES集合对象 MAP
 | 
	
		
			
				|  |  |             HashMap<String,List<FollowupContentESDO>> followupidToESDOListMap = new HashMap<>();
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  |             if (StringUtils.isNotBlank(response)) {
 | 
	
		
			
				|  |  | //                logger.info("从基卫获取随访信息报文为:"+response);
 | 
	
	
		
			
				|  | @ -803,7 +803,9 @@ public class JwPrescriptionService {
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  | //                                logger.info("同步单条随访记录-ES数据对象组装完毕,时间:"+DateUtil.getStringDate());
 | 
	
		
			
				|  |  |                                 //ES保存新数据
 | 
	
		
			
				|  |  |                                 this.esSaveFollowupContentData(String.valueOf(followupId),newList);
 | 
	
		
			
				|  |  | //                                this.esSaveFollowupContentData(String.valueOf(followupId),newList);
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  |                                 followupidToESDOListMap.put(String.valueOf(followupId),newList);
 | 
	
		
			
				|  |  |                         
 | 
	
		
			
				|  |  |                                 List<FollowupDrugs> DRUG_LIST = new ArrayList<>();//用药记录
 | 
	
		
			
				|  |  |                         
 | 
	
	
		
			
				|  | @ -864,6 +866,11 @@ public class JwPrescriptionService {
 | 
	
		
			
				|  |  |                 logger.info("同步随访信息报错接口失败:无数据返回, hosipitalcode" + hospitalMapping.getCode());
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             
 | 
	
		
			
				|  |  |             //处理随访详情数据
 | 
	
		
			
				|  |  |             if(!followupidToESDOListMap.isEmpty()){
 | 
	
		
			
				|  |  |                 this.esSaveFollowupContentData(followupidToESDOListMap);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  |     
 | 
	
	
		
			
				|  | @ -1204,32 +1211,51 @@ public class JwPrescriptionService {
 | 
	
		
			
				|  |  |      *@author huangwenjie
 | 
	
		
			
				|  |  |      *@date 2017/11/1 14:57
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public void esSaveFollowupContentData(String followupid, List<FollowupContentESDO> newdatalist) throws Exception {
 | 
	
		
			
				|  |  |     public void esSaveFollowupContentData(HashMap<String,List<FollowupContentESDO>>  newdataMap) throws Exception {
 | 
	
		
			
				|  |  |         JestClient jestClient = null;
 | 
	
		
			
				|  |  |         
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  | //            logger.info("同步单条随访记录-开始建立ES数据连接,时间:"+DateUtil.getStringDate());
 | 
	
		
			
				|  |  |             //            logger.info("同步单条随访记录-开始建立ES数据连接,时间:"+DateUtil.getStringDate());
 | 
	
		
			
				|  |  |             jestClient = elasticFactory.getJestClient();
 | 
	
		
			
				|  |  |             //先根据条件查找出来
 | 
	
		
			
				|  |  |             SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
 | 
	
		
			
				|  |  |             searchSourceBuilder.query(
 | 
	
		
			
				|  |  |                     new BoolQueryBuilder()
 | 
	
		
			
				|  |  |                             .must(QueryBuilders.matchQuery("followup_id", id))
 | 
	
		
			
				|  |  |             );
 | 
	
		
			
				|  |  |             Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType).build();
 | 
	
		
			
				|  |  |             SearchResult result = jestClient.execute(search);
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  |             List<FollowupContentESDO> resultdata = new ArrayList<>();
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  |             for (String followid: newdataMap.keySet()) {
 | 
	
		
			
				|  |  |                 //先根据条件查找出来
 | 
	
		
			
				|  |  |                 SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
 | 
	
		
			
				|  |  |                 searchSourceBuilder.query(
 | 
	
		
			
				|  |  |                         new BoolQueryBuilder()
 | 
	
		
			
				|  |  |                                 .must(QueryBuilders.matchQuery("followup_id", followid))
 | 
	
		
			
				|  |  |                 );
 | 
	
		
			
				|  |  |                 Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType).build();
 | 
	
		
			
				|  |  |                 SearchResult result = jestClient.execute(search);
 | 
	
		
			
				|  |  | //            logger.info("同步单条随访记录-开始查询ES数据,时间:"+DateUtil.getStringDate());
 | 
	
		
			
				|  |  |             List<FollowupContentESDO> dataList = result.getSourceAsObjectList(FollowupContentESDO.class);
 | 
	
		
			
				|  |  |                 List<FollowupContentESDO> dataList = result.getSourceAsObjectList(FollowupContentESDO.class);
 | 
	
		
			
				|  |  | //            logger.info("同步单条随访记录-ES数据查询成功,时间:"+DateUtil.getStringDate());
 | 
	
		
			
				|  |  |             if(!dataList.isEmpty()){
 | 
	
		
			
				|  |  |                 //删除原有记录
 | 
	
		
			
				|  |  |                 if(!dataList.isEmpty()){
 | 
	
		
			
				|  |  |                     //删除原有记录
 | 
	
		
			
				|  |  | //                logger.info("同步单条随访记录-开始删除ES数据,时间:"+DateUtil.getStringDate());
 | 
	
		
			
				|  |  |                 this.esDeleteFollowUpContent(dataList);
 | 
	
		
			
				|  |  | //                    this.esDeleteFollowUpContent(dataList);
 | 
	
		
			
				|  |  |                     //根据id批量删除
 | 
	
		
			
				|  |  |                     Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType);
 | 
	
		
			
				|  |  |                     for (FollowupContentESDO obj : dataList) {
 | 
	
		
			
				|  |  |                         Delete index = new Delete.Builder(obj.getId()).build();
 | 
	
		
			
				|  |  |                         bulk.addAction(index);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     BulkResult br = jestClient.execute(bulk.build());
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  |                     logger.info("delete data count:" + dataList.size());
 | 
	
		
			
				|  |  |                     logger.info("delete flag:" + br.isSucceeded());
 | 
	
		
			
				|  |  | //                logger.info("同步单条随访记录-ES数据删除成功,时间:"+DateUtil.getStringDate());
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 resultdata.addAll(newdataMap.get(followid));
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             //保存新的随访详情记录
 | 
	
		
			
				|  |  | //            logger.info("同步单条随访记录-开始保存ES数据,时间:"+DateUtil.getStringDate());
 | 
	
		
			
				|  |  |             elastricSearchSave.save(newdatalist,esIndex,esType);
 | 
	
		
			
				|  |  |             if(!resultdata.isEmpty()){
 | 
	
		
			
				|  |  |                 elastricSearchSave.save(resultdata,esIndex,esType);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | //            logger.info("同步单条随访记录-ES数据保存成功,时间:"+DateUtil.getStringDate());
 | 
	
		
			
				|  |  |             jestClient.shutdownClient();
 | 
	
		
			
				|  |  |         }catch (Exception e){
 |