Browse Source

Merge branch 'dev' of wujunjie/patient-co-management into dev

lyr 8 years ago
parent
commit
a7f14541bd

+ 2 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/WeiXinCoreService.java

@ -76,6 +76,8 @@ public class WeiXinCoreService extends BaseService{
            case WeiXinMessageUtils.REQ_MESSAGE_TYPE_EVENT:  // 事件消息
                result = WeiXinEventProcess.eventProcess(message);
                break;
            case WeiXinMessageUtils.EVENT_TYPE_CLICK: //菜单点击
                result = WeiXinEventProcess.clickProcess(message);
            default:
                break;
        }

+ 188 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/wechat/process/WeiXinEventProcess.java

@ -46,18 +46,132 @@ public class WeiXinEventProcess {
    }
    /**
     * 关注事件消息发送
     * 微信菜单点击处理
     *
     * @param message
     * @return
     */
    public static String clickProcess(Map<String, String> message) throws Exception {
        String result = "";
        if(message.get("EventKey").equals("caozuoshuoming")){
            String tempStr = clickEventProcess(message);
            /*int firsIndex = tempStr.indexOf("<item>");
            String result1 = tempStr.substring(0,firsIndex-1);
            int secondIndex = tempStr.indexOf("<item>",firsIndex+10);
            String result2 = tempStr.substring(secondIndex-1);*/
            result=tempStr.replace("<ArticleCount>5</ArticleCount>","<ArticleCount>4</ArticleCount>");
        }
        return result;
    }
    /**
     * 菜单点击消息发送
     *
     * @param message
     * @return
     * @throws Exception
     */
    private static String clickEventProcess(Map<String,String> message) throws Exception{
        String result = "";
        // 配置信息
        Properties systemConf = SystemConf.getInstance().getSystemProperties();
        // 图文信息
        List<Map<String,String>> articles =  new ArrayList<>();
        Map<String,String> articleConsult = new HashMap<>();
        // 图文URL
        String urlConsult = systemConf.getProperty("patient_consult_url");
        // 图文消息图片URL
        String picUrlConsult = systemConf.getProperty("patient_operatinginstrutions_pic_url");
        // URL设置服务器URL、AppId
        urlConsult = urlConsult.replace("{server}", systemConf.getProperty("wechat_base_url"))
                .replace("{appId}", systemConf.getProperty("appId"));
        //图片地址
        picUrlConsult = picUrlConsult.replace("{server}", systemConf.getProperty("server_url"));
        articleConsult.put("Url",urlConsult);
        articleConsult.put("Title", "医生咨询功能使用说明");
        articleConsult.put("Description","功能使用说明");
        articleConsult.put("PicUrl",picUrlConsult);
        articles.add(articleConsult);
        Map<String,String> articleBooking = new HashMap<>();
        // 图文URL
        String urlBooking = systemConf.getProperty("patient_booking_url");
        // 图文消息图片URL
        String picUrlBooking = systemConf.getProperty("patient_operatinginstrutions_pic_url");
        // URL设置服务器URL、AppId
        urlBooking = urlBooking.replace("{server}", systemConf.getProperty("wechat_base_url"))
                .replace("{appId}", systemConf.getProperty("appId"));
        //图片地址
        picUrlBooking = picUrlBooking.replace("{server}", systemConf.getProperty("server_url"));
        articleBooking.put("Url",urlBooking);
        articleBooking.put("Title", "预约挂号功能使用说明");
        articleBooking.put("Description","功能使用说明");
        articleBooking.put("PicUrl",picUrlBooking);
        articles.add(articleBooking);
        Map<String,String> articleDevice = new HashMap<>();
        // 图文URL
        String urlDevice = systemConf.getProperty("patient_device_url");
        // 图文消息图片URL
        String picUrlDevice = systemConf.getProperty("patient_operatinginstrutions_pic_url");
        // URL设置服务器URL、AppId
        urlDevice = urlDevice.replace("{server}", systemConf.getProperty("wechat_base_url"))
                .replace("{appId}", systemConf.getProperty("appId"));
        //图片地址
        picUrlDevice = picUrlDevice.replace("{server}", systemConf.getProperty("server_url"));
        articleDevice.put("Url",urlDevice);
        articleDevice.put("Title", "体征设备管理功能使用说明");
        articleDevice.put("Description","功能使用说明");
        articleDevice.put("PicUrl",picUrlDevice);
        articles.add(articleDevice);
        Map<String,String> articleFamily = new HashMap<>();
        // 图文URL
        String urlFamily = systemConf.getProperty("patient_family_url");
        // 图文消息图片URL
        String picUrlFamily = systemConf.getProperty("patient_operatinginstrutions_pic_url");
        // URL设置服务器URL、AppId
        urlFamily = urlFamily.replace("{server}", systemConf.getProperty("wechat_base_url"))
                .replace("{appId}", systemConf.getProperty("appId"));
        //图片地址
        picUrlFamily = picUrlFamily.replace("{server}", systemConf.getProperty("server_url"));
        articleFamily.put("Url",urlFamily);
        articleFamily.put("Title", "我的家庭功能使用说明");
        articleFamily.put("Description","功能使用说明");
        articleFamily.put("PicUrl",picUrlFamily);
        articles.add(articleFamily);
        // 构建回复消息XML
        result = WeiXinMessageReplyUtils.replyNewsMessage(message.get("FromUserName"),message.get("ToUserName"),articles);
        return result;
    }
    /**
     * 关注事件消息发送
     * @param message
     * @return
     * @throws Exception
     */
    private static String subscribeEventProcess(Map<String,String> message) throws Exception{
        String result = "";
        // 配置信息
        Properties systemConf = SystemConf.getInstance().getSystemProperties();
        // 图文信息
        List<Map<String,String>> articles =  new ArrayList<>();
        Map<String,String> article = new HashMap<>();
        // 图文URL
        String url = systemConf.getProperty("doctor_subscribe_url");
@ -75,6 +189,79 @@ public class WeiXinEventProcess {
        article.put("PicUrl",picUrl);
        articles.add(article);
        Map<String,String> articleConsult = new HashMap<>();
        // 图文URL
        String urlConsult = systemConf.getProperty("patient_consult_url");
        // 图文消息图片URL
        String picUrlConsult = systemConf.getProperty("patient_operatinginstrutions_pic_url");
        // URL设置服务器URL、AppId
        urlConsult = urlConsult.replace("{server}", systemConf.getProperty("wechat_base_url"))
                .replace("{appId}", systemConf.getProperty("appId"));
        //图片地址
        picUrlConsult = picUrlConsult.replace("{server}", systemConf.getProperty("server_url"));
        articleConsult.put("Url",urlConsult);
        articleConsult.put("Title", "医生咨询功能使用说明");
        articleConsult.put("Description","功能使用说明");
        articleConsult.put("PicUrl",picUrlConsult);
        articles.add(articleConsult);
        Map<String,String> articleBooking = new HashMap<>();
        // 图文URL
        String urlBooking = systemConf.getProperty("patient_booking_url");
        // 图文消息图片URL
        String picUrlBooking = systemConf.getProperty("patient_operatinginstrutions_pic_url");
        // URL设置服务器URL、AppId
        urlBooking = urlBooking.replace("{server}", systemConf.getProperty("wechat_base_url"))
                .replace("{appId}", systemConf.getProperty("appId"));
        //图片地址
        picUrlBooking = picUrlBooking.replace("{server}", systemConf.getProperty("server_url"));
        articleBooking.put("Url",urlBooking);
        articleBooking.put("Title", "预约挂号功能使用说明");
        articleBooking.put("Description","功能使用说明");
        articleBooking.put("PicUrl",picUrlBooking);
        articles.add(articleBooking);
        Map<String,String> articleDevice = new HashMap<>();
        // 图文URL
        String urlDevice = systemConf.getProperty("patient_device_url");
        // 图文消息图片URL
        String picUrlDevice = systemConf.getProperty("patient_operatinginstrutions_pic_url");
        // URL设置服务器URL、AppId
        urlDevice = urlDevice.replace("{server}", systemConf.getProperty("wechat_base_url"))
                .replace("{appId}", systemConf.getProperty("appId"));
        //图片地址
        picUrlDevice = picUrlDevice.replace("{server}", systemConf.getProperty("server_url"));
        articleDevice.put("Url",urlDevice);
        articleDevice.put("Title", "体征设备管理功能使用说明");
        articleDevice.put("Description","功能使用说明");
        articleDevice.put("PicUrl",picUrlDevice);
        articles.add(articleDevice);
        Map<String,String> articleFamily = new HashMap<>();
        // 图文URL
        String urlFamily = systemConf.getProperty("patient_family_url");
        // 图文消息图片URL
        String picUrlFamily = systemConf.getProperty("patient_operatinginstrutions_pic_url");
        // URL设置服务器URL、AppId
        urlFamily = urlFamily.replace("{server}", systemConf.getProperty("wechat_base_url"))
                .replace("{appId}", systemConf.getProperty("appId"));
        //图片地址
        picUrlFamily = picUrlFamily.replace("{server}", systemConf.getProperty("server_url"));
        articleFamily.put("Url",urlFamily);
        articleFamily.put("Title", "我的家庭功能使用说明");
        articleFamily.put("Description","功能使用说明");
        articleFamily.put("PicUrl",picUrlFamily);
        articles.add(articleFamily);
        // 构建回复消息XML
        result = WeiXinMessageReplyUtils.replyNewsMessage(message.get("FromUserName"),message.get("ToUserName"),articles);

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/wechat/util/WeiXinMessageReplyUtils.java

@ -31,7 +31,7 @@ public class WeiXinMessageReplyUtils {
        result.append("<FromUserName>" + fromUser + "</FromUserName>");
        result.append("<CreateTime>" + new Date().getTime() + "</CreateTime>");
        result.append("<MsgType>news</MsgType>");
        result.append("<ArticleCount>1</ArticleCount>");
        result.append("<ArticleCount>5</ArticleCount>");
        result.append("<Articles>");
        for(Map<String,String>  article : articles){

+ 9 - 1
patient-co-wlyy/src/main/resources/system.properties

@ -19,6 +19,14 @@ doctor_town_qrcode_url=https://open.weixin.qq.com/connect/oauth2/authorize?appid
doctor_qrcode_pic_url={server}/images/familycontract.png
doctor_invitel_url=https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&redirect_uri={server}%2fwx%2fhtml%2fssgg%2fhtml%2fdoctor-homepage-new.html&response_type=code&scope=snsapi_base&state={doctorCode}__{invilogcode}__{currentPatient}__{currentZH}__{currentName}#wechat_redirect
patient_operatinginstrutions_pic_url={server}/images/operatinginstructions.png
patient_consult_url=https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri={server}%2fwx%2fhtml%2fqygl%2fhtml%2f/wx/html/introduction/html/yszx.html&amp;response_type=code&amp;scope=snsapi_base&amp;state=code#wechat_redirect
patient_booking_url=https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri={server}%2fwx%2fhtml%2fqygl%2fhtml%2f/wx/html/introduction/html/yygh.html&amp;response_type=code&amp;scope=snsapi_base&amp;state=code#wechat_redirect
patient_device_url=https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri={server}%2fwx%2fhtml%2fqygl%2fhtml%2f/wx/html/introduction/html/tzsb.html&amp;response_type=code&amp;scope=snsapi_base&amp;state=code#wechat_redirect
patient_family_url=https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri={server}%2fwx%2fhtml%2fqygl%2fhtml%2f/wx/html/introduction/html/family.html&amp;response_type=code&amp;scope=snsapi_base&amp;state=code#wechat_redirect
# SMS短信配置
yihu_sms_url=https://smsapi.ums86.com:9600/sms/Api/Send.do
yihu_sms_code=229336
@ -58,7 +66,7 @@ im_list_get=http://172.19.103.29:3000/
im_group_server=http://172.19.103.29:3000/api/v1/chats/gm
msg_push_server=http://172.19.103.29:3000/api/v1/chats/sm
# 微信基本配置
# 微信基本配置 wxb3827510b2e15012 c5bdedd909ded9c2ee08028487e6f50d
appId=wxd03f859efdf0873d
appSecret=2935b54b53a957d9516c920a544f2537
wechat_base_url=http%3a%2f%2fweixin.xmtyw.cn%2fwlyy

+ 6 - 1
patient-co-wlyy/src/main/resources/weixin_menu.txt

@ -78,7 +78,12 @@
		   "type":"view",
		   "name":"我的预约",
		   "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fwdyy%2fhtml%2fmy-appointment.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		}
		},
        {
         	"type":"click",
         	"name":"操作说明",
         	"key":"caozuoshuoming"
        }
	 ]
  }
]

BIN
patient-co-wlyy/src/main/webapp/images/operatinginstructions.png