This commit is contained in:
pringgosutono
2026-03-04 09:54:24 +07:00
parent 69bf7a31e8
commit fa57409573

View File

@ -24,6 +24,7 @@ async function commitMessage(now, logDevice) {
} }
const vhc = await VhcModels.getVhcByDeviceId(logDevice.device_id) const vhc = await VhcModels.getVhcByDeviceId(logDevice.device_id)
logDevice.vhc_id = vhc[0] ? vhc[0].vid : 0
// const lastTrack = await GpsTracksModels.get2LastLocByDeviceId(logDevice.device_id) // const lastTrack = await GpsTracksModels.get2LastLocByDeviceId(logDevice.device_id)
let lastTrack let lastTrack
if (vhc.length > 0) if (vhc.length > 0)
@ -33,8 +34,8 @@ async function commitMessage(now, logDevice) {
logDevice.device_id, logDevice.device_id,
) )
if (logDevice.device_id == "0353742374791143") // if (logDevice.device_id == "0353742372637637")
console.log("vhc", vhc, lastTrack) // console.log("vhc", vhc, lastTrack)
if (["heartbeat", "alarm"].includes(logDevice.action)) { if (["heartbeat", "alarm"].includes(logDevice.action)) {
if (logDevice.ignition == GpsTracksModels.STTS_IGNITION_HIGH) { if (logDevice.ignition == GpsTracksModels.STTS_IGNITION_HIGH) {
@ -182,7 +183,7 @@ async function commitMessage(now, logDevice) {
lastTrack[0].sum_milleage + logDevice.pre_milleage lastTrack[0].sum_milleage + logDevice.pre_milleage
).toFixed(8) ).toFixed(8)
if (vhc.length > 0) { if (vhc.length > 0) {
logDevice.vhc_id = vhc[0] ? vhc[0].vid : 0 // logDevice.vhc_id = vhc[0] ? vhc[0].vid : 0
// if (lastTrack[0].vhc_id == logDevice.vhc_id) { // if (lastTrack[0].vhc_id == logDevice.vhc_id) {
// logDevice.vhc_milleage = (lastTrack[0].vhc_milleage + logDevice.pre_milleage).toFixed(8); // logDevice.vhc_milleage = (lastTrack[0].vhc_milleage + logDevice.pre_milleage).toFixed(8);
// } else { // } else {
@ -295,8 +296,8 @@ async function commitMessage(now, logDevice) {
} }
// LibMail.sendVhcSpawnZoneMail(`${(vhc[0]) ? vhc[0].nopol1 : 0 || ''}${(vhc[0]) ? vhc[0].nopol2 : 0 || ''}${(vhc[0]) ? vhc[0].nopol3 : 0 || ''} entering zone ${mailData.z_name}`, mailData.pic_mail, mailData); // LibMail.sendVhcSpawnZoneMail(`${(vhc[0]) ? vhc[0].nopol1 : 0 || ''}${(vhc[0]) ? vhc[0].nopol2 : 0 || ''}${(vhc[0]) ? vhc[0].nopol3 : 0 || ''} entering zone ${mailData.z_name}`, mailData.pic_mail, mailData);
if (logDevice.device_id === "0865784052395871") // if (logDevice.device_id === "0865784052395871")
console.log(1234567890) // console.log(1234567890)
GpsTracksModels.create2SpawnZone({ GpsTracksModels.create2SpawnZone({
device_id: logDevice.device_id, device_id: logDevice.device_id,
master_id: Number(currTrack.result.insertId), master_id: Number(currTrack.result.insertId),
@ -319,8 +320,8 @@ async function commitMessage(now, logDevice) {
.unix(now) .unix(now)
.format("YYYY-MM-DD HH:mm:ss"), .format("YYYY-MM-DD HH:mm:ss"),
}) })
if (logDevice.device_id === "0865784052395871") // if (logDevice.device_id === "0865784052395871")
console.log("DISINI") // console.log("DISINI")
} }
} }
} else { } else {