|
@ -1,9 +1,12 @@
|
|
|
package com.yihu.wlyy.wechat.process;
|
|
|
|
|
|
import com.yihu.wlyy.task.PushMsgTask;
|
|
|
import com.yihu.wlyy.util.SystemConf;
|
|
|
import com.yihu.wlyy.wechat.util.WeiXinMessageReplyUtils;
|
|
|
import com.yihu.wlyy.wechat.util.WeiXinMessageUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.json.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
@ -23,13 +26,16 @@ public class WeiXinEventProcess {
|
|
|
private String appId;
|
|
|
@Value("${server.server_url}")
|
|
|
private String serverUrl;
|
|
|
@Autowired
|
|
|
private PushMsgTask pushMsgTask;
|
|
|
|
|
|
/**
|
|
|
* 微信推送事件处理
|
|
|
*
|
|
|
* @param message
|
|
|
* @return
|
|
|
*/
|
|
|
public String eventProcess(Map<String, String> message) throws Exception {
|
|
|
public String eventProcess(Map<String, String> message) throws Exception {
|
|
|
String result = "";
|
|
|
String event = message.get("Event");
|
|
|
|
|
@ -60,7 +66,7 @@ public class WeiXinEventProcess {
|
|
|
* @param message
|
|
|
* @return
|
|
|
*/
|
|
|
public String clickProcess(Map<String, String> message) throws Exception {
|
|
|
public String clickProcess(Map<String, String> message) throws Exception {
|
|
|
String result = "";
|
|
|
if (message.get("EventKey").equals("caozuoshuoming")) {
|
|
|
|
|
@ -84,7 +90,7 @@ public class WeiXinEventProcess {
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
private String clickEventProcess(Map<String, String> message) throws Exception {
|
|
|
private String clickEventProcess(Map<String, String> message) throws Exception {
|
|
|
String result = "";
|
|
|
// 配置信息
|
|
|
Properties systemConf = SystemConf.getInstance().getSystemProperties();
|
|
@ -98,7 +104,7 @@ public class WeiXinEventProcess {
|
|
|
// 图文消息图片URL
|
|
|
String picUrlConsult = systemConf.getProperty("patient_operatinginstrutions_pic_url");
|
|
|
// URL设置服务器URL、AppId
|
|
|
urlConsult = urlConsult.replace("{server}",wechat_base_url)
|
|
|
urlConsult = urlConsult.replace("{server}", wechat_base_url)
|
|
|
.replace("{appId}", appId);
|
|
|
//图片地址
|
|
|
picUrlConsult = picUrlConsult.replace("{server}", serverUrl);
|
|
@ -134,7 +140,7 @@ public class WeiXinEventProcess {
|
|
|
// 图文消息图片URL
|
|
|
String picUrlDevice = systemConf.getProperty("patient_device_pic_url");
|
|
|
// URL设置服务器URL、AppId
|
|
|
urlDevice = urlDevice.replace("{server}",wechat_base_url)
|
|
|
urlDevice = urlDevice.replace("{server}", wechat_base_url)
|
|
|
.replace("{appId}", appId);
|
|
|
//图片地址
|
|
|
picUrlDevice = picUrlDevice.replace("{server}", serverUrl);
|
|
@ -153,7 +159,7 @@ public class WeiXinEventProcess {
|
|
|
String picUrlFamily = systemConf.getProperty("patient_family_pic_url");
|
|
|
// URL设置服务器URL、AppId
|
|
|
urlFamily = urlFamily.replace("{server}", wechat_base_url)
|
|
|
.replace("{appId}",appId);
|
|
|
.replace("{appId}", appId);
|
|
|
//图片地址
|
|
|
picUrlFamily = picUrlFamily.replace("{server}", serverUrl);
|
|
|
|
|
@ -178,7 +184,7 @@ public class WeiXinEventProcess {
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
private String clickEventProcessMenu(Map<String, String> message) throws Exception {
|
|
|
private String clickEventProcessMenu(Map<String, String> message) throws Exception {
|
|
|
String result = "";
|
|
|
// 配置信息
|
|
|
Properties systemConf = SystemConf.getInstance().getSystemProperties();
|
|
@ -208,8 +214,8 @@ public class WeiXinEventProcess {
|
|
|
// 图文消息图片URL
|
|
|
String inspect_pic = systemConf.getProperty("patient_inspect_pic");
|
|
|
// URL设置服务器URL、AppId
|
|
|
inspect = inspect.replace("{server}",wechat_base_url)
|
|
|
.replace("{appId}",appId);
|
|
|
inspect = inspect.replace("{server}", wechat_base_url)
|
|
|
.replace("{appId}", appId);
|
|
|
//图片地址
|
|
|
inspect_pic = inspect_pic.replace("{server}", serverUrl);
|
|
|
|
|
@ -225,10 +231,10 @@ public class WeiXinEventProcess {
|
|
|
// 图文消息图片URL
|
|
|
String examination_pic = systemConf.getProperty("patient_examination_pic");
|
|
|
// URL设置服务器URL、AppId
|
|
|
examination = examination.replace("{server}",wechat_base_url)
|
|
|
examination = examination.replace("{server}", wechat_base_url)
|
|
|
.replace("{appId}", appId);
|
|
|
//图片地址
|
|
|
examination_pic = examination_pic.replace("{server}",serverUrl);
|
|
|
examination_pic = examination_pic.replace("{server}", serverUrl);
|
|
|
|
|
|
articleExamination.put("Url", examination);
|
|
|
articleExamination.put("Title", "社区体检");
|
|
@ -243,10 +249,10 @@ public class WeiXinEventProcess {
|
|
|
// 图文消息图片URL
|
|
|
String prescription_pic = systemConf.getProperty("patient_prescription_pic");
|
|
|
// URL设置服务器URL、AppId
|
|
|
prescription = prescription.replace("{server}",wechat_base_url)
|
|
|
.replace("{appId}",appId);
|
|
|
prescription = prescription.replace("{server}", wechat_base_url)
|
|
|
.replace("{appId}", appId);
|
|
|
//图片地址
|
|
|
prescription_pic = prescription_pic.replace("{server}",serverUrl);
|
|
|
prescription_pic = prescription_pic.replace("{server}", serverUrl);
|
|
|
|
|
|
articlePrescription.put("Url", prescription);
|
|
|
articlePrescription.put("Title", "处方记录");
|
|
@ -280,43 +286,61 @@ public class WeiXinEventProcess {
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 关注事件消息发送
|
|
|
* 关注事件消息构建回复消息体(图文消息xml,模板消息json串)
|
|
|
*
|
|
|
* @param message
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
private String subscribeEventProcess(Map<String, String> message) throws Exception {
|
|
|
private String subscribeEventProcess(Map<String, String> message) throws Exception {
|
|
|
String result = "";
|
|
|
// 配置信息
|
|
|
Properties systemConf = SystemConf.getInstance().getSystemProperties();
|
|
|
// 图文信息
|
|
|
List<Map<String, String>> articles = new ArrayList<>();
|
|
|
// 场景值
|
|
|
String eventKey = message.get("EventKey");
|
|
|
|
|
|
Map<String, String> article = new HashMap<>();
|
|
|
// 图文URL
|
|
|
String url = systemConf.getProperty("doctor_subscribe_url");
|
|
|
// 图文消息图片URL
|
|
|
String picUrl = systemConf.getProperty("doctor_qrcode_pic_url");
|
|
|
// URL设置服务器URL、AppId
|
|
|
url = url.replace("{server}", wechat_base_url)
|
|
|
.replace("{appId}", appId);
|
|
|
//图片地址
|
|
|
picUrl = picUrl.replace("{server}", serverUrl);
|
|
|
if (StringUtils.isNotEmpty(eventKey) && (("wechat_ehc").equals(eventKey)) ||
|
|
|
eventKey.startsWith("qrscene_wechat_ehc")) {
|
|
|
System.out.println("第三方ehr关注推送事件");
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("first", "first");
|
|
|
json.put("remark", "remark");
|
|
|
json.put("keyword1", "keyword1");
|
|
|
json.put("keyword2", "keyword2");
|
|
|
json.put("url", "www.baidu.com");
|
|
|
//跳转路径问题,如果是第三方不加本地服务器名称(要改push公用方法)
|
|
|
json.put("openId", message.get("FromUserName"));
|
|
|
json.put("type", 11);
|
|
|
//模板消息json串
|
|
|
result = json.toString();
|
|
|
} else {
|
|
|
// 配置信息
|
|
|
Properties systemConf = SystemConf.getInstance().getSystemProperties();
|
|
|
// 图文信息
|
|
|
List<Map<String, String>> articles = new ArrayList<>();
|
|
|
|
|
|
article.put("Url", url);
|
|
|
article.put("Title", "欢迎关注厦门i健康,快来签约家庭医生吧~");
|
|
|
article.put("Description", "请点击查看家庭签约");
|
|
|
article.put("PicUrl", picUrl);
|
|
|
Map<String, String> article = new HashMap<>();
|
|
|
// 图文URL
|
|
|
String url = systemConf.getProperty("doctor_subscribe_url");
|
|
|
// 图文消息图片URL
|
|
|
String picUrl = systemConf.getProperty("doctor_qrcode_pic_url");
|
|
|
// URL设置服务器URL、AppId
|
|
|
url = url.replace("{server}", wechat_base_url)
|
|
|
.replace("{appId}", appId);
|
|
|
//图片地址
|
|
|
picUrl = picUrl.replace("{server}", serverUrl);
|
|
|
|
|
|
articles.add(article);
|
|
|
article.put("Url", url);
|
|
|
article.put("Title", "欢迎关注厦门i健康,快来签约家庭医生吧~");
|
|
|
article.put("Description", "请点击查看家庭签约");
|
|
|
article.put("PicUrl", picUrl);
|
|
|
|
|
|
//设置共有的图文消息
|
|
|
setUrlItems(articles, systemConf);
|
|
|
articles.add(article);
|
|
|
|
|
|
// 构建回复消息XML
|
|
|
result = WeiXinMessageReplyUtils.replyNewsMessage(message.get("FromUserName"), message.get("ToUserName"), articles);
|
|
|
//设置共有的图文消息
|
|
|
setUrlItems(articles, systemConf);
|
|
|
|
|
|
// 构建回复消息XML
|
|
|
result = WeiXinMessageReplyUtils.replyNewsMessage(message.get("FromUserName"), message.get("ToUserName"), articles);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@ -325,7 +349,7 @@ public class WeiXinEventProcess {
|
|
|
*
|
|
|
* @param articles
|
|
|
*/
|
|
|
public void setUrlItems(List<Map<String, String>> articles, Properties systemConf) {
|
|
|
public void setUrlItems(List<Map<String, String>> articles, Properties systemConf) {
|
|
|
Map<String, String> articleConsult = new HashMap<>();
|
|
|
// 图文URL
|
|
|
String urlConsult = systemConf.getProperty("patient_consult_url");
|
|
@ -353,7 +377,7 @@ public class WeiXinEventProcess {
|
|
|
urlBooking = urlBooking.replace("{server}", wechat_base_url)
|
|
|
.replace("{appId}", appId);
|
|
|
//图片地址
|
|
|
picUrlBooking = picUrlBooking.replace("{server}",serverUrl);
|
|
|
picUrlBooking = picUrlBooking.replace("{server}", serverUrl);
|
|
|
|
|
|
articleBooking.put("Url", urlBooking);
|
|
|
articleBooking.put("Title", "预约挂号功能使用说明");
|
|
@ -387,9 +411,9 @@ public class WeiXinEventProcess {
|
|
|
String picUrlFamily = systemConf.getProperty("patient_family_pic_url");
|
|
|
// URL设置服务器URL、AppId
|
|
|
urlFamily = urlFamily.replace("{server}", wechat_base_url)
|
|
|
.replace("{appId}",appId);
|
|
|
.replace("{appId}", appId);
|
|
|
//图片地址
|
|
|
picUrlFamily = picUrlFamily.replace("{server}",serverUrl);
|
|
|
picUrlFamily = picUrlFamily.replace("{server}", serverUrl);
|
|
|
|
|
|
articleFamily.put("Url", urlFamily);
|
|
|
articleFamily.put("Title", "我的家庭功能使用说明");
|
|
@ -400,13 +424,13 @@ public class WeiXinEventProcess {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 微信扫码事件处理
|
|
|
* 微信扫码事件处理(封装图文消息体)
|
|
|
*
|
|
|
* @param message
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
private String scanEventProcess(Map<String, String> message) throws Exception {
|
|
|
private String scanEventProcess(Map<String, String> message) throws Exception {
|
|
|
String result = "";
|
|
|
// 场景值
|
|
|
String eventKey = message.get("EventKey");
|
|
@ -461,7 +485,7 @@ public class WeiXinEventProcess {
|
|
|
String[] keys = eventKey.replace("qrscene_hs_", "").replace("hs_", "").split("_");
|
|
|
|
|
|
// 图文消息URL
|
|
|
url = url.replace("{server}",wechat_base_url)
|
|
|
url = url.replace("{server}", wechat_base_url)
|
|
|
.replace("{appId}", appId)
|
|
|
.replace("{hospital}", keys[0] + ":" + keys[1]);
|
|
|
//图片地址
|
|
@ -496,7 +520,7 @@ public class WeiXinEventProcess {
|
|
|
|
|
|
// 图文消息URL
|
|
|
url = url.replace("{server}", wechat_base_url)
|
|
|
.replace("{appId}",appId)
|
|
|
.replace("{appId}", appId)
|
|
|
.replace("{town}", keys[0]);
|
|
|
//图片地址
|
|
|
picUrl = picUrl.replace("{server}", serverUrl);
|
|
@ -514,6 +538,20 @@ public class WeiXinEventProcess {
|
|
|
articles.add(videoText);
|
|
|
// 消息XML
|
|
|
result = WeiXinMessageReplyUtils.replyNewsMessage(message.get("FromUserName"), message.get("ToUserName"), articles);
|
|
|
} else if (StringUtils.isNotEmpty(eventKey) && (("wechat_ehc").equals(eventKey)) ||
|
|
|
eventKey.startsWith("qrscene_wechat_ehc")) {
|
|
|
System.out.println("第三方ehr扫描推送事件");
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("first", "first");
|
|
|
json.put("remark", "remark");
|
|
|
json.put("keyword1", "keyword1");
|
|
|
json.put("keyword2", "keyword2");
|
|
|
json.put("url", "www.baidu.com");
|
|
|
//跳转路径问题,如果是第三方不加本地服务器名称(要改push公用方法)
|
|
|
json.put("openId", message.get("FromUserName"));
|
|
|
json.put("type", 11);
|
|
|
//模板消息json串
|
|
|
result = json.toString();
|
|
|
}
|
|
|
|
|
|
return result;
|
|
@ -528,7 +566,7 @@ public class WeiXinEventProcess {
|
|
|
* @param description 图文描述
|
|
|
* @return
|
|
|
*/
|
|
|
public Map getNews(String url, String picUrl, String title, String description) {
|
|
|
public Map getNews(String url, String picUrl, String title, String description) {
|
|
|
Properties systemConf = SystemConf.getInstance().getSystemProperties();
|
|
|
Map<String, String> news = new HashMap<>();
|
|
|
// 图文URL
|
|
@ -536,8 +574,8 @@ public class WeiXinEventProcess {
|
|
|
// 图文消息图片URL
|
|
|
String pictureUrl = systemConf.getProperty(picUrl);
|
|
|
// URL设置服务器URL、AppId
|
|
|
targetUrl = targetUrl.replace("{server}",wechat_base_url)
|
|
|
.replace("{appId}",appId);
|
|
|
targetUrl = targetUrl.replace("{server}", wechat_base_url)
|
|
|
.replace("{appId}", appId);
|
|
|
//图片地址
|
|
|
pictureUrl = pictureUrl.replace("{server}", serverUrl);
|
|
|
System.out.println("url ====> " + targetUrl);
|
|
@ -559,7 +597,7 @@ public class WeiXinEventProcess {
|
|
|
* @param message
|
|
|
* @return
|
|
|
*/
|
|
|
public String replyKeyword(Map<String, String> message) throws Exception {
|
|
|
public String replyKeyword(Map<String, String> message) throws Exception {
|
|
|
String result = "";
|
|
|
String description = "您的家庭医生签约将于6月30日到期,为了能继续给您提供健康服务,诚邀您续签家庭医生。";
|
|
|
String description1 = "为了能给您提供健康服务,诚邀您签签约家庭医生。";
|