|
|
@@ -1,6 +1,7 @@
|
|
|
package com.goafanti.common.utils;
|
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
+import java.net.URL;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
@@ -15,6 +16,7 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.goafanti.common.bo.EmailBo;
|
|
|
+import com.goafanti.common.constant.AFTConstants;
|
|
|
import com.goafanti.common.dao.NoticeMapper;
|
|
|
import com.goafanti.common.enums.NoticeTypes;
|
|
|
import com.goafanti.common.error.BusinessException;
|
|
|
@@ -30,10 +32,11 @@ public class AsyncUtils {
|
|
|
private String appId;
|
|
|
@Value(value = "${wx.appSecret}")
|
|
|
private String appSecret;
|
|
|
-
|
|
|
- private static final String sptz="Z630pmux5w-2ryn1MK3x6jZwZbxLV0_jdhOni6Wa_Yg";
|
|
|
- private static final String jgtz="SLb0P5wDArFZU05iMrrnNEsXZ7H2wArqdY8__4M1NUU";
|
|
|
- private static final String send_url="https://api.weixin.qq.com/cgi-bin/message/subscribe/send";
|
|
|
+ //待审核通知
|
|
|
+ private static final String sptz="j7WH3EwQnxGxwuV2HwmJhryxySPE8vOiV5cVOpp-42I";
|
|
|
+ //审核结通知
|
|
|
+ private static final String jgtz="pWia-KJPFwDM8ReDu_BOa2_42G7W2hXB16sUDbSxpcM";
|
|
|
+ private static String send_url="https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=ACCESS_TOKEN";
|
|
|
|
|
|
|
|
|
public void patentSend(EmailBo bo) throws UnsupportedEncodingException, MessagingException {
|
|
|
@@ -64,33 +67,43 @@ public class AsyncUtils {
|
|
|
*
|
|
|
* @param openid
|
|
|
* @param type 0申请 1通过 2驳回
|
|
|
+ * @param string
|
|
|
+ * @param date
|
|
|
*/
|
|
|
- public void addWechatNotice(String openid ,Integer type) {
|
|
|
+ public void addWechatNotice(String openid ,Integer type, Date date, String aname) {
|
|
|
Map<String, Object> map=new HashMap<String, Object>();
|
|
|
String accessToken=getAccessToken();
|
|
|
+ String url=send_url.replace("ACCESS_TOKEN", accessToken);
|
|
|
+ System.out.println(url);
|
|
|
map.put("access_token", accessToken);
|
|
|
map.put("touser", openid);
|
|
|
Map<String, Object> we=new HashMap<String, Object>();
|
|
|
if (type==0) {
|
|
|
map.put("template_id", sptz);
|
|
|
Map<String, Object> v1=new HashMap<String, Object>();
|
|
|
- v1.put("value","2019年10月1日");
|
|
|
+ String str=DateUtils.formatDate(date, AFTConstants.YMDHMS_CHINESE);
|
|
|
+ v1.put("value",str);
|
|
|
we.put("date2", v1);
|
|
|
Map<String, Object> v2=new HashMap<String, Object>();
|
|
|
- v2.put("value", "测试人");
|
|
|
+ v2.put("value", aname);
|
|
|
we.put("name5", v2);
|
|
|
Map<String, Object> v3=new HashMap<String, Object>();
|
|
|
v3.put("value", "我是一个备注");
|
|
|
we.put("thing8", v3);
|
|
|
- }else {
|
|
|
+ }else if (type==1){
|
|
|
+ map.put("template_id", jgtz);
|
|
|
+ we.put("thing17", new HashMap<>().put("value", "通过"));
|
|
|
+ we.put("thing25", new HashMap<>().put("value", "您申请的外出已通过!"));
|
|
|
+ }else if (type==2){
|
|
|
map.put("template_id", jgtz);
|
|
|
we.put("thing17", new HashMap<>().put("value", "通过"));
|
|
|
- we.put("thing25", new HashMap<>().put("value", "我是一个备注"));
|
|
|
+ we.put("thing25", new HashMap<>().put("value", "您申请的外出已驳回!"));
|
|
|
}
|
|
|
map.put("data", we);
|
|
|
System.out.println(JSONObject.toJSON(map));
|
|
|
- JSONObject json=HttpUtils.httpPost(send_url, map);
|
|
|
+ JSONObject json=HttpUtils.httpPost(url, map);
|
|
|
System.out.println(JSONObject.toJSONString(json));
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -112,7 +125,7 @@ public class AsyncUtils {
|
|
|
if (errcode!=null) {
|
|
|
throw new BusinessException("获取AccessToken失败!");
|
|
|
}else {
|
|
|
- LoggerUtils.debug(AsyncUtils.class,"获取AccessToken成功"+js.getString("access_token"));
|
|
|
+ LoggerUtils.debug(AsyncUtils.class,"获取AccessToken成功,accesstoken="+js.getString("access_token"));
|
|
|
}
|
|
|
access_token = js.getString("access_token");
|
|
|
expires_in = js.getString("expires_in");
|