|
@@ -1,10 +1,14 @@
|
|
|
package com.fdkankan.scene.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.fdkankan.common.constant.ErrorCode;
|
|
|
+import com.fdkankan.common.constant.SceneVersionType;
|
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
|
+import com.fdkankan.common.util.JwtUtil;
|
|
|
import com.fdkankan.redis.constant.RedisKey;
|
|
|
+import com.fdkankan.redis.util.RedisUtil;
|
|
|
import com.fdkankan.scene.bean.SceneJsonBean;
|
|
|
import com.fdkankan.scene.entity.SceneDownloadLog;
|
|
|
import com.fdkankan.scene.entity.SceneEditInfo;
|
|
@@ -15,7 +19,9 @@ import com.fdkankan.scene.service.ISceneDownloadLogService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
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 org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -34,12 +40,16 @@ import java.util.Objects;
|
|
|
@Service
|
|
|
public class SceneDownloadLogServiceImpl extends ServiceImpl<ISceneDownloadLogMapper, SceneDownloadLog> implements ISceneDownloadLogService {
|
|
|
|
|
|
+ private static String keyFormat = "touch:scene:download:num:%s";
|
|
|
+
|
|
|
@Autowired
|
|
|
private IScenePlusService scenePlusService;
|
|
|
@Autowired
|
|
|
private ISceneEditInfoService sceneEditInfoService;
|
|
|
@Autowired
|
|
|
private OssUtil ossUtil;
|
|
|
+ @Autowired
|
|
|
+ private RedisUtil redisUtil;
|
|
|
|
|
|
|
|
|
@Override
|
|
@@ -74,19 +84,49 @@ public class SceneDownloadLogServiceImpl extends ServiceImpl<ISceneDownloadLogMa
|
|
|
if(version == sceneDownloadLog.getSceneVersion()){
|
|
|
result.put("status", 2);
|
|
|
result.put("url", sceneDownloadLog.getDownloadUrl());
|
|
|
+ redisUtil.set(String.format(keyFormat, num), "1");
|
|
|
return ResultData.ok(result);
|
|
|
}else{
|
|
|
result.put("status", 3);
|
|
|
download = true;
|
|
|
}
|
|
|
}else{
|
|
|
- result.put("status", 0);
|
|
|
+ result.put("status", 1);
|
|
|
download = true;
|
|
|
}
|
|
|
if(download){
|
|
|
|
|
|
+ redisUtil.set(String.format(keyFormat, num), "1");
|
|
|
+
|
|
|
+ //清除之前的下载记录
|
|
|
+ this.remove(new LambdaQueryWrapper<SceneDownloadLog>().eq(SceneDownloadLog::getSceneNum, num));
|
|
|
+
|
|
|
+ //写入新的记录
|
|
|
+ sceneDownloadLog = new SceneDownloadLog();
|
|
|
+ sceneDownloadLog.setSceneNum(num);
|
|
|
+ sceneDownloadLog.setSceneVersion(version);
|
|
|
+ sceneDownloadLog.setSysVersion("v4");
|
|
|
+ this.save(sceneDownloadLog);
|
|
|
+
|
|
|
+ Map<String,String> params = new HashMap<>(2);
|
|
|
+ params.put("type","local");
|
|
|
+ params.put("num",num);
|
|
|
+ redisUtil.lRightPush(RedisKey.SCENE_DOWNLOADS_TASK_V4, JSONObject.toJSONString(params));
|
|
|
}
|
|
|
|
|
|
- return null;
|
|
|
+ return ResultData.ok(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @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);
|
|
|
+ return ResultData.ok(downLoadProgressBean);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResultData downloadUpDateStatus(String num) {
|
|
|
+ redisUtil.del(String.format(keyFormat, num));
|
|
|
+ return ResultData.ok();
|
|
|
}
|
|
|
}
|