|
@@ -2,8 +2,10 @@ package com.gis.web.controller;
|
|
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
import com.gis.common.util.FileUtils;
|
|
|
import com.gis.common.util.QiniuOssUtil;
|
|
|
import com.gis.common.util.Result;
|
|
@@ -21,11 +23,13 @@ import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.junit.Test;
|
|
|
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.File;
|
|
|
import java.io.IOException;
|
|
|
import java.util.*;
|
|
|
|
|
@@ -42,10 +46,6 @@ public class SceneController extends BaseController {
|
|
|
@Autowired
|
|
|
private SceneService sceneService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private SceneMapper sceneMapper;
|
|
|
-
|
|
|
-
|
|
|
|
|
|
@ApiOperation("场景列表")
|
|
|
@PostMapping("list")
|
|
@@ -111,12 +111,11 @@ public class SceneController extends BaseController {
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * 素材文件,真删除
|
|
|
+ * 软删除
|
|
|
*/
|
|
|
- @WebControllerLog(description = "大场景-删除")
|
|
|
@ApiOperation("场景删除")
|
|
|
@GetMapping("removes/{ids}")
|
|
|
- public Result detail(@PathVariable String ids) {
|
|
|
+ public Result removes(@PathVariable String ids) {
|
|
|
List<SceneEntity> entities = sceneService.findByIds(ids);
|
|
|
for (SceneEntity entity: entities) {
|
|
|
entity.setRecStatus("I");
|
|
@@ -181,7 +180,7 @@ public class SceneController extends BaseController {
|
|
|
|
|
|
@ApiOperation("编辑场景")
|
|
|
@PostMapping("edit")
|
|
|
- public Result edit(@Valid @RequestBody SceneDataDto param) throws QiniuException {
|
|
|
+ public Result edit(@Valid @RequestBody SceneDataDto param) throws QiniuException, InterruptedException {
|
|
|
|
|
|
String sceneCode = param.getSceneCode();
|
|
|
|
|
@@ -275,16 +274,20 @@ public class SceneController extends BaseController {
|
|
|
log.info("网络下载文件地址: {}", data2Url);
|
|
|
FileUtils.downLoadFromUrl(data2Url, data2Name, localBasePath);
|
|
|
|
|
|
- String data2Path = entity.getPath() + "/data2.js";
|
|
|
- boolean file = FileUtil.isFile(data2Path);
|
|
|
- if (!file) {
|
|
|
- log.error("data2.js文件不存在");
|
|
|
+ String data2Path = entity.getPath() + File.separator + data2Name;
|
|
|
+ log.info("data2.js文件位置: {}", data2Path);
|
|
|
+
|
|
|
+ if (!FileUtil.exist(data2Path)) {
|
|
|
+ log.error("data2.js文件不存在: {}", data2Path);
|
|
|
return Result.failure("data2.js文件不存在");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
String data2 = FileUtil.readUtf8String(data2Path);
|
|
|
JSONObject data2Json = JSONObject.parseObject(data2);
|
|
|
|
|
|
+ log.info("old data2Json: " + data2Json.toJSONString());
|
|
|
+
|
|
|
String tourAudio = param.getTourAudio();
|
|
|
if (tourAudio != null) {
|
|
|
data2Json.put("tourAudio", JSONObject.parseObject(tourAudio));
|
|
@@ -322,17 +325,32 @@ public class SceneController extends BaseController {
|
|
|
timeJson.put("time", 40000);
|
|
|
if (guidesArray != null) {
|
|
|
|
|
|
+ // 将旧的audio字段删除
|
|
|
+ data2Json.remove("audio");
|
|
|
+
|
|
|
for (int i = 0; i < guidesArray.size() ; i++) {
|
|
|
JSONObject metadata = guidesArray.getJSONObject(i).getJSONObject("metadata");
|
|
|
if (metadata != null) {
|
|
|
String scanId = metadata.getString("scan_id");
|
|
|
- audioJson.put(scanId, timeJson);
|
|
|
+ if (scanId == null) {
|
|
|
+ log.error("guides.metadata.scan_id为空: {}", i);
|
|
|
+ return Result.failure("guides.metadata.scan_id为空: " + i);
|
|
|
+ }
|
|
|
+ // Fastjson-fastjson中$ref对象重复引用问题,拿不到想要的效果
|
|
|
+// JSONObject timeJson = new JSONObject();
|
|
|
+// timeJson.put("time", 40000);
|
|
|
+ audioJson.put(scanId, JSON.toJSONString(timeJson, SerializerFeature.DisableCircularReferenceDetect));
|
|
|
+
|
|
|
}
|
|
|
+// log.info("audioJson: " + i + ":" + audioJson.toJSONString());
|
|
|
}
|
|
|
|
|
|
+ // 新增audio
|
|
|
data2Json.put("audio", audioJson);
|
|
|
}
|
|
|
|
|
|
+ log.info("new datajs: " + data2Json.toJSONString());
|
|
|
+
|
|
|
|
|
|
// 删除旧data2.js
|
|
|
FileUtil.del(data2Path);
|
|
@@ -585,4 +603,6 @@ public class SceneController extends BaseController {
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
}
|