|
@@ -1,16 +1,20 @@
|
|
|
package com.fdkankan.manage.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.fdkankan.manage.common.ResultCode;
|
|
|
import com.fdkankan.common.constant.SceneConstant;
|
|
|
import com.fdkankan.manage.common.DownloadStatusEnum;
|
|
|
import com.fdkankan.manage.exception.BusinessException;
|
|
|
import com.fdkankan.manage.entity.*;
|
|
|
+import com.fdkankan.manage.httpClient.service.LaserService;
|
|
|
import com.fdkankan.manage.service.*;
|
|
|
import com.fdkankan.manage.vo.response.DownVo;
|
|
|
import com.fdkankan.manage.vo.response.DownloadProcessVo;
|
|
|
+import com.fdkankan.manage.vo.response.SSDownSceneVo;
|
|
|
import com.fdkankan.redis.constant.RedisKey;
|
|
|
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.stereotype.Service;
|
|
@@ -21,6 +25,7 @@ import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@Service
|
|
|
+@Slf4j
|
|
|
public class DownService implements IDownService {
|
|
|
|
|
|
@Autowired
|
|
@@ -35,10 +40,12 @@ public class DownService implements IDownService {
|
|
|
ISceneEditInfoService sceneEditInfoService;
|
|
|
@Autowired
|
|
|
RedisUtil redisUtil;
|
|
|
+ @Autowired
|
|
|
+ LaserService laserService;
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public DownVo checkDownLoad(String sceneNum) {
|
|
|
+ public DownVo checkDownLoad(String sceneNum,Integer isObj) {
|
|
|
if(StringUtils.isEmpty(sceneNum)){
|
|
|
throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS.code(),ResultCode.MISSING_REQUIRED_PARAMETERS.message());
|
|
|
}
|
|
@@ -47,6 +54,11 @@ public class DownService implements IDownService {
|
|
|
if(scenePro == null && plus == null){
|
|
|
throw new BusinessException(SceneConstant.FAILURE_CODE_5005, SceneConstant.FAILURE_MSG_5005);
|
|
|
}
|
|
|
+ Integer sceneType = scenePro !=null ? scenePro.getSceneSource() : plus.getSceneSource();
|
|
|
+ log.info("checkDownLoad--sceneType:{},isObj:{}",sceneType,isObj);
|
|
|
+ if((sceneType == 4 || sceneType == 5) && isObj !=1){ //深时场景
|
|
|
+ return SSCheckDownload(sceneNum);
|
|
|
+ }
|
|
|
SceneDownloadLog sceneDownloadLog;
|
|
|
int isUp = 0;
|
|
|
if(scenePro == null){
|
|
@@ -100,7 +112,7 @@ public class DownService implements IDownService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public DownVo down(String sceneNum) {
|
|
|
+ public DownVo down(String sceneNum,Integer isObj) {
|
|
|
if(StringUtils.isEmpty(sceneNum) ){
|
|
|
throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS.code(),ResultCode.MISSING_REQUIRED_PARAMETERS.message());
|
|
|
}
|
|
@@ -110,6 +122,13 @@ public class DownService implements IDownService {
|
|
|
throw new BusinessException(SceneConstant.FAILURE_CODE_5005, SceneConstant.FAILURE_MSG_5005);
|
|
|
}
|
|
|
Long userId = scenePro == null ? scenePlus.getUserId() : scenePro.getUserId();
|
|
|
+
|
|
|
+ Integer sceneType = scenePro !=null ? scenePro.getSceneSource() : scenePlus.getSceneSource();
|
|
|
+ log.info("down--sceneType:{},isObj:{}",sceneType,isObj);
|
|
|
+ if((sceneType == 4 || sceneType == 5) && isObj !=1){ //深时场景
|
|
|
+ return SSDownload(sceneNum,userId);
|
|
|
+ }
|
|
|
+
|
|
|
DownVo downVo = new DownVo();
|
|
|
Integer sceneVersion = getSceneVersion(scenePro, scenePlus);
|
|
|
|
|
@@ -136,7 +155,7 @@ public class DownService implements IDownService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public DownloadProcessVo downloadProcess(String sceneNum) {
|
|
|
+ public DownloadProcessVo downloadProcess(String sceneNum,Integer isObj) {
|
|
|
if (StringUtils.isEmpty(sceneNum)) {
|
|
|
throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS.code(),ResultCode.MISSING_REQUIRED_PARAMETERS.message());
|
|
|
}
|
|
@@ -145,6 +164,11 @@ public class DownService implements IDownService {
|
|
|
if(scenePro == null && scenePlus == null){
|
|
|
throw new BusinessException(SceneConstant.FAILURE_CODE_5005, SceneConstant.FAILURE_MSG_5005);
|
|
|
}
|
|
|
+ Integer sceneType = scenePro !=null ? scenePro.getSceneSource() : scenePlus.getSceneSource();
|
|
|
+ log.info("downloadProcess--sceneType:{},isObj:{}",sceneType,isObj);
|
|
|
+ if((sceneType == 4 || sceneType == 5) && isObj !=1){ //深时场景
|
|
|
+ return SSDownloadProcess(sceneNum);
|
|
|
+ }
|
|
|
String redisKey = RedisKey.PREFIX_DOWNLOAD_PROGRESS;
|
|
|
if(scenePro == null){
|
|
|
redisKey = RedisKey.PREFIX_DOWNLOAD_PROGRESS_V4;
|
|
@@ -180,4 +204,86 @@ public class DownService implements IDownService {
|
|
|
return downloadProcessVo;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * status :离线包状态是否需要重新生成 0 未生成:1 不需要 2需要 3 生成中
|
|
|
+ */
|
|
|
+ private DownVo SSCheckDownload(String sceneNum) {
|
|
|
+ DownVo downVo = new DownVo();
|
|
|
+ SSDownSceneVo vo = laserService.downOfflineSceneStatus(sceneNum);
|
|
|
+ if(vo == null){
|
|
|
+ throw new BusinessException(ResultCode.SS_SCENE_DOWN_ERROR);
|
|
|
+ }
|
|
|
+ downVo.setDownloadStatus(0);
|
|
|
+ if(vo.getStatus() == 1){
|
|
|
+ downVo.setDownloadStatus(3);
|
|
|
+ downVo.setDownloadUrl(vo.getUrl());
|
|
|
+ }
|
|
|
+ if(vo.getStatus() == 2){
|
|
|
+ downVo.setDownloadStatus(2);
|
|
|
+ }
|
|
|
+ if(vo.getStatus() == 3){
|
|
|
+ downVo.setDownloadStatus(1);
|
|
|
+ }
|
|
|
+ return downVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * downloadStatus -1下载失败 1下载成功
|
|
|
+ */
|
|
|
+ private DownVo SSDownload(String sceneNum,Long userId) {
|
|
|
+ DownVo downVo = new DownVo();
|
|
|
+
|
|
|
+ //status :0:正在生成 1,初次生成 2,已经生成直接下载 3,重新生成
|
|
|
+ SSDownSceneVo vo = laserService.downOfflineScene(sceneNum);
|
|
|
+ if(vo == null){
|
|
|
+ throw new BusinessException(ResultCode.SS_SCENE_DOWN_ERROR);
|
|
|
+ }
|
|
|
+
|
|
|
+ SceneDownloadLog sceneDownloadLogEntity = new SceneDownloadLog();
|
|
|
+ sceneDownloadLogEntity.setUserId(userId);
|
|
|
+ sceneDownloadLogEntity.setSceneNum(sceneNum);
|
|
|
+ sceneDownloadLogEntity.setSceneVersion(0);
|
|
|
+ sceneDownloadLogEntity.setStatus(0);
|
|
|
+ sceneDownloadLogEntity.setSysVersion("ss");
|
|
|
+ sceneDownloadLogService.save(sceneDownloadLogEntity);
|
|
|
+ downVo.setDownloadStatus(1);
|
|
|
+ return downVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static HashMap<String,Integer> ssNumProcessNumMap = new HashMap<>();
|
|
|
+
|
|
|
+ private DownloadProcessVo SSDownloadProcess(String sceneNum) {
|
|
|
+ DownloadProcessVo downVo = new DownloadProcessVo();
|
|
|
+ SSDownSceneVo vo = laserService.downOfflineSceneStatus(sceneNum);
|
|
|
+ if(vo == null){
|
|
|
+ throw new BusinessException(ResultCode.SS_SCENE_DOWN_ERROR);
|
|
|
+ }
|
|
|
+ downVo.setStatus(1003);
|
|
|
+
|
|
|
+ if(vo.getStatus() == 0 || vo.getStatus() == 2 || vo.getStatus() == 3){ //下载中
|
|
|
+ ssNumProcessNumMap.merge(sceneNum, 1, Integer::sum);
|
|
|
+ Integer percent = ssNumProcessNumMap.get(sceneNum);
|
|
|
+ percent = percent /2;
|
|
|
+ if(percent >50){
|
|
|
+ percent = 50;
|
|
|
+ }
|
|
|
+ downVo.setStatus(1001);
|
|
|
+ downVo.setPercent(percent);
|
|
|
+ }
|
|
|
+ if(vo.getStatus() == 1){ //下载完成
|
|
|
+ ssNumProcessNumMap.remove(sceneNum);
|
|
|
+ downVo.setPercent(100);
|
|
|
+ downVo.setUrl(vo.getUrl());
|
|
|
+ downVo.setStatus(1002);
|
|
|
+
|
|
|
+ LambdaUpdateWrapper<SceneDownloadLog> wrapper = new LambdaUpdateWrapper<>();
|
|
|
+ wrapper.eq(SceneDownloadLog::getSceneNum,sceneNum);
|
|
|
+ wrapper.eq(SceneDownloadLog::getStatus,0);
|
|
|
+ wrapper.set(SceneDownloadLog::getDownloadUrl,vo.getUrl());
|
|
|
+ wrapper.set(SceneDownloadLog::getStatus,1);
|
|
|
+ sceneDownloadLogService.update(wrapper);
|
|
|
+ }
|
|
|
+ return downVo;
|
|
|
+ }
|
|
|
+
|
|
|
}
|