Browse Source

文章晋升溯源历史数据同步

wangyunpeng 8 months ago
parent
commit
e8a38ec98c

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

@@ -37,4 +37,6 @@ public interface AigcBaseMapper {
     List<PublishContent> getNearestPublishContent(String publishAccountId, Integer size);
 
     CrawlerContent getCrawlerContentByChannelContentId(String channelContentId);
+
+    List<ProduceContentDTO> getProduceContentByPlanId(String planId);
 }

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

@@ -165,5 +165,14 @@
         where cc.channel_content_id = #{channelContentId}
     </select>
 
+    <select id="getProduceContentByPlanId" resultType="com.tzld.longarticle.recommend.server.model.dto.ProduceContentDTO">
+        select distinct record.channel_content_id as contentId,
+               output.output             as title
+        from produce_plan_exe_record record
+         join produce_plan_module_output output
+          on record.plan_exe_id = output.plan_exe_id and output.produce_module_type = 3
+        where record.plan_id = #{planId} and record.status = 2 and audit_status = 1
+    </select>
+
 
 </mapper>

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

@@ -0,0 +1,52 @@
+package com.tzld.longarticle.recommend.server;
+
+import com.tzld.longarticle.recommend.server.mapper.aigc.AigcBaseMapper;
+import com.tzld.longarticle.recommend.server.mapper.longArticle.LongArticleBaseMapper;
+import com.tzld.longarticle.recommend.server.model.dto.ProduceContentDTO;
+import com.tzld.longarticle.recommend.server.model.entity.longArticle.ArticlePoolPromotionSource;
+import com.tzld.longarticle.recommend.server.repository.longArticle.ArticlePoolPromotionSourceRepository;
+import com.tzld.longarticle.recommend.server.service.recommend.ArticleService;
+import com.tzld.longarticle.recommend.server.util.Md5Util;
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+@SpringBootTest(classes = Application.class)
+public class XxlJobTest {
+    @Resource
+    private ArticleService articleService;
+    @Resource
+    private AigcBaseMapper aigcBaseMapper;
+    @Resource
+    private LongArticleBaseMapper longArticleBaseMapper;
+    @Resource
+    private ArticlePoolPromotionSourceRepository articlePoolPromotionSourceRepository;
+
+    @Test
+    public void test() {
+        List<String> planIds = Arrays.asList("20240804003153130851174", "20240802171417146947657", "20240802143345289374071");
+        List<String> levels = Arrays.asList("autoArticlePoolLevel3", "autoArticlePoolLevel1", "autoArticlePoolLevel1");
+        List<ArticlePoolPromotionSource> dis = articlePoolPromotionSourceRepository.findAll();
+        List<String> channelContentIds = dis.stream().map(ArticlePoolPromotionSource::getChannelContentId).collect(Collectors.toList());
+        for (int i = 0; i < planIds.size(); i++) {
+            List<ProduceContentDTO> list = aigcBaseMapper.getProduceContentByPlanId(planIds.get(i));
+            list = list.stream().filter(item -> !channelContentIds.contains(item.getContentId())).collect(Collectors.toList());
+            List<ArticlePoolPromotionSource> saveList = new ArrayList<>();
+            for (ProduceContentDTO produceContentDTO : list) {
+                ArticlePoolPromotionSource item = new ArticlePoolPromotionSource();
+                item.setChannelContentId(produceContentDTO.getContentId());
+                item.setTitle(produceContentDTO.getTitle());
+                item.setTitleMd5(Md5Util.encoderByMd5(produceContentDTO.getTitle()));
+                item.setLevel(levels.get(i));
+                item.setCreateTimestamp(System.currentTimeMillis());
+                saveList.add(item);
+            }
+            articlePoolPromotionSourceRepository.saveAll(saveList);
+        }
+    }
+}