update sms over speed condition, user got sms if vehicle id is same with role
This commit is contained in:
@ -338,7 +338,11 @@ async function commitMessage(now, logDevice) {
|
|||||||
// check speed limit, if speed > vhc.speed_limit, send sms
|
// check speed limit, if speed > vhc.speed_limit, send sms
|
||||||
if (Array.isArray(vhc) && vhc.length > 0 && vhc[0].speed_limit > 0 && logDevice.speed > vhc[0].speed_limit) {
|
if (Array.isArray(vhc) && vhc.length > 0 && vhc[0].speed_limit > 0 && logDevice.speed > vhc[0].speed_limit) {
|
||||||
|
|
||||||
const users = await db.query(`SELECT phone FROM t_users WHERE status_sms = 1`, [])
|
// const users = await db.query(`SELECT phone FROM t_users WHERE status_sms = 1`, [])
|
||||||
|
const users = await db.query(
|
||||||
|
`SELECT phone FROM t_users WHERE status_sms = 1 AND FIND_IN_SET(?, vhc) > 0`,
|
||||||
|
[vhc[0].id]
|
||||||
|
)
|
||||||
if (!users?.length) return
|
if (!users?.length) return
|
||||||
|
|
||||||
const nopol = (vhc[0].nopol1 ?? "") + (vhc[0].nopol2 ?? "") + (vhc[0].nopol3 ?? "")
|
const nopol = (vhc[0].nopol1 ?? "") + (vhc[0].nopol2 ?? "") + (vhc[0].nopol3 ?? "")
|
||||||
|
|||||||
Reference in New Issue
Block a user