dsx 2 jaren geleden
bovenliggende
commit
2424fdf25e

+ 36 - 0
src/main/java/com/fdkankan/scene/controller/SceneDownloadLogController.java

@@ -0,0 +1,36 @@
+package com.fdkankan.scene.controller;
+
+
+import com.fdkankan.scene.service.ISceneDownloadLogService;
+import com.fdkankan.web.response.ResultData;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author 
+ * @since 2023-03-06
+ */
+@RestController
+@RequestMapping("/service/scene/downlaod")
+public class SceneDownloadLogController {
+
+    @Autowired
+    private ISceneDownloadLogService sceneDownloadLogService;
+
+    @GetMapping("/downOfflineScene ")
+    public ResultData downOfflineScene(@RequestParam("sceneCode")String num){
+        return sceneDownloadLogService.downOfflineScene(num);
+    }
+
+
+
+}
+

+ 78 - 0
src/main/java/com/fdkankan/scene/entity/SceneDownloadLog.java

@@ -0,0 +1,78 @@
+package com.fdkankan.scene.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.util.Date;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author 
+ * @since 2023-03-06
+ */
+@Getter
+@Setter
+@TableName("t_scene_download_log")
+public class SceneDownloadLog implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 用户id
+     */
+    @TableField("user_id")
+    private Long userId;
+
+    /**
+     * 场景码
+     */
+    @TableField("scene_num")
+    private String sceneNum;
+
+    /**
+     * 场景版本
+     */
+    @TableField("scene_version")
+    private Integer sceneVersion;
+
+    /**
+     * 场景打包之后的连接
+     */
+    @TableField("download_url")
+    private String downloadUrl;
+
+    /**
+     * 0下载中,1下载成功,2下载失败
+     */
+    @TableField("status")
+    private Integer status;
+
+    /**
+     * 下载版本v3,v4
+     */
+    @TableField("sys_version")
+    private String sysVersion;
+
+    @TableField("rec_status")
+    @TableLogic(value = "A", delval = "I")
+    private String recStatus;
+
+    @TableField("create_time")
+    private Date createTime;
+
+    @TableField("update_time")
+    private Date updateTime;
+
+
+}

+ 1 - 1
src/main/java/com/fdkankan/scene/generate/AutoGenerate.java

@@ -18,7 +18,7 @@ public class AutoGenerate {
         String path =System.getProperty("user.dir");
 
         generate(path,"scene", getTables(new String[]{
-                "t_scene_asyn_oper_log"
+                "t_scene_download_log"
         }));
 
 //        generate(path,"goods", getTables(new String[]{

+ 18 - 0
src/main/java/com/fdkankan/scene/mapper/ISceneDownloadLogMapper.java

@@ -0,0 +1,18 @@
+package com.fdkankan.scene.mapper;
+
+import com.fdkankan.scene.entity.SceneDownloadLog;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author 
+ * @since 2023-03-06
+ */
+@Mapper
+public interface ISceneDownloadLogMapper extends BaseMapper<SceneDownloadLog> {
+
+}

+ 20 - 0
src/main/java/com/fdkankan/scene/service/ISceneDownloadLogService.java

@@ -0,0 +1,20 @@
+package com.fdkankan.scene.service;
+
+import com.fdkankan.scene.entity.SceneDownloadLog;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.fdkankan.web.response.ResultData;
+import org.springframework.web.bind.annotation.RequestParam;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author 
+ * @since 2023-03-06
+ */
+public interface ISceneDownloadLogService extends IService<SceneDownloadLog> {
+
+    ResultData downOfflineScene(String num);
+
+}

+ 92 - 0
src/main/java/com/fdkankan/scene/service/impl/SceneDownloadLogServiceImpl.java

@@ -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;
+    }
+}

+ 5 - 0
src/main/resources/mapper/scene/SceneDownloadLogMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fdkankan.scene.mapper.ISceneDownloadLogMapper">
+
+</mapper>