|
@@ -1,14 +1,18 @@
|
|
package com.fdkankan.ucenter.service.impl;
|
|
package com.fdkankan.ucenter.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.fdkankan.common.constant.ErrorCode;
|
|
import com.fdkankan.common.constant.ErrorCode;
|
|
import com.fdkankan.common.constant.SceneConstant;
|
|
import com.fdkankan.common.constant.SceneConstant;
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
import com.fdkankan.redis.constant.RedisKey;
|
|
import com.fdkankan.redis.constant.RedisKey;
|
|
import com.fdkankan.redis.util.RedisUtil;
|
|
import com.fdkankan.redis.util.RedisUtil;
|
|
import com.fdkankan.ucenter.common.DownloadStatusEnum;
|
|
import com.fdkankan.ucenter.common.DownloadStatusEnum;
|
|
|
|
+import com.fdkankan.ucenter.common.constants.ResultCode;
|
|
import com.fdkankan.ucenter.constant.LoginConstant;
|
|
import com.fdkankan.ucenter.constant.LoginConstant;
|
|
import com.fdkankan.ucenter.entity.*;
|
|
import com.fdkankan.ucenter.entity.*;
|
|
|
|
+import com.fdkankan.ucenter.httpClient.service.LaserService;
|
|
|
|
+import com.fdkankan.ucenter.httpClient.vo.SSDownSceneVo;
|
|
import com.fdkankan.ucenter.service.*;
|
|
import com.fdkankan.ucenter.service.*;
|
|
import com.fdkankan.ucenter.vo.response.DownVo;
|
|
import com.fdkankan.ucenter.vo.response.DownVo;
|
|
import com.fdkankan.ucenter.vo.response.DownloadProcessVo;
|
|
import com.fdkankan.ucenter.vo.response.DownloadProcessVo;
|
|
@@ -37,6 +41,8 @@ public class DownService implements IDownService {
|
|
ISceneEditInfoService sceneEditInfoService;
|
|
ISceneEditInfoService sceneEditInfoService;
|
|
@Autowired
|
|
@Autowired
|
|
IUserService userService;
|
|
IUserService userService;
|
|
|
|
+ @Autowired
|
|
|
|
+ LaserService laserService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -49,6 +55,11 @@ public class DownService implements IDownService {
|
|
if(scenePro == null && plus == null){
|
|
if(scenePro == null && plus == null){
|
|
throw new BusinessException(SceneConstant.FAILURE_CODE_5005, SceneConstant.FAILURE_MSG_5005);
|
|
throw new BusinessException(SceneConstant.FAILURE_CODE_5005, SceneConstant.FAILURE_MSG_5005);
|
|
}
|
|
}
|
|
|
|
+ Integer sceneType = scenePro !=null ? scenePro.getSceneType() : plus.getSceneType();
|
|
|
|
+
|
|
|
|
+ if(sceneType == 10){ //深时场景
|
|
|
|
+ return SSCheckDownload(sceneNum);
|
|
|
|
+ }
|
|
SceneDownloadLog sceneDownloadLog;
|
|
SceneDownloadLog sceneDownloadLog;
|
|
int isUp = 0;
|
|
int isUp = 0;
|
|
if(scenePro == null){
|
|
if(scenePro == null){
|
|
@@ -82,6 +93,7 @@ public class DownService implements IDownService {
|
|
return downVo;
|
|
return downVo;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
private Integer getSceneVersion(ScenePro scenePro,ScenePlus scenePlus){
|
|
private Integer getSceneVersion(ScenePro scenePro,ScenePlus scenePlus){
|
|
Integer version = 0;
|
|
Integer version = 0;
|
|
if(scenePro != null){
|
|
if(scenePro != null){
|
|
@@ -111,6 +123,11 @@ public class DownService implements IDownService {
|
|
if(scenePro == null && scenePlus == null){
|
|
if(scenePro == null && scenePlus == null){
|
|
throw new BusinessException(SceneConstant.FAILURE_CODE_5005, SceneConstant.FAILURE_MSG_5005);
|
|
throw new BusinessException(SceneConstant.FAILURE_CODE_5005, SceneConstant.FAILURE_MSG_5005);
|
|
}
|
|
}
|
|
|
|
+ Integer sceneType = scenePro !=null ? scenePro.getSceneType() : scenePlus.getSceneType();
|
|
|
|
+
|
|
|
|
+ if(sceneType == 10){ //深时场景
|
|
|
|
+ return SSDownload(sceneNum,userName);
|
|
|
|
+ }
|
|
DownVo downVo = new DownVo();
|
|
DownVo downVo = new DownVo();
|
|
User user = userService.getByUserName(userName);
|
|
User user = userService.getByUserName(userName);
|
|
if(user == null || user.getDownloadNumTotal() - user.getDownloadNum() <= 0){
|
|
if(user == null || user.getDownloadNumTotal() - user.getDownloadNum() <= 0){
|
|
@@ -162,6 +179,11 @@ public class DownService implements IDownService {
|
|
if(scenePro == null && scenePlus == null){
|
|
if(scenePro == null && scenePlus == null){
|
|
throw new BusinessException(SceneConstant.FAILURE_CODE_5005, SceneConstant.FAILURE_MSG_5005);
|
|
throw new BusinessException(SceneConstant.FAILURE_CODE_5005, SceneConstant.FAILURE_MSG_5005);
|
|
}
|
|
}
|
|
|
|
+ Integer sceneType = scenePro !=null ? scenePro.getSceneType() : scenePlus.getSceneType();
|
|
|
|
+
|
|
|
|
+ if(sceneType == 10){ //深时场景
|
|
|
|
+ return SSDownloadProcess(sceneNum);
|
|
|
|
+ }
|
|
String redisKey = RedisKey.PREFIX_DOWNLOAD_PROGRESS;
|
|
String redisKey = RedisKey.PREFIX_DOWNLOAD_PROGRESS;
|
|
if(scenePro == null){
|
|
if(scenePro == null){
|
|
redisKey = RedisKey.PREFIX_DOWNLOAD_PROGRESS_V4;
|
|
redisKey = RedisKey.PREFIX_DOWNLOAD_PROGRESS_V4;
|
|
@@ -199,4 +221,90 @@ public class DownService implements IDownService {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * downloadStatus 1 未下载过,2下载过有修改 ,3下载过没修改
|
|
|
|
+ */
|
|
|
|
+ private DownVo SSCheckDownload(String sceneNum) {
|
|
|
|
+ DownVo downVo = new DownVo();
|
|
|
|
+ SSDownSceneVo vo = laserService.downOfflineSceneStatus(sceneNum);
|
|
|
|
+ if(vo == null){
|
|
|
|
+ throw new BusinessException(ResultCode.FAILURE_CODE_400003,ResultCode.FAILURE_MSG_400003);
|
|
|
|
+ }
|
|
|
|
+ downVo.setDownloadStatus(1);
|
|
|
|
+ if(vo.getStatus() == 1){
|
|
|
|
+ downVo.setDownloadStatus(3);
|
|
|
|
+ downVo.setDownloadUrl(vo.getUrl());
|
|
|
|
+ }
|
|
|
|
+ if(vo.getStatus() == 2){
|
|
|
|
+ downVo.setDownloadStatus(2);
|
|
|
|
+ }
|
|
|
|
+ return downVo;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * downloadStatus -1下载失败 1下载成功
|
|
|
|
+ */
|
|
|
|
+ private DownVo SSDownload(String sceneNum,String userName) {
|
|
|
|
+ DownVo downVo = new DownVo();
|
|
|
|
+
|
|
|
|
+ User user = userService.getByUserName(userName);
|
|
|
|
+ if(user == null || user.getSsDownloadNumTotal() - user.getSsDownloadNum() <= 0){
|
|
|
|
+ downVo.setDownloadStatus(-1);
|
|
|
|
+ return downVo;
|
|
|
|
+ }
|
|
|
|
+ SSDownSceneVo vo = laserService.downOfflineScene(sceneNum);
|
|
|
|
+ if(vo == null){
|
|
|
|
+ throw new BusinessException(ResultCode.FAILURE_CODE_400003,ResultCode.FAILURE_MSG_400003);
|
|
|
|
+ }
|
|
|
|
+ LambdaUpdateWrapper<User> wrapper = new LambdaUpdateWrapper<>();
|
|
|
|
+ wrapper.eq(User::getId,user.getId());
|
|
|
|
+ wrapper.set(User::getSsDownloadNum ,user.getSsDownloadNum() + 1);
|
|
|
|
+ userService.update(wrapper);
|
|
|
|
+
|
|
|
|
+ SceneDownloadLog sceneDownloadLogEntity = new SceneDownloadLog();
|
|
|
|
+ sceneDownloadLogEntity.setUserId(user.getId());
|
|
|
|
+ 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.FAILURE_CODE_400003,ResultCode.FAILURE_MSG_400003);
|
|
|
|
+ }
|
|
|
|
+ downVo.setStatus(1003);
|
|
|
|
+ if(vo.getStatus() == 0){ //下载中
|
|
|
|
+ ssNumProcessNumMap.merge(sceneNum, 2, Integer::sum);
|
|
|
|
+ Integer percent = ssNumProcessNumMap.get(sceneNum);
|
|
|
|
+ if(percent >100){
|
|
|
|
+ percent = 99;
|
|
|
|
+ }
|
|
|
|
+ downVo.setStatus(1001);
|
|
|
|
+ downVo.setPercent(percent);
|
|
|
|
+ }
|
|
|
|
+ if(vo.getStatus() == 1){ //下载完成
|
|
|
|
+ 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;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|