Browse Source

robot

dev_shibei_match
zxc 5 years ago
parent
commit
90af0accdb
  1. 60
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/WarrantServiceImpl.java

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

@ -189,13 +189,11 @@ public class WarrantServiceImpl implements WarrantService {
Object createTime = xml.get(ModuleConstant.CREATE_TIME);
Date date = componentVerifyTicketServiceImpl.sToDate(createTime.toString());
messagePushTextFormDTO.setWeChatCreateTime(date);
// messagePushTextDao.insertMessageText(messagePushTextFormDTO);
String content = messagePushTextFormDTO.getContent();
log.info(String.format(ThirdRunTimeInfoConstant.CONTENT,content));
if(ModuleConstant.TESTCOMPONENT_MSG_TYPE_TEXT.equals(content)){
log.info("收到消息,要回复了......");
// String returnContent = content+ModuleConstant._CALL_BACK;
String returnContent = "TESTCOMPONENT_MSG_TYPE_TEXT_callback";
String returnContent = content+ModuleConstant._CALL_BACK;
log.info("拼接的回复内容【普通】:"+returnContent);
replyTextMessage(request, response, returnContent, toUserName, fromUserName);
@ -240,18 +238,21 @@ public class WarrantServiceImpl implements WarrantService {
"> 客户端:"+clientType+"\n\n"+
"> 延时原因:"+result);
break;
default:
markdown.setText("机器人生病了......");
log.info("event为:"+event);
break;
}
request.setMarkdown(markdown);
log.info("robot需要发送的内容为:"+markdown.getTitle());
log.info("robot需要发送的内容为:"+markdown.getText());
String url = "https://oapi.dingtalk.com/robot/send?access_token=2438902efbcc15909deb7076963c5cbe2d6fdbfdb9d66750faab2f2cce6eb09f";
String secret = "SECe3c785dd254659608667a4a623acc5a0395636143411617f6e36838b48941e74";
this.sendCodeMsg(request,url,secret);
}
/*
public static void main(String[] args) {
WarrantServiceImpl w = new WarrantServiceImpl();
w.dingDingRobot("审核失败","weapp_audit_fail","机器人测试","居民端");
}*/
// public static void main(String[] args) {
// WarrantServiceImpl w = new WarrantServiceImpl();
// w.dingDingRobot("审核失败","weapp_audit_fail","机器人测试","居民端");
// }
public Result<String> sendCodeMsg(OapiRobotSendRequest request,String url,String secret) {
Long timestamp = System.currentTimeMillis();
@ -263,7 +264,10 @@ public class WarrantServiceImpl implements WarrantService {
String sign = URLEncoder.encode(new String(Base64.encodeBase64(signData)), "UTF-8");
log.info("sign为:"+sign);
url = url.concat("&timestamp=" + timestamp + "&sign=" + sign);
Result<String> stringResult = HttpClientManager.getInstance().sendPostByJSON(url, JSON.toJSONString(request));
log.info("发送url:"+url);
String requestString = JSON.toJSONString(request);
log.info("发送内容:"+requestString);
Result<String> stringResult = HttpClientManager.getInstance().sendPostByJSON(url, requestString);
log.info("robot发送消息结果为:"+stringResult.getData());
return stringResult;
} catch (Exception e) {
@ -294,22 +298,6 @@ public class WarrantServiceImpl implements WarrantService {
replyTextMessage(request, response, content, toUserName, fromUserName);
}
/**
* 立马回应文本消息并最终触达粉丝
* @param content 文本
* @param toUserName 发送接收人
* @param fromUserName 发送人
* @author zxc
*/
public void processTextMessage(HttpServletRequest request, HttpServletResponse response,
String content,String toUserName, String fromUserName)
throws IOException, DocumentException{
}
/**
* 方法描述: 直接返回给微信开放平台
* @param request
@ -383,24 +371,4 @@ public class WarrantServiceImpl implements WarrantService {
log.info("客服发送接口返回值:"+data);
}
/**
* 方法描述: 返回数据到请求方
* @param data 数据
* @param response
* @author zxc
*/
public void returnJSON(Object data,HttpServletResponse response) {
try {
ObjectMapper objectMapper = new ObjectMapper();
JsonEncoding encoding = JsonEncoding.UTF8;
response.setContentType(ModuleConstant.APPLICATION_JSON);
JsonGenerator generator = objectMapper.getJsonFactory().
createJsonGenerator(response.getOutputStream(), encoding);
objectMapper.writeValue(generator, data);
} catch (Exception e) {
e.printStackTrace();
}
}
}

Loading…
Cancel
Save