Kaynağa Gözat

添加了场景编辑

wuweihao 5 yıl önce
ebeveyn
işleme
70d01c960e

+ 39 - 0
gis_domain/src/main/java/com/gis/domain/dto/SceneDataDto.java

@@ -0,0 +1,39 @@
+package com.gis.domain.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import java.util.List;
+
+
+/**
+ * Created by Owen on 2019/10/28 0028 12:24
+ *
+ * 编辑场景使用
+ */
+@Data
+public class SceneDataDto {
+
+//    private String name;
+
+    @NotBlank(message = "场景码不能为空")
+    @ApiModelProperty(value = "场景码", required = true)
+    private String sceneCode;
+
+    /** data2.js */
+    private String hots;
+
+    private String guides;
+
+    /** someData.json model */
+    private String info;
+
+    /** data2.js */
+    private String tourAudio;
+
+    /** data2.js */
+    private String overlays;
+
+
+}

+ 18 - 0
gis_domain/src/main/java/com/gis/domain/po/SceneEntity.java

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

+ 1 - 1
gis_web/src/main/java/com/gis/web/controller/IndexController.java

@@ -26,7 +26,7 @@ import java.util.concurrent.TimeUnit;
 /**
  * Created by owen on 2020/2/19 0019 15:53
  */
-@Api(tags = "登录")
+@Api(tags = "s登录")
 @RestController
 @Log4j2
 public class IndexController extends BaseController{

+ 1 - 5
gis_web/src/main/java/com/gis/web/controller/LogController.java

@@ -12,24 +12,20 @@ import lombok.extern.log4j.Log4j2;
 import org.apache.shiro.authz.annotation.Logical;
 import org.apache.shiro.authz.annotation.RequiresRoles;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
-import springfox.documentation.annotations.ApiIgnore;
 
 
 /**
  * Created by owen on 2020/5/12 0018 12:17
  * 日志管理,只有admin权限访问
  */
-@ApiIgnore
 @Log4j2
-@Api(tags = "日志管理")
+@Api(tags = "s日志管理")
 @RestController
 @RequestMapping("manage/log")
-@Transactional
 @RequiresRoles(value = {"sys_admin"}, logical = Logical.OR)
 public class LogController extends BaseController {
 

+ 1 - 1
gis_web/src/main/java/com/gis/web/controller/MenuController.java

@@ -21,7 +21,7 @@ import java.util.List;
 /**
  * Created by owen on 2020/5/8 0008 9:54
  */
-@Api(tags = "菜单管理")
+@Api(tags = "s菜单管理")
 @RestController
 @RequestMapping("manage/menu")
 public class MenuController extends BaseController {

+ 2 - 1
gis_web/src/main/java/com/gis/web/controller/NewsController.java

@@ -22,7 +22,7 @@ import java.util.List;
  * Created by owen on 2020/5/8 0008 9:54
  */
 @Log4j2
-@Api(tags = "史馆动态")
+@Api(tags = "史馆动态", position = 2)
 @RestController
 @RequestMapping("manage/news")
 public class NewsController extends BaseController {
@@ -45,6 +45,7 @@ public class NewsController extends BaseController {
 
     @ApiOperation("新增/修改部信息")
     @PostMapping("save")
+
     public Result save(@Valid @RequestBody NewsRequest param) {
 
         NewsEntity entity = null;

+ 122 - 24
gis_web/src/main/java/com/gis/web/controller/SceneController.java

@@ -1,22 +1,30 @@
 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.Result;
 import com.gis.domain.dto.PageDto;
+import com.gis.domain.dto.SceneDataDto;
 import com.gis.domain.po.SceneEntity;
 import com.gis.service.SceneService;
 import com.github.pagehelper.PageInfo;
+import com.github.xiaoymin.knife4j.annotations.ApiSort;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.log4j.Log4j2;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import javax.validation.Valid;
+
 
 /**
  * Created by owen on 2020/5/8 0008 9:54
  */
 @Log4j2
-@Api(tags = "场景列表")
+@Api(tags = "场景管理")
+@ApiSort(value = 2)
 @RestController
 @RequestMapping("manage/scene")
 public class SceneController extends BaseController {
@@ -35,29 +43,119 @@ public class SceneController extends BaseController {
         return Result.success(page);
     }
 
-//    @ApiOperation("新增/修改部信息")
-//    @PostMapping("save")
-//    public Result save(@Valid @RequestBody SceneDto param) {
-//
-//        SceneEntity entity = null;
-//        if (param.getId() == null) {
-//            entity = new SceneEntity();
-//            BeanUtils.copyProperties(param, entity);
-//            sceneService.save(entity);
-//        } else {
-//            entity = sceneService.findById(param.getId());
-//            if (entity == null) {
-//                return Result.failure("对象id不存在");
-//            }
-//
-//            BeanUtils.copyProperties(param, entity);
-//            entity.setUpdateTime(new Date());
-//            sceneService.update(entity);
-//
-//        }
-//
-//        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
+        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.getJSONObject("name"));
+                model.put("summary", infoJson.getJSONObject("summary"));
+                model.put("camera_start", infoJson.getJSONObject("camera_start"));
+
+                if (guidesArray != null) {
+                    model.put("images", guidesArray);
+                }
+
+
+            }
+
+            // 更新someDataJson
+            someDataJson.put("model", model);
+            someDataJson.put("loadlogo", infoJson.getJSONObject("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));
+        }
+
+        String overlays = param.getOverlays();
+        if (overlays != null) {
+            data2Json.put("overlays", JSONObject.parseObject(overlays));
+        }
+
+        String hots = param.getHots();
+        if (hots != null) {
+            data2Json.put("hots", JSONObject.parseObject(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();
+    }
 
 
     /**

+ 2 - 0
gis_web/src/main/java/com/gis/web/controller/SysDeptController.java

@@ -13,6 +13,7 @@ import lombok.extern.log4j.Log4j2;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
+import springfox.documentation.annotations.ApiIgnore;
 
 import javax.validation.Valid;
 import java.util.Date;
@@ -21,6 +22,7 @@ import java.util.Date;
 /**
  * Created by owen on 2020/2/18 0018 12:17
  */
+@ApiIgnore
 @Log4j2
 @Api(tags = "部门管理")
 @RestController

+ 2 - 1
gis_web/src/main/java/com/gis/web/controller/SysRoleController.java

@@ -14,6 +14,7 @@ import org.apache.shiro.authz.annotation.RequiresRoles;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
+import springfox.documentation.annotations.ApiIgnore;
 
 import javax.validation.Valid;
 import java.util.Date;
@@ -22,7 +23,7 @@ import java.util.Date;
 /**
  * Created by owen on 2020/2/18 0018 12:17
  */
-//@ApiIgnore
+@ApiIgnore
 @Log4j2
 @Api(tags = "角色管理")
 @RestController

+ 2 - 1
gis_web/src/main/java/com/gis/web/controller/SysUserController.java

@@ -9,6 +9,7 @@ import com.gis.domain.dto.PasswordRequest;
 import com.gis.domain.dto.UserRequest;
 import com.gis.service.SysUserService;
 import com.github.pagehelper.PageInfo;
+import com.github.xiaoymin.knife4j.annotations.ApiSort;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.log4j.Log4j2;
@@ -28,7 +29,7 @@ import java.util.Date;
  * Created by owen on 2020/2/18 0018 12:17
  */
 @Log4j2
-@Api(tags = "用户管理")
+@Api(tags = "s用户管理")
 @RestController
 @RequestMapping("manage/user")
 @Transactional

+ 2 - 1
gis_web/src/main/java/com/gis/web/controller/TopicController.java

@@ -6,6 +6,7 @@ import com.gis.domain.po.SceneEntity;
 import com.gis.mapper.CommonMapper;
 import com.gis.service.SceneService;
 import com.github.pagehelper.PageInfo;
+import com.github.xiaoymin.knife4j.annotations.ApiSort;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.log4j.Log4j2;
@@ -20,7 +21,7 @@ import java.util.Map;
  * Created by owen on 2020/5/8 0008 9:54
  */
 @Log4j2
-@Api(tags = "主题管理")
+@Api(tags = "s主题管理", position = 1)
 @RestController
 @RequestMapping("manage/topic")
 public class TopicController extends BaseController {

+ 1 - 0
gis_web/src/main/resources/data/data2.json

@@ -0,0 +1 @@
+{"audio":{"74896eac1c444beeb1da15a27e334dda":{"time":40000}},"hots":{},"weixinDesc":"","tourAudio":{},"overlays":[]}