订阅领域-编辑文档是发飞书消息
This commit is contained in:
+10
-1
@@ -3354,6 +3354,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
}
|
||||
//只要修改了标准,就需要向订阅用户发送消息(内容为-->XXX对“GB 7258 进行了修改请及时查看”)
|
||||
//向订阅领域管理中订阅了该技术领域的人和文档库中订阅了该条文档的人发送消息
|
||||
// 只有技术领域变更为订阅的技术领域这一种情况发消息, 假如订阅了技术领域A,编辑的文档的技术领域也是A,这时编辑的是其他的字段,这种情况不发消息
|
||||
Map<String, Object> mapTemp = new HashMap<>();
|
||||
mapTemp.put("domainId", map.get("technology_territory"));
|
||||
mapTemp.put("documentId", map.get("id"));
|
||||
@@ -3434,10 +3435,18 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
// thirdIdListAll = thirdIdListAll.stream().distinct().collect(Collectors.toList());
|
||||
String contentInfoFei = "In the " + technologyTerritoryNameEn + " technical field you subscribed to, the " +
|
||||
category + " " + serialNumber+" has been updated.";
|
||||
String contentInfoFeiCn = "您所订阅的" + technologyTerritoryNameEn + "技术领域中更新了" + categoryCn + " " + serialNumber;
|
||||
try {
|
||||
//跳转文档详情
|
||||
String url = backUrl + "/docManage/library/detail?id=" + id;
|
||||
iFeishuService.batchSendMessage(thirdIdList.toArray(new String[]{}), contentInfoFei, MessageTypeEnum.READ.getName(), url);
|
||||
FeishuMsgVo feishuMsgVo = new FeishuMsgVo();
|
||||
feishuMsgVo.setTitle(MessageTypeEnum.READ.getName());
|
||||
feishuMsgVo.setUrl(url);
|
||||
feishuMsgVo.setContentEn(contentInfoFei);
|
||||
feishuMsgVo.setContent(contentInfoFeiCn);
|
||||
|
||||
iFeishuService.sendCardMsgTerritory(thirdIdList.toArray(new String[]{}), feishuMsgVo);
|
||||
// iFeishuService.batchSendMessage(thirdIdList.toArray(new String[]{}), contentInfoFei, MessageTypeEnum.READ.getName(), url);
|
||||
} catch (IOException e) {
|
||||
log.error("文档新增飞书消息推送失败");
|
||||
}
|
||||
|
||||
+9
@@ -48,6 +48,15 @@ public interface IFeishuService {
|
||||
*/
|
||||
String sendCardMsgDocument(String[] userIds, FeishuMsgVo feishuMsgVo) throws IOException;
|
||||
|
||||
/**
|
||||
* 订阅领域(飞书消息)
|
||||
* @param userIds
|
||||
* @param feishuMsgVo
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
String sendCardMsgTerritory(String[] userIds, FeishuMsgVo feishuMsgVo) throws IOException;
|
||||
|
||||
/**
|
||||
* 翻译文本
|
||||
* @param params
|
||||
|
||||
+86
-1
@@ -379,12 +379,97 @@ public class FeishuServiceImpl implements IFeishuService {
|
||||
jsonArray.add(elementThree);
|
||||
jsonArray.add(elementFour);
|
||||
jsonArray.add(elementFive);
|
||||
|
||||
jsonObject.put("elements",jsonArray);
|
||||
|
||||
// 设置请求参数
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 订阅领域(飞书消息)
|
||||
* @param userIds
|
||||
* @param feishuMsgVo
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public String sendCardMsgTerritory(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\"},");
|
||||
|
||||
//内容英文
|
||||
if (StrUtil.isNotEmpty(feishuMsgVo.getContentEn())){
|
||||
contentSb.append("{");
|
||||
contentSb.append("\"tag\": \"div\",");
|
||||
contentSb.append("\"text\": {");
|
||||
contentSb.append("\"content\": \"" + feishuMsgVo.getContentEn() + "\",");
|
||||
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());
|
||||
|
||||
// 设置请求参数
|
||||
JSONObject paramsMap = new JSONObject();
|
||||
|
||||
Reference in New Issue
Block a user