|
@ -1,5 +1,6 @@
|
|
|
package com.yihu.wlyy.activemq;
|
|
|
|
|
|
import com.yihu.es.entity.HealthEduArticleES;
|
|
|
import com.yihu.es.entity.HealthEduArticlePatient;
|
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
|
import com.yihu.wlyy.service.app.consult.ConsultService;
|
|
@ -46,9 +47,9 @@ public class HealthArtListener implements MessageListener {
|
|
|
public void onMessage(Message message) {
|
|
|
try {
|
|
|
TextMessage textMessage = (TextMessage) message;
|
|
|
HealthEduArticlePatient healthEduArticlePatient = (HealthEduArticlePatient)JSONObject.toBean(JSONObject.fromObject(textMessage.getText()),HealthEduArticlePatient.class);
|
|
|
HealthEduArticleES healthEduArticleES = (HealthEduArticleES)JSONObject.toBean(JSONObject.fromObject(textMessage.getText()),HealthEduArticlePatient.class);
|
|
|
// logger.info(jo.toString());
|
|
|
sendWxTemplateAndIM(healthEduArticlePatient);
|
|
|
sendWxTemplateAndIM(healthEduArticleES);
|
|
|
//返回服务器表示消息消费成功
|
|
|
message.acknowledge();
|
|
|
} catch (JMSException e) {
|
|
@ -58,18 +59,18 @@ public class HealthArtListener implements MessageListener {
|
|
|
|
|
|
|
|
|
//发送到IM和微信消息模板
|
|
|
private void sendWxTemplateAndIM(HealthEduArticlePatient one) {
|
|
|
private void sendWxTemplateAndIM(HealthEduArticleES one) {
|
|
|
String endMsg = "";//"为了您的健康," + doctor.getName() + "医生给您发送了一篇患教文章,请仔细查阅,如有问题,可随时咨询医生。";
|
|
|
|
|
|
// healthEduArticlePatients.stream().forEach(one -> {
|
|
|
Patient patient = patientService.findByCode(one.getPatient());
|
|
|
Patient patient = patientService.findByCode(one.getPatientCode());
|
|
|
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(), "{\"title\":\"" + one.getArticleTitle() + "\",\"type\":0,\"id\":\"" + one.getId() + "\",\"img\":\"" + one.getArticleCover() + "\",\"content\":\"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通\"}", "4", patient.getName());
|
|
|
if (StringUtils.isNotBlank(one.getLeaveWords())) {
|
|
|
//发送备注
|
|
|
consultService.sendMucMessageBySingnType(one.getDoctorCode(), one.getDoctorName(), patient.getCode(), one.getAttachedMessage(), ImUtill.CONTENT_TYPE_TEXT, patient.getName());
|
|
|
consultService.sendMucMessageBySingnType(one.getDoctorCode(), one.getDoctorName(), patient.getCode(), one.getLeaveWords(), ImUtill.CONTENT_TYPE_TEXT, patient.getName());
|
|
|
}
|
|
|
}
|
|
|
// 推送消息给微信端
|
|
@ -77,12 +78,12 @@ public class HealthArtListener implements MessageListener {
|
|
|
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("title", one.getArticleTitle());
|
|
|
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());
|
|
|
json.put("remark", org.springframework.util.StringUtils.isEmpty(one.getLeaveWords()) ? " " : one.getLeaveWords());
|
|
|
json.put("newArricleFlag",one.getNewArricleFlag());
|
|
|
if (StringUtils.isNotBlank(patient.getOpenid())) {
|
|
|
pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 9,
|
|
|
patient.getOpenid(),
|