From 2b1f542577dd8dfc54d3433dff3615796ceab0af Mon Sep 17 00:00:00 2001
From: shikeying <shikeying@163.com>
Date: 星期二, 11 十月 2022 17:17:50 +0800
Subject: [PATCH] 视频下载,解析分析调度跑通

---
 recommend-video/src/main/java/com/iplatform/recvideo/SimilarExecutor.java |   36 +++++++++++++++++++++++++++---------
 1 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/recommend-video/src/main/java/com/iplatform/recvideo/SimilarExecutor.java b/recommend-video/src/main/java/com/iplatform/recvideo/SimilarExecutor.java
index 1318e53..61d1450 100644
--- a/recommend-video/src/main/java/com/iplatform/recvideo/SimilarExecutor.java
+++ b/recommend-video/src/main/java/com/iplatform/recvideo/SimilarExecutor.java
@@ -4,11 +4,11 @@
 import com.iplatform.recvideo.util.PythonInvokeUtils;
 import com.iplatform.recvideo.util.TestUtils;
 import com.iplatform.recvideo.util.VideoFileUtils;
+import com.walker.infrastructure.utils.FileUtils;
 import com.walker.infrastructure.utils.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.File;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -85,7 +85,14 @@
     public int execute() throws Exception{
         if(!this.pythonLoadVideoDone){
             logger.debug("褰撳墠 pythonLoadVideoDone = false, 闇�瑕佹煡璇㈡暟鎹簱鏄惁宸插姞杞借棰�");
-            this.pythonLoadVideoDone = this.pythonLoadVideoDone(this.batchId, VideoFileUtils.combineBatchPath(videoDataFolder, batchId));
+            String batchPath = VideoFileUtils.combineBatchPath(videoDataFolder, batchId);
+            if(!FileUtils.isExist(batchPath)){
+                // 鏂囦欢澶逛笉瀛樺湪锛屾垨鐣ヨ鐘舵�佽褰曪紝2022-10-11
+                this.ignoreTaskStatus(batchId);
+                logger.warn("鏂囦欢澶逛笉瀛樺湪锛屽拷鐣ヨ鎵规璁板綍锛岃嚜鍔ㄦ洿鏂颁负'宸插畬鎴�', batchPath = " + batchPath);
+                return 1;
+            }
+            this.pythonLoadVideoDone = this.pythonLoadVideoDone(this.batchId, batchPath);
         }
 
         // 1: 濡傛灉瑙嗛杩樻湭鍔犺浇锛屽垯鍏堝姞杞借棰�
@@ -115,9 +122,13 @@
             }
         }
         if(StringUtils.isEmptyList(this.videoFolderInfoList)){
-            logger.warn("瑙嗛鍒嗘瀽鏂囦欢澶瑰唴瀹逛负绌猴紝鏃犳硶缁х画鏌ヨ鐩镐技搴︾粨鏋�! videoFolderInfoList = null");
-            return -1;
+            logger.warn("瑙嗛鍒嗘瀽鏂囦欢澶瑰唴瀹逛负绌猴紝鏃犳硶缁х画鏌ヨ鐩镐技搴︾粨鏋�!蹇界暐璇ユ壒娆°�� videoFolderInfoList = null");
+//            return -1;
+            // 鏂囦欢澶逛笉娌℃湁浠讳綍瑙嗛鏂囦欢锛屾垨鐣ヨ鐘舵�佽褰曪紝2022-10-11
+            this.ignoreTaskStatus(batchId);
+            return 1;
         }
+
         for(VideoFolderInfo v : this.videoFolderInfoList){
             this.videoIdList.add(v.getVideoId());
         }
@@ -139,14 +150,14 @@
         }
 
         try {
-            this.processOneSearchAndWrite();
+            this.processOneSearchAndWrite(this.batchId);
             return 0;
         } catch (Exception e) {
             throw new Exception("processOneSearchAndWrite(): " + e.getMessage(), e);
         }
     }
 
-    private void processOneSearchAndWrite() throws Exception{
+    private void processOneSearchAndWrite(String batchId) throws Exception{
         if(this.currentVideoFolderIndex >= this.videoFolderInfoList.size()){
             throw new IllegalArgumentException("currentVideoFolderIndex 瓒婄晫: " + this.currentVideoFolderIndex);
         }
@@ -170,7 +181,7 @@
         // 姣忎釜瑙嗛鐨勬渶鍚庝竴寮犲浘鐗�
         if((this.currentImageIndex + 1) >= currentVideoFolderInfo.getImageInfoSize()){
             try {
-                this.writeRcVideoT2(currentVideoFolderInfo);
+                this.writeRcVideoT2(currentVideoFolderInfo, batchId);
             } catch (Exception ex){
                 throw new Exception("writeRcVideoT2()鎵ц閿欒:" + ex.getMessage(), ex);
             }
@@ -239,12 +250,19 @@
      * 鍒嗘瀽琛�'rc_video_t1'锛屽苟鎶婄粰瀹氳棰戠浉浼艰褰曞啓鍏ョ浜屼釜涓存椂琛�'rc_video_t2'
      * @param videoFolderInfo
      */
-    protected abstract void writeRcVideoT2(VideoFolderInfo videoFolderInfo);
+    protected abstract void writeRcVideoT2(VideoFolderInfo videoFolderInfo, String batchId);
 
     /**
      * 鍒嗘瀽缁欏畾鎵规鎵�鏈夎棰戠敤鎴锋帹鑽愮殑瑙嗛淇℃伅锛屽苟鍐欏叆琛�:'rc_video_user'
      * @param batchId
-     * @param recVideoIdList 鎺ㄨ崘瑙嗛id闆嗗悎
+     * @param recVideoIdList 鏈壒娆″鐞嗗師濮嬭棰慽d闆嗗悎
      */
     protected abstract void writeRcVideoUser(String batchId, List<String> recVideoIdList);
+
+    /**
+     * 蹇界暐璇ョ姸鎬佹壒娆★紝鐢变簬鏂囦欢澶逛笉瀛樺湪绛夊師鍥狅紝涓嶅甫澶勭悊锛屼笉瑕佸湪杩欓噷鎵撲即銆�
+     * @param batchId
+     * @date 2022-10-11
+     */
+    protected abstract void ignoreTaskStatus(String batchId);
 }

--
Gitblit v1.9.1