From b181d08b9c8c4f3f4d8c475a60506ba4d93c8382 Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期三, 09 四月 2025 11:38:23 +0800
Subject: [PATCH] 灌溉计划详情页,包含计划信息、轮灌组信息、取水口命令发布员结果信息
---
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/allRound/Ar4RemoteSv.java | 147 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 147 insertions(+), 0 deletions(-)
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/allRound/Ar4RemoteSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/allRound/Ar4RemoteSv.java
new file mode 100644
index 0000000..b0e1d2e
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/allRound/Ar4RemoteSv.java
@@ -0,0 +1,147 @@
+package com.dy.pipIrrRemote.allRound;
+
+import com.alibaba.fastjson2.JSON;
+import com.dy.common.mw.protocol.Command;
+import com.dy.common.mw.protocol.CommandBackParam;
+import com.dy.common.webUtil.BaseResponse;
+import com.dy.pipIrrGlobal.voAllRound.VoArIntakeRemote;
+import com.dy.pipIrrGlobal.daoAllRound.Ar4BaseMapper;
+import com.dy.pipIrrGlobal.daoAllRound.Ar4RemoteMapper;
+import com.dy.pipIrrGlobal.rtuMw.CodeLocal;
+import com.dy.pipIrrGlobal.rtuMw.Web2RtuMw;
+import lombok.extern.slf4j.Slf4j;
+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;
+
+/**
+ * @Author: liurunyu
+ * @Date: 2025/1/14 16:59
+ * @Description
+ */
+@Slf4j
+@Service
+public class Ar4RemoteSv extends Web2RtuMw {
+
+ @Autowired
+ private Ar4BaseMapper baseDao;
+
+ @Autowired
+ private Ar4RemoteMapper remoteDao;
+
+ @Autowired
+ private Environment env;
+
+ @Autowired
+ private RestTemplate restTemplate;
+
+ /**
+ * 鍙栨按鍙e熀鏈俊鎭�
+ * @return 鍙栨按鍙e熀鏈俊鎭�
+ */
+ public VoArIntakeRemote intakeInfo(Long intakeId){
+ VoArIntakeRemote rVo = new VoArIntakeRemote() ;
+ rVo.intakeId = intakeId ;
+ String rtuAddr = this.getRtuAddr(intakeId);
+ this.getRtuOnLine(rtuAddr, rVo);
+ this.getAlarmLastInfo(intakeId, rVo);
+ this.getOpenCloseValveLastInfo(intakeId, rVo);
+ this.getLossAmountLastInfo(intakeId, rVo);
+ return rVo ;
+ }
+
+ /**
+ * 鑾峰彇鍙栨按鍙e搴旂殑RTU鍦板潃
+ * @param intakeId 鍙栨按鍙D
+ * @return RTU鍦板潃
+ */
+ private String getRtuAddr(Long intakeId){
+ List<String> rtuAddrs = baseDao.intakeRtuAddr(intakeId) ;
+ if(rtuAddrs != null && rtuAddrs.size() > 0){
+ return rtuAddrs.get(0) ;
+ }
+ return null ;
+ }
+
+ /**
+ * 寰楀埌鍙栨按RTU鍦ㄧ嚎鎯呭喌
+ * @param rtuAddr
+ * @param rVo
+ */
+ private void getRtuOnLine(String rtuAddr, VoArIntakeRemote rVo){
+ if(rtuAddr != null){
+ //鍚戦�氫俊涓棿浠跺彂鍏冲懡浠わ紝鏌ヨ閮ㄥ垎RTU鍦ㄧ嚎鎯呭喌
+ Command com = this.createInnerCommand(CodeLocal.onLinePart);
+ com.setParam(rtuAddr) ;
+ String rqUrl = this.get2MwRequestUrl(this.env, ContextComSend) ;
+ BaseResponse res = sendPostRequest2Mw(restTemplate, rqUrl, com) ;
+ if(res != null){
+ if(res.isSuccess()){
+ Command reCom = JSON.parseObject(res.getContent() == null ? null : JSON.toJSONString(res.getContent()), Command.class) ;
+ CommandBackParam bakParam = JSON.parseObject((reCom== null || reCom.param == null) ? null : JSON.toJSONString(reCom.param), CommandBackParam.class) ;
+ if(bakParam != null){
+ if(bakParam.getSuccess().booleanValue()){
+ //閫氫俊涓棿浠舵垚鍔熻繑鍥炲懡浠ょ粨鏋�
+ HashMap<String, Boolean> onLineMap = JSON.parseObject(JSON.toJSONString(reCom.getAttachment()), HashMap.class);
+ if(onLineMap != null && onLineMap.size() > 0){
+ rVo.onLine = onLineMap.get(rtuAddr) ;
+ }
+ }
+ }else{
+ log.error("閫氫俊涓棿浠惰繑鍥炲唴閮ㄥ懡浠ょ粨鏋滀腑涓嶅寘鍚獵ommandBackParam绫诲瀷鍙傛暟");
+ }
+ }else{
+ log.error("閫氫俊涓棿浠惰繑鍥炲唴閮ㄥ懡浠ゆ墽琛屽け璐�" + (res.getMsg() == null? "" : ("锛�" + res.getMsg()))) ;
+ }
+ }else{
+ log.error("閫氫俊涓棿浠惰繑鍥炲唴閮ㄥ懡浠ょ粨鏋滀负null");
+ }
+ }
+ }
+ /**
+ * 寰楀埌鍙栨按鍙f渶鏂版姤璀︿俊鎭�
+ * @param intakeId
+ * @param rVo
+ */
+ private void getAlarmLastInfo(Long intakeId, VoArIntakeRemote rVo){
+ List<VoArIntakeRemote> list = remoteDao.alarmLastInfo(intakeId);
+ if(list != null && list.size() > 0){
+ VoArIntakeRemote vo = list.get(0) ;
+ rVo.alarm = vo.alarm ;
+ if(rVo.alarm == null || rVo.alarm.trim().equals("")){
+ rVo.alarm = "鏃犳姤璀�" ;
+ }
+ rVo.alarmDt = vo.alarmDt ;
+ }
+ }
+ /**
+ * 寰楀埌鍙栨按鍙f渶鏂板紑鍏抽榾淇℃伅
+ * @param intakeId
+ * @param rVo
+ */
+ private void getOpenCloseValveLastInfo(Long intakeId, VoArIntakeRemote rVo){
+ List<VoArIntakeRemote> list = remoteDao.openCloseValveLastInfo(intakeId);
+ if(list != null && list.size() > 0){
+ VoArIntakeRemote vo = list.get(0) ;
+ rVo.lastOpenDt = vo.lastOpenDt ;
+ rVo.lastCloseDt = vo.lastCloseDt ;
+ }
+ }
+ /**
+ * 寰楀埌鍙栨按鍙f渶鏂版紡鎹熶俊鎭�
+ * @param intakeId
+ * @param rVo
+ */
+ private void getLossAmountLastInfo(Long intakeId, VoArIntakeRemote rVo){
+ List<VoArIntakeRemote> list = remoteDao.lossLastInfo(intakeId);
+ if(list != null && list.size() > 0){
+ VoArIntakeRemote vo = list.get(0) ;
+ rVo.lossDt = vo.lossDt ;
+ rVo.lossAmount = vo.lossAmount ;
+ }
+ }
+}
--
Gitblit v1.8.0