|
|
@@ -316,87 +316,95 @@ public class SceneOfflinePackagePushServiceImpl extends ServiceImpl<SceneOffline
|
|
|
String num = scenePushBean.getNum();
|
|
|
String zipType = scenePushBean.getZipType();
|
|
|
Long version = scenePushBean.getVersion();
|
|
|
- String downloadUrl = null;
|
|
|
- ScenePlus scenePlus = scenePlusService.getByNum(num);
|
|
|
- ScenePlusExt scenePlusExt = scenePlusExtService.getByPlusId(scenePlus.getId());
|
|
|
- String title = scenePlus.getTitle();
|
|
|
- if("laser".equals(zipType)){
|
|
|
- downloadUrl = this.genZipUrl4Laser(num);
|
|
|
- }else{
|
|
|
- downloadUrl = this.genZipUrl4Kankan(num);
|
|
|
- }
|
|
|
+ String zipPath = offlineZipDir.concat(num).concat(".zip");
|
|
|
+ String unzipPath = offlineZipDir.concat(num).concat("-").concat(zipType).concat("-").concat(String.valueOf(version));
|
|
|
+ try {
|
|
|
+ String downloadUrl = null;
|
|
|
+ ScenePlus scenePlus = scenePlusService.getByNum(num);
|
|
|
+ ScenePlusExt scenePlusExt = scenePlusExtService.getByPlusId(scenePlus.getId());
|
|
|
+ String title = scenePlus.getTitle();
|
|
|
+ if("laser".equals(zipType)){
|
|
|
+ downloadUrl = this.genZipUrl4Laser(num);
|
|
|
+ }else{
|
|
|
+ downloadUrl = this.genZipUrl4Kankan(num);
|
|
|
+ }
|
|
|
|
|
|
- //开始推送到第三方服务
|
|
|
- if(StrUtil.isEmpty(downloadUrl)){
|
|
|
- throw new RuntimeException("场景下载失败,下载链接为空,场景码:" + num);
|
|
|
- }
|
|
|
+ //开始推送到第三方服务
|
|
|
+ if(StrUtil.isEmpty(downloadUrl)){
|
|
|
+ throw new RuntimeException("场景下载失败,下载链接为空,场景码:" + num);
|
|
|
+ }
|
|
|
|
|
|
- //下载到本地
|
|
|
- String zipPath = offlineZipDir.concat(num).concat(".zip");
|
|
|
- HttpUtil.downloadFile(downloadUrl, zipPath);
|
|
|
+ //下载到本地
|
|
|
+ HttpUtil.downloadFile(downloadUrl, zipPath);
|
|
|
|
|
|
- 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)){
|
|
|
- dirPath = unzipPath.concat("/www");
|
|
|
- }else{
|
|
|
- dirPath = unzipPath.concat("/wwwroot/scene_view_data");
|
|
|
- }
|
|
|
- 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 500M";
|
|
|
- log.info("压缩命令:{}", cmd);
|
|
|
- CmdUtils.callLineSh(cmd, 200);
|
|
|
- log.info("分卷压缩完成");
|
|
|
-
|
|
|
- List<String> fileList = FileUtil.listFileNames(zipDir);
|
|
|
- if(CollUtil.isEmpty(fileList)){
|
|
|
- throw new RuntimeException("压缩包不存在");
|
|
|
- }
|
|
|
+ String dirPath = null;
|
|
|
+ ZipUtil.unzip(zipPath, unzipPath, Charset.forName("GBK"));
|
|
|
+ if("laser".equals(zipType)){
|
|
|
+ dirPath = unzipPath.concat("/www");
|
|
|
+ }else{
|
|
|
+ dirPath = unzipPath.concat("/wwwroot/scene_view_data");
|
|
|
+ }
|
|
|
+ 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 500M";
|
|
|
+ log.info("压缩命令:{}", cmd);
|
|
|
+ CmdUtils.callLineSh(cmd, 200);
|
|
|
+ log.info("分卷压缩完成");
|
|
|
+
|
|
|
+ List<String> fileList = FileUtil.listFileNames(zipDir);
|
|
|
+ if(CollUtil.isEmpty(fileList)){
|
|
|
+ throw new RuntimeException("压缩包不存在");
|
|
|
+ }
|
|
|
|
|
|
- int index = 1;
|
|
|
- for (String file : fileList) {
|
|
|
+ int index = 1;
|
|
|
+ for (String file : fileList) {
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ params.put("id", id);
|
|
|
+ params.put("action", "upload");
|
|
|
+ params.put("fileName", file);
|
|
|
+ params.put("num", num);
|
|
|
+ params.put("title", title);
|
|
|
+ params.put("zipType", zipType);
|
|
|
+ params.put("file", FileUtil.file(zipDir.concat(file)));
|
|
|
+ log.info("开发发送第{}个压缩包", index);
|
|
|
+ String post = HttpUtil.post(scenePushBean.getDestUrl() + "/historyrical/scene/deploy", params, 60 * 60 * 1000);
|
|
|
+ ResultData deployResult = JSON.parseObject(post,ResultData.class);
|
|
|
+ if(deployResult.getCode() != 0){
|
|
|
+ throw new RuntimeException("部署端接收文件失败");
|
|
|
+ }
|
|
|
+ log.info("第{}个场景推送成功,接收端返回结果:{}", index, post);
|
|
|
+ ++index;
|
|
|
+ }
|
|
|
+
|
|
|
+ if("laser".equals(zipType)){
|
|
|
+ Scene scene = sceneService.getBySceneCode(scenePlus.getNum());
|
|
|
+ title = scene.getTitle();
|
|
|
+ }
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("id", id);
|
|
|
- params.put("action", "upload");
|
|
|
- params.put("fileName", file);
|
|
|
+ params.put("action", "save");
|
|
|
+ params.put("fileName", num.concat(".zip"));
|
|
|
params.put("num", num);
|
|
|
params.put("title", title);
|
|
|
params.put("zipType", zipType);
|
|
|
- params.put("file", FileUtil.file(zipDir.concat(file)));
|
|
|
- log.info("开发发送第{}个压缩包", index);
|
|
|
+ params.put("version", scenePushBean.getVersion());
|
|
|
+ params.put("calcTime", DateExtUtil.format(scenePlusExt.getAlgorithmTime(), DateExtUtil.dateStyle8));
|
|
|
+ params.put("shootCount", scenePlusExt.getShootCount());
|
|
|
String post = HttpUtil.post(scenePushBean.getDestUrl() + "/historyrical/scene/deploy", params, 60 * 60 * 1000);
|
|
|
ResultData deployResult = JSON.parseObject(post,ResultData.class);
|
|
|
if(deployResult.getCode() != 0){
|
|
|
- throw new RuntimeException("部署端接收文件失败");
|
|
|
+ throw new RuntimeException("部署端接收部署指令失败");
|
|
|
}
|
|
|
- log.info("第{}个场景推送成功,接收端返回结果:{}", index, post);
|
|
|
- ++index;
|
|
|
+ log.info("场景推送成功,接收端返回结果:{}", post);
|
|
|
+ }finally {
|
|
|
+ log.info("删除原始压缩包,zipPath:{}", zipPath);
|
|
|
+ FileUtil.del(zipPath);
|
|
|
+ log.info("删除推送数据,unzipPath:{}", unzipPath);
|
|
|
+ FileUtil.del(unzipPath);
|
|
|
}
|
|
|
|
|
|
- if("laser".equals(zipType)){
|
|
|
- Scene scene = sceneService.getBySceneCode(scenePlus.getNum());
|
|
|
- title = scene.getTitle();
|
|
|
- }
|
|
|
- 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", title);
|
|
|
- params.put("zipType", zipType);
|
|
|
- params.put("version", scenePushBean.getVersion());
|
|
|
- params.put("calcTime", DateExtUtil.format(scenePlusExt.getAlgorithmTime(), DateExtUtil.dateStyle8));
|
|
|
- params.put("shootCount", scenePlusExt.getShootCount());
|
|
|
- String post = HttpUtil.post(scenePushBean.getDestUrl() + "/historyrical/scene/deploy", params, 60 * 60 * 1000);
|
|
|
- ResultData deployResult = JSON.parseObject(post,ResultData.class);
|
|
|
- if(deployResult.getCode() != 0){
|
|
|
- throw new RuntimeException("部署端接收部署指令失败");
|
|
|
- }
|
|
|
- log.info("场景推送成功,接收端返回结果:{}", post);
|
|
|
}
|
|
|
|
|
|
public static void main(String[] args) throws Exception {
|