|
@@ -0,0 +1,280 @@
|
|
|
+package org.jeecg.modules.okki.site.service.impl;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.jeecg.common.util.HttpClientUtil;
|
|
|
+import org.jeecg.modules.okki.site.service.IFeiShuMsgService;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author Chen
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class FeiShuMsgServiceImpl implements IFeiShuMsgService {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发送飞书消息
|
|
|
+ *
|
|
|
+ * @param customerName
|
|
|
+ * @param siteId
|
|
|
+ * @param planName
|
|
|
+ * @param syncStatus
|
|
|
+ */
|
|
|
+ public void sendSyncFeiShuSheetMsg(String customerName, String siteId, String planName, String syncStatus) {
|
|
|
+ String botUrl = "https://open.feishu.cn/open-apis/bot/v2/hook/f77f9317-5f15-4aa7-8036-32ce771f40c1";
|
|
|
+
|
|
|
+ String template = "{\n" +
|
|
|
+ " \"config\": {\n" +
|
|
|
+ " \"update_multi\": true\n" +
|
|
|
+ " },\n" +
|
|
|
+ " \"i18n_elements\": {\n" +
|
|
|
+ " \"zh_cn\": [\n" +
|
|
|
+ " {\n" +
|
|
|
+ " \"tag\": \"markdown\",\n" +
|
|
|
+ " \"content\": \"<at id=\\\"all\\\">所有人</at> \",\n" +
|
|
|
+ " \"text_align\": \"left\",\n" +
|
|
|
+ " \"text_size\": \"normal\"\n" +
|
|
|
+ " },\n" +
|
|
|
+ " {\n" +
|
|
|
+ " \"tag\": \"column_set\",\n" +
|
|
|
+ " \"flex_mode\": \"none\",\n" +
|
|
|
+ " \"background_style\": \"default\",\n" +
|
|
|
+ " \"horizontal_spacing\": \"8px\",\n" +
|
|
|
+ " \"horizontal_align\": \"left\",\n" +
|
|
|
+ " \"columns\": [\n" +
|
|
|
+ " {\n" +
|
|
|
+ " \"tag\": \"column\",\n" +
|
|
|
+ " \"width\": \"weighted\",\n" +
|
|
|
+ " \"vertical_align\": \"top\",\n" +
|
|
|
+ " \"vertical_spacing\": \"8px\",\n" +
|
|
|
+ " \"background_style\": \"default\",\n" +
|
|
|
+ " \"elements\": [\n" +
|
|
|
+ " {\n" +
|
|
|
+ " \"tag\": \"markdown\",\n" +
|
|
|
+ " \"content\": \"**公司名称:**\\n${customerName}\",\n" +
|
|
|
+ " \"text_align\": \"left\",\n" +
|
|
|
+ " \"text_size\": \"normal\"\n" +
|
|
|
+ " },\n" +
|
|
|
+ " {\n" +
|
|
|
+ " \"tag\": \"markdown\",\n" +
|
|
|
+ " \"content\": \"**套餐名称:**\\n${planName}\",\n" +
|
|
|
+ " \"text_align\": \"left\",\n" +
|
|
|
+ " \"text_size\": \"normal\"\n" +
|
|
|
+ " }\n" +
|
|
|
+ " ],\n" +
|
|
|
+ " \"weight\": 1\n" +
|
|
|
+ " },\n" +
|
|
|
+ " {\n" +
|
|
|
+ " \"tag\": \"column\",\n" +
|
|
|
+ " \"width\": \"weighted\",\n" +
|
|
|
+ " \"vertical_align\": \"top\",\n" +
|
|
|
+ " \"vertical_spacing\": \"8px\",\n" +
|
|
|
+ " \"background_style\": \"default\",\n" +
|
|
|
+ " \"elements\": [\n" +
|
|
|
+ " {\n" +
|
|
|
+ " \"tag\": \"markdown\",\n" +
|
|
|
+ " \"content\": \"**站点ID:**\\n${siteId}\",\n" +
|
|
|
+ " \"text_align\": \"left\",\n" +
|
|
|
+ " \"text_size\": \"normal\"\n" +
|
|
|
+ " },\n" +
|
|
|
+ " {\n" +
|
|
|
+ " \"tag\": \"markdown\",\n" +
|
|
|
+ " \"content\": \"**同步状态:**\\n${syncStatus}\",\n" +
|
|
|
+ " \"text_align\": \"left\",\n" +
|
|
|
+ " \"text_size\": \"normal\"\n" +
|
|
|
+ " }\n" +
|
|
|
+ " ],\n" +
|
|
|
+ " \"weight\": 1\n" +
|
|
|
+ " }\n" +
|
|
|
+ " ],\n" +
|
|
|
+ " \"margin\": \"16px 0px 0px 0px\"\n" +
|
|
|
+ " },\n" +
|
|
|
+ " {\n" +
|
|
|
+ " \"tag\": \"hr\"\n" +
|
|
|
+ " },\n" +
|
|
|
+ " {\n" +
|
|
|
+ " \"tag\": \"column_set\",\n" +
|
|
|
+ " \"flex_mode\": \"none\",\n" +
|
|
|
+ " \"horizontal_spacing\": \"default\",\n" +
|
|
|
+ " \"background_style\": \"default\",\n" +
|
|
|
+ " \"columns\": [\n" +
|
|
|
+ " {\n" +
|
|
|
+ " \"tag\": \"column\",\n" +
|
|
|
+ " \"elements\": [\n" +
|
|
|
+ " {\n" +
|
|
|
+ " \"tag\": \"div\",\n" +
|
|
|
+ " \"text\": {\n" +
|
|
|
+ " \"tag\": \"plain_text\",\n" +
|
|
|
+ " \"content\": \"来自 OK项目组-文档机器人\",\n" +
|
|
|
+ " \"text_size\": \"normal\",\n" +
|
|
|
+ " \"text_align\": \"left\",\n" +
|
|
|
+ " \"text_color\": \"default\"\n" +
|
|
|
+ " }\n" +
|
|
|
+ " }\n" +
|
|
|
+ " ],\n" +
|
|
|
+ " \"width\": \"weighted\",\n" +
|
|
|
+ " \"weight\": 1\n" +
|
|
|
+ " }\n" +
|
|
|
+ " ]\n" +
|
|
|
+ " }\n" +
|
|
|
+ " ]\n" +
|
|
|
+ " },\n" +
|
|
|
+ " \"i18n_header\": {\n" +
|
|
|
+ " \"zh_cn\": {\n" +
|
|
|
+ " \"title\": {\n" +
|
|
|
+ " \"tag\": \"plain_text\",\n" +
|
|
|
+ " \"content\": \"【站点同步】OMS平台同步站点至飞书表格通知\"\n" +
|
|
|
+ " },\n" +
|
|
|
+ " \"subtitle\": {\n" +
|
|
|
+ " \"tag\": \"plain_text\",\n" +
|
|
|
+ " \"content\": \"\"\n" +
|
|
|
+ " },\n" +
|
|
|
+ " \"template\": \"green\"\n" +
|
|
|
+ " }\n" +
|
|
|
+ " }\n" +
|
|
|
+ "}";
|
|
|
+ template = template.replace("${customerName}", customerName);
|
|
|
+ template = template.replace("${siteId}", siteId);
|
|
|
+ template = template.replace("${planName}", planName);
|
|
|
+ template = template.replace("${syncStatus}", syncStatus);
|
|
|
+
|
|
|
+ JSONObject object = new JSONObject();
|
|
|
+ object.put("msg_type", "interactive");
|
|
|
+ object.put("card", template);
|
|
|
+ HttpClientUtil.doPostJson(botUrl, object.toJSONString());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param customerName
|
|
|
+ * @param siteId
|
|
|
+ * @param planName
|
|
|
+ * @param status
|
|
|
+ */
|
|
|
+ public void sendUpdateFeiShuSheetMsg(String customerName, String siteId, String groupName, String status) {
|
|
|
+ String botUrl = "https://open.feishu.cn/open-apis/bot/v2/hook/f77f9317-5f15-4aa7-8036-32ce771f40c1";
|
|
|
+
|
|
|
+ String template = "{\n" +
|
|
|
+ " \"config\": {\n" +
|
|
|
+ " \"update_multi\": true\n" +
|
|
|
+ " },\n" +
|
|
|
+ " \"i18n_elements\": {\n" +
|
|
|
+ " \"zh_cn\": [\n" +
|
|
|
+ " {\n" +
|
|
|
+ " \"tag\": \"markdown\",\n" +
|
|
|
+ " \"content\": \"<at id=\\\"all\\\">所有人</at> \",\n" +
|
|
|
+ " \"text_align\": \"left\",\n" +
|
|
|
+ " \"text_size\": \"normal\"\n" +
|
|
|
+ " },\n" +
|
|
|
+ " {\n" +
|
|
|
+ " \"tag\": \"column_set\",\n" +
|
|
|
+ " \"flex_mode\": \"none\",\n" +
|
|
|
+ " \"background_style\": \"default\",\n" +
|
|
|
+ " \"horizontal_spacing\": \"8px\",\n" +
|
|
|
+ " \"horizontal_align\": \"left\",\n" +
|
|
|
+ " \"columns\": [\n" +
|
|
|
+ " {\n" +
|
|
|
+ " \"tag\": \"column\",\n" +
|
|
|
+ " \"width\": \"weighted\",\n" +
|
|
|
+ " \"vertical_align\": \"top\",\n" +
|
|
|
+ " \"vertical_spacing\": \"8px\",\n" +
|
|
|
+ " \"background_style\": \"default\",\n" +
|
|
|
+ " \"elements\": [\n" +
|
|
|
+ " {\n" +
|
|
|
+ " \"tag\": \"markdown\",\n" +
|
|
|
+ " \"content\": \"**公司名称:**\\n${customerName}\",\n" +
|
|
|
+ " \"text_align\": \"left\",\n" +
|
|
|
+ " \"text_size\": \"normal\"\n" +
|
|
|
+ " },\n" +
|
|
|
+ " {\n" +
|
|
|
+ " \"tag\": \"markdown\",\n" +
|
|
|
+ " \"content\": \"**建站小组:**\\n${groupName}\",\n" +
|
|
|
+ " \"text_align\": \"left\",\n" +
|
|
|
+ " \"text_size\": \"normal\"\n" +
|
|
|
+ " }\n" +
|
|
|
+ " ],\n" +
|
|
|
+ " \"weight\": 1\n" +
|
|
|
+ " },\n" +
|
|
|
+ " {\n" +
|
|
|
+ " \"tag\": \"column\",\n" +
|
|
|
+ " \"width\": \"weighted\",\n" +
|
|
|
+ " \"vertical_align\": \"top\",\n" +
|
|
|
+ " \"vertical_spacing\": \"8px\",\n" +
|
|
|
+ " \"background_style\": \"default\",\n" +
|
|
|
+ " \"elements\": [\n" +
|
|
|
+ " {\n" +
|
|
|
+ " \"tag\": \"markdown\",\n" +
|
|
|
+ " \"content\": \"**站点ID:**\\n${siteId}\",\n" +
|
|
|
+ " \"text_align\": \"left\",\n" +
|
|
|
+ " \"text_size\": \"normal\"\n" +
|
|
|
+ " },\n" +
|
|
|
+ " {\n" +
|
|
|
+ " \"tag\": \"markdown\",\n" +
|
|
|
+ " \"content\": \"**更新状态:**\\n${status}\",\n" +
|
|
|
+ " \"text_align\": \"left\",\n" +
|
|
|
+ " \"text_size\": \"normal\"\n" +
|
|
|
+ " }\n" +
|
|
|
+ " ],\n" +
|
|
|
+ " \"weight\": 1\n" +
|
|
|
+ " }\n" +
|
|
|
+ " ],\n" +
|
|
|
+ " \"margin\": \"16px 0px 0px 0px\"\n" +
|
|
|
+ " },\n" +
|
|
|
+ " {\n" +
|
|
|
+ " \"tag\": \"hr\"\n" +
|
|
|
+ " },\n" +
|
|
|
+ " {\n" +
|
|
|
+ " \"tag\": \"column_set\",\n" +
|
|
|
+ " \"flex_mode\": \"none\",\n" +
|
|
|
+ " \"horizontal_spacing\": \"default\",\n" +
|
|
|
+ " \"background_style\": \"default\",\n" +
|
|
|
+ " \"columns\": [\n" +
|
|
|
+ " {\n" +
|
|
|
+ " \"tag\": \"column\",\n" +
|
|
|
+ " \"elements\": [\n" +
|
|
|
+ " {\n" +
|
|
|
+ " \"tag\": \"div\",\n" +
|
|
|
+ " \"text\": {\n" +
|
|
|
+ " \"tag\": \"plain_text\",\n" +
|
|
|
+ " \"content\": \"来自 OK项目组-文档机器人\",\n" +
|
|
|
+ " \"text_size\": \"normal\",\n" +
|
|
|
+ " \"text_align\": \"left\",\n" +
|
|
|
+ " \"text_color\": \"default\"\n" +
|
|
|
+ " }\n" +
|
|
|
+ " }\n" +
|
|
|
+ " ],\n" +
|
|
|
+ " \"width\": \"weighted\",\n" +
|
|
|
+ " \"weight\": 1\n" +
|
|
|
+ " }\n" +
|
|
|
+ " ]\n" +
|
|
|
+ " }\n" +
|
|
|
+ " ]\n" +
|
|
|
+ " },\n" +
|
|
|
+ " \"i18n_header\": {\n" +
|
|
|
+ " \"zh_cn\": {\n" +
|
|
|
+ " \"title\": {\n" +
|
|
|
+ " \"tag\": \"plain_text\",\n" +
|
|
|
+ " \"content\": \"${title}\"\n" +
|
|
|
+ " },\n" +
|
|
|
+ " \"subtitle\": {\n" +
|
|
|
+ " \"tag\": \"plain_text\",\n" +
|
|
|
+ " \"content\": \"\"\n" +
|
|
|
+ " },\n" +
|
|
|
+ " \"template\": \"green\"\n" +
|
|
|
+ " }\n" +
|
|
|
+ " }\n" +
|
|
|
+ "}";
|
|
|
+ template = template.replace("${title}", "【"+customerName+"】分配建站小组通知");
|
|
|
+ template = template.replace("${customerName}", customerName);
|
|
|
+ template = template.replace("${siteId}", siteId);
|
|
|
+ template = template.replace("${groupName}", groupName);
|
|
|
+ template = template.replace("${status}", status);
|
|
|
+
|
|
|
+ JSONObject object = new JSONObject();
|
|
|
+ object.put("msg_type", "interactive");
|
|
|
+ object.put("card", template);
|
|
|
+ HttpClientUtil.doPostJson(botUrl, object.toJSONString());
|
|
|
+ }
|
|
|
+}
|