|
@@ -0,0 +1,507 @@
|
|
|
+package com.fdkankan.fusion.down;
|
|
|
+
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
+import cn.hutool.core.io.IORuntimeException;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+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.LocalToOssUtil;
|
|
|
+import com.fdkankan.fusion.common.util.ShellUtil;
|
|
|
+import com.fdkankan.fusion.config.CacheUtil;
|
|
|
+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;
|
|
|
+import com.fdkankan.fusion.response.DownVo;
|
|
|
+import com.fdkankan.fusion.response.DownloadProcessVo;
|
|
|
+import com.fdkankan.fusion.response.FusionNumVo;
|
|
|
+import com.fdkankan.fusion.response.SceneVo;
|
|
|
+import com.fdkankan.fusion.service.*;
|
|
|
+import com.fdkankan.fusion.service.impl.DownService;
|
|
|
+import com.fdkankan.redis.util.RedisUtil;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileOutputStream;
|
|
|
+import java.io.IOException;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashSet;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@Service
|
|
|
+@Slf4j
|
|
|
+public class FusionDownService {
|
|
|
+
|
|
|
+ @Value("${server.servlet.context-path}")
|
|
|
+ String basePath;
|
|
|
+
|
|
|
+ public static String jsonDataName = "data.json";
|
|
|
+ public static String caseFusionInfo = "/caseFusion/info?fusionId=";
|
|
|
+ public static String mapConfig = "/notAuth/getMapConfig";
|
|
|
+ public static String caseSettingsInfo = "/caseSettings/info?fusionId=";
|
|
|
+ public static String hostIcon = "/edit/hotIcon/list?fusionId=";
|
|
|
+ public static String hostIconTreeList = "/edit/hotIcon/treeList?fusionId=";
|
|
|
+ public static String caseTag = "/caseTag/allList?fusionId=";
|
|
|
+ public static String caseTagPoint = "/caseTagPoint/allList?tagId=";
|
|
|
+ public static String fusionGuide = "/fusionGuide/allList?fusionId=";
|
|
|
+ public static String fusionGuidePath = "/fusionGuidePath/allList?guideId=";
|
|
|
+ public static String fusionMeter = "/fusionMeter/allList?fusionId=";
|
|
|
+ public static String casePathInfoUrl = "/casePath/info?fusionId=";
|
|
|
+ public static String caseAnimationUrl = "/caseAnimation/list?fusionId=";
|
|
|
+ public static String laserData = "/laser/dataset/%s/getDataSet";
|
|
|
+ public static String laserDataSetAndControlPoint = "/laser/4dage/%s/getDataSetAndControlPoint";
|
|
|
+ public static String laserDataQuery = "/laser/filter/%s/query?datasetId=%s";
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ICaseSettingsService caseSettingsService;
|
|
|
+ @Autowired
|
|
|
+ IFusionNumService fusionNumService;
|
|
|
+ @Autowired
|
|
|
+ ICaseViewService caseViewService;
|
|
|
+ @Autowired
|
|
|
+ ICaseVideoFolderService caseVideoFolderService;
|
|
|
+ @Autowired
|
|
|
+ ICaseVideoService caseVideoService;
|
|
|
+ @Autowired
|
|
|
+ ICaseFilesService caseFilesService;
|
|
|
+ @Autowired
|
|
|
+ ICaseFilesTypeService caseFilesTypeService;
|
|
|
+ @Autowired
|
|
|
+ IHotIconService hotIconService;
|
|
|
+ @Autowired
|
|
|
+ ICaseTagService caseTagService;
|
|
|
+ @Autowired
|
|
|
+ ICaseTagPointService caseTagPointService;
|
|
|
+ @Autowired
|
|
|
+ IFusionGuideService fusionGuideService;
|
|
|
+ @Autowired
|
|
|
+ IFusionGuidePathService fusionGuidePathService;
|
|
|
+ @Autowired
|
|
|
+ ICaseInquestService caseInquestService;
|
|
|
+ @Autowired
|
|
|
+ ICaseExtractDetailService caseExtractDetailService;
|
|
|
+ @Autowired
|
|
|
+ IFusionMeterService fusionMeterService;
|
|
|
+ @Autowired
|
|
|
+ IModelService modelService;
|
|
|
+ @Autowired
|
|
|
+ LaserService laserService;
|
|
|
+ @Autowired
|
|
|
+ ICaseOfflineService caseOfflineService;
|
|
|
+ @Autowired
|
|
|
+ ICaseImgService caseImgService;
|
|
|
+ @Autowired
|
|
|
+ ICaseInquestInfoService caseInquestInfoService;
|
|
|
+ @Autowired
|
|
|
+ ICasePathService casePathService;
|
|
|
+ @Autowired
|
|
|
+ ICaseFusionService caseFusionService;
|
|
|
+ @Autowired
|
|
|
+ ICaseAnimationService caseAnimationService;
|
|
|
+ @Autowired
|
|
|
+ IMapConfigService mapConfigService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ RedisUtil redisUtil;
|
|
|
+ public static String downProcessKey = "fusion:down:offline:process:fusionId:%s";
|
|
|
+ public static String downProcessKey2 = "fusion:down:process:fusionId:%s";
|
|
|
+
|
|
|
+ public static final String BUILD_SCENE_OFFLINE_FUSION = "BUILD:SCENE:OFFLINE:FUSION";
|
|
|
+
|
|
|
+ public DownVo checkDown(Integer caseId) {
|
|
|
+ DownVo downVo = new DownVo();
|
|
|
+// CaseOffline byCaseId = caseOfflineService.getByCaseId(caseId);
|
|
|
+// if(byCaseId != null){
|
|
|
+// downVo.setDownloadStatus(3);
|
|
|
+// downVo.setDownloadUrl(byCaseId.getOfflineUrl());
|
|
|
+// }
|
|
|
+ return downVo;
|
|
|
+ }
|
|
|
+ @Async
|
|
|
+ public void downOffline(Integer fusionId,String zipPath){
|
|
|
+ String caseOffPath = null;
|
|
|
+ redisUtil.set(BUILD_SCENE_OFFLINE_FUSION,fusionId+"",60 * 60 * 24);
|
|
|
+ try {
|
|
|
+ String redisKey = String.format(downProcessKey, fusionId);
|
|
|
+ if( redisUtil.hasKey(redisKey)){
|
|
|
+ String res = redisUtil.get(redisKey);
|
|
|
+ DownloadProcessVo downloadProcessVo = JSONObject.parseObject(res, DownloadProcessVo.class);
|
|
|
+ if(downloadProcessVo.getStatus() ==1000 && (downloadProcessVo.getPercent()== null || downloadProcessVo.getPercent() != 100)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String timeKey = DateUtils.dateStr();
|
|
|
+ caseOffPath = zipPath+"offline_"+fusionId+"_"+timeKey ;
|
|
|
+ caseFusionService.updateOfflineStatus(fusionId,1,zipPath);
|
|
|
+
|
|
|
+ setRedisProcess(fusionId,0);
|
|
|
+ //复制前端资源
|
|
|
+ cpIndexHtml(fusionId,caseOffPath);
|
|
|
+ setRedisProcess(fusionId,10);
|
|
|
+ //创建data.json并下载资源
|
|
|
+ createDataJson(fusionId,caseOffPath);
|
|
|
+ //打包zip
|
|
|
+ //caseOfflineService.saveByCase(caseId,caseOffPath);
|
|
|
+ setRedisProcess(fusionId,100,caseOffPath);
|
|
|
+ caseFusionService.updateOfflineStatus(fusionId,2,caseOffPath);
|
|
|
+ }catch (IOException e){
|
|
|
+ log.info("down-offline-IOException:{}",fusionId,e);
|
|
|
+ setRedisProcess(fusionId,0,null,1004);
|
|
|
+ caseFusionService.updateOfflineStatus(fusionId,1004,caseOffPath);
|
|
|
+ }catch (IORuntimeException e){
|
|
|
+ log.info("down-offline-IORuntimeException:{}",fusionId,e);
|
|
|
+ setRedisProcess(fusionId,0,null,1004);
|
|
|
+ caseFusionService.updateOfflineStatus(fusionId,1004,caseOffPath);
|
|
|
+ }catch (Exception e){
|
|
|
+ log.info("down-offline-Exception:{}",fusionId,e);
|
|
|
+ setRedisProcess(fusionId,0,null,1003);
|
|
|
+ caseFusionService.updateOfflineStatus(fusionId,1003,caseOffPath);
|
|
|
+ }finally {
|
|
|
+ redisUtil.del(BUILD_SCENE_OFFLINE_FUSION);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setRedisProcess(Integer caseId,Integer num){
|
|
|
+ setRedisProcess(caseId,num,null,1000);
|
|
|
+ if(num ==0){
|
|
|
+ String redisKey2 = String.format(downProcessKey2, caseId);
|
|
|
+ redisUtil.set(redisKey2,"1",60);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setRedisProcess(Integer caseId,Integer num,String url){
|
|
|
+ setRedisProcess(caseId,num,url,1000);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setRedisProcess(Integer caseId,Integer num,String url,Integer status){
|
|
|
+ String redisKey = String.format(downProcessKey, caseId);
|
|
|
+ log.info("down-offline-process:{},{},{}",caseId,num,url);
|
|
|
+ DownloadProcessVo processVo = new DownloadProcessVo();
|
|
|
+ processVo.setStatus(status);
|
|
|
+ processVo.setPercent(num);
|
|
|
+ processVo.setUrl( url);
|
|
|
+ processVo.setCaseId( caseId);
|
|
|
+ redisUtil.set(redisKey,JSONObject.toJSONString(processVo),60 * 60 * 24);
|
|
|
+ }
|
|
|
+
|
|
|
+ public DownloadProcessVo process(Integer caseId) {
|
|
|
+ DownloadProcessVo downVo = new DownloadProcessVo();
|
|
|
+ String redisKey = String.format(downProcessKey, caseId);
|
|
|
+ String redisKey2 = String.format(downProcessKey2, caseId);
|
|
|
+
|
|
|
+ if(redisUtil.hasKey(redisKey)){
|
|
|
+ DownloadProcessVo downloadProcessVo = JSONObject.parseObject(redisUtil.get(redisKey), DownloadProcessVo.class);
|
|
|
+ if(redisUtil.hasKey(redisKey2)){
|
|
|
+ redisUtil.set(redisKey2,String.valueOf(Integer.parseInt(redisUtil.get(redisKey2)) + 1),60);
|
|
|
+ }else {
|
|
|
+ redisUtil.set(redisKey2,"1",60);
|
|
|
+ }
|
|
|
+ if(downloadProcessVo.getPercent() == 100){
|
|
|
+ downloadProcessVo.setPercent(100);
|
|
|
+ }else{
|
|
|
+ Integer percent = Integer.parseInt(redisUtil.get(redisKey2)) <100 ? Integer.parseInt(redisUtil.get(redisKey2)) : 99;
|
|
|
+ downloadProcessVo.setPercent(percent);
|
|
|
+ }
|
|
|
+ return downloadProcessVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ return downVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void createDataJson(Integer fusionId,String caseOffPath){
|
|
|
+ log.info("down-offline-createDataJson:{}",caseOffPath);
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ CaseFusion caseFusion = caseFusionService.getById(fusionId);
|
|
|
+ jsonObject.put(basePath+caseFusionInfo+fusionId, ResultData.ok(caseFusion));
|
|
|
+
|
|
|
+ List<MapConfig> list = mapConfigService.list();
|
|
|
+ jsonObject.put(basePath+mapConfig, ResultData.ok(list));
|
|
|
+
|
|
|
+
|
|
|
+ List<CaseSettings> caseSettings = caseSettingsService.getByFusionId(fusionId);
|
|
|
+ jsonObject.put(basePath+caseSettingsInfo+fusionId, ResultData.ok(caseSettings));
|
|
|
+ for (CaseSettings caseSetting : caseSettings) {
|
|
|
+ downResource(caseSetting.getBack(),caseOffPath);
|
|
|
+ downResource(caseSetting.getCover(),caseOffPath);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ jsonObject.put(basePath+fusionMeter+fusionId, ResultData.ok(fusionMeterService.getListByFusionId(fusionId,null)));
|
|
|
+
|
|
|
+ List<FusionNumVo> fusionNumVos = caseFusionService.getSceneListVo(fusionId);
|
|
|
+ for (FusionNumVo fusionNumVo : fusionNumVos) {
|
|
|
+ SceneVo sceneData = fusionNumVo.getSceneData();
|
|
|
+ //下载模型
|
|
|
+ if(StringUtils.isNotBlank(sceneData.getModelGlbUrl())){
|
|
|
+ downModel(sceneData.getModelGlbUrl(),caseOffPath);
|
|
|
+ }
|
|
|
+ if(sceneData.getType() != 3){
|
|
|
+ //下载场景离线包
|
|
|
+ downSwkk(sceneData.getNum(),sceneData.getType(),caseOffPath);
|
|
|
+ }
|
|
|
+ if(sceneData.getType() == 2 || sceneData.getType() == 5){
|
|
|
+ FdkkResponse sceneInfo = laserService.getSceneInfo(sceneData.getNum());
|
|
|
+ HashSet<String> dataSetIds = new HashSet<>();
|
|
|
+ if(sceneInfo != null){
|
|
|
+ JSONArray jsonArray = JSONArray.parseArray(JSONArray.toJSONString(sceneInfo.getData()));
|
|
|
+ JSONArray newJsonArray = new JSONArray();
|
|
|
+ for (Object object : jsonArray) {
|
|
|
+ JSONObject sceneInfoObj = (JSONObject) object;
|
|
|
+ String newPath = String.format(FilePath.OFFLINE_LASER_OSS_PATH, sceneData.getNum(), sceneData.getNum());
|
|
|
+ String mapping = sceneInfoObj.getString("mapping");
|
|
|
+ String oldPath = sceneInfoObj.getString("webBin");
|
|
|
+ String webBin = null;
|
|
|
+ if(StringUtils.isNotBlank(mapping)){
|
|
|
+ webBin =newPath + mapping+ File.separator+ oldPath;
|
|
|
+ }else {
|
|
|
+ webBin = newPath+ oldPath;
|
|
|
+ }
|
|
|
+ sceneInfoObj.put("oldWebBin",oldPath);
|
|
|
+ sceneInfoObj.put("webBin",webBin);
|
|
|
+ newJsonArray.add(sceneInfoObj);
|
|
|
+ dataSetIds.add( sceneInfoObj.getString("id"));
|
|
|
+ }
|
|
|
+ sceneInfo.setData(newJsonArray);
|
|
|
+ jsonObject.put(String.format(laserData,sceneData.getNum()),sceneInfo);
|
|
|
+ if(!dataSetIds.isEmpty()){
|
|
|
+ for (String dataSetId : dataSetIds) {
|
|
|
+ FdkkResponse sceneInfo2 = laserService.getSceneInfoQuery(sceneData.getNum(),dataSetId);
|
|
|
+ jsonObject.put(String.format(laserDataQuery,sceneData.getNum(),dataSetId),sceneInfo2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ FdkkResponse dataSetAndControlPoint = laserService.getDataSetAndControlPoint(sceneData.getNum());
|
|
|
+ if(dataSetAndControlPoint !=null){
|
|
|
+ jsonObject.put(String.format(laserDataSetAndControlPoint,sceneData.getNum()),dataSetAndControlPoint);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ jsonObject.put(basePath+caseFusion+fusionId, ResultData.ok(fusionNumVos));
|
|
|
+
|
|
|
+ List<HotIcon> hotIconList = hotIconService.getListByFusionId(fusionId);
|
|
|
+ for (HotIcon hotIcon : hotIconList) {
|
|
|
+ downResource(hotIcon.getIconUrl(),caseOffPath);
|
|
|
+ }
|
|
|
+ jsonObject.put(basePath+hostIcon+fusionId, ResultData.ok(hotIconList));
|
|
|
+ jsonObject.put(basePath+hostIconTreeList+fusionId, ResultData.ok(hotIconList));
|
|
|
+
|
|
|
+ List<CaseTag> caseTagList = caseTagService.getListByFusionId(fusionId);
|
|
|
+ jsonObject.put(basePath+caseTag+fusionId, ResultData.ok(caseTagList));
|
|
|
+ for (CaseTag tag : caseTagList) {
|
|
|
+ jsonObject.put(basePath+caseTagPoint+tag.getTagId(), ResultData.ok(caseTagPointService.allList(tag.getTagId())));
|
|
|
+ downResources(tag.getTagImgUrl(),caseOffPath);
|
|
|
+ downResource(tag.getHotIconUrl(),caseOffPath);
|
|
|
+ downResource(tag.getAudio(),caseOffPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ jsonObject.put(basePath+casePathInfoUrl+fusionId, ResultData.ok(casePathService.getByFusionId(fusionId)));
|
|
|
+ List<FusionGuide> fusionGuides = fusionGuideService.getByFusionId(fusionId);
|
|
|
+ jsonObject.put(basePath+fusionGuide+fusionId, ResultData.ok(fusionGuides));
|
|
|
+
|
|
|
+ for (FusionGuide guide : fusionGuides) {
|
|
|
+ downResource(guide.getCover(),caseOffPath);
|
|
|
+ List<FusionGuidePath> listByGuideId = fusionGuidePathService.getListByGuideId(guide.getFusionGuideId());
|
|
|
+ for (FusionGuidePath guidePath : listByGuideId) {
|
|
|
+ downResource(guidePath.getCover(),caseOffPath);
|
|
|
+ }
|
|
|
+ jsonObject.put(basePath+fusionGuidePath+guide.getFusionGuideId(), ResultData.ok(listByGuideId));
|
|
|
+ }
|
|
|
+
|
|
|
+ List<CaseAnimation> listByFusionId = caseAnimationService.getListByFusionId(fusionId);
|
|
|
+ jsonObject.put(basePath+caseAnimationUrl+fusionId, ResultData.ok(listByFusionId));
|
|
|
+
|
|
|
+
|
|
|
+ FileUtil.writeString(JSON.toJSONString(jsonObject), caseOffPath+"/www/package/"+jsonDataName,"UTF-8");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //http://127.0.0.1:8080/offline.html?fusionId=362&app=1&share=1#/show/summary
|
|
|
+
|
|
|
+ static String batName = "start-browser.bat";
|
|
|
+ public void cpIndexHtml(Integer caseId,String caseOffPath) throws IOException {
|
|
|
+ log.info("down-offline-cpIndexHtml:{}",caseOffPath);
|
|
|
+ FileUtil.copyContent(new File(FilePath.OFFLINE_TEMPLATE_PATH),new File(caseOffPath),true);
|
|
|
+
|
|
|
+ String s = FileUtil.readString(caseOffPath + File.separator + batName, StandardCharsets.UTF_8);
|
|
|
+ String s1 = s.replaceAll("@caseId", String.valueOf(caseId));
|
|
|
+ if(CacheUtil.settingEntity.getGa()){
|
|
|
+ s1 = s.replaceAll("@caseId", String.valueOf(caseId)+"^&ga=true");
|
|
|
+ }
|
|
|
+ FileUtil.writeString(s1, caseOffPath + File.separator + batName,"UTF-8");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ DownService downService;
|
|
|
+ @Autowired
|
|
|
+ LocalToOssUtil localToOssUtil;
|
|
|
+
|
|
|
+ public void downSwkk(String num,Integer type,String offPath){
|
|
|
+
|
|
|
+ String swkkPath = offPath+ "/www/swkk";
|
|
|
+ String swssPath = offPath + "/www/swss";
|
|
|
+ String numPath = swkkPath;
|
|
|
+
|
|
|
+ Boolean isLaser = false;
|
|
|
+ if(type == 2 || type == 5){
|
|
|
+ isLaser = true;
|
|
|
+ numPath = swssPath;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Boolean wita = true;
|
|
|
+ Long startTime = new Date().getTime();
|
|
|
+ Long outTime = new Date().getTime();
|
|
|
+ Long wiatTime = 10000L;
|
|
|
+
|
|
|
+
|
|
|
+ JSONObject jsonObject = getSceneInfo(num);
|
|
|
+ Integer sceneId = jsonObject.getInteger("id");
|
|
|
+ laserService.rebuildOffline( isLaser ? swssPath : swkkPath,isLaser,sceneId);
|
|
|
+
|
|
|
+ while (wita){
|
|
|
+ Long nowTime = new Date().getTime();
|
|
|
+ if(nowTime - startTime < wiatTime){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(nowTime - outTime > 1000 * 60 * 60 * 2){ //下载单个场景超时时间
|
|
|
+ throw new BusinessException(ResultCode.SYSTEM_ERROR);
|
|
|
+ }
|
|
|
+ startTime = nowTime;
|
|
|
+ jsonObject = getSceneInfo(num);
|
|
|
+ sceneId = jsonObject.getInteger("id");
|
|
|
+ Boolean meshStatus = jsonObject.getBoolean("meshRebuildOffline");
|
|
|
+ Boolean laserStatus = jsonObject.getBoolean("rebuildOffline");
|
|
|
+ String meshOfflineFolder = jsonObject.getString("meshOfflineFolder");
|
|
|
+ String laserOfflineFolder = jsonObject.getString("offlineFolder");
|
|
|
+ //1 生成成功 ,0:正在生成 1,初次生成 2,下载失败
|
|
|
+ Integer laserOffStatus = jsonObject.getInteger("buildOfflineStatus");
|
|
|
+ //1 生成成功,0:正在生成 1,初次生成 2,下载失败
|
|
|
+ Integer meshBuildOfflineStatus = jsonObject.getInteger("meshBuildOfflineStatus");
|
|
|
+
|
|
|
+ wita = downSceneOffline(num,sceneId, isLaser,
|
|
|
+ isLaser ? swssPath : swkkPath,
|
|
|
+ isLaser ? laserStatus : meshStatus,
|
|
|
+ isLaser ? laserOfflineFolder : meshOfflineFolder,
|
|
|
+ isLaser ? laserOffStatus : meshBuildOfflineStatus
|
|
|
+ );
|
|
|
+
|
|
|
+ }
|
|
|
+ File file = new File(numPath + File.separator + num);
|
|
|
+ if(!file.exists()){
|
|
|
+ log.info("场景下载失败-num:{}",num);
|
|
|
+ throw new BusinessException(ResultCode.SCENE_DOWN_ERROR);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private JSONObject getSceneInfo(String num){
|
|
|
+ FdkkResponse fdkkResponse = laserService.sceneLocInfo(num);
|
|
|
+ if(fdkkResponse.getCode() != 200){
|
|
|
+ throw new BusinessException(ResultCode.SYSTEM_ERROR);
|
|
|
+ }
|
|
|
+ return (JSONObject) fdkkResponse.getData();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param buildOfflineStatus //1 生成成功,0:正在生成 1,初次生成 2,下载失败
|
|
|
+ */
|
|
|
+ private Boolean downSceneOffline(String num,Integer sceneId, Boolean isLaser, String offPath, Boolean rebuildOffline, String offlineFolder, Integer buildOfflineStatus) {
|
|
|
+ if(buildOfflineStatus == null|| buildOfflineStatus == 1 || buildOfflineStatus == -1 || buildOfflineStatus ==2){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Value("${upload.query-path}")
|
|
|
+ private String queryPath;
|
|
|
+ public void downZip(Integer type ,String uri,String kkzipPath,String kknumPath,String sszipPath,String ssNumPath){
|
|
|
+ try {
|
|
|
+ if(type != 2 && type != 5){ //深时点云
|
|
|
+ if(uri.contains("?")){
|
|
|
+ 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( String modelGlbUrl,String offPath) {
|
|
|
+ String path = offPath +FilePath.OFFLINE_OSS_PATH;
|
|
|
+
|
|
|
+ JSONArray jsonArray = JSONArray.parseArray(modelGlbUrl);
|
|
|
+ for (Object object : jsonArray) {
|
|
|
+ String res = (String) object;
|
|
|
+ log.info("下载模型:{}",res);
|
|
|
+ if(res.contains(".json") || res.contains(".obj")){
|
|
|
+ res = new File(res).getParentFile().getPath();
|
|
|
+ }
|
|
|
+ localToOssUtil.downForm(res,path+queryPath+res);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public void downResources(String urls,String offPath) {
|
|
|
+
|
|
|
+ JSONArray jsonArray = JSONArray.parseArray(urls);
|
|
|
+ for (Object object : jsonArray) {
|
|
|
+ String res = (String) object;
|
|
|
+ downResource(res,offPath);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void downResource(String url,String offPath) {
|
|
|
+ if(StringUtils.isBlank(url) ){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if("none".equals(url)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if("map".equals(url)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String path = offPath + FilePath.OFFLINE_OSS_PATH;
|
|
|
+ localToOssUtil.downForm(url,path+queryPath+url);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void downWordByTemplate(Integer caseId,XWPFTemplate template,String name,String offPath){
|
|
|
+ // 指定输出文件的路径
|
|
|
+ String outputPath = offPath +FilePath.OFFLINE_RESOURCE_PACKAGE_PATH + name;
|
|
|
+ try {
|
|
|
+ FileOutputStream out = new FileOutputStream(outputPath);
|
|
|
+ template.write(out);
|
|
|
+ out.close();
|
|
|
+ log.info("文档已成功写入到: " + outputPath);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.info("写出文档失败:{},{}",caseId,name,e);
|
|
|
+ throw new BusinessException(ResultCode.SYSTEM_ERROR);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|