|
@@ -4,25 +4,35 @@ import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
|
|
import com.tzld.longarticle.recommend.server.common.CommonThreadPoolExecutor;
|
|
|
import com.tzld.longarticle.recommend.server.common.enums.StatusEnum;
|
|
|
import com.tzld.longarticle.recommend.server.common.enums.aigc.PublishContentTypeEnum;
|
|
|
+import com.tzld.longarticle.recommend.server.common.enums.recommend.ArticleCategoryStatusEnum;
|
|
|
import com.tzld.longarticle.recommend.server.common.enums.recommend.ArticlePoolPromotionSourceStatusEnum;
|
|
|
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.longArticle.LongArticleBaseMapper;
|
|
|
import com.tzld.longarticle.recommend.server.model.dto.CrawlerContent;
|
|
|
+import com.tzld.longarticle.recommend.server.model.dto.kimi.KimiResult;
|
|
|
import com.tzld.longarticle.recommend.server.model.entity.aigc.PublishAccount;
|
|
|
import com.tzld.longarticle.recommend.server.model.entity.aigc.PublishContent;
|
|
|
import com.tzld.longarticle.recommend.server.model.entity.aigc.PublishContentOutput;
|
|
|
import com.tzld.longarticle.recommend.server.model.entity.crawler.Article;
|
|
|
+import com.tzld.longarticle.recommend.server.model.entity.longArticle.ArticleCategory;
|
|
|
+import com.tzld.longarticle.recommend.server.model.entity.longArticle.ArticleCrawlerPlan;
|
|
|
import com.tzld.longarticle.recommend.server.model.entity.longArticle.ArticlePoolPromotionSource;
|
|
|
import com.tzld.longarticle.recommend.server.model.param.ArticleFindSourceParam;
|
|
|
+import com.tzld.longarticle.recommend.server.model.vo.ProduceContentCrawlerVO;
|
|
|
import com.tzld.longarticle.recommend.server.model.vo.RootPublishContentVO;
|
|
|
+import com.tzld.longarticle.recommend.server.remote.CrawlerContentByPlanService;
|
|
|
+import com.tzld.longarticle.recommend.server.remote.KimiApiService;
|
|
|
import com.tzld.longarticle.recommend.server.repository.aigc.PublishAccountRepository;
|
|
|
import com.tzld.longarticle.recommend.server.repository.aigc.PublishContentOutputRepository;
|
|
|
import com.tzld.longarticle.recommend.server.repository.crawler.AccountAvgInfoRepository;
|
|
|
import com.tzld.longarticle.recommend.server.repository.crawler.ArticleRepository;
|
|
|
+import com.tzld.longarticle.recommend.server.repository.longArticle.ArticleCategoryRepository;
|
|
|
+import com.tzld.longarticle.recommend.server.repository.longArticle.ArticleCrawlerPlanRepository;
|
|
|
import com.tzld.longarticle.recommend.server.repository.longArticle.ArticlePoolPromotionSourceRepository;
|
|
|
import com.tzld.longarticle.recommend.server.service.recommend.config.AccountIndexAvgViewCountService;
|
|
|
import com.tzld.longarticle.recommend.server.util.DateUtils;
|
|
|
+import com.tzld.longarticle.recommend.server.util.Md5Util;
|
|
|
import com.tzld.longarticle.recommend.server.util.TitleSimilarCheckUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
@@ -31,10 +41,7 @@ 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;
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -63,6 +70,14 @@ public class ArticleService {
|
|
|
LongArticleBaseMapper longArticleBaseMapper;
|
|
|
@Autowired
|
|
|
ArticlePoolPromotionSourceRepository articlePoolPromotionSourceRepository;
|
|
|
+ @Autowired
|
|
|
+ ArticleCrawlerPlanRepository articleCrawlerPlanRepository;
|
|
|
+ @Autowired
|
|
|
+ ArticleCategoryRepository articleCategoryRepository;
|
|
|
+ @Autowired
|
|
|
+ CrawlerContentByPlanService crawlerContentByPlanService;
|
|
|
+ @Autowired
|
|
|
+ KimiApiService kimiApiService;
|
|
|
|
|
|
private final static ExecutorService pool = new CommonThreadPoolExecutor(
|
|
|
32,
|
|
@@ -302,9 +317,50 @@ public class ArticleService {
|
|
|
}
|
|
|
longArticleBaseMapper.updateRootProduceContentLevel(task.getRootProduceContentId(), task.getLevel());
|
|
|
} else {
|
|
|
- task.setDeleted(StatusEnum.SUCCESS.getCode());
|
|
|
+ task.setDeleted(StatusEnum.ONE.getCode());
|
|
|
articlePoolPromotionSourceRepository.save(task);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public void articleCategory() {
|
|
|
+ List<ArticleCrawlerPlan> articleCrawlerPlanList = articleCrawlerPlanRepository.getByStatus(StatusEnum.ZERO.getCode());
|
|
|
+ List<String> producePlanIds = Arrays.asList("20240802021606053813696", "20240802080355355308981",
|
|
|
+ "20240805154433785506170", "20240805154359027876170", "20241024100016206421084", "20241030070010871546586");
|
|
|
+ for (ArticleCrawlerPlan crawlerPlan : articleCrawlerPlanList) {
|
|
|
+ List<ProduceContentCrawlerVO> list = crawlerContentByPlanService.getCrawlerContentByPlan(crawlerPlan.getCrawlerPlanId(), producePlanIds);
|
|
|
+ List<String> produceContentIds = list.stream().map(ProduceContentCrawlerVO::getProduceContentId).collect(Collectors.toList());
|
|
|
+ List<ArticleCategory> exists = articleCategoryRepository.getByProduceContentIdIn(produceContentIds);
|
|
|
+ List<String> existsIds = exists.stream().map(ArticleCategory::getProduceContentId).collect(Collectors.toList());
|
|
|
+ list = list.stream().filter(o -> !existsIds.contains(o.getProduceContentId())).collect(Collectors.toList());
|
|
|
+ long now = System.currentTimeMillis();
|
|
|
+ List<ArticleCategory> saveList = new ArrayList<>();
|
|
|
+ for (ProduceContentCrawlerVO vo : list) {
|
|
|
+ ArticleCategory item = new ArticleCategory();
|
|
|
+ item.setCrawlerPlanId(crawlerPlan.getCrawlerPlanId());
|
|
|
+ item.setChannelContentId(vo.getChannelContentId());
|
|
|
+ item.setProduceContentId(vo.getProduceContentId());
|
|
|
+ item.setTitle(vo.getTitle());
|
|
|
+ item.setTitleMd5(Md5Util.encoderByMd5(vo.getTitle()));
|
|
|
+ item.setCreateTimestamp(now);
|
|
|
+ saveList.add(item);
|
|
|
+ }
|
|
|
+ longArticleBaseMapper.batchInsertArticleCategory(saveList);
|
|
|
+ }
|
|
|
+ List<ArticleCategory> dealList = articleCategoryRepository.getByStatus(ArticleCategoryStatusEnum.WAITING.getCode());
|
|
|
+ for (ArticleCategory articleCategory : dealList) {
|
|
|
+ KimiResult kimiResult = kimiApiService.requestOfficialApi(articleCategory.getTitle(), null, null);
|
|
|
+ articleCategory.setKimiResult(kimiResult.getResponseStr());
|
|
|
+ articleCategory.setUpdateTimestamp(System.currentTimeMillis());
|
|
|
+ if (kimiResult.isSuccess()) {
|
|
|
+ articleCategory.setCategory(kimiResult.getResponse().getChoices().get(0).getMessage().getContent());
|
|
|
+ articleCategory.setStatus(ArticleCategoryStatusEnum.SUCCESS.getCode());
|
|
|
+ } else {
|
|
|
+ articleCategory.setStatus(ArticleCategoryStatusEnum.FAIL.getCode());
|
|
|
+ articleCategory.setFailReason(kimiResult.getFailReason());
|
|
|
+ }
|
|
|
+ articleCategoryRepository.save(articleCategory);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|