|
@@ -0,0 +1,92 @@
|
|
|
|
+package com.fdkankan.scene.service.impl;
|
|
|
|
+
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
+import com.fdkankan.common.constant.ErrorCode;
|
|
|
|
+import com.fdkankan.common.exception.BusinessException;
|
|
|
|
+import com.fdkankan.redis.constant.RedisKey;
|
|
|
|
+import com.fdkankan.scene.bean.SceneJsonBean;
|
|
|
|
+import com.fdkankan.scene.entity.SceneDownloadLog;
|
|
|
|
+import com.fdkankan.scene.entity.SceneEditInfo;
|
|
|
|
+import com.fdkankan.scene.entity.ScenePlus;
|
|
|
|
+import com.fdkankan.scene.mapper.ISceneDownloadLogMapper;
|
|
|
|
+import com.fdkankan.scene.oss.OssUtil;
|
|
|
|
+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.response.ResultData;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import java.util.Objects;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * <p>
|
|
|
|
+ * 服务实现类
|
|
|
|
+ * </p>
|
|
|
|
+ *
|
|
|
|
+ * @author
|
|
|
|
+ * @since 2023-03-06
|
|
|
|
+ */
|
|
|
|
+@Service
|
|
|
|
+public class SceneDownloadLogServiceImpl extends ServiceImpl<ISceneDownloadLogMapper, SceneDownloadLog> implements ISceneDownloadLogService {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IScenePlusService scenePlusService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ISceneEditInfoService sceneEditInfoService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private OssUtil ossUtil;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ResultData downOfflineScene(String num) {
|
|
|
|
+
|
|
|
|
+ ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
|
|
|
|
+ if(Objects.isNull(scenePlus)){
|
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
|
+
|
|
|
|
+ String sceneJson = ossUtil.getFileContent(String.format(RedisKey.SCENE_JSON, num));
|
|
|
|
+ SceneJsonBean sceneJsonBean = JSON.parseObject(sceneJson, SceneJsonBean.class);
|
|
|
|
+ int version = sceneJsonBean.getVersion();
|
|
|
|
+
|
|
|
|
+ SceneDownloadLog sceneDownloadLog = this.getOne(
|
|
|
|
+ new LambdaQueryWrapper<SceneDownloadLog>()
|
|
|
|
+ .eq(SceneDownloadLog::getSceneNum, num)
|
|
|
|
+ .orderByDesc(SceneDownloadLog::getId)
|
|
|
|
+ .last("limit 1"));
|
|
|
|
+ boolean download = false;//是否需要生成
|
|
|
|
+ if(Objects.nonNull(sceneDownloadLog)){
|
|
|
|
+ if(sceneDownloadLog.getStatus() == 0){
|
|
|
|
+ result.put("status", 0);
|
|
|
|
+ return ResultData.ok(result);
|
|
|
|
+ }
|
|
|
|
+ if(sceneDownloadLog.getStatus() == 2){
|
|
|
|
+ result.put("status", -1);
|
|
|
|
+ return ResultData.ok(result);
|
|
|
|
+ }
|
|
|
|
+ if(version == sceneDownloadLog.getSceneVersion()){
|
|
|
|
+ result.put("status", 2);
|
|
|
|
+ result.put("url", sceneDownloadLog.getDownloadUrl());
|
|
|
|
+ return ResultData.ok(result);
|
|
|
|
+ }else{
|
|
|
|
+ result.put("status", 3);
|
|
|
|
+ download = true;
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ result.put("status", 0);
|
|
|
|
+ download = true;
|
|
|
|
+ }
|
|
|
|
+ if(download){
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+}
|