fix duplicate
This commit is contained in:
parent
e7cfe25ceb
commit
54f9313a8b
|
@ -9,6 +9,15 @@ const config = {
|
||||||
database: "intops"
|
database: "intops"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var currentIn = [];
|
||||||
|
var currentInOther = [];
|
||||||
|
var currentOut = [];
|
||||||
|
var currentOutOther = [];
|
||||||
|
var maxCompare = 5;
|
||||||
|
var maxFalse = 0;
|
||||||
|
var falseIn = 0;
|
||||||
|
var falseOut = 0;
|
||||||
|
|
||||||
function makeDb(config) {
|
function makeDb(config) {
|
||||||
const connection = mysql.createConnection(config);
|
const connection = mysql.createConnection(config);
|
||||||
return {
|
return {
|
||||||
|
@ -57,14 +66,112 @@ function levenshtein(a, b) {
|
||||||
|
|
||||||
return matrix[b.length][a.length];
|
return matrix[b.length][a.length];
|
||||||
}
|
}
|
||||||
const db = makeDb(config);
|
|
||||||
|
|
||||||
var currentIn = [];
|
function isSavePlate(type, timestamp, plate) {
|
||||||
var currentOut = [];
|
if (type === "in") {
|
||||||
var maxCompare = 5;
|
for (var i = 0; i < currentIn.length; i++) {
|
||||||
var maxFalse = 0;
|
if ((timestamp - currentIn[i].time) < 600) {
|
||||||
var falseIn = 0;
|
if (plate === currentIn[i].plate) {
|
||||||
var falseOut = 0;
|
return false;
|
||||||
|
} /*else if (levenshtein(plate, currentIn[i].plate) < 2) {
|
||||||
|
return false;
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (type === "out") {
|
||||||
|
for (var i = 0; i < currentOut.length; i++) {
|
||||||
|
if ((timestamp - currentOut[i].time) < 600) {
|
||||||
|
if (plate === currentOut[i].plate) {
|
||||||
|
return false;
|
||||||
|
} /*else if (levenshtein(plate, currentOut[i].plate) < 2) {
|
||||||
|
return false;
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isSavePlateOther(type, timestamp, plate) {
|
||||||
|
if (type === "in") {
|
||||||
|
for (var i = 0; i < currentInOther.length; i++) {
|
||||||
|
if ((timestamp - currentInOther[i].time) < 600) {
|
||||||
|
if (plate === currentInOther[i].plate) {
|
||||||
|
return false;
|
||||||
|
} else if (levenshtein(plate, currentInOther[i].plate) < 2) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (type === "out") {
|
||||||
|
for (var i = 0; i < currentOutOther.length; i++) {
|
||||||
|
if ((timestamp - currentOutOther[i].time) < 600) {
|
||||||
|
if (plate === currentOutOther[i].plate) {
|
||||||
|
return false;
|
||||||
|
} else if (levenshtein(plate, currentOutOther[i].plate) < 2) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function consoleLogPlate(type, reqPlate, currentPlate, currentTimestamp, saveType) {
|
||||||
|
if (type === "in") {
|
||||||
|
var listsIn = [];
|
||||||
|
for (var i = 0; i < currentIn.length; i++) {
|
||||||
|
listsIn.push(currentIn[i].plate);
|
||||||
|
}
|
||||||
|
console.log("req: ", reqPlate, " ", currentPlate, " ", type, " ", saveType, " ", listsIn);
|
||||||
|
|
||||||
|
if (currentIn.length >= maxCompare) {
|
||||||
|
currentIn.shift();
|
||||||
|
}
|
||||||
|
currentIn.push({"plate": currentPlate, "time": currentTimestamp});
|
||||||
|
}
|
||||||
|
if (type === "out") {
|
||||||
|
var listsOut = [];
|
||||||
|
for (var i = 0; i < currentOut.length; i++) {
|
||||||
|
listsOut.push(currentOut[i].plate);
|
||||||
|
}
|
||||||
|
console.log("req: ", reqPlate, " ", currentPlate, " ", type, " ", saveType, " ", listsOut);
|
||||||
|
if (currentOut.length >= maxCompare) {
|
||||||
|
currentOut.shift();
|
||||||
|
}
|
||||||
|
currentOut.push({"plate": currentPlate, "time": currentTimestamp});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function consoleLogPlateOther(type, reqPlate, currentPlate, currentTimestamp, saveType) {
|
||||||
|
if (type === "in") {
|
||||||
|
var listsIn = [];
|
||||||
|
for (var i = 0; i < currentInOther.length; i++) {
|
||||||
|
listsIn.push(currentInOther[i].plate);
|
||||||
|
}
|
||||||
|
console.log("req: ", reqPlate, " ", currentPlate, " ", type, " ", saveType, " ", listsIn);
|
||||||
|
|
||||||
|
if (currentInOther.length >= maxCompare) {
|
||||||
|
currentInOther.shift();
|
||||||
|
}
|
||||||
|
currentInOther.push({"plate": currentPlate, "time": currentTimestamp});
|
||||||
|
}
|
||||||
|
if (type === "out") {
|
||||||
|
var listsOut = [];
|
||||||
|
for (var i = 0; i < currentOutOther.length; i++) {
|
||||||
|
listsOut.push(currentOutOther[i].plate);
|
||||||
|
}
|
||||||
|
console.log("req: ", reqPlate, " ", currentPlate, " ", type, " ", saveType, " ", listsOut);
|
||||||
|
if (currentOutOther.length >= maxCompare) {
|
||||||
|
currentOutOther.shift();
|
||||||
|
}
|
||||||
|
currentOutOther.push({"plate": currentPlate, "time": currentTimestamp});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const db = makeDb(config);
|
||||||
|
|
||||||
exports.SaveLogs = async function (req, res) {
|
exports.SaveLogs = async function (req, res) {
|
||||||
|
|
||||||
|
@ -90,72 +197,87 @@ exports.SaveLogs = async function (req, res) {
|
||||||
fs.mkdirSync(rootDir + currentYear + "/" + currentMonth + "/" + currentDate + "/" + req.body.type + "/frame");
|
fs.mkdirSync(rootDir + currentYear + "/" + currentMonth + "/" + currentDate + "/" + req.body.type + "/frame");
|
||||||
var currentTimestamp = Math.round(today.getTime() / 1000);
|
var currentTimestamp = Math.round(today.getTime() / 1000);
|
||||||
|
|
||||||
var canSaveLogs = true;
|
|
||||||
var vehicleInfo = {"status": false};
|
var vehicleInfo = {"status": false};
|
||||||
|
|
||||||
if (req.body.type === "in") {
|
var currentPlate = "";
|
||||||
for (var i = 0; i < currentIn.length; i++) {
|
var fileName = req.body.plate + "_" + currentTimestamp + ".png";
|
||||||
if ((currentTimestamp - currentIn[i].time) < 600) {
|
var plateSaved = currentYear + "/" + currentMonth + "/" + currentDate + "/" + req.body.type + "/plate/" + fileName;
|
||||||
if (req.body.plate === currentIn[i].plate) {
|
var frameSaved = currentYear + "/" + currentMonth + "/" + currentDate + "/" + req.body.type + "/frame/" + fileName;
|
||||||
canSaveLogs = false;
|
|
||||||
} else if (levenshtein(req.body.plate, currentIn[i].plate) < 2) {
|
await fs.writeFileSync(rootDir + plateSaved, req.body.plate_image, 'base64');
|
||||||
canSaveLogs = false;
|
await fs.writeFileSync(rootDir + frameSaved, req.body.frame_image, 'base64');
|
||||||
}
|
|
||||||
}
|
var query_plate_raw = await db.query("SELECT * FROM vehicle WHERE plate='" + req.body.plate + "'");
|
||||||
|
if (query_plate_raw.length > 0) {
|
||||||
|
vehicleInfo = {"status": true, "data": query_plate_raw[0]};
|
||||||
|
currentPlate = query_plate_raw[0].plate;
|
||||||
|
if (req.body.type == "in" && isSavePlate(req.body.type, currentTimestamp, currentPlate)) {
|
||||||
|
var newLogs = await db.query("INSERT INTO logs(`vehicle_id`,`plate_image_in`,`frame_image_in`,`time_in`) VALUES ('" + query_plate_raw[0].id + "','" + plateSaved + "','" + frameSaved + "'," + currentTimestamp + ")");
|
||||||
|
io.emit('logs', {
|
||||||
|
id: newLogs.insertId,
|
||||||
|
vehicleInfo: query_plate_raw[0],
|
||||||
|
type: "in",
|
||||||
|
image: plateSaved,
|
||||||
|
time: currentTimestamp
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
if (req.body.type == "out" && isSavePlate(req.body.type, currentTimestamp, currentPlate)) {
|
||||||
if (req.body.type === "out") {
|
var checkIn = await db.query("SELECT * FROM logs WHERE vehicle_id=" + query_plate_raw[0].id + " AND time_out=0 ORDER BY time_in DESC LIMIT 0,1");
|
||||||
for (var i = 0; i < currentOut.length; i++) {
|
if (checkIn.length > 0) {
|
||||||
if ((currentTimestamp - currentOut[i].time) < 600) {
|
await db.query("UPDATE logs SET `plate_image_out`='" + plateSaved + "',`frame_image_out`='" + frameSaved + "',`time_out`=" + currentTimestamp + " WHERE id=" + checkIn[0].id);
|
||||||
if (req.body.plate === currentOut[i].plate) {
|
io.emit('logs', {
|
||||||
canSaveLogs = false;
|
id: checkIn[0].id,
|
||||||
} else if (levenshtein(req.body.plate, currentOut[i].plate) < 2) {
|
vehicleInfo: query_plate_raw[0],
|
||||||
canSaveLogs = false;
|
type: "out",
|
||||||
}
|
image: plateSaved,
|
||||||
}
|
time: currentTimestamp,
|
||||||
}
|
logs: checkIn[0]
|
||||||
}
|
});
|
||||||
|
} else {
|
||||||
if (canSaveLogs) {
|
var newLogs = await db.query("INSERT INTO logs(`vehicle_id`,`plate_image_out`,`frame_image_out`,`time_out`) VALUES ('" + query_plate_raw[0].id + "','" + plateSaved + "','" + frameSaved + "'," + currentTimestamp + ")");
|
||||||
var currentPlate = "";
|
|
||||||
var fileName = req.body.plate + "_" + currentTimestamp + ".png";
|
|
||||||
var plateSaved = currentYear + "/" + currentMonth + "/" + currentDate + "/" + req.body.type + "/plate/" + fileName;
|
|
||||||
var frameSaved = currentYear + "/" + currentMonth + "/" + currentDate + "/" + req.body.type + "/frame/" + fileName;
|
|
||||||
|
|
||||||
await fs.writeFileSync(rootDir + plateSaved, req.body.plate_image, 'base64');
|
|
||||||
await fs.writeFileSync(rootDir + frameSaved, req.body.frame_image, 'base64');
|
|
||||||
|
|
||||||
var query_plate_raw = await db.query("SELECT * FROM vehicle WHERE plate='" + req.body.plate + "'");
|
|
||||||
if (query_plate_raw.length > 0) {
|
|
||||||
vehicleInfo = {"status": true, "data": query_plate_raw[0]};
|
|
||||||
currentPlate = query_plate_raw[0].plate;
|
|
||||||
if (req.body.type == "in") {
|
|
||||||
var newLogs = await db.query("INSERT INTO logs(`vehicle_id`,`plate_image_in`,`frame_image_in`,`time_in`) VALUES ('" + query_plate_raw[0].id + "','" + plateSaved + "','" + frameSaved + "'," + currentTimestamp + ")");
|
|
||||||
io.emit('logs', {
|
io.emit('logs', {
|
||||||
id: newLogs.insertId,
|
id: newLogs.insertId,
|
||||||
vehicleInfo: query_plate_raw[0],
|
vehicleInfo: query_plate_raw[0],
|
||||||
|
type: "out",
|
||||||
|
image: plateSaved,
|
||||||
|
time: currentTimestamp,
|
||||||
|
logs: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
consoleLogPlate(req.body.type, req.body.plate, currentPlate, currentTimestamp, "absolute");
|
||||||
|
} else {
|
||||||
|
var query_plate_levenshtein = await db.query("SELECT * FROM `vehicle` WHERE LENGTH(`plate`)=" + req.body.plate.length + " AND levenshtein('" + req.body.plate + "', `plate`) BETWEEN 0 AND 1 LIMIT 0,1");
|
||||||
|
if (query_plate_levenshtein.length > 0) {
|
||||||
|
vehicleInfo = {"status": true, "data": query_plate_levenshtein[0]};
|
||||||
|
currentPlate = query_plate_levenshtein[0].plate;
|
||||||
|
if (req.body.type == "in" && isSavePlate(req.body.type, currentTimestamp, currentPlate)) {
|
||||||
|
var newLogs = await db.query("INSERT INTO logs(`vehicle_id`,`plate_image_in`,`frame_image_in`,`time_in`) VALUES ('" + query_plate_levenshtein[0].id + "','" + plateSaved + "','" + frameSaved + "'," + currentTimestamp + ")");
|
||||||
|
io.emit('logs', {
|
||||||
|
id: newLogs.insertId,
|
||||||
|
vehicleInfo: query_plate_levenshtein[0],
|
||||||
type: "in",
|
type: "in",
|
||||||
image: plateSaved,
|
image: plateSaved,
|
||||||
time: currentTimestamp
|
time: currentTimestamp
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (req.body.type == "out") {
|
if (req.body.type == "out" && isSavePlate(req.body.type, currentTimestamp, currentPlate)) {
|
||||||
var checkIn = await db.query("SELECT * FROM logs WHERE vehicle_id=" + query_plate_raw[0].id + " AND time_out=0 ORDER BY time_in DESC LIMIT 0,1");
|
var checkIn = await db.query("SELECT * FROM logs WHERE vehicle_id=" + query_plate_levenshtein[0].id + " AND time_out=0 ORDER BY time_in DESC LIMIT 0,1");
|
||||||
if (checkIn.length > 0) {
|
if (checkIn.length > 0) {
|
||||||
await db.query("UPDATE logs SET `plate_image_out`='" + plateSaved + "',`frame_image_out`='" + frameSaved + "',`time_out`=" + currentTimestamp + " WHERE id=" + checkIn[0].id);
|
await db.query("UPDATE logs SET `plate_image_out`='" + plateSaved + "',`frame_image_out`='" + frameSaved + "',`time_out`=" + currentTimestamp + " WHERE id=" + checkIn[0].id);
|
||||||
io.emit('logs', {
|
io.emit('logs', {
|
||||||
id: checkIn[0].id,
|
id: checkIn[0].id,
|
||||||
vehicleInfo: query_plate_raw[0],
|
vehicleInfo: query_plate_levenshtein[0],
|
||||||
type: "out",
|
type: "out",
|
||||||
image: plateSaved,
|
image: plateSaved,
|
||||||
time: currentTimestamp,
|
time: currentTimestamp,
|
||||||
logs: checkIn[0]
|
logs: checkIn[0]
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var newLogs = await db.query("INSERT INTO logs(`vehicle_id`,`plate_image_out`,`frame_image_out`,`time_out`) VALUES ('" + query_plate_raw[0].id + "','" + plateSaved + "','" + frameSaved + "'," + currentTimestamp + ")");
|
var newLogs = await db.query("INSERT INTO logs(`vehicle_id`,`plate_image_out`,`frame_image_out`,`time_out`) VALUES ('" + query_plate_levenshtein[0].id + "','" + plateSaved + "','" + frameSaved + "'," + currentTimestamp + ")");
|
||||||
io.emit('logs', {
|
io.emit('logs', {
|
||||||
id: newLogs.insertId,
|
id: newLogs.insertId,
|
||||||
vehicleInfo: query_plate_raw[0],
|
vehicleInfo: query_plate_levenshtein[0],
|
||||||
type: "out",
|
type: "out",
|
||||||
image: plateSaved,
|
image: plateSaved,
|
||||||
time: currentTimestamp,
|
time: currentTimestamp,
|
||||||
|
@ -163,109 +285,43 @@ exports.SaveLogs = async function (req, res) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
consoleLogPlate(req.body.type, req.body.plate, currentPlate, currentTimestamp, "levenshtein");
|
||||||
} else {
|
} else {
|
||||||
var query_plate_levenshtein = await db.query("SELECT * FROM `vehicle` WHERE LENGTH(`plate`)>=" + req.body.plate.length + " AND levenshtein('" + req.body.plate + "', `plate`) BETWEEN 0 AND 1 LIMIT 0,1");
|
currentPlate = req.body.plate;
|
||||||
if (query_plate_levenshtein.length > 0) {
|
if (req.body.type == "in" && isSavePlateOther(req.body.type, currentTimestamp, currentPlate)) {
|
||||||
vehicleInfo = {"status": true, "data": query_plate_levenshtein[0]};
|
if (falseIn < maxFalse) {
|
||||||
currentPlate = query_plate_levenshtein[0].plate;
|
vehicleInfo = {"status": false};
|
||||||
if (req.body.type == "in") {
|
falseIn++;
|
||||||
var newLogs = await db.query("INSERT INTO logs(`vehicle_id`,`plate_image_in`,`frame_image_in`,`time_in`) VALUES ('" + query_plate_levenshtein[0].id + "','" + plateSaved + "','" + frameSaved + "'," + currentTimestamp + ")");
|
console.log("status: results in not found");
|
||||||
io.emit('logs', {
|
} else {
|
||||||
id: newLogs.insertId,
|
falseIn = 0;
|
||||||
vehicleInfo: query_plate_levenshtein[0],
|
vehicleInfo = {"status": true};
|
||||||
type: "in",
|
await db.query("INSERT INTO logs_unknow(`plate`,`plate_image_in`,`frame_image_in`,`time_in`) VALUES ('" + req.body.plate + "','" + plateSaved + "','" + frameSaved + "'," + currentTimestamp + ")");
|
||||||
image: plateSaved,
|
|
||||||
time: currentTimestamp
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if (req.body.type == "out") {
|
}
|
||||||
var checkIn = await db.query("SELECT * FROM logs WHERE vehicle_id=" + query_plate_levenshtein[0].id + " AND time_out=0 ORDER BY time_in DESC LIMIT 0,1");
|
if (req.body.type == "out" && isSavePlateOther(req.body.type, currentTimestamp, currentPlate)) {
|
||||||
if (checkIn.length > 0) {
|
if (falseOut < maxFalse) {
|
||||||
await db.query("UPDATE logs SET `plate_image_out`='" + plateSaved + "',`frame_image_out`='" + frameSaved + "',`time_out`=" + currentTimestamp + " WHERE id=" + checkIn[0].id);
|
vehicleInfo = {"status": false};
|
||||||
io.emit('logs', {
|
falseOut++;
|
||||||
id: checkIn[0].id,
|
console.log("status: results out not found");
|
||||||
vehicleInfo: query_plate_levenshtein[0],
|
} else {
|
||||||
type: "out",
|
falseIn = 0;
|
||||||
image: plateSaved,
|
vehicleInfo = {"status": true};
|
||||||
time: currentTimestamp,
|
var checkIn_raw = await db.query("SELECT * FROM logs_unknow WHERE plate='" + req.body.plate + "' AND time_out=0 ORDER BY time_in DESC LIMIT 0,1");
|
||||||
logs: checkIn[0]
|
if (checkIn_raw.length > 0) {
|
||||||
});
|
await db.query("UPDATE logs_unknow SET `plate_image_out`='" + plateSaved + "',`frame_image_out`='" + frameSaved + "',`time_out`=" + currentTimestamp + " WHERE id=" + checkIn_raw[0].id);
|
||||||
} else {
|
} else {
|
||||||
var newLogs = await db.query("INSERT INTO logs(`vehicle_id`,`plate_image_out`,`frame_image_out`,`time_out`) VALUES ('" + query_plate_levenshtein[0].id + "','" + plateSaved + "','" + frameSaved + "'," + currentTimestamp + ")");
|
var checkIn_levenshtein = await db.query("SELECT * FROM `logs_unknow` WHERE levenshtein('" + req.body.plate + "', `plate`) BETWEEN 0 AND 1 AND time_out=0 ORDER BY time_in DESC LIMIT 0,1");
|
||||||
io.emit('logs', {
|
if (checkIn_levenshtein.length > 0) {
|
||||||
id: newLogs.insertId,
|
await db.query("UPDATE logs_unknow SET `plate_image_out`='" + plateSaved + "',`frame_image_out`='" + frameSaved + "',`time_out`=" + currentTimestamp + " WHERE id=" + checkIn_levenshtein[0].id);
|
||||||
vehicleInfo: query_plate_levenshtein[0],
|
|
||||||
type: "out",
|
|
||||||
image: plateSaved,
|
|
||||||
time: currentTimestamp,
|
|
||||||
logs: false
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
currentPlate = req.body.plate;
|
|
||||||
if (req.body.type == "in") {
|
|
||||||
if (falseIn < maxFalse) {
|
|
||||||
vehicleInfo = {"status": false};
|
|
||||||
falseIn++;
|
|
||||||
console.log("status: results in not found");
|
|
||||||
} else {
|
|
||||||
falseIn = 0;
|
|
||||||
vehicleInfo = {"status": true};
|
|
||||||
await db.query("INSERT INTO logs_unknow(`plate`,`plate_image_in`,`frame_image_in`,`time_in`) VALUES ('" + req.body.plate + "','" + plateSaved + "','" + frameSaved + "'," + currentTimestamp + ")");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (req.body.type == "out") {
|
|
||||||
if (falseOut < maxFalse) {
|
|
||||||
vehicleInfo = {"status": false};
|
|
||||||
falseOut++;
|
|
||||||
console.log("status: results out not found");
|
|
||||||
} else {
|
|
||||||
falseIn = 0;
|
|
||||||
vehicleInfo = {"status": true};
|
|
||||||
var checkIn_raw = await db.query("SELECT * FROM logs_unknow WHERE plate='" + req.body.plate + "' AND time_out=0 ORDER BY time_in DESC LIMIT 0,1");
|
|
||||||
if (checkIn_raw.length > 0) {
|
|
||||||
await db.query("UPDATE logs_unknow SET `plate_image_out`='" + plateSaved + "',`frame_image_out`='" + frameSaved + "',`time_out`=" + currentTimestamp + " WHERE id=" + checkIn_raw[0].id);
|
|
||||||
} else {
|
} else {
|
||||||
var checkIn_levenshtein = await db.query("SELECT * FROM `logs_unknow` WHERE levenshtein('" + req.body.plate + "', `plate`) BETWEEN 0 AND 1 AND time_out=0 ORDER BY time_in DESC LIMIT 0,1");
|
await db.query("INSERT INTO logs_unknow(`plate`,`plate_image_out`,`frame_image_out`,`time_out`) VALUES ('" + req.body.plate + "','" + plateSaved + "','" + frameSaved + "'," + currentTimestamp + ")");
|
||||||
if (checkIn_levenshtein.length > 0) {
|
|
||||||
await db.query("UPDATE logs_unknow SET `plate_image_out`='" + plateSaved + "',`frame_image_out`='" + frameSaved + "',`time_out`=" + currentTimestamp + " WHERE id=" + checkIn_levenshtein[0].id);
|
|
||||||
} else {
|
|
||||||
await db.query("INSERT INTO logs_unknow(`plate`,`plate_image_out`,`frame_image_out`,`time_out`) VALUES ('" + req.body.plate + "','" + plateSaved + "','" + frameSaved + "'," + currentTimestamp + ")");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
consoleLogPlateOther(req.body.type, req.body.plate, currentPlate, currentTimestamp, "other");
|
||||||
}
|
}
|
||||||
if (req.body.type === "in") {
|
|
||||||
var lists = [];
|
|
||||||
for (var i = 0; i < currentIn.length; i++) {
|
|
||||||
lists.push(currentIn[i].plate);
|
|
||||||
}
|
|
||||||
console.log("req: ", req.body.plate, " ", currentPlate, " ", req.body.type, " ", lists, " ", vehicleInfo.status);
|
|
||||||
if (vehicleInfo.status) {
|
|
||||||
if (currentIn.length >= maxCompare) {
|
|
||||||
currentIn.shift();
|
|
||||||
}
|
|
||||||
currentIn.push({"plate": currentPlate, "time": currentTimestamp});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (req.body.type === "out") {
|
|
||||||
var lists = [];
|
|
||||||
for (var i = 0; i < currentOut.length; i++) {
|
|
||||||
lists.push(currentOut[i].plate);
|
|
||||||
}
|
|
||||||
console.log("req: ", req.body.plate, " ", currentPlate, " ", req.body.type, " ", lists, " ", vehicleInfo.status);
|
|
||||||
if (vehicleInfo.status) {
|
|
||||||
if (currentOut.length >= maxCompare) {
|
|
||||||
currentOut.shift();
|
|
||||||
}
|
|
||||||
currentOut.push({"plate": currentPlate, "time": currentTimestamp});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
res.send(vehicleInfo);
|
|
||||||
} else {
|
|
||||||
res.send({"status": true});
|
|
||||||
}
|
}
|
||||||
|
res.send(vehicleInfo);
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user