目录
数据库
后端
前端
目标检测系统
CREATE DATABASE /*!32312 IF NOT EXISTS*/`检测小车` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `检测小车`;
/*Table structure for table `t_plane` */
DROP TABLE IF EXISTS `t_plane`;
CREATE TABLE `t_plane` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '数据插入时间',
`x` float DEFAULT NULL,
`y` float DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8;
/*Data for the table `t_plane` */
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。
核心逻辑
@CrossOrigin
@RestController
@RequestMapping("/plane")
public class planeController {
@Autowired
private planeService Service1;
@GetMapping
public R1 getAll() throws ParseException {
int count = Service1.count();
System.out.println("总行数 "+count);
plane users=Service1.selectById(count);
System.out.println("最后插入的数据 "+users);
TimeZone time = TimeZone.getTimeZone("Etc/GMT-8"); //转换为中国时区
TimeZone.setDefault(time);
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date=new Date();
String currentDate=sdf.format(date);
String createDate=sdf.format(users.getCreateTime());
//将string格式转化为date
Date date1 = sdf.parse(currentDate);
Date date2 = sdf.parse(createDate);
//得到计算出时间差
long diff = 3600000*8+date1.getTime() - date2.getTime();
long diffSeconds = diff / 1000 ;
List planes=Service1.getAll();
Collections.reverse(planes);
if(diffSeconds>20) {
return new R1(false, planes);
}
return new R1(true, planes);
}
}
地址:无人机监控后端: 无人机监控后端,使用了springboot,mysql
前端目前只实现了简单的表单渲染功能,核心代码
地址:无人机监控前端: 监控前端实现
检测系统地址:http://t.csdn.cn/ogesG