From 389b77df2609f6c49a64ef22dee7ff867f9f19a6 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期三, 23 十月 2024 08:42:06 +0800
Subject: [PATCH] 重新定义并优化RTU上行数据接口
---
pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeMapper.xml | 76 ++++++++++++++++++++++++++++++--------
1 files changed, 60 insertions(+), 16 deletions(-)
diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeMapper.xml
index 60412c5..5180618 100644
--- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeMapper.xml
+++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeMapper.xml
@@ -225,16 +225,24 @@
<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>
@@ -257,6 +265,18 @@
</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>
@@ -271,6 +291,10 @@
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,
@@ -282,16 +306,24 @@
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>
@@ -315,6 +347,18 @@
<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
<trim prefix="limit ">
--
Gitblit v1.8.0