From ac87f61568a68501aa50d5c3f0d083e8ea36ebb3 Mon Sep 17 00:00:00 2001 From: wuzeyu <1223318623@qq.com> Date: 星期五, 29 十一月 2024 14:33:07 +0800 Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV --- pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeStateReceiverCtrl.java | 56 ++++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 40 insertions(+), 16 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeStateReceiverCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeStateReceiverCtrl.java index abfdc1b..9a8f18f 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeStateReceiverCtrl.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeStateReceiverCtrl.java @@ -21,6 +21,7 @@ import org.springframework.web.bind.annotation.*; import java.util.ArrayList; +import java.util.Comparator; import java.util.List; import java.util.stream.Collectors; @@ -48,15 +49,8 @@ @Hidden //涓嶅叕寮�鎺ュ彛锛屽叾鍙湁閫氫俊涓棿浠惰皟鐢� @PostMapping(path = "/receive") public BaseResponse<Boolean> receive(@RequestBody UpgradeInfo info, HttpServletRequest req, HttpServletResponse rep){ + /* log.info("鎺ユ敹鍒扮殑RTU杩滅▼鍗囩骇鐘舵�佹暟鎹负锛歿}", info.toString("532328000214")); - //杩涜鎺掑簭 - //Comparator<UpgradeRtu> comparator = Comparator.comparing(UpgradeRtu::getRtuAddr, Comparator.naturalOrder()); - //info.ugRtuStateList = info.ugRtuStateList.stream().sorted(comparator).collect(Collectors.toList()); - - //閫氫俊涓棿浠朵紶杩囨潵鐨勬満鏋則ag锛屼互鐢ㄤ簬鏌ユ壘鏁版嵁婧� - String token = req.getHeader(Constant.UserTokenKeyInHeader); - DataSourceContext.set(token); - if(info.ugRtuStateList != null && info.ugRtuStateList.size() > 0){ if(info.ugRtuStateList.size() < 10){ for (UpgradeRtu rtuVo : info.ugRtuStateList) { @@ -64,6 +58,16 @@ } } } + */ + + //杩涜鎺掑簭 + Comparator<UpgradeRtu> comparator = Comparator.comparing(UpgradeRtu::getRtuAddr, Comparator.naturalOrder()); + info.ugRtuStateList = info.ugRtuStateList.stream().sorted(comparator).collect(Collectors.toList()); + + //閫氫俊涓棿浠朵紶杩囨潵鐨勬満鏋則ag锛屼互鐢ㄤ簬鏌ユ壘鏁版嵁婧� + String token = req.getHeader(Constant.UserTokenKeyInHeader); + DataSourceContext.set(token); + if(cache == null){ cache = info; //姝ゆ椂涓嶅仛浠诲姟鎿嶄綔锛屽彧淇濋殰cache涓嶄负绌猴紝 绛夊緟涓嬫鍙戞潵鏁版嵁 @@ -74,11 +78,15 @@ } } }else{ - cache = info; //褰揷ache涓湁鍊兼椂锛岃繘琛屾瘮瀵瑰瓨鍌紝瀵规瘮鐩殑鏄槻姝㈤噸澶嶆搷浣滄暟鎹簱 if(info.ugRtuStateList != null && info.ugRtuStateList.size() > 0){ //姝ゆ椂淇濊瘉涓や釜闆嗗悎閮戒笉涓簄ull this.save2Db(info.ugTaskId, info.ugRtuStateList, cache.ugRtuStateList); + } + //cache璧嬪�煎繀椤绘斁鍦ㄤ笂闈㈠鐞嗙殑鍚庨潰锛屽惁鍒欎笂闈㈢殑姣旇緝涓嶆垚鍔� + cache = info; + if(info.ugOverallState != null && info.ugOverallState.allOver){ + this.saveTaskOver(info.ugTaskId) ; } } return null; @@ -103,15 +111,31 @@ */ private void save2Db(String taskId, List<UpgradeRtu> newList, List<UpgradeRtu> oldList){ List<UpgradeRtu> newOverList = newList.stream().filter(vo -> vo.isOver).collect(Collectors.toList()) ; + List<UpgradeRtu> oldNoOverList = newList.stream().filter(vo -> !vo.isOver).collect(Collectors.toList()) ; + boolean oldExist = false ; for(UpgradeRtu nvo : newOverList){ - if(nvo != null) { - if(oldList.stream().anyMatch(vo -> vo.rtuAddr.equals(nvo.rtuAddr) && vo.isOver == false)){ - //涓婃娌℃湁鍗囩骇缁撴潫锛岃�屽綋鍓嶅崌绾х粨鏉熶簡 - this.sv.saveRtuUpgradeState(Long.parseLong(taskId), nvo); - } + oldExist = false ; + if(oldNoOverList.stream().anyMatch(vo -> vo.rtuAddr.equals(nvo.rtuAddr))){ + oldExist = true ; + } + if(!oldExist){ + //涓婃娌℃湁鍗囩骇缁撴潫锛岃�屽綋鍓嶅崌绾х粨鏉熶簡 + this.sv.saveRtuUpgradeState(Long.parseLong(taskId), nvo); } } } + + /** + * 淇濆瓨鍗囩骇浠诲姟宸茬粡鎵ц瀹屾垚 + * @param taskId + */ + private void saveTaskOver(String taskId){ + this.sv.updateTaskOver(taskId) ; + } + + + + ///////////////////////////////////////////////////// // // 浠ヤ笅妯℃嫙鏁版嵁 @@ -305,10 +329,10 @@ }else if(rtu.state == UpgradeRtu.STATE_SUCCESS) { cache.ugOverallState.successTotal++; }else if(rtu.state == UpgradeRtu.STATE_FAILONE) { - cache.ugOverallState.failOneTotal++; + cache.ugOverallState.dieOneTotal++; cache.ugOverallState.failTotal++; }else if(rtu.state == UpgradeRtu.STATE_FAIL) { - cache.ugOverallState.failMultiTotal++; + cache.ugOverallState.dieMultiTotal++; cache.ugOverallState.failTotal++; } if(rtu.isOver){ -- Gitblit v1.8.0