瀏覽代碼

保存中间环节 晋级溯源

wangyunpeng 8 月之前
父節點
當前提交
bfbd0633c9

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

@@ -1,5 +1,6 @@
 package com.tzld.longarticle.recommend.server.mapper.longArticle;
 
+import com.tzld.longarticle.recommend.server.model.entity.longArticle.ArticlePoolPromotionSource;
 import com.tzld.longarticle.recommend.server.model.entity.longArticle.DatastatSortStrategy;
 import org.apache.ibatis.annotations.Mapper;
 
@@ -14,6 +15,8 @@ public interface LongArticleBaseMapper {
 
     void batchInsertDatastatSortStrategy(List<DatastatSortStrategy> list);
 
+    void batchInsertArticlePoolPromotionSource(List<ArticlePoolPromotionSource> list);
+
     void updateRootProduceContentLevel(String rootProduceContentId, String level);
 
 }

+ 5 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/vo/RootPublishContentVO.java

@@ -2,6 +2,9 @@ package com.tzld.longarticle.recommend.server.model.vo;
 
 import lombok.Data;
 
+import java.util.ArrayList;
+import java.util.List;
+
 @Data
 public class RootPublishContentVO {
 
@@ -10,4 +13,6 @@ public class RootPublishContentVO {
     private String rootPublishContentId;
     private String rootProduceContentId;
 
+    private List<String> midChannelContentIds = new ArrayList<>();
+
 }

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

@@ -24,10 +24,12 @@ import com.tzld.longarticle.recommend.server.util.DateUtils;
 import com.tzld.longarticle.recommend.server.util.TitleSimilarCheckUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
@@ -191,6 +193,7 @@ public class ArticleService {
                                                       String rootPublishContentId,
                                                       int times) {
         RootPublishContentVO result = new RootPublishContentVO();
+        result.setChannelContentId(channelContentId);
         result.setSourcePublishContentId(sourcePublishContentId);
         result.setRootPublishContentId(rootPublishContentId);
         if (times > 20) {
@@ -253,7 +256,11 @@ public class ArticleService {
         if (channelContentId.equals(crawlerContent.getChannelContentId())) {
             return result;
         } else {
-            return getRootPublishContent(channelContentId, result.getSourcePublishContentId(), result.getRootPublishContentId(), ++times);
+            result = getRootPublishContent(channelContentId, result.getSourcePublishContentId(), result.getRootPublishContentId(), ++times);
+            if (!channelContentId.equals(result.getChannelContentId())) {
+                result.getMidChannelContentIds().add(channelContentId);
+            }
+            return result;
         }
     }
 
@@ -276,6 +283,18 @@ public class ArticleService {
                 task.setRootPublishContentId(source.getRootPublishContentId());
                 task.setUpdateTimestamp(System.currentTimeMillis());
                 articlePoolPromotionSourceRepository.save(task);
+                // 保存中间环节 晋级溯源
+                List<ArticlePoolPromotionSource> insertList = new ArrayList<>();
+                for (String midChannelContentId : source.getMidChannelContentIds()) {
+                    ArticlePoolPromotionSource item = new ArticlePoolPromotionSource();
+                    BeanUtils.copyProperties(task, item);
+                    item.setChannelContentId(midChannelContentId);
+                    item.setCreateTimestamp(item.getUpdateTimestamp());
+                    insertList.add(item);
+                }
+                if (CollectionUtils.isNotEmpty(insertList)) {
+                    longArticleBaseMapper.batchInsertArticlePoolPromotionSource(insertList);
+                }
                 longArticleBaseMapper.updateRootProduceContentLevel(task.getRootProduceContentId(), task.getLevel());
             } else {
                 task.setDeleted(1);

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

@@ -41,6 +41,15 @@
         </foreach>
     </insert>
 
+    <insert id="batchInsertArticlePoolPromotionSource">
+        insert into article_pool_promotion_source
+            (channel_content_id, source_publish_content_id, root_publish_content_id, root_produce_content_id, title,
+             title_md5, level, status, deleted, create_timestamp, update_timestamp)
+        values(#{item.channelContentId}, #{item.sourcePublishContentId}, #{item.rootPublishContentId},
+               #{item.rootProduceContentId}, #{item.title}, #{item.titleMd5}, #{item.level}, #{item.status},
+               #{item.deleted}, #{item.createTimestamp}, #{item.updateTimestamp})
+    </insert>
+
     <update id="updateRootProduceContentLevel">
         update article_pool_promotion_source set level = #{level} where root_produce_content_id = #{rootProduceContentId}
     </update>