Explorar o código

fix filecheck

xiewj hai 1 ano
pai
achega
f4b62a05a3

+ 2 - 2
720yun_fd_consumer/gis_consumer/src/main/java/com/gis/service/impl/FodderServiceImpl.java

@@ -10,6 +10,7 @@ import com.gis.mapper.FodderMapper;
 import com.gis.oss.util.FileAndOssUtil;
 import com.gis.service.FodderService;
 import com.gis.util.CmdUtils;
+import com.gis.util.FileUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.slf4j.MDC;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -41,8 +42,7 @@ public class FodderServiceImpl implements FodderService {
         log.info("处理tour.xml");
         String tourPath = configConstant.serverBasePath + code + "/vtour/tour.xml";
         log.info("tourPath: {}", tourPath);
-        BaseRuntimeException.isTrue(!FileUtil.isFile(tourPath), null, code + "_tour.xml文件不存在");
-
+        BaseRuntimeException.isTrue(!FileUtils.checkFileExtend(tourPath, 10), null, code + "_tour.xml文件不存在");
         String tour = FileUtil.readString(tourPath, "utf-8");
         tour = StrUtil.subAfter(tour, "</action>", true);
         tour = StrUtil.subBefore(tour, "</krpano>", true);

+ 20 - 2
720yun_fd_consumer/gis_consumer/src/main/java/com/gis/util/FileUtils.java

@@ -9,6 +9,7 @@ import org.springframework.stereotype.Component;
 
 import java.io.*;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -109,5 +110,22 @@ public class FileUtils {
         return str;
     }
 
-
-}
+    public static boolean checkFileExtend(final String file,int count){
+        int i=0;
+        while (i<=count){
+            final boolean exist = FileUtil.exist(file);
+            log.info("文件={},第-{}-次检测,检测结果={}",file,i,exist);
+            if (!exist&&i==count){
+                return false;
+            }else if (exist){
+                return true;
+            }
+            i++;
+            try {
+                Thread.sleep(5000);
+            } catch (final InterruptedException e) {
+                throw new RuntimeException(e);
+            }
+        }
+        return false;
+    }}