|
@@ -201,207 +201,6 @@ public class SceneController extends BaseController {
|
|
|
}
|
|
|
|
|
|
|
|
|
-// @ApiOperation("编辑场景")
|
|
|
-// @PostMapping("edit")
|
|
|
-// public Result edit(@Valid @RequestBody SceneDataDto param) throws QiniuException, InterruptedException {
|
|
|
-//
|
|
|
-// String sceneCode = param.getSceneCode();
|
|
|
-//
|
|
|
-// SceneEntity entity = sceneService.findBySceneCode(sceneCode);
|
|
|
-// if (entity == null) {
|
|
|
-// log.error("场景不存在 : {}", sceneCode);
|
|
|
-// return Result.failure("场景不存在");
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// // 处理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文件不存在");
|
|
|
-// 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) {
|
|
|
-// String name = infoJson.getString("name");
|
|
|
-// model.put("name", name);
|
|
|
-//
|
|
|
-// // update 场景名称
|
|
|
-// if (!name.equals(entity.getSceneTitle())) {
|
|
|
-// entity.setSceneTitle(name);
|
|
|
-// entity.setUpdateTime(new Date());
|
|
|
-// sceneService.update(entity);
|
|
|
-// }
|
|
|
-//
|
|
|
-// model.put("summary", infoJson.get("summary"));
|
|
|
-//
|
|
|
-//// model.put("camera_start", infoJson.getJSONObject("camera_start"));
|
|
|
-//
|
|
|
-// if (guidesArray != null) {
|
|
|
-// model.put("images", guidesArray);
|
|
|
-// } else {
|
|
|
-// model.put("images", new JSONArray());
|
|
|
-// }
|
|
|
-//
|
|
|
-// // camera_start放到最外层
|
|
|
-//// someDataJson.put("camera_start", infoJson.getJSONObject("camera_start"));
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 更新someDataJson
|
|
|
-// someDataJson.put("model", model);
|
|
|
-//
|
|
|
-// // info信息添加到someDataJson最外层
|
|
|
-// Set<String> infoKey = infoJson.keySet();
|
|
|
-// for (String key : infoKey) {
|
|
|
-//
|
|
|
-// someDataJson.put(key, infoJson.get(key));
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// // 删除旧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() + 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));
|
|
|
-// } else {
|
|
|
-// data2Json.put("tourAudio", new JSONObject());
|
|
|
-// }
|
|
|
-//
|
|
|
-// String overlays = param.getOverlays();
|
|
|
-// if (overlays != null) {
|
|
|
-// data2Json.put("overlays", JSONObject.parseArray(overlays));
|
|
|
-// } else {
|
|
|
-// data2Json.put("overlays", new JSONArray());
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// // 处理guidesArray,将scan_id的值作为key, value: time":40000
|
|
|
-// JSONObject audioJson = new JSONObject();
|
|
|
-// JSONObject timeJson = new JSONObject();
|
|
|
-// 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");
|
|
|
-// 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());
|
|
|
-//
|
|
|
-// // host在data2.js、data.js都需要处理
|
|
|
-// String hots = param.getHots();
|
|
|
-// if (hots != null) {
|
|
|
-// // 获取所有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);
|
|
|
-// } else {
|
|
|
-// data2Json.put("hots", new JSONObject());
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// // 删除旧data2.js
|
|
|
-// FileUtil.del(data2Path);
|
|
|
-// // 写入新data2.js
|
|
|
-// FileUtil.writeUtf8String(data2Json.toJSONString(), data2Path);
|
|
|
-// log.info("新data2.js写入完成");
|
|
|
-//
|
|
|
-// // 将新的someDataJson上传oss
|
|
|
-// QiniuOssUtil.upload(data2Path, OSS_PATH + sceneCode + "/" + data2Name);
|
|
|
-// log.info(data2Name+ "已上传到七牛云");
|
|
|
-//
|
|
|
-// //处理data.js 文件
|
|
|
-// editDataJs(sceneCode, entity, hots);
|
|
|
-//
|
|
|
-//
|
|
|
-// return Result.success();
|
|
|
-// }
|
|
|
-
|
|
|
|
|
|
@ApiOperation("编辑场景")
|
|
|
@PostMapping("edit")
|
|
@@ -549,33 +348,6 @@ public class SceneController extends BaseController {
|
|
|
@PostMapping(value = "upload/{sceneCode}", consumes = {"multipart/form-data"})
|
|
|
public Result upload(MultipartFile file , @PathVariable String sceneCode) throws IOException {
|
|
|
|
|
|
-// Result result = sceneService.editUpload(file, sceneCode);
|
|
|
-
|
|
|
-// if (file == null) {
|
|
|
-// log.error("文件不能为空");
|
|
|
-// return Result.failure("文件不能为空");
|
|
|
-// }
|
|
|
-//
|
|
|
-// SceneEntity entity = sceneService.findBySceneCode(sceneCode);
|
|
|
-// if (entity == null) {
|
|
|
-// log.error("场景不存在: {}", sceneCode);
|
|
|
-// return Result.failure("场景不存在");
|
|
|
-// }
|
|
|
-//
|
|
|
-// 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 ossUploadPath = OSS_PATH + sceneCode + "/edit/" + newName;
|
|
|
-// String ossPath = OSS_DOMAIN + ossUploadPath;
|
|
|
-// QiniuOssUtil.upload(savePath, ossUploadPath);
|
|
|
-// log.info("文件上传到oss完成: {}", ossPath);
|
|
|
-
|
|
|
// 返回前端数据
|
|
|
return sceneService.editUpload(file, sceneCode);
|
|
|
|