dsx 1 سال پیش
والد
کامیت
1ebd470bf1
1فایلهای تغییر یافته به همراه36 افزوده شده و 21 حذف شده
  1. 36 21
      src/main/java/com/fdkankan/external/service/impl/SceneOfflinePackagePushServiceImpl.java

+ 36 - 21
src/main/java/com/fdkankan/external/service/impl/SceneOfflinePackagePushServiceImpl.java

@@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.date.TimeInterval;
 import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.lang.UUID;
 import cn.hutool.core.thread.ExecutorBuilder;
 import cn.hutool.core.util.RuntimeUtil;
 import cn.hutool.core.util.StrUtil;
@@ -328,10 +329,7 @@ public class SceneOfflinePackagePushServiceImpl extends ServiceImpl<SceneOffline
             String zipPath = offlineZipDir.concat(num).concat(".zip");
             HttpUtil.downloadFile(downloadUrl, zipPath);
 
-            long size = FileUtil.size(new File(zipPath));
-            Integer mbSize = FileSizeUtil.convert(size, FileSizeUnitType.MB.code());
             String dirPath = null;
-
             String unzipPath = offlineZipDir.concat(num).concat("-").concat(zipType).concat("-").concat(String.valueOf(version));
             ZipUtil.unzip(zipPath, unzipPath, Charset.forName("GBK"));
             if("laser".equals(zipType)){
@@ -339,28 +337,45 @@ public class SceneOfflinePackagePushServiceImpl extends ServiceImpl<SceneOffline
             }else{
                 dirPath = unzipPath.concat("/wwwroot/scene_view_data");
             }
-            String volumeName = dirPath.concat("/zip/").concat(num).concat(".zip");
+            String zipDir = dirPath.concat("/zip/");
+            FileUtil.del(zipDir);
+            String volumeName = zipDir.concat(num).concat(".zip");
             FileUtil.mkParentDirs(volumeName);
-            String cmd = "cd " + dirPath + " && zip -r " + volumeName + " " + num + " -s 20M";
+            String cmd = "cd " + dirPath + " && zip -r " + volumeName + " " + num + " -s 100M";
             log.info("压缩命令:{}", cmd);
             CmdUtils.callLineSh(cmd, 200);
-//            RuntimeUtil.exec(cmd).waitFor();
-
-//            ScenePlus scenePlus = scenePlusService.getByNum(num);
-//            ScenePlusExt scenePlusExt = scenePlusExtService.getByPlusId(scenePlus.getId());
-//            Map<String, Object> params = new HashMap<>();
-//            params.put("num", num);
-//            params.put("title", scenePlus.getTitle());
-//            params.put("zipType", zipType);
-//            params.put("downloadUrl", downloadUrl);
-//            params.put("version", push.getVersion());
-//            params.put("calcTime", DateExtUtil.format(scenePlusExt.getAlgorithmTime(), DateExtUtil.dateStyle8));
-//            params.put("file", FileUtil.file(zipPath));
-//            String post = HttpUtil.post(push.getDestUrl(), params, 60 * 60 * 1000);
-//            log.info("场景推送成功,接收端返回结果:{}", post);
-////            httpClient.post2(push.getDestUrl(), params, new SuccessCallback(), new ErrorCallback());
+
+            List<String> fileList = FileUtil.listFileNames(zipDir);
+            if(CollUtil.isEmpty(fileList)){
+                throw new RuntimeException("压缩包不存在");
+            }
+
+            String id = UUID.fastUUID().toString();
+            for (String file : fileList) {
+                Map<String, Object> params = new HashMap<>();
+                params.put("id", id);
+                params.put("action", "upload");
+                params.put("fileName", "file");
+                params.put("file", FileUtil.file(zipDir.concat(file)));
+                String post = HttpUtil.post(push.getDestUrl(), params, 60 * 60 * 1000);
+                log.info("场景推送成功,接收端返回结果:{}", post);
+            }
+
+            ScenePlus scenePlus = scenePlusService.getByNum(num);
+            ScenePlusExt scenePlusExt = scenePlusExtService.getByPlusId(scenePlus.getId());
+            Map<String, Object> params = new HashMap<>();
+            params.put("id", id);
+            params.put("action", "save");
+            params.put("fileName", num.concat(".zip"));
+            params.put("num", num);
+            params.put("title", scenePlus.getTitle());
+            params.put("zipType", zipType);
+            params.put("downloadUrl", downloadUrl);
+            params.put("version", push.getVersion());
+            params.put("calcTime", DateExtUtil.format(scenePlusExt.getAlgorithmTime(), DateExtUtil.dateStyle8));
+            String post = HttpUtil.post(push.getDestUrl(), params, 60 * 60 * 1000);
+            log.info("场景推送成功,接收端返回结果:{}", post);
             push.setPushStatus(CommonSuccessStatus.SUCCESS.code());
-//            push.setZipPath(downloadUrl);
         }catch (Exception e){
             log.error("场景推送失败,num:{}", num, e);
             push.setPushStatus(CommonSuccessStatus.FAIL.code());