|
|
@ -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; |
|
|
@ -70,6 +75,8 @@ public class WarrantServiceImpl implements WarrantService { |
|
|
|
private MessagePushTextDao messagePushTextDao; |
|
|
|
@Autowired |
|
|
|
private RedisThird redisThird; |
|
|
|
@Autowired |
|
|
|
private PaCustomerDao paCustomerDao; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 1.保存代码审核结果 2.更新代码上传结果 |
|
|
@ -134,25 +141,32 @@ public class WarrantServiceImpl implements WarrantService { |
|
|
|
codeAuditRecord.setCustomerId(customerId); |
|
|
|
codeAuditRecord.setAuthAppId(authAppId); |
|
|
|
codeAuditRecord.setTemplateId(templateId); |
|
|
|
String customerName = paCustomerDao.selectCustomerName(customerId); |
|
|
|
String client = this.getClient(clientType); |
|
|
|
//插入 代码审核 记录
|
|
|
|
log.info(String.format(ThirdRunTimeInfoConstant.CODE_AUDIT_RESULT, xml)); |
|
|
|
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,customerName,client); |
|
|
|
break; |
|
|
|
case ModuleConstant.WEAPP_AUDIT_FAIL: |
|
|
|
codeResult = ModuleConstant.AUDIT_FAILED; |
|
|
|
this.dingDingRobot(reason,codeResult,customerName,client); |
|
|
|
break; |
|
|
|
case ModuleConstant.WEAPP_AUDIT_DELAY: |
|
|
|
codeResult = ModuleConstant.DELAY; |
|
|
|
this.dingDingRobot(reason,codeResult,customerName,client); |
|
|
|
break; |
|
|
|
} |
|
|
|
String codeCustomerId = codeCustomerDao.selectCodeCustomerId(codeAuditRecord); |
|
|
|
codeAuditResultDao.updateAuditResult(customerId, codeCustomerId, codeResult); |
|
|
|
log.info("消息与事件接收URL【代码审核结果】结束......"); |
|
|
|
}else { |
|
|
|
this.replyEventMessage(request,response,event,toUserName,fromUserName); |
|
|
|
} |
|
|
@ -165,31 +179,62 @@ public class WarrantServiceImpl implements WarrantService { |
|
|
|
// messagePushTextDao.insertMessageText(messagePushTextFormDTO);
|
|
|
|
String content = messagePushTextFormDTO.getContent(); |
|
|
|
log.info(String.format(ThirdRunTimeInfoConstant.CONTENT,content)); |
|
|
|
|
|
|
|
/** |
|
|
|
* 测试公众号处理用户消息 |
|
|
|
* 模拟粉丝发送文本消息给专用测试公众号,第三方平台方需根据文本消息的内容进行相应的响应: |
|
|
|
* 1)微信模推送给第三方平台方:文本消息,其中 Content 字段的内容固定为:TESTCOMPONENT_MSG_TYPE_TEXT |
|
|
|
* 2)第三方平台方立马回应文本消息并最终触达粉丝:Content 必须固定为:TESTCOMPONENT_MSG_TYPE_TEXT_callback |
|
|
|
*/ |
|
|
|
/*if (content.equals(ModuleConstant.TESTCOMPONENT_MSG_TYPE_TEXT)){ |
|
|
|
|
|
|
|
|
|
|
|
}else if (content.startsWith(ModuleConstant.QUERY_AUTH_CODE)){ |
|
|
|
// 测试公众号使用客服消息接口处理用户消息
|
|
|
|
String contentBefore = content.substring(NumConstant.ZERO, content.indexOf(ThirdRedisKeyConstant.COLON)); |
|
|
|
//auth_code
|
|
|
|
String queryAuthCode = content.substring(contentBefore.length() + NumConstant.ONE, content.length()); |
|
|
|
|
|
|
|
}*/ |
|
|
|
|
|
|
|
this.processTextMessage(request,response,content,toUserName,fromUserName); |
|
|
|
|
|
|
|
} |
|
|
|
log.info("消息与事件接收URL【代码审核结果】结束......"); |
|
|
|
return ModuleConstant.SUCCESS; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 钉钉机器人报警 |
|
|
|
* @author zxc |
|
|
|
* @date 2020/8/5 4:33 下午 |
|
|
|
*/ |
|
|
|
public void dingDingRobot(String result,String event,String customerName,String clientType){ |
|
|
|
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/robot/send?access_token=5b48fcbc3fde24b8ba4696aa062b7f8146479a9d3467dbb1f9cf132ec36b955a"); |
|
|
|
OapiRobotSendRequest request = new OapiRobotSendRequest(); |
|
|
|
request.setMsgtype("markdown"); |
|
|
|
OapiRobotSendRequest.Markdown markdown = new OapiRobotSendRequest.Markdown(); |
|
|
|
markdown.setTitle("代码审核结果"); |
|
|
|
switch (event){ |
|
|
|
case ModuleConstant.WEAPP_AUDIT_SUCCESS: |
|
|
|
markdown.setText("代码审核结果: 审核成功\n"+ |
|
|
|
"> 客户名称:" + customerName +"\n\n"+ |
|
|
|
"> 客户端:"+clientType+"\n"); |
|
|
|
break; |
|
|
|
case ModuleConstant.WEAPP_AUDIT_FAIL: |
|
|
|
markdown.setText("代码审核结果: 审核不通过\n"+ |
|
|
|
"> 客户名称:" + customerName +"\n\n"+ |
|
|
|
"> 客户端:"+clientType+"\n\n"+ |
|
|
|
"> 不通过原因:"+result); |
|
|
|
break; |
|
|
|
case ModuleConstant.WEAPP_AUDIT_DELAY: |
|
|
|
markdown.setText("代码审核结果: 审核延时\n"+ |
|
|
|
"> 客户名称:" + customerName +"\n\n"+ |
|
|
|
"> 客户端:"+clientType+"\n\n"+ |
|
|
|
"> 延时原因:"+result); |
|
|
|
break; |
|
|
|
} |
|
|
|
request.setMarkdown(markdown); |
|
|
|
try { |
|
|
|
OapiRobotSendResponse response = client.execute(request); |
|
|
|
} catch (ApiException e) { |
|
|
|
log.error("机器人生病了......"); |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public String getClient(String clientType){ |
|
|
|
String result = clientType == "resi" ? "居民端" : "工作端"; |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 方法描述: 类型为enevt的时候,拼接 |
|
|
|
* @param request |
|
|
@ -242,7 +287,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 +314,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(); |
|
|
|