edit time
This commit is contained in:
parent
4e4658ee5e
commit
365a929ef7
|
@ -36,7 +36,9 @@ exports.SaveLogs = async function (req, res) {
|
||||||
if (result == "") {
|
if (result == "") {
|
||||||
console.log("Nothing to show");
|
console.log("Nothing to show");
|
||||||
//timestamp in seconds
|
//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')";
|
var today = new Date();
|
||||||
|
var currentTimeInInt = Math.round(today.getTime() / 1000);
|
||||||
|
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'," + currentTimeInInt + ",'1','1',11,'1','1','1')";
|
||||||
con.query(sql_insert_logs_unknow_cmd, function (err, result, fields) {
|
con.query(sql_insert_logs_unknow_cmd, function (err, result, fields) {
|
||||||
if (err)
|
if (err)
|
||||||
throw err;
|
throw err;
|
||||||
|
@ -51,9 +53,11 @@ exports.SaveLogs = async function (req, res) {
|
||||||
con.query("SELECT id FROM vehicle where `plate`='" + result[0].plate + "'", function (err, result_vehicle_id) {
|
con.query("SELECT id FROM vehicle where `plate`='" + result[0].plate + "'", function (err, result_vehicle_id) {
|
||||||
if (err)
|
if (err)
|
||||||
throw err;
|
throw err;
|
||||||
console.log("result_vehicle_id");
|
console.log("result_vehicle_id");
|
||||||
console.log(result_vehicle_id[0].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',"+Math.floor(Date.now() / 1000)+",'1','1',11,'1','1','1')";
|
var today = new Date();
|
||||||
|
var currentTimeInInt = Math.round(today.getTime() / 1000);
|
||||||
|
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'," + currentTimeInInt + ",'1','1',11,'1','1','1')";
|
||||||
con.query(sql_insert_logs_cmd, function (err, result, fields) {
|
con.query(sql_insert_logs_cmd, function (err, result, fields) {
|
||||||
if (err)
|
if (err)
|
||||||
throw err;
|
throw err;
|
||||||
|
@ -62,7 +66,7 @@ exports.SaveLogs = async function (req, res) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const base64Image=req.body.plate_image;
|
const base64Image = req.body.plate_image;
|
||||||
const imageBuffer = new Buffer(base64Image, "base64");
|
const imageBuffer = new Buffer(base64Image, "base64");
|
||||||
fs.writeFileSync("image.jpg", imageBuffer);
|
fs.writeFileSync("image.jpg", imageBuffer);
|
||||||
console.log("wrote image");
|
console.log("wrote image");
|
||||||
|
|
|
@ -3,5 +3,5 @@
|
||||||
module.exports = function (app) {
|
module.exports = function (app) {
|
||||||
var Api = require('../controllers/ApiController');
|
var Api = require('../controllers/ApiController');
|
||||||
|
|
||||||
app.route('/logs').get(Api.SaveLogs);
|
app.route('/logs').post(Api.SaveLogs);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user