|
@@ -5,9 +5,20 @@ package com.fdkk.fdkkmeta.ctroller;
|
|
|
* @date 2021/12/29
|
|
|
*/
|
|
|
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.fdkk.fdkkmeta.domain.entity.mysql.BreakpointsEntity;
|
|
|
+import com.fdkk.fdkkmeta.domain.entity.mysql.MoveFrameEntity;
|
|
|
import com.fdkk.fdkkmeta.domain.entity.mysql.RoomEntity;
|
|
|
+import com.fdkk.fdkkmeta.domain.entity.mysql.RotateFrameEntity;
|
|
|
+import com.fdkk.fdkkmeta.domain.po.AnglePO;
|
|
|
+import com.fdkk.fdkkmeta.domain.po.PointPO;
|
|
|
+import com.fdkk.fdkkmeta.service.BreakpointsService;
|
|
|
+import com.fdkk.fdkkmeta.service.MoveFrameService;
|
|
|
import com.fdkk.fdkkmeta.service.RoomService;
|
|
|
+import com.fdkk.fdkkmeta.service.RotateFrameService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
@@ -16,7 +27,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.awt.geom.AffineTransform;
|
|
|
+import java.io.File;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.text.DecimalFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -27,6 +41,12 @@ import java.util.Map;
|
|
|
public class DevController {
|
|
|
@Autowired
|
|
|
RoomService roomService;
|
|
|
+ @Autowired
|
|
|
+ BreakpointsService breakpointsService;
|
|
|
+ @Autowired
|
|
|
+ RotateFrameService rotateFrameService;
|
|
|
+ @Autowired
|
|
|
+ MoveFrameService moveFrameService;
|
|
|
|
|
|
/**
|
|
|
* test
|
|
@@ -35,10 +55,99 @@ public class DevController {
|
|
|
*/
|
|
|
@PostMapping("/test")
|
|
|
public String test() {
|
|
|
- RoomEntity a=new RoomEntity();
|
|
|
- a.setSceneId("1");
|
|
|
- roomService.save(a);
|
|
|
- List<RoomEntity> bySceneId = roomService.findBySceneId("1");
|
|
|
- return bySceneId.toString();
|
|
|
+
|
|
|
+
|
|
|
+ String path="/home/webrtc/creatJson/outputjson/";
|
|
|
+
|
|
|
+ if (FileUtil.exist(path.replaceAll("outputjson",""))){
|
|
|
+ String s = FileUtil.readString(path.replaceAll("outputjson","") + "points.json", "utf8");
|
|
|
+ JSONArray points= JSON.parseArray(s);
|
|
|
+ for (Object point : points) {
|
|
|
+ JSONObject a = JSON.parseObject(JSONObject.toJSON(point).toString());
|
|
|
+ BreakpointsEntity breakpointsEntity=new BreakpointsEntity();
|
|
|
+ breakpointsEntity.setAppId("0000000001");
|
|
|
+ PointPO po=new PointPO();
|
|
|
+ po.setX(a.getJSONObject("position").getDoubleValue("x"));
|
|
|
+ po.setY(a.getJSONObject("position").getDoubleValue("y"));
|
|
|
+ po.setZ(a.getJSONObject("position").getDoubleValue("z"));
|
|
|
+ breakpointsEntity.setPosition(po);
|
|
|
+ breakpointsEntity.setBreakPointId(a.getString("id"));
|
|
|
+ breakpointsService.save(breakpointsEntity);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ File[] ls = FileUtil.ls(path);
|
|
|
+ for (File l : ls) {
|
|
|
+ List<File> files = FileUtil.loopFiles(l);
|
|
|
+ for (File file : files) {
|
|
|
+ if (!file.getName().contains("_")){
|
|
|
+ String s = FileUtil.readString(file, "utf8");
|
|
|
+ JSONArray rotate= JSON.parseArray(s);
|
|
|
+ List<RotateFrameEntity> rotateFrameEntityList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < rotate.size(); i++) {
|
|
|
+ if (i!=360){
|
|
|
+ DecimalFormat decimalFormat = new DecimalFormat("0000");
|
|
|
+ String numFormat= decimalFormat .format(i);
|
|
|
+ JSONObject a = JSON.parseObject(JSONObject.toJSON(rotate.get(i)).toString());
|
|
|
+ RotateFrameEntity rotateFrameEntity=new RotateFrameEntity();
|
|
|
+ rotateFrameEntity.setFrameIndex(a.getInteger("frame"));
|
|
|
+ rotateFrameEntity.setFileName(l.getName()+"."+numFormat+".h264");
|
|
|
+ rotateFrameEntity.setDirectory(l.getName());
|
|
|
+ AnglePO anglePO=new AnglePO();
|
|
|
+ anglePO.setPitch(a.getJSONObject("angle").getDoubleValue("pitch"));
|
|
|
+ anglePO.setRoll(a.getJSONObject("angle").getDoubleValue("roll"));
|
|
|
+ anglePO.setYaw(a.getJSONObject("angle").getDoubleValue("yaw"));
|
|
|
+ rotateFrameEntity.setCameraAngle(anglePO);
|
|
|
+ PointPO po=new PointPO();
|
|
|
+ po.setX(a.getJSONObject("position").getDoubleValue("x"));
|
|
|
+ po.setY(a.getJSONObject("position").getDoubleValue("y"));
|
|
|
+ po.setZ(a.getJSONObject("position").getDoubleValue("z"));
|
|
|
+ rotateFrameEntity.setCameraPosition(po);
|
|
|
+ rotateFrameEntity.setBreakPointId(l.getName());
|
|
|
+ rotateFrameEntity.setAppId("0000000001");
|
|
|
+ rotateFrameEntityList.add(rotateFrameEntity);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ boolean b = rotateFrameService.saveBatch(rotateFrameEntityList);
|
|
|
+ System.out.println("saverotateFrameEntityList-"+b );
|
|
|
+
|
|
|
+ }else {
|
|
|
+ String s = FileUtil.readString(file, "utf8");
|
|
|
+ JSONArray moveFrame= JSON.parseArray(s);
|
|
|
+ List<MoveFrameEntity> moveFrameEntityList=new ArrayList<>();
|
|
|
+ for (int i = 0; i < moveFrame.size(); i++) {
|
|
|
+ DecimalFormat decimalFormat = new DecimalFormat("0000");
|
|
|
+ String numFormat= decimalFormat .format(i);
|
|
|
+ JSONObject a = JSON.parseObject(JSONObject.toJSON(moveFrame.get(i)).toString());
|
|
|
+ MoveFrameEntity moveFrameEntity=new MoveFrameEntity();
|
|
|
+ AnglePO anglePO=new AnglePO();
|
|
|
+ anglePO.setPitch(a.getJSONObject("angle").getDoubleValue("pitch"));
|
|
|
+ anglePO.setRoll(a.getJSONObject("angle").getDoubleValue("roll"));
|
|
|
+ anglePO.setYaw(a.getJSONObject("angle").getDoubleValue("yaw"));
|
|
|
+ moveFrameEntity.setCameraAngle(anglePO);
|
|
|
+ PointPO po=new PointPO();
|
|
|
+ po.setX(a.getJSONObject("position").getDoubleValue("x"));
|
|
|
+ po.setY(a.getJSONObject("position").getDoubleValue("y"));
|
|
|
+ po.setZ(a.getJSONObject("position").getDoubleValue("z"));
|
|
|
+ moveFrameEntity.setCameraPosition(po);
|
|
|
+ String name = file.getName().replace(".json", "");
|
|
|
+ String[] s1 = name.split("_");
|
|
|
+ moveFrameEntity.setStartBreakPointId(Integer.parseInt(s1[0]));
|
|
|
+ moveFrameEntity.setEndBreakPointId(Integer.parseInt(s1[1]));
|
|
|
+ moveFrameEntity.setAngle(Integer.parseInt(s1[2]));
|
|
|
+ moveFrameEntity.setFrameIndex(a.getInteger("frame"));
|
|
|
+ moveFrameEntity.setDirectory(file.getName().replace(".json",""));
|
|
|
+ System.out.println(JSON.toJSONString(moveFrameEntity));
|
|
|
+ moveFrameEntity.setAppId("0000000001");
|
|
|
+ moveFrameEntity.setFileName(file.getName().replace(".json","")+"."+numFormat+".h264");
|
|
|
+ moveFrameEntityList.add(moveFrameEntity);
|
|
|
+ }
|
|
|
+ boolean b = moveFrameService.saveBatch(moveFrameEntityList);
|
|
|
+ System.out.println("savemoveFrameEntityList-"+b );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.out.println(FileUtil.isFile(l));
|
|
|
+ }
|
|
|
+ return "";
|
|
|
}
|
|
|
}
|