This commit is contained in:
Pringgosutono
2025-10-10 07:13:08 +07:00
parent 6fe3050c1c
commit 84a9ce3f4c

View File

@ -141,9 +141,25 @@ class GpsTracksModels {
let rltmLength = Object.keys(rltm).length
let resLogs = undefined
if (Object.keys(logs).length > 0)
if (Object.keys(logs).length > 0) {
resLogs = await MysqlHelpers.queryTrx(conn, `INSERT INTO t_gps_tracks SET ?;`, [logs])
if (logs.action == "location") {
const date = logs.crt_d
const mm = moment.unix(date).format("MM")
const yy = moment.unix(date).format("YY")
logs.id = resLogs.insertId
await MysqlHelpers.queryTrx(
conn,
`
INSERT INTO tracks_${yy}${mm}
SET ?
`,
[logs]
)
}
}
if (rltmLength > 0 && typeof resLogs !== "undefined") rltm.master_id = resLogs.insertId
if (rltmLength > 0 && rltm.latitude !== null && rltm.longitude !== null) {
let devices = await MysqlHelpers.queryTrx(
@ -187,21 +203,6 @@ class GpsTracksModels {
)
}
if (logs.action == "location") {
const date = logs.crt_d
const mm = moment.unix(date).format("MM")
const yy = moment.unix(date).format("YY")
logs.id = resLogs.insertId
await MysqlHelpers.queryTrx(
conn,
`
INSERT INTO tracks_${yy}${mm}
SET ?
`,
[logs]
)
}
await MysqlHelpers.commit(conn)
resolve({
type: "success",