wangyunpeng 7 месяцев назад
Родитель
Сommit
045820a349

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

@@ -8,6 +8,7 @@ import java.util.Objects;
 public enum FeishuRobotIdEnum {
     RECOMMEND("长文排序报警群", "07026a9f-43f5-448b-ba40-a8d71bd6e634"),
     JOB("定时任务报警群", "186c9798-5b6a-4ff8-b7fc-4ce4b6ea5076"),
+    ARTICLE_DELETE("文章删除报警群", "6e43785b-19f6-4d28-a369-829ba8d7bf5d"),
 
     ;
 

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

@@ -50,4 +50,6 @@ public interface AigcBaseMapper {
     List<PublishGzhPushDTO> getPushByPushIdIn(List<String> pushIds);
 
     List<PublishGzhPushContentRelDTO> getGroupPushRelByPushIdIn(List<String> pushIds);
+
+    PublishContentDTO getPublishContentById(String publishContentId);
 }

+ 9 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/entity/longArticle/LongArticleAuditDelete.java

@@ -26,6 +26,15 @@ public class LongArticleAuditDelete {
     @Column(name = "index")
     private Integer index;
 
+    @Column(name = "push_id")
+    private String pushId;
+
+    @Column(name = "push_type")
+    private Integer pushType;
+
+    @Column(name = "publish_content_id")
+    private String publishContentId;
+
     @Column(name = "status")
     private Integer status;
 

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

@@ -3,6 +3,8 @@ package com.tzld.longarticle.recommend.server.service.recommend;
 import cn.hutool.core.collection.CollectionUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.tzld.longarticle.recommend.server.common.enums.StatusEnum;
+import com.tzld.longarticle.recommend.server.common.enums.aigc.PushTypeEnum;
+import com.tzld.longarticle.recommend.server.common.enums.recommend.FeishuRobotIdEnum;
 import com.tzld.longarticle.recommend.server.mapper.aigc.AigcBaseMapper;
 import com.tzld.longarticle.recommend.server.model.dto.*;
 import com.tzld.longarticle.recommend.server.model.entity.aigc.PublishAccount;
@@ -13,6 +15,7 @@ import com.tzld.longarticle.recommend.server.remote.WxArticleDeleteService;
 import com.tzld.longarticle.recommend.server.repository.aigc.PublishAccountRepository;
 import com.tzld.longarticle.recommend.server.repository.longArticle.*;
 import com.tzld.longarticle.recommend.server.util.DateUtils;
+import com.tzld.longarticle.recommend.server.util.feishu.FeishuMessageSender;
 import com.xxl.job.core.biz.model.ReturnT;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import lombok.extern.slf4j.Slf4j;
@@ -22,6 +25,7 @@ import org.springframework.util.StringUtils;
 
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
@@ -85,8 +89,6 @@ public class ArticleAuditService {
 
     /**
      * 视频审核结果处理
-     * @param param
-     * @return
      */
     public void articleVideoAuditResult(ArticleVideoAuditResultParam param) {
         LongArticleVideoAudit longArticleVideoAudit = longArticleVideoAuditRepository.getByVideoId(param.getVideoId());
@@ -117,6 +119,8 @@ public class ArticleAuditService {
         Map<String, String> publishPushIdMap = pushContentRelList.stream()
                 .collect(Collectors.toMap(PublishGzhPushContentRelDTO::getPublishContentId, PublishGzhPushContentRelDTO::getPushId));
         List<PublishGzhPushDTO> pushList = aigcBaseMapper.getPushByPushIdIn(pushIds);
+        Map<String, PublishGzhPushDTO> pushDTOMap = pushList.stream()
+                .collect(Collectors.toMap(PublishGzhPushDTO::getPushId, Function.identity()));
         Map<String, String> pushIdMap = pushList.stream()
                 .collect(Collectors.toMap(PublishGzhPushDTO::getPushId, PublishGzhPushDTO::getGroupPushMsgId));
         List<String> publishAccountIds = pushList.stream().map(PublishGzhPushDTO::getPublishAccountId).collect(Collectors.toList());
@@ -131,6 +135,11 @@ public class ArticleAuditService {
         for (String traceId : traceIds) {
             String publishContentId = publishContentIdMap.get(traceId);
             String pushId = publishPushIdMap.get(publishContentId);
+            if (!StringUtils.hasText(pushId)) {
+                // todo 未发布文章如何进行小程序替换
+                continue;
+            }
+            PublishGzhPushDTO publishGzhPushDTO = pushDTOMap.get(pushId);
             String groupPushMsgId = pushIdMap.get(pushId);
             String publishAccountId = pushAccountMap.get(pushId);
             String ghId = publishAccountMap.get(publishAccountId);
@@ -145,6 +154,9 @@ public class ArticleAuditService {
             LongArticleAuditDelete delete = new LongArticleAuditDelete();
             delete.setGhId(ghId);
             delete.setMsgId(groupPushMsgId);
+            delete.setPushId(pushId);
+            delete.setPushType(publishGzhPushDTO.getPushType());
+            delete.setPublishContentId(publishContentId);
             delete.setIndex(index);
             delete.setStatus(StatusEnum.ZERO.getCode());
             delete.setCreateTimestamp(System.currentTimeMillis());
@@ -154,25 +166,38 @@ public class ArticleAuditService {
 
     /**
      * 删除审核不通过,已发布文章
-     *
-     * @param param
-     * @return
      */
     @XxlJob("articleVideoDelete")
     public ReturnT<String> articleVideoDelete(String param) {
         List<LongArticleAuditDelete> dealList = longArticleAuditDeleteRepository.getByStatus(StatusEnum.ZERO.getCode());
         for (LongArticleAuditDelete delete : dealList) {
-            // 获取token
-            String token = wxAccessTokenRemoteService.getAccessToken(delete.getGhId());
-            // 删除文章
-            RequestResult<String> result = wxArticleDeleteService.deleteArticle(token, delete.getMsgId(), delete.getIndex());
-            if (result.isSuccess()) {
-                delete.setStatus(StatusEnum.ONE.getCode());
+            if (Objects.equals(delete.getPushType(), PushTypeEnum.AUTO_GROUP_PUBLISH.getVal())) {
+                // 获取token
+                String token = wxAccessTokenRemoteService.getAccessToken(delete.getGhId());
+                // 删除文章
+                RequestResult<String> result = wxArticleDeleteService.deleteArticle(token, delete.getMsgId(), delete.getIndex());
+                if (result.isSuccess()) {
+                    delete.setStatus(StatusEnum.ONE.getCode());
+                } else {
+                    delete.setStatus(StatusEnum.TWO.getCode());
+                    delete.setFinishTimestamp(System.currentTimeMillis());
+                }
+                longArticleAuditDeleteRepository.save(delete);
             } else {
-                delete.setStatus(StatusEnum.TWO.getCode());
-                delete.setFinishTimestamp(System.currentTimeMillis());
+                PublishAccount publishAccount = publishAccountRepository.getByGhId(delete.getGhId());
+                PublishContentDTO publishContent = aigcBaseMapper.getPublishContentById(delete.getPublishContentId());
+                String publishTime = DateUtils.timestampToYMDStr(publishContent.getPublishTimestamp() / 1000, "yyyyMMdd");
+                // 无法自动删除 发送飞书通知 人工删除
+                FeishuMessageSender.sendWebHookMessage(FeishuRobotIdEnum.ARTICLE_DELETE.getRobotId(),
+                        "视频审核不通过文章删除\n"
+                                + "账号名称: " + publishAccount.getName() + "\n"
+                                + "发布日期: " + publishTime + "\n"
+                                + "位置: " + delete.getIndex() + "\n"
+                                + "标题: " + publishContent.getTitle());
+
+                delete.setStatus(StatusEnum.ONE.getCode());
+                longArticleAuditDeleteRepository.save(delete);
             }
-            longArticleAuditDeleteRepository.save(delete);
         }
         return ReturnT.SUCCESS;
     }

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

@@ -240,4 +240,13 @@
         order by id
     </select>
 
+    <select id="getPublishContentById"
+            resultType="com.tzld.longarticle.recommend.server.model.dto.PublishContentDTO">
+        select content.id, content.publish_timestamp, output.output as title
+        from publish_content content
+         join publish_content_output output
+          on content.id = output.publish_content_id and output.content_type = 3 AND output.select_status = 1
+        where content.id = #{publishContentId}
+    </select>
+
 </mapper>