wuweihao 3 éve
szülő
commit
ae63c8c58f

+ 2 - 1
720yun_local_manage/gis_common/src/main/java/com/gis/common/constant/CmdConstant.java

@@ -27,5 +27,6 @@ public class CmdConstant {
      * @code  需要下载的目录参数, 参数用逗号隔开
      */
 //    public final static String zip = "zip -r @output @inDir{@code}";
-    public final static String zip = "bash /root/data/720yun_local_manage_data/baseData/zip.sh @workPace @output \"@inDir\"";
+//    public final static String zip = "bash /root/data/720yun_local_manage_data/baseData/zip.sh @workPace @output \"@inDir\"";
+    public final static String zip = "bash /root/data/720yun_local_manage_data/baseData/zip.sh @workPace @output '@inDir'";
 }

+ 20 - 1
720yun_local_manage/gis_common/src/main/java/com/gis/common/util/CmdUtils.java

@@ -10,7 +10,6 @@ public class CmdUtils {
 
 
     /**
-     * 调用算法 xx.sh 脚本
      * @param command
      */
     public static void callShell(String command){
@@ -27,5 +26,25 @@ public class CmdUtils {
         }
     }
 
+    /**
+     * 调用算法 xx.sh 脚本
+     * @param command
+     */
+    public static void callSh(String command){
+        log.info("cmd: {}", command);
+        try {
+            String[] cmd = new String[]{"/bin/sh", "-c", command};
+            Process process = Runtime.getRuntime().exec(cmd);
+            StreamGobbler errorGobbler = new StreamGobbler(process.getErrorStream(), "ERROR");
+            errorGobbler.start();
+            StreamGobbler outGobbler = new StreamGobbler(process.getInputStream(), "STDOUT");
+            outGobbler.start();
+            process.waitFor();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+
 
 }

+ 2 - 2
720yun_local_manage/gis_pano/src/main/java/com/gis/cms/service/impl/OpsServiceImpl.java

@@ -61,7 +61,7 @@ public class OpsServiceImpl  implements OpsService {
         cmd = cmd.replaceAll("@workPace", configConstant.serverBasePath + "/work");
         cmd = cmd.replaceAll("@inDir", ids);
 
-        CmdUtils.callShell(cmd);
+        CmdUtils.callSh(cmd);
 
         return Result.success(zipName);
     }
@@ -93,7 +93,7 @@ public class OpsServiceImpl  implements OpsService {
         cmd = cmd.replaceAll("@workPace", configConstant.serverBasePath );
         cmd = cmd.replaceAll("@inDir", dirCode);
 
-        CmdUtils.callShell(cmd);
+        CmdUtils.callSh(cmd);
 
 
         return Result.success(zipName);