Browse Source

Merge remote-tracking branch 'origin/dev_thirdplatform' into dev

master
zxc 5 years ago
parent
commit
cba6a17cde
  1. 8
      epmet-module/epmet-third/epmet-third-server/pom.xml
  2. 40
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/WarrantServiceImpl.java

8
epmet-module/epmet-third/epmet-third-server/pom.xml

@ -147,6 +147,14 @@
<version>5.1.12.RELEASE</version>
<scope>compile</scope>
</dependency>
<!-- 钉钉机器人 -->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>alibaba-dingtalk-service-sdk</artifactId>
<version>1.0.1</version>
</dependency>
</dependencies>
<build>

40
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/WarrantServiceImpl.java

@ -3,6 +3,10 @@ package com.epmet.service.impl;
import cn.hutool.json.JSONObject;
import com.alibaba.fastjson.JSON;
import com.alibaba.nacos.client.config.utils.IOUtils;
import com.dingtalk.api.DefaultDingTalkClient;
import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.OapiRobotSendRequest;
import com.dingtalk.api.response.OapiRobotSendResponse;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.HttpClientManager;
@ -24,6 +28,7 @@ import com.epmet.wxapi.constant.WxMaCodeConstant;
import com.fasterxml.jackson.core.JsonEncoding;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.taobao.api.ApiException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.dom4j.DocumentException;
@ -139,16 +144,20 @@ public class WarrantServiceImpl implements WarrantService {
codeAuditRecordDao.insertCodeAuditRecord(codeAuditRecord);
// 修改 code_audit_result 中的代码审核结果
// String event = codeAuditRecord.getEvent();
String reason = codeAuditRecord.getReason();
String codeResult = null;
switch (event) {
case ModuleConstant.WEAPP_AUDIT_SUCCESS:
codeResult = ModuleConstant.AUDIT_SUCCESS;
this.dingDingRobot(reason,null);
break;
case ModuleConstant.WEAPP_AUDIT_FAIL:
codeResult = ModuleConstant.AUDIT_FAILED;
this.dingDingRobot(reason,codeResult);
break;
case ModuleConstant.WEAPP_AUDIT_DELAY:
codeResult = ModuleConstant.DELAY;
this.dingDingRobot(reason,codeResult);
break;
}
String codeCustomerId = codeCustomerDao.selectCodeCustomerId(codeAuditRecord);
@ -190,6 +199,33 @@ public class WarrantServiceImpl implements WarrantService {
return ModuleConstant.SUCCESS;
}
public void dingDingRobot(String result,String event){
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/robot/send?access_token=5b48fcbc3fde24b8ba4696aa062b7f8146479a9d3467dbb1f9cf132ec36b955a");
OapiRobotSendRequest request = new OapiRobotSendRequest();
request.setMsgtype("text");
OapiRobotSendRequest.Text text = new OapiRobotSendRequest.Text();
switch (event){
case ModuleConstant.WEAPP_AUDIT_SUCCESS:
text.setContent("代码审核结果: 审核成功");
break;
case ModuleConstant.WEAPP_AUDIT_FAIL:
text.setContent("代码审核结果: 审核不通过,"+
"不通过原因:"+result);
break;
case ModuleConstant.WEAPP_AUDIT_DELAY:
text.setContent("代码审核结果: 审核延时,"+
"延时原因:"+result);
break;
}
request.setText(text);
try {
OapiRobotSendResponse response = client.execute(request);
} catch (ApiException e) {
log.error("机器人生病了......");
e.printStackTrace();
}
}
/**
* 方法描述: 类型为enevt的时候拼接
* @param request
@ -242,7 +278,7 @@ public class WarrantServiceImpl implements WarrantService {
public void replyTextMessage(HttpServletRequest request, HttpServletResponse response,
String content,String toUserName, String fromUserName)
throws DocumentException, IOException {
Long createTime = System.currentTimeMillis() / 1000;
Long createTime = System.currentTimeMillis() / NumConstant.ONE_THOUSAND;
StringBuffer sb = new StringBuffer(512);
sb.append("<xml>");
sb.append("<ToUserName><![CDATA["+toUserName+"]]></ToUserName>");
@ -269,7 +305,7 @@ public class WarrantServiceImpl implements WarrantService {
// 得到微信授权成功的消息后,应该立刻进行处理!!相关信息只会在首次授权的时候推送过来
//第三方平台【component_access_token】
String componentAccessToken = redisThird.getComponentAccessToken();
com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject();
JSONObject jsonObject = new JSONObject();
jsonObject.put(ModuleConstant.COMPONENT_APPID, componentAppId);
jsonObject.put(ModuleConstant.AUTHORIZATION_CODE, auth_code);
String authInfo = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_QUERY_AUTH_URL + componentAccessToken, JSON.toJSONString(jsonObject)).getData();

Loading…
Cancel
Save