Merge remote-tracking branch 'origin/feature_dev_20221025_message' into feature_dev_20221025_message
This commit is contained in:
+10
-3
@@ -3272,13 +3272,20 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
}
|
||||
//订阅文档的飞书消息
|
||||
try {
|
||||
// String contentInfoFei = "In the " + technologyTerritoryNameEn + " technical field you subscribed to, the " +
|
||||
// category + " " + serialNumber+" has been updated.";
|
||||
// String contentInfoFei = "In the "+category + " " + serialNumber +" you subscribed to, "+sysUser.getUsername()+" changed the " + sbStr.toString();;
|
||||
// //跳转文档详情
|
||||
// String url = backUrl + "/docManage/library/detail?id=" + id;
|
||||
// FeishuMsgVo feishuMsgVo = new FeishuMsgVo();
|
||||
// feishuMsgVo.setTitle(MessageTypeEnum.READ.getName());
|
||||
// feishuMsgVo.setUrl(url);
|
||||
// String replaceAll = contentInfoFei.replaceAll("\"", "<");
|
||||
// feishuMsgVo.setContent(replaceAll);
|
||||
//
|
||||
// iFeishuService.sendCardMsgDocument(userIdListUpdateFeishu.toArray(new String[]{}), feishuMsgVo);
|
||||
String contentInfoFei = "In the "+category + " " + serialNumber +" you subscribed to, "+sysUser.getUsername()+" changed the " + sbStr.toString();;
|
||||
//跳转文档详情
|
||||
String url = backUrl + "/docManage/library/detail?id=" + id;
|
||||
iFeishuService.batchSendMessage(userIdListUpdateFeishu.toArray(new String[]{}), contentInfoFei, MessageTypeEnum.READ.getName(), url);
|
||||
// iFeishuService.batchSendMessage(userIdListUpdateFeishu.toArray(new String[]{}), content, MessageTypeEnum.READ.getName(), url);
|
||||
} catch (IOException e) {
|
||||
log.error("文档新增飞书消息推送失败");
|
||||
}
|
||||
|
||||
+9
@@ -39,6 +39,15 @@ public interface IFeishuService {
|
||||
*/
|
||||
String sendCardMsg(String[] userIds, FeishuMsgVo feishuMsgVo) throws IOException;
|
||||
|
||||
/**
|
||||
* 文档库卡片消息
|
||||
* @param userIds
|
||||
* @param feishuMsgVo
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
String sendCardMsgDocument(String[] userIds, FeishuMsgVo feishuMsgVo) throws IOException;
|
||||
|
||||
/**
|
||||
* 翻译文本
|
||||
* @param params
|
||||
|
||||
+87
@@ -281,6 +281,93 @@ public class FeishuServiceImpl implements IFeishuService {
|
||||
return tokenJson.get("msg").toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 文档库卡片消息
|
||||
* @param userIds
|
||||
* @param feishuMsgVo
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public String sendCardMsgDocument(String[] userIds, FeishuMsgVo feishuMsgVo) throws IOException {
|
||||
String token = getTenantAccessToken();
|
||||
// 设置请求头
|
||||
Map<String, String> headerMap = new HashMap<>();
|
||||
headerMap.put("Authorization", "Bearer " + token);
|
||||
headerMap.put("Content-Type", "application/json; charset=utf-8");
|
||||
|
||||
// 示例
|
||||
StringBuilder contentSb = new StringBuilder();
|
||||
contentSb.append("{");
|
||||
contentSb.append("\"elements\": [");
|
||||
// 补充内容
|
||||
if (StrUtil.isNotEmpty(feishuMsgVo.getContent())){
|
||||
contentSb.append("{");
|
||||
contentSb.append("\"tag\": \"div\",");
|
||||
contentSb.append("\"text\": {");
|
||||
contentSb.append("\"content\": \"" + feishuMsgVo.getContent() + "\",");
|
||||
contentSb.append("\"tag\": \"lark_md\"");
|
||||
contentSb.append("}");
|
||||
contentSb.append("},");
|
||||
};
|
||||
|
||||
|
||||
contentSb.append("{\"tag\": \"hr\"},");
|
||||
contentSb.append("{");
|
||||
contentSb.append("\"actions\": [");
|
||||
contentSb.append("{");
|
||||
contentSb.append("\"tag\": \"button\",");
|
||||
contentSb.append("\"text\": {");
|
||||
contentSb.append("\"content\": \"view\",");
|
||||
contentSb.append("\"tag\": \"plain_text\"");
|
||||
contentSb.append("},");
|
||||
contentSb.append("\"type\": \"primary\",");
|
||||
contentSb.append("\"url\": \" "+ feishuMsgVo.getUrl() +" \"");
|
||||
contentSb.append("}");
|
||||
contentSb.append("],");
|
||||
contentSb.append("\"tag\": \"action\"");
|
||||
contentSb.append("}");
|
||||
contentSb.append("],");
|
||||
|
||||
|
||||
|
||||
contentSb.append("\"header\": {");
|
||||
contentSb.append("\"template\": \"green\",");
|
||||
contentSb.append("\"title\": {");
|
||||
contentSb.append("\"content\": \" " + feishuMsgVo.getTitle() + " \",");
|
||||
contentSb.append("\"tag\": \"plain_text\"");
|
||||
contentSb.append("}");
|
||||
contentSb.append("}");
|
||||
contentSb.append("}");
|
||||
|
||||
JSONObject jsonObject = JSONObject.parseObject(contentSb.toString());
|
||||
|
||||
// String content = JSONObject.parseObject(JSONObject.parseObject(JSONArray.parseArray(jsonObject.get("elements").toString()).get(0).toString()).get("text").toString()).get("content").toString();
|
||||
// String contentReplaceAll = content.replaceAll("<", "\"");
|
||||
// JSONObject.parseObject(JSONObject.parseObject(JSONArray.parseArray(jsonObject.get("elements").toString()).get(0).toString()).get("text").toString()).put("content",contentReplaceAll);
|
||||
// JSONObject jsonObject1 = JSONObject.parseObject(JSONObject.parseObject(JSONArray.parseArray(jsonObject.get("elements").toString()).get(0).toString()).get("text").toString());
|
||||
// jsonObject1.put("content",contentReplaceAll);
|
||||
//
|
||||
//
|
||||
// JSONObject text = JSONObject.parseObject(JSONObject.parseObject(JSONArray.parseArray(jsonObject.get("elements").toString()).get(0).toString()).get("text").toString());
|
||||
// text.put("value",jsonObject1);
|
||||
|
||||
|
||||
// 设置请求参数
|
||||
JSONObject paramsMap = new JSONObject();
|
||||
paramsMap.put("user_ids", userIds);
|
||||
paramsMap.put("msg_type", "interactive");
|
||||
paramsMap.put("card", jsonObject);
|
||||
|
||||
// 发送请求给飞书
|
||||
String response = HttpRequestUtil.getResponseOfPOST(batchSendMessageUrl, headerMap, paramsMap.toJSONString());
|
||||
// 获取返回结果
|
||||
JSONObject tokenJson = JSONObject.parseObject(response);
|
||||
if(!tokenJson.get("code").toString().equals("0")) {
|
||||
log.error("请求出现异常:" + tokenJson.get("msg") + " " + tokenJson);
|
||||
}
|
||||
return tokenJson.get("msg").toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 翻译文本
|
||||
* 参数:
|
||||
|
||||
Reference in New Issue
Block a user