|
@@ -25,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.util.ResourceUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
+import springfox.documentation.annotations.ApiIgnore;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.validation.Valid;
|
|
@@ -36,6 +37,7 @@ import java.util.Map;
|
|
|
/**
|
|
|
* Created by owen on 2020/6/10 0010 10:44
|
|
|
*/
|
|
|
+@ApiIgnore
|
|
|
@Log4j2
|
|
|
@Api(tags = "场景")
|
|
|
@RestController
|
|
@@ -47,21 +49,21 @@ public class ApiController extends BaseController {
|
|
|
private SceneService sceneService;
|
|
|
|
|
|
|
|
|
- @ApiOperation("获取场景码")
|
|
|
- @PostMapping("testJson")
|
|
|
- public Result testJson(String a) {
|
|
|
- String sceneCode = RandomUtils.randowString(9);
|
|
|
- sceneCode = "ar_" +sceneCode;
|
|
|
-
|
|
|
- // 创建token,过期24h,
|
|
|
- String token = JwtUtil.createJWT(TOKEN_EXPIRE, TypeCode.TOKEN_API_KEY);
|
|
|
-
|
|
|
- HashMap<Object, Object> reuslt = new HashMap<>();
|
|
|
- reuslt.put("sceneCode", sceneCode);
|
|
|
- reuslt.put("token", token);
|
|
|
-
|
|
|
- return Result.success(reuslt);
|
|
|
- }
|
|
|
+// @ApiOperation("获取场景码")
|
|
|
+// @PostMapping("testJson")
|
|
|
+// public Result testJson(String a) {
|
|
|
+// String sceneCode = RandomUtils.randowString(9);
|
|
|
+// sceneCode = "ar_" +sceneCode;
|
|
|
+//
|
|
|
+// // 创建token,过期24h,
|
|
|
+// String token = JwtUtil.createJWT(TOKEN_EXPIRE, TypeCode.TOKEN_API_KEY);
|
|
|
+//
|
|
|
+// HashMap<Object, Object> reuslt = new HashMap<>();
|
|
|
+// reuslt.put("sceneCode", sceneCode);
|
|
|
+// reuslt.put("token", token);
|
|
|
+//
|
|
|
+// return Result.success(reuslt);
|
|
|
+// }
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -71,169 +73,169 @@ public class ApiController extends BaseController {
|
|
|
* @param request
|
|
|
* @return
|
|
|
*/
|
|
|
- @ApiOperation("box视频上传")
|
|
|
- @PostMapping("uploadBox")
|
|
|
- @ApiImplicitParams({
|
|
|
- @ApiImplicitParam(name = "sceneCode", value = "场景码", required = true),
|
|
|
- @ApiImplicitParam(name = "param", value = "Map传参", required = true),
|
|
|
- })
|
|
|
-
|
|
|
- public Result uploadBox(@RequestParam Map<String, MultipartFile> param, String sceneCode, HttpServletRequest request) throws IOException {
|
|
|
-
|
|
|
- SceneEntity entity = sceneService.findBySceneCode(sceneCode);
|
|
|
- if (entity == null) {
|
|
|
- log.error("对象不存在:{}", sceneCode);
|
|
|
- return Result.failure("场景码不存在");
|
|
|
- }
|
|
|
-
|
|
|
- // 保存位置(箭头函数传参,需要定义final, 使用时需要赋值使用)
|
|
|
- String basePath = entity.getPath();
|
|
|
- final String saveBasePath = basePath + "/boxVideo/";
|
|
|
-
|
|
|
- // box视频信息
|
|
|
- JSONArray overlaysArray = new JSONArray();
|
|
|
-
|
|
|
- param.forEach((key, file)->{
|
|
|
-
|
|
|
- if (StringUtils.isBlank(key)) {
|
|
|
- log.error("key值不能为空");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (file == null) {
|
|
|
- log.error("文件不能为空");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- String fileName = file.getOriginalFilename();
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- JSONObject keyJson = JSONObject.parseObject(key);
|
|
|
-
|
|
|
- // 给相对路径,tomcat配置静态资源让前端读取
|
|
|
- // http://192.168.0.44:8101/data/ar_I4Ef2SS4y/boxVideo/20180201_101827.mp4
|
|
|
- String boxVideoPath = "/data/" + entity.getSceneCode()+ "/boxVideo/" + fileName;
|
|
|
-// log.info("boxVideoPath: {}", boxVideoPath);
|
|
|
-
|
|
|
- // 添加视频参数到overlayJaon
|
|
|
- keyJson.put("file", boxVideoPath);
|
|
|
- overlaysArray.add(keyJson);
|
|
|
-
|
|
|
-
|
|
|
- // final值需要赋值使用
|
|
|
- String filePath = saveBasePath;
|
|
|
-
|
|
|
- filePath += fileName;
|
|
|
- log.info("filePath: {}", filePath);
|
|
|
- try {
|
|
|
-// FileUtils.upload(file, filePath);
|
|
|
- FileUtil.writeFromStream(file.getInputStream(), filePath);
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
- });
|
|
|
-
|
|
|
- JSONObject dataJson = new JSONObject();
|
|
|
- dataJson.put("overlays", overlaysArray);
|
|
|
-
|
|
|
- // 创建data2.js文件
|
|
|
- String saveDataJsonPath = basePath + "/data2.js";
|
|
|
- log.info("data2.js path :{}", saveDataJsonPath);
|
|
|
- FileUtil.writeUtf8String(dataJson.toJSONString(), saveDataJsonPath);
|
|
|
- log.info("data2.js创建完成");
|
|
|
-
|
|
|
- return Result.success(entity.getWebSite());
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- @ApiOperation(value = "Map表单上传多文件,指定保存路径,需要用postman测试", notes = "自定义上传位置")
|
|
|
- @PostMapping("uploads")
|
|
|
- public Result uploads(@RequestParam Map<String, MultipartFile> param, String sceneTitle, String sceneCode, HttpServletRequest request) throws Exception {
|
|
|
- String token = request.getHeader("token");
|
|
|
- if (token == null) {
|
|
|
- log.error("token header is null");
|
|
|
- return Result.failure("token header is null");
|
|
|
- }
|
|
|
-
|
|
|
- SceneEntity entity = sceneService.findBySceneCode(sceneCode);
|
|
|
- if (entity != null) {
|
|
|
- log.error("场景码已存在,请更换新场景码: {}", sceneCode);
|
|
|
- return Result.failure("场景码已存在,请更换新场景码");
|
|
|
- }
|
|
|
-
|
|
|
- Boolean verify = JwtUtil.isVerify(token, TypeCode.TOKEN_API_KEY);
|
|
|
- if (!verify) {
|
|
|
- log.error("api token 无效");
|
|
|
- return Result.failure("token 无效");
|
|
|
- }
|
|
|
-
|
|
|
- param.forEach((path, file)->{
|
|
|
-
|
|
|
- if (StringUtils.isBlank(path)) {
|
|
|
- log.error("保存路径不能为空");
|
|
|
- }
|
|
|
-
|
|
|
- if (file == null) {
|
|
|
- log.error("文件不能为空");
|
|
|
- throw new BaseRuntimeException("文件为空");
|
|
|
- }
|
|
|
-
|
|
|
- path = FILE_PATH + path;
|
|
|
- log.info("savePath: {}", path);
|
|
|
- try {
|
|
|
-// FileUtils.upload(file, path);
|
|
|
- FileUtil.writeFromStream(file.getInputStream(), path);
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- entity = new SceneEntity();
|
|
|
- entity.setSceneCode(sceneCode);
|
|
|
- entity.setPath(FILE_PATH + sceneCode);
|
|
|
- entity.setSceneTitle(sceneTitle);
|
|
|
- entity.setUpdateTime(new Date());
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- // 调用算法切图片转换
|
|
|
- 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.getWebSite());
|
|
|
- }
|
|
|
+// @ApiOperation("box视频上传")
|
|
|
+// @PostMapping("uploadBox")
|
|
|
+// @ApiImplicitParams({
|
|
|
+// @ApiImplicitParam(name = "sceneCode", value = "场景码", required = true),
|
|
|
+// @ApiImplicitParam(name = "param", value = "Map传参", required = true),
|
|
|
+// })
|
|
|
+//
|
|
|
+// public Result uploadBox(@RequestParam Map<String, MultipartFile> param, String sceneCode, HttpServletRequest request) throws IOException {
|
|
|
+//
|
|
|
+// SceneEntity entity = sceneService.findBySceneCode(sceneCode);
|
|
|
+// if (entity == null) {
|
|
|
+// log.error("对象不存在:{}", sceneCode);
|
|
|
+// return Result.failure("场景码不存在");
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 保存位置(箭头函数传参,需要定义final, 使用时需要赋值使用)
|
|
|
+// String basePath = entity.getPath();
|
|
|
+// final String saveBasePath = basePath + "/boxVideo/";
|
|
|
+//
|
|
|
+// // box视频信息
|
|
|
+// JSONArray overlaysArray = new JSONArray();
|
|
|
+//
|
|
|
+// param.forEach((key, file)->{
|
|
|
+//
|
|
|
+// if (StringUtils.isBlank(key)) {
|
|
|
+// log.error("key值不能为空");
|
|
|
+// return;
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (file == null) {
|
|
|
+// log.error("文件不能为空");
|
|
|
+// return;
|
|
|
+// }
|
|
|
+//
|
|
|
+// String fileName = file.getOriginalFilename();
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+// JSONObject keyJson = JSONObject.parseObject(key);
|
|
|
+//
|
|
|
+// // 给相对路径,tomcat配置静态资源让前端读取
|
|
|
+// // http://192.168.0.44:8101/data/ar_I4Ef2SS4y/boxVideo/20180201_101827.mp4
|
|
|
+// String boxVideoPath = "/data/" + entity.getSceneCode()+ "/boxVideo/" + fileName;
|
|
|
+//// log.info("boxVideoPath: {}", boxVideoPath);
|
|
|
+//
|
|
|
+// // 添加视频参数到overlayJaon
|
|
|
+// keyJson.put("file", boxVideoPath);
|
|
|
+// overlaysArray.add(keyJson);
|
|
|
+//
|
|
|
+//
|
|
|
+// // final值需要赋值使用
|
|
|
+// String filePath = saveBasePath;
|
|
|
+//
|
|
|
+// filePath += fileName;
|
|
|
+// log.info("filePath: {}", filePath);
|
|
|
+// try {
|
|
|
+//// FileUtils.upload(file, filePath);
|
|
|
+// FileUtil.writeFromStream(file.getInputStream(), filePath);
|
|
|
+// } catch (IOException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+//
|
|
|
+// });
|
|
|
+//
|
|
|
+// JSONObject dataJson = new JSONObject();
|
|
|
+// dataJson.put("overlays", overlaysArray);
|
|
|
+//
|
|
|
+// // 创建data2.js文件
|
|
|
+// String saveDataJsonPath = basePath + "/data2.js";
|
|
|
+// log.info("data2.js path :{}", saveDataJsonPath);
|
|
|
+// FileUtil.writeUtf8String(dataJson.toJSONString(), saveDataJsonPath);
|
|
|
+// log.info("data2.js创建完成");
|
|
|
+//
|
|
|
+// return Result.success(entity.getWebSite());
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// @ApiOperation(value = "Map表单上传多文件,指定保存路径,需要用postman测试", notes = "自定义上传位置")
|
|
|
+// @PostMapping("uploads")
|
|
|
+// public Result uploads(@RequestParam Map<String, MultipartFile> param, String sceneTitle, String sceneCode, HttpServletRequest request) throws Exception {
|
|
|
+//// String token = request.getHeader("token");
|
|
|
+//// if (token == null) {
|
|
|
+//// log.error("token header is null");
|
|
|
+//// return Result.failure("token header is null");
|
|
|
+//// }
|
|
|
+//
|
|
|
+// SceneEntity entity = sceneService.findBySceneCode(sceneCode);
|
|
|
+// if (entity != null) {
|
|
|
+// log.error("场景码已存在,请更换新场景码: {}", sceneCode);
|
|
|
+// return Result.failure("场景码已存在,请更换新场景码");
|
|
|
+// }
|
|
|
+//
|
|
|
+//// Boolean verify = JwtUtil.isVerify(token, TypeCode.TOKEN_API_KEY);
|
|
|
+//// if (!verify) {
|
|
|
+//// log.error("api token 无效");
|
|
|
+//// return Result.failure("token 无效");
|
|
|
+//// }
|
|
|
+//
|
|
|
+// param.forEach((path, file)->{
|
|
|
+//
|
|
|
+// if (StringUtils.isBlank(path)) {
|
|
|
+// log.error("保存路径不能为空");
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (file == null) {
|
|
|
+// log.error("文件不能为空");
|
|
|
+// throw new BaseRuntimeException("文件为空");
|
|
|
+// }
|
|
|
+//
|
|
|
+// path = FILE_PATH + path;
|
|
|
+// log.info("savePath: {}", path);
|
|
|
+// try {
|
|
|
+//// FileUtils.upload(file, path);
|
|
|
+// FileUtil.writeFromStream(file.getInputStream(), path);
|
|
|
+// } catch (IOException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+//
|
|
|
+// });
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+// entity = new SceneEntity();
|
|
|
+// entity.setSceneCode(sceneCode);
|
|
|
+// entity.setPath(FILE_PATH + sceneCode);
|
|
|
+// entity.setSceneTitle(sceneTitle);
|
|
|
+// entity.setUpdateTime(new Date());
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+// // 调用算法切图片转换
|
|
|
+// 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.getWebSite());
|
|
|
+// }
|
|
|
|
|
|
|
|
|
|
|
@@ -253,11 +255,11 @@ public class ApiController extends BaseController {
|
|
|
sceneCode = "ar_" +sceneCode;
|
|
|
|
|
|
// 创建token,过期24h,
|
|
|
- String token = JwtUtil.createJWT(TOKEN_EXPIRE, TypeCode.TOKEN_API_KEY);
|
|
|
+// String token = JwtUtil.createJWT(TOKEN_EXPIRE, TypeCode.TOKEN_API_KEY);
|
|
|
|
|
|
HashMap<Object, Object> reuslt = new HashMap<>();
|
|
|
reuslt.put("sceneCode", sceneCode);
|
|
|
- reuslt.put("token", token);
|
|
|
+// reuslt.put("token", token);
|
|
|
|
|
|
return Result.success(reuslt);
|
|
|
}
|
|
@@ -289,35 +291,35 @@ public class ApiController extends BaseController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * 文件转换
|
|
|
- * @param sceneCode
|
|
|
- * @throws Exception
|
|
|
- */
|
|
|
- private void convert(String basePath, String sceneCode, String sceneTitle) throws Exception {
|
|
|
-
|
|
|
- // 将result文件夹的upload.json是否存在,并处理业务逻辑
|
|
|
- checkUploadJson(basePath);
|
|
|
-
|
|
|
-
|
|
|
- if(!FileUtil.exist(basePath+"/vision.txt")){
|
|
|
- log.error("文件不存在: " + basePath+"/vision.txt");
|
|
|
- Result.failure("文件不存在: " + basePath+"/vision.txt");
|
|
|
- }
|
|
|
-
|
|
|
- // 2.vision.txt转vision.modeldata
|
|
|
- CreateObjUtil.convertTxtToVisionmodeldata(basePath+"/vision.txt", basePath+"/vision.modeldata");
|
|
|
- log.info("vision.modeldata转换完成");
|
|
|
-
|
|
|
- // 3. 生成一个空的data2.js, 里面是一个空的json
|
|
|
- FileUtil.writeUtf8String("{}",basePath+"/data2.js");
|
|
|
- log.info("data2.js创建完成");
|
|
|
-
|
|
|
- // 4. 创建someData.json, 修改sid值为场景码目录
|
|
|
- createSomeData(basePath, sceneCode, sceneTitle);
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
+// /**
|
|
|
+// * 文件转换
|
|
|
+// * @param sceneCode
|
|
|
+// * @throws Exception
|
|
|
+// */
|
|
|
+// private void convert(String basePath, String sceneCode, String sceneTitle) throws Exception {
|
|
|
+//
|
|
|
+// // 将result文件夹的upload.json是否存在,并处理业务逻辑
|
|
|
+// checkUploadJson(basePath);
|
|
|
+//
|
|
|
+//
|
|
|
+// if(!FileUtil.exist(basePath+"/vision.txt")){
|
|
|
+// log.error("文件不存在: " + basePath+"/vision.txt");
|
|
|
+// Result.failure("文件不存在: " + basePath+"/vision.txt");
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 2.vision.txt转vision.modeldata
|
|
|
+// CreateObjUtil.convertTxtToVisionmodeldata(basePath+"/vision.txt", basePath+"/vision.modeldata");
|
|
|
+// log.info("vision.modeldata转换完成");
|
|
|
+//
|
|
|
+// // 3. 生成一个空的data2.js, 里面是一个空的json
|
|
|
+// FileUtil.writeUtf8String("{}",basePath+"/data2.js");
|
|
|
+// log.info("data2.js创建完成");
|
|
|
+//
|
|
|
+// // 4. 创建someData.json, 修改sid值为场景码目录
|
|
|
+// createSomeData(basePath, sceneCode, sceneTitle);
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
|
|
|
|
|
|
@Test
|
|
@@ -327,35 +329,35 @@ public class ApiController extends BaseController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * 创建someData.json
|
|
|
- */
|
|
|
- private static void createSomeData(String basePath, String sceneCode, String sceneTitle) throws IOException {
|
|
|
- String path = ResourceUtils.getURL("classpath:").getPath();
|
|
|
- path = path + "data/someData.json";
|
|
|
- log.info("path: {}", path);
|
|
|
- String os = FileUtil.readUtf8String(path);
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(os);
|
|
|
- JSONObject model = jsonObject.getJSONObject("model");
|
|
|
-
|
|
|
-
|
|
|
- // 更新images json
|
|
|
- JSONArray imagesJson = updateImagesData(sceneCode);
|
|
|
- model.put("images", imagesJson);
|
|
|
-
|
|
|
- // 修改sid值
|
|
|
- model.put("sid", sceneCode);
|
|
|
- model.put("name", sceneTitle);
|
|
|
-
|
|
|
- // 更新json
|
|
|
- jsonObject.put("model", model);
|
|
|
-
|
|
|
-
|
|
|
- FileUtil.writeUtf8String(jsonObject.toJSONString(), basePath+"/someData.json");
|
|
|
-
|
|
|
- log.info("someData.json创建完成");
|
|
|
-
|
|
|
- }
|
|
|
+// /**
|
|
|
+// * 创建someData.json
|
|
|
+// */
|
|
|
+// private static void createSomeData(String basePath, String sceneCode, String sceneTitle) throws IOException {
|
|
|
+// String path = ResourceUtils.getURL("classpath:").getPath();
|
|
|
+// path = path + "data/someData.json";
|
|
|
+// log.info("path: {}", path);
|
|
|
+// String os = FileUtil.readUtf8String(path);
|
|
|
+// JSONObject jsonObject = JSONObject.parseObject(os);
|
|
|
+// JSONObject model = jsonObject.getJSONObject("model");
|
|
|
+//
|
|
|
+//
|
|
|
+// // 更新images json
|
|
|
+// JSONArray imagesJson = updateImagesData(sceneCode);
|
|
|
+// model.put("images", imagesJson);
|
|
|
+//
|
|
|
+// // 修改sid值
|
|
|
+// model.put("sid", sceneCode);
|
|
|
+// model.put("name", sceneTitle);
|
|
|
+//
|
|
|
+// // 更新json
|
|
|
+// jsonObject.put("model", model);
|
|
|
+//
|
|
|
+//
|
|
|
+// FileUtil.writeUtf8String(jsonObject.toJSONString(), basePath+"/someData.json");
|
|
|
+//
|
|
|
+// log.info("someData.json创建完成");
|
|
|
+//
|
|
|
+// }
|
|
|
|
|
|
public static void main(String[] args) throws IOException {
|
|
|
String path = "F:\\test\\army\\upload.json";
|
|
@@ -368,67 +370,67 @@ public class ApiController extends BaseController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * 创建images.json
|
|
|
- * 如果数据格式有变动,要作出响应的修改
|
|
|
- */
|
|
|
- private static JSONArray updateImagesData(String sceneCode) throws IOException {
|
|
|
- String resourceUrl = FileUtils.getResourceUrl("data/images.json");
|
|
|
- String os = FileUtil.readUtf8String(resourceUrl);
|
|
|
- JSONObject imageObject = JSONObject.parseObject(os);
|
|
|
- imageObject.put("sid", sceneCode);
|
|
|
-
|
|
|
- JSONArray imagesArray = new JSONArray();
|
|
|
- imagesArray.set(0, imageObject);
|
|
|
-
|
|
|
- return imagesArray;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 检查upload.json文件是否存在,执行业务逻辑
|
|
|
- */
|
|
|
- private static void checkUploadJson(String basePath) throws Exception {
|
|
|
- String uploadJsonPath = basePath + "/results/upload.json";
|
|
|
-// String uploadJsonPath = "F:\\test\\army\\upload.json";
|
|
|
- boolean isUploadJsonPath = FileUtil.isFile(uploadJsonPath);
|
|
|
- if (!isUploadJsonPath) {
|
|
|
- log.error("算法的upload.json不存在");
|
|
|
- throw new BaseRuntimeException(5000, "算法的upload.json不存在");
|
|
|
-
|
|
|
- }
|
|
|
- // 判断upload.json文件是否都存在
|
|
|
- String os = FileUtil.readUtf8String(uploadJsonPath);
|
|
|
- JSONObject imageObject = JSONObject.parseObject(os);
|
|
|
-
|
|
|
- // json数组
|
|
|
- JSONArray jsonArray = imageObject.getJSONArray("upload");
|
|
|
- for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
- JSONObject jsonObject = jsonArray.getJSONObject(i);
|
|
|
- String fileName = jsonObject.getString("file");
|
|
|
- String filePath = basePath + "/results/" + fileName;
|
|
|
-
|
|
|
- boolean isFilePath = FileUtil.isFile(filePath);
|
|
|
- if (!isFilePath) {
|
|
|
- log.error("算法的upload.json数据文件: {}", filePath );
|
|
|
- throw new BaseRuntimeException(5000, "算法的upload.json数据文件不存在");
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- String suffix = StringUtils.substringAfterLast(filePath, ".");
|
|
|
- // 把图片复制到指定目录(dacf7dfa24ae47fab8fcebfe4dc41ab9_50k_texture_jpg_high)
|
|
|
- if ("jpg".equals(suffix)) {
|
|
|
- FileUtil.copy(filePath, basePath+"/" + ConstantFileName.modelUUID+"_50k_texture_jpg_high/" + fileName, true);
|
|
|
- }
|
|
|
-
|
|
|
- // 将modeldata.txt转xxx.dam
|
|
|
- if ("txt".equals(suffix)) {
|
|
|
- CreateObjUtil.convertTxtToDam(filePath, basePath+"/" + ConstantFileName.modelUUID+"_50k.dam");
|
|
|
- log.info("dam转换完成");
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
+// /**
|
|
|
+// * 创建images.json
|
|
|
+// * 如果数据格式有变动,要作出响应的修改
|
|
|
+// */
|
|
|
+// private static JSONArray updateImagesData(String sceneCode) throws IOException {
|
|
|
+// String resourceUrl = FileUtils.getResourceUrl("data/images.json");
|
|
|
+// String os = FileUtil.readUtf8String(resourceUrl);
|
|
|
+// JSONObject imageObject = JSONObject.parseObject(os);
|
|
|
+// imageObject.put("sid", sceneCode);
|
|
|
+//
|
|
|
+// JSONArray imagesArray = new JSONArray();
|
|
|
+// imagesArray.set(0, imageObject);
|
|
|
+//
|
|
|
+// return imagesArray;
|
|
|
+// }
|
|
|
+
|
|
|
+// /**
|
|
|
+// * 检查upload.json文件是否存在,执行业务逻辑
|
|
|
+// */
|
|
|
+// private static void checkUploadJson(String basePath) throws Exception {
|
|
|
+// String uploadJsonPath = basePath + "/results/upload.json";
|
|
|
+//// String uploadJsonPath = "F:\\test\\army\\upload.json";
|
|
|
+// boolean isUploadJsonPath = FileUtil.isFile(uploadJsonPath);
|
|
|
+// if (!isUploadJsonPath) {
|
|
|
+// log.error("算法的upload.json不存在");
|
|
|
+// throw new BaseRuntimeException(5000, "算法的upload.json不存在");
|
|
|
+//
|
|
|
+// }
|
|
|
+// // 判断upload.json文件是否都存在
|
|
|
+// String os = FileUtil.readUtf8String(uploadJsonPath);
|
|
|
+// JSONObject imageObject = JSONObject.parseObject(os);
|
|
|
+//
|
|
|
+// // json数组
|
|
|
+// JSONArray jsonArray = imageObject.getJSONArray("upload");
|
|
|
+// for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
+// JSONObject jsonObject = jsonArray.getJSONObject(i);
|
|
|
+// String fileName = jsonObject.getString("file");
|
|
|
+// String filePath = basePath + "/results/" + fileName;
|
|
|
+//
|
|
|
+// boolean isFilePath = FileUtil.isFile(filePath);
|
|
|
+// if (!isFilePath) {
|
|
|
+// log.error("算法的upload.json数据文件: {}", filePath );
|
|
|
+// throw new BaseRuntimeException(5000, "算法的upload.json数据文件不存在");
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// String suffix = StringUtils.substringAfterLast(filePath, ".");
|
|
|
+// // 把图片复制到指定目录(dacf7dfa24ae47fab8fcebfe4dc41ab9_50k_texture_jpg_high)
|
|
|
+// if ("jpg".equals(suffix)) {
|
|
|
+// FileUtil.copy(filePath, basePath+"/" + ConstantFileName.modelUUID+"_50k_texture_jpg_high/" + fileName, true);
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 将modeldata.txt转xxx.dam
|
|
|
+// if ("txt".equals(suffix)) {
|
|
|
+// CreateObjUtil.convertTxtToDam(filePath, basePath+"/" + ConstantFileName.modelUUID+"_50k.dam");
|
|
|
+// log.info("dam转换完成");
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
|
|
|
@Test
|
|
@@ -534,6 +536,7 @@ public class ApiController extends BaseController {
|
|
|
// data2Json.put("overlays", overlays);
|
|
|
}
|
|
|
|
|
|
+ // 热点
|
|
|
String hots = param.getHots();
|
|
|
if (hots != null) {
|
|
|
data2Json.put("hots", JSONObject.parseObject(hots));
|