diff --git a/api/controllers/ApiController.js b/api/controllers/ApiController.js index 7422d45..ae0fc3b 100644 --- a/api/controllers/ApiController.js +++ b/api/controllers/ApiController.js @@ -35,7 +35,8 @@ exports.SaveLogs = async function (req, res) { //if levenshtein not found plate if (result == "") { console.log("Nothing to show"); - sql_insert_logs_unknow_cmd = "INSERT INTO logs_unknow(`id`,`plate`,`plate_image_in`,`frame_image_in`,`time_in`,`plate_image_out`,`frame_image_out`,`time_out`,`seal_no`,`note`,`factory`) VALUES (" + random.int(1, 1000) + ",'" + req.body.plate + "','1','1',11,'1','1',11,'1','1','1')"; + //timestamp in seconds + sql_insert_logs_unknow_cmd = "INSERT INTO logs_unknow(`id`,`plate`,`plate_image_in`,`frame_image_in`,`time_in`,`plate_image_out`,`frame_image_out`,`time_out`,`seal_no`,`note`,`factory`) VALUES (" + random.int(1, 1000) + ",'" + req.body.plate + "','1','1',"+Math.floor(Date.now() / 1000)+",'1','1',11,'1','1','1')"; con.query(sql_insert_logs_unknow_cmd, function (err, result, fields) { if (err) throw err; @@ -52,7 +53,7 @@ exports.SaveLogs = async function (req, res) { throw err; console.log("result_vehicle_id"); console.log(result_vehicle_id[0].id); - sql_insert_logs_cmd = "INSERT INTO logs(`id`,`vehicle_id`,`plate_image_in`,`frame_image_in`,`time_in`,`plate_image_out`,`frame_image_out`,`time_out`,`seal_no`,`note`,`factory`) VALUES (" + random.int(1, 1000) + "," + result_vehicle_id[0].id + ",'1','1',11,'1','1',11,'1','1','1')"; + sql_insert_logs_cmd = "INSERT INTO logs(`id`,`vehicle_id`,`plate_image_in`,`frame_image_in`,`time_in`,`plate_image_out`,`frame_image_out`,`time_out`,`seal_no`,`note`,`factory`) VALUES (" + random.int(1, 1000) + "," + result_vehicle_id[0].id + ",'1','1',"+Math.floor(Date.now() / 1000)+",'1','1',11,'1','1','1')"; con.query(sql_insert_logs_cmd, function (err, result, fields) { if (err) throw err; @@ -61,7 +62,7 @@ exports.SaveLogs = async function (req, res) { }); } }); - const base64Image=req.body.base64; + const base64Image=req.body.plate_image; const imageBuffer = new Buffer(base64Image, "base64"); fs.writeFileSync("image.jpg", imageBuffer); console.log("wrote image");