Browse Source

Merge branch 'wyp/1218-articleDeleteAlarm' of Server/long-article-recommend into master

wangyunpeng 6 months ago
parent
commit
02f678ad90

+ 2 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/mapper/aigc/AigcBaseMapper.java

@@ -60,4 +60,6 @@ public interface AigcBaseMapper {
     List<CrawlerPlan> getColdCrawlerPlan(Long timeStart, Long timeEnd, List<String> planTags);
 
     List<ProducePlanAuditCheckDTO> getColdProducePlanAudit(Long timeStart, Long timeEnd, List<String> planIds);
+
+    List<PublishAccountTypeDTO> getAccountTypeList();
 }

+ 15 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/dto/PublishAccountTypeDTO.java

@@ -0,0 +1,15 @@
+package com.tzld.longarticle.recommend.server.model.dto;
+
+import lombok.Data;
+
+@Data
+public class PublishAccountTypeDTO {
+
+    private String name;
+    private String ghId;
+    private Integer followerCount;
+    private String accountSourceName;
+    private String modeType;
+    private String accountTpe;
+    private String status;
+}

+ 23 - 13
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/ArticleAuditService.java

@@ -229,16 +229,19 @@ public class ArticleAuditService {
         List<PublishGzhPushContentRelDTO> groupPushRelList = aigcBaseMapper.getGroupPushRelByPushIdIn(pushIds);
         Map<String, List<PublishGzhPushContentRelDTO>> groupPushRelMap = groupPushRelList.stream()
                 .collect(Collectors.groupingBy(PublishGzhPushContentRelDTO::getPushId));
+        List<PublishAccountTypeDTO> accountTypeList = aigcBaseMapper.getAccountTypeList();
+        Map<String, PublishAccountTypeDTO> accountTypeMap = accountTypeList.stream()
+               .collect(Collectors.toMap(PublishAccountTypeDTO::getGhId, Function.identity()));
         // 删除文章
         for (String publishContentId : publishContentIds) {
             String pushId = publishPushIdMap.get(publishContentId);
             if (!StringUtils.hasText(pushId)) {
-                deleteFailAlarm(publishContentId, "无推送记录", 0);
+                deleteFailAlarm(publishContentId, "无推送记录", 0, accountTypeMap);
                 continue;
             }
             PublishGzhPushDTO publishGzhPushDTO = pushDTOMap.get(pushId);
             if (Objects.isNull(publishGzhPushDTO)) {
-                deleteFailAlarm(publishContentId, "无推送记录", 0);
+                deleteFailAlarm(publishContentId, "无推送记录", 0, accountTypeMap);
                 continue;
             }
             String publishAccountId = pushAccountMap.get(pushId);
@@ -254,12 +257,12 @@ public class ArticleAuditService {
             }
             if (!publishGzhPushDTO.getPushType().equals(PushTypeEnum.AUTO_GROUP_PUBLISH.getVal())) {
                 PushTypeEnum pushTypeEnum = PushTypeEnum.from(publishGzhPushDTO.getPushType());
-                deleteFailAlarm(publishContentId, "推送类型为" + pushTypeEnum.getDescription(), index);
+                deleteFailAlarm(publishContentId, "推送类型为" + pushTypeEnum.getDescription(), index, accountTypeMap);
                 continue;
             }
             String groupPushMsgId = pushIdMap.get(pushId);
             if (!StringUtils.hasText(groupPushMsgId)) {
-                deleteFailAlarm(publishContentId, "无推送MsgId", index);
+                deleteFailAlarm(publishContentId, "无推送MsgId", index, accountTypeMap);
                 continue;
             }
             LongArticleAuditDelete delete = new LongArticleAuditDelete();
@@ -281,6 +284,9 @@ public class ArticleAuditService {
     @XxlJob("articleVideoDelete")
     public ReturnT<String> articleVideoDelete(String param) {
         List<LongArticleAuditDelete> dealList = longArticleAuditDeleteRepository.getByStatus(ArticleDeleteStatusEnum.WAITING.getCode());
+        List<PublishAccountTypeDTO> accountTypeList = aigcBaseMapper.getAccountTypeList();
+        Map<String, PublishAccountTypeDTO> accountTypeMap = accountTypeList.stream()
+                .collect(Collectors.toMap(PublishAccountTypeDTO::getGhId, Function.identity()));
         for (LongArticleAuditDelete delete : dealList) {
             try {
                 if (Objects.equals(delete.getPushType(), PushTypeEnum.AUTO_GROUP_PUBLISH.getVal())) {
@@ -295,7 +301,7 @@ public class ArticleAuditService {
                         delete.setFailReason(result.getFailReason());
                     }
                 } else {
-                    deleteFailAlarm(delete.getPublishContentId(), "非自动群发", delete.getIndex());
+                    deleteFailAlarm(delete.getPublishContentId(), "非自动群发", delete.getIndex(), accountTypeMap);
                     delete.setStatus(ArticleDeleteStatusEnum.SUCCESS.getCode());
                 }
                 delete.setFinishTimestamp(System.currentTimeMillis());
@@ -307,19 +313,23 @@ public class ArticleAuditService {
         return ReturnT.SUCCESS;
     }
 
-    private void deleteFailAlarm(String publishContentId, String typeMsg, Integer index) {
+    private void deleteFailAlarm(String publishContentId, String typeMsg, Integer index,
+                                 Map<String, PublishAccountTypeDTO> accountTypeMap) {
         PublishContentDTO publishContent = aigcBaseMapper.getPublishContentById(publishContentId);
         PublishAccount publishAccount = publishAccountRepository.getById(publishContent.getPublishAccountId());
         String publishTime = DateUtils.timestampToYMDStr(publishContent.getPublishTimestamp() / 1000, "yyyyMMdd");
+        PublishAccountTypeDTO accountTypeDTO = accountTypeMap.get(publishAccount.getGhId());
+        String accountType = Objects.nonNull(accountTypeDTO) ? accountTypeDTO.getAccountTpe() : "未知";
         // 无法自动删除 发送飞书通知 人工删除
         FeishuMessageSender.sendWebHookMessage(FeishuRobotIdEnum.ARTICLE_DELETE.getRobotId(),
-                "【文章删除失败】\n"
-                        + "账号名称: " + publishAccount.getName() + "\n"
-                        + "账号ghId: " + publishAccount.getGhId() + "\n"
-                        + "发布日期: " + publishTime + "\n"
-                        + "位置: " + index + "\n"
-                        + "标题: " + publishContent.getTitle() + "\n"
-                        + "原因: " + typeMsg);
+                "【文章删除失败】\n" +
+                        "账号名称: " + publishAccount.getName() + "\n" +
+                        "账号ghId: " + publishAccount.getGhId() + "\n" +
+                        "账号来源: " + accountType + "\n" +
+                        "发布日期: " + publishTime + "\n" +
+                        "位置: " + index + "\n" +
+                        "标题: " + publishContent.getTitle() + "\n" +
+                        "原因: " + typeMsg);
     }
 
     public void titleDangerFindDelete(ArticleDangerFindDeleteParam param) {

+ 14 - 0
long-article-recommend-service/src/main/resources/mapper/aigc/AigcBaseMapper.xml

@@ -296,5 +296,19 @@
         and pper.audit_timestamp between #{timeStart} and #{timeEnd}) or (prr.review_status = 0))
         GROUP BY pper.plan_id, pper.audit_status
     </select>
+    <select id="getAccountTypeList"
+            resultType="com.tzld.longarticle.recommend.server.model.dto.PublishAccountTypeDTO">
+        SELECT DISTINCT t3.`name`, t3.gh_id, t3.follower_count, t6.account_source_name, t6.mode_type,
+                        t6.account_type, t6.`status`
+        FROM publish_plan t1
+        JOIN publish_plan_account t2 ON t1.id = t2.plan_id
+        JOIN publish_account t3 ON t2.account_id = t3.id
+        LEFT JOIN publish_account_wx_type t4 on t3.id = t4.account_id
+        LEFT JOIN wx_statistics_group_source_account t5 on t3.id = t5.account_id
+        LEFT JOIN wx_statistics_group_source t6 on t5.group_source_name = t6.account_source_name
+        WHERE t1.plan_status = 1
+          AND t3.channel = 5
+        GROUP BY t3.id;
+    </select>
 
 </mapper>