|  |  |  | 
|---|
|  |  |  | SELECT COUNT(*) AS recordCount | 
|---|
|  |  |  | FROM pr_intake inta | 
|---|
|  |  |  | INNER JOIN pr_controller con ON con.intakeId = inta.id | 
|---|
|  |  |  | <if test="onLineMap != null and onLineMap !='' and isOnLine != null"> | 
|---|
|  |  |  | <if test="onLineMap != null and onLineMap !='' and onLineMap != '[]' and isOnLine != null"> | 
|---|
|  |  |  | LEFT JOIN JSON_TABLE( | 
|---|
|  |  |  | <!--'[{"rtuAddr":"37142501020100215","isOnLine":true},{"rtuAddr":"4000004","isOnLine":true},{"rtuAddr":"dy20240325","isOnLine":false}]',--> | 
|---|
|  |  |  | #{onLineMap}, | 
|---|
|  |  |  | 
|---|
|  |  |  | ) rtus ON con.rtuAddr = rtus.rtuAddr | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | WHERE con.intakeId is not null | 
|---|
|  |  |  | <if test="isOnLine != null"> | 
|---|
|  |  |  | AND rtus.isOnLine = #{isOnLine} | 
|---|
|  |  |  | <if test="isOnLine != null and isOnLine == false"> | 
|---|
|  |  |  | <if test="onLineMap != null and onLineMap !='' and onLineMap != '[]'"> | 
|---|
|  |  |  | AND rtus.isOnLine = false OR rtus.rtuAddr IS NULL | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="isOnLine != null and isOnLine == true"> | 
|---|
|  |  |  | <if test="onLineMap != null and onLineMap !='' and onLineMap != '[]'"> | 
|---|
|  |  |  | AND rtus.isOnLine = true | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="intakeNum != null and intakeNum != ''"> | 
|---|
|  |  |  | AND inta.name = #{intakeNum} | 
|---|
|  |  |  | 
|---|
|  |  |  | WHERE (alarm_loss = 1 OR alarm_battery_volt = 1 OR alarm_valve = 1 OR alarm_water_meter_fault = 1) | 
|---|
|  |  |  | AND dt >= DATE_SUB(NOW(), INTERVAL 12 HOUR) | 
|---|
|  |  |  | ) alarm ON alarm.intakeId = inta.id | 
|---|
|  |  |  | <if test="onLineMap != null and onLineMap !='' and isOnLine != null"> | 
|---|
|  |  |  | <if test="onLineMap != null and onLineMap !='' and onLineMap != '[]' and isOnLine != null"> | 
|---|
|  |  |  | LEFT JOIN JSON_TABLE( | 
|---|
|  |  |  | <!--'[{"rtuAddr":"37142501020100215","isOnLine":true},{"rtuAddr":"4000004","isOnLine":true},{"rtuAddr":"dy20240325","isOnLine":false}]',--> | 
|---|
|  |  |  | #{onLineMap}, | 
|---|
|  |  |  | 
|---|
|  |  |  | ) rtus ON con.rtuAddr = rtus.rtuAddr | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | WHERE con.intakeId is not null | 
|---|
|  |  |  | <if test="isOnLine != null"> | 
|---|
|  |  |  | AND rtus.isOnLine = #{isOnLine} | 
|---|
|  |  |  | <if test="isOnLine != null and isOnLine == false"> | 
|---|
|  |  |  | <if test="onLineMap != null and onLineMap !='' and onLineMap != '[]'"> | 
|---|
|  |  |  | AND rtus.isOnLine = false OR rtus.rtuAddr IS NULL | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="isOnLine != null and isOnLine == true"> | 
|---|
|  |  |  | <if test="onLineMap != null and onLineMap !='' and onLineMap != '[]'"> | 
|---|
|  |  |  | AND rtus.isOnLine = true | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="intakeNum != null and intakeNum != ''"> | 
|---|
|  |  |  | AND inta.name = #{intakeNum} | 
|---|