Преглед изворни кода

大场景
更新编辑场景

wuweihao пре 5 година
родитељ
комит
ce60acd08a

+ 1 - 1
gis_application/src/main/resources/application-dev.properties

@@ -52,7 +52,7 @@ logging.config=classpath:logback-spring.xml
 logging.level.com.gis=debug
 
 # ±¾µØ±£´æÂ·¾¶
-file.path=F:\\test\\ngin\\
+file.path=F:\\test\\ngin\\bin_scene\\
 server.domain =http://192.168.0.135/
 
 # ÆßÅ£ oss info

+ 1 - 1
gis_application/src/main/resources/application-sit.properties

@@ -33,7 +33,7 @@ spring.datasource.druid.stat-view-servlet.enabled=true
 spring.redis.database=0
 spring.redis.host=127.0.0.1
 spring.redis.port=6379
-spring.redis.password=
+spring.redis.password=4dage
 # 连接超时时间 单位 ms(毫秒)
 spring.redis.timeout=3000ms
 # 连接池中的最大空闲连接,默认值也是8。

+ 1 - 6
gis_common/src/main/java/com/gis/common/constant/TypeCode.java

@@ -6,11 +6,6 @@ package com.gis.common.constant;
 public class TypeCode {
 
     /**redis token 前缀*/
-    public static final String REDIS_LOGIN_TOKEN = "ding_token_";
+    public static final String REDIS_LOGIN_TOKEN = "cms_big_scene_";
 
-    /**api token key*/
-    public static final String TOKEN_API_KEY = "apiKey";
-
-    /**文件外键id前缀*/
-    public static final String FILE_GOODS = "goods_";
 }

+ 2 - 11
gis_domain/src/main/java/com/gis/domain/po/SceneEntity.java

@@ -29,19 +29,10 @@ public class SceneEntity extends BaseEntity implements Serializable {
     @ApiModelProperty(value = "简介")
     private String description;
 
-    @ApiModelProperty(value = "提交用户Id")
-    private Long submitId;
 
-    @ApiModelProperty(value = "审核者Id")
-    private Long auditId;
+    @ApiModelProperty(value = "oss存放地址")
+    private String ossPath;
 
-    @ApiModelProperty(value = "状态,1:草稿中,2:待审核,3:审核不通过,4:审核通过")
-    private Integer status;
 
-    @ApiModelProperty(value = "原因")
-    private String reason;
-
-    @ApiModelProperty(value = "是否显示,1:是, 0:否")
-    private Integer display;
 
 }

+ 2 - 2
gis_service/src/main/java/com/gis/service/impl/SceneServiceImpl.java

@@ -60,8 +60,8 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, Long> implem
         String sceneCode = param.getSceneCode();
         SceneEntity entity = entityMapper.findBySceneCode(param.getSceneCode());
         if (entity == null) {
-            log.error("对象不存在:{}", sceneCode);
-            return Result.failure("对象不存在");
+            log.error("场景不存在:{}", sceneCode);
+            return Result.failure("场景不存在");
         }
 
         // 1. 从oss下载vision.modeldata

+ 203 - 115
gis_web/src/main/java/com/gis/web/controller/ApiController.java

@@ -35,6 +35,7 @@ import java.io.IOException;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * Created by owen on 2020/6/10 0010 10:44
@@ -136,116 +137,116 @@ public class ApiController extends BaseController {
 
 
 
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "sceneCode", value = "场景码", required = true),
-            @ApiImplicitParam(name = "param", value = "Map传参", required = true),
-    })
-    @ApiOperation(value = "Map表单上传多文件,指定保存路径,需要用postman测试", notes = "自定义上传位置")
-    @PostMapping("uploads")
-    public Result uploads(@RequestParam Map<String, MultipartFile> param, String sceneCode) throws Exception {
-
-        SceneEntity entity = sceneService.findBySceneCode(sceneCode);
-        if (entity != null) {
-            log.error("场景码已存在,请更换新场景码: {}", sceneCode);
-            return Result.failure("场景码已存在,请更换新场景码");
-        }
-
-        // 服务器文件路径
-        String serverPath = FILE_PATH + sceneCode;
-
-        // oss文件路径
-        String ossPath = OSS_PATH + sceneCode;
-
-
-        // oss上传封装
-        HashMap<String, String> ossMap = new HashMap<>();
-
-        param.forEach((path, file)->{
-
-            if (StringUtils.isBlank(path)) {
-                log.error("保存路径不能为空");
-            }
-
-            if (file == null) {
-                log.error("文件不能为空");
-            }
-
-            String filePath = serverPath + path;
-            log.info("savePath: {}", filePath);
-            try {
-                FileUtil.writeFromStream(file.getInputStream(), filePath);
-                ossMap.put(filePath, ossPath + path);
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-
-        });
-
-        log.info("文件上传完成");
-
-        entity = new SceneEntity();
-        entity.setSceneCode(sceneCode);
-        entity.setPath(FILE_PATH + sceneCode);
-        entity.setUpdateTime(new Date());
-
-
-        // 这个可以编辑的时候创建也可以
-//        createData2Js(entity.getPath());
-//        log.info("data2.js创建完成");
-
-//        AliyunOssUtil.uploadMulFiles(ossMap);
-        QiniuOssUtil.uploads(ossMap);
-        log.info("oss文件上传完成");
-
-
-        // 调用算法切图片转换
-//        String cmd = ConstantCmd.SLICE_SKYBOX + entity.getPath();
-//        log.info("cmd:{}", cmd);
-//        CreateObjUtil.callshell(cmd);
-//        log.info("算法切片完成");
-
-
-        // 调用算法将obj转txt
-//        String objCmd = ConstantCmd.OBJ_TO_TXT + entity.getPath();
-//        log.info("objCmd:{}", objCmd);
-//        CreateObjUtil.callshell(objCmd);
-//        log.info("算法obj转txt完成");
-
-
-        // 转换文件
-//        convert(entity.getPath(), sceneCode, sceneTitle);
-//        log.info("文件转换完成");
-
-        // 场景url
-        String webSite = SERVER_DOMAIN + "SuperTwo/index.html?m=" + sceneCode;
-        log.info("webSite: {}", webSite);
-
-
-        entity.setWebSite(webSite);
-        sceneService.save(entity);
-
-
-        return Result.success(entity);
-    }
-
+//    @ApiImplicitParams({
+//            @ApiImplicitParam(name = "sceneCode", value = "场景码", required = true),
+//            @ApiImplicitParam(name = "param", value = "Map传参", required = true),
+//    })
+//    @ApiOperation(value = "Map表单上传多文件,指定保存路径,需要用postman测试", notes = "自定义上传位置")
+//    @PostMapping("uploads")
+//    public Result uploads(@RequestParam Map<String, MultipartFile> param, String sceneCode) throws Exception {
+//
+//        SceneEntity entity = sceneService.findBySceneCode(sceneCode);
+//        if (entity != null) {
+//            log.error("场景码已存在,请更换新场景码: {}", sceneCode);
+//            return Result.failure("场景码已存在,请更换新场景码");
+//        }
+//
+//        // 服务器文件路径
+//        String serverPath = FILE_PATH + sceneCode;
+//
+//        // oss文件路径
+//        String ossPath = OSS_PATH + sceneCode;
+//
+//
+//        // oss上传封装
+//        HashMap<String, String> ossMap = new HashMap<>();
+//
+//        param.forEach((path, file)->{
+//
+//            if (StringUtils.isBlank(path)) {
+//                log.error("保存路径不能为空");
+//            }
+//
+//            if (file == null) {
+//                log.error("文件不能为空");
+//            }
+//
+//            String filePath = serverPath + path;
+//            log.info("savePath: {}", filePath);
+//            try {
+//                FileUtil.writeFromStream(file.getInputStream(), filePath);
+//                ossMap.put(filePath, ossPath + path);
+//            } catch (IOException e) {
+//                e.printStackTrace();
+//            }
+//
+//        });
+//
+//        log.info("文件上传完成");
+//
+//        entity = new SceneEntity();
+//        entity.setSceneCode(sceneCode);
+//        entity.setPath(FILE_PATH + sceneCode);
+//        entity.setUpdateTime(new Date());
+//
+//
+//        // 这个可以编辑的时候创建也可以
+////        createData2Js(entity.getPath());
+////        log.info("data2.js创建完成");
+//
+////        AliyunOssUtil.uploadMulFiles(ossMap);
+//        QiniuOssUtil.uploads(ossMap);
+//        log.info("oss文件上传完成");
+//
+//
+//        // 调用算法切图片转换
+////        String cmd = ConstantCmd.SLICE_SKYBOX + entity.getPath();
+////        log.info("cmd:{}", cmd);
+////        CreateObjUtil.callshell(cmd);
+////        log.info("算法切片完成");
+//
+//
+//        // 调用算法将obj转txt
+////        String objCmd = ConstantCmd.OBJ_TO_TXT + entity.getPath();
+////        log.info("objCmd:{}", objCmd);
+////        CreateObjUtil.callshell(objCmd);
+////        log.info("算法obj转txt完成");
+//
+//
+//        // 转换文件
+////        convert(entity.getPath(), sceneCode, sceneTitle);
+////        log.info("文件转换完成");
+//
+//        // 场景url
+//        String webSite = SERVER_DOMAIN + "SuperTwo/index.html?m=" + sceneCode;
+//        log.info("webSite: {}", webSite);
+//
+//
+//        entity.setWebSite(webSite);
+//        sceneService.save(entity);
+//
+//
+//        return Result.success(entity);
+//    }
 
-    /**
-     * 创建场景码
-     */
-    private String createSceneCode() {
-        String code = null;
-        boolean flag = true;
-        while (flag) {
-            code = RandomUtils.randowString(9);
-            code = "b_" +code;
-            SceneEntity e = sceneService.findBySceneCode(code);
-            if (e == null) {
-                break;
-            }
-        }
 
-        return code;
-    }
+//    /**
+//     * 创建场景码
+//     */
+//    private String createSceneCode() {
+//        String code = null;
+//        boolean flag = true;
+//        while (flag) {
+//            code = RandomUtils.randowString(9);
+//            code = "b_" +code;
+//            SceneEntity e = sceneService.findBySceneCode(code);
+//            if (e == null) {
+//                break;
+//            }
+//        }
+//
+//        return code;
+//    }
 
 
     @ApiOperation("漫游可行")
@@ -712,7 +713,18 @@ public class ApiController extends BaseController {
 
         String hots = param.getHots();
         if (hots != null) {
-            data2Json.put("hots", JSONObject.parseObject(hots));
+            // 获取所有key
+            JSONObject hotJson = JSONObject.parseObject(hots);
+
+            Set<String> strings = hotJson.keySet();
+            for (String key: strings) {
+                JSONObject subJson = hotJson.getJSONObject(key);
+                String url  = "https://www.4dmodel.com/SuperTwo/hot_online/index.html?m=" + key;
+                // 将link 添加进去
+                subJson.put("link", url);
+            }
+            data2Json.put("hots", hotJson);
+//            log.info("hots: {}", hotJson);
         } else {
             data2Json.put("hots", new JSONObject());
         }
@@ -746,13 +758,85 @@ public class ApiController extends BaseController {
         QiniuOssUtil.upload(data2Path, OSS_PATH + sceneCode + "/" + data2Name);
         log.info(data2Name+ "已上传到七牛云");
 
+        //处理data.js 文件
+        editDataJs(sceneCode, entity, hots);
+
 
         return Result.success();
     }
 
 
+    /**
+     * 处理data.js 文件
+     */
+    private void editDataJs(String sceneCode, SceneEntity entity, String hots ) throws QiniuException {
+
+        // 因为data.js只是热点信息,所以直接创建上传oss
+        JSONObject dataJsJson = new JSONObject();
+        if (hots != null) {
+             dataJsJson = JSONObject.parseObject(hots);
+
+            Set<String> strings = dataJsJson.keySet();
+            for (String key: strings) {
+                JSONObject subJson = dataJsJson.getJSONObject(key);
+                JSONObject infoAttribute = subJson.getJSONObject("infoAttribute");
+                if (infoAttribute != null) {
+                    Set<String> infoKey = infoAttribute.keySet();
+
+                    for (String s: infoKey) {
+                        Object val = null;
+                        // 添加到第一层, 空值不添加
+                        if ("images".equals(s) || "styleImg".equals(s) || "model".equals(s) || "video".equals(s) || "iframe".equals(s)) {
+                            JSONArray jsonArray = infoAttribute.getJSONArray(s);
+                            if (jsonArray.size() == 0) {
+                                continue;
+                            }
+                            val = jsonArray;
+
+                        } else {
+                           String a = infoAttribute.getString(s);
+                            if (StringUtils.isBlank(a)){
+                                continue;
+                            }
+                            val = a;
+                        }
+
+
+                        subJson.put(s, val);
+                    }
+
+                }
+
+                // 删除infoAttribute
+                subJson.remove("infoAttribute");
+
+            }
+
+        }
+        String dataPath = entity.getPath() + "/data.js";
+        FileUtil.writeUtf8String(dataJsJson.toJSONString(), dataPath);
+//        log.info("data.js {}", dataJsJson);
+
+
+
+
+        //上传oss
+        String ossPath = OSS_PATH + sceneCode + "/hot/js/data.js";
+        QiniuOssUtil.upload(dataPath, ossPath);
+        log.info("data.js已上传到七牛云: {}", ossPath);
+
+
+    }
+
 
-    @ApiOperation(value = "上传", notes = "编辑场景使用,根据场景码位置上传")
+    /**
+     * 编辑场景上传多媒体资料
+     * @param file
+     * @param sceneCode
+     * @return
+     * @throws IOException
+     */
+    @ApiOperation(value = "编辑场景上传", notes = "编辑场景使用,根据场景码位置上传")
     @PostMapping(value = "upload/{sceneCode}", consumes = {"multipart/form-data"})
     public Result upload(MultipartFile file , @PathVariable String sceneCode) throws IOException {
 
@@ -767,14 +851,18 @@ public class ApiController extends BaseController {
             return Result.failure("场景不存在");
         }
 
-        String fileName = file.getOriginalFilename();
-        String savePath = entity.getPath() + "/edit/" + fileName;
-        FileUtil.writeFromStream(file.getInputStream(), savePath);
+        String basePath = entity.getPath() + "/edit/";
+        // 时间戳重新命名
+        HashMap<String, String> map = FileUtils.upload(file, basePath);
+        String newName = map.get("newName");
+        String savePath = basePath + newName;
+
         log.info("文件写入成功: {}", savePath);
 
         // 上传到oss
-        String ossPath = OSS_DOMAIN + OSS_PATH + sceneCode + "/edit/" + fileName;
-        QiniuOssUtil.upload(savePath, ossPath);
+        String ossUploadPath = OSS_PATH + sceneCode + "/edit/" + newName;
+        String ossPath = OSS_DOMAIN + ossUploadPath;
+        QiniuOssUtil.upload(savePath, ossUploadPath);
         log.info("文件上传到oss完成: {}", ossPath);
 
         // 返回前端数据

+ 11 - 11
gis_web/src/main/java/com/gis/web/controller/FileController.java

@@ -27,6 +27,7 @@ import java.util.Map;
 /**
  * Created by owen on 2020/5/9 0018 12:17
  */
+@ApiIgnore
 @Log4j2
 @Api(tags = "文件服务")
 @RestController
@@ -42,7 +43,7 @@ public class FileController extends BaseController {
      * @return
      * @throws IOException
      */
-    @ApiOperation(value = "上传", notes = "图片自动生成缩略图")
+    @ApiOperation(value = "上传")
     @PostMapping(value = "upload", consumes = {"multipart/form-data"})
     public Result upload(MultipartFile file) throws IOException {
 
@@ -52,8 +53,7 @@ public class FileController extends BaseController {
         }
 
         // 写入本地服务器
-        String basePath = FILE_PATH + "media/";
-        HashMap<String, String> fileInfo = FileUtils.upload(file, basePath);
+        HashMap<String, String> fileInfo = FileUtils.upload(file, FILE_PATH);
 
 
         // 保存db
@@ -71,14 +71,14 @@ public class FileController extends BaseController {
 
 
         // 图片生成缩略图
-        if (ifImage(newName)) {
-
-            String thumbPath = basePath + "thumb_" + newName;
-            createThumb(filePath, thumbPath);
-
-            String thumbUrl = SERVER_DOMAIN+"data/media/thumb_" + newName;
-            entity.setThumb(thumbUrl);
-        }
+//        if (ifImage(newName)) {
+//
+//            String thumbPath = basePath + "thumb_" + newName;
+//            createThumb(filePath, thumbPath);
+//
+//            String thumbUrl = SERVER_DOMAIN+"data/media/thumb_" + newName;
+//            entity.setThumb(thumbUrl);
+//        }
 
 
         fileService.save(entity);

+ 251 - 136
gis_web/src/main/java/com/gis/web/controller/SceneController.java

@@ -3,9 +3,12 @@ package com.gis.web.controller;
 import cn.hutool.core.io.FileUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.gis.common.util.FileUtils;
+import com.gis.common.util.QiniuOssUtil;
 import com.gis.common.util.Result;
 import com.gis.domain.dto.PageDto;
 import com.gis.domain.dto.SceneDataDto;
+import com.gis.domain.po.FileEntity;
 import com.gis.domain.po.SceneEntity;
 import com.gis.mapper.SceneMapper;
 import com.gis.service.SceneService;
@@ -13,25 +16,30 @@ import com.gis.web.aop.WebControllerLog;
 import com.github.pagehelper.PageInfo;
 import com.github.xiaoymin.knife4j.annotations.ApiSort;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.log4j.Log4j2;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.shiro.authz.annotation.Logical;
 import org.apache.shiro.authz.annotation.RequiresRoles;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.validation.Valid;
+import java.io.IOException;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 
 /**
  * Created by owen on 2020/5/8 0008 9:54
  */
-@RequiresRoles(value = {"sys_admin", "sys_high", "sys_normal"}, logical = Logical.OR)
 @Log4j2
 @Api(tags = "大场景")
-@ApiSort(value = 2)
 @RestController
 @RequestMapping("manage/scene")
 public class SceneController extends BaseController {
@@ -53,125 +61,125 @@ public class SceneController extends BaseController {
         return Result.success(page);
     }
 
-    @ApiOperation("场景编辑")
-    @PostMapping("edit")
-    public Result edit(@Valid @RequestBody SceneDataDto param) {
-
-        SceneEntity entity = sceneService.findBySceneCode(param.getSceneCode());
-        if (entity == null) {
-            log.error("场景不存在 : {}", param.getSceneCode());
-            return Result.failure("场景不存在");
-        }
-
-
-
-        // 处理someData.json
-        // 下载someData.json
-
-        String someDataPath = entity.getPath() + "/someData.json";
-        if (!FileUtil.isFile(someDataPath)) {
-            log.error("someData.json文件不存在");
-            return Result.failure("someData.json文件不存在");
-        }
-
-        // 读取someDataJson
-        String someData = FileUtil.readUtf8String(someDataPath);
-        JSONObject someDataJson = JSONObject.parseObject(someData);
-
-
-
-        String info = param.getInfo();
-        String guides = param.getGuides();
-        JSONArray guidesArray = new JSONArray();
-        if (guides != null) {
-            guidesArray = JSONObject.parseArray(guides);
-
-        }
-
-
-        if (info != null) {
-            JSONObject infoJson = JSONObject.parseObject(info);
-
-            // 处理model
-            JSONObject model = someDataJson.getJSONObject("model");
-            if (model != null) {
-                model.put("name", infoJson.get("name"));
-                model.put("summary", infoJson.get("summary"));
-                model.put("camera_start", infoJson.getJSONObject("camera_start"));
-//                model.put("camera_start", infoJson.get("camera_start"));
-
-                if (guidesArray != null) {
-                    model.put("images", guidesArray);
-                }
-
-
-            }
-
-            // 更新someDataJson
-            someDataJson.put("model", model);
-            someDataJson.put("loadlogo", infoJson.get("loadlogo"));
-
-            // 删除旧someDataJson
-            FileUtil.del(someDataPath);
-            // 写入新someDataJson
-            FileUtil.writeUtf8String(someDataJson.toJSONString(), someDataPath);
-            log.info("someData.json写入完成");
-        }
-
-        // 处理data2.js
-        String data2Path = entity.getPath() + "/data2.js";
-        boolean file = FileUtil.isFile(data2Path);
-        if (!file) {
-            log.error("data2.js文件不存在");
-            return Result.failure("data2.js文件不存在");
-        }
-
-        String data2 = FileUtil.readUtf8String(data2Path);
-        JSONObject data2Json = JSONObject.parseObject(data2);
-
-        String tourAudio = param.getTourAudio();
-        if (tourAudio != null) {
-            data2Json.put("tourAudio", JSONObject.parseObject(tourAudio));
-//            data2Json.put("tourAudio", tourAudio);
-        }
-
-        String overlays = param.getOverlays();
-        if (overlays != null) {
-            data2Json.put("overlays", JSONObject.parseObject(overlays));
-//            data2Json.put("overlays", overlays);
-        }
-
-        String hots = param.getHots();
-        if (hots != null) {
-            data2Json.put("hots", JSONObject.parseObject(hots));
-//            data2Json.put("hots", hots);
-        }
-
-        // 处理guidesArray,将scan_id的值作为key, value:  time":40000
-        JSONObject audioJson = new JSONObject();
-        JSONObject timeJson = new JSONObject();
-        timeJson.put("time", 40000);
-        if (guidesArray != null) {
-
-            for (int i = 0; i < guidesArray.size() ; i++) {
-                String scanId = guidesArray.getJSONObject(i).getString("scan_id");
-                audioJson.put(scanId, timeJson);
-            }
-
-            data2Json.put("audio", audioJson);
-        }
-
-
-        // 删除旧data2.js
-        FileUtil.del(data2Path);
-        // 写入新data2.js
-        FileUtil.writeUtf8String(data2Json.toJSONString(), data2Path);
-        log.info("新data2.js写入完成");
-
-
-
-        return Result.success();
-    }
+//    @ApiOperation("场景编辑")
+//    @PostMapping("edit")
+//    public Result edit(@Valid @RequestBody SceneDataDto param) {
+//
+//        SceneEntity entity = sceneService.findBySceneCode(param.getSceneCode());
+//        if (entity == null) {
+//            log.error("场景不存在 : {}", param.getSceneCode());
+//            return Result.failure("场景不存在");
+//        }
+//
+//
+//
+//        // 处理someData.json
+//        // 下载someData.json
+//
+//        String someDataPath = entity.getPath() + "/someData.json";
+//        if (!FileUtil.isFile(someDataPath)) {
+//            log.error("someData.json文件不存在");
+//            return Result.failure("someData.json文件不存在");
+//        }
+//
+//        // 读取someDataJson
+//        String someData = FileUtil.readUtf8String(someDataPath);
+//        JSONObject someDataJson = JSONObject.parseObject(someData);
+//
+//
+//
+//        String info = param.getInfo();
+//        String guides = param.getGuides();
+//        JSONArray guidesArray = new JSONArray();
+//        if (guides != null) {
+//            guidesArray = JSONObject.parseArray(guides);
+//
+//        }
+//
+//
+//        if (info != null) {
+//            JSONObject infoJson = JSONObject.parseObject(info);
+//
+//            // 处理model
+//            JSONObject model = someDataJson.getJSONObject("model");
+//            if (model != null) {
+//                model.put("name", infoJson.get("name"));
+//                model.put("summary", infoJson.get("summary"));
+//                model.put("camera_start", infoJson.getJSONObject("camera_start"));
+////                model.put("camera_start", infoJson.get("camera_start"));
+//
+//                if (guidesArray != null) {
+//                    model.put("images", guidesArray);
+//                }
+//
+//
+//            }
+//
+//            // 更新someDataJson
+//            someDataJson.put("model", model);
+//            someDataJson.put("loadlogo", infoJson.get("loadlogo"));
+//
+//            // 删除旧someDataJson
+//            FileUtil.del(someDataPath);
+//            // 写入新someDataJson
+//            FileUtil.writeUtf8String(someDataJson.toJSONString(), someDataPath);
+//            log.info("someData.json写入完成");
+//        }
+//
+//        // 处理data2.js
+//        String data2Path = entity.getPath() + "/data2.js";
+//        boolean file = FileUtil.isFile(data2Path);
+//        if (!file) {
+//            log.error("data2.js文件不存在");
+//            return Result.failure("data2.js文件不存在");
+//        }
+//
+//        String data2 = FileUtil.readUtf8String(data2Path);
+//        JSONObject data2Json = JSONObject.parseObject(data2);
+//
+//        String tourAudio = param.getTourAudio();
+//        if (tourAudio != null) {
+//            data2Json.put("tourAudio", JSONObject.parseObject(tourAudio));
+////            data2Json.put("tourAudio", tourAudio);
+//        }
+//
+//        String overlays = param.getOverlays();
+//        if (overlays != null) {
+//            data2Json.put("overlays", JSONObject.parseObject(overlays));
+////            data2Json.put("overlays", overlays);
+//        }
+//
+//        String hots = param.getHots();
+//        if (hots != null) {
+//            data2Json.put("hots", JSONObject.parseObject(hots));
+////            data2Json.put("hots", hots);
+//        }
+//
+//        // 处理guidesArray,将scan_id的值作为key, value:  time":40000
+//        JSONObject audioJson = new JSONObject();
+//        JSONObject timeJson = new JSONObject();
+//        timeJson.put("time", 40000);
+//        if (guidesArray != null) {
+//
+//            for (int i = 0; i < guidesArray.size() ; i++) {
+//                String scanId = guidesArray.getJSONObject(i).getString("scan_id");
+//                audioJson.put(scanId, timeJson);
+//            }
+//
+//            data2Json.put("audio", audioJson);
+//        }
+//
+//
+//        // 删除旧data2.js
+//        FileUtil.del(data2Path);
+//        // 写入新data2.js
+//        FileUtil.writeUtf8String(data2Json.toJSONString(), data2Path);
+//        log.info("新data2.js写入完成");
+//
+//
+//
+//        return Result.success();
+//    }
 
 
     /**
@@ -205,24 +213,131 @@ public class SceneController extends BaseController {
     }
 
 
-    /**
-     * 只有一个场景是显示状态
-     */
-    @ApiOperation("场景显示")
-    @GetMapping("display/{id}")
-    public Result display(@PathVariable Long id) {
-        SceneEntity entity = sceneService.findById(id);
-        if (entity == null) {
-            log.error("对象id不存在 : {}", id);
-            return Result.failure("对象id不存在");
+//    /**
+//     * 只有一个场景是显示状态
+//     */
+//    @ApiOperation("场景显示")
+//    @GetMapping("display/{id}")
+//    public Result display(@PathVariable Long id) {
+//        SceneEntity entity = sceneService.findById(id);
+//        if (entity == null) {
+//            log.error("对象id不存在 : {}", id);
+//            return Result.failure("对象id不存在");
+//        }
+//
+//        // 把所有禁止
+//        sceneMapper.setDisable();
+//        // 开启对应id
+//        sceneMapper.setDisplay(id);
+//
+//        return Result.success();
+//    }
+
+
+//    @ApiOperation(value = "场景上传")
+//    @PostMapping(value = "upload", consumes = {"multipart/form-data"})
+//    public Result upload(MultipartFile file, String sceneCode) throws IOException {
+//
+//        if (file == null) {
+//            log.error("文件不能为空");
+//            return Result.failure("文件不能为空");
+//        }
+//
+//        String basePath = FILE_PATH + sceneCode + "/";
+//
+//        String fileName = file.getOriginalFilename();
+//        String savePath = basePath + fileName;
+//
+//        FileUtil.writeFromStream(file.getInputStream(), savePath);
+//
+//        // 上传到oss
+//        String ossPath = OSS_DOMAIN + OSS_PATH + fileName;
+//        QiniuOssUtil.upload(savePath, ossPath);
+//        log.info("文件上传到oss完成: {}", ossPath);
+//
+//        // 返回前端数据
+//        return Result.success();
+//
+//    }
+
+
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "sceneCode", value = "场景码", required = true),
+            @ApiImplicitParam(name = "param", value = "Map传参", required = true),
+    })
+    @ApiOperation(value = "场景上传", notes = "自定义上传位置,Map表单上传多文件,指定保存路径,需要用postman测试")
+    @PostMapping("uploads")
+    public Result uploads(@RequestParam Map<String, MultipartFile> param, String sceneCode) throws Exception {
+
+        SceneEntity entity = sceneService.findBySceneCode(sceneCode);
+        if (entity != null) {
+            log.error("场景码已存在,请更换新场景码: {}", sceneCode);
+            return Result.failure("场景码已存在,请更换新场景码");
         }
 
-        // 把所有禁止
-        sceneMapper.setDisable();
-        // 开启对应id
-        sceneMapper.setDisplay(id);
+        // 服务器文件路径
+        String serverPath = FILE_PATH + sceneCode;
 
-        return Result.success();
+        // oss文件路径
+        String ossPath = OSS_PATH + sceneCode;
+
+
+        // oss上传封装
+        HashMap<String, String> ossMap = new HashMap<>();
+
+        param.forEach((path, file)->{
+
+            if (StringUtils.isBlank(path)) {
+                log.error("保存路径不能为空");
+            }
+
+            if (file == null) {
+                log.error("文件不能为空");
+            }
+
+            String filePath = serverPath + path;
+            log.info("savePath: {}", filePath);
+            try {
+                FileUtil.writeFromStream(file.getInputStream(), filePath);
+                ossMap.put(filePath, ossPath + path);
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+
+        });
+
+        // 创建data.js、 data2.js
+        String data2Info = "/data2.js";
+//        String dataInfo = "/hot/js/data2.js";
+
+        String data2Path = serverPath + data2Info;
+//        String dataPath = serverPath + dataInfo;
+
+        FileUtil.writeUtf8String("{}", data2Path);
+//        FileUtil.writeUtf8String("{}", dataPath);
+
+        ossMap.put(data2Path, ossPath + data2Info);
+//        ossMap.put(dataPath, ossPath + dataInfo);
+        log.info("文件上传完成");
+
+        QiniuOssUtil.uploads(ossMap);
+        log.info("oss文件上传完成");
+
+
+
+        // 场景url
+        String webSite = SERVER_DOMAIN + "SuperTwo/index.html?m=" + sceneCode;
+        log.info("webSite: {}", webSite);
+
+
+        entity = new SceneEntity();
+        entity.setSceneCode(sceneCode);
+        entity.setWebSite(webSite);
+        entity.setPath(serverPath);
+        entity.setOssPath(ossPath);
+        sceneService.save(entity);
+
+        return Result.success(entity);
     }
 
 

+ 160 - 158
gis_web/src/main/java/com/gis/web/controller/SysUserController.java

@@ -1,161 +1,163 @@
-package com.gis.web.controller;
-
-
-import com.gis.common.util.PasswordUtils;
-import com.gis.common.util.Result;
-import com.gis.domain.po.SysUserEntity;
-import com.gis.domain.dto.PageDto;
-import com.gis.domain.dto.PasswordRequest;
-import com.gis.domain.dto.UserDto;
-import com.gis.service.SysUserService;
-import com.github.pagehelper.PageInfo;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import lombok.extern.log4j.Log4j2;
-import org.apache.shiro.authz.annotation.Logical;
-import org.apache.shiro.authz.annotation.RequiresRoles;
-import org.springframework.beans.BeanUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.bind.annotation.*;
-
-import javax.validation.Valid;
-import java.util.Date;
-
-
-/**
- * Created by owen on 2020/2/18 0018 12:17
- */
-@Log4j2
-@Api(tags = "s用户管理")
-@RestController
-@RequestMapping("manage/user")
-@Transactional
-public class SysUserController extends BaseController {
-
-    @Autowired
-    public SysUserService userService;
-
-    @Autowired
-    public RedisTemplate<Object, Object> redisTemplate;
-
-
-
-    @RequiresRoles(value = {"sys_admin"}, logical = Logical.OR)
-    @ApiOperation("用户列表")
-    @PostMapping("list")
-    public Result<SysUserEntity> list(@RequestBody PageDto param) {
-        startPage(param);
-        PageInfo<SysUserEntity> page = new PageInfo<>(userService.findAll());
-        return Result.success(page);
-    }
-
-    @RequiresRoles(value = {"sys_admin"}, logical = Logical.OR)
-    @ApiOperation("新增/修改用户信息")
-    @PostMapping("save")
-    public Result save(@Valid @RequestBody UserDto param) {
-
-        SysUserEntity entity = null;
-        if (param.getId() == null) {
-            entity = userService.findByUserName(param.getUserName());
-            if (entity != null) {
-                return Result.failure("用户名已存在");
-            }
-            entity = new SysUserEntity();
-            BeanUtils.copyProperties(param, entity);
-            entity.setPassword(PasswordUtils.encrypt(param.getUserName(), "123456", PasswordUtils.getStaticSalt()));
-            userService.save(entity);
-        } else {
-            entity = userService.findById(param.getId());
-            if (entity == null) {
-                log.error("用户不存在: {}", param.getId());
-                return Result.failure("用户不存在");
-            }
-            BeanUtils.copyProperties(param, entity);
-            entity.setUpdateTime(new Date());
-            userService.update(entity);
-        }
-
-        return Result.success();
-    }
-
-
-    @ApiOperation("查询用户信息")
-    @GetMapping("detail/{id}")
-    public Result<SysUserEntity> detail(@PathVariable Long id) {
-        SysUserEntity user = userService.findById(id);
-
-        if (user == null) {
-            log.error("用户不存在: {}", id);
-            return Result.failure("用户不存在");
-        }
-        return Result.success(user);
-    }
-
-    @ApiOperation("修改密码")
-    @PostMapping("updatePwd")
-    public Result updatePwd(@Valid @RequestBody PasswordRequest param) {
-
-        SysUserEntity user = userService.findByUserName(getTokenUserName());
-
-        // 验证原密码
-        Boolean isBoolean = PasswordUtils.decrypt(user.getPassword(), param.getOldPassword(), PasswordUtils.getStaticSalt());
-        if (!isBoolean) {
-            log.error("原始密码错误");
-            return Result.failure("原始密码错误");
-        }
-
-        user.setPassword(PasswordUtils.encrypt(user.getUserName(), param.getNewPassword(), PasswordUtils.getStaticSalt()));
-        user.setUpdateTime(new Date());
-        userService.update(user);
-        return Result.success();
-    }
-
-    @RequiresRoles(value = {"sys_admin"}, logical = Logical.OR)
-    @ApiOperation("重置密码")
-    @GetMapping("resetPass/{id}")
-    public Result resetPass(@PathVariable Long id) {
-        SysUserEntity user = userService.findById(id);
-
-        if (user == null) {
-            log.error("用户不存在: {}", id);
-            return Result.failure("用户不存在");
-        }
-
-        user.setPassword(PasswordUtils.encrypt(user.getUserName(), "123456", PasswordUtils.getStaticSalt()));
-        user.setUpdateTime(new Date());
-        userService.update(user);
-        return Result.success();
-    }
-
-    @RequiresRoles(value = {"sys_admin"}, logical = Logical.OR)
-    @ApiOperation("启用、停用、注销账户")
-    @GetMapping("setStatus/{id}/{status}")
-    public Result setStatus(@PathVariable Long id, @PathVariable Integer status) {
-
-        SysUserEntity user = userService.findById(id);
-        if (user == null) {
-            log.error("用户不存在: {}", id);
-            return Result.failure("用户不存在");
-        }
-
-
-//        if (user.getSysManager() == 1) {
+//package com.gis.web.controller;
+//
+//
+//import com.gis.common.util.PasswordUtils;
+//import com.gis.common.util.Result;
+//import com.gis.domain.po.SysUserEntity;
+//import com.gis.domain.dto.PageDto;
+//import com.gis.domain.dto.PasswordRequest;
+//import com.gis.domain.dto.UserDto;
+//import com.gis.service.SysUserService;
+//import com.github.pagehelper.PageInfo;
+//import io.swagger.annotations.Api;
+//import io.swagger.annotations.ApiOperation;
+//import lombok.extern.log4j.Log4j2;
+//import org.apache.shiro.authz.annotation.Logical;
+//import org.apache.shiro.authz.annotation.RequiresRoles;
+//import org.springframework.beans.BeanUtils;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.data.redis.core.RedisTemplate;
+//import org.springframework.transaction.annotation.Transactional;
+//import org.springframework.web.bind.annotation.*;
+//import springfox.documentation.annotations.ApiIgnore;
+//
+//import javax.validation.Valid;
+//import java.util.Date;
+//
+//
+///**
+// * Created by owen on 2020/2/18 0018 12:17
+// */
+//@ApiIgnore
+//@Log4j2
+//@Api(tags = "s用户管理")
+//@RestController
+//@RequestMapping("manage/user")
+//@Transactional
+//public class SysUserController extends BaseController {
+//
+//    @Autowired
+//    public SysUserService userService;
+//
+//    @Autowired
+//    public RedisTemplate<Object, Object> redisTemplate;
+//
+//
+//
+//    @RequiresRoles(value = {"sys_admin"}, logical = Logical.OR)
+//    @ApiOperation("用户列表")
+//    @PostMapping("list")
+//    public Result<SysUserEntity> list(@RequestBody PageDto param) {
+//        startPage(param);
+//        PageInfo<SysUserEntity> page = new PageInfo<>(userService.findAll());
+//        return Result.success(page);
+//    }
+//
+//    @RequiresRoles(value = {"sys_admin"}, logical = Logical.OR)
+//    @ApiOperation("新增/修改用户信息")
+//    @PostMapping("save")
+//    public Result save(@Valid @RequestBody UserDto param) {
+//
+//        SysUserEntity entity = null;
+//        if (param.getId() == null) {
+//            entity = userService.findByUserName(param.getUserName());
+//            if (entity != null) {
+//                return Result.failure("用户名已存在");
+//            }
+//            entity = new SysUserEntity();
+//            BeanUtils.copyProperties(param, entity);
+//            entity.setPassword(PasswordUtils.encrypt(param.getUserName(), "123456", PasswordUtils.getStaticSalt()));
+//            userService.save(entity);
+//        } else {
+//            entity = userService.findById(param.getId());
+//            if (entity == null) {
+//                log.error("用户不存在: {}", param.getId());
+//                return Result.failure("用户不存在");
+//            }
+//            BeanUtils.copyProperties(param, entity);
+//            entity.setUpdateTime(new Date());
+//            userService.update(entity);
+//        }
+//
+//        return Result.success();
+//    }
+//
+//
+//    @ApiOperation("查询用户信息")
+//    @GetMapping("detail/{id}")
+//    public Result<SysUserEntity> detail(@PathVariable Long id) {
+//        SysUserEntity user = userService.findById(id);
+//
+//        if (user == null) {
+//            log.error("用户不存在: {}", id);
+//            return Result.failure("用户不存在");
+//        }
+//        return Result.success(user);
+//    }
+//
+//    @ApiOperation("修改密码")
+//    @PostMapping("updatePwd")
+//    public Result updatePwd(@Valid @RequestBody PasswordRequest param) {
+//
+//        SysUserEntity user = userService.findByUserName(getTokenUserName());
+//
+//        // 验证原密码
+//        Boolean isBoolean = PasswordUtils.decrypt(user.getPassword(), param.getOldPassword(), PasswordUtils.getStaticSalt());
+//        if (!isBoolean) {
+//            log.error("原始密码错误");
+//            return Result.failure("原始密码错误");
+//        }
+//
+//        user.setPassword(PasswordUtils.encrypt(user.getUserName(), param.getNewPassword(), PasswordUtils.getStaticSalt()));
+//        user.setUpdateTime(new Date());
+//        userService.update(user);
+//        return Result.success();
+//    }
+//
+//    @RequiresRoles(value = {"sys_admin"}, logical = Logical.OR)
+//    @ApiOperation("重置密码")
+//    @GetMapping("resetPass/{id}")
+//    public Result resetPass(@PathVariable Long id) {
+//        SysUserEntity user = userService.findById(id);
+//
+//        if (user == null) {
+//            log.error("用户不存在: {}", id);
+//            return Result.failure("用户不存在");
+//        }
+//
+//        user.setPassword(PasswordUtils.encrypt(user.getUserName(), "123456", PasswordUtils.getStaticSalt()));
+//        user.setUpdateTime(new Date());
+//        userService.update(user);
+//        return Result.success();
+//    }
+//
+//    @RequiresRoles(value = {"sys_admin"}, logical = Logical.OR)
+//    @ApiOperation("启用、停用、注销账户")
+//    @GetMapping("setStatus/{id}/{status}")
+//    public Result setStatus(@PathVariable Long id, @PathVariable Integer status) {
+//
+//        SysUserEntity user = userService.findById(id);
+//        if (user == null) {
+//            log.error("用户不存在: {}", id);
+//            return Result.failure("用户不存在");
+//        }
+//
+//
+////        if (user.getSysManager() == 1) {
+////            log.error("管理员账户不能停用/注销: {}", id);
+////            return Result.failure("管理员账户不能停用/注销");
+////        }
+//
+//        if ("sys_admin".equals(user.getRole())) {
 //            log.error("管理员账户不能停用/注销: {}", id);
 //            return Result.failure("管理员账户不能停用/注销");
 //        }
-
-        if ("sys_admin".equals(user.getRole())) {
-            log.error("管理员账户不能停用/注销: {}", id);
-            return Result.failure("管理员账户不能停用/注销");
-        }
-
-        user.setStatus(status);
-        user.setUpdateTime(new Date());
-        userService.update(user);
-        return Result.success();
-    }
-
-
-}
+//
+//        user.setStatus(status);
+//        user.setUpdateTime(new Date());
+//        userService.update(user);
+//        return Result.success();
+//    }
+//
+//
+//}

+ 7 - 6
gis_web/src/main/java/com/gis/web/shiro/MyRealm.java

@@ -1,5 +1,6 @@
 package com.gis.web.shiro;
 
+import com.gis.common.constant.TypeCode;
 import com.gis.common.exception.JwtAuthenticationException;
 import com.gis.domain.po.SysUserEntity;
 import com.gis.service.SysUserService;
@@ -92,12 +93,12 @@ public class MyRealm extends AuthorizingRealm {
         }
 
         // 校验请求token是否跟redis token一致
-//        String redisToken = redisTemplate.opsForValue().get(TypeCode.REDIS_TOKEN + token);
-//        if (!token.equals(redisToken)) {
-//            log.error("redis token is null");
-//            throw new JwtAuthenticationException(5001, "redis token is null");
-//
-//        }
+        String redisToken = redisTemplate.opsForValue().get(TypeCode.REDIS_LOGIN_TOKEN + token);
+        if (!token.equals(redisToken)) {
+            log.error("redis token is null");
+            throw new JwtAuthenticationException(5001, "redis token is null");
+
+        }
 
 
         if (! JwtUtil.isVerify(token, username)) {