DevController.java 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. package com.fdkk.fdkkmeta.ctroller;
  2. /**
  3. * @author Xiewj
  4. * @date 2021/12/29
  5. */
  6. import cn.hutool.core.io.FileUtil;
  7. import com.alibaba.fastjson.JSON;
  8. import com.alibaba.fastjson.JSONArray;
  9. import com.alibaba.fastjson.JSONObject;
  10. import com.fdkk.fdkkmeta.domain.entity.mysql.BreakpointsEntity;
  11. import com.fdkk.fdkkmeta.domain.entity.mysql.MoveFrameEntity;
  12. import com.fdkk.fdkkmeta.domain.entity.mysql.RoomEntity;
  13. import com.fdkk.fdkkmeta.domain.entity.mysql.RotateFrameEntity;
  14. import com.fdkk.fdkkmeta.domain.po.AnglePO;
  15. import com.fdkk.fdkkmeta.domain.po.PointPO;
  16. import com.fdkk.fdkkmeta.redis.RedisCache;
  17. import com.fdkk.fdkkmeta.service.BreakpointsService;
  18. import com.fdkk.fdkkmeta.service.MoveFrameService;
  19. import com.fdkk.fdkkmeta.service.RoomService;
  20. import com.fdkk.fdkkmeta.service.RotateFrameService;
  21. import com.google.gson.JsonObject;
  22. import lombok.extern.slf4j.Slf4j;
  23. import org.springframework.beans.factory.annotation.Autowired;
  24. import org.springframework.web.bind.annotation.PostMapping;
  25. import org.springframework.web.bind.annotation.RequestBody;
  26. import org.springframework.web.bind.annotation.RequestMapping;
  27. import org.springframework.web.bind.annotation.RestController;
  28. import java.awt.geom.AffineTransform;
  29. import java.io.File;
  30. import java.math.BigDecimal;
  31. import java.text.DecimalFormat;
  32. import java.util.*;
  33. @RestController
  34. @RequestMapping("/dev")
  35. @Slf4j
  36. public class DevController {
  37. @Autowired
  38. RoomService roomService;
  39. @Autowired
  40. BreakpointsService breakpointsService;
  41. @Autowired
  42. RotateFrameService rotateFrameService;
  43. @Autowired
  44. MoveFrameService moveFrameService;
  45. @Autowired
  46. RedisCache redisCache;
  47. /**
  48. * test
  49. *
  50. * @return
  51. */
  52. @PostMapping("/test")
  53. public String test() {
  54. String path="H:\\workfile\\100-150点json数据\\100-150点json数据\\outputjson";
  55. if (FileUtil.exist(path.replaceAll("outputjson",""))){
  56. String s = FileUtil.readString(path.replaceAll("outputjson","") + "points.json", "utf8");
  57. JSONArray points= JSON.parseArray(s);
  58. for (Object point : points) {
  59. JSONObject a = JSON.parseObject(JSONObject.toJSON(point).toString());
  60. BreakpointsEntity breakpointsEntity=new BreakpointsEntity();
  61. breakpointsEntity.setAppId("0000000001");
  62. PointPO po=new PointPO();
  63. po.setX(a.getJSONObject("position").getDoubleValue("x")*100);
  64. po.setY(a.getJSONObject("position").getDoubleValue("y")*100);
  65. po.setZ(a.getJSONObject("position").getDoubleValue("z")*100);
  66. breakpointsEntity.setPosition(po);
  67. breakpointsEntity.setBreakPointId(a.getLong("id"));
  68. JSONArray contact = a.getJSONArray("contact");
  69. List<Integer> collection = JSONObject.parseArray(contact.toJSONString(), Integer.class);//把字符串转换成集合
  70. breakpointsEntity.setContact(collection);
  71. breakpointsService.save(breakpointsEntity);
  72. }
  73. }
  74. // //break*100
  75. // File[] ls = FileUtil.ls(path);
  76. // for (File l : ls) {
  77. // List<File> files = FileUtil.loopFiles(l);
  78. // for (File file : files) {
  79. // if (!file.getName().contains("_")){
  80. // String s = FileUtil.readString(file, "utf8");
  81. // JSONArray rotate= JSON.parseArray(s);
  82. // List<RotateFrameEntity> rotateFrameEntityList = new ArrayList<>();
  83. // for (int i = 0; i < rotate.size(); i++) {
  84. // if (i!=360){
  85. // DecimalFormat decimalFormat = new DecimalFormat("0000");
  86. // String numFormat= decimalFormat .format(i);
  87. // JSONObject a = JSON.parseObject(JSONObject.toJSON(rotate.get(i)).toString());
  88. // RotateFrameEntity rotateFrameEntity=new RotateFrameEntity();
  89. // rotateFrameEntity.setFrameIndex(a.getInteger("frame"));
  90. // rotateFrameEntity.setFileName(l.getName()+"."+numFormat+".h264");
  91. // rotateFrameEntity.setDirectory(l.getName());
  92. // AnglePO anglePO=new AnglePO();
  93. // anglePO.setPitch(a.getJSONObject("angle").getIntValue("pitch"));
  94. // anglePO.setRoll(a.getJSONObject("angle").getIntValue("roll"));
  95. // anglePO.setYaw(a.getJSONObject("angle").getIntValue("yaw"));
  96. // rotateFrameEntity.setCameraAngle(anglePO);
  97. // PointPO po=new PointPO();
  98. // po.setX(a.getJSONObject("position").getDoubleValue("x"));
  99. // po.setY(a.getJSONObject("position").getDoubleValue("y"));
  100. // po.setZ(a.getJSONObject("position").getDoubleValue("z"));
  101. // rotateFrameEntity.setCameraPosition(po);
  102. // rotateFrameEntity.setBreakPointId(Long.parseLong(l.getName()));
  103. // rotateFrameEntity.setAppId("0000000001");
  104. // rotateFrameEntityList.add(rotateFrameEntity);
  105. // }
  106. // }
  107. // boolean b = rotateFrameService.saveBatch(rotateFrameEntityList);
  108. // System.out.println("saverotateFrameEntityList-"+b );
  109. //
  110. // }else {
  111. // String s = FileUtil.readString(file, "utf8");
  112. // JSONArray moveFrame= JSON.parseArray(s);
  113. // List<MoveFrameEntity> moveFrameEntityList=new ArrayList<>();
  114. // for (int i = 0; i < moveFrame.size(); i++) {
  115. // DecimalFormat decimalFormat = new DecimalFormat("0000");
  116. // String numFormat= decimalFormat .format(i);
  117. // JSONObject a = JSON.parseObject(JSONObject.toJSON(moveFrame.get(i)).toString());
  118. // MoveFrameEntity moveFrameEntity=new MoveFrameEntity();
  119. // AnglePO anglePO=new AnglePO();
  120. // anglePO.setPitch(a.getJSONObject("angle").getIntValue("pitch"));
  121. // anglePO.setRoll(a.getJSONObject("angle").getIntValue("roll"));
  122. // anglePO.setYaw(a.getJSONObject("angle").getIntValue("yaw"));
  123. // moveFrameEntity.setCameraAngle(anglePO);
  124. // PointPO po=new PointPO();
  125. // po.setX(a.getJSONObject("position").getDoubleValue("x"));
  126. // po.setY(a.getJSONObject("position").getDoubleValue("y"));
  127. // po.setZ(a.getJSONObject("position").getDoubleValue("z"));
  128. // moveFrameEntity.setCameraPosition(po);
  129. // String name = file.getName().replace(".json", "");
  130. // String[] s1 = name.split("_");
  131. // moveFrameEntity.setStartBreakPointId(Long.parseLong(s1[0]));
  132. // moveFrameEntity.setEndBreakPointId(Long.parseLong(s1[1]));
  133. // moveFrameEntity.setAngle(Integer.parseInt(s1[2]));
  134. // moveFrameEntity.setFrameIndex(a.getInteger("frame"));
  135. // moveFrameEntity.setDirectory(file.getName().replace(".json",""));
  136. // System.out.println(JSON.toJSONString(moveFrameEntity));
  137. // moveFrameEntity.setAppId("0000000001");
  138. // moveFrameEntity.setFileName(file.getName().replace(".json","")+"."+numFormat+".h264");
  139. // moveFrameEntityList.add(moveFrameEntity);
  140. // }
  141. // boolean b = moveFrameService.saveBatch(moveFrameEntityList);
  142. // System.out.println("savemoveFrameEntityList-"+b );
  143. // }
  144. // }
  145. // System.out.println(FileUtil.isFile(l));
  146. // }
  147. return "";
  148. }
  149. @PostMapping("redis")
  150. public void testredis(){
  151. redisCache.pfremove("setCacheRequest:rotate:"+1);
  152. redisCache.setCacheList("setCacheRequest:rotate:"+1, Arrays.asList(1));
  153. redisCache.setCacheList("setCacheRequest:rotate:"+1, Arrays.asList(2));
  154. redisCache.setCacheList("setCacheRequest:rotate:"+1, Arrays.asList(3));
  155. List<Object> cacheList = redisCache.getCacheList("setCacheRequest:rotate:" + 1);
  156. redisCache.lRemove("setCacheRequest:rotate:"+1,0,2);
  157. List<Object> cacheList1 = redisCache.getCacheList("setCacheRequest:rotate:" + 1);
  158. System.out.println(cacheList);
  159. }
  160. }