| 
					
				 | 
			
			
				@ -1,116 +1,116 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//package com.yihu.wlyy.activemq; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//import com.yihu.es.entity.HealthEduArticlePatient; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//import com.yihu.wlyy.entity.patient.Patient; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//import com.yihu.wlyy.service.app.consult.ConsultService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//import com.yihu.wlyy.service.common.account.PatientService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//import com.yihu.wlyy.task.PushMsgTask; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//import com.yihu.wlyy.util.DateUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//import com.yihu.wlyy.util.ImUtill; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//import net.sf.json.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//import org.json.JSONArray; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//import org.slf4j.Logger; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//import org.slf4j.LoggerFactory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//import org.springframework.stereotype.Component; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//import javax.jms.JMSException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//import javax.jms.Message; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//import javax.jms.MessageListener; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//import javax.jms.TextMessage; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				///** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// * Created by chenweida on 2017/9/9. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// * 健康教育文章监听 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//@Component 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//public class HealthArtListener implements MessageListener { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//    private Logger logger = LoggerFactory.getLogger(HealthArtListener.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//    private WeiXinOpenIdUtils weiXinOpenIdUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//    private PushMsgTask pushMsgTask; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//    private PatientService patientService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//    private ConsultService consultService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//    private WeiXinAccessTokenUtils weiXinAccessTokenUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//    public void onMessage(Message message) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            TextMessage textMessage = (TextMessage) message; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            HealthEduArticlePatient healthEduArticlePatient = (HealthEduArticlePatient)JSONObject.toBean(JSONObject.fromObject(textMessage.getText()),HealthEduArticlePatient.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				////            logger.info(jo.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            sendWxTemplateAndIM(healthEduArticlePatient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            //返回服务器表示消息消费成功 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            message.acknowledge(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        } catch (JMSException e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//    //发送到IM和微信消息模板 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//    private void sendWxTemplateAndIM(HealthEduArticlePatient one) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        String endMsg = "";//"为了您的健康," + doctor.getName() + "医生给您发送了一篇患教文章,请仔细查阅,如有问题,可随时咨询医生。"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				////        healthEduArticlePatients.stream().forEach(one -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            Patient patient = patientService.findByCode(one.getPatient()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                //卫纪委发送不推IM 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                if (1 == one.getSendType()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    consultService.sendMucMessageBySingnType(one.getSendCode(), one.getSendName(), patient.getCode(), "{\"title\":\"" + one.getAttachedTitle() + "\",\"type\":0,\"id\":\"" + one.getId() + "\",\"img\":\"" + one.getAttachedPic() + "\",\"content\":\"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通\"}", "4", patient.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    if (StringUtils.isNotBlank(one.getAttachedMessage())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        //发送备注 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        consultService.sendMucMessageBySingnType(one.getSendCode(), one.getSendName(), patient.getCode(), one.getAttachedMessage(), ImUtill.CONTENT_TYPE_TEXT, patient.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                // 推送消息给微信端 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                org.json.JSONObject json = new org.json.JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                json.put("first", patient.getName() + ",您好! " + one.getSendName() + (one.getSendType()==2 ? "卫计委":"医生") +"给您发来了一篇患教文章"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                json.put("toUser", patient.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                json.put("article", one.getArticleId() + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                json.put("title", one.getAttachedTitle()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                json.put("doctorName", one.getSendName()+(one.getSendType()==2 ? "卫计委":"医生")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                json.put("represented", patient.getCode());//被代理人 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                json.put("date", DateUtil.dateToStrLong(DateUtil.getNowDate())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                json.put("remark", org.springframework.util.StringUtils.isEmpty(one.getAttachedMessage()) ? "  " : one.getAttachedMessage()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                json.put("articleUrl",one.getArticleUrl()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                if (StringUtils.isNotBlank(patient.getOpenid())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 9, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                            patient.getOpenid(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                            patient.getName(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                            json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                //发送代理人 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                JSONArray jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient.getCode(), patient.getOpenid()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                if (jsonArray != null && jsonArray.length() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    for (int i = 0; i < jsonArray.length(); i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        org.json.JSONObject j = jsonArray.getJSONObject(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        Patient member = (Patient) j.get("member"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        json.remove("toUser"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        json.put("toUser", member.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        json.remove("first"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                            json.put("first", weiXinOpenIdUtils.getTitleMes(patient, j.isNull("relation") ? 1 : j.getInt("relation"), patient.getName())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                            e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        if (StringUtils.isNotBlank(member.getOpenid())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                            pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 9, member.getOpenid(), patient.getName(), json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                logger.error("patient:" + patient.getCode() + "," + e.getMessage()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				////        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				package com.yihu.wlyy.activemq; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.es.entity.HealthEduArticlePatient; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.entity.patient.Patient; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.app.consult.ConsultService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.common.account.PatientService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.task.PushMsgTask; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.util.DateUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.util.ImUtill; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import net.sf.json.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.json.JSONArray; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.slf4j.Logger; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.slf4j.LoggerFactory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.stereotype.Component; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import javax.jms.JMSException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import javax.jms.Message; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import javax.jms.MessageListener; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import javax.jms.TextMessage; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 * Created by chenweida on 2017/9/9. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 * 健康教育文章监听 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				@Component 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				public class HealthArtListener implements MessageListener { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private Logger logger = LoggerFactory.getLogger(HealthArtListener.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private WeiXinOpenIdUtils weiXinOpenIdUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PushMsgTask pushMsgTask; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PatientService patientService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private ConsultService consultService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private WeiXinAccessTokenUtils weiXinAccessTokenUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void onMessage(Message message) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            TextMessage textMessage = (TextMessage) message; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            HealthEduArticlePatient healthEduArticlePatient = (HealthEduArticlePatient)JSONObject.toBean(JSONObject.fromObject(textMessage.getText()),HealthEduArticlePatient.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            logger.info(jo.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sendWxTemplateAndIM(healthEduArticlePatient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //返回服务器表示消息消费成功 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            message.acknowledge(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } catch (JMSException e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    //发送到IM和微信消息模板 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private void sendWxTemplateAndIM(HealthEduArticlePatient one) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String endMsg = "";//"为了您的健康," + doctor.getName() + "医生给您发送了一篇患教文章,请仔细查阅,如有问题,可随时咨询医生。"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        healthEduArticlePatients.stream().forEach(one -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Patient patient = patientService.findByCode(one.getPatient()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //卫纪委发送不推IM 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (1 == one.getSendType()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    consultService.sendMucMessageBySingnType(one.getDoctorCode(), one.getDoctorName(), patient.getCode(), "{\"title\":\"" + one.getAttachedTitle() + "\",\"type\":0,\"id\":\"" + one.getId() + "\",\"img\":\"" + one.getAttachedPic() + "\",\"content\":\"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通\"}", "4", patient.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (StringUtils.isNotBlank(one.getAttachedMessage())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        //发送备注 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        consultService.sendMucMessageBySingnType(one.getDoctorCode(), one.getDoctorName(), patient.getCode(), one.getAttachedMessage(), ImUtill.CONTENT_TYPE_TEXT, patient.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                // 推送消息给微信端 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                org.json.JSONObject json = new org.json.JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                json.put("first", patient.getName() + ",您好! " + one.getSendName() + (one.getSendType()==2 ? "卫计委":"医生") +"给您发来了一篇患教文章"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                json.put("toUser", patient.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                json.put("article", one.getArticleId() + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                json.put("title", one.getAttachedTitle()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                json.put("doctorName", one.getDoctorName()+(one.getSendType()==2 ? "卫计委":"医生")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                json.put("represented", patient.getCode());//被代理人 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                json.put("date", DateUtil.dateToStrLong(DateUtil.getNowDate())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                json.put("remark", org.springframework.util.StringUtils.isEmpty(one.getAttachedMessage()) ? "  " : one.getAttachedMessage()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                json.put("articleUrl",one.getArticleUrl()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (StringUtils.isNotBlank(patient.getOpenid())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 9, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            patient.getOpenid(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            patient.getName(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //发送代理人 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                JSONArray jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient.getCode(), patient.getOpenid()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (jsonArray != null && jsonArray.length() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    for (int i = 0; i < jsonArray.length(); i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        org.json.JSONObject j = jsonArray.getJSONObject(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        Patient member = (Patient) j.get("member"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        json.remove("toUser"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        json.put("toUser", member.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        json.remove("first"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            json.put("first", weiXinOpenIdUtils.getTitleMes(patient, j.isNull("relation") ? 1 : j.getInt("relation"), patient.getName())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if (StringUtils.isNotBlank(member.getOpenid())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 9, member.getOpenid(), patient.getName(), json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                logger.error("patient:" + patient.getCode() + "," + e.getMessage()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |