|
|
@@ -10,6 +10,7 @@ import com.tzld.longarticle.recommend.server.common.enums.recommend.ContentPoolE
|
|
|
import com.tzld.longarticle.recommend.server.mapper.aigc.AigcBaseMapper;
|
|
|
import com.tzld.longarticle.recommend.server.mapper.longArticle.ArticleCategoryMapper;
|
|
|
import com.tzld.longarticle.recommend.server.model.dto.CrawlerContent;
|
|
|
+import com.tzld.longarticle.recommend.server.model.dto.ProduceContentDTO;
|
|
|
import com.tzld.longarticle.recommend.server.model.dto.kimi.KimiResult;
|
|
|
import com.tzld.longarticle.recommend.server.model.entity.aigc.ProducePlan;
|
|
|
import com.tzld.longarticle.recommend.server.model.entity.aigc.ProducePlanExeRecord;
|
|
|
@@ -275,34 +276,50 @@ public class ArticleCategoryService {
|
|
|
*/
|
|
|
private List<ArticleCategory> addArticleCategoryByProducePlan(List<String> producePlanIds) {
|
|
|
List<ProducePlanExeRecord> produceContentList = aigcBaseMapper.getAllByProducePlanId(producePlanIds);
|
|
|
- List<String> channelContentIds = produceContentList.stream().map(ProducePlanExeRecord::getChannelContentId).distinct().collect(Collectors.toList());
|
|
|
+ List<String> producePlanExeIds = produceContentList.stream().map(ProducePlanExeRecord::getPlanExeId).distinct().collect(Collectors.toList());
|
|
|
List<ArticleCategory> articleCategoryList = new ArrayList<>();
|
|
|
- for (List<String> partition : Lists.partition(channelContentIds, 1000)) {
|
|
|
- articleCategoryList.addAll(articleCategoryRepository.getAllByChannelContentIdInAndVersion(partition, activeVersion));
|
|
|
+ for (List<String> partition : Lists.partition(producePlanExeIds, 1000)) {
|
|
|
+ articleCategoryList.addAll(articleCategoryRepository.getByProduceContentIdInAndVersion(partition, activeVersion));
|
|
|
}
|
|
|
- List<String> articleCategoryIds = articleCategoryList.stream().map(ArticleCategory::getChannelContentId).collect(Collectors.toList());
|
|
|
- List<ProduceContentCrawlerVO> list = produceContentList.stream().filter(o -> !articleCategoryIds.contains(o.getChannelContentId())).map(o -> {
|
|
|
- ProduceContentCrawlerVO item = new ProduceContentCrawlerVO();
|
|
|
- item.setChannelContentId(o.getChannelContentId());
|
|
|
- item.setProduceContentId(o.getPlanExeId());
|
|
|
- return item;
|
|
|
- }).collect(Collectors.toList());
|
|
|
- channelContentIds = channelContentIds.stream().filter(o -> !articleCategoryIds.contains(o)).collect(Collectors.toList());
|
|
|
- if (CollectionUtils.isEmpty(channelContentIds)) {
|
|
|
+ List<String> articleCategoryIds = articleCategoryList.stream().map(ArticleCategory::getProduceContentId).collect(Collectors.toList());
|
|
|
+ List<ProduceContentCrawlerVO> list = produceContentList.stream()
|
|
|
+ .filter(o -> !articleCategoryIds.contains(o.getPlanExeId()))
|
|
|
+ .map(o -> {
|
|
|
+ ProduceContentCrawlerVO item = new ProduceContentCrawlerVO();
|
|
|
+ item.setChannelContentId(o.getChannelContentId());
|
|
|
+ item.setProduceContentId(o.getPlanExeId());
|
|
|
+ return item;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ producePlanExeIds = producePlanExeIds.stream().filter(o -> !articleCategoryIds.contains(o)).collect(Collectors.toList());
|
|
|
+ if (CollectionUtils.isEmpty(producePlanExeIds)) {
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
|
- List<CrawlerContent> crawlerContentList = aigcBaseMapper.getCrawlerContentByChannelContentIdIn(channelContentIds);
|
|
|
- Map<String, CrawlerContent> map = crawlerContentList.stream().collect(Collectors.toMap(CrawlerContent::getChannelContentId, Function.identity()));
|
|
|
+ List<ProduceContentDTO> contentList = new ArrayList<>();
|
|
|
+ for (List<String> partition : Lists.partition(producePlanExeIds, 1000)) {
|
|
|
+ contentList.addAll(aigcBaseMapper.getProduceContentByPlanExeIds(partition));
|
|
|
+ }
|
|
|
+ Map<String, ProduceContentDTO> map = contentList.stream().collect(Collectors.toMap(ProduceContentDTO::getContentId, Function.identity()));
|
|
|
+
|
|
|
+ List<String> channelContentIds = list.stream().map(ProduceContentCrawlerVO::getChannelContentId).collect(Collectors.toList());
|
|
|
+ List<CrawlerContent> crawlerContentList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (List<String> partition : Lists.partition(channelContentIds, 1000)) {
|
|
|
+ crawlerContentList.addAll(aigcBaseMapper.getCrawlerContentByChannelContentIdIn(partition));
|
|
|
+ }
|
|
|
+ Map<String, CrawlerContent> crawlerContentMap = crawlerContentList.stream().collect(Collectors.toMap(CrawlerContent::getChannelContentId, Function.identity()));
|
|
|
long now = System.currentTimeMillis();
|
|
|
List<ArticleCategory> saveList = new ArrayList<>();
|
|
|
for (ProduceContentCrawlerVO vo : list) {
|
|
|
ArticleCategory item = new ArticleCategory();
|
|
|
item.setChannelContentId(vo.getChannelContentId());
|
|
|
item.setProduceContentId(vo.getProduceContentId());
|
|
|
- CrawlerContent crawlerContent = map.get(vo.getChannelContentId());
|
|
|
+ CrawlerContent crawlerContent = crawlerContentMap.get(vo.getChannelContentId());
|
|
|
if (Objects.nonNull(crawlerContent)) {
|
|
|
- String title = crawlerContent.getTitle();
|
|
|
item.setCrawlerPlanId(crawlerContent.getCrawlerPlanId());
|
|
|
+ }
|
|
|
+ ProduceContentDTO contentDTO = map.get(vo.getChannelContentId());
|
|
|
+ if (Objects.nonNull(contentDTO)) {
|
|
|
+ String title = contentDTO.getTitle();
|
|
|
item.setTitle(title);
|
|
|
item.setTitleMd5(Md5Util.encoderByMd5(title));
|
|
|
item.setCreateTimestamp(now);
|