Commit e4af2680 by lixinming

no message

parent 5cbf9408
...@@ -11,7 +11,7 @@ export function broadcastMsg(data) { ...@@ -11,7 +11,7 @@ export function broadcastMsg(data) {
for (let key in connectionPool) { for (let key in connectionPool) {
let result = {code:200, success:true, data}; let result = {code:200, success:true, data};
try { 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)); connectionPool[key].send(JSON.stringify(result));
} catch(err) { } catch(err) {
logError(`广播消息失败: ${err}`); logError(`广播消息失败: ${err}`);
......
...@@ -98,31 +98,9 @@ export function stats(data) { ...@@ -98,31 +98,9 @@ export function stats(data) {
// console.log(data); // console.log(data);
let dataJson = JSON.parse(data); let dataJson = JSON.parse(data);
let 变化 = 0; if (dataJson.VehicleLoc) {
let 无变化 = 0; let {vin, latitude, longitude, positiontime, vehicleId, velocity} = dataJson.VehicleLoc;
let 有速度的车 = 0; // console.log("收到小车位置", vin);
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;
}
broadcastMsg({lng:longitude||0.0, lat:latitude||0.0, vin, vehicleid:vehicleId}); broadcastMsg({lng:longitude||0.0, lat:latitude||0.0, vin, vehicleid:vehicleId});
//加入到缓存 //加入到缓存
let lastMs = positiontime || new Date().valueOf(); let lastMs = positiontime || new Date().valueOf();
...@@ -134,10 +112,38 @@ export function stats(data) { ...@@ -134,10 +112,38 @@ export function stats(data) {
dp[vin].index += 1; dp[vin].index += 1;
if (dp[vin].index > 4) dp[vin].index = 0; if (dp[vin].index > 4) dp[vin].index = 0;
} }
}); }
console.log(`本次消息总共发了:${有速度的车}辆有速度, 其中变化的 ${变化} 辆;没有变化的${无变化}, 速度为0的车${速度为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的车}`);
} catch(err) { } catch(err) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment