|
@@ -16,6 +16,7 @@ import com.gis.domain.dto.SceneDataDto;
|
|
|
import com.gis.domain.po.SceneEntity;
|
|
|
import com.gis.service.SceneService;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
+import com.qiniu.common.QiniuException;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
@@ -29,6 +30,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
+import javax.validation.constraints.NotBlank;
|
|
|
import java.io.IOException;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
@@ -51,12 +53,11 @@ public class ApiController extends BaseController {
|
|
|
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * map的key值是json参数,value是文件
|
|
|
- * @param param
|
|
|
- * @return
|
|
|
- */
|
|
|
-
|
|
|
+// /**
|
|
|
+// * map的key值是json参数,value是文件
|
|
|
+// * @param param
|
|
|
+// * @return
|
|
|
+// */
|
|
|
// @ApiOperation("box视频上传")
|
|
|
// @PostMapping("uploadBox")
|
|
|
// @ApiImplicitParams({
|
|
@@ -596,17 +597,27 @@ public class ApiController extends BaseController {
|
|
|
|
|
|
@ApiOperation("编辑场景")
|
|
|
@PostMapping("edit")
|
|
|
- public Result edit(@Valid @RequestBody SceneDataDto param) {
|
|
|
+ public Result edit(@Valid @RequestBody SceneDataDto param) throws QiniuException {
|
|
|
|
|
|
- SceneEntity entity = sceneService.findBySceneCode(param.getSceneCode());
|
|
|
+ String sceneCode = param.getSceneCode();
|
|
|
+
|
|
|
+ SceneEntity entity = sceneService.findBySceneCode(sceneCode);
|
|
|
if (entity == null) {
|
|
|
- log.error("场景不存在 : {}", param.getSceneCode());
|
|
|
+ log.error("场景不存在 : {}", sceneCode);
|
|
|
return Result.failure("场景不存在");
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- // 处理someData.json
|
|
|
+
|
|
|
+
|
|
|
+ // 处理someData.json, 网络下载someData.json
|
|
|
+ String someDataName = "someData.json";
|
|
|
+ // 注意网络下载会有缓存,必须加时间戳
|
|
|
+ String someDataUrl = OSS_DOMAIN + OSS_PATH + sceneCode + "/" + someDataName+ "?m=" + System.currentTimeMillis();
|
|
|
+ log.info("网络下载文件地址: {}", someDataUrl);
|
|
|
+ String localBasePath = FILE_PATH + sceneCode;
|
|
|
+ FileUtils.downLoadFromUrl(someDataUrl, someDataName, localBasePath);
|
|
|
String someDataPath = entity.getPath() + "/someData.json";
|
|
|
if (!FileUtil.isFile(someDataPath)) {
|
|
|
log.error("someData.json文件不存在");
|
|
@@ -631,16 +642,18 @@ public class ApiController extends BaseController {
|
|
|
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);
|
|
|
+ } else {
|
|
|
+ model.put("images", new JSONArray());
|
|
|
}
|
|
|
|
|
|
|
|
@@ -649,15 +662,29 @@ public class ApiController extends BaseController {
|
|
|
// 更新someDataJson
|
|
|
someDataJson.put("model", model);
|
|
|
someDataJson.put("loadlogo", infoJson.get("loadlogo"));
|
|
|
+ someDataJson.put("supportsVR", infoJson.getBoolean("supportsVR"));
|
|
|
+ someDataJson.put("backgroundMusic", infoJson.getString("backgroundMusic"));
|
|
|
|
|
|
// 删除旧someDataJson
|
|
|
FileUtil.del(someDataPath);
|
|
|
// 写入新someDataJson
|
|
|
FileUtil.writeUtf8String(someDataJson.toJSONString(), someDataPath);
|
|
|
log.info("someData.json写入完成");
|
|
|
+
|
|
|
+ // 将新的someDataJson上传oss
|
|
|
+ QiniuOssUtil.upload(someDataPath, OSS_PATH + sceneCode + "/" + someDataName);
|
|
|
+ log.info(someDataName+ "已上传到七牛云");
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// 处理data2.js
|
|
|
+
|
|
|
+ String data2Name = "data2.js";
|
|
|
+ // 注意网络下载会有缓存,必须加时间戳
|
|
|
+ String data2Url = OSS_DOMAIN + OSS_PATH + sceneCode + "/" + data2Name+ "?m=" + System.currentTimeMillis();
|
|
|
+ log.info("网络下载文件地址: {}", data2Url);
|
|
|
+ FileUtils.downLoadFromUrl(data2Url, data2Name, localBasePath);
|
|
|
+
|
|
|
String data2Path = entity.getPath() + "/data2.js";
|
|
|
boolean file = FileUtil.isFile(data2Path);
|
|
|
if (!file) {
|
|
@@ -671,19 +698,23 @@ public class ApiController extends BaseController {
|
|
|
String tourAudio = param.getTourAudio();
|
|
|
if (tourAudio != null) {
|
|
|
data2Json.put("tourAudio", JSONObject.parseObject(tourAudio));
|
|
|
-// data2Json.put("tourAudio", tourAudio);
|
|
|
+ } else {
|
|
|
+ data2Json.put("tourAudio", new JSONObject());
|
|
|
}
|
|
|
|
|
|
String overlays = param.getOverlays();
|
|
|
+// log.info("overlays: {}", overlays);
|
|
|
if (overlays != null) {
|
|
|
- data2Json.put("overlays", JSONObject.parseObject(overlays));
|
|
|
-// data2Json.put("overlays", overlays);
|
|
|
+ data2Json.put("overlays", JSONObject.parseArray(overlays));
|
|
|
+ } else {
|
|
|
+ data2Json.put("overlays", new JSONArray());
|
|
|
}
|
|
|
|
|
|
String hots = param.getHots();
|
|
|
if (hots != null) {
|
|
|
data2Json.put("hots", JSONObject.parseObject(hots));
|
|
|
-// data2Json.put("hots", hots);
|
|
|
+ } else {
|
|
|
+ data2Json.put("hots", new JSONObject());
|
|
|
}
|
|
|
|
|
|
// 处理guidesArray,将scan_id的值作为key, value: time":40000
|
|
@@ -708,8 +739,12 @@ public class ApiController extends BaseController {
|
|
|
FileUtil.del(data2Path);
|
|
|
// 写入新data2.js
|
|
|
FileUtil.writeUtf8String(data2Json.toJSONString(), data2Path);
|
|
|
+// log.info("data2js: {}", data2Json);
|
|
|
log.info("新data2.js写入完成");
|
|
|
|
|
|
+ // 将新的someDataJson上传oss
|
|
|
+ QiniuOssUtil.upload(data2Path, OSS_PATH + sceneCode + "/" + data2Name);
|
|
|
+ log.info(data2Name+ "已上传到七牛云");
|
|
|
|
|
|
|
|
|
return Result.success();
|
|
@@ -735,12 +770,15 @@ public class ApiController extends BaseController {
|
|
|
String fileName = file.getOriginalFilename();
|
|
|
String savePath = entity.getPath() + "/edit/" + fileName;
|
|
|
FileUtil.writeFromStream(file.getInputStream(), savePath);
|
|
|
+ log.info("文件写入成功: {}", savePath);
|
|
|
|
|
|
- Object urlPath = SERVER_DOMAIN + "data/" + sceneCode + "/edit/" + fileName;
|
|
|
- log.info("文件写入成功: {}", urlPath);
|
|
|
+ // 上传到oss
|
|
|
+ String ossPath = OSS_DOMAIN + OSS_PATH + sceneCode + "/edit/" + fileName;
|
|
|
+ QiniuOssUtil.upload(savePath, ossPath);
|
|
|
+ log.info("文件上传到oss完成: {}", ossPath);
|
|
|
|
|
|
// 返回前端数据
|
|
|
- return Result.success(urlPath);
|
|
|
+ return Result.success((Object) ossPath);
|
|
|
|
|
|
}
|
|
|
|