edit time

This commit is contained in:
LeBo 2020-02-03 09:14:07 +07:00
parent 4e4658ee5e
commit 365a929ef7
2 changed files with 10 additions and 6 deletions

View File

@ -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;
@ -53,7 +55,9 @@ exports.SaveLogs = async function (req, res) {
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;

View File

@ -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);
}; };