From 6aefd96212b19822a07f4b8cb995c2a007388624 Mon Sep 17 00:00:00 2001 From: dongpd Date: Fri, 7 Feb 2020 10:02:28 +0700 Subject: [PATCH] fix bug --- api/controllers/ApiController.js | 58 ++++++++++++++++---------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/api/controllers/ApiController.js b/api/controllers/ApiController.js index 3b87f86..d4f43e2 100644 --- a/api/controllers/ApiController.js +++ b/api/controllers/ApiController.js @@ -113,34 +113,8 @@ exports.SaveLogs = async function (req, res) { } } } - 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, " ", req.body.type, " ", lists, " ", canSaveLogs); - } - 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, " ", req.body.type, " ", lists, " ", canSaveLogs); - } - if (canSaveLogs) { - if (req.body.type === "in") { - if (currentIn.length >= maxCompare) { - currentIn.shift(); - } - currentIn.push({"plate": req.body.plate, "time": currentTimestamp}); - } - if (req.body.type === "out") { - if (currentOut.length >= maxCompare) { - currentOut.shift(); - } - currentOut.push({"plate": req.body.plate, "time": currentTimestamp}); - } + if (canSaveLogs) { 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; @@ -212,8 +186,34 @@ exports.SaveLogs = async function (req, res) { } } } + 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, " ", req.body.type, " ", lists, " ", vehicleInfo.status); + if (vehicleInfo.status) { + if (currentIn.length >= maxCompare) { + currentIn.shift(); + } + currentIn.push({"plate": req.body.plate, "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, " ", req.body.type, " ", lists, " ", vehicleInfo.status); + if (vehicleInfo.status) { + if (currentOut.length >= maxCompare) { + currentOut.shift(); + } + currentOut.push({"plate": req.body.plate, "time": currentTimestamp}); + } + } + res.send(vehicleInfo); } else { - vehicleInfo = {"status": true}; + res.send({"status": true}); } - res.send(vehicleInfo); }; \ No newline at end of file