From 2d2a46e85df4425a231bce33ef994a682d25cc49 Mon Sep 17 00:00:00 2001 From: yangjun <1173114630@qq.com> Date: Fri, 1 Dec 2023 21:05:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=8E=A8=E9=80=81=E5=8E=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/xml/KcBdgxbcopyMapper.xml | 20 +++--- .../SyncWechartTsxx.java | 2 +- .../jeecg/modules/wxgzh/WxgzhController.java | 63 +++++++++++++++++-- 3 files changed, 66 insertions(+), 19 deletions(-) diff --git a/jeecg-module-main/src/main/java/org/jeecg/modules/kc/KcBdgxbcopy/mapper/xml/KcBdgxbcopyMapper.xml b/jeecg-module-main/src/main/java/org/jeecg/modules/kc/KcBdgxbcopy/mapper/xml/KcBdgxbcopyMapper.xml index 539f3e78..13f889cb 100644 --- a/jeecg-module-main/src/main/java/org/jeecg/modules/kc/KcBdgxbcopy/mapper/xml/KcBdgxbcopyMapper.xml +++ b/jeecg-module-main/src/main/java/org/jeecg/modules/kc/KcBdgxbcopy/mapper/xml/KcBdgxbcopyMapper.xml @@ -3,8 +3,7 @@ - INSERT INTO kc_messagelistcopy ( id, touser, template_id, tourl, firstdata, remarkdata, keyword1, keyword2, keyword3, scheduleddatetime ) SELECT - 0,-- id: + INSERT INTO kc_messagelistcopy ( touser, template_id, tourl, firstdata, remarkdata, keyword1, keyword2, keyword3, scheduleddatetime ) SELECT bd.openid,-- touser:oak6lwA02iVyBKrVSok4uUpzeBmY 'KtWw0lwQ8FOgJdKgrmya0eoafGkMfMN8ECdZs8oSJys',-- template_id: 'https://zxkccxwebvpnnenueducn/index',-- tourl: @@ -40,7 +39,7 @@ kc_xuekeduiyingbiao xk, kc_ketangbiao kt, kc_kechengtixingdingyue kd, - kc_bdgxbcopy bd + (select * from choice.bdgxbcopy) bd WHERE xk.rwbh = kt.rwbh AND xk.xh = kd.userid @@ -50,8 +49,7 @@ - INSERT INTO kc_messagelistcopy ( id, touser, template_id, tourl, firstdata, remarkdata,.keyword1, keyword2, keyword3, scheduleddatetime ) SELECT - 0, + INSERT INTO kc_messagelistcopy ( touser, template_id, tourl, firstdata, remarkdata,keyword1, keyword2, keyword3, scheduleddatetime ) SELECT bd.openid, 'KtWw0lwQ8FOgJdKgrmya0eoafGkMfMN8ECdZs8oSJys', 'https://zxkccx.webvpn.nenu.edu.cn/index', @@ -86,7 +84,7 @@ FROM kc_kechengtixingdingyue kd, kc_ketangbiao kt, - kc_bdgxbcopy bd + (select * from choice.bdgxbcopy) bd WHERE kd.userid = kt.jgh AND kd.userid = bd.userid @@ -95,8 +93,7 @@ - INSERT INTO kc_messagelistcopy ( id, touser, template_id, tourl, firstdata, remarkdata, keyword1, keyword2, keyword3, scheduleddatetime ) SELECT - 0,-- id: + INSERT INTO kc_messagelistcopy ( touser, template_id, tourl, firstdata, remarkdata, keyword1, keyword2, keyword3, scheduleddatetime ) SELECT bd.openid,-- touser:oak6lwA02iVyBKrVSok4uUpzeBmY 'KtWw0lwQ8FOgJdKgrmya0eoafGkMfMN8ECdZs8oSJys',-- template_id:KtWw0lwQ8FOgJdKgrmya0eoafGkMfMN8ECdZs8oSJys 'https://zxkccx.webvpn.nenu.edu.cn/index',-- tourl:https://zxkccx.webvpn.nenu.edu.cn/index @@ -130,7 +127,7 @@ kc_kechengtixingdingyue kd, kc_xuekeduiyingbiao xk, kc_ketangbiao kt, - kc_bdgxbcopy bd + (select * from choice.bdgxbcopy) bd WHERE kd.userid = xk.xh AND xk.rwbh = kt.rwbh @@ -144,8 +141,7 @@ - INSERT INTO kc_messagelistcopy ( id, touser, template_id, tourl, firstdata, remarkdata, keyword1, keyword2, keyword3, scheduleddatetime ) SELECT - 0,-- id: + INSERT INTO kc_messagelistcopy ( touser, template_id, tourl, firstdata, remarkdata, keyword1, keyword2, keyword3, scheduleddatetime ) SELECT bd.openid,-- touser:oak6lwAa1epMAgwQziF2K9yBkiLE 'KtWw0lwQ8FOgJdKgrmya0eoafGkMfMN8ECdZs8oSJys',-- template_id:KtWw0lwQ8FOgJdKgrmya0eoafGkMfMN8ECdZs8oSJys 'https://zxkccx.webvpn.nenu.edu.cn/index',-- tourl:https://zxkccx.webvpn.nenu.edu.cn/index @@ -178,7 +174,7 @@ FROM kc_kechengtixingdingyue kd, kc_ketangbiao kt, - kc_bdgxbcopy bd + (select * from choice.bdgxbcopy) bd WHERE kd.userid = kt.jgh AND kd.userid = bd.userid diff --git a/jeecg-module-main/src/main/java/org/jeecg/modules/kc/grab/SynchronizationService/SyncWechartTsxx.java b/jeecg-module-main/src/main/java/org/jeecg/modules/kc/grab/SynchronizationService/SyncWechartTsxx.java index f2a5c4f8..314cb6a3 100644 --- a/jeecg-module-main/src/main/java/org/jeecg/modules/kc/grab/SynchronizationService/SyncWechartTsxx.java +++ b/jeecg-module-main/src/main/java/org/jeecg/modules/kc/grab/SynchronizationService/SyncWechartTsxx.java @@ -31,7 +31,7 @@ public class SyncWechartTsxx extends BaseSync { private static final String appId = "wx59920eb69d611d7f"; // appIdSecret - private static final String appIdSecret = "60b429xxxxxxxxxxxxxxx"; + private static final String appIdSecret = "bf0c19af0e956f447ede4dd902ea63b7"; /** * 若参数变量名修改 QuartzJobController中也需对应修改 */ diff --git a/jeecg-module-main/src/main/java/org/jeecg/modules/wxgzh/WxgzhController.java b/jeecg-module-main/src/main/java/org/jeecg/modules/wxgzh/WxgzhController.java index b9b4f2e1..eff94568 100644 --- a/jeecg-module-main/src/main/java/org/jeecg/modules/wxgzh/WxgzhController.java +++ b/jeecg-module-main/src/main/java/org/jeecg/modules/wxgzh/WxgzhController.java @@ -29,16 +29,13 @@ public class WxgzhController { private static final Logger log = LoggerFactory.getLogger(WxgzhController.class); // appId -// private static final String appId = "wx59920eb69d611d7f";//东师 - private static final String appId = "wxafdbb51ba3aa614d";//测试 + private static final String appId = "wx59920eb69d611d7f";//东师 // appIdSecret -// private static final String appIdSecret = "";//东师 - private static final String appIdSecret = "bdf346ae8b986e9fa5d33b2e4495b27e";//测试 + private static final String appIdSecret = "bf0c19af0e956f447ede4dd902ea63b7";//东师 // 公众号的模板id(也有相应的接口可以查询到) -// private static final String templateId = "KtWw0lwQ8FOgJdKgrmya0eoafGkMfMN8ECdZs8oSJys";//东师 - private static final String templateId = "cFD7lyjpppIZUB9ipuGjkjZr9ED-BhJZ7bw3ILaFgbg";//测试 + private static final String templateId = "KtWw0lwQ8FOgJdKgrmya0eoafGkMfMN8ECdZs8oSJys";//东师 // 微信申请的域名(提前准备) private static final String domain = "https://zxkccx.webvpn.nenu.edu.cn/wxpay"; @@ -182,4 +179,58 @@ public class WxgzhController { return Result.OK("推送成功!"); } + public static void main(String[] args) { + String urlToken = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="+ appId +"&secret=" + appIdSecret; + System.out.println("urlToken: "+ urlToken); + String res = HttpUtil.get(urlToken); + JSONObject jsonObjectToken = JSONObject.parseObject(res); + System.out.println("jsonObjectToken:{}"+ jsonObjectToken); + String accessToken = jsonObjectToken.getString("access_token"); + System.out.println("accessToken:{}"+ accessToken); + + // 模板参数 + Map sendMag = new HashMap(); + + String openId = "oak6lwKGlGQQwt83nuynZnP4HUR4";//曹老师账号 + // 微信的基础accessToken +// String accessToken = getAccessToken(); + String url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken; + + /** + * 其他模板可以从模板库中自己添加 + * 模板ID + * KtWw0lwQ8FOgJdKgrmya0eoafGkMfMN8ECdZs8oSJys + * 开发者调用模板消息接口时需提供模板ID + * 标题 上课提醒 + * 行业 教育 - 院校 + * 详细内容 + * {{first.DATA}} + * 课程:{{keyword1.DATA}} + * 时间:{{keyword2.DATA}} + * 地点:{{keyword3.DATA}} + * {{remark.DATA}} + */ + sendMag.put("first", new WeChatTemplateMsg("有课程即将开始")); + sendMag.put("keyword1", new WeChatTemplateMsg("线性代数")); + sendMag.put("keyword2", new WeChatTemplateMsg("[1,2节] 08:30-10:00")); + sendMag.put("keyword3", new WeChatTemplateMsg("上课地点N304")); + sendMag.put("remark", new WeChatTemplateMsg("请开发者为用户提供定制提醒的选项,以免打扰。")); + RestTemplate restTemplate = new RestTemplate(); + //拼接base参数 + Map sendBody = new HashMap<>(); + sendBody.put("touser", openId); // openId + sendBody.put("url", domainTo); // 点击模板信息跳转地址 + sendBody.put("topcolor", "#FF0000"); // 顶色 + sendBody.put("data", sendMag); // 模板参数 + sendBody.put("template_id", templateId); // 模板Id + ResponseEntity forEntity = restTemplate.postForEntity(url, sendBody, String.class); + log.info("结果是: {}",forEntity.getBody()); + JSONObject jsonObject2 = JSONObject.parseObject(forEntity.getBody()); + // 0 + String messageCode = jsonObject2.getString("errcode"); + // 2431260672639467520 + String msgId = jsonObject2.getString("msgid"); + System.out.println("messageCode : " + messageCode + ", msgId: " +msgId); + } + }