You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
464 lines
22 KiB
464 lines
22 KiB
package com.ynxbd.wx.wxfactory.utils;
|
|
|
|
import com.ynxbd.common.helper.common.ErrorHelper;
|
|
import com.ynxbd.wx.config.WeChatConfig;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
import weixin.popular.bean.xmlmessage.XMLImageMessage;
|
|
import weixin.popular.bean.xmlmessage.XMLNewsMessage;
|
|
import weixin.popular.bean.xmlmessage.XMLTextMessage;
|
|
import weixin.popular.support.ExpireKey;
|
|
import weixin.popular.support.expirekey.DefaultExpireKey;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import java.io.OutputStream;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* 微信被动回复推送
|
|
*/
|
|
@Slf4j
|
|
public class WxPassiveReplyHelper {
|
|
public static final String MSG_TYPE_TEXT = "text";
|
|
public static final String MSG_TYPE_IMAGE = "image";
|
|
public static final String MSG_TYPE_VOICE = "voice";
|
|
public static final String MSG_TYPE_VIDEO = "video";
|
|
public static final String MSG_TYPE_LINK = "link";
|
|
public static final String MSG_TYPE_LOCATION = "location";
|
|
public static final String MSG_TYPE_EVENT = "event";
|
|
|
|
// 订阅
|
|
public static final String EVENT_SUBSCRIBE = "subscribe";
|
|
// 取消订阅
|
|
public static final String EVENT_UNSUB = "unsubscribe";
|
|
public static final String EVENT_CLICK = "CLICK";
|
|
public static final String EVENT_VIEW = "VIEW";
|
|
|
|
// 重复通知过滤
|
|
private static ExpireKey EXPIRE_KEY;
|
|
|
|
final public static String SUCCESS = "success";
|
|
|
|
private synchronized static void getExpireKey() {
|
|
if (EXPIRE_KEY == null) {
|
|
EXPIRE_KEY = new DefaultExpireKey();
|
|
}
|
|
}
|
|
|
|
// 消息通知过滤
|
|
public static boolean isRepeat(String key) {
|
|
if (EXPIRE_KEY == null) {
|
|
getExpireKey();
|
|
}
|
|
if (EXPIRE_KEY.exists(key)) {
|
|
log.info("[公众号]重复通知不处理");
|
|
return true;
|
|
} else {
|
|
EXPIRE_KEY.add(key);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* 文字匹配
|
|
*
|
|
* @return
|
|
*/
|
|
public static boolean textCommon(HttpServletResponse response, String content, String msgType, String fromUserName, String toUserName) {
|
|
String webUrl = WeChatConfig.getWebUrl();
|
|
|
|
if (Arrays.asList(new String[]{
|
|
"缓",
|
|
"缓存",
|
|
"用不了",
|
|
"页面",
|
|
"404",
|
|
"进不去"
|
|
}).contains(content)) {
|
|
return createLinkMsg(response, fromUserName, toUserName, "公众号用不了(缓存清理)", msgType, content,
|
|
(webUrl + "wx-cache.html"),
|
|
(webUrl + "images/message/cache.png"));
|
|
}
|
|
|
|
if (Arrays.asList(new String[]{
|
|
"你好",
|
|
"链接",
|
|
"指引",
|
|
"微官网",
|
|
}).contains(content)) {
|
|
return createLinkMsg(response, fromUserName, toUserName, "微官网链接", msgType, content,
|
|
(webUrl + "app.html"),
|
|
(webUrl + "images/message/hospital.png"));
|
|
}
|
|
|
|
if (Arrays.asList(new String[]{
|
|
"查",
|
|
"查询",
|
|
"报告"
|
|
}).contains(content)) {
|
|
return createLinkMsg(response, fromUserName, toUserName, "报告单查询", msgType, content,
|
|
(webUrl + "all-result.html"),
|
|
(webUrl + "images/message/report.png"));
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* 关注
|
|
*
|
|
* @param response
|
|
* @param content
|
|
* @param msgType
|
|
* @param fromUserName
|
|
* @param toUserName
|
|
* @return
|
|
*/
|
|
public static boolean subscribeCommon(HttpServletResponse response, String content, String msgType, String fromUserName, String toUserName, String event) {
|
|
|
|
log.info("event={}", event);
|
|
if (WxPassiveReplyHelper.EVENT_SUBSCRIBE.equals(event)) {
|
|
String webUrl = WeChatConfig.getWebUrl();
|
|
return createLinkMsg(response, fromUserName, toUserName, "清廉承诺", msgType, content,
|
|
(webUrl + "wx-subscribe.html"),
|
|
(webUrl + "images/message/subscribe.png"));
|
|
}
|
|
return false;
|
|
}
|
|
|
|
|
|
public static void 芒市人民医院(HttpServletResponse response, String content, String msgType, String fromUserName, String toUserName, String eventKey, String event) {
|
|
List<XMLNewsMessage.Article> articleList = new ArrayList<>();
|
|
XMLNewsMessage.Article article;
|
|
|
|
if (WxPassiveReplyHelper.MSG_TYPE_EVENT.equals(msgType)) {
|
|
if (WxPassiveReplyHelper.EVENT_SUBSCRIBE.equals(event)) {
|
|
article = new XMLNewsMessage.Article();
|
|
article.setTitle("微信预约挂号开通喽,大家快快用起来!");
|
|
article.setUrl("https://mp.weixin.qq.com/s/rJF1qBo1-mV5CUdRsi4Z5g");
|
|
article.setPicurl("https://mmbiz.qpic.cn/mmbiz_jpg/RUm4m8SVypy7nVubUuo6KgdlibcduK8l4tWnXrz7VfTO5EYOeDc9hZxR70wTQgX1sYhRR7SeND6426uczdpf1BA/0?wx_fmt=jpeg");
|
|
articleList.add(article);
|
|
XMLNewsMessage xmlNewsMessage = new XMLNewsMessage(fromUserName, toUserName, articleList);
|
|
xmlNewsMessage.outputStreamWrite(getOut(response));
|
|
}
|
|
}
|
|
|
|
String respInfo;
|
|
|
|
if (content != null) {
|
|
if (content.contains("放射") || content.contains("影像") || content.contains("CT") || content.contains("核磁")) {
|
|
respInfo = "放射科:2116611、18869202310(值班)";
|
|
|
|
} else if (content.contains("B超")) {
|
|
respInfo = "B超室:2121651、18869202311(值班)";
|
|
|
|
} else if (content.contains("检验") || content.contains("化验") || content.contains("生化") || content.contains("免疫")) {
|
|
respInfo = "检验科:2130240";
|
|
|
|
} else if (content.contains("口 腔")) {
|
|
respInfo = "口腔科:2139404";
|
|
|
|
} else if (content.contains("皮肤")) {
|
|
respInfo = "皮肤科:2129260";
|
|
|
|
} else if (content.contains("急诊")) {
|
|
respInfo = "急诊科:2103068(护士站)";
|
|
|
|
} else if (content.contains("外三") || content.contains("泌尿")) {
|
|
respInfo = "外三科(泌尿):2113501(护士站)";
|
|
|
|
} else if (content.contains("麻醉")) {
|
|
respInfo = "麻醉科:18869202309";
|
|
|
|
} else if (content.contains("妇产") || content.contains("产科") || content.contains("妇科")) {
|
|
respInfo = "妇产科:2113504(护士站)";
|
|
|
|
} else if (content.contains("感染") || content.contains("传染")) {
|
|
respInfo = "感染科:2116031";
|
|
|
|
} else if (content.contains("内二")) {
|
|
respInfo = "内二科:2113503(护士站)";
|
|
|
|
} else if (content.contains("内一")) {
|
|
respInfo = "内一科:2113500(护士站)";
|
|
|
|
} else if (content.contains("外二") || content.contains("骨科")) {
|
|
respInfo = "外二科(骨 科):2122450(护士站) ";
|
|
|
|
} else if (content.contains("儿") || content.contains("儿科")) {
|
|
respInfo = "儿科:2122381(护士站)";
|
|
|
|
} else if (content.contains("康复")) {
|
|
respInfo = "康复科:2116167(护士站)";
|
|
|
|
} else if (content.contains("体检")) {
|
|
respInfo = "体检科:2917280、18288102873";
|
|
|
|
} else if (content.contains("120") || content.contains("急救")) {
|
|
respInfo = "120急救中心:2107120";
|
|
|
|
} else if (content.contains("外一") || content.contains("普外")) {
|
|
respInfo = "外一科(普外):2133720";
|
|
|
|
} else {
|
|
respInfo = "办公室:2122460\n" +
|
|
"行政值班:18869202307\n" +
|
|
"放射科:2116611、18869202310(值班)\n\n" +
|
|
"B超室:2121651、 18869202311(值班)\n\n" +
|
|
"儿 科:2122381(护士站)\n" +
|
|
"康复科:2116167(护士站)\n" +
|
|
"检验科:2130240\n" +
|
|
"口腔科:2139404\n" +
|
|
"皮肤科:2129260\n" +
|
|
"麻醉科:18869202309\n" +
|
|
"感染科:2116031,\n" +
|
|
"急诊科:2103068(护士站)\n" +
|
|
"妇产科:2113504(护士站)\n" +
|
|
"内二科:2113503(护士站)\n" +
|
|
"内一科:2113500(护士站)\n" +
|
|
"外二科(骨 科):2122450(护士站)\n" +
|
|
"外三科(泌 尿):2113501(护士站)\n\n" +
|
|
"体检科:2917280、18288102873\n" +
|
|
"120急救中心:2107120,\n" +
|
|
"外一科(普外):2133720";
|
|
}
|
|
XMLTextMessage msg = new XMLTextMessage(fromUserName, toUserName, respInfo);
|
|
msg.outputStreamWrite(getOut(response));
|
|
}
|
|
}
|
|
|
|
public static void 华坪县人民医院(HttpServletResponse response, String content, String msgType, String fromUserName, String toUserName, String eventKey, String event) {
|
|
List<XMLNewsMessage.Article> articleList = new ArrayList<>();
|
|
XMLNewsMessage.Article article;
|
|
|
|
if (content != null) {
|
|
String webUrl = WeChatConfig.getWebUrl();
|
|
if (content.equals("支付") || content.equals("微信支付") || content.contains("费")) {
|
|
article = new XMLNewsMessage.Article();
|
|
article.setTitle("微信支付");
|
|
article.setPicurl("http://mmbiz.qpic.cn/mmbiz/0jg8QrIOHOydg7liaUzXoa7otFCiavYozxARcpnrxt5ibQ7Y8BewUOtKJPWRUATkaskjvHeeqmicDbovRwZic7BTSng/0?wx_fmt=jpeg");
|
|
article.setDescription("请点这里进入支付页面,支付您的账单,不用再去排队缴费。如需查看检查结果,请输入“检查”。如需查看化验结果,请输入“化验”。");
|
|
article.setUrl(webUrl + "pay-info.html");
|
|
articleList.add(article);
|
|
|
|
} else if (content.equals("检查") || content.equals("检验") || content.equals("化验")) {
|
|
article = new XMLNewsMessage.Article();
|
|
article.setTitle("查看检查结果");
|
|
article.setPicurl("http://mmbiz.qpic.cn/mmbiz/0jg8QrIOHOydg7liaUzXoa7otFCiavYozxARcpnrxt5ibQ7Y8BewUOtKJPWRUATkaskjvHeeqmicDbovRwZic7BTSng/0?wx_fmt=jpeg");
|
|
article.setDescription("请点这里查看您的检查结果,如要查看化验结果,请输入“化验”或“检验”。如需缴费,请输入“支付”。");
|
|
article.setUrl(webUrl + "all-result.html");
|
|
articleList.add(article);
|
|
}
|
|
}
|
|
|
|
if (WxPassiveReplyHelper.MSG_TYPE_EVENT.equals(msgType)) {
|
|
if (eventKey.equals("MYDDC")) {
|
|
article = new XMLNewsMessage.Article();
|
|
article.setTitle("华坪县人民医院患者满意度调查");
|
|
article.setUrl("http://mp.weixin.qq.com/s/MCswklxDHdmYr3sFP70Xdw");
|
|
article.setPicurl("https://mmbiz.qpic.cn/mmbiz_jpg/0jg8QrIOHOwYlpPRQDFKpbFQsN2ibtZqcS9H9pqX4nOCzdaAHNiciaZubLF9jiayZJBV8ADxAqL6XdbpdqolJuwJIQ/640?wx_fmt=jpeg&tp=webp&wxfrom=5&wx_lazy=1");
|
|
articleList.add(article);
|
|
|
|
article = new XMLNewsMessage.Article();
|
|
article.setTitle("患者满意度调查");
|
|
article.setUrl("http://mp.weixin.qq.com/s/7l2YsE2Y-XSTWEXN7BJlIQ");
|
|
article.setPicurl("https://mmbiz.qpic.cn/mmbiz_jpg/0jg8QrIOHOzYGDMbzzyKicXD9QlRA5MdmpGgicibSdY0A4kmgV94qibuKylgRXbMgPb4zGNw9BvWqDXiby1XyFCFCaQ/640?wx_fmt=jpeg&tp=webp&wxfrom=5&wx_lazy=1");
|
|
articleList.add(article);
|
|
|
|
article = new XMLNewsMessage.Article();
|
|
article.setTitle("员工满意度调查");
|
|
article.setUrl("http://mp.weixin.qq.com/s/VyoOCM8FoEZ53ZQC3yX-Yw");
|
|
article.setPicurl("https://mmbiz.qpic.cn/mmbiz_jpg/0jg8QrIOHOzYGDMbzzyKicXD9QlRA5MdmpF19PW1oFibvCDj60twgfGC556fY3wThlAhIYJsHykiaDIU8h3Igh8Dw/640?wx_fmt=jpeg&tp=webp&wxfrom=5&wx_lazy=1");
|
|
articleList.add(article);
|
|
|
|
if (WxPassiveReplyHelper.EVENT_SUBSCRIBE.equals(event)) {
|
|
article = new XMLNewsMessage.Article();
|
|
article.setTitle("微信支付使用流程!");
|
|
article.setPicurl("http://mmbiz.qpic.cn/mmbiz/0jg8QrIOHOydg7liaUzXoa7otFCiavYozxARcpnrxt5ibQ7Y8BewUOtKJPWRUATkaskjvHeeqmicDbovRwZic7BTSng/0?wx_fmt=jpeg");
|
|
article.setDescription("首先关注微信公众号“华坪县人民医院”,其次打开公众号,点击“微信支付”,首次需进行身份绑定,按要求输入相关内容,获取账单;最多可以绑定除本人外加4个人,在身份绑定页面,点“添加绑定”");
|
|
|
|
articleList.add(article);
|
|
}
|
|
}
|
|
}
|
|
|
|
XMLNewsMessage msg = new XMLNewsMessage(fromUserName, toUserName, articleList);
|
|
msg.outputStreamWrite(getOut(response));
|
|
}
|
|
|
|
public static void 巍山县人民医院(HttpServletResponse response, String content, String msgType, String fromUserName, String toUserName, String eventKey, String event) {
|
|
|
|
List<XMLNewsMessage.Article> articleList = new ArrayList<>();
|
|
XMLNewsMessage.Article article;
|
|
|
|
if (WxPassiveReplyHelper.MSG_TYPE_EVENT.equals(msgType)) {
|
|
// 满意度
|
|
if (eventKey.equals("MYDDC")) {
|
|
article = new XMLNewsMessage.Article();
|
|
article.setTitle("巍山县人民医院患者满意度调查");
|
|
article.setUrl("https://mp.weixin.qq.com/s/R-tX9YtRRM9Hpw2rMmw2iQ");
|
|
article.setPicurl("https://mmbiz.qpic.cn/mmbiz_jpg/5kpYU2jcMVicvMfVRATtAKOEjh4A4VvtHmCMKgD9vAfr741FDDEwiccNdj2ZTicBibeeQZfwp6zbaYMI5ubib1TaaeA/640?wx_fmt=jpeg&tp=webp&wxfrom=5&wx_lazy=1");
|
|
articleList.add(article);
|
|
|
|
}
|
|
// 关注
|
|
if (WxPassiveReplyHelper.EVENT_SUBSCRIBE.equals(event)) {
|
|
article = new XMLNewsMessage.Article();
|
|
article.setTitle("微信预约挂号开通喽,大家快快用起来!");
|
|
article.setUrl("http://mp.weixin.qq.com/s/gl_NitQTP6_ZzoV8pwxOcw");
|
|
article.setPicurl("http://mmbiz.qpic.cn/mmbiz_jpg/5kpYU2jcMVicNybruqia0dn6kBqiakDlrTgDkweiafibyRl9uK6bkKoiaXib0xktJIywqTDzfe9fHcq5x0gggKkurDicpg/0?wx_fmt=jpeg");
|
|
articleList.add(article);
|
|
}
|
|
}
|
|
|
|
XMLNewsMessage msg = new XMLNewsMessage(fromUserName, toUserName, articleList);
|
|
msg.outputStreamWrite(getOut(response));
|
|
}
|
|
|
|
|
|
public static boolean 红河州第一人民医院(HttpServletResponse response, String content, String msgType, String fromUserName, String toUserName, String eventKey, String event) {
|
|
if (content == null) {
|
|
return false;
|
|
}
|
|
|
|
if (content.contains("食堂")) {
|
|
String webUrl = WeChatConfig.getWebUrl();
|
|
return createLinkMsg(response, fromUserName, toUserName, "食堂充值(温馨提示:第一次使用请进行电话号码绑定)", msgType, content,
|
|
("https://passport.whdc2002.com/"),
|
|
(webUrl + "images/message/food.png"));
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public static boolean 玉龙县人民医院(HttpServletResponse response, String content, String msgType, String fromUserName, String toUserName, String eventKey, String event) {
|
|
if (content == null) {
|
|
return false;
|
|
}
|
|
|
|
String respInfo;
|
|
if (content.contains("核酸")) {
|
|
respInfo = " 您好,玉龙县人民医院自助核酸检测需要点击微信挂号—自助核算检测进行具体操作。核酸检测报告电子版可在云南健康码查询," +
|
|
"纸质版可到门诊楼一楼自助打印,如标本检测有异常的,报告出具时间将延迟,如到时间后未查询到结果或有其他疑问可拨打0888-5180762进行咨询。" ;
|
|
|
|
} else if (content.contains("投诉")) {
|
|
respInfo = "您好,您可以拨打投诉电话:0888-5112778或行政值班电话:0888-5115602进行投诉";
|
|
|
|
} else if (content.contains("电话")) {
|
|
respInfo = "玉龙县人民医院行政值班电话:0888-5115602\n" +
|
|
"外一科(泌尿外科):0888-5156546\n" +
|
|
"外二科(普通外科、乳腺外科):0888-5172791\n" +
|
|
"外三科(骨科、神经外科):0888-5129570\n" +
|
|
"外四科(胸心血管外科):0888-5172632\n" +
|
|
"内一科(神经内分泌科):0888-5123615\n" +
|
|
"内二科(心血管内科):0888-5163257\n" +
|
|
"内三科(消化内科):0888-5179785\n" +
|
|
"内四科(感染性疾病科):0888-5102655\n" +
|
|
"内五科(呼吸与危重症医学科):0888-5390632\n" +
|
|
"中医科:0888-5110125\n" +
|
|
"妇产科:0888-5180763\n" +
|
|
"儿科:0888-5110667\n" +
|
|
"麻醉手术科:0888-5186925\n" +
|
|
"重症医学科:0888-5108252\n" +
|
|
"康复科:0888-5169002\n" +
|
|
"老年医学科:0888-5169002\n" +
|
|
"眼耳鼻喉科:0888-5186747\n" +
|
|
"急诊科:0888-5186934\n" +
|
|
"口腔科:0888-5179715\n" +
|
|
"体检科:0888-5182024\n" +
|
|
"医学检验科:0888-5180762\n" +
|
|
"超声医学科:0888-5116254\n" +
|
|
"医学影像科:0888-5187393\n" +
|
|
"药学部:0888-5122672\n" +
|
|
"内镜中心:0888-5304137\n";
|
|
|
|
} else if (content.contains("体检")) {
|
|
respInfo = "您好,您可以拨打体检科电话:0888-5182024进行详细咨询";
|
|
|
|
} else if (content.contains("退")) {
|
|
respInfo = "您好,退费需要持身份证到医院门诊楼一楼收费窗口办理";
|
|
|
|
} else if (content.contains("上班")) {
|
|
respInfo = "玉龙县人民医院上班时间:8:00—12:00 13:00—17:00";
|
|
|
|
} else {
|
|
respInfo = null;
|
|
}
|
|
|
|
if (respInfo == null) {
|
|
return false;
|
|
}
|
|
XMLTextMessage msg = new XMLTextMessage(fromUserName, toUserName, respInfo);
|
|
msg.outputStreamWrite(getOut(response));
|
|
return true;
|
|
}
|
|
|
|
public static void 德宏州妇幼保健院(HttpServletResponse response, String content, String msgType, String fromUserName, String toUserName, String eventKey, String event) {
|
|
if (WxPassiveReplyHelper.MSG_TYPE_EVENT.equals(msgType)) {
|
|
if (WxPassiveReplyHelper.EVENT_SUBSCRIBE.equals(event)) {
|
|
String respInfo ="您好!欢迎关注德宏州妇幼保健院!如有疑问请拨打 24小时值班电话:15368666599";
|
|
XMLTextMessage msg = new XMLTextMessage(fromUserName, toUserName, respInfo);
|
|
msg.outputStreamWrite(getOut(response));
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void 蒙自市妇幼保健院(HttpServletResponse response, String content, String msgType, String fromUserName, String toUserName, String eventKey, String event){
|
|
String mediaId = "iJoe834_vhMOnlrUUCQF5jyeRvOTJ0sF-ly_vZrsGzPqEFY0kvdzr_p410e-lG0K"; //医院科室对应电话列表图片
|
|
if (WxPassiveReplyHelper.MSG_TYPE_EVENT.equals(msgType)) {
|
|
if (WxPassiveReplyHelper.EVENT_SUBSCRIBE.equals(event)) {
|
|
XMLImageMessage imageMessage = new XMLImageMessage(fromUserName,toUserName, mediaId);
|
|
imageMessage.outputStreamWrite(getOut(response));
|
|
}
|
|
}
|
|
if(content==null){
|
|
return;
|
|
}
|
|
XMLImageMessage imageMessage = new XMLImageMessage(fromUserName,toUserName,mediaId);
|
|
imageMessage.outputStreamWrite(getOut(response));
|
|
}
|
|
public static OutputStream getOut(HttpServletResponse response) {
|
|
try {
|
|
return response.getOutputStream();
|
|
} catch (Exception e) {
|
|
ErrorHelper.println(e);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* 信息回复
|
|
*
|
|
* @param response
|
|
* @param fromUserName
|
|
* @param toUserName
|
|
* @param title
|
|
* @param msgType
|
|
* @param userText
|
|
* @param link
|
|
* @param imageUrl
|
|
* @return
|
|
*/
|
|
public static boolean createLinkMsg(HttpServletResponse response, String fromUserName, String toUserName, String title, String msgType, String userText, String link, String imageUrl) {
|
|
if (!MSG_TYPE_TEXT.equals(msgType)) { // 消息类型不为文本
|
|
return false;
|
|
}
|
|
|
|
if (ObjectUtils.isEmpty(userText)) { // 不存在
|
|
return false;
|
|
}
|
|
|
|
List<XMLNewsMessage.Article> articleList = new ArrayList<>();
|
|
XMLNewsMessage.Article article;
|
|
|
|
article = new XMLNewsMessage.Article();
|
|
article.setTitle(title);
|
|
article.setUrl(link);
|
|
article.setPicurl(imageUrl);
|
|
articleList.add(article);
|
|
XMLNewsMessage xmlNewsMessage = new XMLNewsMessage(fromUserName, toUserName, articleList);
|
|
xmlNewsMessage.outputStreamWrite(getOut(response));
|
|
return true;
|
|
}
|
|
|
|
}
|
|
|