From 5fcdef2e8eec55221bb65a7a2cf91a4be7cc89ac Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期一, 02 十二月 2024 16:41:11 +0800
Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV
---
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeCtrl.java | 7
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V2/parse/global/GlCreate.java | 21 ++
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V2/parse/Cd_1602_Down.java | 2
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/parse/Cd_1600_Down.java | 2
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeStateReceiverCtrl.java | 7
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/parse/Cd_1602_Down.java | 2
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/global/GlCreate.java | 35 +++-
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/forTcp/RtuStatus.java | 1
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/DriverV1.java | 2
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_1600_Down.java | 2
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/local/localProtocol/RtuStatusDeal.java | 17 +
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/rtuStatus/RtuInfoNotify.java | 2
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java | 20 --
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V2/parse/Cd_1601_Down.java | 4
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_1602_Down.java | 2
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V2/parse/Cd_1603_Down.java | 2
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V2/DriverV2.java | 2
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/forTcp/RtuStatusDealer.java | 17 +
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/cardOperate/CardOperateSv.java | 57 +++++-
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/forTcp/TcpSessionCache.java | 74 ---------
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/CRC16.java | 117 +++++++++-----
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/parse/Cd_1601_Down.java | 2
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/Web2RtuMw.java | 14 +
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/DriverV202404.java | 2
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/parse/global/GlCreate.java | 16 +
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_1601_Down.java | 2
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/local/localProtocol/CodeLocal.java | 2
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/parse/Cd_1603_Down.java | 2
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V2/parse/Cd_1600_Down.java | 5
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_1603_Down.java | 2
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/AdapterImp_ProtocolUnit.java | 2
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/local/CommandInnerDeaLer.java | 22 ++
32 files changed, 274 insertions(+), 192 deletions(-)
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/DriverV1.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/DriverV1.java
index 789ee94..54279c3 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/DriverV1.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/DriverV1.java
@@ -106,10 +106,10 @@
}
@Override
public void notify(NotifyInfo ...infos) {
+ notify.notify(rtuAddr, ProtocolConstantV206V1.protocolName, ProtocolConstantV206V1.protocolVer, infos);
}
});
}
-
} catch (Exception e) {
isFail = true ;
return new MidResult[]{(new MidResultError(ProtocolConstantV206V1.protocolName, rtuAddr, "涓ラ噸閿欒锛屽垎鏋怰tu鏁版嵁鍑洪敊锛佹暟鎹负锛�" + upHex + (e.getMessage() == null?"":("锛屽嚭閿欎俊鎭細" + e.getMessage())), e))} ;
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/parse/Cd_1600_Down.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/parse/Cd_1600_Down.java
index 55f2527..641d16c 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/parse/Cd_1600_Down.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/parse/Cd_1600_Down.java
@@ -71,6 +71,8 @@
index += 2 ;
GlCreate.createRtuAddr4PUg(para.rtuAddr, preBytes, index);
+ GlCreate.createLen4PUg(preBytes);//闀垮害鏀惧瓧鑺傛暟缁勪腑
+
byte[] bsTail = GlCreate.createCrcTail4Ug(preBytes) ;//CRC鍜屽熬鍙犲姞瀛楄妭鏁扮粍涓�
return ByteUtil.bytesMerge(preBytes, bsTail) ;
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/parse/Cd_1601_Down.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/parse/Cd_1601_Down.java
index 845a90a..26549ff 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/parse/Cd_1601_Down.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/parse/Cd_1601_Down.java
@@ -99,6 +99,8 @@
ByteUtil.hex2Bytes(vo.softStartAddr, bs, 0) ;
bytes = ByteUtil.bytesMerge(bytes, bs) ;
+ GlCreate.createLen4PUg(bytes);//闀垮害鏀惧瓧鑺傛暟缁勪腑
+
byte[] bsTail = GlCreate.createCrcTail4Ug(bytes) ;//CRC鍜屽熬鍙犲姞瀛楄妭鏁扮粍涓�
return ByteUtil.bytesMerge(bytes, bsTail) ;
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/parse/Cd_1602_Down.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/parse/Cd_1602_Down.java
index 8c90752..6e7a932 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/parse/Cd_1602_Down.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/parse/Cd_1602_Down.java
@@ -82,6 +82,8 @@
bytes = ByteUtil.bytesMerge(bytes, (byte[])para.attachment) ;
+ GlCreate.createLen4PUg(bytes);//闀垮害鏀惧瓧鑺傛暟缁勪腑
+
byte[] bsTail = GlCreate.createCrcTail4Ug(bytes) ;//CRC鍜屽熬鍙犲姞瀛楄妭鏁扮粍涓�
return ByteUtil.bytesMerge(bytes, bsTail) ;
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/parse/Cd_1603_Down.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/parse/Cd_1603_Down.java
index 672e40c..1e4a715 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/parse/Cd_1603_Down.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/parse/Cd_1603_Down.java
@@ -71,6 +71,8 @@
index += 2 ;
GlCreate.createRtuAddr4PUg(para.rtuAddr, preBytes, index);
+ GlCreate.createLen4PUg(preBytes);//闀垮害鏀惧瓧鑺傛暟缁勪腑
+
byte[] bsTail = GlCreate.createCrcTail4Ug(preBytes) ;//CRC鍜屽熬鍙犲姞瀛楄妭鏁扮粍涓�
return ByteUtil.bytesMerge(preBytes, bsTail) ;
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/parse/global/GlCreate.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/parse/global/GlCreate.java
index 634534a..553c055 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/parse/global/GlCreate.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/parse/global/GlCreate.java
@@ -54,12 +54,13 @@
public static void createLen4PUg(byte[] bytes) throws Exception {
int len = bytes.length - 4;
- byte[] bs = ByteUtil.int2BCD_LE(len) ;
+ byte[] bs = ByteUtil.short2Bytes_LE((short)len) ;
if(bs != null && bs.length == 1){
- bytes[1] = bs[0] ;
+ bytes[1] = 0 ;
+ bytes[2] = bs[0] ;
}else if(bs != null && bs.length > 1){
- bytes[1] = bs[0] ;
- bytes[2] = bs[1] ;
+ bytes[1] = bs[1] ;
+ bytes[2] = bs[0] ;
}
}
@@ -92,9 +93,12 @@
}
public static byte[] createCrcTail4Ug(byte[] bsNoTail) throws Exception {
- short crc = new CRC16().CRC(bsNoTail, 0, bsNoTail.length -1) ;
+ int crc = new CRC16().CRC16_table(bsNoTail, 0, bsNoTail.length -1) ;
+ byte[] crcBs = new byte[4] ;
+ ByteUtil.int2Bytes_BE(crcBs, crc, 0);
byte[] bytes = new byte[ProtocolConstantV206V1.UG_lenTail] ;
- ByteUtil.short2Bytes_BE(bytes, crc, 0);
+ bytes[0] = crcBs[2] ;
+ bytes[1] = crcBs[3] ;
bytes[2] = ProtocolConstantV206V1.P_Tail_Byte ;
return bytes ;
}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V2/DriverV2.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V2/DriverV2.java
index 5dba5f7..3297dbb 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V2/DriverV2.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V2/DriverV2.java
@@ -1,6 +1,7 @@
package com.dy.common.mw.protocol.p206V2;
import com.dy.common.mw.protocol.*;
+import com.dy.common.mw.protocol.p206V1.ProtocolConstantV206V1;
import com.dy.common.util.DateTime;
@AnnotationDriver(enable = true,
@@ -107,6 +108,7 @@
}
@Override
public void notify(NotifyInfo ...infos) {
+ notify.notify(rtuAddr, ProtocolConstantV206V1.protocolName, ProtocolConstantV206V1.protocolVer, infos);
}
});
}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V2/parse/Cd_1600_Down.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V2/parse/Cd_1600_Down.java
index 13d6504..321f0c2 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V2/parse/Cd_1600_Down.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V2/parse/Cd_1600_Down.java
@@ -1,11 +1,10 @@
package com.dy.common.mw.protocol.p206V2.parse;
import com.dy.common.mw.protocol.*;
-import com.dy.common.mw.protocol.p206V1.ProtocolConstantV206V1;
import com.dy.common.mw.protocol.p206V2.CodeV2;
import com.dy.common.mw.protocol.p206V2.ParseParamsForDownV2;
import com.dy.common.mw.protocol.p206V2.ProtocolConstantV206V2;
-import com.dy.common.mw.protocol.p206V2.parse.global.GlCreate;
+import com.dy.common.mw.protocol.p206V1.parse.global.GlCreate;
import com.dy.common.util.ByteUtil;
/**
@@ -71,6 +70,8 @@
index += 2 ;
GlCreate.createRtuAddr4PUg(para.rtuAddr, preBytes, index);
+ GlCreate.createLen4PUg(preBytes);//闀垮害鏀惧瓧鑺傛暟缁勪腑
+
byte[] bsTail = GlCreate.createCrcTail4Ug(preBytes) ;//CRC鍜屽熬鍙犲姞瀛楄妭鏁扮粍涓�
return ByteUtil.bytesMerge(preBytes, bsTail) ;
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V2/parse/Cd_1601_Down.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V2/parse/Cd_1601_Down.java
index 6b701e3..dcb32aa 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V2/parse/Cd_1601_Down.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V2/parse/Cd_1601_Down.java
@@ -4,7 +4,7 @@
import com.dy.common.mw.protocol.p206V2.CodeV2;
import com.dy.common.mw.protocol.p206V2.ParseParamsForDownV2;
import com.dy.common.mw.protocol.p206V2.ProtocolConstantV206V2;
-import com.dy.common.mw.protocol.p206V2.parse.global.GlCreate;
+import com.dy.common.mw.protocol.p206V1.parse.global.GlCreate;
import com.dy.common.softUpgrade.Com1601Vo;
import com.dy.common.util.ByteUtil;
@@ -99,6 +99,8 @@
ByteUtil.hex2Bytes(vo.softStartAddr, bs, 0) ;
bytes = ByteUtil.bytesMerge(bytes, bs) ;
+ GlCreate.createLen4PUg(bytes);//闀垮害鏀惧瓧鑺傛暟缁勪腑
+
byte[] bsTail = GlCreate.createCrcTail4Ug(bytes) ;//CRC鍜屽熬鍙犲姞瀛楄妭鏁扮粍涓�
return ByteUtil.bytesMerge(bytes, bsTail) ;
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V2/parse/Cd_1602_Down.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V2/parse/Cd_1602_Down.java
index 941a836..4a72d61 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V2/parse/Cd_1602_Down.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V2/parse/Cd_1602_Down.java
@@ -81,6 +81,8 @@
bytes = ByteUtil.bytesMerge(bytes, (byte[])para.attachment) ;
+ GlCreate.createLen4PUg(bytes);//闀垮害鏀惧瓧鑺傛暟缁勪腑
+
byte[] bsTail = GlCreate.createCrcTail4Ug(bytes) ;//CRC鍜屽熬鍙犲姞瀛楄妭鏁扮粍涓�
return ByteUtil.bytesMerge(bytes, bsTail) ;
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V2/parse/Cd_1603_Down.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V2/parse/Cd_1603_Down.java
index f9ad376..5b6b9f9 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V2/parse/Cd_1603_Down.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V2/parse/Cd_1603_Down.java
@@ -71,6 +71,8 @@
index += 2 ;
GlCreate.createRtuAddr4PUg(para.rtuAddr, preBytes, index);
+ GlCreate.createLen4PUg(preBytes);//闀垮害鏀惧瓧鑺傛暟缁勪腑
+
byte[] bsTail = GlCreate.createCrcTail4Ug(preBytes) ;//CRC鍜屽熬鍙犲姞瀛楄妭鏁扮粍涓�
return ByteUtil.bytesMerge(preBytes, bsTail) ;
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V2/parse/global/GlCreate.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V2/parse/global/GlCreate.java
index 9875718..eb37b70 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V2/parse/global/GlCreate.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V2/parse/global/GlCreate.java
@@ -1,5 +1,6 @@
package com.dy.common.mw.protocol.p206V2.parse.global;
+import com.dy.common.mw.protocol.p206V1.ProtocolConstantV206V1;
import com.dy.common.mw.protocol.p206V2.ProtocolConstantV206V2;
import com.dy.common.util.*;
@@ -54,6 +55,17 @@
bsNoTail[ProtocolConstantV206V2.dataLenIndex] = (byte)len ;
}
+ public static void createLen4PUg(byte[] bytes) throws Exception {
+ int len = bytes.length - 4;
+ byte[] bs = ByteUtil.short2Bytes_LE((short)len) ;
+ if(bs != null && bs.length == 1){
+ bytes[1] = 0 ;
+ bytes[2] = bs[0] ;
+ }else if(bs != null && bs.length > 1){
+ bytes[1] = bs[1] ;
+ bytes[2] = bs[0] ;
+ }
+ }
/**
* 鐢熸垚IC鍗$紪鐮�
@@ -83,10 +95,13 @@
}
public static byte[] createCrcTail4Ug(byte[] bsNoTail) throws Exception {
- int crc = new CRC16().CRC(bsNoTail, 0, bsNoTail.length -1) ;
+ int crc = new CRC16().CRC16_table(bsNoTail, 0, bsNoTail.length -1) ;
+ byte[] crcBs = new byte[4] ;
+ ByteUtil.int2Bytes_BE(crcBs, crc, 0);
byte[] bytes = new byte[ProtocolConstantV206V2.UG_lenTail] ;
- ByteUtilUnsigned.short2Bytes_BE(bytes, crc, 0);
- bytes[2] = ProtocolConstantV206V2.P_Tail_Byte ;
+ bytes[0] = crcBs[2] ;
+ bytes[1] = crcBs[3] ;
+ bytes[2] = ProtocolConstantV206V1.P_Tail_Byte ;
return bytes ;
}
}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/DriverV202404.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/DriverV202404.java
index 0c2e775..c504d5c 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/DriverV202404.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/DriverV202404.java
@@ -67,7 +67,6 @@
if(crcStr != null){
return new MidResult[]{(new MidResultError(ProtocolConstantV206V202404.protocolName, rtuAddr, "涓ラ噸閿欒锛屼笂琛屾暟鎹瓹RC妫�鏌ュけ璐ワ紝" + crcStr, null))} ;
}
- rtuAddr = cp.parseRtuAddr(upBuffer) ;
upCode = cp.parseCode(upBuffer) ;
if(upCode == null){
return new MidResult[]{(new MidResultError(ProtocolConstantV206V202404.protocolName, rtuAddr, "涓ラ噸閿欒锛屾湭鑳戒粠涓婅鏁版嵁涓В鏋愬嚭鍔熻兘鐮侊紒", null))} ;
@@ -107,6 +106,7 @@
}
@Override
public void notify(NotifyInfo ...infos) {
+ notify.notify(rtuAddr, ProtocolConstantV206V1.protocolName, ProtocolConstantV206V1.protocolVer, infos);
}
});
}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_1600_Down.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_1600_Down.java
index c73a6d2..dab5bad 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_1600_Down.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_1600_Down.java
@@ -70,6 +70,8 @@
index += 2 ;
GlCreate.createRtuAddr4PUg(para.rtuAddr, preBytes, index);
+ GlCreate.createLen4PUg(preBytes);//闀垮害鏀惧瓧鑺傛暟缁勪腑
+
byte[] bsTail = GlCreate.createCrcTail4Ug(preBytes) ;//CRC鍜屽熬鍙犲姞瀛楄妭鏁扮粍涓�
return ByteUtil.bytesMerge(preBytes, bsTail) ;
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_1601_Down.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_1601_Down.java
index 31d9552..5c03b60 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_1601_Down.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_1601_Down.java
@@ -99,6 +99,8 @@
ByteUtil.hex2Bytes(vo.softStartAddr, bs, 0) ;
bytes = ByteUtil.bytesMerge(bytes, bs) ;
+ GlCreate.createLen4PUg(bytes);//闀垮害鏀惧瓧鑺傛暟缁勪腑
+
byte[] bsTail = GlCreate.createCrcTail4Ug(bytes) ;//CRC鍜屽熬鍙犲姞瀛楄妭鏁扮粍涓�
return ByteUtil.bytesMerge(bytes, bsTail) ;
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_1602_Down.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_1602_Down.java
index 5281b89..cb39f83 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_1602_Down.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_1602_Down.java
@@ -81,6 +81,8 @@
bytes = ByteUtil.bytesMerge(bytes, (byte[])para.attachment) ;
+ GlCreate.createLen4PUg(bytes);//闀垮害鏀惧瓧鑺傛暟缁勪腑
+
byte[] bsTail = GlCreate.createCrcTail4Ug(bytes) ;//CRC鍜屽熬鍙犲姞瀛楄妭鏁扮粍涓�
return ByteUtil.bytesMerge(bytes, bsTail) ;
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_1603_Down.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_1603_Down.java
index b708300..a9a9d24 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_1603_Down.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_1603_Down.java
@@ -71,6 +71,8 @@
index += 2 ;
GlCreate.createRtuAddr4PUg(para.rtuAddr, preBytes, index);
+ GlCreate.createLen4PUg(preBytes);//闀垮害鏀惧瓧鑺傛暟缁勪腑
+
byte[] bsTail = GlCreate.createCrcTail4Ug(preBytes) ;//CRC鍜屽熬鍙犲姞瀛楄妭鏁扮粍涓�
return ByteUtil.bytesMerge(preBytes, bsTail) ;
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/global/GlCreate.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/global/GlCreate.java
index 432a0bf..60e7d69 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/global/GlCreate.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/global/GlCreate.java
@@ -1,7 +1,5 @@
package com.dy.common.mw.protocol.p206V202404.parse.global;
-import com.dy.common.mw.protocol.p206V1.ProtocolConstantV206V1;
-import com.dy.common.mw.protocol.p206V2.ProtocolConstantV206V2;
import com.dy.common.mw.protocol.p206V202404.CommonV202404;
import com.dy.common.mw.protocol.p206V202404.ProtocolConstantV206V202404;
import com.dy.common.util.*;
@@ -142,23 +140,38 @@
}
public static void createLen(byte[] bsNoTail) throws Exception {
- int len = bsNoTail.length - ProtocolConstantV206V1.lenHead2ctrl;
- bsNoTail[ProtocolConstantV206V1.dataLenIndex] = (byte)len ;
+ int len = bsNoTail.length - ProtocolConstantV206V202404.lenHead2ctrl;
+ bsNoTail[ProtocolConstantV206V202404.dataLenIndex] = (byte)len ;
+ }
+
+ public static void createLen4PUg(byte[] bytes) throws Exception {
+ int len = bytes.length - 4;
+ byte[] bs = ByteUtil.short2Bytes_LE((short)len) ;
+ if(bs != null && bs.length == 1){
+ bytes[1] = 0 ;
+ bytes[2] = bs[0] ;
+ }else if(bs != null && bs.length > 1){
+ bytes[1] = bs[1] ;
+ bytes[2] = bs[0] ;
+ }
}
public static byte[] createCrcTail(byte[] bsNoTail) throws Exception {
- int crc = new CRC8_for_2_0().CRC8(bsNoTail, ProtocolConstantV206V1.ctrlIndex, bsNoTail.length -1) ;
- byte[] bytes = new byte[ProtocolConstantV206V1.lenTail] ;
+ int crc = new CRC8_for_2_0().CRC8(bsNoTail, ProtocolConstantV206V202404.ctrlIndex, bsNoTail.length -1) ;
+ byte[] bytes = new byte[ProtocolConstantV206V202404.lenTail] ;
bytes[0] = (byte)crc ;
- bytes[1] = ProtocolConstantV206V1.P_Tail_Byte ;
+ bytes[1] = ProtocolConstantV206V202404.P_Tail_Byte ;
return bytes ;
}
public static byte[] createCrcTail4Ug(byte[] bsNoTail) throws Exception {
- int crc = new CRC16().CRC(bsNoTail, 0, bsNoTail.length -1) ;
- byte[] bytes = new byte[ProtocolConstantV206V2.UG_lenTail] ;
- ByteUtilUnsigned.short2Bytes_BE(bytes, crc, 0);
- bytes[2] = ProtocolConstantV206V2.P_Tail_Byte ;
+ int crc = new CRC16().CRC16_table(bsNoTail, 0, bsNoTail.length -1) ;
+ byte[] crcBs = new byte[4] ;
+ ByteUtil.int2Bytes_BE(crcBs, crc, 0);
+ byte[] bytes = new byte[ProtocolConstantV206V202404.UG_lenTail] ;
+ bytes[0] = crcBs[2] ;
+ bytes[1] = crcBs[3] ;
+ bytes[2] = ProtocolConstantV206V202404.P_Tail_Byte ;
return bytes ;
}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/CRC16.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/CRC16.java
index e056bdc..307e1af 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/CRC16.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/CRC16.java
@@ -1,6 +1,8 @@
package com.dy.common.util;
+import com.dy.common.mw.protocol.p206V1.ProtocolConstantV206V1;
+
@SuppressWarnings("unused")
public final class CRC16 {
@@ -48,57 +50,74 @@
}
return (short)crc;
}
-
-
-
- private static final int[] crc16_rev_table = new int[]
- { 0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241,
- 0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
- 0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40,
- 0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841,
- 0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40,
- 0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41,
- 0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641,
- 0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040,
- 0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240,
- 0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441,
- 0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41,
- 0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840,
- 0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41,
- 0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40,
- 0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640,
- 0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041,
- 0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240,
- 0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441,
- 0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41,
- 0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840,
- 0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41,
- 0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40,
- 0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640,
- 0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041,
- 0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241,
- 0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440,
- 0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40,
- 0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841,
- 0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40,
- 0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41,
- 0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641,
- 0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
- };
+
+ private static final int[] crc16_rev_table = new int[]{
+ 0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241,
+ 0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
+ 0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40,
+ 0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841,
+ 0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40,
+ 0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41,
+ 0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641,
+ 0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040,
+ 0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240,
+ 0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441,
+ 0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41,
+ 0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840,
+ 0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41,
+ 0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40,
+ 0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640,
+ 0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041,
+ 0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240,
+ 0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441,
+ 0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41,
+ 0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840,
+ 0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41,
+ 0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40,
+ 0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640,
+ 0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041,
+ 0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241,
+ 0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440,
+ 0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40,
+ 0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841,
+ 0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40,
+ 0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41,
+ 0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641,
+ 0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
+ };
+
+ /**
+ * 16浣嶇殑CRC鍊兼槸鏃犵鍙蜂袱瀛楄妭鏁存暟锛�
+ * @param bs 瀛楄妭鏁扮粍
+ * @param startIndex 寮�濮嬩笅鏍�
+ * @param endIndex 鎴涓嬫爣
+ * @return CRC
+ */
+ @SuppressWarnings("unused")
+ public int CRC16_table(byte[] bs, int startIndex, int endIndex) {
+ int x ;
+ int crc = 0xffff;
+ if(bs != null && bs.length >= endIndex + 1){
+ for (int i = startIndex ; i <= endIndex; i++){
+ x = (crc ^ bs[i]) ;
+ crc = ((crc >> 8) ^ crc16_rev_table[x & 0x00FF]) ;
+ }
+ }
+ return crc ;
+ }
/**
* 16浣嶇殑CRC鍊� 锛屾煡琛ㄦ硶
* @param bs 瀛楄妭鏁扮粍
* @return CRC
*/
- @SuppressWarnings("unused")
- public int CRC_table(byte[] bs) {
- int x ;
- int crc = 0xffff;
+ public short CRC16_table(byte[] bs) {
+ short x ;
+ short crc = (short)0xffff;
if(bs != null && bs.length > 0){
for(byte b : bs){
- x = crc ^ b ;
- crc = (crc >> 8) ^ crc16_rev_table[x & 0x00FF];
+ x = (short)(crc ^ b) ;
+ crc = (short)((crc >> 8) ^ crc16_rev_table[x & 0x00FF]) ;
}
}
return crc ;
@@ -121,6 +140,16 @@
System.arraycopy(new byte[] {(byte)(c - ((c / 256) * 256)) }, 0, crc, 1, 1);
return crc;
}
-
+
+ public static void main(String[] args) throws Exception {
+ int s = 62430 ;
+ //String hex = "AA0018AA16015301150599800001100000014A005D4D5D4D00004000AA7E16" ;
+ String hex = "AA0018AA16015301150599800001100000014A005D4D5D4D00004000" ;
+ byte[] bs = ByteUtil.hex2Bytes(hex) ;
+ int crc = new CRC16().CRC16_table(bs, 0 , bs.length - 1) ;
+ byte[] crcBs = new byte[4] ;
+ ByteUtil.int2Bytes_BE(crcBs, crc, 0);
+ System.out.println(ByteUtil.bytes2Hex(crcBs, true)) ;
+ }
}
diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/Web2RtuMw.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/Web2RtuMw.java
index e4f1d05..c4318f7 100644
--- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/Web2RtuMw.java
+++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/Web2RtuMw.java
@@ -91,12 +91,18 @@
String url = UriComponentsBuilder.fromUriString(toMwUrl)
.build()
.toUriString();
- HttpHeaders headers = new HttpHeaders();
- HttpEntity<?> httpEntity = new HttpEntity<>(headers);
+
+ //UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url)
+ // .queryParam("test", test);
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url) ;
+
ResponseEntity<BaseResponse> response = null;
try {
- // 閫氳繃Post鏂瑰紡璋冪敤鎺ュ彛
- response = restTemplate.exchange(url, HttpMethod.GET, httpEntity, BaseResponse.class);
+ // 閫氳繃Get鏂瑰紡璋冪敤鎺ュ彛
+ response = restTemplate.exchange(builder.toUriString(),
+ HttpMethod.GET,
+ new HttpEntity<>(new HttpHeaders()),
+ BaseResponse.class);
} catch (Exception e) {
e.printStackTrace();
return BaseResponseUtils.buildError("鍚庣绯荤粺鍑洪敊锛屼腑闂翠欢璋冪敤寮傚父");
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/AdapterImp_ProtocolUnit.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/AdapterImp_ProtocolUnit.java
index 7b5c530..c86bb60 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/AdapterImp_ProtocolUnit.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/AdapterImp_ProtocolUnit.java
@@ -7,7 +7,7 @@
import com.dy.rtuMw.server.forTcp.MidResultActionError;
import com.dy.rtuMw.server.forTcp.MidResultActionFromRtu;
import com.dy.rtuMw.server.forTcp.MidResultActionToRtu;
-import com.dy.rtuMw.server.protocolDriver.RtuInfoNotify;
+import com.dy.rtuMw.server.rtuStatus.RtuInfoNotify;
public class AdapterImp_ProtocolUnit implements ProtocolUnitAdapter {
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/forTcp/RtuStatus.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/forTcp/RtuStatus.java
index 7737987..aebbf41 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/forTcp/RtuStatus.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/forTcp/RtuStatus.java
@@ -89,7 +89,6 @@
this.valveCloseLastDt = DateTime.yyyy_MM_dd_HH_mm_ss() ;
this.valveStatusLastTimeStamp = System.currentTimeMillis() ;
}
-
}
}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/forTcp/RtuStatusDealer.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/forTcp/RtuStatusDealer.java
index 2ec4fb6..9f8c204 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/forTcp/RtuStatusDealer.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/forTcp/RtuStatusDealer.java
@@ -22,18 +22,27 @@
* 寰楀埌閮ㄥ垎鐘舵��
* @return
*/
- public static Map<String, RtuStatus> partStatus(String[] rtuAddrArrGrp){
+ public static Map<String, RtuStatus> someStatus(String[] rtuAddrArrGrp){
synchronized (map){
- Map<String, RtuStatus> map = new HashMap<>();
+ Map<String, RtuStatus> rsMap = new HashMap<>();
for(String rtuAddr : rtuAddrArrGrp){
RtuStatus status = map.get(rtuAddr) ;
if(status != null){
- map.put(rtuAddr, status) ;
+ rsMap.put(rtuAddr, status) ;
}
}
- return map ;
+ return rsMap ;
}
}
+ /**
+ * 寰楀埌涓�涓猂TU鐨勭姸鎬�
+ * @return
+ */
+ public static RtuStatus oneStatus(String rtuAddr){
+ return map.get(rtuAddr) ;
+ }
+
+
public static void onLine(String rtuAddr, String ip, Integer port, String protocolName, Short protocolVersion){
RtuStatus vo = map.get(rtuAddr) ;
if(vo == null) {
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/forTcp/TcpSessionCache.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/forTcp/TcpSessionCache.java
index cc82cf0..d03d826 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/forTcp/TcpSessionCache.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/forTcp/TcpSessionCache.java
@@ -113,19 +113,6 @@
* 寰楀埌Tcp閫氫俊鍗忚鍚嶇О
* @param rtuAddr
* @return
- public static String getTcpProtocolName(String rtuAddr){
- TcpSession tcpSe = sessionTable.get(rtuAddr) ;
- if(tcpSe != null){
- return tcpSe.protocolName ;
- }else{
- return null ;
- }
- }
- */
- /**
- * 寰楀埌Tcp閫氫俊鍗忚鍚嶇О
- * @param rtuAddr
- * @return
* */
public static Object[] getTcpProtocolNameVersion(String rtuAddr){
TcpSession tcpSe = map.get(rtuAddr) ;
@@ -194,50 +181,7 @@
return map ;
}
}
-//
-// /**
-// * 寰楀埌鎵�鏈塕TU杩炴帴鐘舵�佹儏鍐�
-// * @return
-// */
-// public static List<RtuSessionStatus> allConnectStatus(){
-// synchronized (sessionTable){
-// List<RtuSessionStatus> list = new ArrayList<RtuSessionStatus>();
-// Iterator<Entry<String, TcpSession>> it = sessionTable.entrySet().iterator() ;
-// Entry<String, TcpSession> entry = null ;
-// while(it.hasNext()){
-// entry = it.next() ;
-// RtuSessionStatus vo = new RtuSessionStatus() ;
-// vo.rtuAddr = entry.getKey() ;
-// IoSession se = entry.getValue().ioSession ;
-// vo.onTrueOffLine = se.isConnected() ;
-// InetSocketAddress sa = (InetSocketAddress)se.getRemoteAddress() ;
-// if(sa != null){
-// InetAddress inetAddr = sa.getAddress() ;
-// if(inetAddr != null){
-// vo.ip = inetAddr.getHostAddress() ;
-// vo.port = sa.getPort() ;
-// }
-// }
-// list.add(vo) ;
-// }
-// return list ;
-// }
-// }
-//
-
- /**
- * 寰楀埌IoSession
- * @param rtuAddr
- * @return
- */
-// public IoSession getIoSession(String rtuAddr){
-// TcpSession tcpSe = sessionMap.get(rtuAddr) ;
-// if(tcpSe != null){
-// return tcpSe.ioSession ;
-// }
-// return null ;
-// }
-
+
/**
* 缃戠粶鏄惁杩炴帴
* @param rtuAddr
@@ -312,21 +256,5 @@
}
}
}
-
-// public static void updateRtuStatus(Long now){
-// synchronized (sessionTable){
-// Iterator<TcpSession> it = sessionTable.values().iterator() ;
-// TcpSession tcpSe ;
-// while(it.hasNext()){
-// tcpSe = it.next() ;
-// if(tcpSe.lastUpDataTime != null){
-// if(now - tcpSe.lastUpDataTime > ServerProperties.lastUpDataTimeLive){
-// tcpSe.lastUpDataTime = null ;
-// }
-// }
-// }
-// }
-// }
-
}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/local/CommandInnerDeaLer.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/local/CommandInnerDeaLer.java
index 3441197..c26ef26 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/local/CommandInnerDeaLer.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/local/CommandInnerDeaLer.java
@@ -34,7 +34,9 @@
}else if(code.equals(CodeLocal.allRtuStates)){
return this.allRtuStates(com) ;
}else if(code.equals(CodeLocal.partRtuStates)){
- return this.partRtuStates(com) ;
+ return this.someRtuStates(com) ;
+ }else if(code.equals(CodeLocal.oneRtuStates)){
+ return this.oneRtuStates(com) ;
}else if(code.equals(CodeLocal.allProtocols)){
return this.allProtocols(com) ;
}else if(code.equals(CodeLocal.stopTcpSv)){
@@ -101,10 +103,10 @@
* 鏌ヨ閮ㄥ垎RTU鐘舵��
* @throws Exception
*/
- private Command partRtuStates(Command command) throws Exception{
+ private Command someRtuStates(Command command) throws Exception{
if(command.param != null && command.param instanceof String && !command.param.equals("")){
String[] rtuAddrGrp = ((String)command.param).split(",");
- Map<String, RtuStatus> map = new RtuStatusDeal().dealPart(rtuAddrGrp) ;
+ Map<String, RtuStatus> map = new RtuStatusDeal().dealSome(rtuAddrGrp) ;
return ReturnCommand.successed("鏌ヨ閮ㄥ垎RTU鐘舵�佺粨鏋�", command.getId(), command.getCode(), map) ;
}else{
return ReturnCommand.errored("鍑洪敊锛屽懡浠ゅ弬鏁板簲璇ユ槸鎵�鏌ヨRTU鐨勫湴鍧�涓�", command.getId(), command.getCode()) ;
@@ -112,6 +114,20 @@
}
/**
+ * 鏌ヨ閮ㄥ垎RTU鐘舵��
+ * @throws Exception
+ */
+ private Command oneRtuStates(Command command) throws Exception{
+ if(command.param != null && command.param instanceof String && !command.param.equals("")){
+ String rtuAddr = (String)command.param;
+ RtuStatus rtuStatus = new RtuStatusDeal().dealOne(rtuAddr) ;
+ return ReturnCommand.successed("鏌ヨ閮ㄥ垎RTU鐘舵�佺粨鏋�", command.getId(), command.getCode(), rtuStatus) ;
+ }else{
+ return ReturnCommand.errored("鍑洪敊锛屽懡浠ゅ弬鏁板簲璇ユ槸鎵�鏌ヨRTU鐨勫湴鍧�", command.getId(), command.getCode()) ;
+ }
+ }
+
+ /**
* 鏌ヨ鎵�鏈塕TU鍗忚閰嶇疆
* @throws Exception
*/
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/local/localProtocol/CodeLocal.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/local/localProtocol/CodeLocal.java
index 02a1783..9337b04 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/local/localProtocol/CodeLocal.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/local/localProtocol/CodeLocal.java
@@ -14,6 +14,8 @@
public static final String partRtuStates = "LCD0011" ;//鏌ヨ閮ㄥ垎RTU鐘舵��
+ public static final String oneRtuStates = "LCD0012" ;//鏌ヨ涓�涓猂TU鐘舵��
+
public static final String allProtocols = "LCD0100" ;//鏌ヨ鎵�鏈夊崗璁厤缃�
public static final String stopTcpSv = "LCD0110" ;//鍋滄TCP鏈嶅姟锛屼笉鍐嶆帴鍏ユ柊鐨凾CP杩炴帴锛屽凡缁廡CP杩炴帴鐨勫叏閮ㄦ柇杩炴帴
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/local/localProtocol/RtuStatusDeal.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/local/localProtocol/RtuStatusDeal.java
index 7103e28..d5c23c7 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/local/localProtocol/RtuStatusDeal.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/local/localProtocol/RtuStatusDeal.java
@@ -12,7 +12,7 @@
public class RtuStatusDeal {
/**
- * 鏌ヨ鍦ㄧ嚎涓庝笉鍦ㄧ嚎鎯呭喌
+ * 鏌ヨ鐘舵��
*/
public Map<String, RtuStatus> dealAll(){
return RtuStatusDealer.allStatus();
@@ -20,9 +20,18 @@
/**
- * 鏌ヨ鍦ㄧ嚎涓庝笉鍦ㄧ嚎鎯呭喌
+ * 鏌ヨ鐘舵��
*/
- public Map<String, RtuStatus> dealPart(String[] rtuAddrGrp){
- return RtuStatusDealer.partStatus(rtuAddrGrp) ;
+ public Map<String, RtuStatus> dealSome(String[] rtuAddrGrp){
+ return RtuStatusDealer.someStatus(rtuAddrGrp) ;
+ }
+
+
+
+ /**
+ * 鏌ヨ鐘舵��
+ */
+ public RtuStatus dealOne(String rtuAddr){
+ return RtuStatusDealer.oneStatus(rtuAddr) ;
}
}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/protocolDriver/RtuInfoNotify.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/rtuStatus/RtuInfoNotify.java
similarity index 96%
rename from pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/protocolDriver/RtuInfoNotify.java
rename to pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/rtuStatus/RtuInfoNotify.java
index b22a455..9edb6ee 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/protocolDriver/RtuInfoNotify.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/rtuStatus/RtuInfoNotify.java
@@ -1,4 +1,4 @@
-package com.dy.rtuMw.server.protocolDriver;
+package com.dy.rtuMw.server.rtuStatus;
import com.dy.common.mw.protocol.Notify;
import com.dy.common.mw.protocol.NotifyInfo;
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java
index 2a4f64c..b96b485 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java
@@ -165,15 +165,17 @@
* 鎺ユ敹web绯荤粺鍙戞潵寮哄埗缁撴潫鍗囩骇浠诲姟
* @return
*/
- @GetMapping(path = "ugForceOver", consumes = MediaType.APPLICATION_JSON_VALUE)
+ @GetMapping(path = "ugForceOver")
public BaseResponse<String> ugForceOver() {
log.info("鏀跺埌鍋滄RTU鍗囩骇浠诲姟鍛戒护") ;
try{
String mes = UpgradeUnit.getInstance().forceOverUpgradeTask();
if(mes == null){
mes = "鍋滄鍗囩骇浠诲姟鎴愬姛" ;
+ return BaseResponseUtils.buildResult(ResultCodeMsg.RsCode.SUCCESS_CODE, mes, mes);
+ }else{
+ return BaseResponseUtils.buildResult(ResultCodeMsg.RsCode.FAIL_CODE, mes, mes);
}
- return BaseResponseUtils.buildResult(ResultCodeMsg.RsCode.SUCCESS_CODE, mes, mes);
}catch (Exception e){
log.error("鍋滄RTU鍗囩骇浠诲姟鏃跺彂鐢熷紓甯�", e);
return BaseResponseUtils.buildError("鍋滄RTU鍗囩骇浠诲姟鏃跺彂鐢熷紓甯�" + (e.getMessage() == null?"":("锛�" + e.getMessage())));
@@ -207,24 +209,10 @@
//閫氫俊涓棿浠跺唴閮ㄥ懡浠わ紝渚嬪鏌ヨ鐩戞帶涓棿浠舵椂閽燂紝鏌ヨRTU鍦ㄧ嚎鎯呭喌绛�
try{
Command reCom = new CommandInnerDeaLer().deal(com) ;
- /*
- boolean error = false ;
- if(reCom.param != null && reCom.param != null){
- CommandBackParam cbp = (CommandBackParam)reCom.param ;
- if(cbp.getSuccess() != null && !cbp.getSuccess().booleanValue()){
- error = true ;
- return BaseResponseUtils.buildError(ReturnCommand.errored(cbp.getMessage(), com.getId(), null));
- }
- }
- if(!error){
- return BaseResponseUtils.buildError(ReturnCommand.errored(cbp.getMessage(), com.getId(), null));
- }
- */
return BaseResponseUtils.buildSuccess(reCom);
}catch(Exception e){
return BaseResponseUtils.buildError(ReturnCommand.errored("澶勭悊鍐呴儴鍛戒护鍑洪敊" + (e.getMessage() == null?"":("锛�" + e.getMessage())), com.getId(), com.getCode()) );
}
-
}else if(commandType.equals(CommandType.outerCommand)){
//鍙戝悜RTU鐨勫閮ㄥ懡浠わ紝寮傛澶勭悊锛寃eb绔痡roups鎴愬憳鍚屾寰楀埌鍛戒护澶勭悊缁撴灉锛屼絾鏋勯�犲懡浠ゅ強涓嬪彂鍛戒护鍜屽懡浠ょ粨鏋滄帴鏀惰寮傛寰楀埌
try{
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 a618170..146c7c0 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
@@ -144,7 +144,12 @@
BaseResponse res = sendGetRequest2Mw(restTemplate, rqUrl) ;
if(res != null){
if(res.isSuccess()){
- return BaseResponseUtils.buildSuccess(true) ;
+ RtuUpgradeStateReceiverCtrl.afterMwForceOverCurUgTask();
+ String msg = res.getContent()==null?null:(String)res.getContent() ;
+ if(msg == null){
+ msg = res.getMsg() ;
+ }
+ return BaseResponseUtils.buildResult(ResultCodeMsg.RsCode.SUCCESS_CODE, msg, msg) ;
}else{
String msg = res.getContent()==null?null:(String)res.getContent() ;
if(msg == null){
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 9a8f18f..37a7fee 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
@@ -42,6 +42,13 @@
private RtuUpgradeSv sv ;
/**
+ * 寮哄埗缁撴潫鍗囩骇浠诲姟閫氫俊涓棿浠舵垚鍔熸墽琛屽悗
+ */
+ public static void afterMwForceOverCurUgTask(){
+ cache = null ;
+ }
+
+ /**
* rtu杩滅▼鍗囩骇浠诲姟閫氫俊涓棿浠舵墽琛屾儏鍐电粺璁″洖鏀�
* @param info 鏁版嵁
* @return 鎿嶄綔缁撴灉
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/cardOperate/CardOperateSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/cardOperate/CardOperateSv.java
index 31e7ab8..b144bb3 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/cardOperate/CardOperateSv.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/cardOperate/CardOperateSv.java
@@ -416,30 +416,57 @@
for (int i = list.size()-1; i >= 0 ; i--) {
Optional.ofNullable(list.get(i).getGift()).orElse(0d);
if (!list.get(i).getGift().equals(0d)){
- Double gift1 = list.get(i).getGift();
- String districtTitle = list.get(i).getDistrictTitle();
- String clientNum = list.get(i).getClientNum();
- String clientName = list.get(i).getClientName();
- String phone = list.get(i).getPhone();
- Date tradeTime = list.get(i).getTradeTime();
+ Double gift1 = list.get(i).getGift();//璧犻�侀噾棰�
+ String districtTitle = list.get(i).getDistrictTitle();//鍦板潃
+ String clientNum = list.get(i).getClientNum();//鍐滄埛缂栧彿
+ String clientName = list.get(i).getClientName();//鍐滄埛濮撳悕
+ String phone = list.get(i).getPhone();//鎵嬫満鍙�
+ Date tradeTime = list.get(i).getTradeTime();//浜ゆ槗鏃堕棿
+ String orderNumber = list.get(i).getOrderNumber();//璁㈠崟缂栧彿
+ String cardNum = list.get(i).getCardNum();//鍗$紪鍙�
+ String idCard = list.get(i).getIdCard();//韬唤璇�
+ String cashierName = list.get(i).getCashierName();//鎿嶄綔浜�
+ Double money = list.get(i).getMoney();//浣欓
+ Double cardCost1 = list.get(i).getCardCost();//璐崱閲戦
+ Double tradeAmount = list.get(i).getTradeAmount();//浜ゆ槗閲戦
+ Double waterCost1 = list.get(i).getWaterCost();//璐按閲戦
+ Double refundAmount1 = list.get(i).getRefundAmount();//杩斿洖閲戦
+ String paymentName = list.get(i).getPaymentName();//鏀粯鏂瑰紡
+ String operateType = list.get(i).getOperateType();//涓氬姟绫诲瀷
+ String cardState = list.get(i).getCardState();//鍗$姸鎬�
+ Long villageId = list.get(i).getVillageId();//鏉慽d
+ Long cashierId = list.get(i).getCashierId();//鏀堕摱鍛榠d
list.get(i).setGift(0d);
+ list.get(i).setMoney(money-gift1);
VoTradeDetails voTradeDetail = new VoTradeDetails();
- voTradeDetail.setDistrictTitle(districtTitle);
- voTradeDetail.setClientNum(clientNum);
- voTradeDetail.setClientName(clientName);
- voTradeDetail.setPhone(phone);
- voTradeDetail.setOperateType("璧犻��");
- voTradeDetail.setTradeTime(tradeTime);
- voTradeDetail.setWaterCost(0d);
- voTradeDetail.setCardCost(0d);
- voTradeDetail.setGift(gift1);
+ voTradeDetail.setDistrictTitle(districtTitle);//2
+ voTradeDetail.setClientNum(clientNum);//2
+ voTradeDetail.setClientName(clientName);//2
+ voTradeDetail.setPhone(phone);//2
+ voTradeDetail.setOperateType("璧犻��");//2
+ voTradeDetail.setTradeTime(tradeTime);//2
+ voTradeDetail.setWaterCost(0d);//2
+ voTradeDetail.setCardCost(0d);//2
+ voTradeDetail.setGift(gift1);//2
+ voTradeDetail.setTradeAmount(0d);//2
+ voTradeDetail.setRefundAmount(refundAmount1);//2
+ voTradeDetail.setMoney(money);//寰�2
+ voTradeDetail.setPaymentName("璧犻��");//2
+ voTradeDetail.setOrderNumber(orderNumber);//2
+ voTradeDetail.setCardNum(cardNum);//2
+ voTradeDetail.setIdCard(idCard);//2
+ voTradeDetail.setCashierName(cashierName);//2
+ voTradeDetail.setCashierId(cashierId);//2
+ voTradeDetail.setCardState(cardState);//2
+ voTradeDetail.setVillageId(villageId);//2
list.add(voTradeDetail);
itemTotal = itemTotal + 1;
}
}
+ list.sort(Comparator.comparing(VoTradeDetails::getTradeTime));
rsVo.obj = list;
rsVo.calculateAndSet(itemTotal, params);
--
Gitblit v1.8.0