瀏覽代碼

修改没有内容无法总结的情况

xueyiming 2 月之前
父節點
當前提交
2b8d86b7a1

+ 32 - 17
src/main/java/com/tzld/piaoquan/featurestools/job/SummarizeUnderstandingJob.java

@@ -106,30 +106,45 @@ public class SummarizeUnderstandingJob {
         log.info("hook = " + hook);
         log.info("value = " + value);
         log.info("urgency = " + urgency);
-        if (StringUtils.isEmpty(hook) || StringUtils.isEmpty(value) || StringUtils.isEmpty(urgency)) {
+        if (StringUtils.isEmpty(hook) && StringUtils.isEmpty(value) && StringUtils.isEmpty(urgency)) {
             return;
         }
-        EmbeddingResult hookResult = textEmbeddingService.getEmbedding(hook);
-        EmbeddingResult valueResult = textEmbeddingService.getEmbedding(value);
-        EmbeddingResult urgencyResult = textEmbeddingService.getEmbedding(urgency);
+        EmbeddingResult hookResult = null;
+        EmbeddingResult valueResult = null;
+        EmbeddingResult urgencyResult = null;
+        if (StringUtils.isNotEmpty(hook)) {
+            hookResult = textEmbeddingService.getEmbedding(hook);
+        }
+        if (StringUtils.isNotEmpty(value)) {
+            valueResult = textEmbeddingService.getEmbedding(value);
+        }
+        if (StringUtils.isNotEmpty(urgency)) {
+            urgencyResult = textEmbeddingService.getEmbedding(urgency);
+        }
         log.info("hookResult = " + hookResult);
         log.info("valueResult = " + valueResult);
         log.info("urgencyResult = " + urgencyResult);
-        if (hookResult == null || valueResult == null || urgencyResult == null) {
+        if (hookResult == null && valueResult == null && urgencyResult == null) {
             return;
         }
-        CreativeVideoSummarize hookCreativeVideoSummarize = new CreativeVideoSummarize(creativeVideoUnderstander.getId()
-                , creativeVideoUnderstander.getCreativeId(), "creative_hook_embedding", hook,
-                hookResult.getWords(), hookResult.getEmbeddingRes());
-
-        CreativeVideoSummarize valueCreativeVideoSummarize = new CreativeVideoSummarize(creativeVideoUnderstander.getId()
-                , creativeVideoUnderstander.getCreativeId(), "creative_why_embedding", value,
-                valueResult.getWords(), valueResult.getEmbeddingRes());
-
-        CreativeVideoSummarize urgencyCreativeVideoSummarize = new CreativeVideoSummarize(creativeVideoUnderstander.getId()
-                , creativeVideoUnderstander.getCreativeId(), "creative_action_embedding", urgency,
-                urgencyResult.getWords(), urgencyResult.getEmbeddingRes());
-
+        CreativeVideoSummarize hookCreativeVideoSummarize = null;
+        CreativeVideoSummarize valueCreativeVideoSummarize = null;
+        CreativeVideoSummarize urgencyCreativeVideoSummarize = null;
+        if (hookResult != null) {
+            hookCreativeVideoSummarize = new CreativeVideoSummarize(creativeVideoUnderstander.getId()
+                    , creativeVideoUnderstander.getCreativeId(), "creative_hook_embedding", hook,
+                    hookResult.getWords(), hookResult.getEmbeddingRes());
+        }
+        if (valueResult != null) {
+            valueCreativeVideoSummarize = new CreativeVideoSummarize(creativeVideoUnderstander.getId()
+                    , creativeVideoUnderstander.getCreativeId(), "creative_why_embedding", value,
+                    valueResult.getWords(), valueResult.getEmbeddingRes());
+        }
+        if (urgencyResult != null) {
+            urgencyCreativeVideoSummarize = new CreativeVideoSummarize(creativeVideoUnderstander.getId()
+                    , creativeVideoUnderstander.getCreativeId(), "creative_action_embedding", urgency,
+                    urgencyResult.getWords(), urgencyResult.getEmbeddingRes());
+        }
         creativeVideoSummarizeService.saveRes(creativeVideoUnderstander, hookCreativeVideoSummarize,
                 valueCreativeVideoSummarize, urgencyCreativeVideoSummarize);
     }

+ 9 - 3
src/main/java/com/tzld/piaoquan/featurestools/service/impl/CreativeVideoSummarizeServiceImpl.java

@@ -23,9 +23,15 @@ public class CreativeVideoSummarizeServiceImpl implements CreativeVideoSummarize
     @Transactional
     public void saveRes(CreativeVideoUnderstander creativeVideoUnderstander, CreativeVideoSummarize hookCreativeVideoSummarize,
                         CreativeVideoSummarize valueCreativeVideoSummarize, CreativeVideoSummarize urgencyCreativeVideoSummarize) {
-        creativeVideoSummarizeMapper.insertSelective(hookCreativeVideoSummarize);
-        creativeVideoSummarizeMapper.insertSelective(valueCreativeVideoSummarize);
-        creativeVideoSummarizeMapper.insertSelective(urgencyCreativeVideoSummarize);
+        if (hookCreativeVideoSummarize != null) {
+            creativeVideoSummarizeMapper.insertSelective(hookCreativeVideoSummarize);
+        }
+        if (valueCreativeVideoSummarize != null) {
+            creativeVideoSummarizeMapper.insertSelective(valueCreativeVideoSummarize);
+        }
+        if (urgencyCreativeVideoSummarize != null) {
+            creativeVideoSummarizeMapper.insertSelective(urgencyCreativeVideoSummarize);
+        }
         creativeVideoUnderstander.setStatus(3);
         creativeVideoUnderstanderMapper.updateByPrimaryKeySelective(creativeVideoUnderstander);
     }