|
@@ -3,6 +3,7 @@ package com.fdkankan.manage.service.impl;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
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.manage.common.DownloadStatusEnum;
|
|
import com.fdkankan.manage.exception.BusinessException;
|
|
import com.fdkankan.manage.exception.BusinessException;
|
|
import com.fdkankan.manage.entity.*;
|
|
import com.fdkankan.manage.entity.*;
|
|
import com.fdkankan.manage.service.*;
|
|
import com.fdkankan.manage.service.*;
|
|
@@ -108,16 +109,28 @@ 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);
|
|
}
|
|
}
|
|
|
|
+ Long userId = scenePro == null ? scenePlus.getUserId() : scenePro.getUserId();
|
|
DownVo downVo = new DownVo();
|
|
DownVo downVo = new DownVo();
|
|
|
|
+ Integer sceneVersion = getSceneVersion(scenePro, scenePlus);
|
|
|
|
+
|
|
Map<String,String> params = new HashMap<>(2);
|
|
Map<String,String> params = new HashMap<>(2);
|
|
params.put("type","local");
|
|
params.put("type","local");
|
|
params.put("sceneNum",sceneNum);
|
|
params.put("sceneNum",sceneNum);
|
|
String redisKey = RedisKey.DOWNLOAD_TASK;
|
|
String redisKey = RedisKey.DOWNLOAD_TASK;
|
|
|
|
+ String sysVersion = "v3";
|
|
if(scenePro == null){
|
|
if(scenePro == null){
|
|
params.put("num",sceneNum);
|
|
params.put("num",sceneNum);
|
|
redisKey = RedisKey.SCENE_DOWNLOADS_TASK_V4;
|
|
redisKey = RedisKey.SCENE_DOWNLOADS_TASK_V4;
|
|
|
|
+ sysVersion = "v4";
|
|
}
|
|
}
|
|
redisUtil.lRightPush(redisKey, JSONObject.toJSONString(params));
|
|
redisUtil.lRightPush(redisKey, JSONObject.toJSONString(params));
|
|
|
|
+ SceneDownloadLog sceneDownloadLogEntity = new SceneDownloadLog();
|
|
|
|
+ sceneDownloadLogEntity.setUserId(userId);
|
|
|
|
+ sceneDownloadLogEntity.setSceneNum(sceneNum);
|
|
|
|
+ sceneDownloadLogEntity.setSceneVersion(sceneVersion);
|
|
|
|
+ sceneDownloadLogEntity.setStatus(0);
|
|
|
|
+ sceneDownloadLogEntity.setSysVersion(sysVersion);
|
|
|
|
+ sceneDownloadLogService.save(sceneDownloadLogEntity);
|
|
downVo.setDownloadStatus(1);
|
|
downVo.setDownloadStatus(1);
|
|
return downVo;
|
|
return downVo;
|
|
}
|
|
}
|
|
@@ -141,7 +154,27 @@ public class DownService implements IDownService {
|
|
if(StringUtils.isEmpty(result)){
|
|
if(StringUtils.isEmpty(result)){
|
|
return new DownloadProcessVo();
|
|
return new DownloadProcessVo();
|
|
}
|
|
}
|
|
- return JSONObject.parseObject(result,DownloadProcessVo.class);
|
|
|
|
|
|
+ int isUp = 0;
|
|
|
|
+ if(scenePro == null){
|
|
|
|
+ isUp = 1;
|
|
|
|
+ }
|
|
|
|
+ SceneDownloadLog sceneDownloadLog = sceneDownloadLogService.getByStatusAndNum(sceneNum,0,isUp);
|
|
|
|
+
|
|
|
|
+ DownloadProcessVo downloadProcessVo = JSONObject.parseObject(result, DownloadProcessVo.class);
|
|
|
|
+ switch (downloadProcessVo.getStatus()) {
|
|
|
|
+ case DownloadStatusEnum.DOWNLOAD_SUCCESS_CODE:
|
|
|
|
+ String url = downloadProcessVo.getUrl();
|
|
|
|
+ if (!StringUtils.isEmpty(url)) {
|
|
|
|
+ sceneDownloadLog.setDownloadUrl(url);
|
|
|
|
+ sceneDownloadLog.setStatus(1);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ case DownloadStatusEnum.DOWNLOAD_FAILED_CODE:
|
|
|
|
+ sceneDownloadLog.setStatus(-1);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ sceneDownloadLogService.updateById(sceneDownloadLog);
|
|
|
|
+ return downloadProcessVo;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|