Commit 6af6d4645336035980901f0edcd664c1043daad2
1 parent
0408ab56d3
Exists in
master
and in
1 other branch
update
Showing 2 changed files with 5 additions and 5 deletions
talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/AccessTokenServlet.java
View file @
6af6d46
| ... | ... | @@ -29,7 +29,7 @@ |
| 29 | 29 | * 启动后开启线程每5分钟获取一次token |
| 30 | 30 | * @throws ServletException |
| 31 | 31 | */ |
| 32 | - @PostConstruct//部署时开启注释,启动线程(测试环境部署不要开启。会与线上环境冲突) | |
| 32 | + @PostConstruct//部署时开启注释,启动线程 | |
| 33 | 33 | public void init() throws ServletException { |
| 34 | 34 | if(on_off){ |
| 35 | 35 | new Thread(new AccessTokenServlet()).start(); //启动线程 |
| 36 | 36 | |
| ... | ... | @@ -42,9 +42,9 @@ |
| 42 | 42 | try{ |
| 43 | 43 | accessToken = this.getToken(); |
| 44 | 44 | if(null!=accessToken){ |
| 45 | - Thread.sleep(1000 * 300); //获取到access_token 休眠300秒,即5分钟 | |
| 45 | + Thread.sleep(1000 * 7199); //获取到access_token 休眠 7199 秒,即 119.98 分钟 | |
| 46 | 46 | }else{ |
| 47 | - Thread.sleep(1000 * 3); //获取的access_token为空 休眠3秒 | |
| 47 | + Thread.sleep(1000 * 1); //获取的access_token为空 休眠1秒 | |
| 48 | 48 | } |
| 49 | 49 | }catch(Exception e){ |
| 50 | 50 | log.info("发生异常:"+e.getMessage()); |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/WeiXinUtil.java
View file @
6af6d46
| ... | ... | @@ -83,8 +83,6 @@ |
| 83 | 83 | * @param dataMap 推送内容消息主题显示相关map |
| 84 | 84 | */ |
| 85 | 85 | public static Integer SendWeChatMsg(String openid, String template_id, Map<String,Object> dataMap, Map<String,Object> mapInfo) { |
| 86 | - // 接口地址 | |
| 87 | - String sendMsgApi = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+AccessTokenServlet.accessToken; | |
| 88 | 86 | //整体参数map |
| 89 | 87 | Map<String, Object> paramMap = new HashMap<String, Object>(); |
| 90 | 88 | paramMap.put("touser", openid); |
| ... | ... | @@ -102,6 +100,8 @@ |
| 102 | 100 | } |
| 103 | 101 | paramMap.put("miniprogram", miniprogram); |
| 104 | 102 | paramMap.put("data", dataMap); |
| 103 | + // 接口地址 | |
| 104 | + String sendMsgApi = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+AccessTokenServlet.accessToken; | |
| 105 | 105 | String result= repeatDoGetPost(sendMsgApi,"POST",paramMap); |
| 106 | 106 | if(StringUtil.isEmpty(result)){ |
| 107 | 107 | return null; |