Selaa lähdekoodia

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

chenweida 8 vuotta sitten
vanhempi
commit
adf902d4d5

+ 34 - 23
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/SendNews.java

@ -41,14 +41,13 @@ public class SendNews {
     *
     * @param url      请求地址 form表单url地址
     * @param filePath 文件在服务器保存路径
     * @return String url的响应信息返回值
     * @return String 上传的图片地址
     * @throws IOException
     */
    public static String uploadImage(String url, String filePath) throws IOException {
        String result = null;
        filePath = "http:///ehr.yihu.com/wlyy/images/renew.png";
        File file = new File(filePath);
        System.out.println("file  ====> "+file);
        System.out.println("file  ====> " + file);
        if (!file.exists() || !file.isFile()) {
            throw new IOException("文件不存在");
        }
@ -127,7 +126,6 @@ public class SendNews {
        return result;
    }
    /**
     * 上传图文消息文字素材
     *
@ -137,8 +135,10 @@ public class SendNews {
     */
    public static String uploadNesText(String accessToken, String url, JSONObject data) throws Exception {
        url = url.replaceFirst("ACCESS_TOKEN", accessToken);
        System.out.print("data======> " + data);
        //上传的图文消息数据,其中thumb_media_id是文件上传图片上传的id
        String result = HttpClientUtil.postBody(url, data);
        System.out.println("result ========> " + result);
        return result;
    }
@ -159,46 +159,54 @@ public class SendNews {
        // 配置信息
        Properties systemConf = SystemConf.getInstance().getSystemProperties();
        //本地上传图片的路径及跳转路径
        String renewPath = systemConf.getProperty("patient_sign_again_pic_url");
        renewPath = renewPath.replace("{server}", systemConf.getProperty("server_url"));
        String renewPath = systemConf.getProperty("renew_path");
        String renewUrl = systemConf.getProperty("patient_sign_again_url");
        renewUrl = renewUrl.replaceAll("\\{server\\}", SystemConf.getInstance().getSystemProperties().getProperty("wechat_base_url"));
        renewUrl = renewUrl.replaceAll("\\{appId\\}", SystemConf.getInstance().getSystemProperties().getProperty("appId"));
        renewUrl = renewUrl.replaceAll("amp;","");
        renewUrl = renewUrl.replaceAll(";","&");
        String signPath = systemConf.getProperty("doctor_qrcode_pic_url");
        signPath = signPath.replace("{server}", systemConf.getProperty("server_url"));
        String signPath = systemConf.getProperty("sign_path");
        String signUrl = systemConf.getProperty("doctor_subscribe_url");
        signUrl = signUrl.replaceAll("\\{server\\}", SystemConf.getInstance().getSystemProperties().getProperty("wechat_base_url"));
        signUrl = signUrl.replaceAll("\\{appId\\}", SystemConf.getInstance().getSystemProperties().getProperty("appId"));
        signUrl = signUrl.replaceAll("amp;","");
        signUrl = signUrl.replaceAll(";","&");
        String sendUrl = "http://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token=ACCESS_TOKEN&type=image";
        String getMediaUrl = "http://file.api.weixin.qq.com/cgi-bin/media/upload?access_token=ACCESS_TOKEN&type=image";//由sendUrl获取远程图片的mediaId
        String mediaurl = "https://api.weixin.qq.com/cgi-bin/media/uploadnews?access_token=ACCESS_TOKEN";//ACCESS_TOKEN是获取到的access_token
        String groupUrl = "https://api.weixin.qq.com/cgi-bin/message/mass/send?access_token=ACCESS_TOKEN";//根据openid发群发消息地址
        sendUrl = sendUrl.replace("ACCESS_TOKEN", accessToken);
        System.out.println("renewPath --> "+renewPath);
        System.out.println("signPath  --> "+signPath);
        String renewImage = SendNews.uploadImage(sendUrl, renewPath);
        String signImage = SendNews.uploadImage(sendUrl, signPath);
        getMediaUrl = getMediaUrl.replace("ACCESS_TOKEN", accessToken);
        System.out.println("renewPath --> " + renewPath);
        System.out.println("signPath  --> " + signPath);
//
        String renewImage = SendNews.uploadImage(getMediaUrl, renewPath);
        String signImage = SendNews.uploadImage(getMediaUrl, signPath);
        System.out.println("renewImage==?" + renewImage);
        System.out.println("signImage==?" + signImage);
        JSONObject newsTextData = new JSONObject();
        JSONArray newsText = new JSONArray();
//            续签图文
        JSONObject data = new JSONObject();
        data.put("thumb_media_id", new JSONObject(renewImage).get("url"));
        data.put("author", "作者");
        data.put("thumb_media_id", new JSONObject(renewImage).get("media_id"));
        data.put("content_source_url", renewUrl);
        data.put("content", "续签图文消息内容");
        data.put("digest", "续签图文消息描述");
        data.put("content", "家庭医生续签提醒");
        data.put("title", "家庭医生续签提醒");
        data.put("show_cover_pic", 1);
//            签约图文
        JSONObject data1 = new JSONObject();
        data1.put("thumb_media_id", new JSONObject(signImage).get("url"));
//            data1.put("author","作者");
        data1.put("thumb_media_id", new JSONObject(signImage).get("media_id"));
        data1.put("content_source_url", signUrl);
        data1.put("content", "签约图文消息内容");
//            data1.put("digest","签约图文消息描述");
//            data1.put("show_cover_pic",1);
        data1.put("content", "欢迎关注厦门i健康,快来签约家庭医生吧~");
        data1.put("title", "欢迎关注厦门i健康,快来签约家庭医生吧~");
        data1.put("show_cover_pic", 1);
        newsText.put(data1);
        newsText.put(data);
        newsTextData.put("articles", newsText);
        String media = SendNews.uploadNesText(accessToken, mediaurl, newsTextData);
        System.out.println("media+++++>" + media);
        JSONObject news = new JSONObject();
        JSONObject mapnews = new JSONObject();
@ -209,6 +217,9 @@ public class SendNews {
        news.put("msgtype", "mpnews");
        news.put("send_ignore_reprint", 1);
        System.out.println("to go sign =====> "+signUrl);
        System.out.println("to go renew =====> "+renewUrl);
        SendNews.sendNewspMessage(accessToken, groupUrl, news);
    }

+ 13 - 0
patient-co-wlyy/src/main/resources/system.properties

@ -130,6 +130,11 @@ template_doctor_change=TNIDMjduVKgVL4-k71umYLpHROvFB8K6mmm8aZC_EH8
template_doctor_survey=IjQvzBy0PLeft2kN9mdBhACXPE9I_jyJywJ6B-JRxsY
#template_doctor_survey=fgYiMntj1amEkE8_GLUPmAIyssUAroJrNSHqvydt-PQ
#群发图文消息图片地址
renew_path=/usr/local/apache-tomcat-8.0.26/webapps/wlyy/images/renew.png
sign_path=/usr/local/apache-tomcat-8.0.26/webapps/wlyy/images/familycontract.png
#健康之路开放平台
yihu_OpenPlatform_url=http://ssotest.yihu.cn/OpenPlatform/cgiBin/1.0/
yihu_OpenPlatform_appId=9000276
@ -192,6 +197,10 @@ fastdfs_file_url=http://172.19.103.54:80/
##问卷调查
#template_doctor_survey=OqQXrb-e43_TJpq_70_K_y6vYJgY5mpjFYY4c5RWFP4
#
##群发图文消息图片地址
#renew_path=/usr/local/apache-tomcat-8.0.36/webapps/wlyy/images/renew.png
#sign_path=/usr/local/apache-tomcat-8.0.36/webapps/wlyy/images/familycontract.png
#
## FastDFS文件Http访问地址
#fastdfs_file_url=http://172.19.103.54:80/
#
@ -252,6 +261,10 @@ fastdfs_file_url=http://172.19.103.54:80/
#问卷调查
#template_doctor_survey=8ZWKJmoJ7VR7Uk4YS7aa0Z94QzCkxsyTW6R4CHhUJII
#群发图文消息图片地址
#renew_path=/usr/local/tomcat8/webapps/wlyy/images/renew.png
#sign_path=/usr/local/tomcat8/webapps/wlyy/images/familycontract.png
## FastDFS文件Http访问地址
#fastdfs_file_url=http://www.xmtyw.cn/