diff --git a/db/notification_error.db.js b/db/notification_error.db.js index 7648683..8f1aa38 100644 --- a/db/notification_error.db.js +++ b/db/notification_error.db.js @@ -31,7 +31,7 @@ const getNotificationByIdDb = async (id) => { ON b.plant_sub_section_id = c.plant_sub_section_id LEFT JOIN m_device d - ON b.device_id = d.device_id AND d.deleted_at IS NULL + ON a.error_chanel = d.listen_channel AND d.deleted_at IS NULL LEFT JOIN m_brands e ON d.brand_id = e.brand_id AND d.deleted_at IS NULL @@ -102,8 +102,10 @@ const getAllNotificationDb = async (searchParams = {}) => { c.type_solution, c.path_solution, + d.device_code, d.device_name, d.device_location, + e.brand_name, COALESCE(d.device_name, '') + ' - ' + COALESCE(b.error_code_name, '') AS device_name_error @@ -116,7 +118,10 @@ const getAllNotificationDb = async (searchParams = {}) => { ON b.error_code_id = c.error_code_id AND c.deleted_at IS NULL LEFT JOIN m_device d - ON b.brand_id = d.brand_id AND d.deleted_at IS NULL + ON a.error_chanel = d.listen_channel AND d.deleted_at IS NULL + + LEFT JOIN m_brands e + ON d.brand_id = e.brand_id AND d.deleted_at IS NULL WHERE a.deleted_at IS NULL ${whereConditions.length > 0 ? ` AND ${whereConditions.join(" AND ")}` : ""} diff --git a/db/notification_error_log.db.js b/db/notification_error_log.db.js index 1a8a0cf..8c8a4d9 100644 --- a/db/notification_error_log.db.js +++ b/db/notification_error_log.db.js @@ -7,7 +7,7 @@ const getAllNotificationErrorLogDb = async () => { b.contact_name, b.contact_type FROM notification_error_log a - LEFT JOIN contact b ON a.contact_id = b.contact_id + LEFT JOIN contact b ON a.contact_phone = b.contact_phone WHERE a.deleted_at IS NULL ORDER BY a.notification_error_log_id DESC `; @@ -22,7 +22,7 @@ const getNotificationErrorLogByIdDb = async (id) => { b.contact_name, b.contact_type FROM notification_error_log a - LEFT JOIN contact b ON a.contact_id = b.contact_id + LEFT JOIN contact b ON a.contact_phone = b.contact_phone WHERE a.notification_error_log_id = $1 AND a.deleted_at IS NULL `; const result = await pool.query(queryText, [id]); @@ -36,7 +36,7 @@ const getNotificationErrorLogByNotificationErrorIdDb = async (notificationErrorI b.contact_name, b.contact_type FROM notification_error_log a - LEFT JOIN contact b ON a.contact_id = b.contact_id + LEFT JOIN contact b ON a.contact_phone = b.contact_phone WHERE a.notification_error_id = $1 AND a.deleted_at IS NULL ORDER BY a.created_at DESC `;