关于我们

质量为本、客户为根、勇于拼搏、务实创新

< 返回新闻公共列表

目标检测系统前后端搭建

发布时间:2023-06-27 12:01:21
数据库 1. CREATE DATABASE /*!32312 IF NOT EXISTS*/`检测小车` /*!40100 DEFAULT CHARACTER SET utf8 */; 2. 3. USE `检测小车`; 4. 5. /*Table structure for table `t_plane` */ 6. 7. DROP TABLE IF EXISTS `t_plane`; 8. 9. CREATE TABLE `t_plane` ( 10. `id` int(10) NOT NULL AUTO_INCREMENT, 11. `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '数据插入时间', 12. `x` float DEFAULT NULL, 13. `y` float DEFAULT NULL, 14. PRIMARY KEY (`id`) 15. ) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8; 16. 17. /*Data for the table `t_plane` */ 18. 19. insert into `t_plane`(`id`,`create_time`,`x`,`y`) values (1,'2022-08-26 10:48:31',1,1),(2,'2022-08-27 10:48:34',2,2),(3,'2022-08-28 15:21:45',3,3),(4,'2022-08-28 17:38:24',4,4),(5,'2022-08-28 17:40:22',4,3),(6,'2022-08-28 17:41:10',4,4),(7,'2022-08-28 17:42:26',6,6),(8,'2022-08-28 17:51:06',2,2); 后端 目前后端只实现了一个接口,可以获取数据库的全部表单。 当前端发送请求时,会计算数据库最新插入的数据的插入时间和当前时间的差,如果这个差值大于一定值,就说明这条信息已经超时,不需要在前端提示,则返回的数据中一个变量设置为false,否则,设置为true。 核心逻辑 1. @CrossOrigin 2. @RestController 3. @RequestMapping("/plane") 4. public class planeController { 5. @Autowired 6. private planeService Service1; 7. 8. @GetMapping 9. public R1 getAll() throws ParseException { 10. int count = Service1.count(); 11. System.out.println("总行数 "+count); 12. 13. plane users=Service1.selectById(count); 14. System.out.println("最后插入的数据 "+users); 15. 16. TimeZone time = TimeZone.getTimeZone("Etc/GMT-8"); //转换为中国时区 17. TimeZone.setDefault(time); 18. 19. SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 20. Date date=new Date(); 21. String currentDate=sdf.format(date); 22. String createDate=sdf.format(users.getCreateTime()); 23. 24. //将string格式转化为date 25. Date date1 = sdf.parse(currentDate); 26. Date date2 = sdf.parse(createDate); 27. 28. 29. //得到计算出时间差 30. long diff = 3600000*8+date1.getTime() - date2.getTime(); 31. long diffSeconds = diff / 1000 ; 32. 33. 34. List planes=Service1.getAll(); 35. Collections.reverse(planes); 36. if(diffSeconds>20) { 37. return new R1(false, planes); 38. } 39. 40. return new R1(true, planes); 41. } 42. 43. } 地址:无人机监控后端: 无人机监控后端,使用了springboot,mysql 前端  前端目前只实现了简单的表单渲染功能,核心代码 1. 17. 18. 52. 53. 地址:init_unmaned_planesystem: 无人机识别模型初始版

/template/Home/leiyu/PC/Static