Explorar o código

更新traceId

xueyiming hai 7 meses
pai
achega
27fdc4f630

+ 19 - 15
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/local/impl/ContentServiceImpl.java

@@ -71,19 +71,23 @@ public class ContentServiceImpl implements ContentService {
         return matchVideos.get(0);
     }
 
-    public void updateMatchContent(PublishContent publishContent, PlanAccount planAccount, List<PublishMiniprogramBo> publishMiniprogramBoList) {
+    public MatchVideo getMatchVideo(PublishContent publishContent, PlanAccount planAccount) {
+        MatchVideoExample matchVideoExample = new MatchVideoExample();
+        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 null;
+        }
+        return matchVideos.get(0);
+    }
+
+    public void updateMatchContent(PublishContent publishContent,
+                                   List<PublishMiniprogramBo> publishMiniprogramBoList, MatchVideo matchVideo) {
         try {
-            MatchVideoExample matchVideoExample = new MatchVideoExample();
-            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 = getResponse(publishMiniprogramBoList);
-            String traceId = matchVideos.get(0).getTraceId();
-            MatchVideo matchVideo = matchVideos.get(0);
+            String traceId = matchVideo.getTraceId();
             MatchVideo updateMatchVideo = new MatchVideo();
             updateMatchVideo.setId(matchVideo.getId());
             updateMatchVideo.setContentStatus(4);
@@ -190,14 +194,14 @@ public class ContentServiceImpl implements ContentService {
         return data.getRank_list();
     }
 
-    public List<VideoDetail> getPublishVideoDetail(PublishContent publishContent, PlanAccount planAccount) {
+    public List<VideoDetail> getPublishVideoDetail(PublishContent publishContent, PlanAccount planAccount, MatchVideo matchVideo) {
         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);
+        List<VideoDetail> videoDetails = publishVideo(contentMiniVideos, matchVideo);
         log.info("getPublishVideoDetail videoDetails={}", videoDetails);
         if (videoDetails.size() < 2) {
             publicContentService.delPublishContent(publishContent);
@@ -206,7 +210,7 @@ public class ContentServiceImpl implements ContentService {
         return videoDetails;
     }
 
-    public List<VideoDetail> publishVideo(List<CrawlerVideo> contentMiniVideos) {
+    public List<VideoDetail> publishVideo(List<CrawlerVideo> contentMiniVideos, MatchVideo matchVideo) {
         List<VideoDetail> videoDetails = new ArrayList<>();
         //发布小程序
         for (CrawlerVideo crawlerVideo : contentMiniVideos) {
@@ -214,7 +218,7 @@ public class ContentServiceImpl implements ContentService {
             String videoOssPath = crawlerVideo.getVideoOssPath();
             String platform = crawlerVideo.getPlatform();
             String userId = crawlerVideo.getUserId();
-            String traceId = crawlerVideo.getTraceId();
+            String traceId = matchVideo.getTraceId();
             String kimiTitle;
             LongArticlesText kimiText = kimiService.getKimiText(crawlerVideo.getContentId());
             if (kimiText != null && StringUtils.isNotEmpty(kimiText.getKimiTitle())) {

+ 11 - 7
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/local/impl/CoreServiceImpl.java

@@ -413,7 +413,11 @@ public class CoreServiceImpl implements CoreService {
                 List<PublishMiniprogram> publishMiniprogramList = publicContentService.getPublishMiniprograms(publishArticleData);
                 //不存在则重新生成
                 if (CollectionUtils.isEmpty(publishMiniprogramList)) {
-                    List<VideoDetail> videoDetails = contentService.getPublishVideoDetail(publishContent, planAccount);
+                    MatchVideo matchVideo = contentService.getMatchVideo(publishContent, planAccount);
+                    if (matchVideo == null) {
+                        continue;
+                    }
+                    List<VideoDetail> videoDetails = contentService.getPublishVideoDetail(publishContent, planAccount, matchVideo);
                     log.info("publishContentId={}, videoDetails={}", publishContent.getId(), videoDetails);
                     if (CollectionUtils.isEmpty(videoDetails)) {
                         continue;
@@ -433,7 +437,7 @@ public class CoreServiceImpl implements CoreService {
                         publishMiniprogramMapper.insertSelective(publishMiniprogram);
                         publishMiniprogramList.add(publishMiniprogram);
                     }
-                    contentService.updateMatchContent(publishContent, planAccount, publishMiniprogramBoList);
+                    contentService.updateMatchContent(publishContent, publishMiniprogramBoList, matchVideo);
                 }
                 log.info("publishMiniprogramList={}", publishMiniprogramList);
                 List<PublishMiniprogramParam> publishCardList = getPublishCardList(publishMiniprogramList);
@@ -562,11 +566,11 @@ public class CoreServiceImpl implements CoreService {
             if (updateStatus == 2) {
                 for (PublishContent publishContent : entry.getValue()) {
                     publicContentService.updatePublishContentStatus(updateStatus, publishContent.getId(), pushStatusVO.getErrorMsg());
-                    if (StringUtils.isNotEmpty(publishContent.getTraceId())) {
-                        videoService.miniProgramVideoOff(publishContent.getTraceId());
-                    } else {
-                        LarkRobotUtil.sendMessage("publishContent traceId is null publishContent id=" + publishContent.getId());
-                    }
+//                    if (StringUtils.isNotEmpty(publishContent.getTraceId())) {
+//                        videoService.miniProgramVideoOff(publishContent.getTraceId());
+//                    } else {
+//                        LarkRobotUtil.sendMessage("publishContent traceId is null publishContent id=" + publishContent.getId());
+//                    }
                 }
                 if (planAccount == null) {
                     continue;