wangyunpeng 5 месяцев назад
Родитель
Сommit
ded9a0ede4

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

@@ -39,6 +39,8 @@ public interface PublishContentMapper {
 
     List<PublishGzhPushDTO> getPushByPushIdIn(List<String> pushIds);
 
+    List<PublishGzhPushDTO> getPushByPushTimeBetween(Long start, Long end);
+
     List<PublishGzhPushContentRelDTO> getGroupPushRelByPushIdIn(List<String> pushIds);
 
     PublishContentDTO getPublishContentById(String publishContentId);

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

@@ -74,4 +74,6 @@ public interface LongArticleBaseMapper {
     void batchInsertArticleReMatchRecord(List<ArticleReMatchRecord> list);
 
     List<String> getDisAuditDeleteGhid();
+
+    void batchInsertLongArticleAuditDelete(List<LongArticleAuditDelete> deleteList);
 }

+ 11 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/param/ArticleDeleteParam.java

@@ -0,0 +1,11 @@
+package com.tzld.longarticle.recommend.server.model.param;
+
+import lombok.Data;
+
+@Data
+public class ArticleDeleteParam {
+
+    private String dateStrBegin;
+    private String dateStrEnd;
+
+}

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

@@ -31,6 +31,7 @@ import com.tzld.longarticle.recommend.server.model.entity.crawler.Article;
 import com.tzld.longarticle.recommend.server.model.entity.longArticle.*;
 import com.tzld.longarticle.recommend.server.model.param.ArticleCategoryListParam;
 import com.tzld.longarticle.recommend.server.model.param.ArticleDangerFindDeleteParam;
+import com.tzld.longarticle.recommend.server.model.param.ArticleDeleteParam;
 import com.tzld.longarticle.recommend.server.model.param.PublishContentParam;
 import com.tzld.longarticle.recommend.server.model.vo.ArticleDeleteListVO;
 import com.tzld.longarticle.recommend.server.model.vo.FeishuTableDTO;
@@ -511,9 +512,9 @@ public class ArticleAuditService {
         List<PublishAccountTypeDTO> accountTypeList = publishContentMapper.getAccountTypeList(ghIds);
         Map<String, PublishAccountTypeDTO> accountTypeMap = accountTypeList.stream()
                 .collect(Collectors.toMap(PublishAccountTypeDTO::getGhId, Function.identity()));
-        List<JSONObject> alarmList =  Collections.synchronizedList(new ArrayList<>());
+        List<JSONObject> alarmList = Collections.synchronizedList(new ArrayList<>());
         Map<String, List<LongArticleAuditDelete>> dealMap = dealList.stream().collect(Collectors.groupingBy(LongArticleAuditDelete::getGhId));
-        ExecutorService pool = new CommonThreadPoolExecutor( 10, 10, 0L, TimeUnit.SECONDS,
+        ExecutorService pool = new CommonThreadPoolExecutor(10, 10, 0L, TimeUnit.SECONDS,
                 new LinkedBlockingQueue<>(10000),
                 new ThreadFactoryBuilder().setNameFormat("ArticleVideoDelete-%d").build(),
                 new ThreadPoolExecutor.AbortPolicy());
@@ -529,7 +530,7 @@ public class ArticleAuditService {
                     List<String> msgIds = new ArrayList<>(msgIdMap.keySet());
                     List<LongArticleAuditDelete> accountAllDeleteList = longArticleAuditDeleteRepository.getByGhIdAndMsgIdIn(entry.getKey(), msgIds);
                     Map<String, List<LongArticleAuditDelete>> accountAllDeleteMap = accountAllDeleteList.stream()
-                           .collect(Collectors.groupingBy(LongArticleAuditDelete::getMsgId));
+                            .collect(Collectors.groupingBy(LongArticleAuditDelete::getMsgId));
                     for (Map.Entry<String, List<LongArticleAuditDelete>> msgIdEntry : msgIdMap.entrySet()) {
                         String msgId = msgIdEntry.getKey();
                         List<LongArticleAuditDelete> msgIdList = msgIdEntry.getValue();
@@ -842,4 +843,66 @@ public class ArticleAuditService {
             pageNum++;
         }
     }
+
+    @XxlJob("articleDeleteJob")
+    public ReturnT<String> articleDeleteJob(String param) {
+        articleDelete(null);
+        return ReturnT.SUCCESS;
+    }
+
+    public void articleDelete(ArticleDeleteParam param) {
+        Long startTime = DateUtils.getBeforeDayStart(7);
+        Long endTime = DateUtils.getBeforeDayStart(3);
+        if (Objects.nonNull(param) && StringUtils.hasText(param.getDateStrBegin())) {
+            startTime = DateUtils.dateStrToTimestamp(param.getDateStrBegin(), "yyyyMMdd");
+            endTime = DateUtils.dateStrToTimestamp(param.getDateStrEnd(), "yyyyMMdd");
+        }
+        List<PublishGzhPushDTO> pushList = publishContentMapper.getPushByPushTimeBetween(startTime * 1000, endTime * 1000);
+        List<String> pushIds = pushList.stream().map(PublishGzhPushDTO::getPushId).collect(Collectors.toList());
+        Map<String, String> pushIdMap = pushList.stream().filter(o -> StringUtils.hasText(o.getGroupPushMsgId()))
+                .collect(Collectors.toMap(PublishGzhPushDTO::getPushId, PublishGzhPushDTO::getGroupPushMsgId));
+        List<String> publishAccountIds = pushList.stream().map(PublishGzhPushDTO::getPublishAccountId).collect(Collectors.toList());
+        Map<String, String> pushAccountMap = pushList.stream()
+                .collect(Collectors.toMap(PublishGzhPushDTO::getPushId, PublishGzhPushDTO::getPublishAccountId));
+        List<PublishAccount> publishAccountList = publishAccountRepository.getByIdIn(publishAccountIds);
+        Map<String, String> publishAccountMap = publishAccountList.stream()
+                .collect(Collectors.toMap(PublishAccount::getId, PublishAccount::getGhId));
+        List<PublishGzhPushContentRelDTO> groupPushRelList = publishContentMapper.getGroupPushRelByPushIdIn(pushIds);
+        List<String> publishContentIds = groupPushRelList.stream().map(PublishGzhPushContentRelDTO::getPublishContentId)
+                .collect(Collectors.toList());
+        List<LongArticleAuditDelete> exists = longArticleAuditDeleteRepository.getByPublishContentIdIn(publishContentIds);
+        List<String> existsIds = exists.stream().map(LongArticleAuditDelete::getPublishContentId).collect(Collectors.toList());
+        Map<String, List<PublishGzhPushContentRelDTO>> groupPushRelMap = groupPushRelList.stream()
+                .collect(Collectors.groupingBy(PublishGzhPushContentRelDTO::getPushId));
+        for (PublishGzhPushDTO push : pushList) {
+            List<LongArticleAuditDelete> deleteList = new ArrayList<>();
+            String groupPushMsgId = pushIdMap.get(push.getPushId());
+            String publishAccountId = pushAccountMap.get(push.getPushId());
+            String ghId = publishAccountMap.get(publishAccountId);
+            List<PublishGzhPushContentRelDTO> relList = groupPushRelMap.get(push.getPushId()).stream()
+                    .sorted(Comparator.comparing(PublishGzhPushContentRelDTO::getId)).collect(Collectors.toList());
+            Map<String, Integer> articleIndexMap = new HashMap<>();
+            for (int i = 0; i < relList.size(); i++) {
+                articleIndexMap.put(relList.get(i).getPublishContentId(), i + 1);
+            }
+            for (PublishGzhPushContentRelDTO pushContentRelDTO : relList) {
+                if (existsIds.contains(pushContentRelDTO.getPublishContentId())) {
+                    continue;
+                }
+                LongArticleAuditDelete delete = new LongArticleAuditDelete();
+                delete.setGhId(ghId);
+                delete.setMsgId(groupPushMsgId);
+                delete.setPushId(push.getPushId());
+                delete.setPushType(push.getPushType());
+                delete.setPublishContentId(pushContentRelDTO.getPublishContentId());
+                delete.setIndex(articleIndexMap.get(delete.getPublishContentId()));
+                delete.setStatus(StatusEnum.ZERO.getCode());
+                delete.setCreateTimestamp(System.currentTimeMillis());
+                deleteList.add(delete);
+            }
+            if (CollectionUtils.isNotEmpty(deleteList)) {
+                longArticleBaseMapper.batchInsertLongArticleAuditDelete(deleteList);
+            }
+        }
+    }
 }

+ 6 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/web/recommend/ArticleAuditController.java

@@ -3,6 +3,7 @@ package com.tzld.longarticle.recommend.server.web.recommend;
 import com.tzld.longarticle.recommend.server.common.response.CommonResponse;
 import com.tzld.longarticle.recommend.server.model.param.ArticleCategoryListParam;
 import com.tzld.longarticle.recommend.server.model.param.ArticleDangerFindDeleteParam;
+import com.tzld.longarticle.recommend.server.model.param.ArticleDeleteParam;
 import com.tzld.longarticle.recommend.server.model.vo.ArticleDeleteListVO;
 import com.tzld.longarticle.recommend.server.service.recommend.ArticleAuditService;
 import com.tzld.longarticle.recommend.server.util.page.Page;
@@ -61,4 +62,9 @@ public class ArticleAuditController {
     public void articleVideoDelete() {
         service.articleVideoDelete(null);
     }
+
+    @PostMapping("/articleDelete")
+    public void articleDelete(@RequestBody ArticleDeleteParam param) {
+        service.articleDelete(param);
+    }
 }

+ 8 - 0
long-article-recommend-service/src/main/resources/mapper/aigc/PublishContentMapper.xml

@@ -168,6 +168,14 @@
         </foreach>
     </select>
 
+    <select id="getPushByPushTimeBetween"
+            resultType="com.tzld.longarticle.recommend.server.model.dto.PublishGzhPushDTO">
+        select *
+        from publish_gzh_push
+        where push_finish_timestamp between #{start} and #{end}
+        and push_type = 2 and push_status = 2 and publish_status = 2 and group_push_msg_id is not null
+    </select>
+
     <select id="getGroupPushRelByPushIdIn"
             resultType="com.tzld.longarticle.recommend.server.model.dto.PublishGzhPushContentRelDTO">
         select * from publish_gzh_push_content_rel where push_id in

+ 10 - 0
long-article-recommend-service/src/main/resources/mapper/longArticle/LongArticleBaseMapper.xml

@@ -271,4 +271,14 @@
         select distinct gh_id from long_article_audit_delete where create_timestamp > 1736157600000 and status = 2 and fail_reason like 'reach max api daily quota%'
     </select>
 
+    <insert id="batchInsertLongArticleAuditDelete">
+        insert into long_article_audit_delete
+        (gh_id, msg_id, index, push_id, push_type, publish_content_id, status, create_timestamp)
+        values
+        <foreach collection="list" item="item" separator=",">
+            (#{item.ghId}, #{item.msgId}, #{item.index}, #{item.pushId}, #{item.pushType}, #{item.publishContentId},
+            #{item.status}, #{item.createTimestamp})
+        </foreach>
+    </insert>
+
 </mapper>