| | |
| | | <select id="getRecordCount" parameterType="java.util.Map" resultType="java.lang.Long"> |
| | | SELECT COUNT(*) AS recordCount |
| | | FROM pr_intake ge |
| | | INNER JOIN pr_divide divi ON ge.divideId = divi.id |
| | | INNER JOIN ba_block blo ON divi.blockId = blo.id |
| | | LEFT JOIN ba_district country ON ge.countyId = country.id |
| | | LEFT JOIN ba_district town ON ge.townId = town.id |
| | | LEFT JOIN ba_district village ON ge.villageId = village.id |
| | | LEFT JOIN pr_controller cont ON ge.id = cont.intakeId |
| | | INNER JOIN pr_divide divi ON ge.divideId = divi.id |
| | | INNER JOIN ba_block blo ON divi.blockId = blo.id |
| | | LEFT JOIN ba_district country ON ge.countyId = country.id |
| | | LEFT JOIN ba_district town ON ge.townId = town.id |
| | | LEFT JOIN ba_district village ON ge.villageId = village.id |
| | | LEFT JOIN pr_controller cont ON ge.id = cont.intakeId |
| | | left JOIN JSON_TABLE( |
| | | <!--'[{"rtuAddr":"37142501020100215","isOnLine":true},{"rtuAddr":"4000004","isOnLine":true},{"rtuAddr":"dy20240325","isOnLine":false}]',--> |
| | | #{onLineMap}, |
| | | '$[*]' COLUMNS( |
| | | rtuAddr VARCHAR(20) PATH '$.rtuAddr', |
| | | isOnLine BOOLEAN PATH '$.isOnLine' |
| | | ) |
| | | ) rtus ON cont.rtuAddr = rtus.rtuAddr |
| | | <where> |
| | | ge.deleted = 0 |
| | | AND divi.deleted = 0 |
| | | and blo.deleted = 0 |
| | | AND divi.deleted = 0 |
| | | AND blo.deleted = 0 |
| | | <if test="intakeName != null and intakeName != ''"> |
| | | AND ge.name LIKE CONCAT('%', #{intakeName}, '%') |
| | | </if> |
| | |
| | | </if> |
| | | <if test="address != null and address != ''"> |
| | | AND CONCAT(country.`name`, town.`name`, village.`name`) LIKE CONCAT('%', #{address}, '%') |
| | | </if> |
| | | <if test = "rtuAddr != null and rtuAddr !=''"> |
| | | AND cont.rtuAddr like CONCAT('%',#{rtuAddr},'%') |
| | | </if> |
| | | <if test="isOnLine != null and isOnLine !='' "> |
| | | AND rtus.isOnLine = #{isOnLine} |
| | | </if> |
| | | <if test="protocol != null and protocol !='' "> |
| | | AND cont.protocol = #{protocol} |
| | | </if> |
| | | <if test = "bindNumber != null and bindNumber > 0"> |
| | | AND (SELECT COUNT(*) FROM pr_intake_controller WHERE intakeId = ge.id AND operateType = 1) = ${bindNumber} |
| | | </if> |
| | | </where> |
| | | </select> |
| | |
| | | blo.`name` AS blockName, |
| | | CAST(cont.id AS char) AS controllerId, |
| | | cont.rtuAddr AS rtuAddr, |
| | | cont.protocol AS protocol, |
| | | cont.findDt AS findDt, |
| | | rtus.isOnLine AS isOnLine, |
| | | (SELECT COUNT(*) FROM pr_intake_controller WHERE intakeId = ge.id AND operateType = 1) AS bindNumber, |
| | | ge.lng, |
| | | ge.lat, |
| | | ge.remarks, |
| | |
| | | END) AS isBind, |
| | | CONCAT(country.`name`, town.`name`, village.`name`) AS address |
| | | FROM pr_intake ge |
| | | INNER JOIN pr_divide divi ON ge.divideId = divi.id |
| | | INNER JOIN ba_block blo ON divi.blockId = blo.id |
| | | LEFT JOIN ba_district country ON ge.countyId = country.id |
| | | LEFT JOIN ba_district town ON ge.townId = town.id |
| | | LEFT JOIN ba_district village ON ge.villageId = village.id |
| | | LEFT JOIN pr_controller cont ON ge.id = cont.intakeId |
| | | INNER JOIN pr_divide divi ON ge.divideId = divi.id |
| | | INNER JOIN ba_block blo ON divi.blockId = blo.id |
| | | LEFT JOIN ba_district country ON ge.countyId = country.id |
| | | LEFT JOIN ba_district town ON ge.townId = town.id |
| | | LEFT JOIN ba_district village ON ge.villageId = village.id |
| | | LEFT JOIN pr_controller cont ON ge.id = cont.intakeId |
| | | left JOIN JSON_TABLE( |
| | | <!--'[{"rtuAddr":"37142501020100215","isOnLine":true},{"rtuAddr":"4000004","isOnLine":true},{"rtuAddr":"dy20240325","isOnLine":false}]',--> |
| | | #{onLineMap}, |
| | | '$[*]' COLUMNS( |
| | | rtuAddr VARCHAR(20) PATH '$.rtuAddr', |
| | | isOnLine BOOLEAN PATH '$.isOnLine' |
| | | ) |
| | | ) rtus ON cont.rtuAddr = rtus.rtuAddr |
| | | <where> |
| | | ge.deleted = 0 |
| | | AND divi.deleted = 0 |
| | | and blo.deleted = 0 |
| | | AND divi.deleted = 0 |
| | | AND blo.deleted = 0 |
| | | <if test="intakeName != null and intakeName != ''"> |
| | | AND ge.name LIKE CONCAT('%', #{intakeName}, '%') |
| | | </if> |
| | |
| | | </if> |
| | | <if test="address != null and address != ''"> |
| | | AND CONCAT(country.`name`, town.`name`, village.`name`) LIKE CONCAT('%', #{address}, '%') |
| | | </if> |
| | | <if test = "rtuAddr != null and rtuAddr !=''"> |
| | | AND cont.rtuAddr like CONCAT('%',#{rtuAddr},'%') |
| | | </if> |
| | | <if test="isOnLine != null and isOnLine !='' "> |
| | | AND rtus.isOnLine = #{isOnLine} |
| | | </if> |
| | | <if test="protocol != null and protocol !='' "> |
| | | AND cont.protocol = #{protocol} |
| | | </if> |
| | | <if test = "bindNumber != null and bindNumber > 0"> |
| | | AND (SELECT COUNT(*) FROM pr_intake_controller WHERE intakeId = ge.id AND operateType = 1) = ${bindNumber} |
| | | </if> |
| | | </where> |
| | | ORDER BY ge.operateDt DESC |
| | |
| | | LEFT JOIN pr_controller con ON con.intakeId = inta.id |
| | | LEFT JOIN rm_on_hour_report_last hou ON hou.intake_id = inta.id |
| | | LEFT JOIN( |
| | | SELECT intake_id AS intakeId, |
| | | CONCAT( |
| | | IF(alarm_loss = 1, IF(alarm_water_meter_fault = 1, '流量计故障,', ''), |
| | | IF(alarm_water_meter_fault = 1, '流量计故障', '')), |
| | | IF(alarm_battery_volt = 1, IF(alarm_loss = 1, '漏损(偷水)报警,', ''), |
| | | IF(alarm_loss = 1, '漏损(偷水)报警', '')), |
| | | IF(alarm_valve = 1, IF(alarm_battery_volt = 1, '蓄电池电压报警,', ''), |
| | | IF(alarm_battery_volt = 1, '蓄电池电压报警', '')), |
| | | IF(alarm_valve = 1, '阀门报警', '') |
| | | ) AS alarm |
| | | FROM rm_alarm_state_last |
| | | WHERE (alarm_water_meter_fault = 1 OR alarm_loss = 1 OR alarm_battery_volt = 1 OR alarm_valve = 1) |
| | | AND dt >= DATE_SUB(NOW(), INTERVAL 12 HOUR) |
| | | ) alarm ON alarm.intakeId = inta.id |
| | | SELECT intake_id AS intakeId, |
| | | CONCAT( |
| | | IF(alarm_loss = 1, IF(alarm_water_meter_fault = 1, '流量计故障,', ''), |
| | | IF(alarm_water_meter_fault = 1, '流量计故障', '')), |
| | | IF(alarm_battery_volt = 1, IF(alarm_loss = 1, '漏损(偷水)报警,', ''), |
| | | IF(alarm_loss = 1, '漏损(偷水)报警', '')), |
| | | IF(alarm_valve = 1, IF(alarm_battery_volt = 1, '蓄电池电压报警,', ''), |
| | | IF(alarm_battery_volt = 1, '蓄电池电压报警', '')), |
| | | IF(alarm_valve = 1, '阀门报警', '') |
| | | ) AS alarm |
| | | FROM rm_alarm_state_last |
| | | WHERE (alarm_water_meter_fault = 1 OR alarm_loss = 1 OR alarm_battery_volt = 1 OR alarm_valve = 1) |
| | | AND dt >= DATE_SUB(NOW(), INTERVAL 12 HOUR) |
| | | ) alarm ON alarm.intakeId = inta.id |
| | | LEFT JOIN JSON_TABLE( |
| | | <!--'[{"rtuAddr":"37142501020100215","isOnLine":true},{"rtuAddr":"4000004","isOnLine":true},{"rtuAddr":"dy20240325","isOnLine":false}]',--> |
| | | #{onLineMap}, |
| | | '$[*]' COLUMNS ( |
| | | rtuAddr VARCHAR(20) PATH '$.rtuAddr', |
| | | isOnLine BOOLEAN PATH '$.isOnLine' |
| | | ) |
| | | <!--'[{"rtuAddr":"37142501020100215","isOnLine":true},{"rtuAddr":"4000004","isOnLine":true},{"rtuAddr":"dy20240325","isOnLine":false}]',--> |
| | | #{onLineMap}, |
| | | '$[*]' COLUMNS ( |
| | | rtuAddr VARCHAR(20) PATH '$.rtuAddr', |
| | | isOnLine BOOLEAN PATH '$.isOnLine' |
| | | ) |
| | | ) rtus ON con.rtuAddr = rtus.rtuAddr |
| | | <where> |
| | | <if test="isOnLine != null"> |
| | |
| | | </trim> |
| | | </select> |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | <!--获取取水口数量(在线或离线或不设状态)--> |
| | | <select id="selectIntakesCountForOnLine" resultType="java.lang.Long"> |
| | | 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"> |
| | | LEFT JOIN JSON_TABLE( |
| | | <!--'[{"rtuAddr":"37142501020100215","isOnLine":true},{"rtuAddr":"4000004","isOnLine":true},{"rtuAddr":"dy20240325","isOnLine":false}]',--> |
| | | #{onLineMap}, |
| | | '$[*]' COLUMNS ( |
| | | rtuAddr VARCHAR(20) PATH '$.rtuAddr', |
| | | isOnLine BOOLEAN PATH '$.isOnLine' |
| | | ) |
| | | ) rtus ON con.rtuAddr = rtus.rtuAddr |
| | | </if> |
| | | WHERE con.intakeId is not null |
| | | <if test="isOnLine != null"> |
| | | AND rtus.isOnLine = #{isOnLine} |
| | | </if> |
| | | <if test="intakeNum != null and intakeNum != ''"> |
| | | AND inta.name = #{intakeNum} |
| | | </if> |
| | | </select> |
| | | |
| | | |
| | | <!--获取取水口列表(在线或离线或不设状态)--> |
| | | <select id="selectIntakesForOnLine" resultType="com.dy.pipIrrGlobal.voPr.VoOnLineIntake"> |
| | | SELECT |
| | | inta.id AS intakeId, |
| | | con.rtuAddr, |
| | | inta.name AS intakeNum, |
| | | inta.lng, |
| | | inta.lat, |
| | | IFNULL(hou.total_amount, 0) AS totalAmount, |
| | | alarm.alarm |
| | | FROM pr_intake inta |
| | | INNER JOIN pr_controller con ON con.intakeId = inta.id |
| | | LEFT JOIN rm_on_hour_report_last hou ON hou.intake_id = inta.id |
| | | LEFT JOIN( |
| | | SELECT intake_id AS intakeId, |
| | | CONCAT( |
| | | IF(alarm_loss = 1, '漏损报警,', ''), |
| | | IF(alarm_battery_volt = 1, '电池电压报警,', ''), |
| | | IF(alarm_valve = 1, '阀门报警,', ''), |
| | | IF(alarm_water_meter_fault = 1, '流量计故障报警,', '') |
| | | ) AS alarm |
| | | FROM rm_alarm_state_last |
| | | 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"> |
| | | LEFT JOIN JSON_TABLE( |
| | | <!--'[{"rtuAddr":"37142501020100215","isOnLine":true},{"rtuAddr":"4000004","isOnLine":true},{"rtuAddr":"dy20240325","isOnLine":false}]',--> |
| | | #{onLineMap}, |
| | | '$[*]' COLUMNS ( |
| | | rtuAddr VARCHAR(20) PATH '$.rtuAddr', |
| | | isOnLine BOOLEAN PATH '$.isOnLine' |
| | | ) |
| | | ) rtus ON con.rtuAddr = rtus.rtuAddr |
| | | </if> |
| | | WHERE con.intakeId is not null |
| | | <if test="isOnLine != null"> |
| | | AND rtus.isOnLine = #{isOnLine} |
| | | </if> |
| | | <if test="intakeNum != null and intakeNum != ''"> |
| | | AND inta.name = #{intakeNum} |
| | | </if> |
| | | order by inta.id ASC |
| | | <trim prefix="limit "> |
| | | <if test="start != null and count != null"> |
| | | #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} |
| | | </if> |
| | | </trim> |
| | | </select> |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | <!--根据取水口编号获取取水口对象--> |
| | | <select id="getIntakeByName" resultType="com.dy.pipIrrGlobal.voPr.VoOnLineIntake"> |
| | | SELECT con.intakeId, |