|
|
@@ -22,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@Service
|
|
|
@@ -76,30 +77,24 @@ public class DownService implements IDownService {
|
|
|
}
|
|
|
Integer sceneType = plus.getSceneSource();
|
|
|
log.info("checkDownLoad--sceneType:{},isObj:{}",sceneType,isObj);
|
|
|
+ Integer sceneVersion = getSceneVersion(plus);
|
|
|
+ saveLog(plus,sceneVersion,type,isObj);
|
|
|
+
|
|
|
if(NumTypeUtils.isLaserBySceneSource(sceneType) && isObj !=1){ //深时场景
|
|
|
return SSCheckDownload(sceneNum);
|
|
|
}
|
|
|
- SceneDownLog sceneDownloadLog;
|
|
|
- Integer sceneVersion = getSceneVersion(plus);
|
|
|
+ List<SceneDownLog> sceneDownloadLogs = sceneDownloadLogService.getByStatusAndNum(sceneNum,1,sceneVersion,isObj);
|
|
|
|
|
|
- sceneDownloadLog = sceneDownloadLogService.getByStatusAndNum(sceneNum,0,sceneVersion,isObj);
|
|
|
DownVo downVo = new DownVo();
|
|
|
- if(sceneDownloadLog != null){
|
|
|
- downVo.setDownloadStatus(1);
|
|
|
- return downVo;
|
|
|
- }
|
|
|
- sceneDownloadLog = sceneDownloadLogService.getByStatusAndNum(sceneNum,1,sceneVersion,isObj);
|
|
|
//下载过,有更改
|
|
|
- if(sceneDownloadLog == null){
|
|
|
+ if(sceneDownloadLogs == null || sceneDownloadLogs.isEmpty()){
|
|
|
String redisKey = RedisKey.PREFIX_DOWNLOAD_PROGRESS;
|
|
|
downVo.setDownloadStatus(2);
|
|
|
redisUtil.del(String.format(redisKey,sceneNum)); // 清除旧的下载信息
|
|
|
return downVo;
|
|
|
}
|
|
|
- saveLog(plus,sceneVersion,type,isObj);
|
|
|
- //3下载过,并且没有修改过
|
|
|
downVo.setDownloadStatus(3);
|
|
|
- downVo.setDownloadUrl(sceneDownloadLog.getDownUrl());
|
|
|
+ downVo.setDownloadUrl(sceneDownloadLogs.get(0).getDownUrl());
|
|
|
return downVo;
|
|
|
|
|
|
}
|
|
|
@@ -118,9 +113,7 @@ public class DownService implements IDownService {
|
|
|
Long userId = scenePlus.getUserId();
|
|
|
|
|
|
Integer sceneType = scenePlus.getSceneSource();
|
|
|
- Integer sceneVersion = getSceneVersion( scenePlus);
|
|
|
log.info("down--sceneType:{},isObj:{}",sceneType,isObj);
|
|
|
- saveLog(scenePlus,sceneVersion,type,isObj);
|
|
|
if(NumTypeUtils.isLaserBySceneSource(sceneType) && isObj !=1){ //深时场景
|
|
|
return SSDownload(sceneNum,userId);
|
|
|
}
|
|
|
@@ -189,24 +182,19 @@ public class DownService implements IDownService {
|
|
|
if(StringUtils.isEmpty(result)){
|
|
|
return new DownloadProcessVo();
|
|
|
}
|
|
|
- SceneDownLog sceneDownloadLog = sceneDownloadLogService.getByStatusAndNum(sceneNum,0,getSceneVersion(scenePlus),isObj);
|
|
|
|
|
|
DownloadProcessVo downloadProcessVo = JSONObject.parseObject(result, DownloadProcessVo.class);
|
|
|
- if(sceneDownloadLog != null){
|
|
|
switch (downloadProcessVo.getStatus()) {
|
|
|
case DownloadStatusEnum.DOWNLOAD_SUCCESS_CODE:
|
|
|
String url = downloadProcessVo.getUrl();
|
|
|
if (!StringUtils.isEmpty(url)) {
|
|
|
- sceneDownloadLog.setDownUrl(url);
|
|
|
- sceneDownloadLog.setStatus(1);
|
|
|
+ updateLogStatus(sceneNum,getSceneVersion(scenePlus),1,isObj,url);
|
|
|
break;
|
|
|
}
|
|
|
case DownloadStatusEnum.DOWNLOAD_FAILED_CODE:
|
|
|
- sceneDownloadLog.setStatus(-1);
|
|
|
+ updateLogStatus(sceneNum,getSceneVersion(scenePlus),-1,isObj,null);
|
|
|
break;
|
|
|
}
|
|
|
- sceneDownloadLogService.updateById(sceneDownloadLog);
|
|
|
- }
|
|
|
return downloadProcessVo;
|
|
|
}
|
|
|
|
|
|
@@ -275,14 +263,24 @@ public class DownService implements IDownService {
|
|
|
downVo.setUrl(vo.getUrl());
|
|
|
downVo.setStatus(1002);
|
|
|
|
|
|
- LambdaUpdateWrapper<SceneDownLog> wrapper = new LambdaUpdateWrapper<>();
|
|
|
- wrapper.eq(SceneDownLog::getSceneNum,sceneNum);
|
|
|
- wrapper.eq(SceneDownLog::getStatus,0);
|
|
|
- wrapper.set(SceneDownLog::getDownUrl,vo.getUrl());
|
|
|
- wrapper.set(SceneDownLog::getStatus,1);
|
|
|
- sceneDownloadLogService.update(wrapper);
|
|
|
+ updateLogStatus(sceneNum,null,1,0,vo.getUrl());
|
|
|
}
|
|
|
return downVo;
|
|
|
}
|
|
|
|
|
|
+ private void updateLogStatus(String sceneNum,Integer version,Integer status,Integer isObj,String url){
|
|
|
+ LambdaUpdateWrapper<SceneDownLog> wrapper = new LambdaUpdateWrapper<>();
|
|
|
+ wrapper.eq(SceneDownLog::getSceneNum,sceneNum);
|
|
|
+ wrapper.eq(SceneDownLog::getIsObj,isObj);
|
|
|
+ if(version != null){
|
|
|
+ wrapper.eq(SceneDownLog::getVersion,version);
|
|
|
+ }
|
|
|
+ wrapper.eq(SceneDownLog::getStatus,0);
|
|
|
+ if(StringUtils.isNotBlank(url)){
|
|
|
+ wrapper.set(SceneDownLog::getDownUrl,url);
|
|
|
+ }
|
|
|
+ wrapper.set(SceneDownLog::getStatus,status);
|
|
|
+ sceneDownloadLogService.update(wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
}
|