diff --git a/jero-boot/jero-boot-base/jero-boot-base-core/src/main/java/com/jero/common/constant/enums/MessageTypeEnum.java b/jero-boot/jero-boot-base/jero-boot-base-core/src/main/java/com/jero/common/constant/enums/MessageTypeEnum.java index 3181758a0..f9d101325 100644 --- a/jero-boot/jero-boot-base/jero-boot-base-core/src/main/java/com/jero/common/constant/enums/MessageTypeEnum.java +++ b/jero-boot/jero-boot-base/jero-boot-base-core/src/main/java/com/jero/common/constant/enums/MessageTypeEnum.java @@ -6,11 +6,11 @@ package com.jero.common.constant.enums; * @auth zhn */ public enum MessageTypeEnum { - READ("Subscription Notification","1"), - WARN("Early Warning","2"), - PUSH("Share / Forward","3"), - HOMO_TASK("Homo Parameter Task","4"), - TASK("Regulation Compliance Task", "5"), + READ("Subscription Notification","订阅通知","1"), + WARN("Regulation Early Warning","法规预警","2"), + PUSH("Share / Forward","转发推送","3"), + HOMO_TASK("Homo Parameter Task","","4"), + TASK("Regulation Compliance Task","", "5"), //REGULATION_LIST_CONFIRMATION_TASK("Regulation List Confirmation Task", "6"), // 清单确认任务 //REGULATION_LIST_CONFIRMATION_NOTIFICATION("Regulation List Confirmation Notification", "7"), // 清单确认通知 //REGULATION_TASK_CONFIRMATION_TASK("Regulation Task Confirmation", "8"), // 任务确认任务 @@ -21,19 +21,21 @@ public enum MessageTypeEnum { //DESIGN_COMPLIANCE_NOTIFICATION("Design Compliance Notification", "12"), // 设计符合性通知 //PRE_HOMO_NOTIFICATION("Pre-Homo Notification", "13"), // Pre-Homo通知 //VALIDATION_COMPLIANCE_NOTIFICATION("Validation Compliance Notification", "14"), // 验证符合性通知 - SYSTEMATIC_NOTIFICATION("Systematic Notification", "15"), // 系统通知 - LIST_CONFIRMATION("List Confirmation", "17"), // 清单确认 - TASK_CONFIRMATION("Task Confirmation", "18"), // 任务确认 - COMPLIANCE_CONFIRMATION("Compliance Confirmation", "19"), // 符合性确认 - COLLECTION_OF_LEGISLATIVE_COMMENTS("Collection of Legislative Comments", "20"), // 法规意见收集 - REGULATORY_AND_TECHNICAL_ASSESSMENT("Regulatory and technical assessment", "21"), // 法规技术评估 + SYSTEMATIC_NOTIFICATION("Systematic Notification","", "15"), // 系统通知 + LIST_CONFIRMATION("List Confirmation", "","17"), // 清单确认 + TASK_CONFIRMATION("Task Confirmation", "","18"), // 任务确认 + COMPLIANCE_CONFIRMATION("Compliance Confirmation","", "19"), // 符合性确认 + COLLECTION_OF_LEGISLATIVE_COMMENTS("Collection of Legislative Comments","", "20"), // 法规意见收集 + REGULATORY_AND_TECHNICAL_ASSESSMENT("Regulatory and technical assessment", "","21"), // 法规技术评估 ; String name; + String nameCn; String value; - private MessageTypeEnum(String name, String value) { + private MessageTypeEnum(String name,String nameCn, String value) { this.name = name; + this.nameCn = nameCn; this.value = value; } @@ -52,4 +54,12 @@ public enum MessageTypeEnum { public void setValue(String value) { this.value = value; } + + public String getNameCn() { + return nameCn; + } + + public void setNameCn(String nameCn) { + this.nameCn = nameCn; + } } diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/service/impl/BussDocumentLibraryEOServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/service/impl/BussDocumentLibraryEOServiceImpl.java index 6640c4b1a..4353c9894 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/service/impl/BussDocumentLibraryEOServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/service/impl/BussDocumentLibraryEOServiceImpl.java @@ -2208,9 +2208,18 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImplXXX对“GB 7258 进行了修改请及时查看”) //向订阅领域管理中订阅了该技术领域的人和文档库中订阅了该条文档的人发送消息 + // 只有技术领域变更为订阅的技术领域这一种情况发消息, 假如订阅了技术领域A,编辑的文档的技术领域也是A,这时编辑的是其他的字段,这种情况不发消息 Map mapTemp = new HashMap<>(); mapTemp.put("domainId", map.get("technology_territory")); mapTemp.put("documentId", map.get("id")); @@ -3434,10 +3444,18 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl dummyInventoryInfoEOList = iDummyInventoryInfoEOService.list(lambdaQueryWrapper); String contentLog = "The "+ baseEO.getName()+" virtual list you subscribed to has been updated as follows:" + "
"; String contentLogFeishu = "The "+ baseEO.getName()+" virtual list you subscribed to has been updated as follows:" + " "; + String contentLogFeishuTemp = "The "+ baseEO.getName()+" virtual list you subscribed to has been updated as follows:" + " "; if(dummyContentChangeEOList.size() == 0){ //没有添加过需要进行第一次添加 @@ -449,7 +451,15 @@ public class DummyInventoryBaseEOServiceImpl extends ServiceImpl serialNumberAddList,List serialNumberDeleteList) throws IOException; + /** * 翻译文本 * @param params diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/feishu/service/impl/FeishuServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/feishu/service/impl/FeishuServiceImpl.java index f20cd3981..0092c6858 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/feishu/service/impl/FeishuServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/feishu/service/impl/FeishuServiceImpl.java @@ -325,7 +325,6 @@ public class FeishuServiceImpl implements IFeishuService { - contentSb.append("{\"tag\": \"hr\"},"); contentSb.append("{"); contentSb.append("\"actions\": ["); contentSb.append("{"); @@ -366,8 +365,6 @@ public class FeishuServiceImpl implements IFeishuService { JSONObject.parseObject(JSONArray.parseArray(jsonObject.get("elements").toString()).get(1).toString()); JSONObject elementFour = JSONObject.parseObject(JSONArray.parseArray(jsonObject.get("elements").toString()).get(3).toString()); - JSONObject elementFive = - JSONObject.parseObject(JSONArray.parseArray(jsonObject.get("elements").toString()).get(4).toString()); //处理内容中的双引号(将尖括号替换成双引号) JSONObject elementOne = getJsonObject(jsonObject, content); @@ -378,13 +375,221 @@ public class FeishuServiceImpl implements IFeishuService { jsonArray.add(elementTwo); 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 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("{"); + 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(); + 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 sendCardMsgVirtua(String[] userIds, FeishuMsgVo feishuMsgVo, + List serialNumberAddList,List serialNumberDeleteList) throws IOException { + String token = getTenantAccessToken(); + // 设置请求头 + Map 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() + "\"\n,"); + contentSb.append("\"tag\": \"lark_md\""); + contentSb.append("}"); + contentSb.append("},"); + }; + if(ObjectUtils.isNotEmpty(serialNumberAddList)){ + int count = 1; + contentSb.append("{"); + contentSb.append("\"tag\": \"div\","); + contentSb.append("\"text\": {"); + contentSb.append("\"content\": \"" + count + ". 新增文档: " + StringUtils.join(serialNumberAddList,",") + "\"\n,"); + contentSb.append("\"tag\": \"lark_md\""); + contentSb.append("}"); + contentSb.append("},"); + } + if(ObjectUtils.isNotEmpty(serialNumberDeleteList)){ + int count = 2; + contentSb.append("{"); + contentSb.append("\"tag\": \"div\","); + contentSb.append("\"text\": {"); + contentSb.append("\"content\": \"" + count + ". 删除文档: " + StringUtils.join(serialNumberDeleteList,",") + "\"\n,"); + 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() + "\"\n,"); + contentSb.append("\"tag\": \"lark_md\""); + contentSb.append("}"); + contentSb.append("},"); + }; + + if (ObjectUtils.isNotEmpty(serialNumberAddList)) { + int count = 1; + contentSb.append("{"); + contentSb.append("\"tag\": \"div\","); + contentSb.append("\"text\": {"); + contentSb.append("\"content\": \"" + count + ". New regulations: " + StringUtils.join(serialNumberAddList,",") + "\"\n,"); + contentSb.append("\"tag\": \"lark_md\""); + contentSb.append("}"); + contentSb.append("},"); + } + if (ObjectUtils.isNotEmpty(serialNumberDeleteList)) { + int count = 2; + contentSb.append("{"); + contentSb.append("\"tag\": \"div\","); + contentSb.append("\"text\": {"); + contentSb.append("\"content\": \"" + count + ". Remove regulations: " + StringUtils.join(serialNumberDeleteList,",") + "\"\n,"); + contentSb.append("\"tag\": \"lark_md\""); + contentSb.append("}"); + contentSb.append("},"); + } + + 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(); diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/problemKnowledgeBase/service/impl/ProblemKnowledgeBaseEOServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/problemKnowledgeBase/service/impl/ProblemKnowledgeBaseEOServiceImpl.java index 9ab7619ea..79bbdb54d 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/problemKnowledgeBase/service/impl/ProblemKnowledgeBaseEOServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/problemKnowledgeBase/service/impl/ProblemKnowledgeBaseEOServiceImpl.java @@ -18,6 +18,7 @@ import com.jero.modules.document.enums.SearchEnum; import com.jero.modules.document.utils.ReadPdfUtil; import com.jero.modules.document.utils.ReadWordUtil; import com.jero.modules.feishu.service.IFeishuService; +import com.jero.modules.feishu.vo.FeishuMsgVo; import com.jero.modules.message.websocket.WebSocket; import com.jero.modules.oss.entity.OSSFile; import com.jero.modules.oss.service.IOSSFileService; @@ -886,7 +887,20 @@ public class ProblemKnowledgeBaseEOServiceImpl extends ServiceImpl