From 126c2efc23cb8a02e4ff4d300050a590b8a0f1fa Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期五, 25 十月 2024 10:33:25 +0800
Subject: [PATCH] 取水口管理功能中去除顯示在線情況,優化SQL語句。
---
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeCtrl.java | 14 ++--
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeSv.java | 54 ++++-------------
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voPr/VoIntake.java | 6 --
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/QueryVo.java | 12 ----
pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeMapper.xml | 59 ++++++-------------
5 files changed, 37 insertions(+), 108 deletions(-)
diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voPr/VoIntake.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voPr/VoIntake.java
index 6b902c9..3626863 100644
--- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voPr/VoIntake.java
+++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voPr/VoIntake.java
@@ -110,12 +110,6 @@
@ColumnWidth(20)
private Date findDt;
- /**
- * 鏄惁鍦ㄧ嚎
- */
- @ExcelIgnore
- private Boolean isOnLine;
-
@Schema(title = "缁戝畾娆℃暟")
@ExcelProperty(value = {"${title}", "缁戝畾娆℃暟"})
@ColumnWidth(10)
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 9bce76d..f7bf939 100644
--- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeMapper.xml
+++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeMapper.xml
@@ -231,14 +231,9 @@
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
+ <if test = "bindNumber != null and bindNumber > 0">
+ JOIN (SELECT intakeId, COUNT(*) num FROM pr_intake_controller WHERE operateType = 1 group by intakeId) AS bindNumTb on bindNumTb.intakeId= ge.id
+ </if>
<where>
ge.deleted = 0
AND divi.deleted = 0
@@ -255,10 +250,10 @@
AND blo.id = #{blockId}
</if>
- <if test="isBinded == 0">
+ <if test="isBinded != null and isBinded == 0">
AND ge.id NOT IN (SELECT intakeId FROM pr_controller where deleted = 0)
</if>
- <if test="isBinded == 1">
+ <if test="isBinded != null and isBinded == 1">
AND ge.id IN (SELECT intakeId FROM pr_controller where deleted = 0)
</if>
<if test="isBinded == null">
@@ -269,21 +264,20 @@
<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}
+ AND bindNumTb.num = #{bindNumber}
</if>
</where>
</select>
<!--鏍规嵁鎸囧畾鏉′欢鑾峰彇鍙栨按鍙h褰�-->
<select id="getIntakes" resultType="com.dy.pipIrrGlobal.voPr.VoIntake">
- SELECT CAST(ge.id AS char) AS intakeId,
+ WITH intakeIds AS(SELECT intakeId FROM pr_controller where deleted = 0)
+
+ SELECT CAST(ge.id AS char) AS intakeId,
ge.`name` AS intakeName,
CAST(divi.id AS char) AS divideId,
divi.`name` AS divideName,
@@ -293,18 +287,14 @@
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,
+ bindNumTb.num AS bindNumber,
ge.lng,
ge.lat,
ge.remarks,
ge.operator,
ge.operateDt As operateDt,
- (CASE
- WHEN ge.id NOT IN (SELECT intakeId FROM pr_controller where deleted = 0) THEN '鏈粦瀹�'
- WHEN ge.id IN (SELECT intakeId FROM pr_controller where deleted = 0) THEN '宸茬粦瀹�'
- END) AS isBind,
- CONCAT(country.`name`, town.`name`, village.`name`) AS address
+ IF(ge.id IN (SELECT intakeId FROM intakeIds),'宸茬粦瀹�','鏈粦瀹�') 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
@@ -312,14 +302,7 @@
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
+ JOIN (SELECT intakeId, COUNT(*) num FROM pr_intake_controller WHERE operateType = 1 group by intakeId) AS bindNumTb on bindNumTb.intakeId= ge.id
<where>
ge.deleted = 0
AND divi.deleted = 0
@@ -327,19 +310,16 @@
<if test="intakeName != null and intakeName != ''">
AND ge.name LIKE CONCAT('%', #{intakeName}, '%')
</if>
-
<if test="divideId != null and divideId != ''">
AND divi.id = #{divideId}
</if>
-
<if test="blockId != null and blockId != ''">
AND blo.id = #{blockId}
</if>
-
- <if test="isBinded == 0">
+ <if test="isBinded != null and isBinded == 0">
AND ge.id NOT IN (SELECT intakeId FROM pr_controller where deleted = 0)
</if>
- <if test="isBinded == 1">
+ <if test="isBinded != null and isBinded == 1">
AND ge.id IN (SELECT intakeId FROM pr_controller where deleted = 0)
</if>
<if test="isBinded == null">
@@ -347,17 +327,14 @@
<if test="address != null and address != ''">
AND CONCAT(country.`name`, town.`name`, village.`name`) LIKE CONCAT('%', #{address}, '%')
</if>
- <if test = "rtuAddr != null and rtuAddr !=''">
+ <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 test="bindNumber != null and bindNumber > 0">
+ AND bindNumTb.num = #{bindNumber}
</if>
</where>
ORDER BY ge.operateDt DESC
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeCtrl.java
index 57b5513..5753595 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeCtrl.java
@@ -12,7 +12,6 @@
import com.dy.pipIrrGlobal.voPr.VoIntake;
import com.dy.pipIrrGlobal.voPr.VoOnLineIntake;
import com.dy.pipIrrGlobal.voSe.VoActiveCard;
-import com.dy.pipIrrProject.intake.qo.OnLineIntakesQO;
import com.dy.pipIrrProject.result.ProjectResultCode;
import com.taobao.api.ApiException;
import io.swagger.v3.oas.annotations.Operation;
@@ -290,14 +289,13 @@
}
/**
+ * 姝ゅ姛鑳藉凡缍撶Щ妞嶅埌remote妯″鐨凪onitroCtrl涓�
* 鑾峰彇鍙栨按鍙e垪琛紙鍦ㄧ嚎鍜屼笉鍦ㄧ嚎锛�
- *
* @param qo
* @return
- */
- @GetMapping(path = "all_intakes")
- @SsoAop()
- public BaseResponse<QueryResultVo<List<VoOnLineIntake>>> getAllIntakes(OnLineIntakesQO qo) {
+ @GetMapping(path = "all_intakes")
+ @SsoAop()
+ public BaseResponse<QueryResultVo<List<VoOnLineIntake>>> getAllIntakes(OnLineIntakesQO qo) {
try {
QueryResultVo<List<VoOnLineIntake>> res = intakeSv.selectOnLineIntakes(qo);
return BaseResponseUtils.buildSuccess(res);
@@ -305,8 +303,8 @@
log.error("鏌ヨ鍙栨按鍙e紓甯�", e);
return BaseResponseUtils.buildException(e.getMessage());
}
- }
-
+ }
+ */
/**
* 鏍规嵁鎿嶄綔鍛樿幏鍙栧父鐢ㄥ彇姘村彛锛堝湪绾垮拰涓嶅湪绾匡級
*
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeSv.java
index 1bbe943..876cc0c 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeSv.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeSv.java
@@ -134,44 +134,15 @@
* @return 鍙栨按鍙h褰曞垪琛�
*/
public QueryResultVo<List<VoIntake>> getIntakes(QueryVo queryVo) {
- Command com = new Command();
- com.id = Command.defaultId;
- com.code = "LCD0001";
- com.type = "innerCommand";
- comSendUrl = env.getProperty(pro_mw + "." + DataSourceContext.get() + "." + key_mw);
- BaseResponse baseResponse = sendCom2Mw(com);
- JSONObject response = (JSONObject) JSON.toJSON(baseResponse);
+ Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
+ Long itemTotal = prIntakeMapper.getRecordCount(params);
- if (response != null && response.getString("code").equals("0001")) {
- JSONObject attachment = response.getJSONObject("content").getJSONObject("attachment").getJSONObject("onLineMap");
-
- JSONArray jsonArray = new JSONArray();
-
- if(attachment != null) {
- HashMap<String, Boolean> onLineMap = JSON.parseObject(attachment.toJSONString(), HashMap.class);
- for (Map.Entry<String, Boolean> entry : onLineMap.entrySet()) {
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("rtuAddr", entry.getKey());
- jsonObject.put("isOnLine", entry.getValue());
- jsonArray.add(jsonObject);
- }
- }
-
- queryVo.setOnLineMap(jsonArray.toJSONString());
-
- Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
- Long itemTotal = prIntakeMapper.getRecordCount(params);
-
- QueryResultVo<List<VoIntake>> rsVo = new QueryResultVo<>();
- rsVo.pageSize = queryVo.pageSize;
- rsVo.pageCurr = queryVo.pageCurr;
- rsVo.calculateAndSet(itemTotal, params);
- rsVo.obj = prIntakeMapper.getIntakes(params);
- return rsVo;
- } else {
- QueryResultVo<List<VoIntake>> rsVo = new QueryResultVo<>();
- return rsVo;
- }
+ QueryResultVo<List<VoIntake>> rsVo = new QueryResultVo<>();
+ rsVo.pageSize = queryVo.pageSize;
+ rsVo.pageCurr = queryVo.pageCurr;
+ rsVo.calculateAndSet(itemTotal, params);
+ rsVo.obj = prIntakeMapper.getIntakes(params);
+ return rsVo;
}
/**
@@ -249,11 +220,12 @@
}
/**
+ * 姝ゅ姛鑳藉凡缍撶Щ妞嶅埌remote妯″鐨凪onitroSv涓�
+ *
* 鑾峰彇鍙栨按鍙e垪琛�
*
* @return
- */
- public QueryResultVo<List<VoOnLineIntake>> selectOnLineIntakes(OnLineIntakesQO qo) {
+ public QueryResultVo<List<VoOnLineIntake>> selectOnLineIntakes(OnLineIntakesQO qo) {
Command com = new Command();
com.id = Command.defaultId;
com.code = "LCD0001";
@@ -287,8 +259,8 @@
QueryResultVo<List<VoOnLineIntake>> rsVo = new QueryResultVo<>();
return rsVo;
}
- }
-
+ }
+ */
/**
* 鏍规嵁鎿嶄綔鍛樿幏鍙栧父鐢ㄥ彇姘村彛
*
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/QueryVo.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/QueryVo.java
index d12f140..d2ce43e 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/QueryVo.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/QueryVo.java
@@ -40,18 +40,6 @@
@Schema(description = "鎺у埗鍣ㄥ湴鍧�")
private String rtuAddr;
- /**
- * 涓棿浠惰繑鍥炵殑RTU鍦ㄧ嚎鎯呭喌瀵硅薄鏁扮粍
- */
- private String onLineMap;
-
- /**
- * 鏄惁鍦ㄧ嚎
- */
- @Max(value = 1,message = "鏄惁鍦ㄧ嚎浠呭厑璁镐负鐪熸垨鍋�")
- @Min(value = 0,message = "鏄惁鍦ㄧ嚎浠呭厑璁镐负鐪熸垨鍋�")
- private Boolean isOnLine;
-
@Schema(description = "閫氫俊鍗忚")
private String protocol;
--
Gitblit v1.8.0