|
|
|
@ -159,8 +159,10 @@ public class AlertRuleServiceImpl implements IAlertRuleService |
|
|
|
.append(" FROM equ_gather ") |
|
|
|
.append(" FROM equ_gather ") |
|
|
|
.append(" GROUP BY equ_id ") |
|
|
|
.append(" GROUP BY equ_id ") |
|
|
|
.append(") latest ON g.equ_id = latest.equ_id AND g.gather_time = latest.latest_time ") |
|
|
|
.append(") latest ON g.equ_id = latest.equ_id AND g.gather_time = latest.latest_time ") |
|
|
|
.append("WHERE ") |
|
|
|
.append("WHERE b.status = '1' "); // 先把固定条件放在前面
|
|
|
|
.append(buildConditionsSql(conditions)); |
|
|
|
if (!buildConditionsSql(conditions).isEmpty()) { |
|
|
|
|
|
|
|
sql.append(" AND ").append(buildConditionsSql(conditions)); |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// 其他表,需要连 equ_gather → equ_base → equ_type
|
|
|
|
// 其他表,需要连 equ_gather → equ_base → equ_type
|
|
|
|
sql.append("src.*, g.equ_id, t.name AS equ_type,b.name AS equ_name,b.equ_number ") |
|
|
|
sql.append("src.*, g.equ_id, t.name AS equ_type,b.name AS equ_name,b.equ_number ") |
|
|
|
@ -168,8 +170,12 @@ public class AlertRuleServiceImpl implements IAlertRuleService |
|
|
|
.append("JOIN equ_gather g ON src.equ_gather_id = g.id ") |
|
|
|
.append("JOIN equ_gather g ON src.equ_gather_id = g.id ") |
|
|
|
.append("JOIN equ_base b ON g.equ_id = b.id ") |
|
|
|
.append("JOIN equ_base b ON g.equ_id = b.id ") |
|
|
|
.append("JOIN equ_type t ON b.equ_type = t.id ") // ★ 新增关联
|
|
|
|
.append("JOIN equ_type t ON b.equ_type = t.id ") // ★ 新增关联
|
|
|
|
.append("WHERE ") |
|
|
|
.append("WHERE b.status = '1' "); // 先把固定条件放在前面
|
|
|
|
.append(buildConditionsSql(conditions)); |
|
|
|
|
|
|
|
|
|
|
|
if (!buildConditionsSql(conditions).isEmpty()) { |
|
|
|
|
|
|
|
sql.append(" AND ").append(buildConditionsSql(conditions)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return sql.toString(); |
|
|
|
return sql.toString(); |
|
|
|
|