|
@@ -67,41 +67,46 @@ public class WxSendService {
|
|
|
//拿到accessToken
|
|
|
String accessToken = HttpUtils.dogetToken();
|
|
|
|
|
|
- //发送模板消息开始
|
|
|
- TranTemplate tranTemplate = new TranTemplate();
|
|
|
- //设置接收人的openid(当前登录人的openid)
|
|
|
+ String result = "";
|
|
|
|
|
|
- tranTemplate.setTouser(resource.getOpenid());
|
|
|
+ if ( null != accessToken ) {
|
|
|
+ //发送模板消息开始
|
|
|
+ TranTemplate tranTemplate = new TranTemplate();
|
|
|
+ //设置接收人的openid(当前登录人的openid)
|
|
|
|
|
|
- tranTemplate.setUrl(resource.getUrl());
|
|
|
+ tranTemplate.setTouser(resource.getOpenid());
|
|
|
|
|
|
- //设置模板ID
|
|
|
- tranTemplate.setTemplate_id("ehTUuyDFL7f2RApsMXLsJEPlCgt82aTj2vtmO2l9Cso");
|
|
|
- //给模板的内容赋值
|
|
|
- Map<String , TemplateInfo> dataMap = new HashMap<>();
|
|
|
+ tranTemplate.setUrl(resource.getUrl());
|
|
|
|
|
|
- TemplateInfo title = new TemplateInfo(resource.getTitleName(),"#173177");
|
|
|
- dataMap.put("title",title);
|
|
|
+ //设置模板ID
|
|
|
+ tranTemplate.setTemplate_id("ehTUuyDFL7f2RApsMXLsJEPlCgt82aTj2vtmO2l9Cso");
|
|
|
+ //给模板的内容赋值
|
|
|
+ Map<String , TemplateInfo> dataMap = new HashMap<>();
|
|
|
|
|
|
- TemplateInfo processName = new TemplateInfo(resource.getProcessName(),"#173177");
|
|
|
- dataMap.put("processName",processName);
|
|
|
+ TemplateInfo title = new TemplateInfo(resource.getTitleName(),"#173177");
|
|
|
+ dataMap.put("title",title);
|
|
|
|
|
|
- TemplateInfo currentStage = new TemplateInfo(resource.getCurrentStage(),"#173177");
|
|
|
- dataMap.put("currentStage",currentStage);
|
|
|
+ TemplateInfo processName = new TemplateInfo(resource.getProcessName(),"#173177");
|
|
|
+ dataMap.put("processName",processName);
|
|
|
|
|
|
- TemplateInfo processInitiator = new TemplateInfo(resource.getProcessInitiator(),"#173177");
|
|
|
- dataMap.put("processInitiator",processInitiator);
|
|
|
+ TemplateInfo currentStage = new TemplateInfo(resource.getCurrentStage(),"#173177");
|
|
|
+ dataMap.put("currentStage",currentStage);
|
|
|
|
|
|
- TemplateInfo createTime = new TemplateInfo(resource.getCreateTime(),"#173177");
|
|
|
- dataMap.put("createTime",createTime);
|
|
|
+ TemplateInfo processInitiator = new TemplateInfo(resource.getProcessInitiator(),"#173177");
|
|
|
+ dataMap.put("processInitiator",processInitiator);
|
|
|
|
|
|
- tranTemplate.setData(dataMap);
|
|
|
+ TemplateInfo createTime = new TemplateInfo(resource.getCreateTime(),"#173177");
|
|
|
+ dataMap.put("createTime",createTime);
|
|
|
+
|
|
|
+ tranTemplate.setData(dataMap);
|
|
|
+
|
|
|
+ JSONObject jsonObject = JSONUtil.parseObj(tranTemplate);
|
|
|
+ //将入参转为字符串
|
|
|
+ String jsonParam = jsonObject.toString();
|
|
|
+ //发起请求发送模板信息
|
|
|
+ result = HttpUtils.requestPost(sendTemplateUrl + accessToken, jsonParam);
|
|
|
+ }
|
|
|
|
|
|
- JSONObject jsonObject = JSONUtil.parseObj(tranTemplate);
|
|
|
- //将入参转为字符串
|
|
|
- String jsonParam = jsonObject.toString();
|
|
|
- //发起请求发送模板信息
|
|
|
- String result = HttpUtils.requestPost(sendTemplateUrl + accessToken, jsonParam);
|
|
|
|
|
|
return result;
|
|
|
}
|