Browse Source

Merge branch 'wyp/1125-bugFix' of Server/long-article-recommend into master

wangyunpeng 7 months ago
parent
commit
6d06f34035

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

@@ -71,4 +71,7 @@ public class DatastatScore {
     @Column(name = "read_avg_rate")
     private Double readAvgRate;
 
+    @Column(name = "first_pub_interval")
+    private Integer firstPubInterval;
+
 }

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

@@ -16,4 +16,6 @@ public interface ArticlePoolPromotionSourceRepository extends JpaRepository<Arti
     List<ArticlePoolPromotionSource> getByChannelContentIdInAndStatusAndDeleted(List<String> channelContentIds, Integer status, Integer deleted);
 
     List<ArticlePoolPromotionSource> getByStatusAndDeleted(Integer status, Integer deleted);
+
+    List<ArticlePoolPromotionSource> getByStatusAndDeletedAndWxSnIsNotNull(Integer status, Integer deleted);
 }

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

@@ -6,11 +6,11 @@ import com.alibaba.fastjson.JSONObject;
 import com.aliyun.odps.data.Record;
 import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
 import com.google.common.collect.Lists;
+import com.tzld.longarticle.recommend.server.common.ThreadPoolFactory;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.AccountBusinessTypeEnum;
 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.mapper.crawler.CrawlerBaseMapper;
-import com.tzld.longarticle.recommend.server.mapper.crawler.PushMessageCallbackMapper;
 import com.tzld.longarticle.recommend.server.mapper.growth.NewPushMessageCallbackMapper;
 import com.tzld.longarticle.recommend.server.model.dto.AccountTypeFansDTO;
 import com.tzld.longarticle.recommend.server.model.dto.NotPublishPlan;
@@ -46,6 +46,7 @@ import org.springframework.util.StringUtils;
 
 import java.time.LocalTime;
 import java.util.*;
+import java.util.concurrent.CountDownLatch;
 import java.util.stream.Collectors;
 
 import static com.tzld.longarticle.recommend.server.common.constant.TimeConstant.MILLISECOND_DAY;
@@ -142,9 +143,17 @@ public class XxlJobService {
             List<GetOffVideoCrawler> getOffVideoCrawlerList = getOffVideoCrawlerRepository.getByPublishTimeBetween(timeStamp, timeStamp + 86400);
             List<String> traceIds = getOffVideoCrawlerList.stream().map(GetOffVideoCrawler::getTraceId).distinct().collect(Collectors.toList());
             List<LongArticlesVideo> longArticlesVideoList = longArticlesVideoRepository.getByTraceIdIn(traceIds);
+            CountDownLatch cdl = new CountDownLatch(longArticlesVideoList.size());
             for (LongArticlesVideo longArticlesVideo : longArticlesVideoList) {
-                processCrawlerEachData(longArticlesVideo);
+                ThreadPoolFactory.defaultPool().submit(() -> {
+                    try {
+                        processCrawlerEachData(longArticlesVideo);
+                    } finally {
+                        cdl.countDown();
+                    }
+                });
             }
+            cdl.await();
         } catch (Exception e) {
             log.error("migrateCrawlerRootSourceId exception: {}", e.getMessage(), e);
             return ReturnT.FAIL;
@@ -227,9 +236,17 @@ public class XxlJobService {
             List<GetOffVideoArticle> getOffVideoArticleList = getOffVideoArticleRepository.getByPublishTimeBetween(timeStamp, timeStamp + 86400);
             List<String> traceIds = getOffVideoArticleList.stream().map(GetOffVideoArticle::getTraceId).distinct().collect(Collectors.toList());
             List<LongArticlesMatchVideo> longArticlesMatchVideoList = longArticlesMatchVideoRepository.getByTraceIdIn(traceIds);
+            CountDownLatch cdl = new CountDownLatch(longArticlesMatchVideoList.size());
             for (LongArticlesMatchVideo longArticlesMatchVideo : longArticlesMatchVideoList) {
-                processArticleEachData(longArticlesMatchVideo);
+                ThreadPoolFactory.defaultPool().submit(() -> {
+                    try {
+                        processArticleEachData(longArticlesMatchVideo);
+                    } finally {
+                        cdl.countDown();
+                    }
+                });
             }
+            cdl.await();
         } catch (Exception e) {
             log.error("migrateArticleRootSourceId exception: {}", e.getMessage(), e);
             return ReturnT.FAIL;

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

@@ -280,7 +280,7 @@ public class ArticleService {
             ArticlePoolPromotionSource item = articlePoolPromotionSourceRepository.getByChannelContentId(channelContentId);
             tasks.add(item);
         } else {
-            tasks = articlePoolPromotionSourceRepository.getByStatusAndDeleted(0, 0);
+            tasks = articlePoolPromotionSourceRepository.getByStatusAndDeletedAndWxSnIsNotNull(0, 0);
         }
         long now = System.currentTimeMillis();
         for (ArticlePoolPromotionSource task : tasks) {
@@ -308,7 +308,7 @@ public class ArticleService {
                 articlePoolPromotionSourceRepository.save(task);
                 continue;
             }
-            RootPublishContentVO source = getRootPublishContent(publishContent.getCrawlerChannelContentId(), null, publishContent.getId(), null, 0);
+            RootPublishContentVO source = getRootPublishContent(publishContent.getCrawlerChannelContentId(), null, publishContent.getId(), publishContent.getSourceId(), 0);
             // 更新
             if (StringUtils.hasText(source.getRootProduceContentId())) {
                 task.setStatus(ArticlePoolPromotionSourceStatusEnum.FINISH.getCode());

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

@@ -1545,6 +1545,7 @@ public class DataDashboardService {
                 item.setReadCount(value.getReadCount());
                 item.setReadAvg(value.getReadAvg());
                 item.setReadAvgRate(value.getReadAvgRate());
+                item.setFirstPubInterval(value.getFirstExplorationIntervalAvg());
                 saveList.add(item);
             }
             for (List<DatastatScore> saveListPartition : Lists.partition(saveList, 1000)) {

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

@@ -68,13 +68,13 @@
         INSERT INTO datastat_score
         (dt, gh_id, account_name, `index`, title, strategy, score, similarity, view_count_rate,
          his_fission_avg_read_rate_rate, his_fission_avg_read_sum_rate, his_fission_de_weight_avg_read_sum_rate,
-        read_count, read_avg, read_avg_rate, category, category_score)
+        read_count, read_avg, read_avg_rate, category, category_score, first_pub_interval)
         VALUES
         <foreach collection="list" item="item" separator=",">
             (#{item.dt}, #{item.ghId}, #{item.accountName}, #{item.index}, #{item.title}, #{item.strategy},
              #{item.score}, #{item.similarity}, #{item.viewCountRate}, #{item.hisFissionAvgReadRateRate},
             #{item.hisFissionAvgReadSumRate}, #{item.hisFissionDeWeightAvgReadSumRate}, #{item.readCount},
-             #{item.readAvg}, #{item.readAvgRate}, #{item.category}, #{item.categoryScore})
+             #{item.readAvg}, #{item.readAvgRate}, #{item.category}, #{item.categoryScore}, #{item.firstPubInterval})
         </foreach>
     </insert>