wangyunpeng 2 weeks ago
parent
commit
a8d2cdd209

+ 1 - 3
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/remote/aigc/AIGCPublishContentDiscardService.java

@@ -42,11 +42,9 @@ public class AIGCPublishContentDiscardService {
 
     public Boolean post(LongArticleSystemFilterSortParam param) {
         Boolean result = false;
-        JSONObject bodyParam = new JSONObject();
-        bodyParam.put("params", param);
         try {
             MediaType mediaType = MediaType.parse("application/json");
-            RequestBody body = RequestBody.create(mediaType, JSONObject.toJSONString(bodyParam));
+            RequestBody body = RequestBody.create(mediaType, JSONObject.toJSONString(param));
             Request request = new Request.Builder()
                     .url(filterSortContentsUrl)
                     .method("POST", body)

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

@@ -1208,33 +1208,7 @@ public class XxlJobService {
             thread.submit(() -> {
                 boolean success = false;
                 try {
-                    String value = redisTemplate.opsForValue().get(redisKey);
-                    if (StringUtils.hasText(value)) {
-                        return;
-                    }
-                    Account account = accountRepository.getById(item.getAccountId());
-                    List<Content> contentList = longArticleBaseMapper.getPublishContentGzhWaiting(item.getPlanId(), item.getAccountId());
-                    // 预处理过滤
-                    if (Objects.isNull(account) || CollectionUtil.isEmpty(contentList)) {
-                        return;
-                    }
-                    FilterParam filterParam = buildFilterParam(item.getPlanId(), account, contentList);
-                    FilterResult filterResult = filterService.filter(filterParam, true);
-                    if (CollectionUtil.isNotEmpty(filterResult.getFilterContent())) {
-                        List<ArticleSortResponseDataItem> filterContentList = new ArrayList<>();
-                        for (Content filterContent : filterResult.getFilterContent()) {
-                            ArticleSortResponseDataItem saveItem = new ArticleSortResponseDataItem();
-                            BeanUtils.copyProperties(filterContent, saveItem);
-                            filterContentList.add(saveItem);
-                        }
-                        log.info("ContentPreFilterJob success index:{} planId: {} accountId: {} filterContent: {}",
-                                finalIndex, item.getPlanId(), item.getAccountId(), filterContentList.size());
-                        recommendService.updateWaitingContentFilter(filterContentList);
-                        // 调用aigc publish_content待发布内容状态废弃
-                        LongArticleSystemFilterSortParam param = new LongArticleSystemFilterSortParam();
-                        param.setFilterSortContentList(buildFilterSortContentList(filterResult));
-                        aigcPublishContentDiscardService.filterSortContents(param);
-                    }
+                    preFilter(item, redisKey, finalIndex);
                     success = true;
                 } catch (Exception e) {
                     log.error("ContentPreFilterJob error index:{} planId: {} accountId: {}",
@@ -1256,6 +1230,36 @@ public class XxlJobService {
         }
     }
 
+    public void preFilter(PublishPlanAccountDTO item, String redisKey, Integer finalIndex) {
+        String value = redisTemplate.opsForValue().get(redisKey);
+        if (StringUtils.hasText(value)) {
+            return;
+        }
+        Account account = accountRepository.getById(item.getAccountId());
+        List<Content> contentList = longArticleBaseMapper.getPublishContentGzhWaiting(item.getPlanId(), item.getAccountId());
+        // 预处理过滤
+        if (Objects.isNull(account) || CollectionUtil.isEmpty(contentList)) {
+            return;
+        }
+        FilterParam filterParam = buildFilterParam(item.getPlanId(), account, contentList);
+        FilterResult filterResult = filterService.filter(filterParam, true);
+        if (CollectionUtil.isNotEmpty(filterResult.getFilterContent())) {
+            List<ArticleSortResponseDataItem> filterContentList = new ArrayList<>();
+            for (Content filterContent : filterResult.getFilterContent()) {
+                ArticleSortResponseDataItem saveItem = new ArticleSortResponseDataItem();
+                BeanUtils.copyProperties(filterContent, saveItem);
+                filterContentList.add(saveItem);
+            }
+            log.info("ContentPreFilterJob success index:{} planId: {} accountId: {} filterContent: {}",
+                    finalIndex, item.getPlanId(), item.getAccountId(), filterContentList.size());
+            recommendService.updateWaitingContentFilter(filterContentList);
+            // 调用aigc publish_content待发布内容状态废弃
+            LongArticleSystemFilterSortParam param = new LongArticleSystemFilterSortParam();
+            param.setFilterSortContentList(buildFilterSortContentList(filterResult));
+            aigcPublishContentDiscardService.filterSortContents(param);
+        }
+    }
+
     private List<LongArticleSystemFilterSortContentParam> buildFilterSortContentList(FilterResult filterResult) {
         List<LongArticleSystemFilterSortContentParam> contentList = new ArrayList<>();
         for (Content filterContent : filterResult.getFilterContent()) {

+ 5 - 2
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/RecommendService.java

@@ -2,6 +2,7 @@ package com.tzld.longarticle.recommend.server.service.recommend;
 
 import com.alibaba.fastjson.JSONObject;
 import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
+import com.google.common.collect.Lists;
 import com.tzld.longarticle.recommend.server.common.CostMonitor;
 import com.tzld.longarticle.recommend.server.common.constant.SceneConstants;
 import com.tzld.longarticle.recommend.server.common.enums.aigc.PushTypeEnum;
@@ -255,8 +256,10 @@ public class RecommendService {
             return;
         }
         Long updateTimestamp = System.currentTimeMillis();
-        List<String> contentIds = filterContentList.stream().map(ArticleSortResponseDataItem::getId).collect(Collectors.toList());
-        longArticleBaseMapper.updatePublishContentGzhWaitingStatusByIds(contentIds, 0, updateTimestamp);
+        for (List<ArticleSortResponseDataItem> partition : Lists.partition(filterContentList, 2000)) {
+            List<String> contentIds = partition.stream().map(ArticleSortResponseDataItem::getId).collect(Collectors.toList());
+            longArticleBaseMapper.updatePublishContentGzhWaitingStatusByIds(contentIds, 0, updateTimestamp);
+        }
     }
 
     public RecommendParam genRecommendParam(RecommendRequest request, String abCode) {

+ 1 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV18Strategy.java

@@ -153,6 +153,7 @@ public class RankV18Strategy implements RankStrategy {
         // 3-8
         // RankService.commonAdd38Content(param, result, contentPools, contentMap, param.getStrategy());
         List<Content> pool = contentMap.get(contentPools[2]);
+        RankService.printSortLog(param.getStrategy(), param.getAccountName(), "3-8", pool);
         if (CollectionUtils.isNotEmpty(pool)) {
             Integer videoSourceType = PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal();
             Queue<Content> videoPoolQueue = pool.stream().filter(o -> Objects.equals(o.getSourceType(), videoSourceType))

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

@@ -475,7 +475,7 @@
 
     <select id="getPublishContentGzhWaiting"
             resultType="com.tzld.longarticle.recommend.server.model.dto.Content">
-        select id, source_type, source_id, title, content_pool_type
+        select id, source_type, source_id, title, content_pool_type, create_timestamp, crawler_channel_content_id, crawler_timestamp
         from publish_content_gzh_waiting
         where plan_id = #{planId}
           and publish_account_id = #{accountId}

+ 15 - 0
long-article-recommend-service/src/test/java/com/tzld/longarticle/recommend/server/XxlJobTest.java

@@ -8,14 +8,17 @@ import com.tzld.longarticle.recommend.server.mapper.longArticle.ArticleCategoryM
 import com.tzld.longarticle.recommend.server.model.dto.CrawlerContent;
 import com.tzld.longarticle.recommend.server.model.dto.ProduceContentDTO;
 import com.tzld.longarticle.recommend.server.model.dto.PublishAccountTypeDTO;
+import com.tzld.longarticle.recommend.server.model.dto.aigc.PublishPlanAccountDTO;
 import com.tzld.longarticle.recommend.server.model.entity.aigc.ProducePlanExeRecord;
 import com.tzld.longarticle.recommend.server.model.entity.longArticle.ArticleCategory;
 import com.tzld.longarticle.recommend.server.model.entity.longArticle.ArticlePoolPromotionSource;
 import com.tzld.longarticle.recommend.server.model.vo.ProduceContentCrawlerVO;
 import com.tzld.longarticle.recommend.server.repository.longArticle.ArticleCategoryRepository;
 import com.tzld.longarticle.recommend.server.repository.longArticle.ArticlePoolPromotionSourceRepository;
+import com.tzld.longarticle.recommend.server.service.XxlJobService;
 import com.tzld.longarticle.recommend.server.service.recommend.ArticleService;
 import com.tzld.longarticle.recommend.server.service.recommend.DataDashboardService;
+import com.tzld.longarticle.recommend.server.util.DateUtils;
 import com.tzld.longarticle.recommend.server.util.Md5Util;
 import org.junit.jupiter.api.Test;
 import org.springframework.boot.test.context.SpringBootTest;
@@ -39,6 +42,8 @@ public class XxlJobTest {
     private ArticlePoolPromotionSourceRepository articlePoolPromotionSourceRepository;
     @Resource
     private ArticleCategoryRepository articleCategoryRepository;
+    @Resource
+    private XxlJobService xxlJobService;
 
     @Resource
     private DataDashboardService dataDashboardService;
@@ -116,4 +121,14 @@ public class XxlJobTest {
     public void coverStatisticDataExportTest() {
         dataDashboardService.coverStatisticTestDataExport("20250413");
     }
+
+    @Test
+    public void preFilterTest() {
+        PublishPlanAccountDTO item = new PublishPlanAccountDTO();
+        item.setPlanId("20240809061450286142711");
+        item.setAccountId("20240708082126256410152");
+        String dateStr = DateUtils.getCurrentDateStr("yyyyMMdd");
+        String redisKey = "ContentPreFilterJob:" + dateStr + ":" + item.getPlanId() + "-" + item.getAccountId();
+        xxlJobService.preFilter(item, redisKey, 1);
+    }
 }