|
@@ -1,14 +1,27 @@
|
|
|
package com.tzld.piaoquan.longarticle.service.local.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
|
|
|
+import com.tzld.piaoquan.longarticle.common.enums.PublishGzhPushTypeEnum;
|
|
|
import com.tzld.piaoquan.longarticle.dao.mapper.CrawlerVideoMapper;
|
|
|
import com.tzld.piaoquan.longarticle.dao.mapper.MatchVideoMapper;
|
|
|
import com.tzld.piaoquan.longarticle.dao.mapper.PublishContentMapper;
|
|
|
import com.tzld.piaoquan.longarticle.dao.mapper.PublishMiniprogramMapper;
|
|
|
+import com.tzld.piaoquan.longarticle.model.bo.PublishMiniprogramBo;
|
|
|
+import com.tzld.piaoquan.longarticle.model.bo.VideoDetail;
|
|
|
+import com.tzld.piaoquan.longarticle.model.dto.ArticleSortRequest;
|
|
|
+import com.tzld.piaoquan.longarticle.model.dto.ArticleSortResponse;
|
|
|
+import com.tzld.piaoquan.longarticle.model.dto.ArticleSortResponseData;
|
|
|
import com.tzld.piaoquan.longarticle.model.dto.PublishArticleData;
|
|
|
import com.tzld.piaoquan.longarticle.model.po.*;
|
|
|
+import com.tzld.piaoquan.longarticle.model.vo.*;
|
|
|
import com.tzld.piaoquan.longarticle.service.local.ContentService;
|
|
|
+import com.tzld.piaoquan.longarticle.service.local.KimiService;
|
|
|
+import com.tzld.piaoquan.longarticle.service.remote.AigcService;
|
|
|
+import com.tzld.piaoquan.longarticle.service.remote.SortService;
|
|
|
+import com.tzld.piaoquan.longarticle.service.remote.VideoService;
|
|
|
+import com.tzld.piaoquan.longarticle.utils.LarkRobotUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -34,6 +47,18 @@ public class ContentServiceImpl implements ContentService {
|
|
|
@Autowired
|
|
|
private PublicContentServiceImpl publicContentService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private AigcService aigcService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SortService sortService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private KimiService kimiService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private VideoService videoService;
|
|
|
+
|
|
|
|
|
|
public MatchVideo getContent(String contentId, String ghId, Integer publishFlag) {
|
|
|
MatchVideoExample matchVideoExample = new MatchVideoExample();
|
|
@@ -46,16 +71,30 @@ public class ContentServiceImpl implements ContentService {
|
|
|
return matchVideos.get(0);
|
|
|
}
|
|
|
|
|
|
- public void updateMatchContent(PublishContent publishContent, String ghId, JSONArray jsonArray) {
|
|
|
+ public void updateMatchContent(PublishContent publishContent, PlanAccount planAccount, List<PublishMiniprogramBo> publishMiniprogramBoList) {
|
|
|
try {
|
|
|
MatchVideoExample matchVideoExample = new MatchVideoExample();
|
|
|
- matchVideoExample.createCriteria().andGhIdEqualTo(ghId).andContentIdEqualTo(publishContent.getSourceId())
|
|
|
+ matchVideoExample.createCriteria().andGhIdEqualTo(planAccount.getGhId()).andContentIdEqualTo(publishContent.getSourceId())
|
|
|
.andPublishFlagIn(Arrays.asList(1, 2));
|
|
|
matchVideoExample.setOrderByClause("publish_flag desc");
|
|
|
List<MatchVideo> matchVideos = matchVideoMapper.selectByExample(matchVideoExample);
|
|
|
if (CollectionUtils.isEmpty(matchVideos)) {
|
|
|
return;
|
|
|
}
|
|
|
+ JSONArray jsonArray = new JSONArray();
|
|
|
+ for (PublishMiniprogramBo publishMiniprogramBo : publishMiniprogramBoList) {
|
|
|
+ //生成match表json数据
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("uid", publishMiniprogramBo.getUserId());
|
|
|
+ jsonObject.put("source", publishMiniprogramBo.getSource());
|
|
|
+ jsonObject.put("kimiTitle", publishMiniprogramBo.getVideoTitle());
|
|
|
+ jsonObject.put("videoId", publishMiniprogramBo.getVideoId());
|
|
|
+ jsonObject.put("videoCover", publishMiniprogramBo.getVideoCover());
|
|
|
+ jsonObject.put("videoPath", publishMiniprogramBo.getVideoPath());
|
|
|
+ jsonObject.put("videoOss", publishMiniprogramBo.getVideoOssPath());
|
|
|
+ jsonObject.put("rootSourceId", publishMiniprogramBo.getRootSourceId());
|
|
|
+ jsonArray.add(jsonObject);
|
|
|
+ }
|
|
|
String traceId = matchVideos.get(0).getTraceId();
|
|
|
MatchVideo matchVideo = matchVideos.get(0);
|
|
|
MatchVideo updateMatchVideo = new MatchVideo();
|
|
@@ -70,15 +109,134 @@ public class ContentServiceImpl implements ContentService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public List<PublishArticleData> getWaitingSort(PlanAccount planAccount) {
|
|
|
+ //获取待排序数据
|
|
|
+ LongArticleSystemGetContentsParam waitingSortParam = new LongArticleSystemGetContentsParam();
|
|
|
+ waitingSortParam.setPlanId(planAccount.getPlanId());
|
|
|
+ waitingSortParam.setAccountId(planAccount.getAccountId());
|
|
|
+ waitingSortParam.setPageNum(1);
|
|
|
+ waitingSortParam.setPageSize(planAccount.getPublishPreNum());
|
|
|
+ LongArticleSystemContentVO longArticleSystemContentVO = aigcService.listWaitingSortContents(waitingSortParam);
|
|
|
+ log.info("aigcService.listWaitingSortContents={}", longArticleSystemContentVO);
|
|
|
+ if (longArticleSystemContentVO == null
|
|
|
+ || longArticleSystemContentVO.getTotalCount() < planAccount.getPublishPreMinNum()
|
|
|
+ || CollectionUtils.isEmpty(longArticleSystemContentVO.getContentItemList())
|
|
|
+ || longArticleSystemContentVO.getContentItemList().size() < planAccount.getPublishPreMinNum()) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ List<PublishArticleData> waitSortList = new ArrayList<>();
|
|
|
+ for (ContentItemVO contentItemVO : longArticleSystemContentVO.getContentItemList()) {
|
|
|
+ PublishArticleData publishArticleData = new PublishArticleData();
|
|
|
+ publishArticleData.setId(contentItemVO.getPublishContentId());
|
|
|
+ publishArticleData.setSourceId(contentItemVO.getSourceId());
|
|
|
+ publishArticleData.setTitle(contentItemVO.getTitle());
|
|
|
+ publishArticleData.setContentPoolType(contentItemVO.getFlowPoolLevelTag());
|
|
|
+ waitSortList.add(publishArticleData);
|
|
|
+ }
|
|
|
+ return waitSortList;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<PublishArticleData> getSortList(PlanAccount planAccount) {
|
|
|
+ ArticleSortRequest articleSortRequest = new ArticleSortRequest();
|
|
|
+ articleSortRequest.setAccountId(planAccount.getAccountId());
|
|
|
+ articleSortRequest.setAccountName(planAccount.getAccountName());
|
|
|
+ articleSortRequest.setGhId(planAccount.getGhId());
|
|
|
+ //测试参数
|
|
|
+// articleSortRequest.setStrategy("ArticleRankRandom");
|
|
|
+// articleSortRequest.setExcludeLog(true);
|
|
|
+ articleSortRequest.setStrategy(planAccount.getSortStrategy());
|
|
|
+ articleSortRequest.setPublishNum(planAccount.getPublishPreNum());
|
|
|
+ if (Objects.equals(PublishGzhPushTypeEnum.auto_group_publish.getVal(), planAccount.getPushType())) {
|
|
|
+ articleSortRequest.setPublishNum(planAccount.getPublishNum());
|
|
|
+ }
|
|
|
+ articleSortRequest.setPlanId(planAccount.getPlanId());
|
|
|
+ articleSortRequest.setPushType(planAccount.getPushType());
|
|
|
+
|
|
|
+ ArticleSortResponse articleSortResponse = sortService.publishArticleSort(articleSortRequest);
|
|
|
+
|
|
|
+ if (articleSortResponse == null || articleSortResponse.getData() == null) {
|
|
|
+ log.info("articleSortResponse={}", articleSortResponse);
|
|
|
+ LarkRobotUtil.sendMessage("排序结果为空");
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ ArticleSortResponseData data = articleSortResponse.getData();
|
|
|
+ if (!CollectionUtils.isEmpty(data.getFilter_list())) {
|
|
|
+ List<FilterSortContentParam> list = new ArrayList<>();
|
|
|
+ for (PublishArticleData publishArticleData : data.getFilter_list()) {
|
|
|
+ FilterSortContentParam param = new FilterSortContentParam();
|
|
|
+ param.setFilterReason(publishArticleData.getFilterReason());
|
|
|
+ param.setPublishContentId(publishArticleData.getId());
|
|
|
+ list.add(param);
|
|
|
+ }
|
|
|
+ FilterSortParam param = new FilterSortParam();
|
|
|
+ param.setFilterSortContentList(list);
|
|
|
+ aigcService.filterSortContents(param);
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isEmpty(articleSortResponse.getData().getRank_list())
|
|
|
+ || articleSortResponse.getData().getRank_list().size() < planAccount.getPublishPreMinNum()) {
|
|
|
+ log.info("rank_list = {}", articleSortResponse.getData().getRank_list());
|
|
|
+ LarkRobotUtil.sendMessage("排序结果不足");
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ return data.getRank_list();
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<VideoDetail> getPublishVideoDetail(PublishContent publishContent, PlanAccount planAccount) {
|
|
|
+ List<CrawlerVideo> contentMiniVideos = getContentMiniVideo(publishContent, planAccount);
|
|
|
+ log.info("getPublishVideoDetail contentMiniVideos={}", contentMiniVideos);
|
|
|
+ if (contentMiniVideos.size() < 2) {
|
|
|
+ publicContentService.delPublishContent(publishContent);
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ List<VideoDetail> videoDetails = publishVideo(contentMiniVideos);
|
|
|
+ log.info("getPublishVideoDetail videoDetails={}", videoDetails);
|
|
|
+ if (videoDetails.size() < 2) {
|
|
|
+ publicContentService.delPublishContent(publishContent);
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ return videoDetails;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<VideoDetail> publishVideo(List<CrawlerVideo> contentMiniVideos) {
|
|
|
+ List<VideoDetail> videoDetails = new ArrayList<>();
|
|
|
+ //发布小程序
|
|
|
+ for (CrawlerVideo crawlerVideo : contentMiniVideos) {
|
|
|
+ Integer crawlerVideoId = crawlerVideo.getId();
|
|
|
+ String videoOssPath = crawlerVideo.getVideoOssPath();
|
|
|
+ String platform = crawlerVideo.getPlatform();
|
|
|
+ String userId = crawlerVideo.getUserId();
|
|
|
+ String traceId = crawlerVideo.getTraceId();
|
|
|
+ String kimiTitle;
|
|
|
+ LongArticlesText kimiText = kimiService.getKimiText(crawlerVideo.getContentId());
|
|
|
+ if (kimiText != null && StringUtils.isNotEmpty(kimiText.getKimiTitle())) {
|
|
|
+ kimiTitle = kimiText.getKimiTitle();
|
|
|
+ } else {
|
|
|
+ kimiTitle = crawlerVideo.getVideoTitle();
|
|
|
+ }
|
|
|
+ VideoDetail videoDetail = videoService.publish(videoOssPath, userId, kimiTitle);
|
|
|
+ if (videoDetail == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ videoDetail.setCrawlerVideoId(crawlerVideoId);
|
|
|
+ videoDetail.setKimiTitle(kimiTitle);
|
|
|
+ videoDetail.setUid(userId);
|
|
|
+ videoDetail.setVideoOss(videoOssPath);
|
|
|
+ videoDetail.setSource(platform);
|
|
|
+ videoDetail.setTraceId(traceId);
|
|
|
+ videoDetails.add(videoDetail);
|
|
|
+ }
|
|
|
+ return videoDetails;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
- public List<CrawlerVideo> getContentMiniVideo(PublishArticleData publishArticleData, PlanAccount planAccount) {
|
|
|
+ public List<CrawlerVideo> getContentMiniVideo(PublishContent publishContent, PlanAccount planAccount) {
|
|
|
try {
|
|
|
CrawlerVideoExample example = new CrawlerVideoExample();
|
|
|
example.setOrderByClause("score desc");
|
|
|
- example.createCriteria().andDownloadStatusEqualTo(2).andContentIdEqualTo(publishArticleData.getSourceId());
|
|
|
+ example.createCriteria().andDownloadStatusEqualTo(2).andContentIdEqualTo(publishContent.getSourceId());
|
|
|
List<CrawlerVideo> crawlerVideoList = crawlerVideoMapper.selectByExample(example);
|
|
|
List<CrawlerVideo> videoList;
|
|
|
- switch (publishArticleData.getContentPoolType()) {
|
|
|
+ switch (publishContent.getContentPoolType()) {
|
|
|
case "autoArticlePoolLevel4":
|
|
|
// 冷启层,全量做
|
|
|
videoList = shuffleList(crawlerVideoList).subList(0, Math.min(crawlerVideoList.size(), 3));
|