|
@@ -123,34 +123,38 @@ public class FollowRecordServiceImpl extends ServiceImpl<FollowRecordMapper, Fol
|
|
|
|
|
|
@Override
|
|
|
public void sendMessage(FollowRecord record) {
|
|
|
- JSONObject jsonObject = JSONUtil.parseObj(HttpUtil.get("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + env.getProperty("wx.appid") + "&secret=" + env.getProperty("wx.appSecret")));
|
|
|
- JSONObject body = new JSONObject();
|
|
|
- body.set("appid", env.getProperty("wx.appid"));
|
|
|
- JSONObject content = new JSONObject();
|
|
|
- User user = userService.selectUserByPatientId(record.getPatientId());
|
|
|
- if (user == null) {
|
|
|
- return;
|
|
|
+ try {
|
|
|
+ JSONObject jsonObject = JSONUtil.parseObj(HttpUtil.get("https://api.weixin.qq.com:4430/cgi-bin/token?grant_type=client_credential&appid=" + env.getProperty("wx.appid") + "&secret=" + env.getProperty("wx.appSecret")));
|
|
|
+ JSONObject body = new JSONObject();
|
|
|
+ body.set("appid", env.getProperty("wx.appid"));
|
|
|
+ JSONObject content = new JSONObject();
|
|
|
+ User user = userService.selectUserByPatientId(record.getPatientId());
|
|
|
+ if (user == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ body.set("touser", user.getOpenId());
|
|
|
+ body.set("page", "pages/user/index?patientId=" + record.getPatientId());
|
|
|
+ //复查提醒
|
|
|
+ if (record.getType() == 0) {
|
|
|
+ body.set("template_id", "S6JARkInVBjID8QMpgZdSHNyxeMDZQq7lur8YrNK0oY");
|
|
|
+ content.set("thing1", new JSONObject().set("value", record.getTemplateName()));//复查提醒名称
|
|
|
+ content.set("thing3", new JSONObject().set("value", "岑溪人民医院"));//复查机构
|
|
|
+ content.set("thing6", new JSONObject().set("value", StringUtils.truncateTo12Chars(record.getOp())));//备注
|
|
|
+ }
|
|
|
+ //随访提醒
|
|
|
+ if (record.getType() == 1) {
|
|
|
+ body.set("template_id", "1Jvx8F22na-tG2Q6HFX_3vRtbiv7zZko6NwX8ICIFXc");
|
|
|
+ content.set("thing11", new JSONObject().set("value", record.getTemplateName()));//随访名称
|
|
|
+ content.set("thing2", new JSONObject().set("value", "岑溪人民医院"));//随访机构
|
|
|
+ content.set("phrase3", new JSONObject().set("value", record.getPatientName()));//就诊人
|
|
|
+ }
|
|
|
+ body.set("data", content);
|
|
|
+ String result = HttpUtil.post("https://api.weixin.qq.com:4430/cgi-bin/message/subscribe/send?access_token=" + jsonObject.getStr("access_token"), body.toString());
|
|
|
+ System.out.println("body:" + body);
|
|
|
+ System.out.println("小程序订阅消息:" + result);
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println("小程序订阅消息发送失败");
|
|
|
}
|
|
|
- body.set("touser", user.getOpenId());
|
|
|
- body.set("page", "pages/user/index?patientId=" + record.getPatientId());
|
|
|
- //复查提醒
|
|
|
- if (record.getType() == 0) {
|
|
|
- body.set("template_id", "S6JARkInVBjID8QMpgZdSHNyxeMDZQq7lur8YrNK0oY");
|
|
|
- content.set("thing1", new JSONObject().set("value", record.getTemplateName()));//复查提醒名称
|
|
|
- content.set("thing3", new JSONObject().set("value", "岑溪人民医院"));//复查机构
|
|
|
- content.set("thing6", new JSONObject().set("value", StringUtils.truncateTo12Chars(record.getOp())));//备注
|
|
|
- }
|
|
|
- //随访提醒
|
|
|
- if (record.getType() == 1) {
|
|
|
- body.set("template_id", "1Jvx8F22na-tG2Q6HFX_3vRtbiv7zZko6NwX8ICIFXc");
|
|
|
- content.set("thing11", new JSONObject().set("value", record.getTemplateName()));//随访名称
|
|
|
- content.set("thing2", new JSONObject().set("value", "岑溪人民医院"));//随访机构
|
|
|
- content.set("phrase3", new JSONObject().set("value", record.getPatientName()));//就诊人
|
|
|
- }
|
|
|
- body.set("data", content);
|
|
|
- String result = HttpUtil.post("https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + jsonObject.getStr("access_token"), body.toString());
|
|
|
- System.out.println("body:" + body);
|
|
|
- System.out.println("小程序订阅消息:" + result);
|
|
|
}
|
|
|
|
|
|
@Override
|