From 781aaa24d1f12659581eb545fc4ee678e4d85b7f Mon Sep 17 00:00:00 2001 From: wuzeyu <1223318623@qq.com> Date: 星期四, 23 五月 2024 17:02:21 +0800 Subject: [PATCH] 田间灌溉项目管理 轮灌组 修改轮灌组移除灌溉单元接口为批量移除 --- pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpClient/MyThreadJob.java | 41 +++++++++++++++++++++++++++++------------ 1 files changed, 29 insertions(+), 12 deletions(-) diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpClient/MyThreadJob.java b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpClient/MyThreadJob.java index e50537f..0f58f3e 100644 --- a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpClient/MyThreadJob.java +++ b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpClient/MyThreadJob.java @@ -23,9 +23,10 @@ public static final int connectTimeout = 3000 ; - public int sendTimes = 0 ;//鍙戦�佹暟鎹鏁� - public int heartbeatTimes = 0 ;//涓婃姤蹇冭烦娆℃暟 + public int sendTimes = 1 ;//鍙戦�佹暟鎹鏁� + public int heartbeatTimes = 1 ;//涓婃姤蹇冭烦娆℃暟 + public long overStart = 0L; public boolean isOver = false ; public MyThreadJob(){ @@ -38,21 +39,35 @@ @Override public void execute() throws Exception { - log.info("RTU" + rtuAddr + "寮�濮嬩换鍔�"); - if(session != null){ - log.info("RTU" + rtuAddr + "灏嗚鎵ц" + ServerProperties.sendTimes + "杞浠诲姟锛屽綋鍓嶈疆娆℃槸" + sendTimes); - if(sendTimes <= ServerProperties.sendTimes){ - sendDataOfP206V1_0_0() ; - }else{ - this.jobOver() ; + if(!this.isOver){ + if(session != null){ + if(sendTimes <= ServerProperties.sendTimes){ + log.info("RTU" + rtuAddr + "寮�濮嬩换鍔�"); + log.info("RTU" + rtuAddr + "灏嗚鎵ц" + ServerProperties.sendTimes + "杞浠诲姟锛屽綋鍓嶈疆娆℃槸" + sendTimes); + sendDataOfP206V1_0_0() ; + }else{ + if(ServerProperties.sendOverThenCloseConnect == 1){ + log.info("RTU" + rtuAddr + "绛夊緟涓�浼氾紝浠ユ帴鏀堕�氫俊涓棿浠朵笅琛屾暟鎹�"); + if(overStart == 0){ + overStart = System.currentTimeMillis() ; + }else{ + long now = System.currentTimeMillis() ; + if(now - overStart >= 30 * 1000){ + this.jobOver() ; + } + } + }else{ + this.jobOver() ; + } + } } } } private void sendDataOfP206V1_0_0(){ try{ - if(heartbeatTimes >= ServerProperties.heartbeatTimes){ - heartbeatTimes = 0 ; + if(heartbeatTimes > ServerProperties.heartbeatTimes){ + heartbeatTimes = 1 ; this.sendReportData() ; TcpClUnit.clientSendData(); sendTimes++ ; @@ -86,7 +101,9 @@ } private void jobOver(){ - session.closeOnFlush() ; + if(ServerProperties.sendOverThenCloseConnect == 1){ + session.closeOnFlush() ; + } this.isOver = true ; TcpClUnit.clientOver() ; } -- Gitblit v1.8.0