|
|
@@ -19,6 +19,7 @@ import com.fdkankan.common.constant.FileSizeUnitType;
|
|
|
import com.fdkankan.common.constant.SceneSource;
|
|
|
import com.fdkankan.common.util.DateExtUtil;
|
|
|
import com.fdkankan.common.util.FileSizeUtil;
|
|
|
+import com.fdkankan.external.ScenePushBean;
|
|
|
import com.fdkankan.external.bean.DownloadProcessBean;
|
|
|
import com.fdkankan.external.bean.LaserDownloadBean;
|
|
|
import com.fdkankan.external.callback.ErrorCallback;
|
|
|
@@ -165,7 +166,7 @@ public class SceneOfflinePackagePushServiceImpl extends ServiceImpl<SceneOffline
|
|
|
push.setZipType("laser");
|
|
|
push.setVersion(scene.getOfflineVerForPush());
|
|
|
try {
|
|
|
- sceneOfflinePackagePushService.scenePushHandler(push);
|
|
|
+// sceneOfflinePackagePushService.scenePushHandler(push);
|
|
|
}catch (Exception e){
|
|
|
log.error("场景推送失败,num:{}",scenePlus.getNum(), e);
|
|
|
}
|
|
|
@@ -198,7 +199,7 @@ public class SceneOfflinePackagePushServiceImpl extends ServiceImpl<SceneOffline
|
|
|
push.setZipType("kankan");
|
|
|
push.setVersion(version);
|
|
|
try {
|
|
|
- sceneOfflinePackagePushService.scenePushHandler(push);
|
|
|
+// sceneOfflinePackagePushService.scenePushHandler(push);
|
|
|
}catch (Exception e){
|
|
|
log.error("场景推送失败,num:{}",scenePlus.getNum(), e);
|
|
|
}
|
|
|
@@ -313,91 +314,83 @@ public class SceneOfflinePackagePushServiceImpl extends ServiceImpl<SceneOffline
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void scenePushHandler(SceneOfflinePackagePush push){
|
|
|
- String num = push.getNum();
|
|
|
- String zipType = push.getZipType();
|
|
|
- int version = push.getVersion();
|
|
|
+ public void scenePushHandler(ScenePushBean scenePushBean) throws Exception {
|
|
|
+ String id = scenePushBean.getTaskId();
|
|
|
+ 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);
|
|
|
+ }
|
|
|
|
|
|
+ //开始推送到第三方服务
|
|
|
+ if(StrUtil.isEmpty(downloadUrl)){
|
|
|
+ throw new RuntimeException("场景下载失败,下载链接为空,场景码:" + num);
|
|
|
+ }
|
|
|
|
|
|
- try {
|
|
|
- if("laser".equals(zipType)){
|
|
|
- downloadUrl = this.genZipUrl4Laser(num);
|
|
|
- }else{
|
|
|
- downloadUrl = this.genZipUrl4Kankan(num);
|
|
|
- }
|
|
|
-
|
|
|
- //开始推送到第三方服务
|
|
|
- if(StrUtil.isEmpty(downloadUrl)){
|
|
|
- throw new RuntimeException("场景下载失败,下载链接为空,场景码:" + num);
|
|
|
- }
|
|
|
-
|
|
|
- //下载到本地
|
|
|
- String zipPath = offlineZipDir.concat(num).concat(".zip");
|
|
|
- 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 id = UUID.fastUUID().toString();
|
|
|
- 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("file", FileUtil.file(zipDir.concat(file)));
|
|
|
- log.info("开发发送第{}个压缩包", index);
|
|
|
- String post = HttpUtil.post(push.getDestUrl(), params, 60 * 60 * 1000);
|
|
|
- log.info("第{}个场景推送成功,接收端返回结果:{}", index, post);
|
|
|
- ++index;
|
|
|
- }
|
|
|
+ //下载到本地
|
|
|
+ String zipPath = offlineZipDir.concat(num).concat(".zip");
|
|
|
+ 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("压缩包不存在");
|
|
|
+ }
|
|
|
|
|
|
- ScenePlus scenePlus = scenePlusService.getByNum(num);
|
|
|
- ScenePlusExt scenePlusExt = scenePlusExtService.getByPlusId(scenePlus.getId());
|
|
|
- String title = scenePlus.getTitle();
|
|
|
- if("laser".equals(zipType)){
|
|
|
- Scene scene = sceneService.getBySceneCode(scenePlus.getNum());
|
|
|
- title = scene.getTitle();
|
|
|
- }
|
|
|
+ int index = 1;
|
|
|
+ for (String file : fileList) {
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("id", id);
|
|
|
- params.put("action", "save");
|
|
|
- params.put("fileName", num.concat(".zip"));
|
|
|
+ params.put("action", "upload");
|
|
|
+ params.put("fileName", file);
|
|
|
params.put("num", num);
|
|
|
params.put("title", title);
|
|
|
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());
|
|
|
- }catch (Exception e){
|
|
|
- log.error("场景推送失败,num:{}", num, e);
|
|
|
- push.setPushStatus(CommonSuccessStatus.FAIL.code());
|
|
|
+ params.put("file", FileUtil.file(zipDir.concat(file)));
|
|
|
+ log.info("开发发送第{}个压缩包", index);
|
|
|
+ String post = HttpUtil.post(scenePushBean.getDestUrl(), params, 60 * 60 * 1000);
|
|
|
+ log.info("第{}个场景推送成功,接收端返回结果:{}", index, post);
|
|
|
+ ++index;
|
|
|
}
|
|
|
|
|
|
- this.saveOrUpdate(push);
|
|
|
+ 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));
|
|
|
+ String post = HttpUtil.post(scenePushBean.getDestUrl(), params, 60 * 60 * 1000);
|
|
|
+ log.info("场景推送成功,接收端返回结果:{}", post);
|
|
|
}
|
|
|
|
|
|
public static void main(String[] args) throws Exception {
|