-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathununuond2.html
76 lines (56 loc) · 2.58 KB
/
ununuond2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<!DOCTYPE html>
<html>
<head>
<script src="./axios/dist/axios.min.js"></script>
</head>
<body>
<script>
const batchSize = 1000;
let offset = 0;
var thisstr = [];
var ishavedate = 0;
var license='豫rx2585';
function fetchData() {
axios.post("./myindex_ShowRoad.php", {
License: license,
offset: offset,
limit: batchSize
})
.then(response => {
const data = response.data;
console.log(data);
})
.catch(error => {
console.error('发生错误:', error);
});
}
// 第一次请求
fetchData();
//1传入时间数组,先按照时间排序,之后间隔一段时间的数据分到同一组
function cleanAndSortTimeArray(arr) {
arr.sort((a, b) => {
return new Date(a.uptime) - new Date(b.uptime);
});
let result = [];
let group = [];
let prevTime = null;
for (let obj of arr) {
let currentTime = new Date(obj.uptime);
if (prevTime && (currentTime - prevTime) / 3600000 < 1) {//除以3600000是将ms转化为h
group.push(obj);
} else {
if (group.length > 0) {
result.push(group);
}
group = [obj];
}
prevTime = currentTime;
}
if (group.length > 0) {
result.push(group);
}
return result;
}
</script>
</body>
</html>