|
@@ -6,11 +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.LocalToOssUtil;
|
|
|
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;
|
|
@@ -137,10 +139,12 @@ public class CaseDownService {
|
|
|
}
|
|
|
@Async
|
|
|
public void downOffline(Integer caseId,String zipPath){
|
|
|
- String timeKey = DateUtils.dateStr();
|
|
|
- String caseOffPath = zipPath+File.separator+"offline_"+caseId+"_"+timeKey ;
|
|
|
try {
|
|
|
+ caseService.updateOfflineStatus(caseId,1,zipPath);
|
|
|
+ String timeKey = DateUtils.dateStr();
|
|
|
+ String caseOffPath = zipPath+File.separator+"offline_"+caseId+"_"+timeKey ;
|
|
|
String redisKey = String.format(downProcessKey, caseId);
|
|
|
+
|
|
|
if( redisUtil.hasKey(redisKey)){
|
|
|
String res = redisUtil.get(redisKey);
|
|
|
DownloadProcessVo downloadProcessVo = JSONObject.parseObject(res, DownloadProcessVo.class);
|
|
@@ -157,20 +161,14 @@ public class CaseDownService {
|
|
|
createDataJson(caseId,caseOffPath);
|
|
|
setRedisProcess(caseId,50);
|
|
|
//打包zip
|
|
|
- caseOfflineService.saveByCase(caseId,caseOffPath);
|
|
|
+ //caseOfflineService.saveByCase(caseId,caseOffPath);
|
|
|
setRedisProcess(caseId,100,zipPath);
|
|
|
-
|
|
|
+ caseService.updateOfflineStatus(caseId,2,zipPath);
|
|
|
}catch (Exception e){
|
|
|
log.info("down-offline-error:{}",caseId,e);
|
|
|
setRedisProcess(caseId,0,null,1003);
|
|
|
- }finally {
|
|
|
- try {
|
|
|
- setRedisProcess(caseId,0,null,1003);
|
|
|
- }catch (Exception e){
|
|
|
- log.info("down-offline-del-error:{}",caseId,e);
|
|
|
- }
|
|
|
+ caseService.updateOfflineStatus(caseId,-1,zipPath);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
public void setRedisProcess(Integer caseId,Integer num){
|
|
@@ -188,7 +186,7 @@ public class CaseDownService {
|
|
|
processVo.setStatus(status);
|
|
|
processVo.setPercent(num);
|
|
|
processVo.setUrl( url);
|
|
|
- redisUtil.set(redisKey,JSONObject.toJSONString(processVo));
|
|
|
+ redisUtil.set(redisKey,JSONObject.toJSONString(processVo),60 * 60 * 24);
|
|
|
}
|
|
|
|
|
|
public DownloadProcessVo process(Integer caseId) {
|
|
@@ -387,37 +385,32 @@ public class CaseDownService {
|
|
|
if(nowTime - startTime < wiatTime){
|
|
|
continue;
|
|
|
}
|
|
|
- if(nowTime - outTime > 1000 * 60 * 60 * 24){ //下载单个场景超时时间
|
|
|
- break;
|
|
|
+ if(nowTime - outTime > 1000 * 60 * 60 * 2){ //下载单个场景超时时间
|
|
|
+ throw new BusinessException(ResultCode.SYSTEM_ERROR);
|
|
|
}
|
|
|
startTime = nowTime;
|
|
|
- try {
|
|
|
- FdkkResponse fdkkResponse = laserService.sceneLocInfo(num);
|
|
|
- if(fdkkResponse.getCode() != 200){
|
|
|
- break;
|
|
|
- }
|
|
|
- JSONObject jsonObject = (JSONObject) fdkkResponse.getData();
|
|
|
- Integer 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
|
|
|
- );
|
|
|
-
|
|
|
- }catch (Exception e){
|
|
|
- log.info("下载场景离线包失败:{}",num,e);
|
|
|
- break;
|
|
|
+ FdkkResponse fdkkResponse = laserService.sceneLocInfo(num);
|
|
|
+ if(fdkkResponse.getCode() != 200){
|
|
|
+ throw new BusinessException(ResultCode.SYSTEM_ERROR);
|
|
|
}
|
|
|
+ JSONObject jsonObject = (JSONObject) fdkkResponse.getData();
|
|
|
+ Integer 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
|
|
|
+ );
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -533,6 +526,7 @@ public class CaseDownService {
|
|
|
log.info("文档已成功写入到: " + outputPath);
|
|
|
} catch (Exception e) {
|
|
|
log.info("写出文档失败:{},{}",caseId,name,e);
|
|
|
+ throw new BusinessException(ResultCode.SYSTEM_ERROR);
|
|
|
}
|
|
|
}
|
|
|
|