|
@@ -1,11 +1,13 @@
|
|
|
package com.fdkankan.scene.service.impl;
|
|
|
|
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.fdkankan.common.constant.ErrorCode;
|
|
|
+import com.fdkankan.common.constant.SceneDownloadProgressStatus;
|
|
|
import com.fdkankan.common.constant.SceneVersionType;
|
|
|
import com.fdkankan.common.constant.UploadStatus;
|
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
@@ -26,6 +28,7 @@ import com.fdkankan.scene.service.ISceneEditInfoService;
|
|
|
import com.fdkankan.scene.service.IScenePlusService;
|
|
|
import com.fdkankan.web.bean.DownLoadProgressBean;
|
|
|
import com.fdkankan.web.response.ResultData;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -44,6 +47,7 @@ import java.util.Objects;
|
|
|
* @since 2023-03-06
|
|
|
*/
|
|
|
@Service
|
|
|
+@Slf4j
|
|
|
public class SceneDownloadLogServiceImpl extends ServiceImpl<ISceneDownloadLogMapper, SceneDownloadLog> implements ISceneDownloadLogService {
|
|
|
|
|
|
private static String keyFormat = "touch:scene:download:num:%s";
|
|
@@ -93,8 +97,12 @@ public class SceneDownloadLogServiceImpl extends ServiceImpl<ISceneDownloadLogMa
|
|
|
download = true;
|
|
|
}
|
|
|
if(version == sceneDownloadLog.getSceneVersion()){
|
|
|
+ String url=this.publicUrl+":"+serviceConfig.getServerPort()+"/profile" +sceneDownloadLog.getDownloadUrl();
|
|
|
result.put("status", 2);
|
|
|
- result.put("url",this.publicUrl+":"+serviceConfig.getServerPort()+"/profile" +sceneDownloadLog.getDownloadUrl());
|
|
|
+ result.put("url",url);
|
|
|
+ String key=String.format(RedisKey.PREFIX_DOWNLOAD_PROGRESS_V4,num);
|
|
|
+ DownLoadProgressBean progress = new DownLoadProgressBean(sceneDownloadLog.getDownloadUrl(),100, SceneDownloadProgressStatus.DOWNLOAD_SUCCESS.code());
|
|
|
+ redisUtil.set(key, JSONUtil.toJsonStr(progress));
|
|
|
return ResultData.ok(result);
|
|
|
}else{
|
|
|
result.put("status", 3);
|
|
@@ -127,8 +135,14 @@ public class SceneDownloadLogServiceImpl extends ServiceImpl<ISceneDownloadLogMa
|
|
|
|
|
|
@Override
|
|
|
public ResultData downloadProcess(String num) {
|
|
|
- String processStr = redisUtil.get(String.format(RedisKey.PREFIX_DOWNLOAD_PROGRESS_V4,num));
|
|
|
- DownLoadProgressBean downLoadProgressBean = JSONObject.parseObject(processStr, DownLoadProgressBean.class);
|
|
|
+ String key=String.format(RedisKey.PREFIX_DOWNLOAD_PROGRESS_V4,num);
|
|
|
+ DownLoadProgressBean downLoadProgressBean = new DownLoadProgressBean();
|
|
|
+ if (!redisUtil.hasKey(key)){
|
|
|
+ return ResultData.ok(downLoadProgressBean);
|
|
|
+ }
|
|
|
+ String processStr = redisUtil.get(key);
|
|
|
+ log.info("downloadProcess-processStr-{}",processStr);
|
|
|
+ downLoadProgressBean = JSONObject.parseObject(processStr, DownLoadProgressBean.class);
|
|
|
if (downLoadProgressBean.getStatus()== 1002){
|
|
|
//写库
|
|
|
update(
|
|
@@ -145,6 +159,7 @@ public class SceneDownloadLogServiceImpl extends ServiceImpl<ISceneDownloadLogMa
|
|
|
@Override
|
|
|
public ResultData downloadUpDateStatus(String num) {
|
|
|
redisUtil.del(String.format(keyFormat, num));
|
|
|
+ redisUtil.del(String.format(RedisKey.PREFIX_DOWNLOAD_PROGRESS_V4,num));
|
|
|
return ResultData.ok();
|
|
|
}
|
|
|
}
|