| 
															
																@ -103,11 +103,11 @@ public class GcEduArticleController extends WeixinBaseController { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                return new ResultBatchModel(BaseResultModel.statusEm.opera_error.getCode(), BaseResultModel.statusEm.opera_error.getMessage() + ":文章参数长度错误"); 
															 | 
															
															 | 
															
																                return new ResultBatchModel(BaseResultModel.statusEm.opera_error.getCode(), BaseResultModel.statusEm.opera_error.getMessage() + ":文章参数长度错误"); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            } 
															 | 
															
															 | 
															
																            } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            //得到需要发送的患者 
															 | 
															
															 | 
															
																            //得到需要发送的患者 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            gcEduArticleService.initPatient(patientSet, patients,unPatients, labelType, labelCode, teamId); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            gcEduArticleService.initPatient(patientSet, patients, unPatients, labelType, labelCode, teamId); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            //保存发送记录 
															 | 
															
															 | 
															
																            //保存发送记录 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            List<HealthEduArticlePatient> healthEduArticlePatients = gcEduArticleService.saveArticle(patientSet, sendCode, sendName, sendMessage, teamId, articleIdArr, articlePicArr, articleTitleArr); 
															 | 
															
															 | 
															
																            List<HealthEduArticlePatient> healthEduArticlePatients = gcEduArticleService.saveArticle(patientSet, sendCode, sendName, sendMessage, teamId, articleIdArr, articlePicArr, articleTitleArr); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            //推送微信模板消息和发送im消息 
															 | 
															
															 | 
															
																            //推送微信模板消息和发送im消息 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            sendWxTemplateAndIM(healthEduArticlePatients); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            sendWxTemplateAndIM(healthEduArticlePatients, sendType); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            return new BaseResultModel(); 
															 | 
															
															 | 
															
																            return new BaseResultModel(); 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@ -116,49 +116,51 @@ public class GcEduArticleController extends WeixinBaseController { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        } 
															 | 
															
															 | 
															
																        } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    } 
															 | 
															
															 | 
															
																    } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    private void sendWxTemplateAndIM(List<HealthEduArticlePatient> healthEduArticlePatients) throws  Exception{ 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    private void sendWxTemplateAndIM(List<HealthEduArticlePatient> healthEduArticlePatients, String sendType) throws Exception { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        String endMsg = "";//"为了您的健康," + doctor.getName() + "医生给您发送了一篇患教文章,请仔细查阅,如有问题,可随时咨询医生。"; 
															 | 
															
															 | 
															
																        String endMsg = "";//"为了您的健康," + doctor.getName() + "医生给您发送了一篇患教文章,请仔细查阅,如有问题,可随时咨询医生。"; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        healthEduArticlePatients.stream().forEach(one -> { 
															 | 
															
															 | 
															
																        healthEduArticlePatients.stream().forEach(one -> { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            Patient patient=patientService.findByCode(one.getPatient()); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            consultService.sendMucMessageBySingnType(one.getDoctor(), one.getDoctorName(), patient.getCode(), "{\"title\":\"" + one.getAttachedTitle()+ "\",\"type\":0,\"id\":\"" + one.getId() + "\",\"img\":\"" + one.getAttachedPic() + "\",\"content\":\"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通\"}", "4", patient.getName()); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            if(StringUtils.isNotBlank(one.getAttachedContent())){ 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                //发送备注 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                consultService.sendMucMessageBySingnType(one.getDoctor(),one.getDoctorName(), patient.getCode(), one.getAttachedContent(), ImUtill.CONTENT_TYPE_TEXT, patient.getName()); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            Patient patient = patientService.findByCode(one.getPatient()); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            //卫纪委发送不推IM 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            if ("1".equals(sendType)) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                consultService.sendMucMessageBySingnType(one.getDoctor(), one.getDoctorName(), patient.getCode(), "{\"title\":\"" + one.getAttachedTitle() + "\",\"type\":0,\"id\":\"" + one.getId() + "\",\"img\":\"" + one.getAttachedPic() + "\",\"content\":\"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通\"}", "4", patient.getName()); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                if (StringUtils.isNotBlank(one.getAttachedContent())) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                    //发送备注 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                    consultService.sendMucMessageBySingnType(one.getDoctor(), one.getDoctorName(), patient.getCode(), one.getAttachedContent(), ImUtill.CONTENT_TYPE_TEXT, patient.getName()); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            } 
															 | 
															
															 | 
															
																            } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            // 推送消息给微信端 
															 | 
															
															 | 
															
																            // 推送消息给微信端 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            JSONObject json = new JSONObject(); 
															 | 
															
															 | 
															
																            JSONObject json = new JSONObject(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            json.put("first", patient.getName() + ",您好!\n" +  one.getDoctorName() + "医生给您发来了一篇患教文章"); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            json.put("first", patient.getName() + ",您好!\n" + one.getDoctorName() + "医生给您发来了一篇患教文章"); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            json.put("toUser", patient.getCode()); 
															 | 
															
															 | 
															
																            json.put("toUser", patient.getCode()); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            json.put("article", one.getId()+ ""); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            json.put("article", one.getId() + ""); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            json.put("title", one.getAttachedTitle()); 
															 | 
															
															 | 
															
																            json.put("title", one.getAttachedTitle()); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            json.put("doctorName", one.getDoctorName()); 
															 | 
															
															 | 
															
																            json.put("doctorName", one.getDoctorName()); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            json.put("represented",patient.getCode());//被代理人 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            json.put("represented", patient.getCode());//被代理人 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            json.put("date", DateUtil.dateToStrLong(DateUtil.getNowDate())); 
															 | 
															
															 | 
															
																            json.put("date", DateUtil.dateToStrLong(DateUtil.getNowDate())); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            json.put("remark", one.getAttachedContent()); 
															 | 
															
															 | 
															
																            json.put("remark", one.getAttachedContent()); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            if(StringUtils.isNotBlank(patient.getOpenid())){ 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            if (StringUtils.isNotBlank(patient.getOpenid())) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                pushMsgTask.putWxMsg(getAccessToken(), 9, 
															 | 
															
															 | 
															
																                pushMsgTask.putWxMsg(getAccessToken(), 9, 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                        patient.getOpenid(), 
															 | 
															
															 | 
															
																                        patient.getOpenid(), 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                        patient.getName(), 
															 | 
															
															 | 
															
																                        patient.getName(), 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                        json); 
															 | 
															
															 | 
															
																                        json); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            } 
															 | 
															
															 | 
															
																            } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            //发送代理人 
															 | 
															
															 | 
															
																            //发送代理人 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            JSONArray jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient.getCode(),patient.getOpenid()); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            if(jsonArray!=null&&jsonArray.length()>0){ 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                for (int i=0;i<jsonArray.length();i++){ 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            JSONArray jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient.getCode(), patient.getOpenid()); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            if (jsonArray != null && jsonArray.length() > 0) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                for (int i = 0; i < jsonArray.length(); i++) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                    JSONObject j = jsonArray.getJSONObject(i); 
															 | 
															
															 | 
															
																                    JSONObject j = jsonArray.getJSONObject(i); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                    Patient member = (Patient)j.get("member"); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                    Patient member = (Patient) j.get("member"); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                    json.remove("toUser"); 
															 | 
															
															 | 
															
																                    json.remove("toUser"); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                    json.put("toUser",member.getCode()); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                    json.put("toUser", member.getCode()); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                    json.remove("first"); 
															 | 
															
															 | 
															
																                    json.remove("first"); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                    try { 
															 | 
															
															 | 
															
																                    try { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                        json.put("first",weiXinOpenIdUtils.getTitleMes(patient,j.isNull("relation")?1:j.getInt("relation"),patient.getName())); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                        json.put("first", weiXinOpenIdUtils.getTitleMes(patient, j.isNull("relation") ? 1 : j.getInt("relation"), patient.getName())); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                    } catch (Exception e) { 
															 | 
															
															 | 
															
																                    } catch (Exception e) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                        e.printStackTrace(); 
															 | 
															
															 | 
															
																                        e.printStackTrace(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                    } 
															 | 
															
															 | 
															
																                    } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                    if(StringUtils.isNotBlank(member.getOpenid())){ 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                    if (StringUtils.isNotBlank(member.getOpenid())) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                        pushMsgTask.putWxMsg(getAccessToken(), 9, member.getOpenid(), patient.getName(), json); 
															 | 
															
															 | 
															
																                        pushMsgTask.putWxMsg(getAccessToken(), 9, member.getOpenid(), patient.getName(), json); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                    } 
															 | 
															
															 | 
															
																                    } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                } 
															 | 
															
															 | 
															
																                } 
															 |