From d5a24d68b0ddb3faade00504dabc0643db7d056c Mon Sep 17 00:00:00 2001 From: zhubaomin <zhubaomin> Date: 星期二, 26 十一月 2024 11:26:18 +0800 Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV --- pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreConstantThread.java | 9 pipIrr-platform/pom.xml | 11 pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/tcpClient/downData/DownData.java | 28 + pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/java/com/dy/pipIrrApp/inspect/InspectCtrl.java | 26 + pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreUnit.java | 28 pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeStateReceiverCtrl.java | 21 pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/CommandSv.java | 2 pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/Server.java | 7 pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/task/UgRtuResultCtrl.java | 2 pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeGeneralMapper.xml | 2 pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/Server.java | 10 pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voUg/VoUgRtuResult.java | 30 + pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/upgrade/UpgradeManager.java | 44 + pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeResSv.java | 160 +++++++ pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreTimer.java | 80 +++ pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreUnitConfigVo.java | 3 pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/config(ym元谋).xml | 6 pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/PipIrrMwSimulateRtuApplication.java | 21 + pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/说明.txt | 1 pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/TimerTaskJob.java | 3 pipIrr-platform/pipIrr-global/src/main/resources/mapper/OpeInspectMapper.xml | 48 ++ pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/upgrade/UpgradeTask.java | 36 + pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/config.xml | 10 pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/state/UpgradeState.java | 5 pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/tcpClient/TcpHandler.java | 6 pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoOp/OpeInspectMapper.java | 18 pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoOp/OpeTrackMapper.java | 7 pipIrr-platform/pipIrr-global/src/main/resources/mapper/OpeTrackMapper.xml | 11 pipIrr-platform/pipIrr-common/pom.xml | 6 pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml | 2 pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeCtrl.java | 171 +++---- pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voOp/VoInspect.java | 53 ++ pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/task/UgRtuControllerCtrl.java | 14 pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreConstantManage.java | 20 pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/config(sp沙盘).xml | 6 pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreThread.java | 9 pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ThreadJob.java | 1 pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/resources/config.xml | 2 pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/task/UgRtuAddControllerCtrl.java | 8 pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/state/UpgradeRtu.java | 4 pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/CreateRandom.java | 16 pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/config(test测试).xml | 6 pipIrr-platform/pipIrr-global/pom.xml | 6 pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voUg/VoWatch.java | 10 pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/ServerProperties.java | 6 pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/java/com/dy/pipIrrApp/captcha/CaptchaCtrl.java | 4 pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/program/UgRtuProgramCtrl.java | 30 pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreConstantTimer.java | 45 ++ pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/java/com/dy/pipIrrApp/inspect/InspectSv.java | 45 ++ pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeSv.java | 57 +- pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/java/com/dy/pipIrrApp/inspect/qo/QoInspect.java | 41 + pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/task/UgRtuTaskCtrl.java | 42 +- 52 files changed, 961 insertions(+), 278 deletions(-) diff --git a/pipIrr-platform/pipIrr-common/pom.xml b/pipIrr-platform/pipIrr-common/pom.xml index 9b94099..fa7c5a5 100644 --- a/pipIrr-platform/pipIrr-common/pom.xml +++ b/pipIrr-platform/pipIrr-common/pom.xml @@ -101,6 +101,11 @@ <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.5.3.2</version> </dependency> + <dependency> + <groupId>com.baomidou</groupId> + <artifactId>mybatis-plus-extension</artifactId> + <version>3.5.3.2</version> + </dependency> <!-- 闃块噷fastjson --> <dependency> @@ -167,6 +172,7 @@ <artifactId>log4j-slf4j-impl</artifactId> <version>2.17.2</version> </dependency> + </dependencies> <build> diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreConstantManage.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreConstantManage.java index 262df98..492aab1 100644 --- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreConstantManage.java +++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreConstantManage.java @@ -1,5 +1,6 @@ package com.dy.common.mw.core; +import java.util.ArrayList; import java.util.List; import org.apache.logging.log4j.*; @@ -10,10 +11,12 @@ private final static CoreConstantManage instance = new CoreConstantManage() ; - private static Long sleepBigBusy = 100L ;//澶у繖鏃讹紙闄や簡鎭掍箙浠诲姟锛岃繕鏄叾浠栦换鍔★級锛屾牳蹇冪嚎绋嬫殏鍋滈棿闅� - private static Long sleepSmallBusy = 500L ;//灏忓繖鏃讹紙鍙湁鎭掍箙浠诲姟锛屾棤鍏朵粬浠诲姟锛夛紝鏍稿績绾跨▼鏆傚仠闂撮殧 - + private List<CoreConstantTimer> coreConstantTimers ; + + private Long coreInterval = 100L ;//鏍稿績绾跨▼鏆傚仠闂撮殧 + private CoreConstantManage(){ + coreConstantTimers = new ArrayList<>() ; } public static CoreConstantManage getInstance(){ @@ -22,12 +25,10 @@ /** * 璁剧疆鏆傚仠鏃堕暱 - * @param sleepBigBusy 澶у繖鏃讹紙闄や簡鎭掍箙浠诲姟锛岃繕鏄叾浠栦换鍔★級锛屾牳蹇冪嚎绋嬫殏鍋滈棿闅� - * @param sleepSmallBusy 灏忓繖鏃讹紙鍙湁鎭掍箙浠诲姟锛屾棤鍏朵粬浠诲姟锛夛紝鏍稿績绾跨▼鏆傚仠闂撮殧 + * @param coreInterval 鏍稿績绾跨▼鏆傚仠闂撮殧 */ - public void setSleep(Long sleepBigBusy, Long sleepSmallBusy){ - CoreConstantManage.sleepBigBusy = sleepBigBusy ; - CoreConstantManage.sleepSmallBusy = sleepSmallBusy ; + public void setSleep(Long coreInterval){ + this.coreInterval = coreInterval ; } public void start(){ @@ -35,7 +36,8 @@ List<CoreTask> constantTasks = CoreUnit.getAllConstantTasks(); if (constantTasks != null && constantTasks.size() > 0) { for (CoreTask task : constantTasks) { - new CoreConstantThread(sleepBigBusy, sleepSmallBusy, task).start(); + //new CoreConstantThread(sleepBigBusy, sleepSmallBusy, task).start(); + coreConstantTimers.add(new CoreConstantTimer(coreInterval, task).start()); } } } diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreConstantThread.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreConstantThread.java index 8e497f2..34a6f56 100644 --- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreConstantThread.java +++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreConstantThread.java @@ -9,6 +9,15 @@ * @LastEditTime 2023/12/19 16:41 * @Description */ +/** + * 2024-11-21 璇ョ被宸茬粡寮冪敤锛屾敼鐢盋oreConstantTimer瀹炵幇銆� + * 褰撻噰鐢═hread瀹炵幇鏃讹紝鍦╳hile(true){}涓娇鐢═hread.sleep()锛屽彲鑳藉鑷寸殑涓ラ噸鎬ц兘闂锛屼笉鎺ㄨ崘鍦ㄥ惊鐜腑浣跨敤绾跨▼浼戠湢銆� + * Java绾跨▼瀹炵幇閲囩敤鍐呮牳绾跨▼瀹炵幇锛岀嚎绋嬬殑浼戠湢鍙婂敜閱掞紙鐘舵�佸垏鎹級闇�鍊熷姪鎿嶄綔绯荤粺杩涜锛岃繖鏄竴涓瀬鍏惰�楁椂鑰楀姏鐨勬搷浣溿�� + * 鍦ㄧ嚎绋嬩紤鐪犳垨杩愯鏃堕棿杈冮暱鐨勬儏鏅笅锛屽叾瀵规�ц兘鐨勫奖鍝嶈繕涓嶇畻鏄庢樉锛屽洜涓哄绾跨▼鐘舵�佺殑鍒囨崲骞朵笉棰戠箒銆� + * 浣嗚嫢绾跨▼浼戠湢鍙婅繍琛岀殑鏃堕棿閮藉緢鐭紙渚嬪姣/绉掞級锛� + * 绯荤粺灏嗛绻佺殑瀵圭嚎绋嬬姸鎬佽繘琛屽垏鎹紝瀵艰嚧涓ラ噸鐨勬�ц兘鎹熻�楋紝骞跺鐫�寰幆娆℃暟鐨勯�掑鑰屾斁澶с�� + */ +@Deprecated public class CoreConstantThread extends Thread { private final static Logger log = LogManager.getLogger(CoreConstantThread.class.getName()) ; diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreConstantTimer.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreConstantTimer.java new file mode 100644 index 0000000..a6aceb2 --- /dev/null +++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreConstantTimer.java @@ -0,0 +1,45 @@ +package com.dy.common.mw.core; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.Timer; +import java.util.TimerTask; + +/** + * @Author: liurunyu + * @Date: 2024/11/21 17:13 + * @Description + */ +public class CoreConstantTimer extends TimerTask { + + private final static Logger log = LogManager.getLogger(CoreConstantTimer.class.getName()) ; + + private Timer timer; + + private long coreInterval ; + + private CoreTask task ; + + public CoreConstantTimer(long coreInterval, CoreTask task){ + this.timer = new Timer(); + this.coreInterval = coreInterval ; + this.task = task ; + } + + public CoreConstantTimer start(){ + this.timer.schedule(this, 0 , this.coreInterval); + return this ; + } + + @Override + public void run() { + if(task != null){ + try { + task.execute(); + } catch (Exception e) { + log.error("鎭掍箙浠诲姟" + task.getClass().getName() + "鎵ц鏃跺彂鐢熷紓甯�" + (e.getMessage() == null ? "" : (":" + e.getMessage())), e); + } + } + } +} diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreThread.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreThread.java index 4f706a3..e77a8d1 100644 --- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreThread.java +++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreThread.java @@ -4,6 +4,15 @@ import com.dy.common.queue.Queue; +/** + * 2024-11-21 璇ョ被宸茬粡寮冪敤锛屾敼鐢盋oreTimer瀹炵幇銆� + * 褰撻噰鐢═hread瀹炵幇鏃讹紝鍦╳hile(true){}涓娇鐢═hread.sleep()锛屽彲鑳藉鑷寸殑涓ラ噸鎬ц兘闂锛屼笉鎺ㄨ崘鍦ㄥ惊鐜腑浣跨敤绾跨▼浼戠湢銆� + * Java绾跨▼瀹炵幇閲囩敤鍐呮牳绾跨▼瀹炵幇锛岀嚎绋嬬殑浼戠湢鍙婂敜閱掞紙鐘舵�佸垏鎹級闇�鍊熷姪鎿嶄綔绯荤粺杩涜锛岃繖鏄竴涓瀬鍏惰�楁椂鑰楀姏鐨勬搷浣溿�� + * 鍦ㄧ嚎绋嬩紤鐪犳垨杩愯鏃堕棿杈冮暱鐨勬儏鏅笅锛屽叾瀵规�ц兘鐨勫奖鍝嶈繕涓嶇畻鏄庢樉锛屽洜涓哄绾跨▼鐘舵�佺殑鍒囨崲骞朵笉棰戠箒銆� + * 浣嗚嫢绾跨▼浼戠湢鍙婅繍琛岀殑鏃堕棿閮藉緢鐭紙渚嬪姣/绉掞級锛� + * 绯荤粺灏嗛绻佺殑瀵圭嚎绋嬬姸鎬佽繘琛屽垏鎹紝瀵艰嚧涓ラ噸鐨勬�ц兘鎹熻�楋紝骞跺鐫�寰幆娆℃暟鐨勯�掑鑰屾斁澶с�� + */ +@Deprecated public class CoreThread extends Thread{ private static Logger log = LogManager.getLogger(CoreThread.class.getName()) ; diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreTimer.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreTimer.java new file mode 100644 index 0000000..9e30fd6 --- /dev/null +++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreTimer.java @@ -0,0 +1,80 @@ +package com.dy.common.mw.core; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.Timer; +import java.util.TimerTask; + +/** + * @Author: liurunyu + * @Date: 2024/11/21 13:41 + * @Description + */ +public class CoreTimer extends TimerTask { + + private static final Logger log = LogManager.getLogger(CoreTimer.class.getName()) ; + + private static final CoreTimer instance = new CoreTimer() ; + + private Long workInterval = 100L ;//鏍稿績绾跨▼鏆傚仠闂撮殧 + + private Timer timer; + + private boolean stop; + + private CoreTimer(){ + this.timer = new Timer(); + this.stop = false ; + } + + public static CoreTimer getInstance(){ + return instance ; + } + + public void stop(){ + this.stop = true ; + if(this.timer != null){ + this.timer.cancel(); + } + } + public boolean isStop(){ + return this.stop ; + } + + /** + * 璁剧疆/鏍稿績绾跨▼鏆傚仠闂撮殧 + * @param workInterval /鏍稿績绾跨▼鏆傚仠闂撮殧 + */ + public void setSleep(Long workInterval){ + this.workInterval = workInterval ; + } + + public void start(){ + this.timer.schedule(this, 0 , this.workInterval); + } + + /** + * TimerTask鐨剅un鏂规硶 + */ + @Override + public void run() { + try{ + /** + * 姝ゅ鍙栧嚭褰撳墠闃熷垪鐨勮妭鐐规暟閲忥紝浣滀负涓�涓畾閲廲ount澶勭悊锛� + * 鍘熷洜: + * 鍦ㄥ鐞嗗畾閲廲ount杩囩▼涓紝鍙兘鏈夌殑鑺傜偣鍙堝洖鍒伴槦鍒椾腑锛屼篃鍙兘鏂扮敓鑺傜偣杩涘叆闃熷垪涓紝鍗冲湪澶勭悊杩囩▼涓紝闃熷垪鍙兘鍙堝闀夸簡 + */ + int count = CoreUnit.taskQueue.size() ; + while(count > 0){ + CoreTask task = (CoreTask)CoreUnit.taskQueue.pop() ; + if(task != null){ + task.execute(); + } + count-- ; + } + }catch(Exception e){ + log.error("鏍稿績绾跨▼鍙戠敓寮傚父" + (e.getMessage() == null ? "" : (":" + e.getMessage())), e);; + } + } +} diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreUnit.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreUnit.java index d7c3261..6b3ce51 100644 --- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreUnit.java +++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreUnit.java @@ -8,6 +8,7 @@ import com.dy.common.mw.UnitInterface; import com.dy.common.mw.UnitCallbackInterface; + public class CoreUnit implements UnitInterface { private static final CoreUnit instance = new CoreUnit() ; @@ -36,17 +37,14 @@ if(vo == null){ throw new Exception("鏍稿績妯″潡閰嶇疆瀵硅薄涓嶈兘涓虹┖锛�") ; } - if(vo.sleepBigBusy == null || vo.sleepSmallBusy == null){ + if(vo.coreInterval == null){ throw new Exception("鏍稿績妯″潡閰嶇疆瀵硅薄闂撮殧灞炴�у�间笉鑳戒负绌猴紒") ; } - if(vo.sleepBigBusy <= 0){ - throw new Exception("鏍稿績妯″潡閰嶇疆瀵硅薄灞炴�leepBigBusy鍊间笉鑳藉皬浜�0锛�") ; + if(vo.coreInterval <= 0){ + throw new Exception("鏍稿績妯″潡閰嶇疆瀵硅薄灞炴�oreInterval鍊间笉鑳藉皬浜�0锛�") ; } - if(vo.sleepBigBusy > 1000){ - throw new Exception("鏍稿績妯″潡閰嶇疆瀵硅薄灞炴�leepBigBusy鍊间笉鑳藉ぇ浜�1000锛�") ; - } - if(vo.sleepSmallBusy > 1000){ - throw new Exception("鏍稿績妯″潡閰嶇疆瀵硅薄灞炴�leepSmallBusy鍊间笉鑳藉ぇ浜�1000锛�") ; + if(vo.coreInterval > 1000){ + throw new Exception("鏍稿績妯″潡閰嶇疆瀵硅薄灞炴�oreInterval鍊间笉鑳藉ぇ浜�1000锛�") ; } if(vo.queueWarnSize == null || vo.queueMaxSize == null){ throw new Exception("鏍稿績妯″潡閰嶇疆瀵硅薄闃熷垪鑺傜偣闄愬埗鏁伴噺灞炴�у�间笉鑳戒负绌猴紒") ; @@ -67,18 +65,22 @@ public void start(UnitCallbackInterface callback) throws Exception { if(!started){ started = true ; + /* CoreThread ct = CoreThread.getInstance() ; ct.setSleep(this.adapter.getConfig().sleepBigBusy, this.adapter.getConfig().sleepSmallBusy); - ct.start(); - + ct.start(); + */ + CoreTimer ct = CoreTimer.getInstance() ; + ct.setSleep(this.adapter.getConfig().coreInterval); + ct.start(); + CoreConstantManage ccm = CoreConstantManage.getInstance() ; - ccm.setSleep(this.adapter.getConfig().sleepBigBusy, this.adapter.getConfig().sleepSmallBusy); + ccm.setSleep(this.adapter.getConfig().coreInterval); ccm.start(); if(adapter.getConfig().showStartInfo){ System.out.println("鏍稿績妯″潡鎴愬姛鍚姩锛�" - + "涓荤嚎绋嬬箒蹇欓棿闅旓細" + adapter.getConfig().sleepBigBusy + "姣锛�" - + "杞婚棽闂撮殧锛�" + adapter.getConfig().sleepSmallBusy + "姣" ); + + "涓荤嚎绋嬫墽琛岄棿闅旓細" + adapter.getConfig().coreInterval + "姣"); } callback.call(null); } diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreUnitConfigVo.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreUnitConfigVo.java index 521c1cf..591c566 100644 --- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreUnitConfigVo.java +++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreUnitConfigVo.java @@ -1,8 +1,7 @@ package com.dy.common.mw.core; public class CoreUnitConfigVo { - public Long sleepBigBusy = 100L ;//澶у繖鏃讹紙闄や簡鎭掍箙浠诲姟锛岃繕鏈夊叾浠栦换鍔¢渶澶勭悊锛夛紝鏍稿績绾跨▼鏆傚仠闂撮殧 - public Long sleepSmallBusy = 500L ;//灏忓繖鏃讹紙鍙湁鎭掍箙浠诲姟锛屾棤鍏朵粬浠诲姟闇�澶勭悊锛夛紝鏍稿績绾跨▼鏆傚仠闂撮殧 + public Long coreInterval = 100L ;//澶у繖鏃讹紙闄や簡鎭掍箙浠诲姟锛岃繕鏈夊叾浠栦换鍔¢渶澶勭悊锛夛紝鏍稿績绾跨▼鏆傚仠闂撮殧 public Integer queueWarnSize = 1000 ;//闃熷垪鎶ヨ闀垮害 public Integer queueMaxSize = 5000 ;//闃熷垪鏈�澶ч暱搴� public Boolean showStartInfo; //鏄惁鍦ㄦ帶鍒跺彴涓婃樉绀轰俊鎭� diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/state/UpgradeRtu.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/state/UpgradeRtu.java index ba9c1d6..2d81abd 100644 --- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/state/UpgradeRtu.java +++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/state/UpgradeRtu.java @@ -22,9 +22,9 @@ @JSONField(serialize = false) public static final int STATE_SUCCESS = 2 ;//2-鍗囩骇鎴愬姛 @JSONField(serialize = false) - public static final int STATE_FAILONE = 3 ;//3-鍗囩骇澶辫触锛�1鍖呮锛� + public static final int STATE_FAILONE = 3 ;//3-鍗囩骇澶辫触锛堜竴鍖呮锛� @JSONField(serialize = false) - public static final int STATE_FAIL = 4 ;//4-鍗囩骇澶辫触锛堥潪1鍖呮锛� + public static final int STATE_FAIL = 4 ;//4-鍗囩骇澶辫触锛堝鍖呮锛� @JSONField(serialize = false) public static final int STATE_FAILOFFLINE = 5 ;//4-鍗囩骇澶辫触锛堢绾匡級 @JSONField(serialize = false) diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/state/UpgradeState.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/state/UpgradeState.java index f1983e7..a9e20a5 100644 --- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/state/UpgradeState.java +++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/state/UpgradeState.java @@ -18,6 +18,7 @@ public int successTotal ;//鎵�鏈夋垚鍔� public int failTotal ;//鎵�鏈夊け璐ワ紙涓�鍖呮澶辫触+澶氬寘姝诲け璐�+绂荤嚎澶辫触锛� public int failOneTotal ;//鎵�鏈変竴鍖呮澶辫触 + public int failMultiTotal ;//鎵�鏈夊鍖呮澶辫触 public int failOffTotal ;//鎵�鏈夌绾垮け璐� public Boolean allOver ;//鎵�鏈夐兘缁撴潫锛坱rue:鏄紝false:鍚︼級 @@ -35,6 +36,7 @@ this.successTotal = 0; this.failTotal = 0; this.failOneTotal = 0; + this.failMultiTotal = 0; this.failOffTotal = 0; this.allOver = false ; } @@ -49,7 +51,8 @@ sb.append(" \n宸茬粨鏉熸�绘暟锛�" + overTotal) ; sb.append(" \n鎴愬姛鎬绘暟锛�" + successTotal) ; sb.append(" \n澶辫触鎬绘暟锛�" + failTotal) ; - sb.append(" \n1鍖呮澶辫触鎬绘暟锛�" + failOneTotal) ; + sb.append(" \n涓�鍖呮澶辫触鎬绘暟锛�" + failOneTotal) ; + sb.append(" \n澶氬寘姝诲け璐ユ�绘暟锛�" + failMultiTotal) ; sb.append(" \n绂荤嚎澶辫触鎬绘暟锛�" + failOffTotal) ; sb.append(" \n鍏ㄧ粨鏉燂細" + allOver) ; return sb.toString() ; diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/CreateRandom.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/CreateRandom.java index 1491ef3..984b0d3 100644 --- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/CreateRandom.java +++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/CreateRandom.java @@ -11,13 +11,15 @@ /* public static void main(String[] args) { - System.out.println(CreateRandom.Random(1, 0)); - System.out.println(CreateRandom.Random(2, 0)); - System.out.println(CreateRandom.Random(3, 0)); - System.out.println(CreateRandom.Random(4, 0)); - System.out.println(CreateRandom.Random(5, 0)); - System.out.println(CreateRandom.Random(100, 0)); - System.out.println(CreateRandom.Random(1256, 1234)); + System.out.println(CreateRandom.random(1, 0)); + System.out.println(CreateRandom.random(2, 0)); + System.out.println(CreateRandom.random(3, 0)); + System.out.println(CreateRandom.random(4, 0)); + System.out.println(CreateRandom.random(5, 0)); + System.out.println(CreateRandom.random(100, 0)); + System.out.println(CreateRandom.random(1256, 1234)); + System.out.println("======================="); + System.out.println(create_between(10, 100)); } */ diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ThreadJob.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ThreadJob.java index 35c75e0..cfd912a 100644 --- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ThreadJob.java +++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ThreadJob.java @@ -2,6 +2,7 @@ @SuppressWarnings("unused") +@Deprecated public abstract class ThreadJob { protected Thread thread ; protected boolean stop = false ; diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/TimerTaskJob.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/TimerTaskJob.java index b72f479..8aefc22 100644 --- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/TimerTaskJob.java +++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/TimerTaskJob.java @@ -7,11 +7,12 @@ * @Author: liurunyu * @Date: 2024/11/20 17:49 * @Description : + * 2024-11-20锛� * 姝ゆ娊璞$被浠f浛ThreadJob锛屽師鍥狅細 * 鍦╳hile(true){}涓娇鐢═hread.sleep()锛屽彲鑳藉鑷寸殑涓ラ噸鎬ц兘闂锛屼笉鎺ㄨ崘鍦ㄥ惊鐜腑浣跨敤绾跨▼浼戠湢銆� * Java绾跨▼瀹炵幇閲囩敤鍐呮牳绾跨▼瀹炵幇锛岀嚎绋嬬殑浼戠湢鍙婂敜閱掞紙鐘舵�佸垏鎹級闇�鍊熷姪鎿嶄綔绯荤粺杩涜锛岃繖鏄竴涓瀬鍏惰�楁椂鑰楀姏鐨勬搷浣溿�� * 鍦ㄧ嚎绋嬩紤鐪犳垨杩愯鏃堕棿杈冮暱鐨勬儏鏅笅锛屽叾瀵规�ц兘鐨勫奖鍝嶈繕涓嶇畻鏄庢樉锛屽洜涓哄绾跨▼鐘舵�佺殑鍒囨崲骞朵笉棰戠箒銆� - * 浣嗚嫢绾跨▼浼戠湢鍙婅繍琛岀殑鏃堕棿閮藉緢鐭紙渚嬪姣/绉掞紝鏂囦腑妗堜緥灏辨槸涓�涓吀鍨嬫渚嬶級锛� + * 浣嗚嫢绾跨▼浼戠湢鍙婅繍琛岀殑鏃堕棿閮藉緢鐭紙渚嬪姣/绉掞級锛� * 绯荤粺灏嗛绻佺殑瀵圭嚎绋嬬姸鎬佽繘琛屽垏鎹紝瀵艰嚧涓ラ噸鐨勬�ц兘鎹熻�楋紝骞跺鐫�寰幆娆℃暟鐨勯�掑鑰屾斁澶с�� */ public abstract class TimerTaskJob { diff --git a/pipIrr-platform/pipIrr-global/pom.xml b/pipIrr-platform/pipIrr-global/pom.xml index 84298ca..161108e 100644 --- a/pipIrr-platform/pipIrr-global/pom.xml +++ b/pipIrr-platform/pipIrr-global/pom.xml @@ -69,7 +69,6 @@ <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> - <version>1.18.28</version> </dependency> <dependency> <groupId>org.aspectj</groupId> @@ -94,6 +93,11 @@ <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.5.3.2</version> </dependency> + <dependency> + <groupId>com.baomidou</groupId> + <artifactId>mybatis-plus-extension</artifactId> + <version>3.5.3.2</version> + </dependency> <!-- 闃块噷fastjson --> <dependency> <groupId>cglib</groupId> diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoOp/OpeInspectMapper.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoOp/OpeInspectMapper.java index 86ab9e7..3e5c041 100644 --- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoOp/OpeInspectMapper.java +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoOp/OpeInspectMapper.java @@ -2,7 +2,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.dy.pipIrrGlobal.pojoOp.OpeInspect; +import com.dy.pipIrrGlobal.voOp.VoInspect; import org.apache.ibatis.annotations.Mapper; + +import java.util.List; +import java.util.Map; /** * @author ZhuBaoMin @@ -24,4 +28,18 @@ int updateByPrimaryKeySelective(OpeInspect record); int updateByPrimaryKey(OpeInspect record); + + /** + * 宸℃鏌ヨ + * @param params + * @return + */ + Long getInspectsCount(Map<String, Object> params); + + /** + * 宸℃鏌ヨ + * @param params + * @return + */ + List<VoInspect> getInspects(Map<String, Object> params); } \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoOp/OpeTrackMapper.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoOp/OpeTrackMapper.java index 492a918..c1e7004 100644 --- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoOp/OpeTrackMapper.java +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoOp/OpeTrackMapper.java @@ -33,4 +33,11 @@ * @return */ int insertTracks(List<OpeTrack> list); + + /** + * 閫氳繃宸℃ID鏌ヨ杞ㄨ抗 + * @param inspectId + * @return + */ + List<OpeTrack> selectByInspectId(Long inspectId); } \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voOp/VoInspect.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voOp/VoInspect.java new file mode 100644 index 0000000..cb8fc4d --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voOp/VoInspect.java @@ -0,0 +1,53 @@ +package com.dy.pipIrrGlobal.voOp; + +import com.dy.common.po.BaseEntity; +import com.dy.pipIrrGlobal.pojoOp.OpeTrack; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.Data; +import java.util.Date; + +import java.util.List; + +/** + * @author :WuZeYu + * @Date :2024/11/20 15:37 + * @LastEditTime :2024/11/20 15:37 + * @Description + */ +@Data +public class VoInspect implements BaseEntity { + private static final long serialVersionUID = 202411201537001L; + + /** + * 宸℃鍛業D + */ + @JsonSerialize(using = ToStringSerializer.class) + private Long inspectorId; + + /** + * 宸℃鍛樺鍚� + */ + private String inspectorName; + + /** + * 宸℃ID + */ + @JsonSerialize(using = ToStringSerializer.class) + private Long inspectId; + /** + * 寮�濮嬪贰妫�鏃堕棿 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date startTime; + /** + * 缁撴潫宸℃鏃堕棿 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date stopTime; + /** + * 鍚勪釜宸℃鐐� + */ + private List<OpeTrack> tracks; +} diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voUg/VoUgRtuResult.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voUg/VoUgRtuResult.java new file mode 100644 index 0000000..2653252 --- /dev/null +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voUg/VoUgRtuResult.java @@ -0,0 +1,30 @@ +package com.dy.pipIrrGlobal.voUg; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.alibaba.excel.annotation.write.style.ContentRowHeight; +import com.alibaba.excel.annotation.write.style.ContentStyle; +import com.alibaba.excel.annotation.write.style.HeadRowHeight; +import com.alibaba.excel.enums.poi.HorizontalAlignmentEnum; +import com.alibaba.excel.enums.poi.VerticalAlignmentEnum; +import lombok.Data; + +/** + * @Author: liurunyu + * @Date: 2024/11/22 14:26 + * @Description + */ +@Data +@HeadRowHeight(26) +@ContentRowHeight(22) +public class VoUgRtuResult { + @ExcelProperty("鎺у埗鍣ㄥ湴鍧�") + @ColumnWidth(20) + @ContentStyle(horizontalAlignment = HorizontalAlignmentEnum.CENTER, verticalAlignment = VerticalAlignmentEnum.CENTER) + public String rtuAddr; + + @ExcelProperty("鍗囩骇缁撴灉") + @ColumnWidth(30) + @ContentStyle(horizontalAlignment = HorizontalAlignmentEnum.LEFT, verticalAlignment = VerticalAlignmentEnum.CENTER) + public String result; +} diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voUg/VoWatch.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voUg/VoWatch.java index 2c31869..7320ca6 100644 --- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voUg/VoWatch.java +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voUg/VoWatch.java @@ -28,15 +28,19 @@ public String rtuAddr ; //鎺у埗鍣ㄥ湴鍧� public Integer rate ; //杩涘害 public String state; //鍗囩骇鐘舵�� - public Integer status; //杩囩▼鐘舵�侊紙0锛氱绾匡紝1锛氬崌绾т腑锛�2锛氬崌绾ф垚鍔燂紝3鍗囩骇澶辫触锛� + public Integer status; //杩囩▼鐘舵�侊紙0锛氱绾匡紝1锛氬崌绾т腑锛�2锛氬崌绾ф垚鍔燂紝3鍗囩骇澶辫触锛夛紝鍓嶇鍒╃敤鍏惰缃崱鐗囨牱寮� public Integer reTryTimes ; //閲嶈瘯娆℃暟 public Boolean over ; //鏄惁缁撴潫锛坱rue锛氭槸锛宖alse锛氬惁锛� public Boolean success ; //鏄惁鎴愬姛锛坣ull:杩涜涓紝true锛氭槸锛宖alse锛氬惁锛� public void fromCache(UpgradeRtu ugRtu){ this.rtuAddr = ugRtu.rtuAddr ; + this.rate = (ugRtu.currentPackage * 1000)/ugRtu.totalPackage ;//鍓嶇瀹炵幇鏄�1000浠界殑杩涘害鏉� + this.state = UpgradeRtu.getStateName(ugRtu.state) ; + + //杩囩▼鐘舵�侊紙0锛氱绾匡紝1锛氬崌绾т腑锛�2锛氬崌绾ф垚鍔燂紝3鍗囩骇澶辫触锛夛紝鍓嶇鍒╃敤鍏惰缃崱鐗囨牱寮� this.status = 1 ;//榛樿鍗囩骇涓� if(ugRtu.state == UpgradeRtu.STATE_OFFLINE){ this.status = 0 ; @@ -47,8 +51,12 @@ this.status = 3; } } + + this.reTryTimes = ugRtu.reTryTimes ; + this.over = ugRtu.isOver ; + if(ugRtu.isOver){ this.success = (ugRtu.state == UpgradeRtu.STATE_SUCCESS ? true : false) ; }else{ diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml b/pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml index 3445b17..fc2033d 100644 --- a/pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml +++ b/pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml @@ -313,7 +313,7 @@ #鍛戒护鍙戦�佸湴鍧�(涓紑鏄満鏋則ag锛屽叾涔熸槸鏁版嵁婧愬悗缂�鍚嶇О) ym: comSendUrl: "http://127.0.0.1:8070/rtuMw/com/send" - ugTaskSendUrl: "http://192.168.40.132:8070/rtuMw/com/upgradeRtu" + ugTaskSendUrl: "http://127.0.0.1:8070/rtuMw/com/upgradeRtu" rtuLogFileUrl: "http://127.0.0.1:8070/rtuMw/com/rtuLogFile" rtuLogTextUrl: "http://127.0.0.1:8070/rtuMw/com/rtuLogText" sp: diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/OpeInspectMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/OpeInspectMapper.xml index 888dd76..c7f927a 100644 --- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/OpeInspectMapper.xml +++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/OpeInspectMapper.xml @@ -88,4 +88,52 @@ stop_time = #{stopTime,jdbcType=TIMESTAMP} where id = #{id,jdbcType=BIGINT} </update> +<!-- 鏌ヨ鎬绘暟 --> + <select id="getInspectsCount" resultType="java.lang.Long"> + SELECT + count(*) + FROM `ope_inspect` oi + INNER JOIN `ba_user` ON oi.inspector_id = ba_user.id + <where> + ba_user.deleted = 0 + <if test="inspectorId != null"> + AND oi.inspector_id = #{inspectorId} + </if> + <if test="inspectId != null"> + AND oi.id = #{inspectId} + </if> + <if test="inspectorName != null"> + AND ba_user.`name` LIKE CONCAT('%',#{inspectorName},'%') + </if> + <if test="timeStart != null and timeStop != null"> + AND oi.start_time BETWEEN #{timeStart} AND #{timeStop} + </if> + </where> + </select> +<!-- 鏌ヨ鍒楄〃 --> + <select id="getInspects" resultType="com.dy.pipIrrGlobal.voOp.VoInspect"> + SELECT + oi.inspector_id AS inspectorId, + ba_user.`name` AS inspectorName, + oi.id AS inspectId, + oi.start_time AS startTime, + oi.stop_time AS stopTime + FROM `ope_inspect` oi + INNER JOIN `ba_user` ON oi.inspector_id = ba_user.id + <where> + ba_user.deleted = 0 + <if test="inspectorId != null"> + AND oi.inspector_id = #{inspectorId} + </if> + <if test="inspectId != null"> + AND oi.id = #{inspectId} + </if> + <if test="inspectorName != null"> + AND ba_user.`name` LIKE CONCAT('%',#{inspectorName},'%') + </if> + <if test="timeStart != null and timeStop != null"> + AND oi.start_time BETWEEN #{timeStart} AND #{timeStop} + </if> + </where> + </select> </mapper> \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/OpeTrackMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/OpeTrackMapper.xml index ebb150d..6231a5d 100644 --- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/OpeTrackMapper.xml +++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/OpeTrackMapper.xml @@ -108,4 +108,15 @@ (#{item.id}, #{item.inspectId}, #{item.lng}, #{item.lat}, #{item.locateTime}) </foreach> </insert> + <!--鏍规嵁宸℃id鏌ヨ杞ㄨ抗--> +<!-- <select id="selectByInspectId" resultMap="BaseResultMap">--> + <select id="selectByInspectId" resultType="com.dy.pipIrrGlobal.pojoOp.OpeTrack"> + SELECT + id, + inspect_id AS inspectId, + lng, + lat, + locate_time AS locateTime + FROM ope_track WHERE inspect_id = #{inspectId} + </select> </mapper> \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeGeneralMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeGeneralMapper.xml index d42ffae..e3d5365 100644 --- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeGeneralMapper.xml +++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeGeneralMapper.xml @@ -157,7 +157,7 @@ 1 AS auditStatus FROM se_card_operate ope INNER JOIN ba_user us ON ope.operator = us.id - WHERE Date(ope.operate_dt) = #{operateDate} + WHERE Date(ope.operate_dt) = #{operateDate} AND ope.operate_valid = 2 GROUP BY ope.operator, Date(ope.operate_dt) UNION ALL diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/Server.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/Server.java index 72902e7..129aa1f 100644 --- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/Server.java +++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/Server.java @@ -336,11 +336,11 @@ //RTU杩滅▼鍗囩骇妯″潡 UpgradeUnitConfigVo ugVo = new UpgradeUnitConfigVo(); ugVo.enable = conf.getSetAttrBoolean(doc, "config.upgrade", "enable", null, null) ; - ugVo.noOneRtuUpgradeMaxDuration = conf.getSetAttrPlusInt(doc, "config.upgrade", "noOneRtuUpgradeMaxDuration", null, 5, 3600, null); + ugVo.noOneRtuUpgradeMaxDuration = conf.getSetAttrPlusInt(doc, "config.upgrade", "noOneRtuUpgradeMaxDuration", null, 5, 360000, null); ugVo.noOneRtuUpgradeMaxDuration = ugVo.noOneRtuUpgradeMaxDuration * 1000 ;//鍙樻垚姣 ugVo.failTryTimes = conf.getSetAttrPlusInt(doc, "config.upgrade", "failTryTimes", null, 0, 100, null); ugVo.ugMaxRtuAtOnce = conf.getSetAttrPlusInt(doc, "config.upgrade", "ugMaxRtuAtOnce", null, 0, 1000000, null); - ugVo.rtuOffLineWaitDuration = conf.getSetAttrPlusInt(doc, "config.upgrade", "rtuOffLineWaitDuration", null, 1, 36000, null); + ugVo.rtuOffLineWaitDuration = conf.getSetAttrPlusInt(doc, "config.upgrade", "rtuOffLineWaitDuration", null, 1, 3600000, null); ugVo.rtuOffLineWaitDuration = ugVo.rtuOffLineWaitDuration * 1000;//鍙樻垚姣 ugVo.notifyStateInterval = conf.getSetAttrPlusInt(doc, "config.upgrade", "notifyStateInterval", null, 1, 300, null); ugVo.notifyStateInterval = ugVo.notifyStateInterval * 1000;//鍙樻垚姣 @@ -370,8 +370,7 @@ // /////////////// // 鏍稿績 CoreUnitConfigVo coreConfVo = new CoreUnitConfigVo(); - coreConfVo.sleepBigBusy = conf.getSetAttrPlusInt(doc, "config.core", "sleepBigBusy", null, 1, 200, null).longValue() ; - coreConfVo.sleepSmallBusy = conf.getSetAttrPlusInt(doc, "config.core", "sleepSmallBusy", null, 2, 1000, null).longValue(); + coreConfVo.coreInterval = conf.getSetAttrPlusInt(doc, "config.core", "coreInterval", null, 1, 200, null).longValue() ; coreConfVo.queueWarnSize = ServerProperties.cacheUpDownDataWarnCount ; coreConfVo.queueMaxSize = ServerProperties.cacheUpDownDataMaxCount ; coreConfVo.showStartInfo = showStartInfo ; diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/upgrade/UpgradeManager.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/upgrade/UpgradeManager.java index af7d7fa..678d2f2 100644 --- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/upgrade/UpgradeManager.java +++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/upgrade/UpgradeManager.java @@ -64,6 +64,11 @@ this.task = new UpgradeTask(); this.task.initOption(this.failTryTimes, this.ugMaxRtuSameTime); this.task.setTask(vo); + log.error("==================================================") ; + log.error("= =") ; + log.error("=褰撳墠璁剧疆浜嗗崌绾т换鍔★紝鍏朵腑RTU鏈�" + vo.rtuAddrList.size() + "涓� =") ; + log.error("= =") ; + log.error("==================================================") ; }catch (Exception e){ ex = e ; }finally { @@ -182,22 +187,51 @@ //鍗囩骇浠诲姟鏈畬鎴� //宸ヤ綔1锛氬垽鏂槸鍚︽棤浠讳綍涓�涓猂TU杩涜杩囧崌绾э紝骞朵笖杈惧埌鏃堕檺锛屽垯璁や负褰撳墠鍗囩骇浠诲姟瀹屾垚 //-1:鏃犱竴RTU鍗囩骇涓旇秴鏃讹紝0锛氭棤RTU鍗囩骇浣嗘湭瓒呮椂绛夊緟锛�1鏈塕TU鍗囩骇姝e父鎵ц + //int temp = 1 ; int temp = this.task.countNoOneRtuUpgradeInDuration() ; if(temp == -1){ + //褰撳墠娌℃湁RTU杩涜杩囧崌绾э紝鑰屼笖瓒呮椂浜嗭紝璁や负浠诲姟宸茬粡瀹屾垚 + log.error("==================================================") ; + log.error("= =") ; + log.error("=褰撳墠娌℃湁RTU杩涜杩囧崌绾э紝鑰屼笖瓒呮椂浜嗭紝璁や负浠诲姟宸茬粡瀹屾垚 =") ; + log.error("= =") ; + log.error("==================================================") ; this.task.taskIsOver = true ; - //浠诲姟宸茬粡瀹屾垚 this.stop(); }else if(temp == 1){ + //褰撳墠鏈塕TU杩涜杩囧崌绾� //宸ヤ綔2锛氱粺璁″綋鍓嶆鍦ㄥ崌绾х殑RTU鏁伴噺锛屼负鍚屾椂鍗囩骇鏁伴噺闄愬埗鍋氬噯澶� this.task.countRunningRtuCount() ; - //宸ヤ綔3锛氱粺璁¢渶瑕佸崌绾т絾褰撳墠绂荤嚎RTU鐨勬儏鍐碉紝瓒呰繃鏃堕檺鐨勮澶囦负鍗囩骇瀹屾垚 - this.task.countOffRtuAndSetIfOver() ; - + //宸ヤ綔3锛氱粺璁¢渶瑕佸崌绾т絾褰撳墠绂荤嚎RTU鐨勬儏鍐碉紝瓒呰繃鏃堕檺鐨勮缃负鍗囩骇瀹屾垚 + int tmp = this.task.countOffRtuAndSetIfOver() ; + if(tmp >= 1){ + //瓒呮椂锛屽己鍒惰缃竴浜汻TU鍗囩骇澶辫触骞朵笖鍗囩骇瀹屾垚锛� + log.error("==================================================") ; + log.error("= =") ; + log.error("=瓒呮椂锛屽己鍒惰缃�" + tmp + "涓猂TU鍗囩骇澶辫触骞朵笖鍗囩骇瀹屾垚 =") ; + log.error("= =") ; + log.error("==================================================") ; + }else if(tmp == 0){ + log.error("==================================================") ; + log.error("= =") ; + log.error("=瓒呮椂锛屽己鍒惰缃�0涓猂TU鍗囩骇澶辫触骞朵笖鍗囩骇瀹屾垚 =") ; + log.error("= =") ; + log.error("==================================================") ; + }else{//tmp = -1 + //鏃犱换鍔¢�昏緫 + } //宸ヤ綔4锛氱粺璁℃槸鍚﹀叏閮ㄥ崌绾у畬鎴� this.task.taskIsOver = this.task.countIsAllOver() ; + if(this.task.taskIsOver){ + log.error("==================================================") ; + log.error("= =") ; + log.error("=鍗囩骇鍏ㄩ儴缁撴潫锛岃缃崌绾т换鍔″畬鎴� =") ; + log.error("= =") ; + log.error("==================================================") ; + } }else if(temp == 0){ - //涓嶄綔涓� + //褰撳墠娌℃湁涓�涓猂TU杩涜杩囧崌绾э紝涔熸病鏈夎秴鏃讹紝涓嶄綔涓� } if(this.task.taskIsOver){ if(!this.task.taskOverType.equals(UpgradeTask.TaskOverType_Force)){ diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/upgrade/UpgradeTask.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/upgrade/UpgradeTask.java index 9c606ec..b19ea75 100644 --- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/upgrade/UpgradeTask.java +++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/upgrade/UpgradeTask.java @@ -13,6 +13,7 @@ import java.util.*; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.atomic.AtomicBoolean; /** * @Author: liurunyu @@ -136,8 +137,7 @@ //rtu涓嶅湪鍗囩骇涔嬪垪 return ; } - } - if(ugRtu != null){ + }else{ if(ugRtu.isOver){ //褰撳墠RTU宸茬粡鍗囩骇瀹屾垚锛屾棤闇�鍐嶅崌绾� return; @@ -173,9 +173,6 @@ ugRtu.trigger(code, protocolName, protocolVersion, this.softFileDataGrp, callbackCom) ; } } - }else{ - //rtu涓嶅湪鍗囩骇涔嬪垪 - return ; } } } @@ -202,19 +199,21 @@ if(this.taskVo.rtuAddrList != null && this.taskVo.rtuAddrList.size() > 0){ state.rtuTotal = this.taskVo.rtuAddrList.size() ; if(this.upgradeRtus != null && this.upgradeRtus.size() > 0){ - this.upgradeRtus.values().stream().forEach(info ->{ + AtomicBoolean hasRunning = new AtomicBoolean(false); + this.upgradeRtus.values().forEach(info ->{ if(info.state == UpgradeRtu.STATE_OFFLINE){ - state.offLineTotal ++ ; + state.offLineTotal++ ; }else if(info.state == UpgradeRtu.STATE_UNSTART){ state.unStartTotal ++ ; }else if(info.state == UpgradeRtu.STATE_RUNNING){ state.runningTotal ++ ; }else if(info.state == UpgradeRtu.STATE_SUCCESS) { state.successTotal++; - }else if(info.state == UpgradeRtu.STATE_FAIL) { - state.failTotal++; }else if(info.state == UpgradeRtu.STATE_FAILONE) { state.failOneTotal++; + state.failTotal++; + }else if(info.state == UpgradeRtu.STATE_FAIL) { + state.failMultiTotal++; state.failTotal++; }else if(info.state == UpgradeRtu.STATE_FAILOFFLINE) { state.failTotal++; @@ -222,8 +221,15 @@ } if(info.isOver){ state.overTotal++; + }else{ + hasRunning.set(true); } }); + if(!hasRunning.get()){ + state.allOver = true ; + }else{ + state.allOver = false ; + } } } return state ; @@ -266,7 +272,9 @@ } /////////////////////////////////////////////////////////// - //浠ヤ笅鏂规硶涓哄唴閮ㄦ湇鍔★紝涓嶅澶栨彁渚涙湇鍔� + // + // 浠ヤ笅鏂规硶涓哄唴閮ㄦ湇鍔★紝涓嶅澶栨彁渚涙湇鍔� + // /////////////////////////////////////////////////////////// /** @@ -312,20 +320,26 @@ /** * 缁熻闇�瑕佸崌绾т絾褰撳墠绂荤嚎RTU鐨勬儏鍐碉紝瓒呰繃鏃堕檺鐨勮澶囦负鍗囩骇瀹屾垚 + * @return -1:娌℃湁瓒呮椂锛�0瓒呮椂浜嗕笖鏃犲洜绂荤嚎琚己鍒惰缃崌绾у畬鎴愮殑RTU锛�>0绂荤嚎琚己鍒惰缃崌绾у畬鎴愮殑RTU鏁伴噺 */ - protected void countOffRtuAndSetIfOver() { + protected int countOffRtuAndSetIfOver() { Long now = System.currentTimeMillis() ; if(now - this.setupDtLong > UpgradeUnit.confVo.rtuOffLineWaitDuration){ //rtu绂荤嚎锛岀瓑寰呭叾鍗囩骇鐨勬椂闀�(姣)锛岃秴杩囬厤缃殑鏈�澶ф椂闀匡紝璁剧疆鍏跺崌绾уけ璐ワ紝涓旇缃崌绾т换鍔″畬鎴� + int count = 0 ; if (this.taskVo.rtuAddrList != null && this.taskVo.rtuAddrList.size() > 0) { Collection<UpgradeRtu> col = this.upgradeRtus.values() ; for(UpgradeRtu info : col){ if(info.state == UpgradeRtu.STATE_OFFLINE){ info.isOver = true ; info.state = UpgradeRtu.STATE_FAILOFFLINE ; + count ++ ; } } } + return count ; + }else{ + return -1 ; } } diff --git "a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/config\050sp\346\262\231\347\233\230\051.xml" "b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/config\050sp\346\262\231\347\233\230\051.xml" index a84ad5e..27724cf 100644 --- "a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/config\050sp\346\262\231\347\233\230\051.xml" +++ "b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/config\050sp\346\262\231\347\233\230\051.xml" @@ -124,14 +124,12 @@ /> <!-- - sleepBigBusy锛氫富绾跨▼澶у繖鏃舵瘡娆℃墽琛岄棿闅旀椂闀匡紙姣锛� - sleepSmallBusy锛氫富绾跨▼灏忓繖鏃舵瘡娆℃墽琛岄棿闅旀椂闀匡紙姣锛� + coreInterval锛氫富绾跨▼姣忔鎵ц闂撮殧鏃堕暱锛堟绉掞級 queueWarnSize: 缂撳瓨闃熷垪鑺傜偣鏁拌鍛婃暟閲� queueMaxSize: 缂撳瓨闃熷垪鑺傜偣鏁版渶澶ф暟閲� --> <core - sleepBigBusy="100" - sleepSmallBusy="500" + coreInterval="100" queueWarnSize="100000" queueMaxSize="300000" /> diff --git "a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/config\050test\346\265\213\350\257\225\051.xml" "b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/config\050test\346\265\213\350\257\225\051.xml" index a9648f9..2ba0296 100644 --- "a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/config\050test\346\265\213\350\257\225\051.xml" +++ "b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/config\050test\346\265\213\350\257\225\051.xml" @@ -124,14 +124,12 @@ /> <!-- - sleepBigBusy锛氫富绾跨▼澶у繖鏃舵瘡娆℃墽琛岄棿闅旀椂闀匡紙姣锛� - sleepSmallBusy锛氫富绾跨▼灏忓繖鏃舵瘡娆℃墽琛岄棿闅旀椂闀匡紙姣锛� + coreInterval锛氫富绾跨▼姣忔鎵ц闂撮殧鏃堕暱锛堟绉掞級 queueWarnSize: 缂撳瓨闃熷垪鑺傜偣鏁拌鍛婃暟閲� queueMaxSize: 缂撳瓨闃熷垪鑺傜偣鏁版渶澶ф暟閲� --> <core - sleepBigBusy="100" - sleepSmallBusy="500" + coreInterval="100" queueWarnSize="100000" queueMaxSize="300000" /> diff --git "a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/config\050ym\345\205\203\350\260\213\051.xml" "b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/config\050ym\345\205\203\350\260\213\051.xml" index 3a54042..eabdf5c 100644 --- "a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/config\050ym\345\205\203\350\260\213\051.xml" +++ "b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/config\050ym\345\205\203\350\260\213\051.xml" @@ -124,14 +124,12 @@ /> <!-- - sleepBigBusy锛氫富绾跨▼澶у繖鏃舵瘡娆℃墽琛岄棿闅旀椂闀匡紙姣锛� - sleepSmallBusy锛氫富绾跨▼灏忓繖鏃舵瘡娆℃墽琛岄棿闅旀椂闀匡紙姣锛� + coreInterval锛氫富绾跨▼姣忔鎵ц闂撮殧鏃堕暱锛堟绉掞級 queueWarnSize: 缂撳瓨闃熷垪鑺傜偣鏁拌鍛婃暟閲� queueMaxSize: 缂撳瓨闃熷垪鑺傜偣鏁版渶澶ф暟閲� --> <core - sleepBigBusy="100" - sleepSmallBusy="500" + coreInterval="100" queueWarnSize="100000" queueMaxSize="300000" /> diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/config.xml b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/config.xml index 3a54042..114cafe 100644 --- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/config.xml +++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/resources/config.xml @@ -63,10 +63,10 @@ notifyStateInterval: 鍗囩骇鐘舵�侀�氱煡闂撮殧锛堢锛� --> <upgrade enable="true" - noOneRtuUpgradeMaxDuration="600" + noOneRtuUpgradeMaxDuration="1200" failTryTimes="1" ugMaxRtuAtOnce="1000" - rtuOffLineWaitDuration="1200" + rtuOffLineWaitDuration="1800" notifyStateInterval="2" /> @@ -124,14 +124,12 @@ /> <!-- - sleepBigBusy锛氫富绾跨▼澶у繖鏃舵瘡娆℃墽琛岄棿闅旀椂闀匡紙姣锛� - sleepSmallBusy锛氫富绾跨▼灏忓繖鏃舵瘡娆℃墽琛岄棿闅旀椂闀匡紙姣锛� + coreInterval锛氫富绾跨▼姣忔鎵ц闂撮殧鏃堕暱锛堟绉掞級 queueWarnSize: 缂撳瓨闃熷垪鑺傜偣鏁拌鍛婃暟閲� queueMaxSize: 缂撳瓨闃熷垪鑺傜偣鏁版渶澶ф暟閲� --> <core - sleepBigBusy="100" - sleepSmallBusy="500" + coreInterval="100" queueWarnSize="100000" queueMaxSize="300000" /> diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/PipIrrMwSimulateRtuApplication.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/PipIrrMwSimulateRtuApplication.java index 9f79fa7..720cfa1 100644 --- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/PipIrrMwSimulateRtuApplication.java +++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/PipIrrMwSimulateRtuApplication.java @@ -34,6 +34,27 @@ public class PipIrrMwSimulateRtuApplication implements CommandLineRunner { public static void main(String[] args) { + if(args != null && args.length > 0){ + if(args.length == 3){ + if(args[0] instanceof String){ + if(args[0] != null && !args[0].trim().equals("")){ + String rtuAddr = (String)args[0] ;//鏈ā鎷熷櫒妯℃嫙RTU鍦板潃 + ServerProperties.argRtuAddr = rtuAddr ; + } + if(args[1] != null && !args[1].trim().equals("")){ + Integer oneDie = Integer.parseInt(args[1]) ;//涓�鍖呮锛�1鏄紝0鍚� + ServerProperties.argOneDie = oneDie == 1?true:false ; + } + if(args[2] != null && !args[2].trim().equals("")){ + Integer multiDie = Integer.parseInt(args[2]) ;//澶氬寘姝伙細1鏄紝0鍚� + ServerProperties.argMultiDie = multiDie == 1?true:false ; + } + if(ServerProperties.argOneDie && ServerProperties.argMultiDie){ + ServerProperties.argOneDie = false ; + } + } + } + } new SpringApplicationBuilder(PipIrrMwSimulateRtuApplication.class) .web(WebApplicationType.NONE)//涓嶅惎鍔╳eb鏈嶅姟 .run(args); diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/Server.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/Server.java index eabf255..b651a13 100644 --- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/Server.java +++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/Server.java @@ -44,6 +44,16 @@ this.startUnits() ; + if(ServerProperties.argRtuAddr != null && !ServerProperties.argRtuAddr.trim().equals("")){ + System.out.println("鍙傛暟RTU鍦板潃锛�" + ServerProperties.argRtuAddr) ; + ServerProperties.rtuAddr = ServerProperties.argRtuAddr ; + }else{ + System.out.println("閰嶇疆RTU鍦板潃锛�" + ServerProperties.rtuAddr) ; + } + + System.out.println("鍚姩涓�鍖呮锛�" + (ServerProperties.argOneDie==null?"鍚�":(ServerProperties.argOneDie?"鏄�":"鍚�"))) ; + System.out.println("鍚姩澶氬寘姝伙細" + (ServerProperties.argMultiDie==null?"鍚�":(ServerProperties.argMultiDie?"鏄�":"鍚�"))) ; + String svName ; try{ svName = this.conf.getSetAttrTxt(this.doc, "config.server", "name", null, false, null) ; diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/ServerProperties.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/ServerProperties.java index 94d5073..e69fead 100644 --- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/ServerProperties.java +++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/ServerProperties.java @@ -9,4 +9,10 @@ public class ServerProperties { public static String rtuAddr ; + + //绋嬪簭鍚姩鍙傛暟锛� + public static String argRtuAddr ; + public static Boolean argOneDie = false ; + public static Boolean argMultiDie = false ; + } diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/tcpClient/TcpHandler.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/tcpClient/TcpHandler.java index 449fb41..76c4199 100644 --- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/tcpClient/TcpHandler.java +++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/tcpClient/TcpHandler.java @@ -67,11 +67,11 @@ */ @Override public void messageSent(IoSession session, Object message) throws Exception { - log.info("缃戠粶鍙戦�佷簡鏁版嵁锛�" - + (session==null?"":(session.getRemoteAddress() != null?("涓棿浠剁綉鍧�鏄細" + session.getRemoteAddress().toString()):"")) ); if(message != null){ byte[] bs = (byte[])message ; - log.info("缃戠粶鍙戦�佷簡鏁版嵁锛�" + ByteUtil.bytes2Hex(bs, true)); + log.info("\n缃戠粶鍙戦�佷簡鏁版嵁锛�" + + (session==null?"":(session.getRemoteAddress() != null?("涓棿浠剁綉鍧�鏄細" + session.getRemoteAddress().toString()):"")) + + ("\n鏁版嵁锛�" + ByteUtil.bytes2Hex(bs, true))); } } diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/tcpClient/downData/DownData.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/tcpClient/downData/DownData.java index 6211d7b..30b2555 100644 --- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/tcpClient/downData/DownData.java +++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/tcpClient/downData/DownData.java @@ -2,6 +2,8 @@ import com.dy.common.mw.protocol.p206V1.ProtocolConstantV206V1; import com.dy.common.util.ByteUtil; +import com.dy.common.util.CreateRandom; +import com.dy.simRtu.ServerProperties; import com.dy.simRtu.tcpClient.upData.*; /** @@ -10,6 +12,8 @@ * @Description 涓棿浠剁殑涓嬭鏁版嵁 */ public class DownData { + + private static int count9602 = 0; public void parseData(byte[] bs){ if(bs != null && bs.length > 0){ @@ -32,16 +36,34 @@ String cdPre = ByteUtil.bytes2Hex(bs, false, ProtocolConstantV206V1.UG_codeIndex, 1); if(cdPre.equals("16")){ //鍗囩骇鍔熻兘鐮� - UpHeartBeat.upHeartBeat = false ;//涓嶄笂琛屽績璺� + UpHeartBeat.upHeartBeat = false ;//绂佹涓婅蹇冭烦 if(bs.length >= ProtocolConstantV206V1.UG_lenHead2Cmd + 1){ String cdSuf = ByteUtil.bytes2Hex(bs, false, ProtocolConstantV206V1.UG_codeIndex + 1, 1); String cd = cdPre + cdSuf; if(cd.equals("1601")){ //鍗囩骇閰嶇疆 - UpCd9601.upData() ; + if(ServerProperties.argOneDie){ + UpHeartBeat.upHeartBeat = true ;//浣胯兘涓婅蹇冭烦 + }else{ + UpCd9601.upData() ; + } }else if(cd.equals("1602")){ //鍗囩骇鏁版嵁 - UpCd9602.upData() ; + count9602 ++ ; + if(ServerProperties.argMultiDie){ + if(count9602 > 10){ + int random = CreateRandom.create_between(10, 100) ; + if(random > 50){ + UpHeartBeat.upHeartBeat = true ;//浣胯兘涓婅蹇冭烦 + }else{ + UpCd9602.upData() ; + } + }else{ + UpCd9602.upData() ; + } + }else{ + UpCd9602.upData() ; + } }else if(cd.equals("1603")){ //鍗囩骇鏍¢獙 UpCd9603.upData() ; diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/resources/config.xml b/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/resources/config.xml index fa87df5..1996da7 100644 --- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/resources/config.xml +++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/resources/config.xml @@ -10,5 +10,5 @@ --> <base rtuAddr="532328000214"></base> <!-- --> - <tcpCl mwServerIp="192.168.40.132" mwServerPort="60000" connectTimeout="3000" /> + <tcpCl mwServerIp="192.168.40.166" mwServerPort="60000" connectTimeout="3000" /> </config> \ No newline at end of file diff --git "a/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/\350\257\264\346\230\216.txt" "b/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/\350\257\264\346\230\216.txt" new file mode 100644 index 0000000..eff934f --- /dev/null +++ "b/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/\350\257\264\346\230\216.txt" @@ -0,0 +1 @@ +鏈ā鍧楁槸RTU妯℃嫙鍣紝妯℃嫙RTU鍗囩骇杩囩▼ \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/java/com/dy/pipIrrApp/captcha/CaptchaCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/java/com/dy/pipIrrApp/captcha/CaptchaCtrl.java index a2449e2..e11e3f3 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/java/com/dy/pipIrrApp/captcha/CaptchaCtrl.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/java/com/dy/pipIrrApp/captcha/CaptchaCtrl.java @@ -74,7 +74,7 @@ baCaptcha.setCode(captchaDomain.getCode()); baCaptcha.setExpiration(calendar.getTimeInMillis()); Long rec = captchaSV.addCaptcha(baCaptcha); - System.out.println("token: " + captchaDomain.getToken() + "; code: " + captchaDomain.getCode()); + //System.out.println("token: " + captchaDomain.getToken() + "; code: " + captchaDomain.getCode()); // 鏃犵敤淇℃伅璁剧┖ captchaDomain.setText(null); @@ -118,7 +118,7 @@ baCaptcha.setCode(captchaDomain.getCode()); baCaptcha.setExpiration(calendar.getTimeInMillis()); Long rec = captchaSV.addCaptcha(baCaptcha); - System.out.println("token: " + captchaDomain.getToken() + "; code: " + captchaDomain.getCode()); + //System.out.println("token: " + captchaDomain.getToken() + "; code: " + captchaDomain.getCode()); // 浠ユ枃浠舵祦鐨勫舰寮忥紝杈撳嚭楠岃瘉鐮佸浘鐗� ServletOutputStream out = null; diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/java/com/dy/pipIrrApp/inspect/InspectCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/java/com/dy/pipIrrApp/inspect/InspectCtrl.java index 26446d4..f18bb02 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/java/com/dy/pipIrrApp/inspect/InspectCtrl.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/java/com/dy/pipIrrApp/inspect/InspectCtrl.java @@ -4,19 +4,20 @@ import com.dy.common.util.IDLongGenerator; import com.dy.common.webUtil.BaseResponse; import com.dy.common.webUtil.BaseResponseUtils; +import com.dy.common.webUtil.QueryResultVo; import com.dy.pipIrrApp.inspect.dto.Inspects; +import com.dy.pipIrrApp.inspect.qo.QoInspect; import com.dy.pipIrrGlobal.pojoOp.OpeInspect; import com.dy.pipIrrGlobal.pojoOp.OpeTrack; +import com.dy.pipIrrGlobal.voOp.VoInspect; +import com.dy.pipIrrGlobal.voOp.VoIssueReport; import jakarta.validation.Valid; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.BindingResult; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.Date; import java.util.List; @@ -121,4 +122,21 @@ return BaseResponseUtils.buildErrorMsg("鎮ㄦ彁浜ょ殑宸℃杞ㄨ抗涓虹┖"); } + /** + * 鏌ヨ宸℃杞ㄨ抗 + * @param qo + * @return + */ + @GetMapping(path = "/getInspects") + @SsoAop() + public BaseResponse<QueryResultVo<List<VoInspect>>> getInspects(QoInspect qo){ + + try{ + QueryResultVo<List<VoInspect>> res = inspectSv.getInspects(qo); + return BaseResponseUtils.buildSuccess(res); + }catch (Exception e){ + log.error("鑾峰彇宸℃鍒楄〃寮傚父", e); + return BaseResponseUtils.buildException(e.getMessage()); + } + } } diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/java/com/dy/pipIrrApp/inspect/InspectSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/java/com/dy/pipIrrApp/inspect/InspectSv.java index 6d04f09..00a4d0d 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/java/com/dy/pipIrrApp/inspect/InspectSv.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/java/com/dy/pipIrrApp/inspect/InspectSv.java @@ -1,14 +1,20 @@ package com.dy.pipIrrApp.inspect; +import com.dy.common.webUtil.QueryResultVo; +import com.dy.pipIrrApp.inspect.qo.QoInspect; import com.dy.pipIrrGlobal.daoOp.OpeInspectMapper; import com.dy.pipIrrGlobal.daoOp.OpeTrackMapper; import com.dy.pipIrrGlobal.pojoOp.OpeInspect; import com.dy.pipIrrGlobal.pojoOp.OpeTrack; +import com.dy.pipIrrGlobal.voOp.VoInspect; +import com.dy.pipIrrGlobal.voOp.VoIssueReport; import lombok.extern.slf4j.Slf4j; +import org.apache.dubbo.common.utils.PojoUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; +import java.util.Map; /** * @author ZhuBaoMin @@ -28,6 +34,7 @@ /** * 娣诲姞宸℃璁板綍 + * * @param po * @return */ @@ -38,6 +45,7 @@ /** * 淇敼宸℃璁板綍 + * * @param po * @return */ @@ -47,6 +55,7 @@ /** * 鎵归噺娣诲姞宸℃杞ㄨ抗 + * * @param list * @return */ @@ -54,5 +63,41 @@ return opeTrackMapper.insertTracks(list); } + /** + * 宸℃鏌ヨ + * + * @param queryVo + * @return + */ + public QueryResultVo<List<VoInspect>> getInspects(QoInspect queryVo) { + //瀹屽杽鏌ヨ鍏呭�艰褰曠殑璧锋鏃堕棿 + String timeStart = queryVo.getTimeStart(); + String timeStop = queryVo.getTimeStop(); + if (timeStart != null) { + timeStart = timeStart + " 00:00:00"; + queryVo.setTimeStart(timeStart); + } + if (timeStop != null) { + timeStop = timeStop + " 23:59:59"; + queryVo.setTimeStop(timeStop); + } + Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); + + Long itemTotal = opeInspectMapper.getInspectsCount(params); + QueryResultVo<List<VoInspect>> rsVo = new QueryResultVo<>(); + + rsVo.pageSize = queryVo.pageSize; + rsVo.pageCurr = queryVo.pageCurr; + + rsVo.calculateAndSet(itemTotal, params); + + List<VoInspect> inspects = opeInspectMapper.getInspects(params); + for (int i = 0; i < inspects.size(); i++) { + List<OpeTrack> tracks = opeTrackMapper.selectByInspectId(inspects.get(i).getInspectId()); + inspects.get(i).setTracks(tracks); + } + rsVo.obj = inspects; + return rsVo; + } } diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/java/com/dy/pipIrrApp/inspect/qo/QoInspect.java b/pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/java/com/dy/pipIrrApp/inspect/qo/QoInspect.java new file mode 100644 index 0000000..294c259 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/java/com/dy/pipIrrApp/inspect/qo/QoInspect.java @@ -0,0 +1,41 @@ +package com.dy.pipIrrApp.inspect.qo; + +import com.dy.common.webUtil.QueryConditionVo; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.Data; + +/** + * @author :WuZeYu + * @Date :2024/11/20 15:19 + * @LastEditTime :2024/11/20 15:19 + * @Description + */ +@Data +public class QoInspect extends QueryConditionVo { + /** + * 宸℃ID + */ + @JsonSerialize(using = ToStringSerializer.class) + private Long inspectId; + /** + * 宸℃鍛業D + */ + @JsonSerialize(using = ToStringSerializer.class) + private Long inspectorId; + + /** + * 宸℃鍛樺鍚� + */ + private String inspectorName; + + /** + * 銆佸紑濮嬪贰妫�鐨勬椂闂达紝寮�濮嬭寖鍥� + */ + private String timeStart; + + /** + * 銆佸紑濮嬪贰妫�鐨勬椂闂达紝缁撴潫鑼冨洿 + */ + private String timeStop; +} diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/program/UgRtuProgramCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/program/UgRtuProgramCtrl.java index 21098a9..9cadf12 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/program/UgRtuProgramCtrl.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/program/UgRtuProgramCtrl.java @@ -75,7 +75,7 @@ } return BaseResponseUtils.buildSuccess(po); }else{ - return BaseResponseUtils.buildException("鏈煡璇㈠埌瀵瑰簲鐨勮褰�") ; + return BaseResponseUtils.buildErrorMsg("鏈煡璇㈠埌瀵瑰簲鐨勮褰�") ; } } /** @@ -99,7 +99,7 @@ return BaseResponseUtils.buildSuccess(res); } catch (Exception e) { log.error("鏌ヨRTU鍗囩骇绋嬪簭寮傚父", e); - return BaseResponseUtils.buildException(e.getMessage()) ; + return BaseResponseUtils.buildErrorMsg(e.getMessage()) ; } } @@ -124,7 +124,7 @@ return BaseResponseUtils.buildSuccess(res); } catch (Exception e) { log.error("鏌ヨRTU鍗囩骇绋嬪簭寮傚父", e); - return BaseResponseUtils.buildException(e.getMessage()) ; + return BaseResponseUtils.buildErrorMsg(e.getMessage()) ; } } @@ -146,26 +146,26 @@ @SsoAop() public BaseResponse<Boolean> save(@Parameter(description = "form琛ㄥ崟鏁版嵁", required = true) @Valid VoRtuProgram vo, @Parameter(hidden = true) BindingResult bindingResult){ if(bindingResult != null && bindingResult.hasErrors()){ - return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } if(vo.storeRamAddr == null || vo.storeRamAddr.trim().equals("") || vo.storeRamAddr.length() != 8 || !HexUtil.isHexNumber(vo.storeRamAddr)){ - return BaseResponseUtils.buildFail("鍗囩骇绋嬪簭瀛樻斁鍦板潃(4瀛楄妭锛�8浣嶅崄鍏繘鍒舵暟)涓嶆纭�") ; + return BaseResponseUtils.buildErrorMsg("鍗囩骇绋嬪簭瀛樻斁鍦板潃(4瀛楄妭锛�8浣嶅崄鍏繘鍒舵暟)涓嶆纭�") ; } if(vo.startRamAddr == null || vo.startRamAddr.trim().equals("") || vo.startRamAddr.length() != 8 || !HexUtil.isHexNumber(vo.startRamAddr)){ - return BaseResponseUtils.buildFail("绋嬪簭瑕嗙洊璧峰鍦板潃(4瀛楄妭锛�8浣嶅崄鍏繘鍒舵暟)涓嶆纭�") ; + return BaseResponseUtils.buildErrorMsg("绋嬪簭瑕嗙洊璧峰鍦板潃(4瀛楄妭锛�8浣嶅崄鍏繘鍒舵暟)涓嶆纭�") ; } if(vo.file == null){ - return BaseResponseUtils.buildFail("RTU绋嬪簭鏂囦欢蹇呴』涓婁紶") ; + return BaseResponseUtils.buildErrorMsg("RTU绋嬪簭鏂囦欢蹇呴』涓婁紶") ; } String fileName = vo.file.getOriginalFilename() ; if(this.sv.existFileName(fileName)){ - return BaseResponseUtils.buildFail("RTU绋嬪簭鏂囦欢鍚嶅凡瀛樺湪") ; + return BaseResponseUtils.buildErrorMsg("RTU绋嬪簭鏂囦欢鍚嶅凡瀛樺湪") ; } HexFileVo fileVo = null ; @@ -178,7 +178,7 @@ } }catch (Exception e){ fileVo = null ; - return BaseResponseUtils.buildFail("瑙f瀽RTU绋嬪簭鏂囦欢寮傚父锛�" + e.getMessage()) ; + return BaseResponseUtils.buildErrorMsg("瑙f瀽RTU绋嬪簭鏂囦欢寮傚父锛�" + e.getMessage()) ; } if(fileVo != null){ UgRtuProgram po = new UgRtuProgram(); @@ -197,15 +197,15 @@ count = this.sv.save(po); } catch (Exception e) { log.error("淇濆瓨RTU鍗囩骇绋嬪簭寮傚父", e); - return BaseResponseUtils.buildException(e.getMessage()) ; + return BaseResponseUtils.buildErrorMsg(e.getMessage()) ; } if(count <= 0){ - return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�") ; + return BaseResponseUtils.buildErrorMsg("鏁版嵁搴撳瓨鍌ㄥけ璐�") ; }else{ return BaseResponseUtils.buildSuccess(true) ; } }else{ - return BaseResponseUtils.buildFail("瑙f瀽RTU绋嬪簭鏂囦欢寮傚父") ; + return BaseResponseUtils.buildErrorMsg("瑙f瀽RTU绋嬪簭鏂囦欢寮傚父") ; } } /** @@ -245,17 +245,17 @@ @SsoAop() public BaseResponse<Boolean> delete(Long id){ if(id == null){ - return BaseResponseUtils.buildFail("id涓嶈兘涓虹┖") ; + return BaseResponseUtils.buildErrorMsg("id涓嶈兘涓虹┖") ; } int count; try { count = this.sv.delete(id); } catch (Exception e) { log.error("鍒犻櫎RTU鍗囩骇绋嬪簭寮傚父", e); - return BaseResponseUtils.buildException(e.getMessage()) ; + return BaseResponseUtils.buildErrorMsg(e.getMessage()) ; } if(count <= 0){ - return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�") ; + return BaseResponseUtils.buildErrorMsg("鏁版嵁搴撳瓨鍌ㄥけ璐�") ; }else{ return BaseResponseUtils.buildSuccess(true) ; } diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/task/UgRtuAddControllerCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/task/UgRtuAddControllerCtrl.java index 1c3a5cf..be016ea 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/task/UgRtuAddControllerCtrl.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/task/UgRtuAddControllerCtrl.java @@ -65,7 +65,7 @@ return BaseResponseUtils.buildSuccess(res); } catch (Exception e) { log.error("鏌ヨRTU鍗囩骇浠诲姟寮傚父", e); - return BaseResponseUtils.buildException(e.getMessage()) ; + return BaseResponseUtils.buildErrorMsg(e.getMessage()) ; } } @@ -129,7 +129,7 @@ return BaseResponseUtils.buildSuccess(res); } catch (Exception e) { log.error("鏌ヨRTU鍗囩骇浠诲姟寮傚父", e); - return BaseResponseUtils.buildException(e.getMessage()) ; + return BaseResponseUtils.buildErrorMsg(e.getMessage()) ; } } @@ -165,14 +165,14 @@ ugRtuController.setRtuAddr(rtuAddr) ; int count = this.addedSv.save(ugRtuController); if(count <= 0){ - return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�") ; + return BaseResponseUtils.buildErrorMsg("鏁版嵁搴撳瓨鍌ㄥけ璐�") ; }else{ return BaseResponseUtils.buildSuccess(true) ; } } } catch (Exception e) { log.error("鏌ヨRTU鍗囩骇浠诲姟寮傚父", e); - return BaseResponseUtils.buildException(e.getMessage()) ; + return BaseResponseUtils.buildErrorMsg(e.getMessage()) ; } } } diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/task/UgRtuControllerCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/task/UgRtuControllerCtrl.java index a084132..1b13aef 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/task/UgRtuControllerCtrl.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/task/UgRtuControllerCtrl.java @@ -70,7 +70,7 @@ return BaseResponseUtils.buildSuccess(res); } catch (Exception e) { log.error("鏌ヨRTU鍗囩骇浠诲姟寮傚父", e); - return BaseResponseUtils.buildException(e.getMessage()) ; + return BaseResponseUtils.buildErrorMsg(e.getMessage()) ; } } @@ -92,17 +92,17 @@ @SsoAop() public BaseResponse<Boolean> deleteAll(Long taskId){ if(taskId == null){ - return BaseResponseUtils.buildFail("浠诲姟id涓嶈兘涓虹┖") ; + return BaseResponseUtils.buildErrorMsg("浠诲姟id涓嶈兘涓虹┖") ; } int count; try { count = this.sv.deleteAll(taskId); } catch (Exception e) { log.error("鍒犻櫎鍗囩骇鎵�鏈夊璞℃帶鍒跺櫒寮傚父", e); - return BaseResponseUtils.buildException(e.getMessage()) ; + return BaseResponseUtils.buildErrorMsg(e.getMessage()) ; } if(count <= 0){ - return BaseResponseUtils.buildFail("鏁版嵁搴撴搷浣滃け璐�") ; + return BaseResponseUtils.buildErrorMsg("鏁版嵁搴撴搷浣滃け璐�") ; }else{ return BaseResponseUtils.buildSuccess(true) ; } @@ -127,17 +127,17 @@ @SsoAop() public BaseResponse<Boolean> deleteOne(Long id){ if(id == null){ - return BaseResponseUtils.buildFail("id涓嶈兘涓虹┖") ; + return BaseResponseUtils.buildErrorMsg("id涓嶈兘涓虹┖") ; } int count; try { count = this.sv.deleteOne(id); } catch (Exception e) { log.error("鍒犻櫎鍗囩骇瀵硅薄鎺у埗鍣ㄥ紓甯�", e); - return BaseResponseUtils.buildException(e.getMessage()) ; + return BaseResponseUtils.buildErrorMsg(e.getMessage()) ; } if(count <= 0){ - return BaseResponseUtils.buildFail("鏁版嵁搴撴搷浣滃け璐�") ; + return BaseResponseUtils.buildErrorMsg("鏁版嵁搴撴搷浣滃け璐�") ; }else{ return BaseResponseUtils.buildSuccess(true) ; } diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/task/UgRtuResultCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/task/UgRtuResultCtrl.java index 3a99797..a69188f 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/task/UgRtuResultCtrl.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/task/UgRtuResultCtrl.java @@ -64,7 +64,7 @@ return BaseResponseUtils.buildSuccess(res); } catch (Exception e) { log.error("鏌ヨRTU鍗囩骇浠诲姟寮傚父", e); - return BaseResponseUtils.buildException(e.getMessage()); + return BaseResponseUtils.buildErrorMsg(e.getMessage()); } } } diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/task/UgRtuTaskCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/task/UgRtuTaskCtrl.java index 759e430..3e6cc53 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/task/UgRtuTaskCtrl.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/task/UgRtuTaskCtrl.java @@ -85,7 +85,7 @@ return BaseResponseUtils.buildSuccess(res); } catch (Exception e) { log.error("鏌ヨRTU鍗囩骇浠诲姟寮傚父", e); - return BaseResponseUtils.buildException(e.getMessage()) ; + return BaseResponseUtils.buildErrorMsg(e.getMessage()) ; } } @@ -110,7 +110,7 @@ return BaseResponseUtils.buildSuccess(res); } catch (Exception e) { log.error("鏌ヨRTU鍗囩骇浠诲姟寮傚父", e); - return BaseResponseUtils.buildException(e.getMessage()) ; + return BaseResponseUtils.buildErrorMsg(e.getMessage()) ; } } @@ -132,7 +132,7 @@ @SsoAop() public BaseResponse<Boolean> save(@Parameter(description = "form琛ㄥ崟鏁版嵁", required = true) @Valid VoRtuTask vo, @Parameter(hidden = true) BindingResult bindingResult){ if(bindingResult != null && bindingResult.hasErrors()){ - return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } UgRtuTask po = new UgRtuTask(); vo.toPo(po); @@ -142,10 +142,10 @@ count = this.sv.save(po); } catch (Exception e) { log.error("淇濆瓨RTU鍗囩骇浠诲姟寮傚父", e); - return BaseResponseUtils.buildException(e.getMessage()) ; + return BaseResponseUtils.buildErrorMsg(e.getMessage()) ; } if(count <= 0){ - return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�") ; + return BaseResponseUtils.buildErrorMsg("鏁版嵁搴撳瓨鍌ㄥけ璐�") ; }else{ return BaseResponseUtils.buildSuccess(true) ; } @@ -168,20 +168,20 @@ @SsoAop() public BaseResponse<Boolean> update(@Parameter(description = "form琛ㄥ崟鏁版嵁", required = true) @Valid UgRtuTask po, @Parameter(hidden = true) BindingResult bindingResult){ if(bindingResult != null && bindingResult.hasErrors()){ - return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } if(po.id == null){ - return BaseResponseUtils.buildFail("鏃犳暟鎹疄浣揑D") ; + return BaseResponseUtils.buildErrorMsg("鏃犳暟鎹疄浣揑D") ; } int count; try { count = this.sv.update(po); } catch (Exception e) { log.error("淇濆瓨瀹炰綋鏁版嵁寮傚父", e); - return BaseResponseUtils.buildException(e.getMessage()) ; + return BaseResponseUtils.buildErrorMsg(e.getMessage()) ; } if(count <= 0){ - return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�") ; + return BaseResponseUtils.buildErrorMsg("鏁版嵁搴撳瓨鍌ㄥけ璐�") ; }else{ return BaseResponseUtils.buildSuccess(true) ; } @@ -206,25 +206,25 @@ @SsoAop() public BaseResponse<Boolean> execute(Long id){ if(id == null){ - return BaseResponseUtils.buildFail("id涓嶈兘涓虹┖") ; + return BaseResponseUtils.buildErrorMsg("id涓嶈兘涓虹┖") ; } int count; try { count = this.sv.isOver(id) ; if(count > 0){ - return BaseResponseUtils.buildError("浠诲姟宸茬粡缁撴潫锛屼笉鑳藉啀鎵ц") ; + return BaseResponseUtils.buildErrorMsg("浠诲姟宸茬粡缁撴潫锛屼笉鑳藉啀鎵ц") ; } count = this.sv.isExecute(id) ; if(count > 0){ - return BaseResponseUtils.buildError("浠诲姟宸茬粡鎵ц锛屼笉鑳藉啀鎵ц") ; + return BaseResponseUtils.buildErrorMsg("浠诲姟宸茬粡鎵ц锛屼笉鑳藉啀鎵ц") ; } count = this.sv.execute(id); } catch (Exception e) { log.error("鎵цRTU鍗囩骇浠诲姟寮傚父", e); - return BaseResponseUtils.buildException(e.getMessage()) ; + return BaseResponseUtils.buildErrorMsg(e.getMessage()) ; } if(count <= 0){ - return BaseResponseUtils.buildFail("鏁版嵁搴撴搷浣滃け璐�") ; + return BaseResponseUtils.buildErrorMsg("鏁版嵁搴撴搷浣滃け璐�") ; }else{ return BaseResponseUtils.buildSuccess(true) ; } @@ -248,20 +248,20 @@ @SsoAop() public BaseResponse<Boolean> over(Long id){ if(id == null){ - return BaseResponseUtils.buildFail("id涓嶈兘涓虹┖") ; + return BaseResponseUtils.buildErrorMsg("id涓嶈兘涓虹┖") ; } int count; try {count = this.sv.isOver(id) ; if(count > 0){ - return BaseResponseUtils.buildError("浠诲姟宸茬粡缁撴潫锛屼笉鐢ㄥ啀缁撴潫") ; + return BaseResponseUtils.buildErrorMsg("浠诲姟宸茬粡缁撴潫锛屼笉鐢ㄥ啀缁撴潫") ; } count = this.sv.over(id); } catch (Exception e) { log.error("缁撴潫RTU鍗囩骇浠诲姟寮傚父", e); - return BaseResponseUtils.buildException(e.getMessage()) ; + return BaseResponseUtils.buildErrorMsg(e.getMessage()) ; } if(count <= 0){ - return BaseResponseUtils.buildFail("鏁版嵁搴撴搷浣滃け璐�") ; + return BaseResponseUtils.buildErrorMsg("鏁版嵁搴撴搷浣滃け璐�") ; }else{ return BaseResponseUtils.buildSuccess(true) ; } @@ -285,17 +285,17 @@ @SsoAop() public BaseResponse<Boolean> delete(Long id){ if(id == null){ - return BaseResponseUtils.buildFail("id涓嶈兘涓虹┖") ; + return BaseResponseUtils.buildErrorMsg("id涓嶈兘涓虹┖") ; } int count; try { count = this.sv.delete(id); } catch (Exception e) { log.error("鍒犻櫎RTU鍗囩骇浠诲姟寮傚父", e); - return BaseResponseUtils.buildException(e.getMessage()) ; + return BaseResponseUtils.buildErrorMsg(e.getMessage()) ; } if(count <= 0){ - return BaseResponseUtils.buildFail("鏁版嵁搴撴搷浣滃け璐�") ; + return BaseResponseUtils.buildErrorMsg("鏁版嵁搴撴搷浣滃け璐�") ; }else{ return BaseResponseUtils.buildSuccess(true) ; } diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/CommandSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/CommandSv.java index 8c7fb80..be352d7 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/CommandSv.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/CommandSv.java @@ -132,7 +132,7 @@ jsonArray.add(jsonObject); }); } - System.out.println(jsonArray); + //System.out.println(jsonArray); } /** diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeCtrl.java index 0e99c5e..d5929d6 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeCtrl.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeCtrl.java @@ -1,7 +1,8 @@ package com.dy.pipIrrRemote.rtuUpgrage; +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.support.ExcelTypeEnum; import com.dy.common.aop.SsoAop; -import com.dy.common.multiDataSource.DataSourceContext; import com.dy.common.softUpgrade.state.UpgradeRtu; import com.dy.common.softUpgrade.state.UpgradeTaskVo; import com.dy.common.springUtil.SpringContextUtil; @@ -12,6 +13,8 @@ import com.dy.pipIrrGlobal.pojoUg.UgRtuProgram; import com.dy.pipIrrGlobal.pojoUg.UgRtuTask; import com.dy.pipIrrGlobal.rtuMw.ToRtuMwCom; +import com.dy.pipIrrGlobal.voPr.VoDivide; +import com.dy.pipIrrGlobal.voUg.VoUgRtuResult; import com.dy.pipIrrGlobal.voUg.VoWatch; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Content; @@ -19,15 +22,19 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.servlet.http.HttpServletResponse; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.RestTemplate; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.ArrayList; import java.util.Base64; import java.util.List; @@ -44,6 +51,9 @@ public class RtuUpgradeCtrl extends ToRtuMwCom { @Autowired private RtuUpgradeSv sv ; + + @Autowired + RtuUpgradeResSv resSv ; @Autowired private Environment env; @@ -69,28 +79,28 @@ @SsoAop() public BaseResponse<Boolean> issuedTask(String id){ if(id == null || id.trim().equals("")){ - return BaseResponseUtils.buildError("浠诲姟id涓嶈兘涓虹┖") ; + return BaseResponseUtils.buildErrorMsg("浠诲姟id涓嶈兘涓虹┖") ; } UgRtuTask tpo = this.sv.selectTaskById(id) ; if(tpo == null){ - return BaseResponseUtils.buildError("浠诲姟涓嶅瓨鍦�") ; + return BaseResponseUtils.buildErrorMsg("浠诲姟涓嶅瓨鍦�") ; } if(tpo.isExecute == 1){ - return BaseResponseUtils.buildError("浠诲姟宸蹭笅鍙戯紝涓嶈兘閲嶅涓嬪彂浠诲姟") ; + return BaseResponseUtils.buildErrorMsg("浠诲姟宸蹭笅鍙戯紝涓嶈兘閲嶅涓嬪彂浠诲姟") ; } UgRtuProgram ppo = this.sv.selectProgramById(tpo.programId) ; if(ppo == null){ - return BaseResponseUtils.buildError("浠诲姟瀵瑰簲鐨勭▼搴忎笉瀛樺湪") ; + return BaseResponseUtils.buildErrorMsg("浠诲姟瀵瑰簲鐨勭▼搴忎笉瀛樺湪") ; } List<String> taskRtuAddrs = this.sv.selectAllRtuAddrByTask(id) ; if(taskRtuAddrs == null || taskRtuAddrs.size() == 0){ - return BaseResponseUtils.buildError("浠诲姟鎵�娑夊強鐨勬帶鍒跺櫒杩樻湭璁剧疆") ; + return BaseResponseUtils.buildErrorMsg("浠诲姟鎵�娑夊強鐨勬帶鍒跺櫒杩樻湭璁剧疆") ; } String ugCallbackUrl_rm = env.getProperty("mw.ugCallbackUrl_rm" ); if(ugCallbackUrl_rm == null || ugCallbackUrl_rm.trim().equals("")){ - return BaseResponseUtils.buildError("鏈厤缃崌绾т换鍔″洖璋冪綉鍧�") ; + return BaseResponseUtils.buildErrorMsg("鏈厤缃崌绾т换鍔″洖璋冪綉鍧�") ; } UpgradeTaskVo vo = new UpgradeTaskVo() ; @@ -110,11 +120,11 @@ msg = res.getMsg() ; } log.error("閫氫俊涓棿浠舵墽琛屼笅鍙戝崌绾т换鍔″け璐�" + msg) ; - return BaseResponseUtils.buildFail("閫氫俊涓棿浠舵墽琛屽け璐�" + msg) ; + return BaseResponseUtils.buildErrorMsg("閫氫俊涓棿浠舵墽琛屽け璐�" + msg) ; } }else{ log.error("閫氫俊涓棿浠惰繑鍥炵粨鏋滀负null") ; - return BaseResponseUtils.buildFail("閫氫俊涓棿浠惰繑鍥炵粨鏋滀负null") ; + return BaseResponseUtils.buildErrorMsg("閫氫俊涓棿浠惰繑鍥炵粨鏋滀负null") ; } } @@ -128,9 +138,10 @@ vo.softBytesCalculate = ppo.programCalculateBytes ; vo.softByteSrc16 = ppo.programCrc16 ; } + + /** - * 鐩戣锛� - * 閲嶇疆锛屾紨绀虹殑閲嶇疆 + * 閲嶇疆杩滅▼鍗囩骇婕旂ず绋嬪簭 * @return 鎿嶄綔缁撴灉 */ @GetMapping(path = "/demoReset") @@ -166,104 +177,58 @@ if(qvo == null){ qvo = new QueryVo(); qvo.pageCurr = 1 ; - qvo.pageSize = 50 ; + qvo.pageSize = 49 ; } if(RtuUpgradeStateReceiverCtrl.cache == null){ - //return BaseResponseUtils.buildError("褰撳墠娌℃湁鍗囩骇浠诲姟") ; + return BaseResponseUtils.buildErrorMsg("褰撳墠娌℃湁鍗囩骇浠诲姟") ; //姝e紡杩愯鏃讹紝涓嬮潰涓よ鍘绘帀锛屼笂闈竴琛屾墦寮� - RtuUpgradeStateReceiverCtrl ctrl = SpringContextUtil.getBean(RtuUpgradeStateReceiverCtrl.class); - ctrl.demo(); + //RtuUpgradeStateReceiverCtrl ctrl = SpringContextUtil.getBean(RtuUpgradeStateReceiverCtrl.class); + //ctrl.demo(); } - - 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(0L + (listFiltered==null?0:listFiltered.size()), null); + QueryResultVo<VoWatch> rsVo = this.resSv.curUpgradeState(qvo) ; return BaseResponseUtils.buildSuccess(rsVo) ; } - private List<UpgradeRtu> filterByQuery(QueryVo qvo){ - if (qvo.status != null || qvo.result != null) { - final Integer qvoStatus = qvo.status ; - final Integer qvoResult = qvo.result ; - final String qvoRtuAddr = qvo.rtuAddr ; - return RtuUpgradeStateReceiverCtrl.cache.ugRtuStateList.stream().filter(rtu -> { - boolean ok = false; - if (qvoStatus != null) { - if (qvoStatus.intValue() == 1) { - if (rtu.state == UpgradeRtu.STATE_RUNNING) { - ok = true; - }else{ - ok = false ; - } - } else if (qvoStatus.intValue() == 0) { - if (rtu.isOver) { - ok = true; - }else{ - ok = false ; - } - } - } - if (qvoResult != null) { - if (qvoResult.intValue() == 1) { - if (rtu.state == UpgradeRtu.STATE_SUCCESS) { - ok = true; - }else{ - ok = false ; - } - } else if (qvoResult.intValue() == 0) { - if (rtu.state == UpgradeRtu.STATE_OFFLINE - || rtu.state == UpgradeRtu.STATE_FAILONE - || rtu.state == UpgradeRtu.STATE_FAIL - || rtu.state == UpgradeRtu.STATE_FAILOFFLINE) { - ok = true; - }else{ - ok = false ; - } - } - } - if(qvoRtuAddr != null && !qvoRtuAddr.trim().equals("")){ - if(rtu.rtuAddr.equals(qvoRtuAddr)){ - ok = true; - }else{ - ok = false ; - } - } - return ok; - }).toList() ; - }else{ - return RtuUpgradeStateReceiverCtrl.cache.ugRtuStateList ; - } + /** + * 瀵煎嚭鍗囩骇澶辫触RTU鍒楄〃 + * @param response + */ + @RequestMapping(value = "/exportUgFail", method = RequestMethod.GET) + public void exportUgFail(HttpServletResponse response) throws Exception { + setExcelRespProp(response, "鍗囩骇澶辫触RTU鍒楄〃"); + List<VoUgRtuResult> rsList = resSv.exportUgFail(); + EasyExcel.write(response.getOutputStream()) + .head(VoUgRtuResult.class) + .excelType(ExcelTypeEnum.XLSX) + .sheet("鍗囩骇澶辫触RTU鍒楄〃") + .doWrite(rsList); } + + + /** + * 瀵煎嚭闀跨骇鎴愬姛RTU鍒楄〃 + * @param response + */ + @RequestMapping(value = "/exportUgSuccess", method = RequestMethod.GET) + public void exportUgSuccess(HttpServletResponse response) throws Exception { + setExcelRespProp(response, "鍗囩骇鎴愬姛RTU鍒楄〃"); + List<VoUgRtuResult> rsList = resSv.exportUgSuccess(); + EasyExcel.write(response.getOutputStream()) + .head(VoUgRtuResult.class) + .excelType(ExcelTypeEnum.XLSX) + .sheet("鍗囩骇鎴愬姛RTU鍒楄〃") + .doWrite(rsList); + } + + + /** + * 璁剧疆excel涓嬭浇鍝嶅簲澶村睘鎬� + */ + private void setExcelRespProp(HttpServletResponse response, String rawFileName) throws UnsupportedEncodingException { + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setCharacterEncoding("utf-8"); + String fileName = URLEncoder.encode(rawFileName, "UTF-8").replaceAll("\\+", "%20"); + response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); + } + } 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..03c204d --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeResSv.java @@ -0,0 +1,160 @@ +package com.dy.pipIrrRemote.rtuUpgrage; + +import com.dy.common.softUpgrade.state.UpgradeRtu; +import com.dy.common.webUtil.QueryResultVo; +import com.dy.pipIrrGlobal.voUg.VoUgRtuResult; +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; + } + } + if(qvoRtuAddr != null && !qvoRtuAddr.trim().equals("")){ + ok = rtu.rtuAddr.equals(qvoRtuAddr); + } + return ok; + }).toList() ; + }else{ + return RtuUpgradeStateReceiverCtrl.cache.ugRtuStateList ; + } + } + + /** + * 杩囨护鍑哄綋鍓嶉暱绾т换鍔′腑鍗囩骇澶辫触鐨凴TU + * @return 闆嗗悎 + */ + public List<VoUgRtuResult> exportUgFail(){ + List<VoUgRtuResult> 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){ + VoUgRtuResult vo = new VoUgRtuResult() ; + vo.rtuAddr = rtu.rtuAddr ; + vo.result = "绂荤嚎" ; + list.add(vo); + }else if(rtu.state == UpgradeRtu.STATE_FAILONE){ + VoUgRtuResult vo = new VoUgRtuResult() ; + vo.rtuAddr = rtu.rtuAddr ; + vo.result = "涓�鍖呮" ; + list.add(vo); + }else if(rtu.state == UpgradeRtu.STATE_FAIL){ + VoUgRtuResult vo = new VoUgRtuResult() ; + vo.rtuAddr = rtu.rtuAddr ; + vo.result = "澶氬寘姝�" ; + list.add(vo); + } + } + }); + } + } + return list ; + } + + /** + * 杩囨护鍑哄綋鍓嶉暱绾т换鍔′腑鍗囩骇鎴愬姛鐨凴TU + * @return 闆嗗悎 + */ + public List<VoUgRtuResult> exportUgSuccess(){ + List<VoUgRtuResult> 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){ + VoUgRtuResult vo = new VoUgRtuResult() ; + vo.rtuAddr = rtu.rtuAddr ; + vo.result = "鍗囩骇鎴愬姛" ; + list.add(vo); + } + } + }); + } + } + return list ; + } +} 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 7654ce3..abfdc1b 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 @@ -65,20 +65,20 @@ } } if(cache == null){ + cache = info; //姝ゆ椂涓嶅仛浠诲姟鎿嶄綔锛屽彧淇濋殰cache涓嶄负绌猴紝 绛夊緟涓嬫鍙戞潵鏁版嵁 if(info.ugRtuStateList != null && info.ugRtuStateList.size() > 0){ List<UpgradeRtu> overList = info.ugRtuStateList.stream().filter(itemVo -> itemVo.isOver).collect(Collectors.toList()) ; if(overList != null && overList.size() > 0){ - cache = info; this.save2Db(info.ugTaskId, overList); } } }else{ + cache = info; //褰揷ache涓湁鍊兼椂锛岃繘琛屾瘮瀵瑰瓨鍌紝瀵规瘮鐩殑鏄槻姝㈤噸澶嶆搷浣滄暟鎹簱 if(info.ugRtuStateList != null && info.ugRtuStateList.size() > 0){ //姝ゆ椂淇濊瘉涓や釜闆嗗悎閮戒笉涓簄ull this.save2Db(info.ugTaskId, info.ugRtuStateList, cache.ugRtuStateList); - cache = info; } } return null; @@ -154,7 +154,7 @@ @Override public Object execute() throws Exception { while(!this.stop){ - if(!runDemo()){ + if(!runInDemo()){ this.stop = true ; }else{ try { @@ -188,7 +188,7 @@ } } } - private boolean runDemo(){ + private boolean runInDemo(){ for(UpgradeRtu rtu : cache.ugRtuStateList){ this.rtuUpgrade(rtu) ; } @@ -244,7 +244,7 @@ } int n = Integer.parseInt(new CreateRandom().create(3)) ; - if(n == 540 || n == 541 || n == 542 || n == 543 || n == 544 || n == 545){ + if(n == 540 || n == 541 || n == 542 || n == 543 || n == 544 || n == 545 || n == 546 || n == 547 || n == 548 || n == 549 ){ if(rtu.currentPackage == 1){ //1鍖呮 rtu.state = UpgradeRtu.STATE_FAILONE ; @@ -296,6 +296,7 @@ for(UpgradeRtu rtu : cache.ugRtuStateList){ if(rtu.state == UpgradeRtu.STATE_OFFLINE){ cache.ugOverallState.offLineTotal ++ ; + cache.ugOverallState.failTotal++; }else if(rtu.state == UpgradeRtu.STATE_UNSTART){ cache.ugOverallState.unStartTotal ++ ; }else if(rtu.state == UpgradeRtu.STATE_RUNNING){ @@ -307,6 +308,7 @@ cache.ugOverallState.failOneTotal++; cache.ugOverallState.failTotal++; }else if(rtu.state == UpgradeRtu.STATE_FAIL) { + cache.ugOverallState.failMultiTotal++; cache.ugOverallState.failTotal++; } if(rtu.isOver){ @@ -317,6 +319,15 @@ if(!hasRunning){ cache.ugOverallState.allOver = true ; } + if(cache.ugOverallState.allOver){ + cache.ugOverallState.overTotal = 0; + if(cache.ugRtuStateList != null && cache.ugRtuStateList.size() > 0){ + for(UpgradeRtu rtu : cache.ugRtuStateList){ + rtu.isOver = true ; + cache.ugOverallState.overTotal++; + } + } + } return hasRunning ; } } diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeSv.java index 3293427..11787ec 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeSv.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeSv.java @@ -58,28 +58,6 @@ } /** - * 鏌ヨ涓�涓崌绾т换鍔℃湁鍏充俊鎭� - * @return 鍗囩骇浠诲姟鏈夊叧淇℃伅 - */ - public VoUpgradeDetail selectTaskDetail(String taskId){ - List<VoUpgradeDetail> list = this.tdao.selectTaskDetail(Long.valueOf(taskId)) ; - if(list != null && list.size() > 0){ - return list.get(0) ; - } - return null ; - } - - - /** - * 淇濆瓨鍗囩骇浠诲姟涓烘墽琛岀姸鎬� - * @param taskId 浠诲姟ID - */ - public void setUpgradeTaskExecuted(String taskId){ - this.tdao.executeById(Long.valueOf(taskId)) ; - } - - - /** * 淇濆瓨RTU鍗囩骇缁撴潫鐘舵�� * @param taskId * @param rtu @@ -91,17 +69,38 @@ cdao.updateRtuUpgradeState(params) ; } - ///////////////////////////////////////////////////// - // - // 浠ヤ笅妯℃嫙鏁版嵁 - // - ///////////////////////////////////////////////////// /** - * 閫氫俊涓婚敭鏌ヨ涓�涓崌绾т换鍔� + * 鏌ヨ涓�涓崌绾т换鍔℃湁鍏充俊鎭� + * @return 鍗囩骇浠诲姟鏈夊叧淇℃伅 + */ + public VoUpgradeDetail selectTaskDetail(String taskId){ + List<VoUpgradeDetail> list = this.tdao.selectTaskDetail(Long.valueOf(taskId)) ; + if(list != null && list.size() > 0){ + return list.get(0) ; + } + return null ; + } + + /** + * 淇濆瓨鍗囩骇浠诲姟涓烘墽琛岀姸鎬� + * @param taskId 浠诲姟ID + */ + public void setUpgradeTaskExecuted(String taskId){ + this.tdao.executeById(Long.valueOf(taskId)) ; + } + + + ///////////////////////////////////////////////////// + // + // 浠ヤ笅婕旂ず鍗囩骇鍔熻兘鐢ㄥ埌 + // + ///////////////////////////////////////////////////// + + /** + * 鏌ヨ鏈�鏂颁竴涓崌绾т换鍔� * @return */ public UgRtuTask selectLastTask(){ return tdao.selectLastTask(); } - } diff --git a/pipIrr-platform/pom.xml b/pipIrr-platform/pom.xml index 62c1229..a7955fc 100644 --- a/pipIrr-platform/pom.xml +++ b/pipIrr-platform/pom.xml @@ -186,6 +186,13 @@ <type>pom</type> <scope>import</scope> </dependency> + <dependency> + <groupId>com.baomidou</groupId> + <artifactId>mybatis-plus-extension</artifactId> + <version>3.5.3.2</version> + <type>pom</type> + <scope>import</scope> + </dependency> <!-- 闃块噷fastjson --> <dependency> @@ -271,11 +278,11 @@ <scope>import</scope> </dependency> - <!-- quartz --> + <!-- rocketmq-client --> <dependency> <groupId>org.apache.rocketmq</groupId> <artifactId>rocketmq-client</artifactId> - <version>4.9.7</version> + <version>5.3.1</version> <type>pom</type> <scope>import</scope> </dependency> -- Gitblit v1.8.0