|
@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.deepoove.poi.XWPFTemplate;
|
|
|
import com.fdkankan.fusion.common.FilePath;
|
|
|
import com.fdkankan.fusion.common.ResultData;
|
|
|
+import com.fdkankan.fusion.common.util.DateUtils;
|
|
|
import com.fdkankan.fusion.common.util.ShellUtil;
|
|
|
import com.fdkankan.fusion.common.util.LocalToOssUtil;
|
|
|
import com.fdkankan.fusion.entity.*;
|
|
@@ -30,6 +31,7 @@ import org.springframework.stereotype.Service;
|
|
|
import java.io.File;
|
|
|
import java.io.FileOutputStream;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -131,7 +133,9 @@ public class CaseDownService {
|
|
|
return downVo;
|
|
|
}
|
|
|
@Async
|
|
|
- public void downOffline(Integer caseId){
|
|
|
+ public void downOffline(Integer caseId,String zipPath){
|
|
|
+ String timeKey = DateUtils.dateStr();
|
|
|
+ String caseOffPath = FilePath.OFFLINE_PACKAGE_PATH+timeKey + caseId;
|
|
|
try {
|
|
|
String redisKey = String.format(downProcessKey, caseId);
|
|
|
if( redisUtil.hasKey(redisKey)){
|
|
@@ -144,28 +148,27 @@ public class CaseDownService {
|
|
|
|
|
|
setRedisProcess(caseId,0);
|
|
|
//复制前端资源
|
|
|
- cpIndexHtml(caseId);
|
|
|
+ cpIndexHtml(caseId,caseOffPath);
|
|
|
setRedisProcess(caseId,10);
|
|
|
//创建data.json并下载资源
|
|
|
- createDataJson(caseId);
|
|
|
+ createDataJson(caseId,caseOffPath);
|
|
|
setRedisProcess(caseId,50);
|
|
|
//打包zip
|
|
|
- String path = "/mnt/fusion/offline";
|
|
|
- String name = "offline_"+ caseId;
|
|
|
- String zipName = path+File.separator+name+".zip";
|
|
|
- ShellUtil.zipOffline(zipName,name);
|
|
|
- setRedisProcess(caseId,70);
|
|
|
- //上传oss
|
|
|
- String ossUrl = zipName.replace("/mnt/", "");
|
|
|
- ShellUtil.yunUpload(zipName,ossUrl);
|
|
|
- Thread.sleep(2000L);
|
|
|
- FileUtil.del(zipName);
|
|
|
- ossUrl = queryPath + ossUrl;
|
|
|
- caseOfflineService.saveByCase(caseId,ossUrl);
|
|
|
- setRedisProcess(caseId,100,ossUrl);
|
|
|
+ FileUtil.copyContent(new File(caseOffPath),new File(zipPath),true);
|
|
|
+ caseOfflineService.saveByCase(caseId,zipPath);
|
|
|
+ setRedisProcess(caseId,100,zipPath);
|
|
|
+
|
|
|
}catch (Exception e){
|
|
|
log.info("down-offline-error:{}",caseId,e);
|
|
|
setRedisProcess(caseId,0,null,1003);
|
|
|
+ }finally {
|
|
|
+ try {
|
|
|
+ Thread.sleep(2000L);
|
|
|
+ FileUtil.del(caseOffPath);
|
|
|
+ setRedisProcess(caseId,0,null,1003);
|
|
|
+ }catch (Exception e){
|
|
|
+ log.info("down-offline-del-error:{}",caseId,e);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -197,8 +200,8 @@ public class CaseDownService {
|
|
|
return downVo;
|
|
|
}
|
|
|
|
|
|
- public void createDataJson(Integer caseId){
|
|
|
- log.info("down-offline-createDataJson:{}",caseId);
|
|
|
+ public void createDataJson(Integer caseId,String caseOffPath){
|
|
|
+ log.info("down-offline-createDataJson:{}",caseOffPath);
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
CaseParam param = new CaseParam();
|
|
|
param.setCaseId(caseId);
|
|
@@ -210,8 +213,8 @@ public class CaseDownService {
|
|
|
List<CaseSettings> caseSettings = caseSettingsService.getByCaseId(caseId);
|
|
|
jsonObject.put(basePath+caseSettingsInfo+caseId, ResultData.ok(caseSettings));
|
|
|
for (CaseSettings caseSetting : caseSettings) {
|
|
|
- downResource(caseId,caseSetting.getBack());
|
|
|
- downResource(caseId,caseSetting.getCover());
|
|
|
+ downResource(caseId,caseSetting.getBack(),caseOffPath);
|
|
|
+ downResource(caseId,caseSetting.getCover(),caseOffPath);
|
|
|
}
|
|
|
|
|
|
List<FusionNumVo> listByCaseId = fusionNumService.getListByCaseId(caseId,null);
|
|
@@ -224,7 +227,7 @@ public class CaseDownService {
|
|
|
for (SceneVo sceneData : sceneVos) {
|
|
|
//下载模型
|
|
|
if(StringUtils.isNotBlank(sceneData.getModelGlbUrl())){
|
|
|
- downModel(caseId,sceneData.getModelGlbUrl());
|
|
|
+ downModel(caseId,sceneData.getModelGlbUrl(),caseOffPath);
|
|
|
}
|
|
|
if(sceneData.getType() != 3){
|
|
|
//下载场景离线包
|
|
@@ -266,27 +269,27 @@ public class CaseDownService {
|
|
|
List<CaseView> caseViews = caseViewService.allList(caseId, null, null, null, null);
|
|
|
jsonObject.put(basePath+caseView+caseId, ResultData.ok(caseViews));
|
|
|
for (CaseView view : caseViews) {
|
|
|
- downResource(caseId,view.getViewImg());
|
|
|
- downResource(caseId,view.getViewImgSmall());
|
|
|
+ downResource(caseId,view.getViewImg(),caseOffPath);
|
|
|
+ downResource(caseId,view.getViewImgSmall(),caseOffPath);
|
|
|
}
|
|
|
|
|
|
List<CaseVideoFolder> videoFolders = caseVideoFolderService.getAllList(caseId);
|
|
|
jsonObject.put(basePath+caseVideoFolder+caseId, ResultData.ok(videoFolders));
|
|
|
for (CaseVideoFolder videoFolder : videoFolders) {
|
|
|
- downResource(caseId,videoFolder.getVideoFolderCover());
|
|
|
- downResource(caseId,videoFolder.getVideoMergeUrl());
|
|
|
+ downResource(caseId,videoFolder.getVideoFolderCover(),caseOffPath);
|
|
|
+ downResource(caseId,videoFolder.getVideoMergeUrl(),caseOffPath);
|
|
|
|
|
|
List<CaseVideo> allList = caseVideoService.getAllList(videoFolder.getVideoFolderId());
|
|
|
for (CaseVideo video : allList) {
|
|
|
- downResource(caseId,video.getVideoCover());
|
|
|
- downResource(caseId,video.getVideoPath());
|
|
|
+ downResource(caseId,video.getVideoCover(),caseOffPath);
|
|
|
+ downResource(caseId,video.getVideoPath(),caseOffPath);
|
|
|
}
|
|
|
jsonObject.put(basePath+caseVideo+videoFolder.getVideoFolderId(), ResultData.ok(allList));
|
|
|
}
|
|
|
|
|
|
List<CaseFiles> caseFilesList = caseFilesService.allList(caseId, null);
|
|
|
for (CaseFiles files : caseFilesList) {
|
|
|
- downResource(caseId,files.getFilesUrl());
|
|
|
+ downResource(caseId,files.getFilesUrl(),caseOffPath);
|
|
|
}
|
|
|
jsonObject.put(basePath+caseFiles+caseId, ResultData.ok(caseFilesList));
|
|
|
|
|
@@ -295,7 +298,7 @@ public class CaseDownService {
|
|
|
|
|
|
List<HotIcon> hotIconList = hotIconService.getListByCaseId(caseId);
|
|
|
for (HotIcon hotIcon : hotIconList) {
|
|
|
- downResource(caseId,hotIcon.getIconUrl());
|
|
|
+ downResource(caseId,hotIcon.getIconUrl(),caseOffPath);
|
|
|
}
|
|
|
jsonObject.put(basePath+hostIcon+caseId, ResultData.ok(hotIconList));
|
|
|
|
|
@@ -303,8 +306,8 @@ public class CaseDownService {
|
|
|
jsonObject.put(basePath+caseTag+caseId, ResultData.ok(caseTagList));
|
|
|
for (CaseTag tag : caseTagList) {
|
|
|
jsonObject.put(basePath+caseTagPoint+tag.getTagId(), ResultData.ok(caseTagPointService.allList(tag.getTagId())));
|
|
|
- downResources(caseId,tag.getTagImgUrl());
|
|
|
- downResource(caseId,tag.getHotIconUrl());
|
|
|
+ downResources(caseId,tag.getTagImgUrl(),caseOffPath);
|
|
|
+ downResource(caseId,tag.getHotIconUrl(),caseOffPath);
|
|
|
}
|
|
|
|
|
|
jsonObject.put(basePath+casePathInfoUrl+caseId, ResultData.ok(casePathService.getByCaseId(caseId)));
|
|
@@ -312,35 +315,35 @@ public class CaseDownService {
|
|
|
jsonObject.put(basePath+fusionGuide+caseId, ResultData.ok(fusionGuides));
|
|
|
|
|
|
for (FusionGuide guide : fusionGuides) {
|
|
|
- downResource(caseId,guide.getCover());
|
|
|
+ downResource(caseId,guide.getCover(),caseOffPath);
|
|
|
List<FusionGuidePath> listByGuideId = fusionGuidePathService.getListByGuideId(guide.getFusionGuideId());
|
|
|
for (FusionGuidePath guidePath : listByGuideId) {
|
|
|
- downResource(caseId,guidePath.getCover());
|
|
|
+ downResource(caseId,guidePath.getCover(),caseOffPath);
|
|
|
}
|
|
|
jsonObject.put(basePath+fusionGuidePath+guide.getFusionGuideId(), ResultData.ok(listByGuideId));
|
|
|
}
|
|
|
CaseInquest caseInquest1 = caseInquestService.getByCaseId(caseId);
|
|
|
if(caseInquest1 != null){
|
|
|
XWPFTemplate inquestTemp = caseInquestService.getWordByTemplate(caseInquest1);
|
|
|
- downWordByTemplate(caseId,inquestTemp,"caseInquest.doc");
|
|
|
+ downWordByTemplate(caseId,inquestTemp,"caseInquest.doc",caseOffPath);
|
|
|
}
|
|
|
jsonObject.put(basePath+caseInquest+caseId, ResultData.ok(caseInquest1));
|
|
|
|
|
|
CaseExtractDetail caseExtractDetail1 = caseExtractDetailService.getByCaseId(caseId);
|
|
|
if(caseExtractDetail1 != null){
|
|
|
XWPFTemplate detailTemp = caseExtractDetailService.getWordByTemplate(caseExtractDetail1);
|
|
|
- downWordByTemplate(caseId,detailTemp,"caseExtractDetail.doc");
|
|
|
+ downWordByTemplate(caseId,detailTemp,"caseExtractDetail.doc",caseOffPath);
|
|
|
}
|
|
|
jsonObject.put(basePath+caseExtractDetail+caseId, ResultData.ok(caseExtractDetail1));
|
|
|
|
|
|
List<CaseImg> caseImgList = caseImgService.getByCaseId(caseId, 1);
|
|
|
for (CaseImg img : caseImgList) {
|
|
|
- downResource(img.getCaseId(),img.getImgUrl());
|
|
|
+ downResource(img.getCaseId(),img.getImgUrl(),caseOffPath);
|
|
|
}
|
|
|
jsonObject.put(basePath+caseImg+caseId, ResultData.ok(caseImgList));
|
|
|
|
|
|
|
|
|
- FileUtil.writeString(JSON.toJSONString(jsonObject), FilePath.OFFLINE_PACKAGE_PATH+caseId+"/www/package/"+jsonDataName,"UTF-8");
|
|
|
+ FileUtil.writeString(JSON.toJSONString(jsonObject), caseOffPath+"/www/package/"+jsonDataName,"UTF-8");
|
|
|
|
|
|
}
|
|
|
|
|
@@ -350,15 +353,14 @@ public class CaseDownService {
|
|
|
//http://127.0.0.1:8080/offline.html?caseId=362&app=1&share=1#/show/summary
|
|
|
|
|
|
static String batName = "start-browser.bat";
|
|
|
- public void cpIndexHtml(Integer caseId){
|
|
|
- log.info("down-offline-cpIndexHtml:{}",caseId);
|
|
|
+ public void cpIndexHtml(Integer caseId,String caseOffPath){
|
|
|
+ log.info("down-offline-cpIndexHtml:{}",caseOffPath);
|
|
|
|
|
|
- String caseOfflinePath = FilePath.OFFLINE_PACKAGE_PATH+caseId;
|
|
|
- FileUtil.copyContent(new File(FilePath.OFFLINE_TEMPLATE_PATH),new File(caseOfflinePath),true);
|
|
|
+ FileUtil.copyContent(new File(FilePath.OFFLINE_TEMPLATE_PATH),new File(caseOffPath),true);
|
|
|
|
|
|
- String s = FileUtil.readString(caseOfflinePath + File.separator + batName, StandardCharsets.UTF_8);
|
|
|
+ String s = FileUtil.readString(caseOffPath + File.separator + batName, StandardCharsets.UTF_8);
|
|
|
String s1 = s.replaceAll("@caseId", String.valueOf(caseId));
|
|
|
- FileUtil.writeString(s1, caseOfflinePath + File.separator + batName,"UTF-8");
|
|
|
+ FileUtil.writeString(s1, caseOffPath + File.separator + batName,"UTF-8");
|
|
|
}
|
|
|
|
|
|
|
|
@@ -370,31 +372,16 @@ public class CaseDownService {
|
|
|
public void downSwkk(Integer caseId,String num,Integer type){
|
|
|
|
|
|
String swkkPath = FilePath.OFFLINE_PACKAGE_PATH+caseId + "/www/swkk/"+num;
|
|
|
- String swkkZipPath = swkkPath +".zip";
|
|
|
String swssPath = FilePath.OFFLINE_PACKAGE_PATH+caseId + "/www/swss/"+num;
|
|
|
- String swssZipPath = swssPath +".zip";
|
|
|
|
|
|
Integer isObj = 0;
|
|
|
if(type == 4 || type == 6){
|
|
|
isObj =1;
|
|
|
}
|
|
|
try {
|
|
|
+ FdkkResponse fdkkResponse = laserService.sceneLocInfo(num);
|
|
|
+
|
|
|
|
|
|
- DownVo downVo = downService.checkDownLoad(num, isObj,"offline");
|
|
|
- log.info("down:{}",downVo);
|
|
|
- if(downVo.getDownloadStatus() == 3 && StringUtils.isNotBlank(downVo.getDownloadUrl())){
|
|
|
- downZip(type,downVo.getDownloadUrl(),swkkZipPath,swkkPath,swssZipPath,swssPath);
|
|
|
- }else {
|
|
|
- DownVo down = downService.down(num, isObj,"offline");
|
|
|
- if(down.getDownloadStatus() == 1){
|
|
|
- DownloadProcessVo downloadProcessVo = downService.downloadProcess(num, isObj);
|
|
|
- while (downloadProcessVo.getStatus() != 1002 ){
|
|
|
- downloadProcessVo = downService.downloadProcess(num, isObj);
|
|
|
- Thread.sleep(2000L);
|
|
|
- }
|
|
|
- downZip(type,downloadProcessVo.getUrl(),swkkZipPath,swkkPath,swssZipPath,swssPath);
|
|
|
- }
|
|
|
- }
|
|
|
}catch (Exception e){
|
|
|
log.info("下载场景离线包失败:{}",num,e);
|
|
|
}
|
|
@@ -409,20 +396,9 @@ public class CaseDownService {
|
|
|
uri = uri.split("[?]")[0];
|
|
|
}
|
|
|
ShellUtil.yunDownload(uri.replace(queryPath, ""), kkzipPath);
|
|
|
-
|
|
|
ShellUtil.unZip(kkzipPath,kknumPath);
|
|
|
FileUtil.del(kkzipPath);
|
|
|
}else {
|
|
|
-// InputStream in = minIoUploadService.getObject(uri);
|
|
|
-// FileOutputStream out = new FileOutputStream(sszipPath);
|
|
|
-// byte[] buffer = new byte[1024];
|
|
|
-// int bytesRead;
|
|
|
-// while ((bytesRead = in.read(buffer)) != -1) {
|
|
|
-// out.write(buffer, 0, bytesRead);
|
|
|
-// }
|
|
|
-// out.flush();
|
|
|
-// out.close();
|
|
|
-// in.close();
|
|
|
ShellUtil.yunDownloadSs(uri.replace(queryPath, ""), sszipPath);
|
|
|
ShellUtil.unZip(sszipPath,ssNumPath);
|
|
|
FileUtil.del(sszipPath);
|
|
@@ -432,8 +408,8 @@ public class CaseDownService {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- public void downModel(Integer caseId, String modelGlbUrl) {
|
|
|
- String path = String.format(FilePath.OFFLINE_OSS_PATH,caseId);
|
|
|
+ public void downModel(Integer caseId, String modelGlbUrl,String offPath) {
|
|
|
+ String path = offPath +FilePath.OFFLINE_OSS_PATH;
|
|
|
|
|
|
JSONArray jsonArray = JSONArray.parseArray(modelGlbUrl);
|
|
|
for (Object object : jsonArray) {
|
|
@@ -443,25 +419,20 @@ public class CaseDownService {
|
|
|
if(res.contains(".json") || res.contains(".shp")){
|
|
|
res = new File(res).getParentFile().getPath();
|
|
|
}
|
|
|
- ShellUtil.yunDownload(res, path +queryPath + res);
|
|
|
+ localToOssUtil.downFormAli(res,path+queryPath+res);
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
- public void downResources(Integer caseId,String urls) {
|
|
|
+ public void downResources(Integer caseId,String urls,String offPath) {
|
|
|
|
|
|
JSONArray jsonArray = JSONArray.parseArray(urls);
|
|
|
for (Object object : jsonArray) {
|
|
|
String res = (String) object;
|
|
|
- downResource(caseId,res);
|
|
|
- }
|
|
|
- }
|
|
|
- public void downResources(Integer caseId,JSONArray urls) {
|
|
|
- for (Object object : urls) {
|
|
|
- String res = (String) object;
|
|
|
- downResource(caseId,res);
|
|
|
+ downResource(caseId,res,offPath);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void downResource(Integer caseId,String url) {
|
|
|
+ public void downResource(Integer caseId,String url,String offPath) {
|
|
|
if(StringUtils.isBlank(url) ){
|
|
|
return;
|
|
|
}
|
|
@@ -470,13 +441,13 @@ public class CaseDownService {
|
|
|
log.info("downResource文件不存在:{},{}",caseId,url);
|
|
|
return;
|
|
|
}
|
|
|
- String path = String.format(FilePath.OFFLINE_OSS_PATH,caseId);
|
|
|
- ShellUtil.yunDownload(url,path+queryPath+url);
|
|
|
+ String path = offPath + FilePath.OFFLINE_OSS_PATH;
|
|
|
+ localToOssUtil.downFormAli(url,path+queryPath+url);
|
|
|
}
|
|
|
|
|
|
- public void downWordByTemplate(Integer caseId,XWPFTemplate template,String name){
|
|
|
+ public void downWordByTemplate(Integer caseId,XWPFTemplate template,String name,String offPath){
|
|
|
// 指定输出文件的路径
|
|
|
- String outputPath = String.format(FilePath.OFFLINE_RESOURCE_PACKAGE_PATH,caseId) + name;
|
|
|
+ String outputPath = offPath +FilePath.OFFLINE_RESOURCE_PACKAGE_PATH + name;
|
|
|
try {
|
|
|
FileOutputStream out = new FileOutputStream(outputPath);
|
|
|
template.write(out);
|