xiewenjie 3 年 前
コミット
279838265f

+ 24 - 20
src/main/java/com/fdkk/fdkkmeta/ctroller/DevController.java

@@ -56,26 +56,30 @@ public class DevController   {
     @PostMapping("/test")
     public String test() {
 
-//
-//        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);
-//            }
-//        }
-//
+
+        String path="H:\\workfile\\100-150点json数据\\100-150点json数据\\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.getLong("id"));
+
+                JSONArray contact = a.getJSONArray("contact");
+                List<Integer>  collection = JSONObject.parseArray(contact.toJSONString(), Integer.class);//把字符串转换成集合
+                breakpointsEntity.setContact(collection);
+                breakpointsService.save(breakpointsEntity);
+            }
+        }
+
 //        File[] ls = FileUtil.ls(path);
 //        for (File l : ls) {
 //            List<File> files = FileUtil.loopFiles(l);

+ 9 - 0
src/main/java/com/fdkk/fdkkmeta/domain/entity/mysql/BreakpointsEntity.java

@@ -4,9 +4,12 @@ import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
 import com.fdkk.fdkkmeta.base.BaseEntity;
+import com.fdkk.fdkkmeta.domain.po.ContactPO;
 import com.fdkk.fdkkmeta.domain.po.PointPO;
 import lombok.Data;
 
+import java.util.List;
+
 /**
  * @author Xiewj
  * @date 2022/5/9
@@ -17,5 +20,11 @@ public class BreakpointsEntity extends BaseEntity {
     @TableField(value = "position", typeHandler = JacksonTypeHandler.class)
     private PointPO position;
     private Long breakPointId;
+
+    @TableField(value = "contact", typeHandler = JacksonTypeHandler.class)
+    private List<Integer> contact;
     private String appId;
+
+
+
 }

+ 14 - 0
src/main/java/com/fdkk/fdkkmeta/domain/po/ContactPO.java

@@ -0,0 +1,14 @@
+package com.fdkk.fdkkmeta.domain.po;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author Xiewj
+ * @date 2022/5/12
+ */
+@Data
+public class ContactPO {
+    private Integer contactId;
+}

+ 8 - 5
src/main/java/com/fdkk/fdkkmeta/grpcService/sceneGrpcServer.java

@@ -164,7 +164,7 @@ public class sceneGrpcServer extends SceneGrpcServiceGrpc.SceneGrpcServiceImplBa
     		//这三个变量从user表和rotateframe表里取
             UserEntity user = userService.findById(user_id);
 			Long breakPointId = user.getBreakPointId();
-            BreakpointsEntity breakpointsEntity = breakpointsService.findById(breakPointId);
+            BreakpointsEntity breakpointsEntity = breakpointsService.findByAppIdAndBreakPointId(user.getAppId(),breakPointId);
             RotateFrameEntity rotateFrameEntity = rotateFrameService.findById(user.getFrameId());
 
             PointPO playerPoint = breakpointsEntity.getPosition();
@@ -241,7 +241,8 @@ public class sceneGrpcServer extends SceneGrpcServiceGrpc.SceneGrpcServiceImplBa
 
             UserEntity user = userService.findById(user_id);
 			Long breakPointId = user.getBreakPointId();
-			BreakpointsEntity breakpointsEntity = breakpointsService.findById(breakPointId);
+			BreakpointsEntity breakpointsEntity = breakpointsService.findByAppIdAndBreakPointId(user.getAppId(),breakPointId);
+
             RotateFrameEntity rotateFrameEntity = rotateFrameService.findById(user.getFrameId());
 
             Point start = null;    //从user表里取
@@ -342,7 +343,7 @@ public class sceneGrpcServer extends SceneGrpcServiceGrpc.SceneGrpcServiceImplBa
      		boolean needNext = request.getNext();
 
             UserEntity user = userService.findById(user_id);
-            BreakpointsEntity breakpointsEntity = breakpointsService.findById(user.getBreakPointId());
+            BreakpointsEntity breakpointsEntity = breakpointsService.findByAppIdAndBreakPointId(user.getAppId(),user.getBreakPointId());
             RotateFrameEntity rotateFrameEntity = rotateFrameService.findById(user.getFrameId());
      		//moveStart的结果参考moveStart
      		//开始返回结果,一段一段的返回(每段是两个邻居点的过渡),第一段之前还要有角度的矫正
@@ -467,8 +468,10 @@ public class sceneGrpcServer extends SceneGrpcServiceGrpc.SceneGrpcServiceImplBa
      		UserEntity user = userService.findById(user_id);
      		Long breakPointId = user.getBreakPointId();
      		//获得当前点所有邻居点
-			//TODO 获取棋盘
-     		//找到与角度move_angle最近的邻居点
+			//TODO 获取棋盘邻居点 getContact
+			BreakpointsEntity breakpointsEntity = breakpointsService.findByAppIdAndBreakPointId(user.getAppId(), breakPointId);
+			log.info("breakpointsEntity-getContact",breakpointsEntity.getContact());
+			//找到与角度move_angle最近的邻居点
      		//移动player,并且更新相机角度
 
     	}

+ 3 - 0
src/main/java/com/fdkk/fdkkmeta/service/BreakpointsService.java

@@ -10,4 +10,7 @@ import java.util.List;
  */
 public interface BreakpointsService extends IBaseService<BreakpointsEntity> {
     List<BreakpointsEntity>     findByAppId(String AppId);
+
+    BreakpointsEntity findByAppIdAndBreakPointId(String AppId,Long breakpointId);
+
 }

+ 8 - 0
src/main/java/com/fdkk/fdkkmeta/service/impl/BreakpointsServiceImpl.java

@@ -24,4 +24,12 @@ public class BreakpointsServiceImpl extends BaseServiceImpl<BreakpointsMapper, B
         wrapper.eq(BreakpointsEntity::getAppId, AppId);
         return list(wrapper);
     }
+
+    @Override
+    public BreakpointsEntity findByAppIdAndBreakPointId(String AppId, Long breakpointId) {
+        LambdaQueryWrapper<BreakpointsEntity> wrapper = Wrappers.lambdaQuery();
+        wrapper.eq(BreakpointsEntity::getAppId, AppId);
+        wrapper.eq(BreakpointsEntity::getBreakPointId, breakpointId);
+        return getOne(wrapper);
+    }
 }

+ 0 - 76
src/main/java/com/fdkk/fdkkmeta/util/test.java

@@ -20,81 +20,5 @@ import java.util.List;
  */
 public class test {
     public static void main(String[] args) {
-        String path="H:\\workfile\\100-150点json数据\\100-150点json数据\\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"));
-            }
-        }
-
-        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);
-                    for (Object o : rotate) {
-                        JSONObject a = JSON.parseObject(JSONObject.toJSON(o).toString());
-                        RotateFrameEntity rotateFrameEntity=new RotateFrameEntity();
-                        rotateFrameEntity.setFrameIndex(a.getInteger("frame"));
-                        rotateFrameEntity.setFileName(l.getName()+".h64");
-                        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());
-                        System.out.println(JSON.toJSONString(rotateFrameEntity));
-
-                    }
-
-                }else {
-                    String s = FileUtil.readString(file, "utf8");
-                    JSONArray moveFrame= JSON.parseArray(s);
-                    for (Object o : moveFrame) {
-                        JSONObject a = JSON.parseObject(JSONObject.toJSON(o).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(l.getName());
-                        System.out.println(JSON.toJSONString(moveFrameEntity));
-                    }
-
-                }
-            }
-            System.out.println(FileUtil.isFile(l));
-        }
     }
 }