|
|
@@ -6,10 +6,13 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.deepoove.poi.XWPFTemplate;
|
|
|
import com.fdkankan.fusion.common.FilePath;
|
|
|
+import com.fdkankan.fusion.common.ResultCode;
|
|
|
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.UploadToOssUtil;
|
|
|
import com.fdkankan.fusion.entity.*;
|
|
|
+import com.fdkankan.fusion.exception.BusinessException;
|
|
|
import com.fdkankan.fusion.httpClient.LaserService;
|
|
|
import com.fdkankan.fusion.httpClient.response.FdkkResponse;
|
|
|
import com.fdkankan.fusion.request.CaseParam;
|
|
|
@@ -94,6 +97,8 @@ public class CaseDownService {
|
|
|
|
|
|
@Async
|
|
|
public void downOffline(Integer caseId){
|
|
|
+ String caseOffPath = null;
|
|
|
+ String zipName = null;
|
|
|
try {
|
|
|
String redisKey = String.format(downProcessKey, caseId);
|
|
|
if( redisUtil.hasKey(redisKey)){
|
|
|
@@ -103,33 +108,44 @@ public class CaseDownService {
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
+ String timeKey = DateUtils.dateStr();
|
|
|
+ caseOffPath =FilePath.OFFLINE_PACKAGE_PATH_CASE+timeKey+caseId ;
|
|
|
|
|
|
setRedisProcess(caseId,0);
|
|
|
//复制前端资源
|
|
|
- cpIndexHtml(caseId);
|
|
|
+ cpIndexHtml(caseId,caseOffPath);
|
|
|
setRedisProcess(caseId,10);
|
|
|
//创建data.json并下载资源
|
|
|
- createDataJson(caseId);
|
|
|
+ createDataJson(caseId,caseOffPath+"/env/www");
|
|
|
setRedisProcess(caseId,50);
|
|
|
//打包zip
|
|
|
- String path = "/mnt/fusion/offline";
|
|
|
- String name = "offline_"+ caseId;
|
|
|
- String zipName = path+File.separator+name+".zip";
|
|
|
- ShellUtil.zip(zipName,name);
|
|
|
+ zipName = caseOffPath+".zip";
|
|
|
+ ShellUtil.zip(zipName,caseOffPath);
|
|
|
setRedisProcess(caseId,70);
|
|
|
//上传oss
|
|
|
String ossUrl = zipName.replace("/mnt/", "");
|
|
|
ShellUtil.yunUpload(zipName,ossUrl);
|
|
|
- Thread.sleep(2000L);
|
|
|
- FileUtil.del(zipName);
|
|
|
+
|
|
|
ossUrl = queryPath + ossUrl;
|
|
|
setRedisProcess(caseId,100,ossUrl);
|
|
|
}catch (Exception e){
|
|
|
- log.info("down-offline-error:{}",caseId,e);
|
|
|
setRedisProcess(caseId,0,null,1003);
|
|
|
+ log.info("down-offline-error:{}",caseId,e);
|
|
|
+ }finally {
|
|
|
+ delFile(caseOffPath);
|
|
|
+ delFile(zipName);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+ private void delFile(String path){
|
|
|
+ if(StringUtils.isNotBlank(path)){
|
|
|
+ try {
|
|
|
+ FileUtil.del(path);
|
|
|
+ }catch (Exception e){
|
|
|
+ log.info("删除文件失败:{}",path);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
public void setRedisProcess(Integer caseId,Integer num){
|
|
|
setRedisProcess(caseId,num,null,1000);
|
|
|
@@ -158,17 +174,16 @@ public class CaseDownService {
|
|
|
return downVo;
|
|
|
}
|
|
|
|
|
|
- public void createDataJson(Integer caseId){
|
|
|
+ public void createDataJson(Integer caseId,String casePath){
|
|
|
log.info("down-offline-createDataJson:{}",caseId);
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
|
//设置案件信息
|
|
|
- jsonObject.put(basePath+caseInfoUrl+caseId, ResultData.ok(caseService.getInfo(caseId)));
|
|
|
+ jsonObject.put(basePath+caseInfoUrl+caseId, ResultData.ok(caseService.getInfo(caseId,false)));
|
|
|
List<CaseFilesTypeTreeVo> byTree = caseFilesTypeService.getByTree(caseId);
|
|
|
for (CaseFilesTypeTreeVo caseFilesTypeTreeVo : byTree) {
|
|
|
- downTreeResource(caseId,caseFilesTypeTreeVo);
|
|
|
+ downTreeResource(caseFilesTypeTreeVo,casePath,jsonObject);
|
|
|
}
|
|
|
-
|
|
|
jsonObject.put(basePath+caseFilesTypeTreeUrl+caseId, ResultData.ok(byTree));
|
|
|
|
|
|
CaseParam param = new CaseParam();
|
|
|
@@ -176,14 +191,14 @@ public class CaseDownService {
|
|
|
jsonObject.put(basePath+sceneListUrl+caseId, ResultData.ok(caseService.sceneList(param)));
|
|
|
jsonObject.put(basePath+caseInquestInfoUrl+caseId, ResultData.ok(caseInquestInfoService.getByCaseId(caseId)));
|
|
|
|
|
|
- List<FusionAndSceneVo> sceneList = caseService.getFusionAndScene(caseId, "scene");
|
|
|
+ List<FusionAndSceneVo> sceneList = caseService.getFusionAndScene(caseId, "scene",false);
|
|
|
jsonObject.put(basePath+String.format(fusionAndSceneTypeSceneUrl,caseId), ResultData.ok(sceneList));
|
|
|
- List<FusionAndSceneVo> fusionList = caseService.getFusionAndScene(caseId, "fusion");
|
|
|
+ List<FusionAndSceneVo> fusionList = caseService.getFusionAndScene(caseId, "fusion",false);
|
|
|
jsonObject.put(basePath+String.format(fusionAndSceneTypeFusionUrl,caseId), ResultData.ok(fusionList));
|
|
|
|
|
|
for (FusionAndSceneVo fusionAndSceneVo : sceneList) {
|
|
|
//下载场景
|
|
|
- downSwkk(caseId,fusionAndSceneVo.getNum(),fusionAndSceneVo.getSceneType());
|
|
|
+ downSwkk(casePath,fusionAndSceneVo.getNum(),fusionAndSceneVo.getSceneType());
|
|
|
if(fusionAndSceneVo.getSceneType() == 2 || fusionAndSceneVo.getSceneType() == 5){
|
|
|
FdkkResponse sceneInfo = laserService.getSceneInfo(fusionAndSceneVo.getNum());
|
|
|
HashSet<String> dataSetIds = new HashSet<>();
|
|
|
@@ -217,64 +232,47 @@ public class CaseDownService {
|
|
|
}
|
|
|
}
|
|
|
for (FusionAndSceneVo fusionAndSceneVo : fusionList) {
|
|
|
- downFusion(caseId,fusionAndSceneVo.getFusionId());
|
|
|
+ downFusion(casePath,fusionAndSceneVo.getFusionId());
|
|
|
}
|
|
|
|
|
|
String jsonString = JSON.toJSONString(jsonObject);
|
|
|
- FileUtil.writeString(jsonString, FilePath.OFFLINE_PACKAGE_PATH_CASE+caseId+"/env/www/package/"+jsonDataName,"UTF-8");
|
|
|
+ FileUtil.writeString(jsonString, casePath+"/package/"+jsonDataName,"UTF-8");
|
|
|
|
|
|
}
|
|
|
|
|
|
- private void downTreeResource(Integer caseId,CaseFilesTypeTreeVo caseFilesTypeTreeVo) {
|
|
|
+ private void downTreeResource(CaseFilesTypeTreeVo caseFilesTypeTreeVo,String casePath,JSONObject jsonObject) {
|
|
|
if(caseFilesTypeTreeVo.getCaseFilesList() != null && !caseFilesTypeTreeVo.getCaseFilesList().isEmpty()){
|
|
|
for (CaseFiles caseFiles : caseFilesTypeTreeVo.getCaseFilesList()) {
|
|
|
- downResource(caseId,caseFiles.getFilesUrl());
|
|
|
+ downResource(caseFiles.getFilesUrl(),casePath);
|
|
|
}
|
|
|
if(caseFilesTypeTreeVo.getChildrenList() != null && !caseFilesTypeTreeVo.getChildrenList().isEmpty()){
|
|
|
List<CaseFilesTypeTreeVo> childrenList = caseFilesTypeTreeVo.getChildrenList();
|
|
|
for (CaseFilesTypeTreeVo filesTypeTreeVo : childrenList) {
|
|
|
- downTreeResource(caseId,filesTypeTreeVo);
|
|
|
+ downTreeResource(filesTypeTreeVo,casePath,jsonObject);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void downFusion(Integer caseId,Integer fusionId) {
|
|
|
- String path = FilePath.OFFLINE_PACKAGE_PATH_CASE+caseId + "/env/www/fusionOffline/"+fusionId;
|
|
|
- String zipPath = path +".zip";
|
|
|
- try {
|
|
|
- fusionDownService.downOffline(fusionId);
|
|
|
- DownloadProcessVo downloadProcessVo = fusionDownService.process(fusionId);
|
|
|
- while (downloadProcessVo.getStatus() != 1002 ){
|
|
|
- downloadProcessVo = fusionDownService.process(fusionId);
|
|
|
- Thread.sleep(2000L);
|
|
|
- }
|
|
|
- ShellUtil.yunDownload(downloadProcessVo.getUrl().replace(queryPath, ""), path);
|
|
|
- ShellUtil.unZip(zipPath,path);
|
|
|
- FileUtil.del(zipPath);
|
|
|
- }catch (Exception e){
|
|
|
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
|
|
|
//http://127.0.0.1:8080/offline.html?caseId=362&app=1&share=1#/show/summary
|
|
|
|
|
|
static String batName = "start-browser.bat";
|
|
|
static String batName2 = "信创环境启动(打开后选在终端运行).sh";
|
|
|
- public void cpIndexHtml(Integer caseId){
|
|
|
+ public void cpIndexHtml(Integer caseId,String casePath){
|
|
|
log.info("down-offline-cpIndexHtml:{}",caseId);
|
|
|
|
|
|
- String caseOfflinePath = FilePath.OFFLINE_PACKAGE_PATH_CASE+caseId;
|
|
|
- FileUtil.copyContent(new File(FilePath.OFFLINE_TEMPLATE_PATH_CASE),new File(caseOfflinePath),true);
|
|
|
+ FileUtil.copyContent(new File(FilePath.OFFLINE_TEMPLATE_PATH_CASE),new File(casePath),true);
|
|
|
|
|
|
- String s = FileUtil.readString(caseOfflinePath + File.separator + batName, StandardCharsets.UTF_8);
|
|
|
+ String s = FileUtil.readString(casePath + File.separator + batName, StandardCharsets.UTF_8);
|
|
|
s = s.replaceAll("@caseId", String.valueOf(caseId));
|
|
|
- FileUtil.writeString(s, caseOfflinePath + File.separator + batName,"UTF-8");
|
|
|
+ FileUtil.writeString(s, casePath + File.separator + batName,"UTF-8");
|
|
|
|
|
|
- String s1 = FileUtil.readString(caseOfflinePath + File.separator + batName2, StandardCharsets.UTF_8);
|
|
|
+ String s1 = FileUtil.readString(casePath + File.separator + batName2, StandardCharsets.UTF_8);
|
|
|
s1 = s1.replaceAll("@caseId", String.valueOf(caseId));
|
|
|
- FileUtil.writeString(s1, caseOfflinePath + File.separator + batName2,"UTF-8");
|
|
|
+ FileUtil.writeString(s1, casePath + File.separator + batName2,"UTF-8");
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -284,11 +282,22 @@ public class CaseDownService {
|
|
|
@Autowired
|
|
|
UploadToOssUtil uploadToOssUtil;
|
|
|
|
|
|
- public void downSwkk(Integer caseId,String num,Integer type){
|
|
|
+ private void downFusion(String casePath,Integer fusionId) {
|
|
|
+ String path = casePath +"/fusionOffline/"+fusionId;
|
|
|
+ try {
|
|
|
+ log.info("下载多元融合:{},{}",casePath,fusionId);
|
|
|
+ fusionDownService.downOffline(fusionId,path,null);
|
|
|
+ }catch (Exception e){
|
|
|
+ log.info("下载多元融合失败:{}",fusionId,e);
|
|
|
+ throw new BusinessException(ResultCode.FUSION_DOWN_ERROR);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void downSwkk(String path,String num,Integer type){
|
|
|
|
|
|
- String swkkPath = FilePath.OFFLINE_PACKAGE_PATH_CASE+caseId + "/env/www/swkk/"+num;
|
|
|
+ String swkkPath = path + "/swkk/"+num;
|
|
|
String swkkZipPath = swkkPath +".zip";
|
|
|
- String swssPath = FilePath.OFFLINE_PACKAGE_PATH_CASE+caseId + "/env/www/swss/"+num;
|
|
|
+ String swssPath = path + "/swss/"+num;
|
|
|
String swssZipPath = swssPath +".zip";
|
|
|
|
|
|
Integer isObj = 0;
|
|
|
@@ -305,15 +314,19 @@ public class CaseDownService {
|
|
|
DownVo down = downService.down(num, isObj,"offline");
|
|
|
if(down.getDownloadStatus() == 1){
|
|
|
DownloadProcessVo downloadProcessVo = downService.downloadProcess(num, isObj);
|
|
|
- while (downloadProcessVo.getStatus() != 1002 ){
|
|
|
+ while (downloadProcessVo.getStatus() == 1000 || downloadProcessVo.getStatus() == 1001 ){
|
|
|
downloadProcessVo = downService.downloadProcess(num, isObj);
|
|
|
Thread.sleep(2000L);
|
|
|
}
|
|
|
+ if(downloadProcessVo.getStatus() == 1003 && StringUtils.isBlank(downVo.getDownloadUrl())){
|
|
|
+ throw new BusinessException(ResultCode.SS_SCENE_DOWN_ERROR);
|
|
|
+ }
|
|
|
downZip(type,downloadProcessVo.getUrl(),swkkZipPath,swkkPath,swssZipPath,swssPath);
|
|
|
}
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
log.info("下载场景离线包失败:{}",num,e);
|
|
|
+ throw new BusinessException(ResultCode.SS_SCENE_DOWN_ERROR);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -326,73 +339,34 @@ public class CaseDownService {
|
|
|
uri = uri.split("[?]")[0];
|
|
|
}
|
|
|
ShellUtil.yunDownload(uri.replace(queryPath, ""), kkzipPath);
|
|
|
-
|
|
|
ShellUtil.unZip(kkzipPath,kknumPath);
|
|
|
FileUtil.del(kkzipPath);
|
|
|
+
|
|
|
}else {
|
|
|
ShellUtil.yunDownloadSs(uri.replace(queryPath, ""), sszipPath);
|
|
|
ShellUtil.unZip(sszipPath,ssNumPath);
|
|
|
FileUtil.del(sszipPath);
|
|
|
+
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
log.info("下载场景离线包失败:{}",uri,e);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- public void downModel(Integer caseId, String modelGlbUrl) {
|
|
|
- String path = String.format(FilePath.OFFLINE_OSS_PATH,caseId);
|
|
|
-
|
|
|
- JSONArray jsonArray = JSONArray.parseArray(modelGlbUrl);
|
|
|
- for (Object object : jsonArray) {
|
|
|
- String res = (String) object;
|
|
|
- log.info("下载模型:{}",res);
|
|
|
- res = res.replace(queryPath, "");
|
|
|
- if(res.contains(".json") ){
|
|
|
- res = new File(res).getParentFile().getPath();
|
|
|
- }
|
|
|
- ShellUtil.yunDownload(res, path +queryPath + res);
|
|
|
- }
|
|
|
- }
|
|
|
- public void downResources(Integer caseId,String urls) {
|
|
|
|
|
|
- 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);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public void downResource(Integer caseId,String url) {
|
|
|
+ public void downResource(String url,String path) {
|
|
|
+ log.info("下载文件:{},{}",url,path);
|
|
|
if(StringUtils.isBlank(url) ){
|
|
|
return;
|
|
|
}
|
|
|
url = url.replace(queryPath, "");
|
|
|
if( !uploadToOssUtil.existKey(url)){
|
|
|
- log.info("downResource文件不存在:{},{}",caseId,url);
|
|
|
+ log.info("downResource文件不存在:{},{}",url,path);
|
|
|
return;
|
|
|
}
|
|
|
- String path = String.format(FilePath.OFFLINE_OSS_PATH,caseId);
|
|
|
ShellUtil.yunDownload(url,path+queryPath+url);
|
|
|
}
|
|
|
|
|
|
- public void downWordByTemplate(Integer caseId,XWPFTemplate template,String name){
|
|
|
- // 指定输出文件的路径
|
|
|
- String outputPath = String.format(FilePath.OFFLINE_RESOURCE_PACKAGE_PATH,caseId) + name;
|
|
|
- try {
|
|
|
- FileOutputStream out = new FileOutputStream(outputPath);
|
|
|
- template.write(out);
|
|
|
- out.close();
|
|
|
- log.info("文档已成功写入到: " + outputPath);
|
|
|
- } catch (Exception e) {
|
|
|
- log.info("写出文档失败:{},{}",caseId,name,e);
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
|
|
|
|