Przeglądaj źródła

Merge branch 'wyp/1230-checkPublishPlanAccount' of Server/long-article-recommend into master

wangyunpeng 6 miesięcy temu
rodzic
commit
9b11961937

+ 2 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/common/enums/recommend/FeishuRobotIdEnum.java

@@ -12,6 +12,8 @@ public enum FeishuRobotIdEnum {
     ARTICLE_DELETE("文章删除报警群", "2262caec-3f52-4a93-9fa5-da2382a21482"),
     ARTICLE_SAFE_AUDIT("长文内容安全审核群", "ea26981a-cf97-4eeb-b1e8-1c4a9f895090"),
 
+    TEST("test", "eb781adb-066a-455b-88a2-57b4f7bb5082"),
+
     ;
 
     private final String groupName;

+ 31 - 6
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/XxlJobService.java

@@ -8,6 +8,7 @@ import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
 import com.google.common.collect.Lists;
 import com.google.common.util.concurrent.ThreadFactoryBuilder;
 import com.tzld.longarticle.recommend.server.common.CommonThreadPoolExecutor;
+import com.tzld.longarticle.recommend.server.common.enums.FieshuTableColumnDataTypeEnum;
 import com.tzld.longarticle.recommend.server.common.enums.aigc.ProduceContentAuditStatusEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.AccountBusinessTypeEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.ContentPoolEnum;
@@ -26,6 +27,7 @@ import com.tzld.longarticle.recommend.server.model.entity.crawler.LongArticlesVi
 import com.tzld.longarticle.recommend.server.model.entity.longArticle.*;
 import com.tzld.longarticle.recommend.server.model.param.ArticleFindSourceParam;
 import com.tzld.longarticle.recommend.server.model.param.TitleHisCacheParam;
+import com.tzld.longarticle.recommend.server.model.vo.FeishuTableDTO;
 import com.tzld.longarticle.recommend.server.remote.ODPSManager;
 import com.tzld.longarticle.recommend.server.repository.aigc.ProducePlanRepository;
 import com.tzld.longarticle.recommend.server.repository.crawler.GetOffVideoCrawlerRepository;
@@ -197,6 +199,8 @@ public class XxlJobService {
         List<PublishPlanAccountNotifyDTO> notifyAccounts = aigcBaseMapper.checkPublishPlanAccount();
         Map<String, List<PublishPlanAccountNotifyDTO>> notifyAccountMap = notifyAccounts.stream()
                 .collect(Collectors.groupingBy(PublishPlanAccountNotifyDTO::getPlanId));
+        List<FeishuTableDTO.Column> columns = buildCheckPublishPlanAccountColumns();
+        List<JSONObject> rows = new ArrayList<>();
         for (Map.Entry<String, List<PublishPlanAccountNotifyDTO>> entry : notifyAccountMap.entrySet()) {
             String planId = entry.getKey();
             List<PublishPlanAccountNotifyDTO> list = entry.getValue();
@@ -206,16 +210,37 @@ public class XxlJobService {
             String planName = list.get(0).getPlanName();
             List<String> accountNames = list.stream().map(PublishPlanAccountNotifyDTO::getAccountName).collect(Collectors.toList());
             log.info("checkPublishPlanAccount planId: {}, planName: {}, accountNames: {}", planId, planName, JSONObject.toJSONString(accountNames));
-            FeishuMessageSender.sendWebHookMessage(FeishuRobotIdEnum.RECOMMEND.getRobotId(),
-                    "发布计划开启账号未开启计划报警\n"
-                            + "发布计划ID: " + planId + "\n"
-                            + "发布计划名称: " + planName + "\n"
-                            + "开关关闭账号: " + JSONObject.toJSONString(accountNames) + "\n"
-                            + "<at user_id=\"all\">所有人</at> ");
+
+            JSONObject row = new JSONObject();
+            row.put("plan_id", planId);
+            row.put("plan_name", planName);
+            row.put("account_names", accountNames);
+            rows.add(row);
         }
+        FeishuTableDTO tableDTO = FeishuTableDTO.createTable("发布计划开启账号未开启计划报警", columns, rows);
+        JSONObject content = JSONObject.parseObject(JSONObject.toJSONString(tableDTO));
+        // 无法自动删除 发送飞书通知 人工删除
+        JSONObject bodyParam = new JSONObject();
+        bodyParam.put("msg_type", "interactive");
+        bodyParam.put("card", content);
+        FeishuMessageSender.sendWebHookMessage(FeishuRobotIdEnum.RECOMMEND.getRobotId(), bodyParam);
         return ReturnT.SUCCESS;
     }
 
+    private List<FeishuTableDTO.Column> buildCheckPublishPlanAccountColumns() {
+        List<FeishuTableDTO.Column> columns = new ArrayList<>();
+        FeishuTableDTO.Column accountNameColumn = FeishuTableDTO.createFeishuColumns(
+                FieshuTableColumnDataTypeEnum.TEXT.getType(), "plan_id", "发布计划ID", null);
+        columns.add(accountNameColumn);
+        FeishuTableDTO.Column accountGhIdColumn = FeishuTableDTO.createFeishuColumns(
+                FieshuTableColumnDataTypeEnum.TEXT.getType(), "plan_name", "发布计划名称", null);
+        columns.add(accountGhIdColumn);
+        FeishuTableDTO.Column accountTypeColumn = FeishuTableDTO.createFeishuColumns(
+                FieshuTableColumnDataTypeEnum.TEXT.getType(), "account_names", "开关关闭账号", null);
+        columns.add(accountTypeColumn);
+        return columns;
+    }
+
     @XxlJob("checkColdCrawlerPlan")
     public ReturnT<String> checkColdCrawlerPlan(String param) {
         long timeStamp = DateUtils.getBeforeDayStart(1);