|
@@ -1,9 +1,11 @@
|
|
|
package com.fdkankan.manage.httpClient.service;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.thread.ThreadUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fdkankan.common.util.JwtUtil;
|
|
|
+import com.fdkankan.manage.common.RedisKeyUtil;
|
|
|
import com.fdkankan.manage.common.Result;
|
|
|
import com.fdkankan.manage.common.ResultCode;
|
|
|
import com.fdkankan.manage.common.ShellUtil;
|
|
@@ -17,9 +19,11 @@ import com.fdkankan.manage.service.IDownService;
|
|
|
import com.fdkankan.manage.vo.response.DownVo;
|
|
|
import com.fdkankan.manage.vo.response.DownloadProcessVo;
|
|
|
import com.fdkankan.rabbitmq.util.RabbitMqProducer;
|
|
|
+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.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@Service
|
|
@@ -33,6 +37,8 @@ public class OverallService {
|
|
|
IDownService downService;
|
|
|
@Autowired
|
|
|
FyunConfig fyunConfig;
|
|
|
+ @Autowired
|
|
|
+ RedisUtil redisUtil;
|
|
|
|
|
|
private static String appId ="BDA385EC848C1A425F746869011C8D23";
|
|
|
private static String key ="appId";
|
|
@@ -45,17 +51,40 @@ public class OverallService {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public void getSceneListByWorkId(String workId){
|
|
|
+
|
|
|
+
|
|
|
+ public synchronized Object downOfflinePage(String workId){
|
|
|
try {
|
|
|
+ String redisKey = String.format(RedisKeyUtil.overallDownOfflineProgressKey,workId);
|
|
|
+
|
|
|
+ if(redisUtil.hasKey(redisKey)){
|
|
|
+ return redisUtil.get(redisKey);
|
|
|
+ }
|
|
|
|
|
|
OverallVo offlineDetail = overallClient.getOfflineDetail(new WorkOfflineDTO(workId),appId,key);
|
|
|
if(offlineDetail == null || offlineDetail.getCode() !=0){
|
|
|
throw new BusinessException(ResultCode.OVERALL_VIEW_ERROR);
|
|
|
}
|
|
|
-
|
|
|
Object data = offlineDetail.getData();
|
|
|
+ String jsonString = JSONObject.toJSONString(data);
|
|
|
+ WorkOfflineDTO dto = JSONObject.parseObject(jsonString,WorkOfflineDTO.class);
|
|
|
+ redisUtil.set(redisKey,jsonString,RedisKeyUtil.overallDownOfflineProgressKeyTime);
|
|
|
+ run(dto,redisKey);
|
|
|
+ return dto;
|
|
|
+ }catch (Exception e){
|
|
|
+ log.info("全景看看访问失败:{}",e);
|
|
|
+ throw new BusinessException(ResultCode.OVERALL_VIEW_ERROR);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- WorkOfflineDTO dto = JSONObject.parseObject(JSONObject.toJSONString(data),WorkOfflineDTO.class);
|
|
|
+ private void downScene(String downloadUrl, String path) {
|
|
|
+ ShellUtil.yunDownload(downloadUrl.replace(fyunConfig.getFyunHost(), ""),path +"/mesh");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Async
|
|
|
+ public void run(WorkOfflineDTO dto,String redisKey){
|
|
|
+ try {
|
|
|
if(dto.getSceneCodes() != null && !dto.getSceneCodes().isEmpty()){ //下载场景mesh离线包
|
|
|
for (String sceneCode : dto.getSceneCodes()) {
|
|
|
log.info("下载mesh场景:{}",sceneCode);
|
|
@@ -76,24 +105,15 @@ public class OverallService {
|
|
|
}
|
|
|
downScene(downloadProcessVo.getUrl(),dto.getPath());
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
+ dto.setProgress(50);
|
|
|
+ redisUtil.set(redisKey,JSONObject.toJSONString(dto),RedisKeyUtil.overallDownOfflineProgressKeyTime);
|
|
|
rabbitMqProducer.sendByWorkQueue("qjkk-work-offline", BeanUtil.beanToMap(dto));
|
|
|
-
|
|
|
}catch (Exception e){
|
|
|
- log.info("全景看看访问失败:{}",e);
|
|
|
- throw new BusinessException(ResultCode.OVERALL_VIEW_ERROR);
|
|
|
+ log.info("执行失败:{}",e);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-
|
|
|
- private void downScene(String downloadUrl, String path) {
|
|
|
- ShellUtil.yunDownload(downloadUrl.replace(fyunConfig.getFyunHost(), ""),path +"/mesh");
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
}
|