From e67870fff62635cd14beb0d5988f08aeef4b22fa Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期一, 07 四月 2025 21:27:06 +0800
Subject: [PATCH] 添加远程关阀式终止灌溉计划,未测试

---
 pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeResSv.java |  167 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 167 insertions(+), 0 deletions(-)

diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeResSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeResSv.java
new file mode 100644
index 0000000..59eb4c2
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeResSv.java
@@ -0,0 +1,167 @@
+package com.dy.pipIrrRemote.rtuUpgrage;
+
+import com.dy.common.softUpgrade.state.UpgradeRtu;
+import com.dy.common.webUtil.QueryResultVo;
+import com.dy.pipIrrGlobal.voUg.VoUgRtuResult4Failure;
+import com.dy.pipIrrGlobal.voUg.VoUgRtuResult4Success;
+import com.dy.pipIrrGlobal.voUg.VoWatch;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @Author liurunyu
+ * @Date 2024/11/22 14:40
+ * @Description
+ */
+@Slf4j
+@Service
+public class RtuUpgradeResSv {
+    @Autowired
+    private RtuUpgradeSv sv ;
+
+    public QueryResultVo<VoWatch> curUpgradeState(QueryVo qvo){
+        QueryResultVo<VoWatch> rsVo = new QueryResultVo<>();
+        VoWatch vo = new VoWatch() ;
+        List<UpgradeRtu> listFiltered = null ;
+        if(RtuUpgradeStateReceiverCtrl.cache != null && RtuUpgradeStateReceiverCtrl.cache.ugTaskId != null){
+            vo.upgrade = this.sv.selectTaskDetail(RtuUpgradeStateReceiverCtrl.cache.ugTaskId);
+            vo.overall = RtuUpgradeStateReceiverCtrl.cache.ugOverallState ;
+            vo.rtus = new ArrayList<>() ;
+            if(RtuUpgradeStateReceiverCtrl.cache.ugRtuStateList != null && RtuUpgradeStateReceiverCtrl.cache.ugRtuStateList.size() > 0) {
+                listFiltered = filterByQuery(qvo) ;
+                if (listFiltered.size() > 0) {
+                    if(qvo.pageCurr < 1){
+                        qvo.pageCurr = 1 ;
+                    }
+                    int start = (qvo.pageCurr - 1) * qvo.pageSize ;
+                    if(start >= listFiltered.size()){
+                        if(listFiltered.size()%qvo.pageSize > 0){
+                            start = listFiltered.size() - listFiltered.size()%qvo.pageSize ;
+                        }else{
+                            start = listFiltered.size() - qvo.pageSize ;
+                        }
+                    }
+                    for(int i = start; i < (start + qvo.pageSize) && i < listFiltered.size(); i++){
+                        UpgradeRtu ugRtu = listFiltered.get(i) ;
+                        VoWatch.VoWatchRtu rtu = new VoWatch.VoWatchRtu() ;
+                        rtu.fromCache(ugRtu) ;
+                        vo.rtus.add(rtu) ;
+                    }
+                }
+            }
+        }
+
+        rsVo.obj = vo ;
+        rsVo.pageSize = qvo.pageSize ;
+        rsVo.pageCurr = qvo.pageCurr ;
+        rsVo.calculateAndSet((long)(listFiltered==null?0:listFiltered.size()), null);
+        return rsVo ;
+    }
+
+    /**
+     * 杩囨护缁撴灉
+     * @param qvo 鏌ヨ鍙傛暟
+     * @return 闆嗗悎
+     */
+    private List<UpgradeRtu> filterByQuery(QueryVo qvo){
+        if (qvo.status != null || qvo.result != null) {
+            Integer qvoStatus = qvo.status ;
+            Integer qvoResult = qvo.result ;
+            String qvoRtuAddr = qvo.rtuAddr ;
+            return RtuUpgradeStateReceiverCtrl.cache.ugRtuStateList.stream().filter(rtu -> {
+                boolean ok = false;
+                if (qvoStatus != null) {
+                    if (qvoStatus == 1) {
+                        ok = rtu.state == UpgradeRtu.STATE_RUNNING;
+                    } else if (qvoStatus == 0) {
+                        ok = rtu.isOver;
+                    }
+                }
+                if (qvoResult != null) {
+                    if (qvoResult == 1) {
+                        ok = rtu.state == UpgradeRtu.STATE_SUCCESS;
+                    } else if (qvoResult == 0) {
+                        ok = rtu.state == UpgradeRtu.STATE_OFFLINE
+                                || rtu.state == UpgradeRtu.STATE_FAILONE
+                                || rtu.state == UpgradeRtu.STATE_FAIL
+                                || rtu.state == UpgradeRtu.STATE_FAILOFFLINE
+                                || rtu.state == UpgradeRtu.STATE_FAILOPEN;
+                    }
+                }
+                if(qvoRtuAddr != null && !qvoRtuAddr.trim().equals("")){
+                    ok = rtu.rtuAddr.equals(qvoRtuAddr);
+                }
+                return ok;
+            }).toList() ;
+        }else{
+            return RtuUpgradeStateReceiverCtrl.cache.ugRtuStateList ;
+        }
+    }
+
+    /**
+     * 杩囨护鍑哄綋鍓嶉暱绾т换鍔′腑鍗囩骇澶辫触鐨凴TU
+     * @return 闆嗗悎
+     */
+    public List<VoUgRtuResult4Failure> exportUgFail(){
+        List<VoUgRtuResult4Failure> list = new ArrayList<>() ;
+        if(RtuUpgradeStateReceiverCtrl.cache != null && RtuUpgradeStateReceiverCtrl.cache.ugTaskId != null){
+            if(RtuUpgradeStateReceiverCtrl.cache.ugRtuStateList != null && RtuUpgradeStateReceiverCtrl.cache.ugRtuStateList.size() > 0) {
+                RtuUpgradeStateReceiverCtrl.cache.ugRtuStateList.forEach(rtu -> {
+                    if(rtu.isOver){
+                        if(rtu.state == UpgradeRtu.STATE_OFFLINE
+                                || rtu.state == UpgradeRtu.STATE_UNSTART
+                                || rtu.state == UpgradeRtu.STATE_FAILOFFLINE){
+                            VoUgRtuResult4Failure vo = new VoUgRtuResult4Failure() ;
+                            vo.rtuAddr = rtu.rtuAddr ;
+                            vo.result = "绂荤嚎" ;
+                            list.add(vo);
+                        }else if(rtu.state == UpgradeRtu.STATE_FAILOPEN){
+                            VoUgRtuResult4Failure vo = new VoUgRtuResult4Failure() ;
+                            vo.rtuAddr = rtu.rtuAddr ;
+                            vo.result = "闃�寮�" ;
+                            list.add(vo);
+                        }else if(rtu.state == UpgradeRtu.STATE_FAILONE){
+                            VoUgRtuResult4Failure vo = new VoUgRtuResult4Failure() ;
+                            vo.rtuAddr = rtu.rtuAddr ;
+                            vo.result = "涓�鍖呮" ;
+                            list.add(vo);
+                        }else if(rtu.state == UpgradeRtu.STATE_FAIL){
+                            VoUgRtuResult4Failure vo = new VoUgRtuResult4Failure() ;
+                            vo.rtuAddr = rtu.rtuAddr ;
+                            vo.result = "澶氬寘姝�" ;
+                            list.add(vo);
+                        }
+                    }
+                });
+            }
+        }
+        return list ;
+    }
+
+    /**
+     * 杩囨护鍑哄綋鍓嶉暱绾т换鍔′腑鍗囩骇鎴愬姛鐨凴TU
+     * @return 闆嗗悎
+     */
+    public List<VoUgRtuResult4Success> exportUgSuccess(){
+        List<VoUgRtuResult4Success> list = new ArrayList<>() ;
+        if(RtuUpgradeStateReceiverCtrl.cache != null && RtuUpgradeStateReceiverCtrl.cache.ugTaskId != null){
+            if(RtuUpgradeStateReceiverCtrl.cache.ugRtuStateList != null && RtuUpgradeStateReceiverCtrl.cache.ugRtuStateList.size() > 0) {
+                RtuUpgradeStateReceiverCtrl.cache.ugRtuStateList.forEach(rtu -> {
+                    if(rtu.isOver){
+                        if(rtu.state == UpgradeRtu.STATE_SUCCESS){
+                            VoUgRtuResult4Success vo = new VoUgRtuResult4Success() ;
+                            vo.rtuAddr = rtu.rtuAddr ;
+                            vo.result = "鍗囩骇鎴愬姛" ;
+                            list.add(vo);
+                        }
+                    }
+                });
+            }
+        }
+        return list ;
+    }
+}

--
Gitblit v1.8.0