|
@@ -3,14 +3,18 @@ package com.tzld.longarticle.recommend.server;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.tzld.longarticle.recommend.server.common.enums.recommend.ArticleCategoryStatusEnum;
|
|
import com.tzld.longarticle.recommend.server.common.enums.recommend.ArticleCategoryStatusEnum;
|
|
|
import com.tzld.longarticle.recommend.server.mapper.longArticle.ArticleCategoryMapper;
|
|
import com.tzld.longarticle.recommend.server.mapper.longArticle.ArticleCategoryMapper;
|
|
|
|
|
+import com.tzld.longarticle.recommend.server.mapper.longArticle.LongArticleBaseMapper;
|
|
|
import com.tzld.longarticle.recommend.server.model.entity.longArticle.ArticleCategory;
|
|
import com.tzld.longarticle.recommend.server.model.entity.longArticle.ArticleCategory;
|
|
|
import com.tzld.longarticle.recommend.server.model.entity.longArticle.DatastatScore;
|
|
import com.tzld.longarticle.recommend.server.model.entity.longArticle.DatastatScore;
|
|
|
|
|
+import com.tzld.longarticle.recommend.server.model.entity.longArticle.DatastatSortStrategy;
|
|
|
import com.tzld.longarticle.recommend.server.model.vo.IntermediateIndicatorsExport;
|
|
import com.tzld.longarticle.recommend.server.model.vo.IntermediateIndicatorsExport;
|
|
|
import com.tzld.longarticle.recommend.server.model.vo.NewSortStrategyExport;
|
|
import com.tzld.longarticle.recommend.server.model.vo.NewSortStrategyExport;
|
|
|
import com.tzld.longarticle.recommend.server.repository.longArticle.ArticleCategoryRepository;
|
|
import com.tzld.longarticle.recommend.server.repository.longArticle.ArticleCategoryRepository;
|
|
|
import com.tzld.longarticle.recommend.server.repository.longArticle.DatastatScoreRepository;
|
|
import com.tzld.longarticle.recommend.server.repository.longArticle.DatastatScoreRepository;
|
|
|
|
|
+import com.tzld.longarticle.recommend.server.repository.longArticle.DatastatSortStrategyRepository;
|
|
|
import com.tzld.longarticle.recommend.server.service.recommend.DataDashboardService;
|
|
import com.tzld.longarticle.recommend.server.service.recommend.DataDashboardService;
|
|
|
import com.tzld.longarticle.recommend.server.util.DateUtils;
|
|
import com.tzld.longarticle.recommend.server.util.DateUtils;
|
|
|
|
|
+import com.tzld.longarticle.recommend.server.util.Md5Util;
|
|
|
import com.tzld.longarticle.recommend.server.util.feishu.FeiShu;
|
|
import com.tzld.longarticle.recommend.server.util.feishu.FeiShu;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.junit.jupiter.api.Test;
|
|
import org.junit.jupiter.api.Test;
|
|
@@ -31,11 +35,15 @@ public class DataDashboardTest {
|
|
|
@Resource
|
|
@Resource
|
|
|
DataDashboardService dataDashboardService;
|
|
DataDashboardService dataDashboardService;
|
|
|
@Resource
|
|
@Resource
|
|
|
|
|
+ DatastatSortStrategyRepository datastatSortStrategyRepository;
|
|
|
|
|
+ @Resource
|
|
|
DatastatScoreRepository datastatScoreRepository;
|
|
DatastatScoreRepository datastatScoreRepository;
|
|
|
@Resource
|
|
@Resource
|
|
|
ArticleCategoryRepository articleCategoryRepository;
|
|
ArticleCategoryRepository articleCategoryRepository;
|
|
|
@Resource
|
|
@Resource
|
|
|
ArticleCategoryMapper articleCategoryMapper;
|
|
ArticleCategoryMapper articleCategoryMapper;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ LongArticleBaseMapper longArticleBaseMapper;
|
|
|
|
|
|
|
|
@Test
|
|
@Test
|
|
|
public void test() {
|
|
public void test() {
|
|
@@ -107,4 +115,31 @@ public class DataDashboardTest {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Test
|
|
|
|
|
+ public void datastatSortStrategyCategory() {
|
|
|
|
|
+ List<String> sourceIds = longArticleBaseMapper.getSentSourceIds();
|
|
|
|
|
+ List<ArticleCategory> categoryList = articleCategoryRepository.getByStatusAndVersion(ArticleCategoryStatusEnum.SUCCESS.getCode(), 2);
|
|
|
|
|
+ Map<String, ArticleCategory> categoryMap = categoryList.stream().collect(Collectors.toMap(ArticleCategory::getProduceContentId, category -> category));
|
|
|
|
|
+ Map<String, ArticleCategory> titleMap = categoryList.stream().collect(Collectors.toMap(ArticleCategory::getTitleMd5, category -> category, (a, b) -> a));
|
|
|
|
|
+ for (String sourceId : sourceIds) {
|
|
|
|
|
+ ArticleCategory articleCategory = categoryMap.get(sourceId);
|
|
|
|
|
+ if (Objects.isNull(articleCategory)) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ String category = articleCategory.getCategory();
|
|
|
|
|
+ longArticleBaseMapper.updateDatastatCategoryBySourceId(sourceId, category);
|
|
|
|
|
+ }
|
|
|
|
|
+ List<DatastatSortStrategy> list = longArticleBaseMapper.getNullCategoryDatastat();
|
|
|
|
|
+ for (DatastatSortStrategy datastatSortStrategy : list) {
|
|
|
|
|
+ String titleMd5 = Md5Util.encoderByMd5(datastatSortStrategy.getTitle());
|
|
|
|
|
+ ArticleCategory articleCategory = titleMap.get(titleMd5);
|
|
|
|
|
+ if (Objects.isNull(articleCategory)) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ String category = articleCategory.getCategory();
|
|
|
|
|
+ datastatSortStrategy.setCategory(category);
|
|
|
|
|
+ datastatSortStrategyRepository.save(datastatSortStrategy);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|