lyhzzz il y a 6 mois
Parent
commit
dd8dd3f9b3

+ 2 - 2
src/main/java/com/fdkankan/manage/service/impl/ScenePlusServiceImpl.java

@@ -124,7 +124,7 @@ public class ScenePlusServiceImpl extends ServiceImpl<IScenePlusMapper, ScenePlu
     @Override
     public String getSceneBuildLog(String num) {
         String buildLogPath = "/oss/4dkankan/build_log/" + num;
-        String zipName = buildLogPath+"/"+num+".zip";
+        String zipName = num+".zip";
 
         List<SceneBuildProcessLog> listProcessLog =  sceneBuildProcessLogService.getByNum(num);
         List<BuildLog> listBuildLog =  buildLogService.getByNum(num);
@@ -136,6 +136,6 @@ public class ScenePlusServiceImpl extends ServiceImpl<IScenePlusMapper, ScenePlu
             excelService.commonExport(listBuildLog,BuildLog.class,buildLogPath +"/build.xlsx");
         }
         ShellUtil.zip(buildLogPath,zipName);
-        return zipName.replace("/4dkankan","");
+        return buildLogPath +"/"+zipName;
     }
 }

+ 4 - 5
src/main/java/com/fdkankan/manage/util/ShellUtil.java

@@ -24,7 +24,9 @@ public class ShellUtil {
         try {
             // 执行命令, 返回一个子进程对象(命令在子进程中执行)
             log.info("执行cmd:{}",cmd);
-            process = Runtime.getRuntime().exec(cmd);
+            String[] cmd2 = new String[]{"/bin/sh", "-c", cmd};
+
+            process = Runtime.getRuntime().exec(cmd2);
             // 获取命令执行结果, 有两个结果: 正常的输出 和 错误的输出(PS: 子进程的输出就是主进程的输入)
             //处理InputStream的线程
             threadRun(process);
@@ -115,10 +117,7 @@ public class ShellUtil {
 
     public static void zip(String dataPath, String zipPath) {
         log.info("打包zip开始");
-        if(!new File(zipPath).getParentFile().exists()){
-            return;
-        }
-        String command = "zip -r   " + zipPath + "  " + dataPath;
+        String command ="cd " + dataPath + " && zip -r   " + zipPath + " * " ;
         execCmd(command);
         log.info("解压zip完毕:" + command);
     }