From 76b0ffff1d0d483b1837cb0d5fdbb59339210c3a Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期三, 23 十月 2024 16:54:08 +0800
Subject: [PATCH] 在remote子模块实现的”远程监测“功能(查询列表附在线状态)
---
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/MonitorSv.java | 174 +++++++++++++++++++
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/QueryVo.java | 32 +++
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/MonitorCtrl.java | 49 +++++
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/CodeLocal.java | 21 ++
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrIntakeMapper.java | 17 +
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/ToRtuMwCom.java | 85 +++++++++
pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeMapper.xml | 131 ++++++++++++--
7 files changed, 489 insertions(+), 20 deletions(-)
diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrIntakeMapper.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrIntakeMapper.java
index f67fb00..9789d67 100644
--- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrIntakeMapper.java
+++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoPr/PrIntakeMapper.java
@@ -127,6 +127,23 @@
//List<VoOnLineIntake> getOnLineIntakes(@Param("onLineMap") String onLineMap, @Param("isOnLine") Boolean isOnLine);
List<VoOnLineIntake> getOnLineIntakes(Map<?, ?> params);
+
+ /**
+ * 鑾峰彇鍙栨按鍙f暟閲忥紙鍦ㄧ嚎鎴栦笉鍦ㄧ嚎锛�
+ * @param params
+ * @return
+ */
+ Long selectIntakesCountForOnLine(Map<?, ?> params);
+
+ /**
+ * 鑾峰彇鍙栨按鍙e垪琛ㄥ湪绾挎垨涓嶅湪绾匡級
+ * @param params
+ * @return
+ */
+ List<VoOnLineIntake> selectIntakesForOnLine(Map<?, ?> params);
+
+
+
/**
* 鏍规嵁鍙栨按鍙g紪鍙疯幏鍙栧彇姘村彛瀵硅薄
* @param params
diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/CodeLocal.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/CodeLocal.java
new file mode 100644
index 0000000..24f3a3c
--- /dev/null
+++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/CodeLocal.java
@@ -0,0 +1,21 @@
+package com.dy.pipIrrGlobal.rtuMw;
+
+public class CodeLocal {
+
+ public static final String clock = "LCD0000" ;//鏌ヨ鐩戞帶涓棿浠舵椂閽�
+
+ public static final String onLineAll = "LCD0001" ;//鏌ヨ鎵�鏈塕TU鍦ㄧ嚎鎯呭喌
+
+ public static final String onLinePart = "LCD0002" ;//鏌ヨ閮ㄥ垎RTU鍦ㄧ嚎鎯呭喌
+
+ public static final String onLineStatistics = "LCD0003" ;//鏌ヨ鎵�鏈塕TU鐘舵�佹儏鍐�
+
+ public static final String allProtocols = "LCD0100" ;//鏌ヨ鎵�鏈夊崗璁厤缃�
+
+ public static final String stopTcpSv = "LCD0110" ;//鍋滄TCP鏈嶅姟锛屼笉鍐嶆帴鍏ユ柊鐨凾CP杩炴帴锛屽凡缁廡CP杩炴帴鐨勫叏閮ㄦ柇杩炴帴
+
+ public static final String recoverTcpSv = "LCD0112" ;//閲嶅惎TCP鏈嶅姟锛屾帴鍏ユ柊鐨凾CP杩炴帴
+
+ public static final String mwState = "LCD0200" ;//寰楀埌閫氫俊涓棿浠惰繍琛屼俊鎭�
+
+}
diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/ToRtuMwCom.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/ToRtuMwCom.java
new file mode 100644
index 0000000..74099ea
--- /dev/null
+++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/ToRtuMwCom.java
@@ -0,0 +1,85 @@
+package com.dy.pipIrrGlobal.rtuMw;
+
+import com.dy.common.multiDataSource.DataSourceContext;
+import com.dy.common.mw.protocol.Command;
+import com.dy.common.mw.protocol.CommandType;
+import com.dy.common.webUtil.BaseResponse;
+import org.springframework.core.env.Environment;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.client.RestTemplate;
+import org.springframework.web.util.UriComponentsBuilder;
+
+/**
+ * @Author: liurunyu
+ * @Date: 2024/10/23 11:45
+ * @Description
+ */
+public abstract class ToRtuMwCom {
+ /**
+ * pro_mw锛氬睘鎬�
+ * tag浠庢帶鍒跺櫒涓幏鍙�
+ * key_mw锛歶rl鐨刱ey
+ */
+ private static final String pro_mw = "mw";
+ private static final String key_mw = "comSendUrl";
+
+
+ /**
+ * 寰楀埌鍚戦�氫俊涓棿浠跺彂閫佹暟鎹殑URL
+ * @param env
+ * @return
+ */
+ protected String getToMwUrl(Environment env) {
+ return env.getProperty(pro_mw + "." + DataSourceContext.get() + "." + key_mw);
+ }
+
+ /**
+ * 鍒涘缓澶栭儴鍛戒护锛堝彂缁欐帶鍒跺櫒锛�
+ * @param code 鍛戒护code
+ * @return
+ */
+ protected Command createOuterCommand(String comId, String code) {
+ Command com = new Command();
+ com.id = comId;
+ com.code = code ;
+ com.type = CommandType.outerCommand;
+ return com ;
+ }
+
+ /**
+ * 鍒涘缓鍐呴儴
+ * @param code 鍛戒护code
+ * @return
+ */
+ protected Command createInnerCommand(String code) {
+ Command com = new Command();
+ com.id = Command.defaultId;
+ com.code = code ;
+ com.type = CommandType.innerCommand;
+ return com ;
+ }
+
+ /**
+ * 鍙戦�佸懡浠�
+ *
+ * @return
+ */
+ protected BaseResponse sendCom2Mw(RestTemplate restTemplate, String comSendUrl, Command com) {
+ String url = UriComponentsBuilder.fromUriString(comSendUrl)
+ .build()
+ .toUriString();
+ HttpHeaders headers = new HttpHeaders();
+ HttpEntity<Command> httpEntity = new HttpEntity<>(com, headers);
+ ResponseEntity<BaseResponse> response = null;
+ try {
+ // 閫氳繃Post鏂瑰紡璋冪敤鎺ュ彛
+ response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, BaseResponse.class);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return response.getBody();
+ }
+}
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 5180618..8709694 100644
--- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeMapper.xml
+++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrIntakeMapper.xml
@@ -421,27 +421,27 @@
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">
@@ -521,6 +521,97 @@
</trim>
</select>
+
+
+
+
+
+
+ <!--鑾峰彇鍙栨按鍙f暟閲忥紙鍦ㄧ嚎鎴栫绾挎垨涓嶈鐘舵�侊級-->
+ <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>
+
+
+ <!--鑾峰彇鍙栨按鍙e垪琛紙鍦ㄧ嚎鎴栫绾挎垨涓嶈鐘舵�侊級-->
+ <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>
+
+
+
+
+
+
+
+
+
+
+
<!--鏍规嵁鍙栨按鍙g紪鍙疯幏鍙栧彇姘村彛瀵硅薄-->
<select id="getIntakeByName" resultType="com.dy.pipIrrGlobal.voPr.VoOnLineIntake">
SELECT con.intakeId,
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/MonitorCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/MonitorCtrl.java
new file mode 100644
index 0000000..36e30e9
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/MonitorCtrl.java
@@ -0,0 +1,49 @@
+package com.dy.pipIrrRemote.monitor;
+
+import com.dy.common.aop.SsoAop;
+import com.dy.common.webUtil.BaseResponse;
+import com.dy.common.webUtil.BaseResponseUtils;
+import com.dy.common.webUtil.QueryResultVo;
+import com.dy.pipIrrGlobal.voPr.VoOnLineIntake;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * @Author: liurunyu
+ * @Date: 2024/10/23 11:32
+ * @Description
+ */
+
+@Slf4j
+@Tag(name = "鐩戞祴鎺у埗", description = "鐩戞祴鎺у埗")
+@RestController
+@RequestMapping(path = "monitor")
+@RequiredArgsConstructor
+public class MonitorCtrl {
+ private final MonitorSv monitorSv;
+
+ /**
+ * 鑾峰彇鍙栨按鍙e垪琛紙鍦ㄧ嚎鍜屼笉鍦ㄧ嚎锛�
+ *
+ * @param qo
+ * @return
+ */
+ @GetMapping(path = "all_intakes")
+ @SsoAop()
+ public BaseResponse<QueryResultVo<List<VoOnLineIntake>>> allIntakes(QueryVo qo) {
+ try {
+ QueryResultVo<List<VoOnLineIntake>> res = monitorSv.selectOnLineIntakes(qo);
+ return BaseResponseUtils.buildSuccess(res);
+ } catch (Exception e) {
+ log.error("鏌ヨ鍙栨按鍙e紓甯�", e);
+ return BaseResponseUtils.buildException(e.getMessage());
+ }
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/MonitorSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/MonitorSv.java
new file mode 100644
index 0000000..6684947
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/MonitorSv.java
@@ -0,0 +1,174 @@
+package com.dy.pipIrrRemote.monitor;
+
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
+import com.dy.common.mw.protocol.Command;
+import com.dy.common.mw.protocol.CommandBackParam;
+import com.dy.common.webUtil.BaseResponse;
+import com.dy.common.webUtil.QueryResultVo;
+import com.dy.pipIrrGlobal.daoPr.PrIntakeMapper;
+import com.dy.pipIrrGlobal.rtuMw.CodeLocal;
+import com.dy.pipIrrGlobal.rtuMw.ToRtuMwCom;
+import com.dy.pipIrrGlobal.voPr.VoOnLineIntake;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.dubbo.common.utils.PojoUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
+import org.springframework.stereotype.Service;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Author: liurunyu
+ * @Date: 2024/10/23 11:32
+ * @Description
+ */
+@Slf4j
+@Service
+public class MonitorSv extends ToRtuMwCom {
+
+ @Autowired
+ private PrIntakeMapper prIntakeMapper;
+
+ @Autowired
+ private Environment env;
+
+ @Autowired
+ private RestTemplate restTemplate;
+
+ /**
+ * 鑾峰彇宸茬粡缁戝畾鎺у埗鍣ㄧ殑鍙栨按鍙e垪琛紙骞舵爣璁板湪绾夸笌涓嶅湪绾匡級
+ *
+ * @return
+ */
+ public QueryResultVo<List<VoOnLineIntake>> selectOnLineIntakes(QueryVo vo) {
+ if(vo.getIsOnLine() == null){
+ //涓嶅尯鍒嗗湪绾夸笌绂荤嚎
+ return selectIntakesIgnoreOnOffLine(vo) ;
+ }else{
+ //鍦ㄧ嚎 鎴� 绂荤嚎
+ return selectIntakesOnOrOffLine(vo) ;
+ }
+ }
+
+ /**
+ * 鏌ヨ鍙栨按鍙o紝涓嶉檺鍒跺湪绾夸笌绂荤嚎鐘舵��
+ * @param vo
+ * @return
+ */
+ private QueryResultVo<List<VoOnLineIntake>> selectIntakesIgnoreOnOffLine(QueryVo vo) {
+ QueryResultVo<List<VoOnLineIntake>> rsVo = this.queryDb(vo) ;
+ if(rsVo != null && rsVo.obj != null && (rsVo.obj.size() > 0)){
+ String rtuAddrs = "" ;
+ boolean first = true ;
+ for(VoOnLineIntake rVo : rsVo.obj){
+ if(first){
+ first = false ;
+ rtuAddrs += rVo.getRtuAddr() ;
+ }else{
+ rtuAddrs += "," + rVo.getRtuAddr() ;
+ }
+ }
+ //鍚戦�氫俊涓棿浠跺彂鍏冲懡浠わ紝鏌ヨ閮ㄥ垎RTU鍦ㄧ嚎鎯呭喌
+ Command com = this.createInnerCommand(CodeLocal.onLinePart);
+ com.setParam(rtuAddrs) ;
+ String comSendUrl = this.getToMwUrl(this.env) ;
+ BaseResponse<Command> res = sendCom2Mw(restTemplate, comSendUrl, com) ;
+ if(res != null){
+ if(res.isSuccess()){
+ Command reCom = res.getContent() ;
+ CommandBackParam bakParam = JSON.parseObject(((JSONObject)reCom.param).toJSONString(), CommandBackParam.class) ;
+ if(bakParam != null){
+ if(bakParam.getSuccess().booleanValue()){
+ //閫氫俊涓棿浠舵垚鍔熻繑鍥炲懡浠ょ粨鏋�
+ HashMap<String, Boolean> onLineMap = JSON.parseObject(((JSONObject)reCom.getAttachment()).toJSONString(), HashMap.class);
+ for(VoOnLineIntake rVo : rsVo.obj){
+ if(onLineMap.containsKey(rVo.getRtuAddr())) {
+ rVo.setIsOnLine(onLineMap.get(rVo.getRtuAddr()));
+ }
+ }
+ }
+ }else{
+ log.error("閫氫俊涓棿浠惰繑鍥炲唴閮ㄥ懡浠ょ粨鏋滀腑涓嶅寘鍚獵ommandBackParam绫诲瀷鍙傛暟");
+ }
+ }else{
+ log.error("閫氫俊涓棿浠惰繑鍥炲唴閮ㄥ懡浠ゆ墽琛屽け璐�" + (res.getMsg() == null? "" : ("锛�" + res.getMsg()))) ;
+ }
+ }else{
+ log.error("閫氫俊涓棿浠惰繑鍥炲唴閮ㄥ懡浠ょ粨鏋滀负null");
+ }
+ }
+ return rsVo;
+ }
+
+
+ /**
+ * 鏌ヨ鍙栨按鍙o紝鍦ㄧ嚎鎴栫绾跨姸鎬�
+ * @param vo
+ * @return
+ */
+ private QueryResultVo<List<VoOnLineIntake>> selectIntakesOnOrOffLine(QueryVo vo) {
+ //鍚戦�氫俊涓棿浠跺彂鍏冲懡浠わ紝鏌ヨ閮ㄥ垎RTU鍦ㄧ嚎鎯呭喌
+ Command com = this.createInnerCommand(CodeLocal.onLineAll);
+ String comSendUrl = this.getToMwUrl(this.env) ;
+ BaseResponse<Command> res = sendCom2Mw(restTemplate, comSendUrl, com) ;
+ if(res != null){
+ if(res.isSuccess()){
+ Command reCom = res.getContent() ;
+ CommandBackParam bakParam = JSON.parseObject(((JSONObject)reCom.param).toJSONString(), CommandBackParam.class) ;
+ if(bakParam != null){
+ if(bakParam.getSuccess().booleanValue()){
+ //閫氫俊涓棿浠舵垚鍔熻繑鍥炲懡浠ょ粨鏋�
+ HashMap<String, Boolean> onLineMap = JSON.parseObject(((JSONObject)reCom.getAttachment()).toJSONString(), HashMap.class);
+ JSONArray jsonArray = new JSONArray();
+ 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);
+ }
+ vo.setOnLineMap(jsonArray.toJSONString());
+ }
+ }else{
+ log.error("閫氫俊涓棿浠惰繑鍥炲唴閮ㄥ懡浠ょ粨鏋滀腑涓嶅寘鍚獵ommandBackParam绫诲瀷鍙傛暟");
+ }
+ }else{
+ log.error("閫氫俊涓棿浠惰繑鍥炲唴閮ㄥ懡浠ゆ墽琛屽け璐�" + (res.getMsg() == null? "" : ("锛�" + res.getMsg()))) ;
+ }
+ }else{
+ log.error("閫氫俊涓棿浠惰繑鍥炲唴閮ㄥ懡浠ょ粨鏋滀负null");
+ }
+
+ return this.queryDb(vo) ;
+ }
+
+ /**
+ * 鏌ヨ鏁版嵁搴�
+ * @param vo
+ * @return
+ */
+ private QueryResultVo<List<VoOnLineIntake>> queryDb(QueryVo vo){
+ Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(vo);
+ Long itemTotal = prIntakeMapper.selectIntakesCountForOnLine(params);
+
+ QueryResultVo<List<VoOnLineIntake>> rsVo = new QueryResultVo<>();
+ rsVo.pageSize = vo.pageSize;
+ rsVo.pageCurr = vo.pageCurr;
+ rsVo.calculateAndSet(itemTotal, params);
+ List<VoOnLineIntake> records = prIntakeMapper.selectIntakesForOnLine(params) ;
+ rsVo.obj = records ;
+ for(VoOnLineIntake rVo : records){
+ if(rVo.getAlarm() != null && !rVo.getAlarm().trim().equals("") && rVo.getAlarm().endsWith("锛�")){
+ rVo.setAlarm(rVo.getAlarm().substring(0, rVo.getAlarm().length() - 1)) ;
+ }
+ }
+ return rsVo ;
+ }
+
+
+
+}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/QueryVo.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/QueryVo.java
new file mode 100644
index 0000000..8b846ef
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/QueryVo.java
@@ -0,0 +1,32 @@
+package com.dy.pipIrrRemote.monitor;
+
+import com.dy.common.webUtil.QueryConditionVo;
+import lombok.Data;
+
+/**
+ * @author ZhuBaoMin
+ * @date 2024-05-27 20:32
+ * @LastEditTime 2024-05-27 20:32
+ * @Description
+ */
+
+@Data
+public class QueryVo extends QueryConditionVo {
+ /**
+ * 鍙栨按鍙g紪鍙�
+ */
+ private String intakeNum;
+
+ /**
+ * 鏄惁鍦ㄧ嚎
+ */
+
+ private Boolean isOnLine;
+
+
+ /**
+ * 闈炲墠绔缃殑鍙傛暟鎹紝涓棿浠惰繑鍥炵殑RTU鍦ㄧ嚎鎯呭喌瀵硅薄鏁扮粍
+ */
+ private String onLineMap;
+
+}
--
Gitblit v1.8.0