CreateObjUtil.java 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. package com.fdkankan.model.utils;
  2. import com.fdkankan.model.constants.ConstantCmd;
  3. import com.fdkankan.model.constants.ConstantFileName;
  4. import com.fdkankan.model.constants.ConstantFilePath;
  5. import com.fdkankan.model.proto.BigSceneProto;
  6. import com.fdkankan.model.proto.Common;
  7. import com.fdkankan.model.proto.Visionmodeldata;
  8. import com.fdkankan.model.proto.format.JsonFormat;
  9. import com.google.protobuf.TextFormat;
  10. import lombok.extern.slf4j.Slf4j;
  11. import java.io.*;
  12. import java.util.HashMap;
  13. import java.util.Map;
  14. import lombok.extern.slf4j.Slf4j;
  15. @Slf4j
  16. public class CreateObjUtil {
  17. // private static Logger log = LoggerFactory.getLogger(CreateObjUtil.class);
  18. public void saveuploadImgs(String folderName) throws IOException, Exception
  19. {
  20. log.info("开始计算");
  21. String command = "bash /home/ubuntu/photoscan-pro/build_model.sh "+folderName;
  22. callshell(command);
  23. boolean flag = false;
  24. String sPath = ConstantFilePath.CREATE_MODEL_PATH+folderName+File.separator+"mesh"+File.separator+"mesh.obj";
  25. while(!flag)
  26. {
  27. flag = isModel(sPath,folderName);
  28. }
  29. log.info("计算完毕");
  30. }
  31. public void saveuploadImgs2(String folderName) throws IOException, Exception
  32. {
  33. log.info("开始计算");
  34. String command = "bash /home/ubuntu/photoscan-pro/build_bigscene.sh "+folderName;
  35. callshell(command);
  36. boolean flag = false;
  37. String sPath = ConstantFilePath.CREATE_BIG_SCENE_PATH+folderName+File.separator+"mesh"+File.separator+"mesh.obj";
  38. while(!flag)
  39. {
  40. flag = isModel(sPath,folderName);
  41. }
  42. log.info("计算完毕");
  43. log.info("obj和camera转换成大场景要的格式");
  44. convertobjTotxt( folderName);
  45. }
  46. //开始建模
  47. public static void unRar(String rarPath,String dataPath) throws Exception{
  48. log.info("解压rar开始");
  49. String command = "unrar e " + rarPath + " " + dataPath;
  50. callshell(command);
  51. log.info("解压rar完毕:" + command);
  52. }
  53. public static void unZip(String zipPath,String dataPath) throws Exception{
  54. log.info("解压zip开始");
  55. String command = "unzip -O GBK/GB18030CP936 " + zipPath + " -d " + dataPath;
  56. callshell(command);
  57. log.info("解压zip完毕:" + command);
  58. }
  59. //开始建模
  60. public static void build3dModel(String folderName,String isModel) throws Exception{
  61. log.info("开始建模");
  62. String command = ConstantCmd.BUILD_MODEL_COMMAND+folderName;
  63. callshell(command);
  64. log.info("计算完毕:" + command);
  65. }
  66. //开始建模
  67. public static void build3dModel2(String folderName,String isModel) throws Exception{
  68. log.info("开始建模");
  69. String command = ConstantCmd.BUILD_MODEL_COMMAND2+folderName;
  70. callshell(command);
  71. log.info("计算完毕:" + command);
  72. }
  73. //开始建模
  74. public static void build3dModelOld(String folderName,String isModel) throws Exception{
  75. log.info("开始v2建模");
  76. String command = ConstantCmd.BUILD_MODEL_OLD_COMMAND+folderName;
  77. callshell(command);
  78. log.info("计算v2完毕:" + command);
  79. }
  80. //开始建模
  81. public static void translateHoustfloorJSONFile(String filePath,String outputPath) throws Exception{
  82. log.info("开始转换houst_floor.json");
  83. String command = ConstantCmd.TRANSLATE_HOUST_FLOOR + filePath + " " + outputPath;
  84. callshell(command);
  85. log.info("转换houst_floor.json 结束");
  86. }
  87. //激光相机复制资源
  88. public static void cpfile(String filepathOld,String filepathNew) throws Exception{
  89. log.info("开始复制");
  90. String command = ConstantCmd.CP_JG_EXTRA+ " " + filepathOld + " " + filepathNew;
  91. callshell(command);
  92. log.info("复制完毕:" + command);
  93. }
  94. //激光相机复制资源laser下的全部资源
  95. public static void cplaserfile(String filepathOld,String filepathNew) throws Exception{
  96. log.info("开始复制");
  97. String command = ConstantCmd.CP_JG_ALL+ " " + filepathOld + " " + filepathNew;
  98. callshell(command);
  99. log.info("复制完毕:" + command);
  100. }
  101. //开始建模
  102. public void build3dModelSFM(String folderName,String isModel) throws Exception{
  103. log.info("开始建模");
  104. String command = ConstantCmd.BUILD_MODEL_SFM_COMMAND+folderName+" "+isModel;
  105. callshell(command);
  106. log.info("计算完毕");
  107. }
  108. //obj文件转换问txt
  109. public static void objToTxt(String folderName,String isModel) throws Exception{
  110. log.info("obj2txt开始转换");
  111. String command = ConstantCmd.OBJ_TO_TXT+folderName;
  112. callshell(command);
  113. log.info("转换完毕:" + command);
  114. }
  115. public void rebuildModelFllor(String folderName, String isModel) {
  116. try{
  117. log.info("开始建模");
  118. String command = ConstantCmd.REBUILD_MODEL_FLLOR+folderName+" "+isModel;
  119. callshell(command);
  120. log.info("计算完毕");
  121. }
  122. catch(Exception e)
  123. {
  124. e.printStackTrace();
  125. }
  126. }
  127. //切图
  128. public void cutImgs(String[] imgNames ,String folderName)
  129. {
  130. try{
  131. log.info("开始切图");
  132. for(int i=0;i<imgNames.length;++i)
  133. {
  134. String imgName=imgNames[i].replace(".jpg", "");
  135. String command = ConstantCmd.CUT_IMG_COMMAND+folderName+" "+imgName;
  136. callshell(command);
  137. }
  138. log.info("切图完毕");
  139. }
  140. catch(Exception e)
  141. {
  142. e.printStackTrace();
  143. }
  144. }
  145. //调整切图
  146. public void adjustImgs(String folderName)
  147. {
  148. try{
  149. String command = ConstantCmd.ADJUST_IMG_COMMAND + folderName;
  150. log.info("开始调整图片");
  151. callshell(command);
  152. log.info("调整图片完毕");
  153. }
  154. catch(Exception e)
  155. {
  156. e.printStackTrace();
  157. }
  158. }
  159. //obj和camera转换成大场景要的格式
  160. public void convertobjTotxt(String folderName) throws Exception
  161. {
  162. //obj
  163. String command = "/home/ubuntu/photoscan-pro/main/mesh/mesh "+folderName;
  164. callshell(command);
  165. //camera
  166. command = "/home/ubuntu/photoscan-pro/main/read_camera/read_camera "+folderName;
  167. callshell(command);
  168. String prefix = ConstantFilePath.CREATE_BIG_SCENE_PATH+folderName+File.separator+"data"+File.separator;
  169. String srcpath = prefix +"mesh.txt";
  170. String despath = prefix +"dacf7dfa24ae47fab8fcebfe4dc41ab9_50k.dam";
  171. convertTxtToDam( srcpath, despath);
  172. //dam转换成lzma
  173. command = "lzma /home/ubuntu/photo_data/bigscene/"+folderName+"/data/dacf7dfa24ae47fab8fcebfe4dc41ab9_50k.dam";
  174. callshell(command);
  175. srcpath = prefix +"vision.txt";
  176. despath = prefix +"vision.modeldata";
  177. convertTxtToVisionmodeldata( srcpath, despath);
  178. }
  179. public static void convertDamToLzma(String folderName)throws Exception
  180. {
  181. try
  182. {
  183. String command = "lzma "+ folderName+ ConstantFileName.modelUUID+"_50k.dam";
  184. log.info("开始转换lzma");
  185. callshell(command);
  186. log.info("转换lzma完毕");
  187. }
  188. catch(Exception e)
  189. {
  190. StringWriter trace=new StringWriter();
  191. e.printStackTrace(new PrintWriter(trace));
  192. log.error(trace.toString());
  193. }
  194. }
  195. public static void convertDamToLzmaByAbsolutePath(String path)throws Exception
  196. {
  197. try
  198. {
  199. String command = "lzma "+ path;
  200. log.info("开始转换lzma");
  201. callshell(command);
  202. log.info("转换lzma完毕");
  203. }
  204. catch(Exception e)
  205. {
  206. StringWriter trace=new StringWriter();
  207. e.printStackTrace(new PrintWriter(trace));
  208. log.error(trace.toString());
  209. }
  210. }
  211. public static void convertDamToLzma2(String folderName)throws Exception
  212. {
  213. try
  214. {
  215. String command = "lzma "+ folderName+File.separator+ ConstantFileName.modelUUID+"_50k2.dam";
  216. log.info("开始转换lzma");
  217. callshell(command);
  218. log.info("转换lzma完毕");
  219. }
  220. catch(Exception e)
  221. {
  222. StringWriter trace=new StringWriter();
  223. e.printStackTrace(new PrintWriter(trace));
  224. log.error(trace.toString());
  225. }
  226. }
  227. public static void convertTxtToDam(String srcpath,String despath)throws Exception{
  228. BigSceneProto.binary_mesh.Builder builder = BigSceneProto.binary_mesh.newBuilder();
  229. InputStream inputStream = new FileInputStream(srcpath);
  230. InputStreamReader reader = new InputStreamReader(inputStream, "ASCII");
  231. TextFormat.merge(reader, builder);
  232. byte[] buf = builder.build().toByteArray();
  233. //把序列化后的数据写入本地磁盘
  234. ByteArrayInputStream stream = new ByteArrayInputStream(buf);
  235. BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(despath));//设置输出路径
  236. BufferedInputStream bis = new BufferedInputStream(stream);
  237. int b = -1;
  238. while ((b = bis.read()) != -1) {
  239. bos.write(b);
  240. }
  241. bis.close();
  242. bos.close();
  243. }
  244. public static void convertVisionmodeldataToTxt(String srcpath,String despath)throws Exception
  245. {
  246. try
  247. {
  248. File file = new File(srcpath);
  249. FileInputStream fis=new FileInputStream(file);
  250. Visionmodeldata.NavigationInfo data_NavigationInfo = Visionmodeldata.NavigationInfo.parseFrom(fis);
  251. //PrintStream out = new PrintStream(despath);
  252. String jsonFormat1 = JsonFormat.printToString(data_NavigationInfo);
  253. ByteArrayInputStream stream = new ByteArrayInputStream(jsonFormat1.getBytes());
  254. BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(despath));//设置输出路径
  255. BufferedInputStream bis = new BufferedInputStream(stream);
  256. int b = -1;
  257. while ((b = bis.read()) != -1) {
  258. bos.write(b);
  259. }
  260. //out.close();
  261. bis.close();
  262. bos.close();
  263. }
  264. catch(Exception e)
  265. {
  266. StringWriter trace=new StringWriter();
  267. e.printStackTrace(new PrintWriter(trace));
  268. log.error(trace.toString());
  269. }
  270. }
  271. public static void convertTxtToVisionmodeldata(String srcpath,String despath)throws Exception
  272. {
  273. try{
  274. Visionmodeldata.NavigationInfo.Builder builder = Visionmodeldata.NavigationInfo.newBuilder();
  275. String jsonFormat = readTxtFileToJson(srcpath);
  276. JsonFormat.merge(jsonFormat, builder);
  277. byte[] buf= builder.build().toByteArray();
  278. //把序列化后的数据写入本地磁盘
  279. ByteArrayInputStream stream = new ByteArrayInputStream(buf);
  280. BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(despath));//设置输出路径
  281. BufferedInputStream bis = new BufferedInputStream(stream);
  282. int b = -1;
  283. while ((b = bis.read()) != -1) {
  284. bos.write(b);
  285. }
  286. bis.close();
  287. bos.close();
  288. }
  289. catch(Exception e)
  290. {
  291. StringWriter trace=new StringWriter();
  292. e.printStackTrace(new PrintWriter(trace));
  293. log.error(trace.toString());
  294. }
  295. }
  296. public static void convertVisionmodeldataToTxtCommon(String srcpath,String despath)throws Exception
  297. {
  298. try
  299. {
  300. File file = new File(srcpath);
  301. FileInputStream fis=new FileInputStream(file);
  302. Common.NavigationInfo data_NavigationInfo = Common.NavigationInfo.parseFrom(fis);
  303. //PrintStream out = new PrintStream(despath);
  304. String jsonFormat1 = JsonFormat.printToString(data_NavigationInfo);
  305. ByteArrayInputStream stream = new ByteArrayInputStream(jsonFormat1.getBytes());
  306. BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(despath));//设置输出路径
  307. BufferedInputStream bis = new BufferedInputStream(stream);
  308. int b = -1;
  309. while ((b = bis.read()) != -1) {
  310. bos.write(b);
  311. }
  312. //out.close();
  313. bis.close();
  314. bos.close();
  315. }
  316. catch(Exception e)
  317. {
  318. StringWriter trace=new StringWriter();
  319. e.printStackTrace(new PrintWriter(trace));
  320. log.error(trace.toString());
  321. }
  322. }
  323. public static void convertTxtToVisionmodeldataCommon(String srcpath,String despath)throws Exception
  324. {
  325. try
  326. {
  327. Common.NavigationInfo.Builder builder = Common.NavigationInfo.newBuilder();
  328. String jsonFormat = readTxtFileToJson(srcpath);
  329. JsonFormat.merge(jsonFormat, builder);
  330. byte[] buf= builder.build().toByteArray();
  331. //把序列化后的数据写入本地磁盘
  332. ByteArrayInputStream stream = new ByteArrayInputStream(buf);
  333. BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(despath));//设置输出路径
  334. BufferedInputStream bis = new BufferedInputStream(stream);
  335. int b = -1;
  336. while ((b = bis.read()) != -1) {
  337. bos.write(b);
  338. }
  339. bis.close();
  340. bos.close();
  341. }
  342. catch(Exception e)
  343. {
  344. StringWriter trace=new StringWriter();
  345. e.printStackTrace(new PrintWriter(trace));
  346. log.error(trace.toString());
  347. }
  348. }
  349. public static void callshell(String command){
  350. try {
  351. Long start = System.currentTimeMillis();
  352. Process process = Runtime.getRuntime().exec(command);
  353. StreamGobbler errorGobbler = new StreamGobbler(process.getErrorStream(), "ERROR");
  354. errorGobbler.start();
  355. StreamGobbler outGobbler = new StreamGobbler(process.getInputStream(), "STDOUT");
  356. outGobbler.start();
  357. process.waitFor();
  358. log.info("脚本{}执行完毕,用时:{}ms",command,System.currentTimeMillis()-start);
  359. } catch (Exception e) {
  360. e.printStackTrace();
  361. }
  362. }
  363. public static int doWaitFor(Process process) {
  364. InputStream in = null;
  365. InputStream err = null;
  366. int exitValue = -1; // returned to caller when p is finished
  367. try {
  368. in = process.getInputStream();
  369. err = process.getErrorStream();
  370. boolean finished = false; // Set to true when p is finished
  371. while (!finished) {
  372. try {
  373. while (in.available() > 0) {
  374. // Print the output of our system call
  375. Character c = new Character((char) in.read());
  376. System.out.print(c);
  377. }
  378. while (err.available() > 0) {
  379. // Print the output of our system call
  380. Character c = new Character((char) err.read());
  381. System.out.print(c);
  382. }
  383. // Ask the process for its exitValue. If the process
  384. // is not finished, an IllegalThreadStateException
  385. // is thrown. If it is finished, we fall through and
  386. // the variable finished is set to true.
  387. exitValue = process.exitValue();
  388. finished = true;
  389. } catch (IllegalThreadStateException e) {
  390. // Process is not finished yet;
  391. // Sleep a little to save on CPU cycles
  392. Thread.currentThread().sleep(500);
  393. }
  394. }
  395. } catch (Exception e) {
  396. e.printStackTrace();
  397. } finally {
  398. try {
  399. if (in != null) {
  400. in.close();
  401. }
  402. } catch (IOException e) {
  403. e.printStackTrace();
  404. }
  405. if (err != null) {
  406. try {
  407. err.close();
  408. } catch (IOException e) {
  409. e.printStackTrace();
  410. }
  411. }
  412. }
  413. return exitValue;
  414. }
  415. private boolean isModel(String sPath,String folderName)
  416. {
  417. boolean flag = false;
  418. File file = new File(sPath);
  419. if (file.isFile() && file.exists()) {
  420. flag = true;
  421. }
  422. log.info("等待...");
  423. return flag;
  424. }
  425. public static String readTxtFileToJson(String filePath){
  426. try {
  427. String encoding="UTF-8";
  428. File file=new File(filePath);
  429. if(file.isFile() && file.exists()){
  430. InputStreamReader read = new InputStreamReader(
  431. new FileInputStream(file),encoding);
  432. BufferedReader bufferedReader = new BufferedReader(read);
  433. String lineTxt = null;
  434. String result="";
  435. while((lineTxt = bufferedReader.readLine()) != null){
  436. result+=lineTxt;
  437. //log.info(lineTxt);
  438. }
  439. read.close();
  440. return result;
  441. }else{
  442. return null;
  443. }
  444. } catch (Exception e) {
  445. e.printStackTrace();
  446. return null;
  447. }
  448. }
  449. public Map<String,String> getAllFile(String dPath,String prefix)
  450. {
  451. File dirFile = new File(dPath);
  452. if (!dirFile.isDirectory()) {
  453. }
  454. Map<String,String> map = new HashMap<String,String>();
  455. File[] files = dirFile.listFiles();
  456. for (int i = 0; i < files.length; i++) {
  457. if (files[i].isFile()) {
  458. String path = files[i].getPath();
  459. map.put(path, prefix+path.substring(path.lastIndexOf("/")+1));
  460. }
  461. }
  462. return map;
  463. }
  464. public Map<String,String> getchildFile(String dPath,String prefix,String childname)
  465. {
  466. File dirFile = new File(dPath+File.separator+childname);
  467. if (!dirFile.isDirectory()) {
  468. return null;
  469. }
  470. Map<String,String> map = new HashMap<String,String>();
  471. File[] files = dirFile.listFiles();
  472. for (int i = 0; i < files.length; i++) {
  473. if (files[i].isFile()) {
  474. String path = files[i].getPath();
  475. map.put(path, prefix+childname+path.substring(path.lastIndexOf("/")));
  476. }
  477. }
  478. return map;
  479. }
  480. //转台拼图
  481. public void buildPanoramicImgs(String folderName)throws Exception
  482. {
  483. String command = ConstantCmd.BUILD_PANORAMA + folderName;
  484. log.info("开始拼全景图");
  485. callshell(command);
  486. log.info("全景图拼接完毕");
  487. }
  488. //六目拼图、切图,计算
  489. public void buildForSix(String folderName)throws Exception
  490. {
  491. String command = ConstantCmd.BUILD_FOR_SIX + folderName;
  492. log.info("开始处理数据(六目)");
  493. callshell(command);
  494. log.info("数据处理完毕(六目)");
  495. }
  496. public static void createSoftConnection(String source, String target) {
  497. String command = "ln -s " + source + " " + target;
  498. log.info("开始创建文件夹软连接");
  499. callshell(command);
  500. log.info("数据处理完毕(六目):" + command);
  501. }
  502. //合并音频
  503. public static void mergeVideo(String oldVideo , String newVideo, String targetVideo) throws Exception{
  504. String command = ConstantCmd.MERGE_VIDEO + " " + oldVideo + " " + newVideo + " " + targetVideo + " -y";
  505. log.info("开始合并视频");
  506. callshell(command);
  507. log.info("合并视频完毕:" + command);
  508. }
  509. //生成一段静音音频
  510. public static void createMuteViode(double time , String targetVideo) throws Exception{
  511. String command = ConstantCmd.CREATE_MUTE_VIDEO + " " + time + " " + targetVideo + " -y";
  512. log.info("开始生成一段静音音频");
  513. callshell(command);
  514. log.info("生成一段静音音频完毕:" + command);
  515. }
  516. //mp4文件转换成flv文件
  517. public static void mp4ToFlv(String oldVideo, String newVideo) throws Exception{
  518. String command = ConstantCmd.MP4_TO_FLV + " " + oldVideo + " " + newVideo;
  519. log.info("mp4文件转换成flv文件");
  520. callshell(command);
  521. log.info("mp4文件转换成flv文件完毕:" + command);
  522. }
  523. public static void formatMp4(String oldVideo, String newVideo) throws Exception{
  524. String command = ConstantCmd.FORMAT_MP4 + " " + oldVideo + " " + newVideo;
  525. log.info("mp4格式转换开始:{}", command);
  526. callshell(command);
  527. log.info("mp4格式转换完毕:{}", command);
  528. }
  529. //删除/mnt/data/下的数据
  530. public static void deleteFile(String filePath) throws Exception{
  531. String command = ConstantCmd.DELETE_FILE + " " + filePath;
  532. log.info("删除/mnt/data/下的数据");
  533. callshell(command);
  534. log.info("删除/mnt/data/下的数据完毕:" + command);
  535. }
  536. /**
  537. *
  538. * @param fyunType oss类型(oss, aws)
  539. * @param bucket oss桶名
  540. * @param fileUrl key
  541. * @param path 本地路径
  542. * @throws Exception
  543. */
  544. public static void ossUtilCp(String fyunType, String bucket, String fileUrl , String path) throws Exception{
  545. String optType = fileUrl.contains(".") ? "file" : "folder";
  546. String command = String.format(ConstantCmd.FYUN_DOWNLOAD, bucket, fileUrl, path, fyunType, optType);
  547. Long start = System.currentTimeMillis();
  548. log.info("开始oss下载文件:" + command);
  549. callshell(command);
  550. log.info("oss下载文件完成,时间为:" + (System.currentTimeMillis() - start));
  551. }
  552. public static void ossFileCp(String fileUrl , String path) throws Exception{
  553. String command = ConstantCmd.OSS_FILE_CP + " " + fileUrl + " " + path;
  554. Long start = System.currentTimeMillis();
  555. log.info("开始s3文件下载文件:" + command);
  556. callshell(command);
  557. log.info("s3文件下载文件完成,时间为:" + (System.currentTimeMillis() - start));
  558. }
  559. /**
  560. * matterpro场景获取阿里云的切图数据
  561. * @param path
  562. * @throws Exception
  563. */
  564. public static void matterproCutImg(String num , String path) throws Exception{
  565. String command = ConstantCmd.MATTERPRO_CUT_IMG + " -s " + num + " -d " + path;
  566. Long start = System.currentTimeMillis();
  567. log.info("开始matterpro获取阿里云图片方法:" + command);
  568. callshell(command);
  569. log.info("matterpro获取阿里云图片方法完成,时间为:" + (System.currentTimeMillis() - start));
  570. }
  571. public static void ossUtilCpFolder(String sourceFolder , String targetFolder){
  572. File sourceFile = new File(sourceFolder);
  573. if (!sourceFile.exists()) {
  574. log.error("oss文件夹上传异常,文件夹不存在{}", sourceFolder);
  575. }
  576. String command = String.format(ConstantCmd.OSS_UTIL_CP_FOLDER,targetFolder,sourceFolder);
  577. Long start = System.currentTimeMillis();
  578. log.info("开始上传oss文件夹:" + command);
  579. callshell(command);
  580. log.info("oss文件夹上传完成,时间为:" + (System.currentTimeMillis() - start));
  581. }
  582. }