wangyunpeng пре 9 часа
родитељ
комит
a75884f758

+ 19 - 15
api-module/src/main/java/com/tzld/piaoquan/api/job/GzhReplyVideoRefreshJob.java

@@ -175,23 +175,27 @@ public class GzhReplyVideoRefreshJob {
         for (AdPutCreativeComponentCostData costData : costDataList) {
             for (AdPutCreativeComponentCostData.AdPutTencentComponent component : costData.getComponentList()) {
                 String imageUrl = component.getImageUrl();
-                // download & upload to oss
-                String fileName = String.format("growth/image/%s_%d.jpg", costData.getCreativeId(), System.currentTimeMillis());
-                String ossImageUrl = AliOssFileTool.downloadAndSaveInOSS(fileName, imageUrl, "image/jpeg");
-                // 调用gemini-3-pro模型提取图片中的文字
-                String prompt = "识别图片里的文字,直接输出图片里的文字标题,但是不要输出图片里右下角的字,比如“点开看看”“看这里”等,仅输出标题,不要有多余的文字输出";
-                GoogleLLMResult result = aigcApiService.gemini("gemini-2.0-flash", prompt, Arrays.asList(ossImageUrl));
-                String text = result.getResult();
-                for (String existText : creativeIdTextMap.keySet()) {
-                    if (TitleSimilarCheckUtil.isSimilar(text, existText, TitleSimilarCheckUtil.SIMILARITY_THRESHOLD)) {
-                        text = existText;
-                        break;
+                try {
+                    // download & upload to oss
+                    String fileName = String.format("growth/image/%s_%d.jpg", costData.getCreativeId(), System.currentTimeMillis());
+                    String ossImageUrl = AliOssFileTool.downloadAndSaveInOSS(fileName, imageUrl, "image/jpeg");
+                    // 调用gemini-3-pro模型提取图片中的文字
+                    String prompt = "识别图片里的文字,直接输出图片里的文字标题,但是不要输出图片里右下角的字,比如“点开看看”“看这里”等,仅输出标题,不要有多余的文字输出";
+                    GoogleLLMResult result = aigcApiService.gemini("gemini-2.0-flash", prompt, Arrays.asList(ossImageUrl));
+                    String text = result.getResult();
+                    for (String existText : creativeIdTextMap.keySet()) {
+                        if (TitleSimilarCheckUtil.isSimilar(text, existText, TitleSimilarCheckUtil.SIMILARITY_THRESHOLD)) {
+                            text = existText;
+                            break;
+                        }
                     }
+                    Long cost = creativeIdTextMap.getOrDefault(text, 0L);
+                    cost += costData.getCost();
+                    creativeIdTextMap.put(text, cost);
+                    break;
+                } catch (Exception e) {
+                    log.error("GzhReplyVideoRefreshJob analysisImageText error, imageUrl:{}", imageUrl, e);
                 }
-                Long cost = creativeIdTextMap.getOrDefault(text, 0L);
-                cost += costData.getCost();
-                creativeIdTextMap.put(text, cost);
-                break;
             }
         }
         return creativeIdTextMap;