|
@@ -28,6 +28,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.io.FileNotFoundException;
|
|
|
import java.io.IOException;
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -54,6 +55,12 @@ public class ApiController extends BaseController {
|
|
|
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 无效");
|
|
@@ -80,10 +87,13 @@ public class ApiController extends BaseController {
|
|
|
|
|
|
});
|
|
|
|
|
|
- SceneEntity entity = new SceneEntity();
|
|
|
+
|
|
|
+
|
|
|
+ entity = new SceneEntity();
|
|
|
entity.setSceneCode(sceneCode);
|
|
|
entity.setPath(FILE_PATH + sceneCode);
|
|
|
entity.setSceneTitle(sceneTitle);
|
|
|
+ entity.setUpdateTime(new Date());
|
|
|
|
|
|
|
|
|
|
|
@@ -129,6 +139,9 @@ public class ApiController extends BaseController {
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
@ApiOperation("获取场景码")
|
|
|
@GetMapping("getSceneCode")
|
|
|
public Result getSceneCode() {
|
|
@@ -190,9 +203,11 @@ public class ApiController extends BaseController {
|
|
|
|
|
|
// 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);
|
|
@@ -201,40 +216,6 @@ public class ApiController extends BaseController {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-// @ApiOperation("文件转换")
|
|
|
-// @GetMapping(value = "convert/{sceneCode}")
|
|
|
-// public Result convert1(@PathVariable String sceneCode) throws Exception {
|
|
|
-// SceneEntity entity = sceneService.findBySceneCode(sceneCode);
|
|
|
-// assert entity != null;
|
|
|
-// String basePath = entity.getPath();
|
|
|
-// log.info("filePath: {}", basePath);
|
|
|
-//
|
|
|
-// // 1. 将XXX_50k.dam写到服务器
|
|
|
-//// FileUtils.fielWrite("", basePath+ "/"+ConstantFileName.modelUUID+"_50k.dam");
|
|
|
-// String resourceUrl = FileUtils.getResourceUrl(ConstantFileName.modelUUID + "_50k.dam");
|
|
|
-// FileUtil.writeUtf8String(resourceUrl, basePath+ "/"+ConstantFileName.modelUUID+"_50k.dam");
|
|
|
-//
|
|
|
-//
|
|
|
-// 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");
|
|
|
-//
|
|
|
-// // 3. 生成一个空的data2.js, 里面是一个空的json
|
|
|
-// FileUtil.writeUtf8String("{}",basePath+"/data2.js");
|
|
|
-//
|
|
|
-// // 4. 创建someData.json, 修改sid值为场景码目录
|
|
|
-// String sceneTitle = "1111111111111";
|
|
|
-// createSomeData(basePath, sceneCode, sceneTitle);
|
|
|
-//
|
|
|
-// return Result.success();
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
@Test
|
|
|
public void createData2Js(){
|
|
|
String basePath = "F:\\test\\army";
|
|
@@ -246,7 +227,6 @@ public class ApiController extends BaseController {
|
|
|
* 创建someData.json
|
|
|
*/
|
|
|
private static void createSomeData(String basePath, String sceneCode, String sceneTitle) throws IOException {
|
|
|
- log.info("run createSomeData" );
|
|
|
String path = ResourceUtils.getURL("classpath:").getPath();
|
|
|
path = path + "data/someData.json";
|
|
|
log.info("path: {}", path);
|
|
@@ -268,7 +248,8 @@ public class ApiController extends BaseController {
|
|
|
|
|
|
|
|
|
FileUtil.writeUtf8String(jsonObject.toJSONString(), basePath+"/someData.json");
|
|
|
- log.info("end createSomeData" );
|
|
|
+
|
|
|
+ log.info("someData.json创建完成");
|
|
|
|
|
|
}
|
|
|
|