Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
motorCity
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
node_server
motorCity
Commits
e4af2680
Commit
e4af2680
authored
Dec 14, 2022
by
lixinming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
5cbf9408
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
28 deletions
+34
-28
wsData.ts
src/biz/jgfwnl/wsData.ts
+1
-1
wsData.ts
src/data/interface/wsData.ts
+33
-27
No files found.
src/biz/jgfwnl/wsData.ts
View file @
e4af2680
...
...
@@ -11,7 +11,7 @@ export function broadcastMsg(data) {
for
(
let
key
in
connectionPool
)
{
let
result
=
{
code
:
200
,
success
:
true
,
data
};
try
{
if
(
data
.
vin
==
"LZFH18T19LD019241"
)
console
.
log
(
data
.
lat
+
"======"
+
data
.
lng
)
//
if (data.vin == "LZFH18T19LD019241") console.log(data.lat + "======"+ data.lng)
connectionPool
[
key
].
send
(
JSON
.
stringify
(
result
));
}
catch
(
err
)
{
logError
(
`广播消息失败:
${
err
}
`
);
...
...
src/data/interface/wsData.ts
View file @
e4af2680
...
...
@@ -98,31 +98,9 @@ export function stats(data) {
// console.log(data);
let
dataJson
=
JSON
.
parse
(
data
);
let
变化
=
0
;
let
无变化
=
0
;
let
有速度的车
=
0
;
let
速度为
0
的车
=
0
;
dataJson
.
VehicleLoc
.
forEach
(
info
=>
{
let
{
vin
,
latitude
,
longitude
,
positiontime
,
vehicleId
,
velocity
}
=
info
;
// if (velocity != 0 && vin == "LZFH18T13KD005883") {
// console.log(vin, "车速==",velocity, "经纬度", latitude, longitude);
// }
if
(
velocity
!=
0
)
{
有速度的车
+=
1
;
if
(
!
test
[
vin
]
)
test
[
vin
]
=
{
latitude
,
longitude
,
type
:
"无变化"
};
else
{
if
(
latitude
!=
test
[
vin
].
latitude
||
longitude
!=
test
[
vin
].
longitude
)
{
test
[
vin
].
type
=
"有变化"
test
[
vin
].
latitude
=
latitude
;
test
[
vin
].
longitude
=
longitude
;
变化
+=
1
;
}
else
{
无变化
+=
1
;
}
}
}
else
{
速度为
0
的车
+=
1
;
}
if
(
dataJson
.
VehicleLoc
)
{
let
{
vin
,
latitude
,
longitude
,
positiontime
,
vehicleId
,
velocity
}
=
dataJson
.
VehicleLoc
;
// console.log("收到小车位置", vin);
broadcastMsg
({
lng
:
longitude
||
0.0
,
lat
:
latitude
||
0.0
,
vin
,
vehicleid
:
vehicleId
});
//加入到缓存
let
lastMs
=
positiontime
||
new
Date
().
valueOf
();
...
...
@@ -134,10 +112,38 @@ export function stats(data) {
dp
[
vin
].
index
+=
1
;
if
(
dp
[
vin
].
index
>
4
)
dp
[
vin
].
index
=
0
;
}
});
}
// let 变化 = 0;
// let 无变化 = 0;
// let 有速度的车 = 0;
// let 速度为0的车 = 0;
// dataJson.VehicleLoc.forEach(info => {
// // if (velocity != 0 && vin == "LZFH18T13KD005883") {
// // console.log(vin, "车速==",velocity, "经纬度", latitude, longitude);
// // }
// // if (velocity != 0 ) {
// // 有速度的车 += 1;
// // if ( !test[vin] ) test[vin] = {latitude, longitude, type:"无变化"};
// // else {
// // if (latitude != test[vin].latitude || longitude != test[vin].longitude) {
// // test[vin].type = "有变化"
// // test[vin].latitude = latitude;
// // test[vin].longitude = longitude;
// // 变化 += 1;
// // } else {
// // 无变化 += 1;
// // }
// // }
// // } else {
// // 速度为0的车 += 1;
// // }
// });
console
.
log
(
`本次消息总共发了:
${
有速度的车
}
辆有速度, 其中变化的
${
变化
}
辆;没有变化的
${
无变化
}
, 速度为0的车
${
速度为
0
的车
}
`
);
//
console.log(`本次消息总共发了:${有速度的车}辆有速度, 其中变化的 ${变化} 辆;没有变化的${无变化}, 速度为0的车${速度为0的车}`);
}
catch
(
err
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment