Forráskód Böngészése

Merge branch 'dev-xym-update-cover' of Server/long-article-manage into master

xueyiming 4 napja
szülő
commit
57a4a0e169

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

@@ -1,5 +1,6 @@
 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.ContentStatusEnum;
@@ -10,6 +11,8 @@ import com.tzld.piaoquan.longarticle.model.po.longarticle.*;
 import com.tzld.piaoquan.longarticle.model.vo.MatchMiniprogramStatusParam;
 import com.tzld.piaoquan.longarticle.service.local.CardService;
 import com.tzld.piaoquan.longarticle.service.remote.AigcService;
+import com.tzld.piaoquan.longarticle.service.remote.MatchService;
+import com.tzld.piaoquan.longarticle.service.remote.VideoService;
 import com.tzld.piaoquan.longarticle.utils.ImageUrlValidator;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
@@ -31,11 +34,17 @@ public class CardServiceImpl implements CardService {
     @ApolloJsonValue("${miniMap:{}}")
     private JSONObject miniProgramMap;
 
+    @ApolloJsonValue("${coverTestAccount:[]}")
+    private JSONArray coverTestAccount;
+
     @Autowired
     AigcService aigcService;
 
     @Autowired
-    private NewVideoCoverMapper newVideoCoverMapper;
+    private VideoService videoService;
+
+    @Autowired
+    private MatchService matchService;
 
     private static final List<String> crawlerImgPathList = new ArrayList<String>() {{
         add("20250208065525959973866");
@@ -50,7 +59,7 @@ public class CardServiceImpl implements CardService {
         add("20250304073234245880032");
     }};
 
-    private static final List<String> useShareImgPathList = new ArrayList<String>(){{
+    private static final List<String> useShareImgPathList = new ArrayList<String>() {{
         add("妙用俏生活");
         add("票圈精彩");
     }};
@@ -217,19 +226,16 @@ public class CardServiceImpl implements CardService {
             for (int index = 0; index < videoDetails.size(); index++) {
                 VideoDetail videoDetail = videoDetails.get(index);
                 PublishMiniprogram card = generateSingleCard(index + 1, miniId, videoDetail, planAccount, publishContent);
-//                //1号位置和2号位置视频  查询2号视频是否有新封面
-//                if (index == 1 && Objects.equals(videoDetail.getCrawlerVideoId(), videoDetails.get(0).getCrawlerVideoId())) {
-//                    NewVideoCoverExample example = new NewVideoCoverExample();
-//                    example.createCriteria().andCrawlerVideoIdEqualTo(videoDetail.getCrawlerVideoId()).andGetCoverStatusEqualTo(2);
-//                    List<NewVideoCover> newVideoCovers = newVideoCoverMapper.selectByExample(example);
-//                    // 查询是否存在新封面
-//                    if (!CollectionUtils.isEmpty(newVideoCovers)) {
-//                        NewVideoCover newVideoCover = newVideoCovers.get(0);
-//                        String cover = " https://rescdn.yishihui.com/" + newVideoCover.getCoverOssPath();
-//                        card.setVideoCover(cover);
-//                        card.setNewVideoCoverId(newVideoCover.getId());
-//                    }
-//                }
+                if (coverTestAccount.contains(planAccount.getGhId())) {
+                    if (index == 0 || index == 1) {
+                        String updateCover = videoService.getUpdateCover(publishContent.getSourceId(), index + 1, videoDetail.getVideoId());
+                        if (StringUtils.isNotEmpty(updateCover)) {
+                            card.setVideoCover(updateCover);
+                        } else {
+                            log.error("updateCover is null contentId={} videoId={} index={}", publishContent.getSourceId(), videoDetail.getVideoId(), index + 1);
+                        }
+                    }
+                }
                 if (card != null) {
                     String videoCover = card.getVideoCover();
                     String wxUrl = aigcService.pushCover(videoCover, card.getPublishContentId());
@@ -240,6 +246,7 @@ public class CardServiceImpl implements CardService {
                             statusParam.setStatus(MatchResultStatusEnum.FAIL.getStatusCode());
                             statusParam.setPublishContentId(card.getPublishContentId());
                             statusParam.setErrorMsg("封面不可用");
+                            matchService.notHasMiniVideos(publishContent.getSourceId());
                             aigcService.updateMatchMiniprogramStatus(statusParam);
                         }
                         continue;

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

@@ -47,7 +47,7 @@ public class ContentServiceImpl implements ContentService {
     private Set<String> ghIdSet = new HashSet<String>();
 
     private Set<String> accountNameSet = new HashSet<String>() {{
-        add("妙用俏生活");
+
     }};
 
     private final String SINGLE_VIDEO_UID = "76862180";

+ 2 - 3
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/local/impl/NewMatchVideoServiceImpl.java

@@ -49,8 +49,7 @@ public class NewMatchVideoServiceImpl implements NewMatchVideoService {
     @Autowired
     private LongArticlesTextMapper longArticlesTextMapper;
 
-    @Autowired
-    private AigcService aigcService;
+    private static final Integer retryCountMax = 3;
 
 
     @Transactional
@@ -122,7 +121,7 @@ public class NewMatchVideoServiceImpl implements NewMatchVideoService {
             retryCount = 0;
         } else {
             retryCount++;
-            newStatus = (retryCount > 3)
+            newStatus = (retryCount >= retryCountMax)
                     ? failStatus.getStatusCode()
                     : video.getContentStatus();
         }

+ 2 - 0
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/remote/VideoService.java

@@ -10,4 +10,6 @@ public interface VideoService {
     void miniProgramVideoOff(String traceId);
 
     void addOffVideo(PublishMiniprogram publishMiniprogram);
+
+    String getUpdateCover(String contentId, Integer videoIndex, String videoId);
 }

+ 30 - 0
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/remote/impl/VideoServiceImpl.java

@@ -166,4 +166,34 @@ public class VideoServiceImpl implements VideoService {
         offVideo.setTraceId(publishMiniprogram.getTraceId());
         offVideoMapper.insertSelective(offVideo);
     }
+
+    @Override
+    public String getUpdateCover(String contentId, Integer videoIndex, String videoId) {
+        try {
+            String apiUrl = "http://192.168.142.66:6060/api/get_cover";
+            com.alibaba.fastjson.JSONObject params = new com.alibaba.fastjson.JSONObject();
+            params.put("content_id", contentId);
+            params.put("video_index", videoIndex);
+            params.put("seed_video_id", videoId);
+            String res = HTTP_POOL_CLIENT_UTIL_DEFAULT.post(apiUrl, params.toJSONString());
+            if (StringUtils.isNotEmpty(res)) {
+                com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(res);
+                if (jsonObject.getInteger("code") == 0) {
+                    return jsonObject.getJSONObject("data").getString("cover");
+                }
+            }
+            String apiUrl1 = "http://192.168.100.31:6060/api/get_cover";
+            String res1 = HTTP_POOL_CLIENT_UTIL_DEFAULT.post(apiUrl1, params.toJSONString());
+            if (StringUtils.isNotEmpty(res1)) {
+                com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(res1);
+                if (jsonObject.getInteger("code") == 0) {
+                    return jsonObject.getJSONObject("data").getString("cover");
+                }
+            }
+
+        } catch (Exception e) {
+            log.error("getUpdateCover error ", e);
+        }
+        return null;
+    }
 }