定时任务添加推送原
This commit is contained in:
parent
140a1c7f06
commit
2d2a46e85d
|
@ -3,8 +3,7 @@
|
|||
<mapper namespace="org.jeecg.modules.kc.KcBdgxbcopy.mapper.KcBdgxbcopyMapper">
|
||||
|
||||
<insert id="saveStudentKqtx">
|
||||
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>
|
||||
|
||||
<insert id="saveTeacherKqtx">
|
||||
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>
|
||||
|
||||
<insert id="saveStudentMrtx">
|
||||
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>
|
||||
|
||||
<insert id="saveTeacherMrtx">
|
||||
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
|
||||
|
|
|
@ -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中也需对应修改
|
||||
*/
|
||||
|
|
|
@ -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<String, WeChatTemplateMsg> sendMag = new HashMap<String, WeChatTemplateMsg>();
|
||||
|
||||
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<String, Object> 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<String> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue