From c1ddfd71223c1a7d704b6f21b669fbfcb37adc82 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期六, 18 十一月 2023 21:11:56 +0800
Subject: [PATCH] 实现了通信中间件基础代码
---
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/OnLineV1_0_1.java | 42
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreConstantThread.java | 64
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationScan.java | 280 +
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/MidResultActionError.java | 26
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/PrefixedDataAvailableHandle.java | 21
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/TcpUnit.java | 137
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/rmi/RmiFrameWorkImpl.java | 76
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/rtuStatus/StDownData.java | 8
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/rmi/RmiRequestCallback.java | 21
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/resource/rtuLog/RtuLogManager.java | 242 +
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/resources/application.yml | 18
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreUnitAdapter.java | 11
pipIrr-platform/pipIrr-web/pipIrr-web.iml | 39
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/RtuUpTask.java | 193 +
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationOnLine.java | 23
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/DataCd03Vo.java | 78
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/resource/ResourceUnitConfigVo.java | 27
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationPrefixedDataAvailableVo.java | 45
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/AsciiPic.java | 91
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/pom.xml | 30
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/RtuStatusDealer.java | 146
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/ParseParamsForUpV1_0_1.java | 51
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/PipIrrMwAcceptApplication.java | 36
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/DataCd01Vo.java | 133
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/MidResultActionToRtu.java | 25
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/CodeParse.java | 12
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/support/SupportUnitConfigVo.java | 34
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/UnitStartedCallbackInterface.java | 10
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/Callback.java | 8
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreTask.java | 12
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/aepRtuStatus/OnOffLineVo.java | 87
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/TcpIoSessionAttrIdIsRtuAddr.java | 11
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/DataV1_0_1.java | 136
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationPrefixedDataAvailable.java | 33
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/OnLine.java | 36
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/resource/ResourceUnitAdapter.java | 9
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/parse/Cd_01_Up.java | 168
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/ToRtuConstantTask.java | 93
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/CommandType.java | 22
pipIrr-platform/pipIrr-mw/pom.xml | 30
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/PrefixedDataAvailableHandleImp.java | 165
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/UnitInterface.java | 22
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ClassScan.java | 90
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/mvnw | 308 +
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/mvnw.cmd | 205 +
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ThreadJob.java | 29
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationOnLineVo.java | 31
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/CreateRandom.java | 121
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/DataCodecFactory.java | 23
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpSessionCach.java | 202 +
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Driver.java | 176 +
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/CRC16.java | 126
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpSession.java | 12
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/TcpIoHandler.java | 82
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/CommandBackParam.java | 41
pipIrr-platform/pipIrr-web/pom.xml | 30
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/CodeV1_0_1.java | 35
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/support/SupportUnitAdapter.java | 8
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/PrefixedDataAvailablePool.java | 59
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/TcpIoSessionEventCallback.java | 32
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/rmi/RmiFrameWork.java | 31
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/PrefixedDataAvailableV1_0_1.java | 125
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/parse/Cd_0405_Up.java | 88
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/CodeParseParams.java | 7
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/ProtocolUnit.java | 93
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/CRC8_for_2_0.java | 21
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/PrefixedDataAvailable.java | 37
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/DataCd0405Vo.java | 81
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/rtuStatus/StPumpStatus.java | 9
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreUnit.java | 119
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/resources/log4j2.yml | 73
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationCodeUp.java | 17
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/RtuLogDealer.java | 34
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/DateTime.java | 1636 +++++++++
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Data4Temp.java | 28
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/.mvn/wrapper/maven-wrapper.jar | 0
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpDownCommandCach.java | 129
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/rmi/RmiUnit.java | 103
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/test/java/com/dy/aceMw/PipIrrMwAcceptApplicationTests.java | 13
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/parse/Cd_06_Down.java | 117
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/CommonV1_0_1.java | 166
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreUnitConfigVo.java | 9
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/support/SupportUnit.java | 112
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/RtuSessionStatus.java | 10
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/DriverV1_0_1.java | 188 +
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/ProtocolConstantV1_0_1.java | 54
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/rtuStatus/StOnOffLine.java | 11
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/parse/Cd_03_Up.java | 124
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/TcpUnitAdapter.java | 26
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/MidResult.java | 7
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/MidResultFromRtu.java | 38
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpIoSessionCallback.java | 81
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/MidResultAction.java | 11
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/UnitAdapterInterface.java | 9
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationCodeDown.java | 18
pipIrr-platform/pipIrr-common/pom.xml | 16
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/parse/Cd_XY_Down.java | 126
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/rtuStatus/StUpData.java | 10
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/ServerProperties.java | 30
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/DriverParserDataCallback.java | 26
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/rtuStatus/RtuStatuz.java | 10
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/MidResultError.java | 32
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/rmi/RmiClient.java | 37
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/ProtocolConstant.java | 25
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/resource/rtuLog/RtuLogNode.java | 14
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/resources/config.xml | 133
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/rmi/RmiConfigVo.java | 12
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/OnLinePool.java | 58
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/CodeParseCallback.java | 12
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Data.java | 144
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/ProtocolConfigVo.java | 11
pipIrr-platform/pipIrr-mw/pipIrr-mw.iml | 39
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Command.java | 269 +
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/rtuStatus/StCommandResult.java | 10
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/.gitignore | 33
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreThread.java | 72
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/RtuDownTask.java | 69
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/说明.txt | 0
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/resource/ResourceUnit.java | 150
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/DataEncoder.java | 19
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationDriverVo.java | 11
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationDriver.java | 12
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/MidResultActionFromRtu.java | 57
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpDownCommandObj.java | 98
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/parse/Cd_06_Up.java | 120
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/MidResultToRtu.java | 41
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/ParseParamsForDownV1_0_1.java | 52
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/DataCd02Vo.java | 94
pipIrr-platform/pipIrr-common/pipIrr-common.iml | 2
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/DataCd06Vo.java | 41
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/PrefixedDataAvailableStatus.java | 105
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/TcpConfigVo.java | 9
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/OnLineHandle.java | 76
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/DataDecoder.java | 144
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/resources/application-database.yml | 8
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/rmi/RmiUnitAdapter.java | 19
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/ProtocolUnitAdapter.java | 30
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/parse/Cd_02_Up.java | 136
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/ProtocolCach.java | 86
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/.mvn/wrapper/maven-wrapper.properties | 2
140 files changed, 10,410 insertions(+), 76 deletions(-)
diff --git a/pipIrr-platform/pipIrr-common/pipIrr-common.iml b/pipIrr-platform/pipIrr-common/pipIrr-common.iml
index cfc160c..bfdde8c 100644
--- a/pipIrr-platform/pipIrr-common/pipIrr-common.iml
+++ b/pipIrr-platform/pipIrr-common/pipIrr-common.iml
@@ -104,5 +104,7 @@
<orderEntry type="library" name="Maven: com.alibaba.fastjson2:fastjson2-extension:2.0.40" level="project" />
<orderEntry type="library" name="Maven: org.jdom:jdom2:2.0.6.1" level="project" />
<orderEntry type="library" name="Maven: cn.hutool:hutool-all:5.8.21" level="project" />
+ <orderEntry type="library" name="Maven: org.apache.mina:mina-core:2.2.1" level="project" />
+ <orderEntry type="library" name="Maven: org.quartz-scheduler:quartz-weblogic:2.1.7" level="project" />
</component>
</module>
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-common/pom.xml b/pipIrr-platform/pipIrr-common/pom.xml
index 19db807..d645758 100644
--- a/pipIrr-platform/pipIrr-common/pom.xml
+++ b/pipIrr-platform/pipIrr-common/pom.xml
@@ -109,6 +109,22 @@
<artifactId>jdom2</artifactId>
</dependency>
+ <!-- apache mina -->
+ <dependency>
+ <groupId>org.apache.mina</groupId>
+ <artifactId>mina-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.mina</groupId>
+ <artifactId>mina-filter-compression</artifactId>
+ </dependency>
+
+ <!-- quartz -->
+ <dependency>
+ <groupId>org.quartz-scheduler</groupId>
+ <artifactId>quartz</artifactId>
+ </dependency>
+
<!-- Hutool鏄竴涓皬鑰屽叏鐨凧ava宸ュ叿绫诲簱(https://github.com/dromara/hutool) -->
<dependency>
<groupId>cn.hutool</groupId>
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/UnitAdapterInterface.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/UnitAdapterInterface.java
new file mode 100644
index 0000000..5a03972
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/UnitAdapterInterface.java
@@ -0,0 +1,9 @@
+package com.dy.common.mw;
+
+
+/**
+ * 妯″潡鍗曞厓閫傞厤鍣ㄦ帴鍙�
+ *
+ */
+public interface UnitAdapterInterface {
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/UnitInterface.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/UnitInterface.java
new file mode 100644
index 0000000..95ee7c0
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/UnitInterface.java
@@ -0,0 +1,22 @@
+package com.dy.common.mw;
+
+/**
+ * 妯″潡鍗曞厓鎺ュ彛
+ *
+ */
+public interface UnitInterface {
+ /**
+ * 璁剧疆閫傞厤鍣�
+ * @throws Exception
+ */
+ public void setAdapter(UnitAdapterInterface adapter) throws Exception ;
+ /**
+ * 鍚姩妯″潡
+ */
+ public void start(UnitStartedCallbackInterface callback) throws Exception ;
+ /**
+ * 鍋滄妯″潡杩愯
+ */
+ public void stop(UnitStartedCallbackInterface callback) throws Exception ;
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/UnitStartedCallbackInterface.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/UnitStartedCallbackInterface.java
new file mode 100644
index 0000000..0b2e44a
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/UnitStartedCallbackInterface.java
@@ -0,0 +1,10 @@
+package com.dy.common.mw;
+
+public interface UnitStartedCallbackInterface {
+ /**
+ * 妯″潡鍚姩鍚庡洖璋�
+ * @param obj
+ * @throws Exception
+ */
+ void call(Object obj) throws Exception ;
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/rmi/RmiClient.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/rmi/RmiClient.java
new file mode 100644
index 0000000..3209d4f
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/rmi/RmiClient.java
@@ -0,0 +1,37 @@
+package com.dy.common.mw.channel.rmi;
+
+import java.rmi.Naming;
+import org.apache.logging.log4j.* ;
+
+public class RmiClient {
+
+ private static Logger log = LogManager.getLogger(RmiClient.class.getName()) ;
+
+ private String rmiServerIp;
+ private Integer rmiServerPort;
+ private String rmiServerContext ;
+
+ public RmiClient(String rmiServerIp, Integer rmiServerPort, String rmiServerContext){
+ this.rmiServerIp = rmiServerIp ;
+ this.rmiServerPort = rmiServerPort ;
+ this.rmiServerContext = rmiServerContext ;
+ }
+
+ /**
+ * 寰楀埌涓棿浠禦MI
+ * @return
+ */
+ @SuppressWarnings("finally")
+ public RmiFrameWork getRmiInterface() {
+ String rmiServerUrl = "rmi://" + this.rmiServerIp + ":" + this.rmiServerPort + "/" + this.rmiServerContext ;
+ RmiFrameWork rmiIntf = null;
+ try {
+ rmiIntf = (RmiFrameWork) Naming.lookup(rmiServerUrl);
+ } catch (Exception e) {
+ log.error("杩炴帴RMI鏈嶅姟锛�" + rmiServerUrl + "鏃跺嚭閿欍��", e);
+ } finally {
+ return rmiIntf;
+ }
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/rmi/RmiConfigVo.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/rmi/RmiConfigVo.java
new file mode 100644
index 0000000..4eea7c7
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/rmi/RmiConfigVo.java
@@ -0,0 +1,12 @@
+package com.dy.common.mw.channel.rmi;
+
+public class RmiConfigVo {
+
+ public boolean enable ;//鏄惁鍚姩
+
+ public Integer port ; //绔彛鍙�
+ //RMI閫氫俊 锛宲ort銆乧ontext = localUnit 涓庝腑蹇冪郴缁熶腑閰嶇疆涓�鑷�
+ public String context ;
+
+ public Boolean showStartInfo; //鏄惁鍦ㄦ帶鍒跺彴涓婃樉绀轰俊鎭�
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/rmi/RmiFrameWork.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/rmi/RmiFrameWork.java
new file mode 100644
index 0000000..8aee140
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/rmi/RmiFrameWork.java
@@ -0,0 +1,31 @@
+package com.dy.common.mw.channel.rmi;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+public interface RmiFrameWork extends Remote {
+
+ /**
+ * 鍏抽棴鏈嶅姟鐨勮姹�
+ * @return
+ * @throws RemoteException
+ */
+ String shutRequest() throws RemoteException;
+
+ /**
+ * 寮傛璇锋眰
+ * @param command 鍛戒护
+ * @return 鍛戒护缁撴灉鐨処D锛屽鏋滀负绌猴紝鍒欒鏄庡嚭閿�
+ * @throws RemoteException
+ */
+ String asyncRequest(Object command) throws RemoteException;
+
+ /**
+ * 鍚屾璇锋眰
+ * @param command 鍛戒护
+ * @return
+ * @throws RemoteException
+ */
+ Object syncRequest(Object command) throws RemoteException;
+}
+
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/rmi/RmiFrameWorkImpl.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/rmi/RmiFrameWorkImpl.java
new file mode 100644
index 0000000..83201a5
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/rmi/RmiFrameWorkImpl.java
@@ -0,0 +1,76 @@
+package com.dy.common.mw.channel.rmi;
+
+import java.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
+
+import com.dy.common.threadPool.ThreadPool;
+import com.dy.common.threadPool.TreadPoolFactory;
+
+public class RmiFrameWorkImpl extends UnicastRemoteObject implements RmiFrameWork {
+
+ private static final long serialVersionUID = 201807220009001L;
+
+ private RmiUnitAdapter adapter ;
+ /**
+ * 鏋勯�犳柟娉�
+ * @throws RemoteException
+ */
+ protected RmiFrameWorkImpl(RmiUnitAdapter adapter) throws RemoteException {
+ super();
+ this.adapter = adapter ;
+ }
+
+ /**
+ * 鍚屾璇锋眰
+ * @param in
+ * @return 杩斿洖鍛戒护缁撴灉
+ * @throws RemoteException
+ */
+ @Override
+ public Object syncRequest(Object obj) throws RemoteException {
+ if(obj == null){
+ throw new RemoteException("涓ラ噸閿欒锛岃緭鍏ュ懡浠ゅ弬鏁颁负绌猴紒") ;
+ }
+ return adapter.newRequestCallback().syncRequest(obj) ;
+ }
+
+ /**
+ * 寮傛璇锋眰
+ * @param command
+ * @return 鍛戒护缁撴灉鐨処D锛屽鏋滀负绌猴紝鍒欒鏄庨偖閿�
+ * @throws RemoteException
+ */
+ @Override
+ public String asyncRequest(Object obj) throws RemoteException {
+ try {
+ TreadPoolFactory.getThreadPoolShort().putJob(new ThreadPool.Job() {
+ public void execute() throws RemoteException {
+ throw new RemoteException("姝ゆ柟娉曟湭瀹炵幇") ;
+ }
+ @Override
+ public void destroy() {
+ }
+ @Override
+ public boolean isDestroy() {
+ return false;
+ }
+
+ });
+ }catch (RemoteException ee) {
+ throw ee ;
+ }catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ /**
+ * 鍏抽棴鏈嶅姟鐨勮姹�
+ */
+ @Override
+ public String shutRequest() throws RemoteException {
+ throw new RemoteException("姝ゆ柟娉曟湭瀹炵幇") ;
+ }
+
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/rmi/RmiRequestCallback.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/rmi/RmiRequestCallback.java
new file mode 100644
index 0000000..af1efb0
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/rmi/RmiRequestCallback.java
@@ -0,0 +1,21 @@
+package com.dy.common.mw.channel.rmi;
+
+import java.rmi.RemoteException;
+
+public interface RmiRequestCallback {
+ /**
+ * 鍚屾璇锋眰
+ * @param obj 璇锋眰鎻愪氦瀵硅薄
+ * @return 杩斿洖鍛戒护缁撴灉
+ * @throws RemoteException
+ */
+ Object syncRequest(Object obj) throws RemoteException ;
+
+ /**
+ * 寮傛璇锋眰
+ * @param obj 璇锋眰鎻愪氦瀵硅薄
+ * @return 鍛戒护缁撴灉鐨処D锛屽鏋滀负绌猴紝鍒欒鏄庨偖閿�
+ * @throws RemoteException
+ */
+ String asyncRequest(Object obj) throws RemoteException ;
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/rmi/RmiUnit.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/rmi/RmiUnit.java
new file mode 100644
index 0000000..3debe95
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/rmi/RmiUnit.java
@@ -0,0 +1,103 @@
+package com.dy.common.mw.channel.rmi;
+
+import java.io.IOException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.rmi.server.UnicastRemoteObject;
+
+import com.dy.common.mw.UnitAdapterInterface;
+import com.dy.common.mw.UnitInterface;
+import com.dy.common.mw.UnitStartedCallbackInterface;
+
+public class RmiUnit implements UnitInterface {
+
+ private static RmiUnit instance = new RmiUnit() ;
+ private static boolean started = false ;
+
+ private static RmiUnitAdapter adapter ;
+
+ private static RmiFrameWork rmiFrm = null ;
+
+
+ private RmiUnit(){} ;
+
+ public static RmiUnit getInstance(){
+ return instance ;
+ }
+
+
+ @Override
+ public void setAdapter(UnitAdapterInterface adapter) throws Exception {
+ if(adapter == null){
+ throw new Exception("Rmi妯″潡閫傞厤鍣ㄥ璞′笉鑳戒负绌猴紒") ;
+ }
+ RmiUnit.adapter = (RmiUnitAdapter)adapter ;
+ RmiConfigVo vo = RmiUnit.adapter.getConfig() ;
+ if(vo == null){
+ throw new Exception("Rmi妯″潡灞炴�ч厤缃璞′笉鑳戒负绌猴紒") ;
+ }
+ if(vo.port == null){
+ throw new Exception("Rmi妯″潡port灞炴�у�间笉鑳戒负绌猴紒") ;
+ }
+ if(vo.context == null || vo.context.trim().equals("")){
+ throw new Exception("Rmi妯″潡context灞炴�у�间笉鑳戒负绌猴紒") ;
+ }
+ }
+ /**
+ * 鍚姩妯″潡
+ */
+ public void start(UnitStartedCallbackInterface callback) throws Exception {
+ if(!started){
+ started = true ;
+
+ RmiConfigVo vo = RmiUnit.adapter.getConfig() ;
+
+ boolean isException = false ;
+ try {
+
+ //鏀瑰眬鍩熷彉閲忎负闈欐�佸叏灞�鍙橀噺锛岄槻姝㈠眬鍩熷彉閲忓湪鏃犲紩鐢ㄦ椂琚瀮鍦惧洖鏀讹紝浠庤�屽鎴风寰椾笉鍒癛MI鏈嶅姟绔�
+ if(rmiFrm == null){
+ rmiFrm = new RmiFrameWorkImpl(RmiUnit.adapter);
+ }
+
+ //杩炴帴鍒版湰鍦癑NDI
+ Registry registry = LocateRegistry.createRegistry(vo.port);
+
+ //瑙i櫎娉ㄥ唽
+ UnicastRemoteObject.unexportObject(rmiFrm, true);
+
+ //娉ㄥ唽
+ registry.bind(vo.context, UnicastRemoteObject.exportObject(rmiFrm, 0));
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ System.out.println("Rmi閫氫俊妯″潡鍚姩澶辫触锛�");
+ isException = true ;
+ }finally{
+ ;
+ }
+
+ if(!isException){
+ if(vo.showStartInfo != null && vo.showStartInfo.booleanValue()){
+ System.out.println("Rmi妯″潡鎴愬姛鍚姩锛岀鍙o細" + vo.port + "锛屼笂涓嬫枃涓猴細" + vo.context );
+ }
+ }
+ callback.call(null);
+ }
+ }
+
+ @Override
+ public void stop(UnitStartedCallbackInterface callback) throws Exception {
+ }
+
+
+ public static boolean isStarted() {
+ return started;
+ }
+
+ public RmiUnitAdapter getAdapter() {
+ return adapter;
+ }
+
+
+}
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/rmi/RmiUnitAdapter.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/rmi/RmiUnitAdapter.java
new file mode 100644
index 0000000..311f796
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/rmi/RmiUnitAdapter.java
@@ -0,0 +1,19 @@
+package com.dy.common.mw.channel.rmi;
+
+import com.dy.common.mw.UnitAdapterInterface;
+
+public interface RmiUnitAdapter extends UnitAdapterInterface {
+
+ /**
+ * 寰楀埌閰嶇疆
+ * @return RmiConfigVo
+ */
+ RmiConfigVo getConfig() ;
+
+ /**
+ * 鎵�浠ユ澶勫緱鍒癛miRequestCallback涓嶈兘鏄崟渚嬶紝
+ * @return RmiRequestCallback
+ */
+ RmiRequestCallback newRequestCallback() ;
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/DataCodecFactory.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/DataCodecFactory.java
new file mode 100644
index 0000000..417bda2
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/DataCodecFactory.java
@@ -0,0 +1,23 @@
+package com.dy.common.mw.channel.tcp;
+
+import org.apache.mina.filter.codec.ProtocolCodecFactory;
+import org.apache.mina.filter.codec.ProtocolEncoder;
+import org.apache.mina.filter.codec.ProtocolDecoder;
+import org.apache.mina.core.session.IoSession;
+
+public class DataCodecFactory implements ProtocolCodecFactory {
+
+ private TcpUnitAdapter adapter ;
+
+ public DataCodecFactory(TcpUnitAdapter adapter) {
+ this.adapter = adapter ;
+ }
+
+ public ProtocolEncoder getEncoder(IoSession ioSession) {
+ return new DataEncoder();
+ }
+
+ public ProtocolDecoder getDecoder(IoSession ioSession) {
+ return new DataDecoder(adapter.newPrefixedDataAvailableHandle());
+ }
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/DataDecoder.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/DataDecoder.java
new file mode 100644
index 0000000..28720a5
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/DataDecoder.java
@@ -0,0 +1,144 @@
+package com.dy.common.mw.channel.tcp;
+
+import com.dy.common.util.ByteUtil;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.mina.filter.codec.CumulativeProtocolDecoder;
+import org.apache.mina.filter.codec.ProtocolDecoderOutput;
+import org.apache.mina.core.buffer.* ;
+import org.apache.mina.core.session.IoSession;
+
+
+public class DataDecoder extends CumulativeProtocolDecoder {
+
+ private static final Logger log = LogManager.getLogger(DataDecoder.class) ;
+
+ protected PrefixedDataAvailableHandle pdaHandle ;
+
+ public DataDecoder(PrefixedDataAvailableHandle pdaHandle) {
+ this.pdaHandle = pdaHandle ;
+ }
+
+ /**
+ * 瑙g爜
+ * (non-Javadoc)
+ * @see org.apache.mina.filter.codec.CumulativeProtocolDecoder#doDecode(
+ * org.apache.mina.core.session.IoSession,
+ * org.apache.mina.core.buffer.IoBuffer,
+ * org.apache.mina.filter.codec.ProtocolDecoderOutput)
+ */
+ protected boolean doDecode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) {
+ String meterNo = (String)session.getAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrIdKey) ;
+ if(meterNo == null){
+ //浼氳瘽鏈绠$悊
+ //浼氳瘽绠$悊鍣ㄤ腑涓嶅瓨鍦ㄦ浼氳瘽锛岃鏄庡垰寤虹珛缃戠粶杩炴帴锛�
+ return this.doDecode_onLineData(session, in, out) ;
+ }else{
+ //浼氳瘽宸茶绠$悊
+ //浼氳瘽绠$悊鍣ㄤ腑瀛樺湪姝や細璇濓紝璇存槑宸茬粡涓婄嚎浜嗭紝
+ return this.doDecode_data(session, in, out, meterNo) ;
+ }
+ }
+
+ /**
+ * 閽堝缃戠粶杩炴帴鎴愬姛鍚庣涓�鍖呮暟鎹�
+ * @param session IO浼氳瘽
+ * @param in 杈撳叆Buffer
+ * @param out 鍗忚杈撳嚭缂栫爜
+ * @return 鏄惁姝eソ鎴栫矘鍖�
+ */
+ @SuppressWarnings("unused")
+ private boolean doDecode_onLineData(IoSession session, IoBuffer in, ProtocolDecoderOutput out){
+ //鏈変竴浜涘崗璁紝璐熻矗鍙戜笂绾挎暟鎹紝浣嗕笂绾�(鎴栧績璺�)鏁版嵁涓棤 Rtu鍦板潃锛屾墍浠ヨ繖鏍风殑鏁版嵁鍙兘鏀捐锛岃�屼笖涓嶈兘浜х敓鏈夎韩浠�(Rtu鍦板潃)鐨勭綉缁滀細璇濓紝鍗充笉鑳芥妸session鏀惧叆浼氳瘽缂撳瓨涓�
+ //鏈変竴浜涘崗璁紝Rtu璐熻矗鍙戜笂绾挎暟鎹紝涓婄嚎鏁版嵁涓湁 Rtu鍦板潃锛屾墍浠ヨ繖鏍风殑鏁版嵁鏀捐鍚庯紝鑳戒骇鐢熸湁韬唤(Rtu鍦板潃)鐨勭綉缁滀細璇濓紝鍗宠兘鎶妔ession鏀惧叆浼氳瘽缂撳瓨涓�
+ //涓嶈浣曠鎯呭舰锛屼笂绾挎暟鎹殑鏁版嵁閲忎笉浼氬緢澶э紝涓�鑸笉浼氫骇鐢熸柇鍖咃紝鎵�浠ヨ繖閲屽彧杩涜绠�鍗曟柇鍖呮鏌ャ��
+ PrefixedDataAvailableStatus dataStatus = this.pdaHandle.forOnLine(in) ;
+ if(dataStatus.isCompleted() || dataStatus.isAdjoined()){
+ //姝eソ鎴栫矘鍖�
+ this.nextDeal(in, dataStatus.getDataLen(), out) ;
+ return true;
+ }else if(dataStatus.isRubbish()){
+ //鍨冨溇鏁版嵁
+ this.dealRubbishData(in, dataStatus.getDataLen()) ;
+ return true ;
+ }else{
+ //鏂寘
+ return false ;
+ }
+ }
+
+
+ /**
+ * 閽堝缃戠粶杩炴帴鎴愬姛鍚庨潪绗竴鍖呮暟鎹�
+ * @param session IO浼氳瘽
+ * @param in 杈撳叆Buffer
+ * @param out 鍗忚杈撳嚭缂栫爜
+ * @param meterNo 鎺у埗鍣ㄧ紪鍙�
+ * @return 鏄惁姝eソ鎴栫矘鍖�
+ */
+ @SuppressWarnings("unused")
+ private boolean doDecode_data(IoSession session, IoBuffer in, ProtocolDecoderOutput out, String meterNo) {
+ //闈炰笂绾挎暟鎹紝鍙兘浼氬嚭鐜版柇鍖呮垨绮樺寘鐜拌薄
+ PrefixedDataAvailableStatus dataStatus = this.pdaHandle.forUpData(in) ;
+ if(dataStatus == null){
+ //涓嶅彲鑳藉彂鐢�
+ log.error("涓ラ噸閿欒锛孯tu (姘磋〃鍙蜂负" + meterNo + ")涓婅鏁版嵁瀹屾暣鎬ф鏌ユ椂锛岃繑鍥炵殑瀵硅薄涓虹┖銆�") ;
+ this.nextDeal(in, null, out) ;
+ return true;
+ }else{
+ if(dataStatus.isBreaked()){
+ //鏂寘浜�
+ return false ;
+ }else if(dataStatus.isCompleted() || dataStatus.isAdjoined()){
+ //鏈寘鏁版嵁宸茬粡鍏ㄩ儴鎺ユ敹锛屽苟涓斿彲鑳界矘鏈変笅鍖呮暟鎹�
+ this.nextDeal(in, dataStatus.getDataLen(), out) ;
+ if(dataStatus.isAdjoined()){
+ //璇存槑绮樺寘浜嗭紝杩樻湁鏁版嵁锛岄渶瑕佸杩欎簺鏁版嵁鍐嶆鎵цdoDecode_鏂规硶.
+ return this.doDecode_data(session, in, out, meterNo) ;//鍔犱笂閫掑綊
+ }else if(dataStatus.isCompleted()){
+ //鏁版嵁涓嶆柇涓嶇矘
+ return true;
+ }else{
+ //涓嶅瓨鍦ㄦ绉嶆儏鍐�
+ return true ;
+ }
+ }else if(dataStatus.isRubbish()){
+ //鍨冨溇鏁版嵁
+ this.dealRubbishData(in, dataStatus.getDataLen()) ;
+ return true ;
+ }else{
+ //涓嶅瓨鍦ㄦ绉嶆儏鍐�
+ return true ;
+ }
+ }
+ }
+
+ /**
+ * 鍚庣画澶勭悊鏁版嵁
+ * @param in IObuffer
+ * @param length 闀垮害
+ * @param out 鍗忚缂栫爜杈撳嚭
+ */
+ private void nextDeal(IoBuffer in, Integer length, ProtocolDecoderOutput out){
+ if(length == null){
+ length = in.limit() ;
+ }
+ if(length > 0){
+ byte[] data = new byte[length];
+ in.get(data);//get涓�涓瓧鑺傦紝鐩稿簲position鍚戝悗绉诲姩涓�涓瓧鑺�
+ out.write(data);
+ }
+ }
+
+ /**
+ * 鍨冨溇鏁版嵁澶勭悊
+ * @param in IObuffer
+ * @param length 闀垮害
+ */
+ @SuppressWarnings("unused")
+ private void dealRubbishData(IoBuffer in, Integer length){
+ byte[] data = new byte[in.limit()];
+ in.get(data);//get涓�涓瓧鑺傦紝鐩稿簲position鍚戝悗绉诲姩涓�涓瓧鑺�
+ log.error("鎶涘純鍨冨溇鏁版嵁锛�" + ByteUtil.bytes2Hex(data, true));
+ }
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/DataEncoder.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/DataEncoder.java
new file mode 100644
index 0000000..bb49da6
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/DataEncoder.java
@@ -0,0 +1,19 @@
+package com.dy.common.mw.channel.tcp;
+
+import org.apache.mina.filter.codec.ProtocolEncoderOutput;
+import org.apache.mina.filter.codec.ProtocolEncoderAdapter;
+import org.apache.mina.core.buffer.IoBuffer;
+import org.apache.mina.core.session.IoSession;
+
+public class DataEncoder extends ProtocolEncoderAdapter {
+
+ //private static Logger log = LogManager.getLogger(DataEncoder.class.getName()) ;
+
+ public void encode(IoSession session, Object message, ProtocolEncoderOutput out){
+ byte[] data = (byte[])message;
+
+ //log.info("涓嬭鏁版嵁锛�" + ByteUtil.bytes2Hex(data, true));
+
+ out.write(IoBuffer.allocate((data==null?0:data.length), false).put(data).flip());
+ }
+ }
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/PrefixedDataAvailableHandle.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/PrefixedDataAvailableHandle.java
new file mode 100644
index 0000000..7fd12f8
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/PrefixedDataAvailableHandle.java
@@ -0,0 +1,21 @@
+package com.dy.common.mw.channel.tcp;
+
+import org.apache.mina.core.buffer.IoBuffer;
+
+public interface PrefixedDataAvailableHandle {
+
+ /**
+ * 棰勫鐞嗕笂绾挎暟鎹�
+ * @param in IoBuffer
+ * @return 鐘舵��
+ */
+ PrefixedDataAvailableStatus forOnLine(IoBuffer in) ;
+
+ /**
+ * 棰勫鐞嗕笂琛屾暟鎹�
+ * @param in IoBuffer
+ * @return 鐘舵��
+ */
+ PrefixedDataAvailableStatus forUpData(IoBuffer in) ;
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/PrefixedDataAvailableStatus.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/PrefixedDataAvailableStatus.java
new file mode 100644
index 0000000..2045a91
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/PrefixedDataAvailableStatus.java
@@ -0,0 +1,105 @@
+package com.dy.common.mw.channel.tcp;
+
+public class PrefixedDataAvailableStatus {
+
+ public final static Integer status_rubbish = 0 ;//鍨冨溇鏁版嵁
+ public final static Integer status_break = 1 ;//鏂寘
+ public final static Integer status_adjoin = 2 ;//绮樺寘
+ public final static Integer status_complete = 3 ;//涓嶆柇涓嶇矘
+
+ private Integer status ;
+ private Integer dataLen ;
+
+ public PrefixedDataAvailableStatus(){
+ status = null ;
+ dataLen = null ;
+ }
+
+ /**
+ * 鍨冨溇鏁版嵁
+ * @param dataLen 鏁版嵁闀垮害
+ * @return 鐘舵��
+ */
+ @SuppressWarnings("unused")
+ public PrefixedDataAvailableStatus rubbish(Integer dataLen){
+ this.status = status_rubbish ;
+ this.dataLen = dataLen ;
+ return this ;
+ }
+
+ /**
+ * 鍙戠敓鏂寘
+ * @return 鐘舵��
+ */
+ @SuppressWarnings("unused")
+ public PrefixedDataAvailableStatus breaked(){
+ this.status = status_break ;
+ this.dataLen = null ;
+ return this ;
+ }
+
+ /**
+ * 鍙戠敓绮樺寘
+ * @param dataLen 鏁版嵁闀垮害
+ * @return 鐘舵��
+ */
+ @SuppressWarnings("unused")
+ public PrefixedDataAvailableStatus adjoined(Integer dataLen){
+ this.status = status_adjoin ;
+ this.dataLen = dataLen ;
+ return this ;
+ }
+
+ /**
+ * 涓嶆柇鍖呬笉绮樺寘锛屾暟鎹濂芥敹鍏�
+ * @param dataLen 鏁版嵁闀垮害
+ * @return 鐘舵��
+ */
+ @SuppressWarnings("unused")
+ public PrefixedDataAvailableStatus completed(Integer dataLen){
+ this.status = status_complete ;
+ this.dataLen = dataLen ;
+ return this ;
+ }
+
+ /**
+ * 鏄惁鍨冨溇鏁版嵁
+ * @return 鐘舵��
+ */
+ public boolean isRubbish(){
+ return this.status.intValue() == status_rubbish.intValue();
+ }
+ /**
+ * 鏄惁鏂寘
+ * @return 鐘舵��
+ */
+ public boolean isBreaked(){
+ return this.status.intValue() == status_break.intValue();
+ }
+
+
+ /**
+ * 鏄惁绮樺寘
+ * @return 鏄惁绮樺寘
+ */
+ public boolean isAdjoined(){
+ return this.status.intValue() == status_adjoin.intValue();
+ }
+
+ /**
+ * 鏄惁涓嶆柇涓嶇矘
+ * @return 鏄惁涓嶆柇涓嶇矘
+ */
+ public boolean isCompleted(){
+ return this.status.intValue() == status_complete.intValue();
+ }
+
+ /**
+ * 杩斿洖鏁版嵁闀垮害
+ * @return 鏁版嵁闀垮害
+ */
+ public Integer getDataLen(){
+ return this.dataLen ;
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/TcpConfigVo.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/TcpConfigVo.java
new file mode 100644
index 0000000..c49f0ae
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/TcpConfigVo.java
@@ -0,0 +1,9 @@
+package com.dy.common.mw.channel.tcp;
+
+public class TcpConfigVo {
+ public boolean enable ;//鏄惁鍚姩
+ public Integer port ; //绔彛鍙�
+ public Integer processors ;//澶勭悊鍣ㄦ暟閲�
+ public Integer idle; //缃戠粶鑱旀帴绌洪棽鏃堕暱
+ public Boolean showStartInfo; //鏄惁鍦ㄦ帶鍒跺彴涓婃樉绀轰俊鎭�
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/TcpIoHandler.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/TcpIoHandler.java
new file mode 100644
index 0000000..695ec8d
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/TcpIoHandler.java
@@ -0,0 +1,82 @@
+package com.dy.common.mw.channel.tcp;
+
+import org.apache.mina.core.service.IoHandlerAdapter;
+import org.apache.mina.core.session.IdleStatus;
+import org.apache.mina.core.session.IoSession;
+
+public class TcpIoHandler extends IoHandlerAdapter {
+
+ private TcpUnitAdapter adapter ;
+
+
+ public TcpIoHandler(TcpUnitAdapter adapter){
+ this.adapter = adapter ;
+ }
+
+ /**
+ * 鍒涘缓浜嗕細璇�
+ */
+ @Override
+ public void sessionCreated(IoSession session) throws Exception {
+ super.sessionCreated(session);
+ }
+
+ /**
+ * 浼氳瘽open鏃跺洖璋冪殑鏂规硶
+ */
+ public void sessionOpened(IoSession session) throws Exception {
+ this.adapter.newSessionEventCallback().sessionOpened(session);
+ }
+
+ /**
+ * 浼氳瘽绌洪棽
+ */
+ @Override
+ public void sessionIdle(IoSession session, IdleStatus status)
+ throws Exception {
+ super.sessionIdle(session, status);
+ }
+
+ /**
+ * 杈撳叆鍏抽棴
+ */
+ @Override
+ public void inputClosed(IoSession session) throws Exception {
+ super.inputClosed(session);
+ }
+
+ /**
+ * 缃戠粶鍏抽棴
+ */
+ @Override
+ public void sessionClosed(IoSession session) throws Exception {
+ this.adapter.newSessionEventCallback().sessionClosed(session);
+ super.sessionClosed(session);
+ }
+
+ /**
+ * 鍙戠敓寮傚父
+ */
+ @Override
+ public void exceptionCaught(IoSession session, Throwable cause) throws Exception {
+ this.adapter.newSessionEventCallback().exceptionCaught(session, cause);
+ }
+
+ /**
+ * 娑堟伅鍙戦�佷簡
+ */
+ @Override
+ public void messageSent(IoSession session, Object message) throws Exception {
+ super.messageSent(session, message);
+ this.adapter.newSessionEventCallback().messageSended(session, message);
+ }
+
+ /**
+ * 鎺ユ敹鍒版暟鎹悗锛屽洖璋冪殑鏂规硶锛岃繘琛屾暟鎹鐞�
+ */
+ @Override
+ public void messageReceived(IoSession session, Object message) throws Exception {
+ this.adapter.newSessionEventCallback().messageReceived(session, message);
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/TcpIoSessionAttrIdIsRtuAddr.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/TcpIoSessionAttrIdIsRtuAddr.java
new file mode 100644
index 0000000..3bd48c5
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/TcpIoSessionAttrIdIsRtuAddr.java
@@ -0,0 +1,11 @@
+package com.dy.common.mw.channel.tcp;
+
+/**
+ * TCP Session涓斁鍏ョ殑灞炴�х殑ID灏辨槸姘磋〃鍙�
+ * 褰撳簲鐢╮tuMw鏃剁敤鍒帮紝搴旂敤aepMw鏃剁敤涓嶅埌
+ *
+ */
+public class TcpIoSessionAttrIdIsRtuAddr {
+
+ public static final String sessionArrIdKey = "key_rtuAddr" ; //杩欎釜key瀛樺偍鐨勬槸IMEI鍙�
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/TcpIoSessionEventCallback.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/TcpIoSessionEventCallback.java
new file mode 100644
index 0000000..e277133
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/TcpIoSessionEventCallback.java
@@ -0,0 +1,32 @@
+package com.dy.common.mw.channel.tcp;
+
+import org.apache.mina.core.session.IoSession;
+
+public interface TcpIoSessionEventCallback {
+
+ /**
+ * 缃戠粶鎵撳紑
+ */
+ void sessionOpened(IoSession session) throws Exception ;
+ /**
+ * 缃戠粶鍏抽棴
+ */
+ void sessionClosed(IoSession session) throws Exception ;
+
+ /**
+ * 鍙戠敓寮傚父
+ */
+ void exceptionCaught(IoSession session, Throwable cause) throws Exception ;
+
+
+ /**
+ * 鍙戦�佹暟鎹悗锛屽洖璋冪殑鏂规硶锛岃繘琛屾暟鎹鐞�
+ */
+ void messageSended(IoSession session, Object message) throws Exception ;
+
+ /**
+ * 鎺ユ敹鍒版暟鎹悗锛屽洖璋冪殑鏂规硶锛岃繘琛屾暟鎹鐞�
+ */
+ void messageReceived(IoSession session, Object message) throws Exception ;
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/TcpUnit.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/TcpUnit.java
new file mode 100644
index 0000000..e0d83d6
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/TcpUnit.java
@@ -0,0 +1,137 @@
+package com.dy.common.mw.channel.tcp;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+
+import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
+import org.apache.mina.core.session.IdleStatus ;
+import org.apache.mina.core.session.IoSession;
+import org.apache.mina.transport.socket.SocketSessionConfig;
+import org.apache.mina.core.filterchain.DefaultIoFilterChainBuilder ;
+import org.apache.mina.filter.codec.ProtocolCodecFilter;
+import org.apache.mina.filter.executor.ExecutorFilter ;
+
+import com.dy.common.mw.UnitAdapterInterface;
+import com.dy.common.mw.UnitInterface;
+import com.dy.common.mw.UnitStartedCallbackInterface;
+
+@SuppressWarnings("unused")
+public class TcpUnit implements UnitInterface {
+
+ private static final TcpUnit instance = new TcpUnit() ;
+ private static boolean started = false ;
+
+ private TcpUnitAdapter adapter ;
+
+ private TcpUnit(){} ;
+
+ public static TcpUnit getInstance(){
+ return instance ;
+ }
+
+ /**
+ * 鎶奍oSession浼氳瘽鐨処D灞炴�ц缃埌IoSession灞炴�т腑
+ * @throws Exception
+ */
+ public void setIoSessionArrId(IoSession session, String id) throws Exception {
+ session.setAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrIdKey, id) ;
+ }
+
+
+ @Override
+ public void setAdapter(UnitAdapterInterface adapter) throws Exception {
+ if(adapter == null){
+ throw new Exception("TCP妯″潡閫傞厤鍣ㄥ璞′笉鑳戒负绌猴紒") ;
+ }
+ this.adapter = (TcpUnitAdapter)adapter ;
+ TcpConfigVo vo = this.adapter.getConfig() ;
+ if(vo == null){
+ throw new Exception("TCP妯″潡杩炴帴灞炴�ч厤缃璞′笉鑳戒负绌猴紒") ;
+ }
+ if(vo.port == null || vo.idle == null || vo.processors == null){
+ throw new Exception("TCP妯″潡杩炴帴灞炴�ч厤缃璞″睘鎬у�间笉鑳戒负绌猴紒") ;
+ }
+ if(this.adapter.newPrefixedDataAvailableHandle() == null){
+ throw new Exception("TCP妯″潡涓婅鏁版嵁瑙g爜绫讳负绌猴紒") ;
+ }
+ if(this.adapter.newSessionEventCallback() == null){
+ throw new Exception("TCP妯″潡浜嬩欢澶勭悊鍥炶皟绫讳负绌猴紒") ;
+ }
+ }
+ /**
+ * 鍚姩妯″潡
+ */
+ public void start(UnitStartedCallbackInterface callback) throws Exception {
+ if(!started){
+ started = true ;
+ /**
+ * 寮傛闈為樆濉炵綉缁滈�氫俊鎺ユ敹鍣紝璐熻矗鎺ユ敹鑱旀帴璇锋眰
+ * 鍚屾椂璁剧疆IoProcessor涓暟
+ * 杩欎釜鍦版柟鐢ㄤ簬鎵ц鐪熸鐨処O 鎿嶄綔锛岄粯璁ゅ惎鐢ㄧ殑绾跨▼涓暟鏄疌PU 鐨勬牳鏁�+1锛岃濡傦細鍗旵PU 鍙�
+ * 鏍哥殑鐢佃剳锛岄粯璁ょ殑IoProcessor 绾跨▼浼氬垱寤�3 涓�傝繖涔熷氨鏄涓�涓狪oAcceptor 鎴栬��
+ * IoConnector 榛樿浼氬叧鑱斾竴涓狪oProcessor 姹狅紝杩欎釜姹犱腑鏈�3 涓狪oProcessor銆傚洜涓篒O 鎿嶄綔
+ * 鑰楄垂璧勬簮锛屾墍浠ヨ繖閲屼娇鐢↖oProcessor 姹犳潵瀹屾垚鏁版嵁鐨勮鍐欐搷浣滐紝鏈夊姪浜庢彁楂樻�ц兘銆傝繖涔熷氨
+ * 鏄墠闈㈣鐨処oAccetor銆両oConnector 浣跨敤涓�涓猄elector锛岃�孖oProcessor 浣跨敤鑷繁鍗曠嫭鐨�
+ * Selector 鐨勫師鍥犮��
+ * 閭d箞涓轰粈涔圛oProcessor 姹犱腑鐨処oProcessor 鏁伴噺鍙瘮CPU 鐨勬牳鏁板ぇ1 鍛紵鍥犱负IO 璇诲啓鎿�
+ * 浣滄槸鑰楄垂CPU 鐨勬搷浣滐紝鑰屾瘡涓�鏍窩PU 鍚屾椂鍙兘杩愯涓�涓嚎绋嬶紝鍥犳IoProcessor 姹犱腑鐨�
+ * IoProcessor 鐨勬暟閲忓苟涓嶆槸瓒婂瓒婂ソ銆�
+ */
+ NioSocketAcceptor acceptor = new NioSocketAcceptor(this.adapter.getConfig().processors);
+
+ SocketSessionConfig seConf = acceptor.getSessionConfig() ;
+
+ /* 璁剧疆璇绘暟鎹椂涓�娆℃�х敵璇峰爢缂撳瓨澶у皬锛�
+ * 涓�鑸笉闇�瑕佽皟鐢ㄨ繖涓柟娉曪紝鍥犱负IoProcessor 浼氳嚜鍔ㄨ皟鏁寸紦鍐茬殑澶у皬銆�
+ * 鍙互璋冪敤setMinReadBufferSize()銆乻etMaxReadBufferSize()鏂规硶锛�
+ * 杩欐牱鏃犺IoProcessor濡備綍鑷姩璋冩暣锛岄兘浼氬湪浣犳寚瀹氱殑鍖洪棿銆�
+ */
+ //seConf.setReadBufferSize(1024);
+
+ //璁剧疆缃戠粶鑱旀帴绌洪棽鏃堕暱
+ seConf.setIdleTime(IdleStatus.BOTH_IDLE, this.adapter.getConfig().idle);
+
+ //寰楀埌缃戠粶 閫氫俊鏁版嵁杩囨护鍣ㄩ摼
+ DefaultIoFilterChainBuilder chain = acceptor.getFilterChain() ;
+ //缂栬В鐮佽繃婊ゅ櫒
+ chain.addLast("protocol", new ProtocolCodecFilter(new DataCodecFactory(this.adapter)));
+
+ /*
+ * 涓�鑸珽xecutorFilter 閮借鏀惧湪ProtocolCodecFilter 杩囨护鍣ㄧ殑鍚庨潰锛�
+ * 涔熷氨鏄笉瑕佽缂栬В鐮佽繍琛屽湪鐙珛鐨勭嚎绋嬩笂锛岃�屾槸瑕佽繍琛屽湪IoProcessor 鎵�鍦ㄧ殑绾跨▼锛�
+ * 鍥犱负缂栬В鐮佸鐞嗙殑鏁版嵁閮芥槸鐢盜oProcessor 璇诲彇鍜屽彂閫佺殑锛屾病蹇呰寮�鍚柊鐨勭嚎绋嬶紝
+ * 鍚﹀垯鎬ц兘鍙嶈�屼細涓嬮檷銆備竴鑸娇鐢‥xecutorFilter 鐨勫吀鍨嬪満鏅槸灏嗕笟鍔¢�昏緫锛堣濡傦細鑰楁椂鐨勬暟鎹簱鎿嶄綔锛�
+ * 鏀惧湪鍗曠嫭鐨勭嚎绋嬩腑杩愯锛屼篃灏辨槸璇翠笌IO 澶勭悊鏃犲叧鐨勬搷浣滃彲浠ヨ�冭檻浣跨敤ExecutorFilter 鏉ュ紓姝ユ墽琛屻��
+ */
+ chain.addLast("exceutor", new ExecutorFilter());
+
+ //涓氬姟閫昏緫澶勭悊鍣紝璐熻矗澶勭悊缃戠粶浼氳瘽鍙婅緭鍏ヨ緭鍑烘暟鎹�
+ acceptor.setHandler(new TcpIoHandler(this.adapter));
+
+ boolean isException = false ;
+ try {
+ acceptor.bind(new InetSocketAddress(this.adapter.getConfig().port));
+ } catch (IOException e) {
+ e.printStackTrace();
+ System.out.println("TCP閫氫俊妯″潡鍚姩澶辫触锛�" + (e.getMessage()==null?"":e.getMessage()));
+ isException = true ;
+ }finally{
+ ;
+ }
+
+ if(!isException){
+ if(this.adapter.getConfig().showStartInfo != null && this.adapter.getConfig().showStartInfo.booleanValue()){
+ System.out.println("TCP妯″潡鎴愬姛鍚姩锛岀鍙o細" + this.adapter.getConfig().port);
+ }
+ }
+
+ callback.call(null);
+ }
+ }
+
+ @Override
+ public void stop(UnitStartedCallbackInterface callback) throws Exception {
+ }
+
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/TcpUnitAdapter.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/TcpUnitAdapter.java
new file mode 100644
index 0000000..50b4dac
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/TcpUnitAdapter.java
@@ -0,0 +1,26 @@
+package com.dy.common.mw.channel.tcp;
+
+import com.dy.common.mw.UnitAdapterInterface;
+
+public interface TcpUnitAdapter extends UnitAdapterInterface {
+
+ /**
+ * 寰楀埌閰嶇疆
+ * @return
+ */
+ TcpConfigVo getConfig() ;
+ /**
+ * mina瀹炵幇鐨凾CP NIO锛岄噰鐢ㄤ簡绾跨▼姹犳妧鏈紝瀛樺湪绾跨▼瀹夊叏闂锛�
+ * 鎵�浠ユ澶勫緱鍒癙refixedDataAvailableHandle涓嶈兘鏄崟渚嬶紝
+ * @return
+ */
+ PrefixedDataAvailableHandle newPrefixedDataAvailableHandle() ;
+
+ /**
+ * mina瀹炵幇鐨凾CP NIO锛岄噰鐢ㄤ簡绾跨▼姹犳妧鏈紝瀛樺湪绾跨▼瀹夊叏闂锛�
+ * 鎵�浠ユ澶勫緱鍒癟cpSessionEventCallback涓嶈兘鏄崟渚嬶紝
+ * @return
+ */
+ TcpIoSessionEventCallback newSessionEventCallback() ;
+
+}
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
new file mode 100644
index 0000000..bb54e15
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreConstantThread.java
@@ -0,0 +1,64 @@
+package com.dy.common.mw.core;
+
+import java.util.List;
+
+import org.apache.logging.log4j.*;
+
+public class CoreConstantThread extends Thread{
+
+ private final static Logger log = LogManager.getLogger(CoreConstantThread.class.getName()) ;
+
+ private final static CoreConstantThread instance = new CoreConstantThread() ;
+
+ @SuppressWarnings("unused")
+ private static Long sleepBigBusy = 100L ;//澶у繖鏃讹紙闄や簡鎭掍箙浠诲姟锛岃繕鏄叾浠栦换鍔★級锛屾牳蹇冪嚎绋嬫殏鍋滈棿闅�
+ private static Long sleepSmallBusy = 500L ;//灏忓繖鏃讹紙鍙湁鎭掍箙浠诲姟锛屾棤鍏朵粬浠诲姟锛夛紝鏍稿績绾跨▼鏆傚仠闂撮殧
+
+ private CoreConstantThread(){
+ }
+
+ public static CoreConstantThread getInstance(){
+ return instance ;
+ }
+
+ /**
+ * 璁剧疆鏆傚仠鏃堕暱
+ * @param sleepBigBusy 澶у繖鏃讹紙闄や簡鎭掍箙浠诲姟锛岃繕鏄叾浠栦换鍔★級锛屾牳蹇冪嚎绋嬫殏鍋滈棿闅�
+ * @param sleepSmallBusy 灏忓繖鏃讹紙鍙湁鎭掍箙浠诲姟锛屾棤鍏朵粬浠诲姟锛夛紝鏍稿績绾跨▼鏆傚仠闂撮殧
+ */
+ public void setSleep(Long sleepBigBusy, Long sleepSmallBusy){
+ CoreConstantThread.sleepBigBusy = sleepBigBusy ;
+ CoreConstantThread.sleepSmallBusy = sleepSmallBusy ;
+ }
+
+ /**
+ * 鏍稿績鍗曠嚎绋嬶紝鎵ц鎵�鏈夌殑鍗曠嚎绋嬩换鍔�
+ */
+ @Override
+ @SuppressWarnings("InfiniteLoopStatement")
+ public void run(){
+ int count ;
+ Integer temp ;
+ while (true) {
+ count = 0;
+ try {
+ //鎭掍箙浠诲姟
+ List<CoreTask> constantTasks = CoreUnit.getAllConstantTasks();
+ if (constantTasks != null && constantTasks.size() > 0) {
+ for (CoreTask task : constantTasks) {
+ temp = task.excute();
+ if (temp != null) {
+ count += temp;
+ }
+ }
+ }
+ if (count == 0) {
+ //灏忔殏鍋滀竴涓�
+ Thread.sleep(sleepSmallBusy);
+ }
+ } 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/CoreTask.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreTask.java
new file mode 100644
index 0000000..fd70cd4
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreTask.java
@@ -0,0 +1,12 @@
+package com.dy.common.mw.core;
+
+import com.dy.common.queue.NodeObj;
+
+public abstract class CoreTask implements NodeObj{
+ public Object data ;//浠诲姟鏁版嵁
+ /**
+ * 浠诲姟鑷垜鎵ц鏂规硶
+ * @return 鎵ц浠诲姟鐨勬暟閲忥紝濡傛灉璋冪敤鑰呬笉闇�瑕佹暟閲忔椂锛屽彲浠ヨ繑鍥瀗ull
+ */
+ public abstract Integer excute() ;
+}
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
new file mode 100644
index 0000000..46341fe
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreThread.java
@@ -0,0 +1,72 @@
+package com.dy.common.mw.core;
+
+import org.apache.logging.log4j.*;
+
+import com.dy.common.queue.Queue;
+
+public class CoreThread extends Thread{
+
+ private static Logger log = LogManager.getLogger(CoreThread.class.getName()) ;
+
+ private static CoreThread instance = new CoreThread() ;
+
+ private static Long sleepBigBusy = 100L ;//澶у繖鏃讹紙闄や簡鎭掍箙浠诲姟锛岃繕鏄叾浠栦换鍔★級锛屾牳蹇冪嚎绋嬫殏鍋滈棿闅�
+ private static Long sleepSmallBusy = 500L ;//灏忓繖鏃讹紙鍙湁鎭掍箙浠诲姟锛屾棤鍏朵粬浠诲姟锛夛紝鏍稿績绾跨▼鏆傚仠闂撮殧
+
+ private CoreThread(){
+ }
+
+ public static CoreThread getInstance(){
+ return instance ;
+ }
+
+ /**
+ * 璁剧疆鏆傚仠鏃堕暱
+ * @param sleepWorking
+ * @param sleepIdel
+ */
+ public void setSleep(Long sleepBigBusy, Long sleepSmallBusy){
+ CoreThread.sleepBigBusy = sleepBigBusy ;
+ CoreThread.sleepSmallBusy = sleepSmallBusy ;
+ }
+
+ /**
+ * 鏍稿績鍗曠嚎绋嬶紝鎵ц鎵�鏈夌殑鍗曠嚎绋嬩换鍔�
+ */
+ @SuppressWarnings("finally")
+ @Override
+ public void run() {
+ Queue coreQueue = CoreUnit.taskQueue ;
+ int count = 0 ;
+ int n = 0 ;
+ while(true){
+ try{
+ /**
+ * 姝ゅ鍙栧嚭褰撳墠闃熷垪鐨勮妭鐐规暟閲忥紝浣滀负涓�涓畾閲廲ount澶勭悊锛�
+ * 鍘熷洜:
+ * 鍦ㄥ鐞嗗畾閲廲ount杩囩▼涓紝鍙兘鏈夌殑鑺傜偣鍙堝洖鍒伴槦鍒椾腑锛屽彲鑳芥柊鐢熻妭鐐硅繘鍏ラ槦鍒椾腑锛屽嵆鍦ㄥ鐞嗚繃绋嬩腑锛岄槦鍒楀彲鑳藉張澧為暱浜�
+ */
+ count = coreQueue.size() ;
+ if(count > 0){
+ n = 0 ;
+ while(n < count){
+ CoreTask task = (CoreTask)coreQueue.pop() ;
+ if(task != null){
+ task.excute();
+ }
+ n ++ ;
+ }
+ //澶ф殏鍋滀竴涓�
+ sleep(sleepBigBusy) ;
+ }else{
+ //灏忔殏鍋滀竴涓�
+ sleep(sleepSmallBusy) ;
+ }
+ }catch(Exception e){
+ log.error("鏍稿績绾跨▼鍙戠敓寮傚父" + (e.getMessage() == null ? "" : (":" + e.getMessage())), e);;
+ }finally{
+ continue ;
+ }
+ }
+ }
+}
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
new file mode 100644
index 0000000..5c5e0df
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreUnit.java
@@ -0,0 +1,119 @@
+package com.dy.common.mw.core;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.dy.common.queue.Queue;
+import com.dy.common.mw.UnitAdapterInterface;
+import com.dy.common.mw.UnitInterface;
+import com.dy.common.mw.UnitStartedCallbackInterface;
+
+public class CoreUnit implements UnitInterface {
+
+ private static final CoreUnit instance = new CoreUnit() ;
+ private static boolean started = false ;
+
+ //鎭掍箙浠诲姟锛屼竴鏃﹀姞鍏ワ紝姘镐箙瀛樺湪
+ private static final List<CoreTask> constantTasks = new ArrayList<>() ;
+ //浠诲姟闃熷垪锛屼竴娆℃�т换鍔★紝浠诲姟鎵ц鏃朵粠闃熷垪涓竻闄�
+ protected static Queue taskQueue = new Queue("coreTaskQueue") ;
+
+ public CoreUnitAdapter adapter ;
+
+ private CoreUnit(){}
+
+ public static CoreUnit getInstance(){
+ return instance ;
+ }
+
+ @Override
+ public void setAdapter(UnitAdapterInterface adapter) throws Exception {
+ if(adapter == null){
+ throw new Exception("鏍稿績妯″潡閫傞厤鍣ㄥ璞′笉鑳戒负绌猴紒") ;
+ }
+ this.adapter = (CoreUnitAdapter)adapter ;
+ CoreUnitConfigVo vo = this.adapter.getConfig() ;
+ if(vo == null){
+ throw new Exception("鏍稿績妯″潡閰嶇疆瀵硅薄涓嶈兘涓虹┖锛�") ;
+ }
+ if(vo.sleepBigBusy == null || vo.sleepSmallBusy == null){
+ throw new Exception("鏍稿績妯″潡閰嶇疆瀵硅薄闂撮殧灞炴�у�间笉鑳戒负绌猴紒") ;
+ }
+ if(vo.sleepBigBusy <= 0){
+ throw new Exception("鏍稿績妯″潡閰嶇疆瀵硅薄灞炴�leepBigBusy鍊间笉鑳藉皬浜�0锛�") ;
+ }
+ if(vo.sleepBigBusy > 1000){
+ throw new Exception("鏍稿績妯″潡閰嶇疆瀵硅薄灞炴�leepBigBusy鍊间笉鑳藉ぇ浜�1000锛�") ;
+ }
+ if(vo.sleepSmallBusy > 1000){
+ throw new Exception("鏍稿績妯″潡閰嶇疆瀵硅薄灞炴�leepSmallBusy鍊间笉鑳藉ぇ浜�1000锛�") ;
+ }
+ if(vo.queueWarnSize == null || vo.queueMaxSize == null){
+ throw new Exception("鏍稿績妯″潡閰嶇疆瀵硅薄闃熷垪鑺傜偣闄愬埗鏁伴噺灞炴�у�间笉鑳戒负绌猴紒") ;
+ }
+ if(vo.queueWarnSize < 500){
+ throw new Exception("鏍稿績妯″潡閰嶇疆瀵硅薄闃熷垪鑺傜偣璀﹀憡闄愬埗鏁伴噺灞炴�у�间笉鑳藉皬浜�500锛�") ;
+ }
+ if(vo.queueMaxSize < 5000){
+ throw new Exception("鏍稿績妯″潡閰嶇疆瀵硅薄闃熷垪鑺傜偣鎷掔粷闄愬埗鏁伴噺灞炴�у�间笉鑳藉皬浜�5000锛�") ;
+ }
+ if(vo.queueWarnSize > vo.queueMaxSize){
+ throw new Exception("鏍稿績妯″潡閰嶇疆瀵硅薄闃熷垪鑺傜偣璀﹀憡闄愬埗鏁伴噺灞炴�у�间笉鑳藉ぇ浜庢嫆缁濋檺鍒舵暟閲忥紒") ;
+ }
+ taskQueue.setLimit(vo.queueWarnSize, vo.queueMaxSize);
+ }
+
+ @Override
+ public void start(UnitStartedCallbackInterface callback) throws Exception {
+ if(!started){
+ started = true ;
+ CoreThread ct = CoreThread.getInstance() ;
+ ct.setSleep(this.adapter.getConfig().sleepBigBusy, this.adapter.getConfig().sleepSmallBusy);
+ ct.start();
+
+ CoreConstantThread cct = CoreConstantThread.getInstance() ;
+ cct.setSleep(this.adapter.getConfig().sleepBigBusy, this.adapter.getConfig().sleepSmallBusy);
+ cct.start();
+
+ if(adapter.getConfig().showStartInfo){
+ System.out.println("鏍稿績妯″潡鎴愬姛鍚姩锛�"
+ + "涓荤嚎绋嬬箒蹇欓棿闅旓細" + adapter.getConfig().sleepBigBusy + "姣锛�"
+ + "杞婚棽闂撮殧锛�" + adapter.getConfig().sleepSmallBusy + "姣" );
+ }
+ callback.call(null);
+ }
+ }
+
+ @Override
+ public void stop(UnitStartedCallbackInterface callback) {
+ }
+
+
+ /**
+ * 鍔犲叆鏍稿績浠诲姟
+ * @param task 鏍稿績浠诲姟
+ * @throws Exception 寮傚父
+ */
+ @SuppressWarnings("unused")
+ public void pushCoreTask(CoreTask task) throws Exception{
+ taskQueue.pushTail(task);
+ }
+
+ /**
+ * 鍔犲叆鎭掍箙浠诲姟
+ * @param task 鎭掍箙浠诲姟
+ */
+ @SuppressWarnings("unused")
+ public static void addConstantTask(CoreTask task){
+ constantTasks.add(task) ;
+ }
+
+ /**
+ * 寰楀埌鎵�鏈夋亽涔呬换鍔�
+ * @return 鎵�鏈夋亽涔呬换鍔�
+ */
+ public static List<CoreTask> getAllConstantTasks(){
+ return constantTasks ;
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreUnitAdapter.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreUnitAdapter.java
new file mode 100644
index 0000000..941e236
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreUnitAdapter.java
@@ -0,0 +1,11 @@
+package com.dy.common.mw.core;
+
+import com.dy.common.mw.UnitAdapterInterface;
+
+public interface CoreUnitAdapter extends UnitAdapterInterface {
+ /**
+ * 寰楀埌鏍稿績妯″潡閰嶇疆瀵硅薄
+ * @return
+ */
+ public CoreUnitConfigVo getConfig() ;
+}
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
new file mode 100644
index 0000000..521c1cf
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreUnitConfigVo.java
@@ -0,0 +1,9 @@
+package com.dy.common.mw.core;
+
+public class CoreUnitConfigVo {
+ public Long sleepBigBusy = 100L ;//澶у繖鏃讹紙闄や簡鎭掍箙浠诲姟锛岃繕鏈夊叾浠栦换鍔¢渶澶勭悊锛夛紝鏍稿績绾跨▼鏆傚仠闂撮殧
+ public Long sleepSmallBusy = 500L ;//灏忓繖鏃讹紙鍙湁鎭掍箙浠诲姟锛屾棤鍏朵粬浠诲姟闇�澶勭悊锛夛紝鏍稿績绾跨▼鏆傚仠闂撮殧
+ public Integer queueWarnSize = 1000 ;//闃熷垪鎶ヨ闀垮害
+ public Integer queueMaxSize = 5000 ;//闃熷垪鏈�澶ч暱搴�
+ public Boolean showStartInfo; //鏄惁鍦ㄦ帶鍒跺彴涓婃樉绀轰俊鎭�
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationCodeDown.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationCodeDown.java
new file mode 100644
index 0000000..0520bb6
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationCodeDown.java
@@ -0,0 +1,18 @@
+package com.dy.common.mw.protocol;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface AnnotationCodeDown {
+
+ /**
+ * 鍗忚鍚嶇О锛屽悇涓崗璁悕绉颁笉鑳芥湁閲嶅鐜拌薄
+ */
+ String value() default ProtocolConstant.anyCode ;//鍙傛暟涓虹┖鏃讹紝琛ㄧず鏄櫎鏄庣‘娉ㄨВ鐨勫姛鑳界爜澶栫殑鍗忚鍏朵粬鍔熻兘鐮�
+ String[] ifAny() default{} ;
+}
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationCodeUp.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationCodeUp.java
new file mode 100644
index 0000000..c23776e
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationCodeUp.java
@@ -0,0 +1,17 @@
+package com.dy.common.mw.protocol;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface AnnotationCodeUp {
+ /**
+ * 寰楀埌瀵瑰簲鐨勫姛鑳界爜
+ */
+ String value() default ProtocolConstant.anyCode ;//鍙傛暟涓虹┖鏃讹紝琛ㄧず鏄櫎鏄庣‘娉ㄨВ鐨勫姛鑳界爜澶栫殑鍗忚鍏朵粬鍔熻兘鐮�
+ String[] ifAny() default{} ;
+}
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationDriver.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationDriver.java
new file mode 100644
index 0000000..a8a700d
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationDriver.java
@@ -0,0 +1,12 @@
+package com.dy.common.mw.protocol;
+
+import java.lang.annotation.*;
+
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface AnnotationDriver {
+ /**
+ * 鍗忚鍚嶇О锛屽悇涓崗璁悕绉颁笉鑳芥湁閲嶅鐜拌薄
+ */
+ String name() default "" ;
+}
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationDriverVo.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationDriverVo.java
new file mode 100644
index 0000000..1e729ed
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationDriverVo.java
@@ -0,0 +1,11 @@
+package com.dy.common.mw.protocol;
+
+public class AnnotationDriverVo {
+
+ //椹卞姩绫�
+ public Class<?> clazz ;
+
+ public AnnotationDriverVo(Class<?> clazz){
+ this.clazz = clazz ;
+ }
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationOnLine.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationOnLine.java
new file mode 100644
index 0000000..4e2069a
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationOnLine.java
@@ -0,0 +1,23 @@
+package com.dy.common.mw.protocol;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface AnnotationOnLine {
+ /**
+ * 鎵�灞炲崗璁悕绉�
+ */
+ String protocolName() default "" ;
+ /**
+ * 涓轰紭鍏堢骇(浠�1寮�濮嬶紝鏈�灏忎负1锛屽悇鍗忚闂翠紭鍏堢骇鐩稿樊1)锛屾暟瀛楄秺灏忕骇鍒秺楂樸��
+ * 鑻ユ湁澶氫釜鍗忚锛屽悇涓崗璁殑涓婄嚎澶勭悊绫讳互浼樺厛绾ц繘琛屾帓搴忥紝浼樺厛绾ч珮鐨勫厛澶勭悊涓婄嚎鏁版嵁銆�
+ * 鏁板�间笌AnnotationPrefixedDataAvailable鐨刾riority鐩哥瓑
+ */
+ int priority() default 0 ;
+
+}
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationOnLineVo.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationOnLineVo.java
new file mode 100644
index 0000000..188a92f
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationOnLineVo.java
@@ -0,0 +1,31 @@
+package com.dy.common.mw.protocol;
+
+public class AnnotationOnLineVo {
+
+ /**
+ * 澶勭悊涓婄嚎鐨勭被
+ */
+ public Class<?> clazz ;
+ /**
+ * 鎵�灞炲崗璁悕绉�
+ */
+ public String protocolName ;
+ /**
+ * 涓轰紭鍏堢骇(浠�1寮�濮嬶紝鏈�灏忎负1锛屽悇鍗忚闂翠紭鍏堢骇鐩稿樊1)锛屾暟瀛楄秺灏忕骇鍒秺楂樸��
+ * 鑻ユ湁澶氫釜鍗忚锛屽悇涓崗璁殑涓婄嚎澶勭悊绫讳互浼樺厛绾ц繘琛屾帓搴忥紝浼樺厛绾ч珮鐨勫厛澶勭悊涓婄嚎鏁版嵁銆�
+ * 鏁板�间笌AnnotationPrefixedDataAvailable鐨刾riority鐩哥瓑
+ */
+ public int priority ;
+
+ /**
+ * 鏋勯�犳柟娉�
+ * @param clazz 绫�
+ * @param protocolName 鍗忚鍚嶇О
+ * @param priority 浼樺厛绾�
+ */
+ public AnnotationOnLineVo(Class<?> clazz, String protocolName, int priority){
+ this.clazz = clazz ;
+ this.protocolName = protocolName ;
+ this.priority = priority ;
+ }
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationPrefixedDataAvailable.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationPrefixedDataAvailable.java
new file mode 100644
index 0000000..75ab6a9
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationPrefixedDataAvailable.java
@@ -0,0 +1,33 @@
+package com.dy.common.mw.protocol;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface AnnotationPrefixedDataAvailable {
+ /**
+ * 鎵�灞炲崗璁悕绉�
+ */
+ String protocolName() default "" ;
+ /**
+ * 涓轰紭鍏堢骇(浠�1寮�濮嬶紝鏈�灏忎负1锛屽悇鍗忚闂翠紭鍏堢骇鐩稿樊1)锛屾暟瀛楄秺灏忕骇鍒秺楂樸��
+ * 鑻ユ湁澶氫釜鍗忚锛屽悇涓崗璁殑涓婄嚎澶勭悊绫讳互浼樺厛绾ц繘琛屾帓搴忥紝浼樺厛绾ч珮鐨勫厛澶勭悊涓婄嚎鏁版嵁銆�
+ * 鏁板�间笌AnnotationOnLine鐨刾riority鐩哥瓑
+ */
+ int priority() default 0 ;
+ /**
+ * RTU涓婄嚎鏁版嵁锛堜笂绾垮悗绗竴鍖呮暟鎹級鏈�灏忛暱搴︼紝璁剧疆璇ュ睘鎬т互澶囪繘琛屽畬鏁存�ф鏌ワ紝
+ * 鍗虫柇鍖呮鏌ワ紝浣垮敖鍙兘鏀跺叏涓婄嚎鏁版嵁锛堝彇鍊艰寖鍥�1-100锛�
+ */
+ int onLineDataMinLength() default 0 ;
+ /**
+ * RTU涓婃姤鏁版嵁鐨勫ご閮ㄦ渶灏忛暱搴︼紝涓婃姤鏁版嵁鐨勮繖涓渶灏忛暱搴︾殑閮ㄥ垎鏁版嵁锛�
+ * 涓�瀹氬寘鍚暟鎹暱搴︼紝浠ュ鍙栧嚭鏁版嵁闀垮害鏉ワ紝璁剧疆璇ュ睘鎬т互澶囪繘琛屽畬鏁存�ф鏌ワ紝
+ * 鍗虫柇鍖呬笌绮樺寘妫�鏌�(鍙栧�艰寖鍥�0-100锛屽叾涓彇鍊间负0鏃讹紝琛ㄧずheadMinLength鏁版嵁鏃犱綔鐢紝鐢卞崗璁疄鐜版潵鎺у埗)
+ */
+ int headMinLength() default 0 ;
+}
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationPrefixedDataAvailableVo.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationPrefixedDataAvailableVo.java
new file mode 100644
index 0000000..3600cb3
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationPrefixedDataAvailableVo.java
@@ -0,0 +1,45 @@
+package com.dy.common.mw.protocol;
+
+public class AnnotationPrefixedDataAvailableVo {
+ /**
+ * 澶勭悊瀹屾暣鎬ф鏌ョ殑绫�
+ */
+ public Class<?> clazz ;
+ /**
+ * 鎵�灞炲崗璁悕绉�
+ */
+ public String protocolName ;
+ /**
+ * 涓轰紭鍏堢骇(浠�1寮�濮嬶紝鏈�灏忎负1锛屽悇鍗忚闂翠紭鍏堢骇鐩稿樊1)锛屾暟瀛楄秺灏忕骇鍒秺楂樸��
+ * 鑻ユ湁澶氫釜鍗忚锛屽悇涓崗璁殑涓婄嚎澶勭悊绫讳互浼樺厛绾ц繘琛屾帓搴忥紝浼樺厛绾ч珮鐨勫厛澶勭悊涓婄嚎鏁版嵁銆�
+ * 鏁板�间笌AnnotationOnLine鐨刾riority鐩哥瓑
+ */
+ public int priority ;
+ /**
+ * RTU涓婄嚎鏁版嵁锛堜笂绾垮悗绗竴鍖呮暟鎹級鏈�灏忛暱搴︼紝璁剧疆璇ュ睘鎬т互澶囪繘琛屽畬鏁存�ф鏌ワ紝
+ * 鍗虫柇鍖呮鏌ワ紝浣垮敖鍙兘鏀跺叏涓婄嚎鏁版嵁锛堝彇鍊艰寖鍥�1-100锛�
+ */
+ public int onLineDataMinLength ;
+ /**
+ * RTU涓婃姤鏁版嵁鐨勫ご閮ㄦ渶灏忛暱搴︼紝涓婃姤鏁版嵁鐨勮繖涓渶灏忛暱搴︾殑閮ㄥ垎鏁版嵁锛�
+ * 涓�瀹氬寘鍚暟鎹暱搴︼紝浠ュ鍙栧嚭鏁版嵁闀垮害鏉ワ紝璁剧疆璇ュ睘鎬т互澶囪繘琛屽畬鏁存�ф鏌ワ紝
+ * 鍗虫柇鍖呬笌绮樺寘妫�鏌�(鍙栧�艰寖鍥�0-100锛屽叾涓彇鍊间负0鏃讹紝琛ㄧずheadMinLength鏁版嵁鏃犱綔鐢紝鐢卞崗璁疄鐜版潵鎺у埗)
+ */
+ public int headMinLength ;
+
+ /**
+ * 闈炴硶鏁版嵁闀垮害
+ * 渚嬪锛氭暟鎹ご閮ㄦ槸姝g‘鐨勶紝浣嗗悎娉曟暟鎹粨灏炬�讳笉鍑虹幇锛岃涓烘鏁版嵁鍨冨溇鏁版嵁
+ */
+ public int errorMaxLength ;
+
+ public AnnotationPrefixedDataAvailableVo(Class<?> clazz, String protocolName, int priority, int onLineDataMinLength, int headMinLength, int errorMaxLength){
+ this.clazz = clazz ;
+ this.protocolName = protocolName ;
+ this.priority = priority ;
+ this.onLineDataMinLength = onLineDataMinLength ;
+ this.headMinLength = headMinLength ;
+ this.errorMaxLength = errorMaxLength ;
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationScan.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationScan.java
new file mode 100644
index 0000000..f4ec4cb
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationScan.java
@@ -0,0 +1,280 @@
+package com.dy.common.mw.protocol;
+
+import java.net.URI;
+import java.net.URL;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+
+import com.dy.common.util.ClassScan;
+import com.dy.common.util.NumUtil;
+
+/**
+ * 鎵弿锛�
+ * 鍗忚椹卞姩绫�
+ * 涓婅鏁版嵁瀹屾暣鎬ф鏌ョ被锛堟柇鍖呯矘鍖呮鏌ワ級
+ * 涓婄嚎鏁版嵁锛堣繛鎺ュ悗绗竴鍖呮暟鎹級澶勭悊绫伙紙璇嗗埆鍗忚鍙婄粓绔湴鍧�锛�
+ * @author Administrator
+ *
+ */
+@SuppressWarnings("unused")
+public class AnnotationScan {
+
+ private static String scanRootPackage = "com.dy.common.mw.protocol." ;
+
+ private static AnnotationScan instance ;
+
+ private AnnotationScan(){
+ }
+
+ /**
+ * 寰楀埌鍞竴瀹炰緥锛�
+ * 骞跺湪鐢熸垚鍞竴瀹炰緥鏃讹紝鎵弿娉ㄨВ绫�
+ * @return AnnotationScan
+ * @throws Exception 寮傚父
+ */
+ public static AnnotationScan getIntance()throws Exception{
+ if(instance == null){
+ instance = new AnnotationScan() ;
+ instance.scanEndpointAnnotations();
+ }
+ return instance ;
+ }
+
+ /**
+ * 鎵弿鍑烘敞瑙g殑绫�
+ * @throws ClassNotFoundException 寮傚父
+ * @throws Exception 寮傚父
+ */
+ private void scanEndpointAnnotations() throws Exception{
+ ClassLoader load = this.getClass().getClassLoader() ;
+
+ if(!scanRootPackage.endsWith(".")){
+ scanRootPackage += "." ;
+ }
+ URL url = AnnotationScan.class.getResource("/" + scanRootPackage.replace('.', '/'));
+ if(url != null){
+ String urlStr = url.toString() ;
+ if(urlStr != null){
+ URI uri = new URI(url.toString());
+
+ List<String> classNames = new ClassScan().searchClassFromUrl(new URI[]{uri}, scanRootPackage) ;
+ if(classNames != null && classNames.size() > 0){
+ String protocolName ;
+ int priority;
+ int onLineDataMinLength;
+ int headMinLength ;
+
+ HashMap<String, AnnotationDriverVo> driverMap = ProtocolCach.getDriverMap() ;
+ HashMap<String, AnnotationPrefixedDataAvailableVo> prefixedDataAvailableMap = ProtocolCach.getPrefixedDataAvailableMap() ;
+ HashMap<String, AnnotationOnLineVo> onLineMap = ProtocolCach.getOnLineMap() ;
+
+ for(String cName : classNames){
+ String className = cName.substring(0, cName.lastIndexOf('.')) ;
+ Class<?> clazz = load.loadClass(className) ;
+ if(clazz.isAnnotationPresent(AnnotationDriver.class)){
+ AnnotationDriver ann = clazz.getAnnotation(AnnotationDriver.class) ;
+ if(ann != null){
+ protocolName = ann.name() ;
+ if(!(protocolName.trim().equals(""))){
+ if(driverMap.containsKey(protocolName)){
+ throw new Exception("涓ラ噸閿欒锛屽崗璁┍鍔ㄥ悕绉�" + protocolName + "鍑虹幇浜嗛噸澶嶆敞瑙o紒") ;
+ }
+ driverMap.put(protocolName, new AnnotationDriverVo(clazz)) ;
+ }else{
+ throw new Exception("涓ラ噸閿欒锛屽崗璁┍鍔ㄥ悕绉版敞瑙e�间负绌哄瓧绗︿覆") ;
+ }
+ }
+ }
+
+
+ if(clazz.isAnnotationPresent(AnnotationPrefixedDataAvailable.class)){
+ AnnotationPrefixedDataAvailable ann = clazz.getAnnotation(AnnotationPrefixedDataAvailable.class) ;
+ if(ann != null){
+ protocolName = ann.protocolName() ;
+ if(!(protocolName.trim().equals(""))){
+ if(prefixedDataAvailableMap.containsKey(protocolName)){
+ throw new Exception("涓ラ噸閿欒锛� 涓婅鏁版嵁瀹屾暣鎬ф鏌ユ墍閰嶅崗璁┍鍔�" + protocolName + "鍑虹幇浜嗛噸澶嶆敞瑙o紒") ;
+ }
+ }else{
+ throw new Exception("涓ラ噸閿欒锛屼笂琛屾暟鎹畬鏁存�ф鏌ユ墍閰嶅崗璁┍鍔ㄦ敞瑙e�间负绌哄瓧绗︿覆") ;
+ }
+
+ priority = ann.priority() ;
+ if(priority == 0){
+ throw new Exception("涓ラ噸閿欒锛� 涓婅鏁版嵁瀹屾暣鎬ф鏌ユ墍閰嶄紭鍏堢骇娉ㄨВ涓嶈兘涓�0") ;
+ }
+ if(isRepeatPrefixedDataAvailablePriority(priority, prefixedDataAvailableMap)){
+ throw new Exception("涓ラ噸閿欒锛� 涓婅鏁版嵁瀹屾暣鎬ф鏌ユ墍閰嶄紭鍏堢骇娉ㄨВ(priority)鏁板��" + priority + "閲嶅") ;
+ }
+
+ onLineDataMinLength = ann.onLineDataMinLength() ;
+ /*姘旇薄鍗忚涓�0
+ if(onLineDataMinLength == 0){
+ throw new Exception("涓ラ噸閿欒锛� 涓婅鏁版嵁瀹屾暣鎬ф鏌ユ墍閰嶄笂绾挎暟鎹渶灏忛暱搴︽敞瑙d笉鑳戒负0") ;
+ }
+ */
+ headMinLength = ann.headMinLength() ;
+ /*姘旇薄鍗忚涓�0
+ if(headMinLength == 0){
+ throw new Exception("涓ラ噸閿欒锛� 涓婅鏁版嵁瀹屾暣鎬ф鏌ユ墍閰嶄笂鎶ユ暟鎹殑澶撮儴鏈�灏忛暱搴︽敞瑙d笉鑳戒负0") ;
+ }
+ */
+
+ prefixedDataAvailableMap.put(protocolName, new AnnotationPrefixedDataAvailableVo(clazz, protocolName, priority, onLineDataMinLength, headMinLength, ProtocolConstant.errorMaxLength)) ;
+ }
+ }
+
+ if(clazz.isAnnotationPresent(AnnotationOnLine.class)){
+ AnnotationOnLine ann = clazz.getAnnotation(AnnotationOnLine.class) ;
+ if(ann != null){
+ protocolName = ann.protocolName() ;
+ if(!(protocolName.trim().equals(""))){
+ if(onLineMap.containsKey(protocolName)){
+ throw new Exception("涓ラ噸閿欒锛� 涓婄嚎鏁版嵁鍒嗘瀽鎵�閰嶅崗璁┍鍔�" + protocolName + "鍑虹幇浜嗛噸澶嶆敞瑙o紒") ;
+ }
+ }else{
+ throw new Exception("涓ラ噸閿欒锛屼笂绾挎暟鎹垎鏋愭墍閰嶅崗璁┍鍔ㄦ敞瑙e�间负绌哄瓧绗︿覆") ;
+ }
+
+ priority = ann.priority() ;
+ if(priority == 0){
+ throw new Exception("涓ラ噸閿欒锛� 涓婄嚎鏁版嵁鍒嗘瀽鎵�閰嶄紭鍏堢骇娉ㄨВ涓嶈兘涓�0") ;
+ }
+ if(isRepeatOnLinePriority(priority, onLineMap)){
+ throw new Exception("涓ラ噸閿欒锛� 涓婄嚎鏁版嵁鍒嗘瀽鎵�閰嶄紭鍏堢骇娉ㄨВ(priority)鏁板��" + priority + "閲嶅") ;
+ }
+
+ onLineMap.put(protocolName, new AnnotationOnLineVo(clazz, protocolName, priority)) ;
+ }
+ }
+ }
+
+ String error = this.hasErrorInDriver(driverMap) ;
+ if(error != null){
+ throw new Exception(error) ;
+ }else{
+ error = this.hasErrorInPrefixedDataAvailable(driverMap, prefixedDataAvailableMap) ;
+ if(error != null){
+ throw new Exception(error) ;
+ }else{
+ error = this.hasErrorInOnLine(driverMap, onLineMap) ;
+ if(error != null){
+ throw new Exception(error) ;
+ }
+ }
+ }
+ }else{
+ throw new Exception("涓ラ噸閿欒锛� 鎵弿鍗忚鐩稿叧娉ㄨВ鎵�寰楀埌绫诲瀷闆嗗悎涓虹┖锛屾壂鎻忔牴璺緞鏄�" + scanRootPackage) ;
+ }
+ }
+ }
+ }
+ /**
+ * 妫�鏌ヤ紭鍏堢骇閲嶅
+ * @param priority 浼樺厛绾�
+ * @return 缁撴灉
+ */
+ private boolean isRepeatPrefixedDataAvailablePriority(int priority, HashMap<String, AnnotationPrefixedDataAvailableVo> prefixedDataAvailableMap){
+ Collection<AnnotationPrefixedDataAvailableVo> col = prefixedDataAvailableMap.values();
+ for(AnnotationPrefixedDataAvailableVo vo : col){
+ if(vo.priority == priority){
+ return true ;
+ }
+ }
+ return false ;
+ }
+ /**
+ * 妫�鏌ヤ紭鍏堢骇閲嶅
+ * @param priority 浼樺厛绾�
+ * @return 缁撴灉
+ */
+ private boolean isRepeatOnLinePriority(int priority, HashMap<String, AnnotationOnLineVo> onLineMap){
+ Collection<AnnotationOnLineVo> col = onLineMap.values();
+ for(AnnotationOnLineVo vo : col){
+ if(vo.priority == priority){
+ return true ;
+ }
+ }
+ return false ;
+ }
+
+ private String hasErrorInDriver(HashMap<String, AnnotationDriverVo> driverMap){
+ if(driverMap.size() == 0){
+ return "涓ラ噸閿欒锛屾湭娉ㄨВ浠讳綍鍗忚椹卞姩" ;
+ }
+ return null ;
+ }
+
+ private String hasErrorInPrefixedDataAvailable(HashMap<String, AnnotationDriverVo> driverMap,
+ HashMap<String, AnnotationPrefixedDataAvailableVo> prefixedDataAvailableMap){
+ Collection<AnnotationPrefixedDataAvailableVo> col = prefixedDataAvailableMap.values();
+ for(AnnotationPrefixedDataAvailableVo vo : col){
+ if(!driverMap.containsKey(vo.protocolName)){
+ return "涓ラ噸閿欒锛屼笂琛屾暟鎹畬鏁存�ф鏌ユ墍閰嶉┍鍔ㄥ悕绉�(" + vo.protocolName + ")鍦ㄥ崗璁┍鍔ㄤ腑鏈厤缃�" ;
+ }
+ }
+
+ int[] prioritys = new int[prefixedDataAvailableMap.size()] ;
+ int count = 0 ;
+ col = prefixedDataAvailableMap.values();
+ for(AnnotationPrefixedDataAvailableVo vo : col){
+ prioritys[count++] = vo.priority ;
+ }
+ NumUtil.sort(prioritys, true) ;
+
+ int firstPriority = prioritys[0] ;
+ if(ProtocolConstant.firstPriority != firstPriority){
+ return "涓ラ噸閿欒锛屼笂琛屾暟鎹畬鏁存�ф鏌ユ墍閰嶄紭鍏堢骇蹇呴』浠� " + ProtocolConstant.firstPriority + " 寮�濮�" ;
+ }
+ int prePriority = prioritys[0] ;
+ int nextPriority;
+ if(prioritys.length > 1){
+ for(int i = 1 ; i < prioritys.length; i++){
+ nextPriority = prioritys[i] ;
+ if(nextPriority - prePriority != 1){
+ return "涓ラ噸閿欒锛屼笂琛屾暟鎹畬鏁存�ф鏌ユ墍閰嶅悇涓紭鍏堢骇蹇呴』鐩稿樊1" ;
+ }else{
+ prePriority = nextPriority ;
+ }
+ }
+ }
+ return null ;
+ }
+
+ private String hasErrorInOnLine(HashMap<String, AnnotationDriverVo> driverMap,
+ HashMap<String, AnnotationOnLineVo> onLineMap){
+ Collection<AnnotationOnLineVo> col = onLineMap.values();
+ for(AnnotationOnLineVo vo : col){
+ if(!driverMap.containsKey(vo.protocolName)){
+ return "涓ラ噸閿欒锛屼笂绾挎暟鎹垎鏋愭墍閰嶉┍鍔ㄥ悕绉�(" + vo.protocolName + ")鍦ㄥ崗璁┍鍔ㄤ腑鏈厤缃�" ;
+ }
+ }
+
+ int[] prioritys = new int[onLineMap.size()] ;
+ int count = 0 ;
+ col = onLineMap.values();
+ for(AnnotationOnLineVo vo : col){
+ prioritys[count++] = vo.priority ;
+ }
+ NumUtil.sort(prioritys, true) ;
+
+ int firstPriority = prioritys[0] ;
+ if(ProtocolConstant.firstPriority != firstPriority){
+ return "涓ラ噸閿欒锛屼笂绾挎暟鎹垎鏋愭墍閰嶄紭鍏堢骇蹇呴』浠� " + ProtocolConstant.firstPriority + " 寮�濮�" ;
+ }
+ int prePriority = prioritys[0] ;
+ int nextPriority;
+ if(prioritys.length > 1){
+ for(int i = 1 ; i < prioritys.length; i++){
+ nextPriority = prioritys[i] ;
+ if(nextPriority - prePriority != 1){
+ return "涓ラ噸閿欒锛屼笂绾挎暟鎹垎鏋愭墍閰嶅悇涓紭鍏堢骇蹇呴』鐩稿樊1" ;
+ }else{
+ prePriority = nextPriority ;
+ }
+ }
+ }
+ return null ;
+ }
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/CodeParse.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/CodeParse.java
new file mode 100644
index 0000000..da1fac5
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/CodeParse.java
@@ -0,0 +1,12 @@
+package com.dy.common.mw.protocol;
+
+/**
+ * 涓婅鏁版嵁鍔熻兘鐮佽В鏋愬強涓嬭鏁版嵁鍔熻兘鐮佸懡浠ゆ瀯閫� 绫绘帴鍙e畾涔�
+ * @author Administrator
+ *
+ */
+public interface CodeParse {
+
+ MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback) throws Exception ;
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/CodeParseCallback.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/CodeParseCallback.java
new file mode 100644
index 0000000..23776b9
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/CodeParseCallback.java
@@ -0,0 +1,12 @@
+package com.dy.common.mw.protocol;
+
+public interface CodeParseCallback {
+
+ /**
+ * 璁剧疆涓婅鏁版嵁绫诲瀷锛屼笂鎶ユ暟鎹�:true锛屽懡浠ゅ簲绛�:false锛屽叾浠栵紙濡傚績璺炽�侀摼璺淮鎸侊級:null
+ * 鍙栧緱鏁版嵁涓殑rtuAddr
+ * @param reportOrResponse_trueOrFalse
+ */
+ void callback(Boolean reportOrResponse_trueOrFalse) ;
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/CodeParseParams.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/CodeParseParams.java
new file mode 100644
index 0000000..170a40e
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/CodeParseParams.java
@@ -0,0 +1,7 @@
+package com.dy.common.mw.protocol;
+
+/**
+ * 涓婅鏁版嵁鍙婁笅琛屽懡浠ゆ暟鎹� 鐨勫姛鑳界爜鍒嗘瀽绫绘垨鍔熻兘鐮佸懡浠ゆ瀯閫犵被 锛屽悜鍏朵紶閫掔殑鍙傛暟绫荤殑鎺ュ彛瀹氫箟
+ */
+public interface CodeParseParams {
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Command.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Command.java
new file mode 100644
index 0000000..674046b
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Command.java
@@ -0,0 +1,269 @@
+package com.dy.common.mw.protocol;
+
+import java.io.Serializable;
+
+import com.alibaba.fastjson2.JSON ;
+
+public class Command implements Serializable{
+
+ public static final long serialVersionUID;
+ static {
+ serialVersionUID = 201211292156L;
+ }
+
+ /**
+ * 榛樿鍛戒护ID
+ * 濡傛灉鍛戒护涓嶅湪鏁版嵁搴撲腑瀛樺偍锛屾垨鍏朵粬鍙互鐢╠efaultId
+ */
+ public static final String defaultId = "999999999" ;
+
+ /**
+ * 鏈潯鍛戒护鐨処D
+ * 涓�鑸槸鍛戒护鍦ㄦ暟鎹簱涓瓨鍌ㄨ褰旾D鐨勫瓧绗︿覆褰㈠紡
+ */
+ public String id;
+
+ /**
+ * 姘磋〃鍗忚鍚嶇О锛岃繖涓彲浠ヤ负绌猴紝鍥犱负姘磋〃涓婅鏁版嵁瑙f瀽鍑哄崗璁悕绉帮紝鐒跺悗绯荤粺鎶婂崗璁悕绉颁繚瀛樺湪姘磋〃鏁版嵁璁板綍涓紝浠庢鍗忚鍚嶇О灏变笉鍐嶇┖浜�
+ */
+ public String protocol;
+
+ /**
+ * RTU 鍦板潃
+ */
+ public String rtuAddr ;
+
+ /**
+ * 姘磋〃鍙�
+ * 搴旂敤鐢典俊骞冲彴鏃舵湁鏁�
+ */
+ public String meterNo ;
+
+ /**
+ * 鐢典俊骞冲彴涓婄殑浜у搧ID锛屽綋涓嶅湪鐢典俊骞冲彴涓婅繍琛屾椂锛屼负null
+ * 搴旂敤鐢典俊骞冲彴鏃舵湁鏁�
+ */
+ public Integer productId ;
+
+ /**
+ * 鐢典俊骞冲彴涓婄殑璁惧ID锛屽綋涓嶅湪鐢典俊骞冲彴涓婅繍琛屾椂锛屼负null
+ * 搴旂敤鐢典俊骞冲彴鏃舵湁鏁�
+ */
+ public String deviceId ;
+
+ /**
+ * 鍛戒护绫诲瀷:Rtu鍛戒护銆侀拡瀵圭洃鎺т腑闂翠欢鐨勫懡浠�
+ * 鐢眂om.dy.common.mw.protocol.CommandType绫诲畾涔�
+ */
+ public String type ;
+
+ /**
+ * 鍔熻兘鐮�
+ */
+ public String code ;
+
+ /**
+ * 涓嶈繑鍥炰腑闂翠欢瀵瑰懡浠ゅ鐞嗙粨鏋滐紙true锛氫笉杩斿洖澶勭悊缁撴灉锛宖alse鎴杗ull锛氳繑鍥炲鐞嗙粨鏋滐級
+ */
+ public Boolean noRtMwDealRes ;
+
+ /**
+ * 鍏蜂綋鍙傛暟鏁版嵁
+ */
+ public Object param ;
+
+ /**
+ * 鍏朵粬鏁版嵁
+ */
+ public Object attachment ;
+
+ public String toString(){
+ String s = "鍛戒护id=" + id + "\n" ;
+ s += (protocol == null ? "" : ("鍗忚=" + protocol + "\n"));
+ s += (rtuAddr == null ? "" : ("IMEI鍙�=" + rtuAddr + "\n"));
+ s += (meterNo == null ? "" : ("姘磋〃鍙�=" + meterNo + "\n"));
+ if(productId != null){
+ s += "鐢典俊骞冲彴浜у搧ID=" + productId + "\n" ;
+ }
+ if(deviceId != null && !deviceId.trim().equals("")){
+ s += "鐢典俊骞冲彴璁惧ID=" + deviceId + "\n" ;
+ }
+ s += "鍛戒护绫诲瀷=" + (type.equals(CommandType.innerCommand)?"鍐呴儴鍛戒护":"缁堢鍛戒护") + "\n" ;
+ s += (code == null ? "" : ("鍔熻兘鐮�=" + code + "\n")) ;
+ s += "杩斿洖涓棿浠跺鍛戒护澶勭悊缁撴灉=" + (noRtMwDealRes == null?"杩斿洖":(noRtMwDealRes?"涓嶈繑鍥�":"杩斿洖") + "\n") ;
+ if(param != null){
+ s += "鍙傛暟:" + param ;
+ }
+ if(attachment != null){
+ s += "鍏朵粬鏁版嵁:" + attachment ;
+ }
+ return s ;
+ }
+ /**
+ * 瀵硅薄杞垚json
+ * @return json
+ * @throws Exception 寮傚父
+ */
+ @SuppressWarnings("unused")
+ public String toJson()throws Exception{
+ try{
+ return JSON.toJSONString(this) ;
+ }catch(Exception e){
+ throw new Exception(e.getMessage() , e ) ;
+ }
+ }
+ /**
+ * json杞垚瀵硅薄
+ * @param json json
+ * @return Command
+ * @throws Exception 寮傚父
+ */
+ @SuppressWarnings("unused")
+ public static Command jsonToObject(String json)throws Exception{
+ try{
+ return JSON.parseObject(json, Command.class) ;
+ }catch(Exception e){
+ throw new Exception(e.getMessage() , e ) ;
+ }
+ }
+
+ /**
+ * 鍒涘缓杩斿洖鐨勫嚭閿欏懡浠�
+ * @param error 閿欒娑堟伅
+ * @param commandId 鍛戒护ID
+ * @return Command
+ */
+ @SuppressWarnings("unused")
+ public Command createReturnErrorCommand(String error , String commandId, String code){
+ if(commandId == null){
+ this.setId(defaultId) ;
+ }else{
+ this.setId(commandId) ;
+ }
+ this.code = code ;
+ this.type = CommandType.resultCommand ;
+
+ CommandBackParam p = new CommandBackParam() ;
+ p.setSuccess(false) ;
+ p.setMessage(error) ;
+
+ this.param = p ;
+
+ return this ;
+ }
+
+ /**
+ * 鍒涘缓杩斿洖鐨勭畝鍗曟垚鍔熷懡浠わ紝閽堝鐩戞帶涓棿浠剁殑鍛戒护
+ * @param message 娑堟伅
+ * @param commandId 鍛戒护ID
+ * @param code 鍔熻兘鐮�
+ * @return Command
+ */
+ @SuppressWarnings("unused")
+ public Command createReturnSuccessCommand(String message , String commandId, String code){
+ if(commandId == null){
+ this.setId(defaultId) ;
+ }else{
+ this.setId(commandId) ;
+ }
+ this.code = code ;
+ this.type = CommandType.resultCommand ;
+
+ CommandBackParam p = new CommandBackParam() ;
+ p.setSuccess(true) ;
+ p.setMessage(message) ;
+
+ this.param = p ;
+
+ return this ;
+ }
+ /*
+ public static void main(String[] args){
+ String json = "{\"attachment\":null,\"code\":\"03\",\"deviceId\":\"d8c9601f214747d98d47a4736e5\",\"id\":\"999999999\",\"meterNo\":\"23040600377\",\"productId\":16873252,\"param\":\"0002\",\"protocol\":\"HAC_NBhV2_5\",\"rtuAddr\":\"863318060168996\",\"type\":\"outerCommand\"}" ;
+ try {
+ Command com = jsonToObject(json) ;
+ System.out.println(com.param);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ */
+
+ public String getId() {
+ return id;
+ }
+ public Command setId(String id) {
+ this.id = id;
+ return this ;
+ }
+ public String getRtuAddr() {
+ return rtuAddr;
+ }
+ public Command setRtuAddr(String rtuAddr) {
+ this.rtuAddr = rtuAddr;
+ return this ;
+ }
+
+ public String getProtocol() {
+ return protocol;
+ }
+ public void setProtocol(String protocol) {
+ this.protocol = protocol;
+ }
+ public String getMeterNo() {
+ return meterNo;
+ }
+ public void setMeterNo(String meterNo) {
+ this.meterNo = meterNo;
+ }
+ public Integer getProductId() {
+ return productId;
+ }
+ public void setProductId(Integer productId) {
+ this.productId = productId;
+ }
+ public String getDeviceId() {
+ return deviceId;
+ }
+ public void setDeviceId(String deviceId) {
+ this.deviceId = deviceId;
+ }
+ public String getType() {
+ return type;
+ }
+ public Command setType(String type) {
+ this.type = type;
+ return this ;
+ }
+ public String getCode() {
+ return code;
+ }
+ public Command setCode(String code) {
+ this.code = code;
+ return this ;
+ }
+ @SuppressWarnings("unused")
+ public Boolean getNoRtMwDealRes() {
+ return noRtMwDealRes;
+ }
+ @SuppressWarnings("unused")
+ public void setNoRtMwDealRes(Boolean noRtMwDealRes) {
+ this.noRtMwDealRes = noRtMwDealRes;
+ }
+ public Object getParam() {
+ return param;
+ }
+ public Command setParam(Object param) {
+ this.param = param;
+ return this ;
+ }
+ public Object getAttachment() {
+ return attachment;
+ }
+ @SuppressWarnings("unused")
+ public Command setAttachment(Object attachment) {
+ this.attachment = attachment;
+ return this ;
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/CommandBackParam.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/CommandBackParam.java
new file mode 100644
index 0000000..3029283
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/CommandBackParam.java
@@ -0,0 +1,41 @@
+package com.dy.common.mw.protocol;
+
+import java.io.Serializable;
+
+public class CommandBackParam implements Serializable{
+
+ public static final long serialVersionUID;
+ static {
+ serialVersionUID = 201606251456001L;
+ }
+
+ //鍛戒护澶勭悊鏄惁鎴愬姛(鐩戞帶涓棿浠跺鐞嗗懡浠ゆ槸鍚︽垚鍔燂紝涓嶄唬琛ㄥ彂閫佸懡浠ょ粰Rtu鎴愬姛涓庡惁)锛�
+ private Boolean success ;
+ //鍛戒护澶勭悊鎯呭喌鐨勬秷鎭�
+ private String message ;
+
+ public String toString(){
+ String s = "" ;
+ if(this.success != null){
+ s += "success:" + this.success + "\n" ;
+ }
+ if(this.message != null){
+ s += "message:" + this.message + "\n" ;
+ }
+ return s ;
+ }
+ @SuppressWarnings("unused")
+ public Boolean getSuccess() {
+ return success;
+ }
+ public void setSuccess(Boolean success) {
+ this.success = success;
+ }
+ public String getMessage() {
+ return message;
+ }
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/CommandType.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/CommandType.java
new file mode 100644
index 0000000..84869f0
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/CommandType.java
@@ -0,0 +1,22 @@
+package com.dy.common.mw.protocol;
+
+public class CommandType {
+
+ /**
+ * 閽堝鐩戞帶涓棿浠剁殑鍐呴儴鍛戒护
+ * 鍙疄鐜板悓姝ワ紝鍛戒护缁撴灉閫氳繃鍛戒护鐨勫彂閫佺綉缁滈�氶亾杩斿洖
+ */
+ public static final String innerCommand = "innerCommand" ;
+
+ /**
+ * 閽堝Rtu澶栭儴鍛戒护
+ * 鍙兘鏄紓姝ワ紝鍛戒护缁撴灉閫氳繃鐩稿叧鐨勪俊鎭彂甯冮�氶亾鍙戝竷鍑哄幓
+ */
+ public static final String outerCommand = "outerCommand" ;
+
+ /**
+ * 鏈懡浠ゆ槸涓�涓埆鐨勫懡浠ょ殑缁撴灉锛堢粨鏋滀互鍛戒护鐨勬柟寮忚〃绀猴級
+ */
+ public static final String resultCommand = "resultCommand" ;
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Data.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Data.java
new file mode 100644
index 0000000..53ffb2c
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Data.java
@@ -0,0 +1,144 @@
+package com.dy.common.mw.protocol;
+
+import com.alibaba.fastjson2.JSON;
+
+/**
+ * 鏁版嵁鏍�
+ * @author Administrator
+ *
+ */
+public class Data implements java.io.Serializable{
+
+ private static final long serialVersionUID = 20160805192500101L;
+
+ public static String ALIAS = Data.class.getName() ;
+
+ private String commandId ;//鍛戒护ID锛屽彲鑳戒负null
+ private String rtuAddr ;//缁堢鍦板潃
+ private String meterNo ;//姘磋〃鍙�
+ private String protocol ;//鏁版嵁鎵�瀵瑰簲鐨勫崗璁悕绉�
+ private String code ;//鏁版嵁鎵�瀵瑰簲鐨勫姛鑳界爜:
+ private Object subData ;//瀵瑰簲鍚勪釜鍔熻兘鐮佺殑鍏蜂綋鏁版嵁
+ private String hex ;//涓婃姤鏁版嵁鐨勫崄鍏繘鍒�
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer() ;
+ sb.append("涓婅鎶ユ枃(鍗佸叚杩涘埗): " + (hex == null?"":hex) + "\n") ; //
+ sb.append("IMEI鍙� : " + (rtuAddr==null?"":rtuAddr) + "\n") ;
+ sb.append("姘磋〃鍙� : " + (meterNo==null?"":meterNo) + "\n") ;
+ if(commandId != null){
+ sb.append("鍛戒护ID : " + commandId + "\n") ; //鍛戒护ID
+ }
+ sb.append("鍗忚 : " + (protocol == null?"":protocol) + "\n") ; //
+ sb.append((code == null ? "" : ("鍔熻兘鐮�:" + code + "\n"))) ;
+ if(this.subData != null){
+ sb.append("涓婅鏁版嵁锛歕n" + this.subData.toString()) ;
+ }
+ return sb.toString() ;
+ }
+
+
+ /**
+ * 瀵硅薄杞垚json
+ * @return json
+ * @throws Exception
+ */
+ public String toJson()throws Exception{
+ return JSON.toJSONString(this);
+ }
+ /**
+ * json杞垚瀵硅薄
+ * @param json
+ * @return Data
+ * @throws Exception
+ */
+ public static Data jsonToObject(String json)throws Exception{
+ return JSON.parseObject(json, Data.class) ;
+ }
+
+ /*
+ public static void main(String[] rags) throws Exception{
+ Data d = new Data() ;
+ d.code = "01" ;
+ d.rtuAddr = "123234" ;
+ d.meterNo = "1234567890123456" ;
+
+ DataV1_0_1 subD = new DataV1_0_1() ;
+ subD.rtuAddr = "2342345" ;
+ subD.meterNo = "1234567890123456" ;
+
+ d.subData = subD ;
+
+
+ DataCd01Vo cd1Vo = new DataCd01Vo() ;
+ cd1Vo.dt = "345w" ;
+
+ subD.dataCd01Vo = cd1Vo ;
+
+ String json = d.toJson() ;
+
+ System.out.println(json);
+ }
+ */
+
+ public String getRtuAddr() {
+ return rtuAddr;
+ }
+
+ public void setRtuAddr(String rtuAddr) {
+ this.rtuAddr = rtuAddr;
+ }
+
+ public String getMeterNo() {
+ return meterNo;
+ }
+ public void setMeterNo(String meterNo) {
+ this.meterNo = meterNo;
+ }
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public String getProtocol() {
+ return protocol;
+ }
+
+ public void setProtocol(String protocol) {
+ this.protocol = protocol;
+ }
+
+ public Object getSubData() {
+ return subData;
+ }
+
+ public void setSubData(Object subData) {
+ this.subData = subData;
+ }
+
+ public String getHex() {
+ return hex;
+ }
+
+ public void setHex(String hex) {
+ this.hex = hex;
+ }
+
+ public void setCommandId(String commandId) {
+ this.commandId = commandId;
+ }
+ /**
+ * 寰楀埌涓婅鏁版嵁瀵瑰簲鐨勫懡浠D
+ * 濡傛灉鏄富鍔ㄤ笂鎶ユ暟鎹紝鍒欐ID涓虹┖
+ * @return commandId
+ */
+ public String getCommandId(){
+ return this.commandId ;
+ }
+
+
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Data4Temp.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Data4Temp.java
new file mode 100644
index 0000000..446ece9
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Data4Temp.java
@@ -0,0 +1,28 @@
+package com.dy.common.mw.protocol;
+
+/**
+ * 鏁版嵁鏍�---涓存椂瀵硅薄
+ */
+@SuppressWarnings("unused")
+public class Data4Temp implements java.io.Serializable{
+
+ public static final long serialVersionUID;
+
+ static {
+ serialVersionUID = 202307261129001L;
+ }
+
+ public static String ALIAS = Data4Temp.class.getName() ;
+
+ public String protocol ;//鏁版嵁鎵�瀵瑰簲鐨勫崗璁悕绉�
+
+ public String getProtocol() {
+ return protocol;
+ }
+
+ public void setProtocol(String protocol) {
+ this.protocol = protocol;
+ }
+
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Driver.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Driver.java
new file mode 100644
index 0000000..b3efc80
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Driver.java
@@ -0,0 +1,176 @@
+package com.dy.common.mw.protocol;
+
+import java.net.URI;
+import java.util.HashMap;
+import java.util.List;
+
+import com.dy.common.util.ClassScan;
+
+
+public abstract class Driver {
+
+ //鍗曠嚎绋嬪崟渚婦river妯″紡涓嬭繍琛�
+ protected HashMap<String, Class<CodeParse>> upCode2Classes = new HashMap<>() ;
+ protected HashMap<String, CodeParse> upCode2ClassInstance = new HashMap<>() ;
+ protected HashMap<String, Class<CodeParse>> downCode2Class = new HashMap<>() ;
+ protected HashMap<String, CodeParse> downCode2ClassInstance = new HashMap<>() ;
+
+ /**
+ * 鍗曠嚎绋嬪崟渚婦river妯″紡涓嬭繍琛�
+ * 鎵弿璇嗗埆鍔熻兘鐮佹敞瑙g被
+ * @throws Exception 寮傚父
+ */
+ public abstract void scanAnnotationCode() throws Exception ;
+
+ /**
+ * 鎵弿璇嗗埆鍔熻兘鐮佹敞瑙g被
+ * @param driver 椹卞姩
+ * @param protocolName 鍗忚鍚嶇О
+ * @param uri URI
+ * @param scanRootPackage 鎵弿鍖�
+ * @throws Exception 寮傚父
+ */
+ @SuppressWarnings("unchecked")
+ protected void doScanAnnotationCode(Driver driver, String protocolName, URI uri, String scanRootPackage) throws Exception{
+ ClassLoader load = driver.getClass().getClassLoader() ;
+ List<String> classNames = new ClassScan().searchClassFromUrl(new URI[]{uri}, scanRootPackage) ;
+ if(classNames != null && classNames.size() > 0){
+ String code ;
+ String[] codes ;
+ for(String cName : classNames){
+ String className = cName.substring(0, cName.lastIndexOf('.')) ;
+ Class<?> clazz = load.loadClass(className) ;
+ Class<CodeParse> codeParseClazz ;
+ if(clazz.isAnnotationPresent(AnnotationCodeUp.class)){
+ AnnotationCodeUp ann = clazz.getAnnotation(AnnotationCodeUp.class) ;
+ if(ann != null){
+ codeParseClazz = (Class<CodeParse>)clazz ;
+ codes = ann.ifAny() ;
+ if(codes.length > 0){
+ for(String cd: codes){
+ cd = cd.trim() ;
+ if(!(cd.trim().equals(""))){
+ if(driver.upCode2Classes.containsKey(cd)){
+ throw new Exception("涓ラ噸閿欒锛屽崗璁�" + protocolName + "鐨勪笂琛屾暟鎹姛鑳界爜" + cd + "鍑虹幇浜嗛噸澶嶆敞瑙o紒") ;
+ }
+ driver.upCode2Classes.put(cd, codeParseClazz) ;
+ }
+ }
+ }else{
+ code = ann.value().trim() ;
+ if(!(code.equals(""))){
+ if(driver.upCode2Classes.containsKey(code)){
+ throw new Exception("涓ラ噸閿欒锛屽崗璁�" + protocolName + "鐨勪笂琛屾暟鎹姛鑳界爜" + code + "鍑虹幇浜嗛噸澶嶆敞瑙o紒") ;
+ }
+ driver.upCode2Classes.put(code, codeParseClazz) ;
+ }
+ }
+ }
+ }
+
+ if(clazz.isAnnotationPresent(AnnotationCodeDown.class)){
+ AnnotationCodeDown ann = clazz.getAnnotation(AnnotationCodeDown.class) ;
+ if(ann != null){
+ codeParseClazz = (Class<CodeParse>)clazz ;
+ codes = ann.ifAny() ;
+ if(codes.length > 0){
+ for(String cd: codes){
+ cd = cd.trim() ;
+ if(!(cd.trim().equals(""))){
+ if(driver.downCode2Class.containsKey(cd)){
+ throw new Exception("涓ラ噸閿欒锛屽崗璁┍鍔�" + protocolName + "鐨勪笅琛屾暟鎹姛鑳界爜" + cd + "鍑虹幇浜嗛噸澶嶆敞瑙o紒") ;
+ }
+ driver.downCode2Class.put(cd, codeParseClazz) ;
+ }
+ }
+ }else{
+ code = ann.value() ;
+ if(!(code.trim().equals(""))){
+ if(driver.downCode2Class.containsKey(code)){
+ throw new Exception("涓ラ噸閿欒锛屽崗璁┍鍔�" + protocolName + "鐨勪笅琛屾暟鎹姛鑳界爜" + code + "鍑虹幇浜嗛噸澶嶆敞瑙o紒") ;
+ }
+ driver.downCode2Class.put(code, codeParseClazz) ;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ /**
+ * 鍗曠嚎绋嬪崟渚婦river妯″紡涓嬭繍琛�
+ * 寰楀埌涓婅鏁版嵁鍔熻兘鐮佸鐞嗙被CodeParse瀵硅薄
+ * @param code 鍔熻兘鐮�
+ * @return CodeParse
+ * @throws Exception 寮傚父
+ */
+ public CodeParse getUpCodeParser(String code) throws Exception{
+ CodeParse codeParse = upCode2ClassInstance.get(code) ;
+ if(codeParse == null){
+ Class<CodeParse> clazz = upCode2Classes.get(code) ;
+ if(clazz == null){
+ clazz = upCode2Classes.get(ProtocolConstant.anyCode) ;
+ }
+ if(clazz != null){
+ //codeParse = clazz.newInstance() ;
+ codeParse = clazz.getDeclaredConstructor(CodeParse.class).newInstance();
+ upCode2ClassInstance.put(code, codeParse) ;
+ }
+ }
+ return codeParse ;
+ }
+ /**
+ * 鍗曠嚎绋嬪崟渚婦river妯″紡涓嬭繍琛�
+ * 寰楀埌涓嬭鏁版嵁鍔熻兘鐮佸鐞嗙被CodeParse瀵硅薄
+ * @param code 鍔熻兘鐮�
+ * @return CodeParse
+ * @throws Exception 寮傚父
+ */
+ public CodeParse getDownCodeParser(String code) throws Exception{
+ CodeParse codeParse = downCode2ClassInstance.get(code) ;
+ if(codeParse == null){
+ Class<CodeParse> clazz = downCode2Class.get(code) ;
+ if(clazz == null){
+ clazz = downCode2Class.get(ProtocolConstant.anyCode) ;
+ }
+ if(clazz != null){
+ //codeParse = clazz.newInstance() ;
+ codeParse = clazz.getDeclaredConstructor(CodeParse.class).newInstance();
+ downCode2ClassInstance.put(code, codeParse) ;
+ }
+ }
+ return codeParse ;
+ }
+ /**
+ * 瑙f瀽涓婅鏁版嵁
+ * @param isLowPower 鏄惁鍦ㄤ綆鍔熻�楃幆澧冧笅杩愯
+ * @param rtuAddr 鎺у埗鍣ㄥ湴鍧�
+ * @param upBuffer 瀛楄妭鏁扮粍
+ * @param upHex 瀛楄妭鏁扮粍16杩涘埗褰㈠紡
+ * @param callback 鍥炶皟
+ * @return MidResult[]
+ */
+ public abstract MidResult[] parseData(Boolean isLowPower, String rtuAddr, byte[] upBuffer, String upHex, DriverParserDataCallback callback, Object... params) ;
+ /**
+ * 瑙f瀽鐢典俊骞冲彴涓婅鏁版嵁
+ * @param isLowPower 鏄惁鍦ㄤ綆鍔熻�楃幆澧冧笅杩愯
+ * @param rtuAddr 鎺у埗鍣ㄥ湴鍧�
+ * @param productId 鐢典俊骞冲彴浜у搧ID锛屽綋涓嶅湪鐢典俊骞冲彴涓繍琛屾椂锛屼负null
+ * @param deviceId 鐢典俊骞冲彴璁惧ID锛屽綋涓嶅湪鐢典俊骞冲彴涓繍琛屾椂锛屼负null
+ * @param upBuffer 瀛楄妭鏁扮粍
+ * @param upHex 瀛楄妭鏁扮粍16杩涘埗褰㈠紡
+ * @param callback 鍥炶皟
+ * @return MidResult[]
+ */
+ public abstract MidResult[] parseData(Boolean isLowPower, String rtuAddr, Integer productId, String deviceId, byte[] upBuffer, String upHex, DriverParserDataCallback callback, Object... params) ;
+
+ /**
+ * 鏋勯�犱笅琛屾暟鎹紙鍛戒护锛�
+ * @param isLowPower 鏄惁鍦ㄤ綆鍔熻�楃幆澧冧笅杩愯
+ * @param command 鍛戒护
+ * @return MidResult[]
+ */
+ public abstract MidResult[] createCommand(Boolean isLowPower, Command command, Object... params);
+
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/DriverParserDataCallback.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/DriverParserDataCallback.java
new file mode 100644
index 0000000..62b845a
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/DriverParserDataCallback.java
@@ -0,0 +1,26 @@
+package com.dy.common.mw.protocol;
+
+public interface DriverParserDataCallback {
+
+ /**
+ * 瑙f瀽涓婅鏁版嵁鍚庡洖璋�
+ * @param rtuAddr 涓婅鏁版嵁鍗忚澶翠腑鐨処MEI鍙�
+ * @param rtuAddr 涓婅鏁版嵁鍗忚澶翠腑鐨勬按琛ㄥ彿
+ * @param code 涓婅鏁版嵁 鍔熻兘鐮�
+ * @param upHex 涓婅鏁版嵁
+ * @param reportOrResponse_trueOrFalse 涓婅鏁版嵁鏄富鍔ㄤ笂鎶ヨ繕鏄懡浠ょ粨鏋�
+ * @param parseFail 涓婅鏁版嵁瑙f瀽鏄惁澶辫触
+ * @param rtuAddrInData 涓婅鏁版嵁涓湪鍗忚鏁版嵁涓殑IMEI鍙凤紝
+ * @param meterNoInData 涓婅鏁版嵁涓湪鍗忚鏁版嵁涓殑姘磋〃鍙凤紝
+ * 鈥滀慨鏀筊TU缁堢绠$悊閰嶇疆鍙傛暟鈥濆懡浠ょ殑杩斿洖鏁版嵁锛屽叾鍗忚澶翠腑鐨処MEI鍙蜂笌鏁版嵁涓殑IMEI鍙蜂笉涓�鏍凤紝
+ * 濡傛灉RTU涓嶈兘鍏抽棴缃戠粶锛岄偅涔坰essionCach涓殑IMEI鍙锋�绘槸鐢ㄤ慨鏀瑰墠鐨処MEI鍙凤紝浣垮緱浠ュ悗涓婅鏁版嵁鐨勪笉鑳芥壘鍒扮紦瀛樹腑鐨凷ession
+ */
+ void callback(String rtuAddr,
+ String meterNo,
+ String code,
+ String upHex,
+ Boolean reportOrResponse_trueOrFalse,
+ boolean parseFail,
+ String rtuAddrInData,
+ String meterNoInData) ;
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/MidResult.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/MidResult.java
new file mode 100644
index 0000000..50b09b3
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/MidResult.java
@@ -0,0 +1,7 @@
+package com.dy.common.mw.protocol;
+
+import java.io.Serializable;
+
+public interface MidResult extends Serializable{
+ void action() ;
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/MidResultAction.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/MidResultAction.java
new file mode 100644
index 0000000..b159489
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/MidResultAction.java
@@ -0,0 +1,11 @@
+package com.dy.common.mw.protocol;
+
+/**
+ * action绫诲璞$殑鎵ц绫绘帴鍙e畾涔�
+ * @author Administrator
+ *
+ */
+public interface MidResultAction {
+
+ void doAction(MidResult result) ;
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/MidResultError.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/MidResultError.java
new file mode 100644
index 0000000..0a71d84
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/MidResultError.java
@@ -0,0 +1,32 @@
+package com.dy.common.mw.protocol;
+
+/**
+ * 澶勭悊鍑洪敊
+ */
+public class MidResultError implements MidResult{
+
+ public static final long serialVersionUID;
+ static {
+ serialVersionUID = 201606271057001L;
+ }
+
+ public String protocolName ;//鍗忚鍚嶇О
+ public String rtuAddr ;//IMEI鍙凤紝娉ㄦ剰rtuAddr鍙兘涓簄ull
+ public String meterNo ;//姘磋〃鍙凤紝娉ㄦ剰meterNo鍙兘涓簄ull
+ public String message ;//鍑洪敊娑堟伅
+ public Exception e ;//寮傚父
+
+ public MidResultError(String protocolName, String rtuAddr, String meterNo, String message, Exception e){
+ this.protocolName = protocolName ;
+ this.rtuAddr = rtuAddr ;
+ this.meterNo = meterNo ;
+ this.message = message ;
+ this.e = e ;
+ }
+
+ @Override
+ public void action() {
+ ProtocolUnit.getInstance().adapter.getSingleActionError(this.protocolName).doAction(this);
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/MidResultFromRtu.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/MidResultFromRtu.java
new file mode 100644
index 0000000..50562ef
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/MidResultFromRtu.java
@@ -0,0 +1,38 @@
+package com.dy.common.mw.protocol;
+
+/**
+ * 浠嶳TU鏀跺埌鏁版嵁
+ */
+public class MidResultFromRtu implements MidResult{
+
+ public static final long serialVersionUID;
+ static {
+ serialVersionUID = 201606271057002L;
+ }
+
+ public String commandId ;//鍙戦�佸懡浠ょ殑ID锛屽鏋滄槸鍛戒护缁撴灉锛屽苟涓斿尮閰嶄簡涓嬪彂鍛戒护锛屾鍊间笉涓虹┖
+
+ public String protocolName ;//鍗忚鍚嶇О
+ public String rtuAddr ;//IMEI鍙�
+ public String meterNo ;//姘磋〃鍙�
+ public Integer productId ;//鐢典俊骞冲彴浜у搧ID锛屽綋涓嶅湪鐢典俊骞冲彴杩愯鏃讹紝涓簄ull
+ public String deviceId ;//鐢典俊骞冲彴璁惧ID锛屽綋涓嶅湪鐢典俊骞冲彴杩愯鏃讹紝涓簄ull
+ public String upCode ;//涓婅鏁版嵁涓殑鍔熻兘鐮�
+ public String upHex ;//涓婅鏁版嵁鍗佸叚杩涘埗褰㈠紡
+ public byte[] upBuffer ;//涓婅鏁版嵁瀛楄妭鏁扮粍
+ public Data data ;//瑙f瀽鍚庣殑鏁版嵁
+ public Boolean reportOrResponse_trueOrFalse ;//鏁版嵁鏄嚜鍔ㄤ笂鎶ヨ繕鏄懡浠ゅ簲绛旓紝鑷姩涓婃姤(report)涓簍rue锛屽懡浠ゅ簲绛旓紙response锛変负false
+
+ @Override
+ public void action() {
+ ProtocolUnit.getInstance().adapter.getSingleActionFromRtu(this.protocolName).doAction(this);
+ }
+
+ public void setCommandId(String commandId){
+ this.commandId = commandId ;
+ if(this.data != null){
+ this.data.setCommandId(commandId);
+ }
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/MidResultToRtu.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/MidResultToRtu.java
new file mode 100644
index 0000000..4c58abe
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/MidResultToRtu.java
@@ -0,0 +1,41 @@
+package com.dy.common.mw.protocol;
+
+/**
+ * 鍚慠TU鍙戦�佹暟鎹�
+ */
+public class MidResultToRtu implements MidResult{
+
+ public static final long serialVersionUID;
+ static {
+ serialVersionUID = 201606271057003L;
+ }
+
+ public String protocolName ;//鍗忚鍚嶇О
+ public String rtuAddr ;//IMEI鍙�(鐢典俊骞冲彴IMEI)
+ public String meterNo ;//姘磋〃鍙�
+ public Integer productId ;//鐢典俊骞冲彴浜у搧ID
+ public String deviceId ;//鐢典俊骞冲彴璁惧ID
+ public String commandId ;//鍛戒护ID锛屽彂璧峰懡浠ょ殑瀹㈡埛绔�(web绔�)鐢熸垚锛屼互鍖归厤鍛戒护缁撴灉
+ public String downCode ;//涓嬭鍛戒护鍔熻兘鐮�;
+ public byte[] downBuffer ;//涓嬭鍛戒护鏁版嵁
+ public String downBufHex ;//涓嬭鍛戒护鏁版嵁鍗佸叚杩涘埗褰㈠紡
+ public boolean hasResponse ;//鏄惁鏈夊簲绛�
+ public Byte maxSendTimes ;//鍛戒护鏈�澶у彂閫佹鏁�(褰撴敹涓嶅埌搴旂瓟鏃讹紝灏嗛噸鍙�)锛屽鏋滀笉璁剧疆锛屽懡浠ょ紦瀛樺櫒杩涜琛ュ厖璁剧疆
+ public boolean isCachForOffLine ;//RTU涓嶅湪绾匡紝鍛戒护鏄惁缂撳瓨
+
+ public boolean isSendFirst;//浼樺厛鍏朵粬鍙戦�侊紝渚嬪鍚勫懡浠ょ殑搴旂瓟
+ public boolean isQuickSend;//閫熷彂鍛戒护锛屽嵆涓嶅彈涓嬪彂鏁版嵁鏃堕棿闂撮殧闄愬埗
+
+ public MidResultToRtu(){
+ hasResponse = true ;
+ isCachForOffLine = false ;
+ isSendFirst = false ;
+ isQuickSend = false ;
+ }
+
+ @Override
+ public void action() {
+ ProtocolUnit.getInstance().adapter.getSingleActionToRtu(this.protocolName).doAction(this);
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/OnLine.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/OnLine.java
new file mode 100644
index 0000000..a005b72
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/OnLine.java
@@ -0,0 +1,36 @@
+package com.dy.common.mw.protocol;
+
+public interface OnLine {
+
+ /**
+ * 瀵逛笂绾挎暟鎹繘琛屽垎鏋�
+ * @param aepImei 鐢典俊骞冲彴浼犳潵鐨処MEI鍙�
+ * @param upBuf 涓婅鏁版嵁
+ * @return OnLineResult
+ */
+ OnLineResult parse(String aepImei, byte[] upBuf)throws Exception ;
+
+ /**
+ * 鍒嗘瀽缁撴灉
+ * @author Administrator
+ */
+ class OnLineResult{
+ public int result ;//鍒嗘瀽缁撴灉
+ public String protocolName ;//鍗忚鍚嶇О
+ public String rtuAddr ;//IMEI鍙�
+ public String meterNo ;//姘磋〃鍙�
+ public byte[] remoteData;//闇�瑕佸悜Rtu鍥炲啓鐨勬暟鎹�
+ public OnLineResult(){
+ result = OnLineAction_fail ;
+ rtuAddr = null ;
+ meterNo = null ;
+ remoteData = null ;
+ }
+ }
+
+ public static final int OnLineAction_fail = 0; //鍒嗘瀽涓婄嚎鏁版嵁澶辫触锛屽鎻愪緵鐨勬暟鎹负null绛夊師鍥�
+ public static final int OnLineAction_success = 1; //鍒嗘瀽涓婄嚎鏁版嵁鎴愬姛锛屽苟鑳藉緱鍒癐MEI鍙�
+ public static final int OnLineAction_success_noMe = 2; //鍒嗘瀽涓婄嚎鏁版嵁鎴愬姛锛岃瘑鍒嚭涓嶆槸鏈崗璁暟鎹�
+ public static final int OnLineAction_success_response = 3; //鍒嗘瀽涓婄嚎鏁版嵁鎴愬姛锛屽苟闇�瑕佸悜Rtu鍥炲啓鏁版嵁
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/OnLineHandle.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/OnLineHandle.java
new file mode 100644
index 0000000..b2f7d94
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/OnLineHandle.java
@@ -0,0 +1,76 @@
+package com.dy.common.mw.protocol;
+
+import java.util.Collection;
+import java.util.HashMap;
+
+public class OnLineHandle {
+
+ /**
+ * 瑙f瀽涓婄嚎鏁版嵁锛屽緱鍒癐MEI鍙�
+ * @param bs 瀛楄妭鏁扮粍
+ * @return OnLine.OnLineResult
+ */
+ public OnLine.OnLineResult parse(String aepImei, byte[] bs)throws Exception{
+ OnLine.OnLineResult rs = null ;
+ HashMap<String, AnnotationOnLineVo> onLineMap = ProtocolCach.getOnLineMap() ;
+ Collection<AnnotationOnLineVo> set = onLineMap.values() ;
+ if(set.size() == 0){
+ throw new Exception("澶勭悊涓婄嚎鏃讹紝寰楀埌鐨勫崗璁泦鍚堜负绌恒��") ;
+ }
+ int prority = ProtocolConstant.firstPriority ;
+ while(true){
+ Object[] objs = this.getClassObjAndAnnotationVo(prority, set) ;
+ OnLine onLine = (OnLine)objs[0] ;
+ if(onLine == null && prority == ProtocolConstant.firstPriority){
+ throw new Exception("澶勭悊涓婄嚎鏃讹紝鏈緱鍒颁紭鍏堢骇涓�" + prority + "涓婄嚎澶勭悊绫伙紒") ;
+ }else if(onLine == null){
+ //璇存槑涓婄嚎澶勭悊闆嗗悎宸茬粡閬嶅巻瀹屼簡銆�
+ break ;
+ }
+ rs = onLine.parse(aepImei, bs) ;
+ OnLinePool.freeInstance(((AnnotationOnLineVo)objs[1]).clazz, onLine);
+ if(rs != null){
+ if(rs.result == OnLine.OnLineAction_success){
+ //鎴愬姛, 鍋滄寰幆锛岃繑鍥炵粨鏋�
+ break ;
+ }else if(rs.result == OnLine.OnLineAction_success_noMe){
+ //涓嶆槸鏈崗璁暟鎹� , 寰幆缁х画
+ prority++ ;
+ }else if(rs.result == OnLine.OnLineAction_success_response){
+ //瑙f瀽涓婄嚎鏁版嵁锛岄渶瑕佸洖鍐欐暟鎹�
+ //鍋滄寰幆锛岃繑鍥炵粨鏋�
+ break ;
+ }else if(rs.result == OnLine.OnLineAction_fail){
+ //瑙f瀽涓婄嚎鏁版嵁閿欒锛屼竴鑸槸涓婅鏁版嵁涓虹┖
+ throw new Exception("澶勭悊涓婄嚎鏃讹紝瑙f瀽ID鍑洪敊(鍙兘绋嬪簭閿欒锛屼笂琛屾暟鎹负null)锛�") ;
+ }
+ }
+ }
+ if(rs == null){
+ throw new Exception("澶勭悊涓婄嚎鏃跺嚭閿欙紝鏈兘鎴愬姛鍒嗘瀽鍑篒MEI鍙凤紒") ;
+ }
+ return rs ;
+ }
+
+ /**
+ * 寰楀埌澶勭悊绫诲璞�
+ * @param priority 浼樺厛绾�
+ * @param set 闆嗗悎
+ * @return Object[]
+ * @throws Exception 寮傚父
+ */
+ private Object[] getClassObjAndAnnotationVo(int priority, Collection<AnnotationOnLineVo> set) throws Exception{
+ OnLine obj = null ;
+ AnnotationOnLineVo rVo = null ;
+ for(AnnotationOnLineVo vo : set){
+ if(priority == vo.priority){
+ obj = OnLinePool.getInstance(vo.clazz) ;
+ rVo = vo ;
+ break ;
+ }
+ }
+ return new Object[]{obj, rVo} ;
+ }
+
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/OnLinePool.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/OnLinePool.java
new file mode 100644
index 0000000..2a0d4fc
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/OnLinePool.java
@@ -0,0 +1,58 @@
+package com.dy.common.mw.protocol;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+public class OnLinePool {
+
+ protected static HashMap<String, List<OnLine>> pool = new HashMap<String, List<OnLine>>() ;
+
+ /**
+ * 鐢熸垚瀵硅薄
+ * @param clazz 绫诲瀷
+ * @return OnLine
+ */
+ public static synchronized OnLine getInstance(Class<?> clazz)throws Exception {
+ if(pool == null){
+ pool = new HashMap<String, List<OnLine>>() ;
+ }
+ String className = clazz.getName() ;
+ OnLine obj = null ;
+
+ List<OnLine> list = pool.get(className) ;
+ if(list == null){
+ list = new ArrayList<OnLine>() ;
+ }else{
+ obj = list.get(0) ;
+ }
+
+ if(obj != null){
+ list.remove(0) ;
+ return obj ;
+ }else{
+ try {
+ obj = (OnLine)clazz.newInstance();
+ } catch (Exception e) {
+ throw new Exception( "鐢�" + className + "鐢熸垚瀹炰緥澶辫触锛�");
+ }
+ return obj ;
+ }
+ }
+
+ /**
+ * 鎶婂璞℃斁鍥炴睜涓�
+ * @param clazz 绫�
+ * @param obj 涓婄嚎瀵硅薄
+ */
+ public static void freeInstance(Class<?> clazz, OnLine obj){
+ if(pool != null){
+ String className = clazz.getName() ;
+ List<OnLine> list = pool.get(className) ;
+ if(list != null){
+ list.add(obj) ;
+ }
+ }
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/PrefixedDataAvailable.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/PrefixedDataAvailable.java
new file mode 100644
index 0000000..f6a653c
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/PrefixedDataAvailable.java
@@ -0,0 +1,37 @@
+package com.dy.common.mw.protocol;
+
+import org.apache.mina.core.buffer.IoBuffer;
+
+import com.dy.common.mw.channel.tcp.PrefixedDataAvailableStatus;
+
+public interface PrefixedDataAvailable {
+
+ /**
+ * 鍒嗘瀽涓婄嚎鏁版嵁(缃戠粶杩炴帴鍚庣涓�鍖呮暟鎹�)鏄惁鍙幏寰�
+ * @param in IoBuffer
+ * @param remain 涓�瀹氭椂澶т簬0鐨勬暟鎹�
+ * @param minDataLength 鏈�灏忔暟鎹暱搴�
+ * @param maxDataLength 鏈�澶ф暟鎹暱搴︼紝杈惧埌鎴栬秴杩囨闀垮害锛岃涓烘槸鍨冨溇鏁版嵁銆備緥濡傦細鏁版嵁澶撮儴鏄纭殑锛屼絾鍚堟硶鏁版嵁缁撳熬鎬讳笉鍑虹幇锛岃涓烘鏁版嵁鍨冨溇鏁版嵁
+ * @return 涓嶆椂鏈崗璁暟鎹椂杩斿洖绌�
+ * @throws Exception 寮傚父
+ */
+ PrefixedDataAvailableStatus forOnLine(IoBuffer in,
+ int remain,
+ int minDataLength,
+ int maxDataLength) throws Exception ;
+
+ /**
+ * 鍒嗘瀽涓婄嚎鍚�(缃戠粶杩炴帴鍚庨潪绗竴鍖呮暟鎹�)鏄惁鍙幏寰�
+ * @param in IoBuffer
+ * @param remain 涓�瀹氭椂澶т簬0鐨勬暟鎹�
+ * @param minDataLength 鏈�灏忔暟鎹暱搴�
+ * @param maxDataLength 鏈�澶ф暟鎹暱搴︼紝杈惧埌鎴栬秴杩囨闀垮害锛岃涓烘槸鍨冨溇鏁版嵁銆備緥濡傦細鏁版嵁澶撮儴鏄纭殑锛屼絾鍚堟硶鏁版嵁缁撳熬鎬讳笉鍑虹幇锛岃涓烘鏁版嵁鍨冨溇鏁版嵁
+ * @return
+ * @throws Exception 寮傚父
+ */
+ PrefixedDataAvailableStatus forUpData(IoBuffer in,
+ int remain,
+ int minDataLength,
+ int maxDataLength) throws Exception;
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/PrefixedDataAvailableHandleImp.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/PrefixedDataAvailableHandleImp.java
new file mode 100644
index 0000000..4725c66
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/PrefixedDataAvailableHandleImp.java
@@ -0,0 +1,165 @@
+package com.dy.common.mw.protocol;
+
+import java.util.Collection;
+import java.util.HashMap;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.mina.core.buffer.IoBuffer;
+
+import com.dy.common.util.ByteUtil;
+import com.dy.common.mw.channel.tcp.PrefixedDataAvailableHandle;
+import com.dy.common.mw.channel.tcp.PrefixedDataAvailableStatus;
+
+public class PrefixedDataAvailableHandleImp implements PrefixedDataAvailableHandle {
+
+ private static Logger log = LogManager.getLogger(PrefixedDataAvailableHandleImp.class) ;
+
+
+ /**
+ * 鍦ㄥ绾跨▼鐜涓繍琛�
+ * 鍒嗘瀽涓婄嚎鏁版嵁(缃戠粶杩炴帴鍚庣涓�鍖呮暟鎹�)鏄惁鍙幏寰�
+ * @param in
+ * @return
+ * @throws Exception
+ */
+ public PrefixedDataAvailableStatus forOnLine(IoBuffer in){
+ int remain = in.remaining() ;
+ if(remain == 0){
+ return new PrefixedDataAvailableStatus().breaked() ;
+ }else{
+ try{
+ PrefixedDataAvailableStatus pds = null ;
+
+ HashMap<String, AnnotationPrefixedDataAvailableVo> prefixedDataAvailableMap = ProtocolCach.getPrefixedDataAvailableMap() ;
+ Collection<AnnotationPrefixedDataAvailableVo> set = prefixedDataAvailableMap.values() ;
+ if(set == null || set.size() == 0){
+ throw new Exception("涓婄嚎鏁版嵁瀹屾暣鎬ф鏌ユ椂锛屽緱鍒扮殑鍗忚瀹屾暣鎬ф鏌ョ被闆嗗悎涓虹┖銆�") ;
+ }
+ int prority = ProtocolConstant.firstPriority ;
+
+ while(true){
+ Object[] objs = this.getClassObjAndAnnotationVo(prority, set) ;
+ PrefixedDataAvailable pda = (PrefixedDataAvailable)objs[0] ;
+ if(pda == null && prority == ProtocolConstant.firstPriority){
+ throw new Exception("涓婄嚎鏁版嵁瀹屾暣鎬ф鏌ユ椂锛屾湭寰楀埌浼樺厛绾т负" + prority + "涓婄嚎鏁版嵁瀹屾暣鎬ф鏌ョ被锛�") ;
+ }else if(pda == null){
+ //璇存槑涓婄嚎鏁版嵁瀹屾暣鎬ф鏌ョ被闆嗗悎宸茬粡閬嶅巻瀹屼簡銆�
+ break ;
+ }
+ //澶勭悊瀹屾暣鎬ф鏌�
+ pds = pda.forOnLine(in, remain, ((AnnotationPrefixedDataAvailableVo)objs[1]).onLineDataMinLength, ((AnnotationPrefixedDataAvailableVo)objs[1]).errorMaxLength) ;
+ //鐢ㄥ畬瀵硅薄鍚庯紝鏀惧洖姹犱腑
+ PrefixedDataAvailablePool.freeInstance(((AnnotationPrefixedDataAvailableVo)objs[1]).clazz, pda);
+ if(pds == null){
+ //璇存槑涓嶆槸瀵瑰簲鐨勫崗璁暟鎹紝闇�瑕佸彟澶栫殑鍗忚鏉ュ鐞嗕笂绾�
+ //寰幆缁х画
+ prority++ ;
+ }else{
+ //鍋滄寰幆锛岃繑鍥炵粨鏋�
+ break ;
+ }
+ }
+ if(pds == null){
+ //璇存槑鏁版嵁涓嶅睘浜庝换浣曞崗璁紝涓�鑸负Rtu鏁版嵁鍑洪敊锛屾垨缃戠粶鏀诲嚮鏁版嵁
+ byte[] preByte = new byte[remain];
+ in.get(preByte) ;
+ in.position(0) ;
+ log.error("涓婄嚎绗竴鍖呮暟鎹湭鎵惧埌瀵瑰簲鐨勮В鏋愬崗璁�傛暟鎹槸锛�" + ByteUtil.bytes2Hex(preByte, true)) ;
+ //璁や负鏄畬鏁村寘鏁版嵁锛屽悗缁鍑猴紝闃叉鍗犵敤鍐呭瓨鍙婃寰幆IO璇绘暟鎹�
+ pds = new PrefixedDataAvailableStatus().rubbish(remain) ;
+ }
+ return pds ;
+ }catch(Exception e){
+ //澶勭悊杩囩▼涓彂鐢熷紓甯革紝涓婅鏁版嵁灏辨槸鍨冨溇鏁版嵁浜嗭紝鍚庣画浠ュ瀮鍦炬暟鎹鐞嗭紝鍗虫妸鏁版嵁浠嶪O涓彇鍑烘潵锛屼互闃叉姝诲惊鐜疘O璇绘暟鎹�
+ return new PrefixedDataAvailableStatus().rubbish(remain) ;
+ }
+ }
+ }
+
+ /**
+ * 鍦ㄥ绾跨▼鐜涓繍琛�
+ * 鍒嗘瀽涓婅鏁版嵁(缃戠粶杩炴帴鍚庣浜�(鍖呭惈)鍖呬互鍚庢暟鎹�)鏄惁鍙幏寰�
+ * @param in
+ * @param clientProtocol
+ * @param maxDataLength
+ * @return
+ * @throws Exception
+ */
+ public PrefixedDataAvailableStatus forUpData(IoBuffer in){
+ int remain = in.remaining() ;
+ if(remain == 0){
+ return new PrefixedDataAvailableStatus().breaked() ;
+ }else{
+ try{
+ PrefixedDataAvailableStatus pds = null ;
+
+ HashMap<String, AnnotationPrefixedDataAvailableVo> prefixedDataAvailableMap = ProtocolCach.getPrefixedDataAvailableMap() ;
+ Collection<AnnotationPrefixedDataAvailableVo> set = prefixedDataAvailableMap.values() ;
+ if(set == null || set.size() == 0){
+ throw new Exception("涓婄嚎鏁版嵁瀹屾暣鎬ф鏌ユ椂锛屽緱鍒扮殑鍗忚闆嗗悎涓虹┖銆�") ;
+ }
+ int prority = ProtocolConstant.firstPriority ;
+
+ while(true){
+ Object[] objs = this.getClassObjAndAnnotationVo(prority, set) ;
+ PrefixedDataAvailable pda = (PrefixedDataAvailable)objs[0] ;
+ if(pda == null && prority == ProtocolConstant.firstPriority){
+ throw new Exception("涓婄嚎鏁版嵁瀹屾暣鎬ф鏌ユ椂锛屾湭寰楀埌浼樺厛绾т负" + prority + "涓婄嚎鏁版嵁瀹屾暣鎬ф鏌ョ被锛�") ;
+ }else if(pda == null){
+ //璇存槑涓婄嚎鏁版嵁瀹屾暣鎬ф鏌ョ被闆嗗悎宸茬粡閬嶅巻瀹屼簡銆�
+ break ;
+ }
+ //澶勭悊瀹屾暣鎬ф鏌�
+ pds = pda.forUpData(in, remain, ((AnnotationPrefixedDataAvailableVo)objs[1]).headMinLength, ((AnnotationPrefixedDataAvailableVo)objs[1]).errorMaxLength) ;
+ //鐢ㄥ畬瀵硅薄鍚庯紝鏀惧洖姹犱腑
+ PrefixedDataAvailablePool.freeInstance(objs[0].getClass(), pda);
+ if(pds == null){
+ //璇存槑涓嶆槸瀵瑰簲鐨勫崗璁暟鎹紝闇�瑕佸彟澶栫殑鍗忚鏉ュ鐞嗕笂绾�
+ //寰幆缁х画
+ prority++ ;
+ }else{
+ //鍋滄寰幆锛岃繑鍥炵粨鏋�
+ break ;
+ }
+ }
+ if(pds == null){
+ //璇存槑鏁版嵁涓嶅睘浜庝换浣曞崗璁紝涓�鑸负Rtu鏁版嵁鍑洪敊锛屾垨缃戠粶鏀诲嚮鏁版嵁
+ byte[] preByte = new byte[remain];
+ in.get(preByte) ;
+ in.position(0) ;
+ log.error("涓婅鏁版嵁鏈壘鍒板搴旂殑瑙f瀽鍗忚銆傛暟鎹槸锛�" + ByteUtil.bytes2Hex(preByte, true)) ;
+ //璁や负鏄畬鏁村寘鏁版嵁锛屽悗缁鍑猴紝闃叉鍗犵敤鍐呭瓨鍙婃寰幆IO璇绘暟鎹�
+ pds = new PrefixedDataAvailableStatus().rubbish(remain) ;
+ }
+ return pds ;
+ }catch(Exception e){
+ //澶勭悊杩囩▼涓彂鐢熷紓甯革紝涓婅鏁版嵁灏辨槸鍨冨溇鏁版嵁浜嗭紝鍚庣画浠ュ瀮鍦炬暟鎹鐞嗭紝鍗虫妸鏁版嵁浠嶪O涓彇鍑烘潵锛屼互闃叉姝诲惊鐜疘O璇绘暟鎹�
+ return new PrefixedDataAvailableStatus().rubbish(remain) ;
+ }
+ }
+ }
+
+
+
+ /**
+ * 寰楀埌澶勭悊绫诲璞�
+ * @param prority
+ * @param set
+ * @return
+ * @throws Exception
+ */
+ private Object[] getClassObjAndAnnotationVo(int prority, Collection<AnnotationPrefixedDataAvailableVo> set) throws Exception{
+ PrefixedDataAvailable obj = null ;
+ AnnotationPrefixedDataAvailableVo rVo = null ;
+ for(AnnotationPrefixedDataAvailableVo vo : set){
+ if(prority == vo.priority){
+ obj = PrefixedDataAvailablePool.getInstance(vo.clazz) ;
+ rVo = vo ;
+ break ;
+ }
+ }
+ return new Object[]{obj, rVo} ;
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/PrefixedDataAvailablePool.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/PrefixedDataAvailablePool.java
new file mode 100644
index 0000000..57d7ec0
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/PrefixedDataAvailablePool.java
@@ -0,0 +1,59 @@
+package com.dy.common.mw.protocol;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+public class PrefixedDataAvailablePool {
+
+ protected static HashMap<String, List<PrefixedDataAvailable>> pool = new HashMap<String, List<PrefixedDataAvailable>>() ;
+
+ /**
+ * 鐢熸垚瀵硅薄
+ * 绾跨▼闈炲畨鍏ㄧ殑锛屾墍浠ョ敤鍒皊ynchronized
+ * @param className
+ * @return
+ */
+ public static synchronized PrefixedDataAvailable getInstance(Class<?> clazz)throws Exception {
+ if(pool == null){
+ pool = new HashMap<String, List<PrefixedDataAvailable>>() ;
+ }
+ String className = clazz.getName() ;
+ PrefixedDataAvailable obj = null ;
+
+ List<PrefixedDataAvailable> list = pool.get(className) ;
+ if(list == null){
+ list = new ArrayList<PrefixedDataAvailable>() ;
+ }else{
+ obj = list.get(0) ;
+ }
+
+ if(obj != null){
+ list.remove(0) ;
+ return obj ;
+ }else{
+ try {
+ obj = (PrefixedDataAvailable)clazz.newInstance();
+ } catch (Exception e) {
+ throw new Exception( "鐢�" + className + "鐢熸垚瀹炰緥澶辫触锛�");
+ }
+ return obj ;
+ }
+ }
+
+ /**
+ * 鎶婂璞℃斁鍥炴睜涓�
+ * @param className
+ * @return
+ */
+ public static void freeInstance(Class<?> clazz, PrefixedDataAvailable obj)throws Exception {
+ if(pool != null){
+ String className = clazz.getName() ;
+ List<PrefixedDataAvailable> list = pool.get(className) ;
+ if(list != null){
+ list.add(obj) ;
+ }
+ }
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/ProtocolCach.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/ProtocolCach.java
new file mode 100644
index 0000000..1a9753e
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/ProtocolCach.java
@@ -0,0 +1,86 @@
+package com.dy.common.mw.protocol;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class ProtocolCach {
+
+ //鏈郴缁熶腑锛孌river鍦ㄥ崟绾跨▼涓繍琛岋紝鎵�浠ュ彧鐢ㄤ竴涓疄渚�
+ private static HashMap<String, Driver> drivers = new HashMap<String, Driver>() ;
+ //娉ㄨВ涓庡鐞嗙被鐨勬槧灏�
+ private static HashMap<String, AnnotationDriverVo> driverMap = new HashMap<String, AnnotationDriverVo>() ;
+ private static HashMap<String, AnnotationPrefixedDataAvailableVo> prefixedDataAvailableMap = new HashMap<String, AnnotationPrefixedDataAvailableVo>() ;
+ private static HashMap<String, AnnotationOnLineVo> onLineMap = new HashMap<String, AnnotationOnLineVo>() ;
+
+
+ /**
+ * 鍦ㄥ崟绾跨▼鐜涓繍琛�
+ * 閫氳繃鍗忚椹卞姩鐨勭被鍚嶏紝寰楀埌绫诲崟渚�
+ * @param protocolName
+ * @return
+ * @throws Exception
+ */
+ public static Driver getDriver(String protocolName) throws Exception{
+ Driver dri = drivers.get(protocolName);
+ if(dri == null){
+ AnnotationDriverVo vo = driverMap.get(protocolName) ;
+ if(vo != null && vo.clazz != null){
+ dri = (Driver)vo.clazz.newInstance() ;
+ drivers.put(protocolName, dri) ;
+ }
+ }
+ return dri ;
+ }
+
+ /**
+ * 寰楀埌椹卞姩鐨勬暟閲忥紝鍗充腑闂翠欢鏀寔鐨勫崗璁暟閲�
+ * @return
+ */
+ public static int driverCount(){
+ if(drivers == null || drivers.size() == 0){
+ return 0 ;
+ }else{
+ return drivers.size() ;
+ }
+ }
+
+ /**
+ * 寰楀埌绗竴涓┍鍔�
+ * @return
+ */
+ public static Driver getFirstDriver() throws Exception{
+ Driver dri = null ;
+ if(drivers != null && drivers.size() > 0){
+ Map.Entry<String, Driver> ent = drivers.entrySet().iterator().next() ;
+ dri = ent.getValue();
+ }
+ return dri ;
+ }
+
+ /**
+ * 寰楀埌鎵�鏈夊崗璁悕绉�
+ * @return
+ */
+ public static List<String> getProtocolList() {
+ List<String> list = new ArrayList<String>() ;
+ Collection<String> col = driverMap.keySet() ;
+ for(String pname : col){
+ list.add(pname) ;
+ }
+ return list;
+ }
+
+ protected static HashMap<String, AnnotationDriverVo> getDriverMap() {
+ return driverMap;
+ }
+ protected static HashMap<String, AnnotationPrefixedDataAvailableVo> getPrefixedDataAvailableMap() {
+ return prefixedDataAvailableMap;
+ }
+ protected static HashMap<String, AnnotationOnLineVo> getOnLineMap() {
+ return onLineMap;
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/ProtocolConfigVo.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/ProtocolConfigVo.java
new file mode 100644
index 0000000..5ed316a
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/ProtocolConfigVo.java
@@ -0,0 +1,11 @@
+package com.dy.common.mw.protocol;
+
+public class ProtocolConfigVo {
+ public Integer centerAddr ;//涓績鍦板潃
+ public Boolean synchroRtuClock ;//鏄惁瀵筊TU鏍℃椂
+ public Integer synchroRtuClockTimepieces ;//褰揜TU涓庢湇鍔″櫒鏃堕挓鐩稿樊涓�瀹氭绉掞紙閰嶇疆鏂囦欢鏄閽燂級鍚庯紝杩涜鏍℃椂
+ public String serverIp ;//鏈嶅姟绔疘P鍦板潃锛屾眽濞佸崗璁腑鐢ㄥ埌
+ public Integer serverPort ;//鏈嶅姟绔鍙o紝姹夊▉鍗忚涓敤鍒�
+
+ public Boolean showStartInfo; //鏄惁鍦ㄦ帶鍒跺彴涓婃樉绀轰俊鎭�
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/ProtocolConstant.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/ProtocolConstant.java
new file mode 100644
index 0000000..ee9678d
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/ProtocolConstant.java
@@ -0,0 +1,25 @@
+package com.dy.common.mw.protocol;
+
+public class ProtocolConstant {
+
+ /**
+ * 绗竴涓紭鍏堢骇涓�1锛�
+ * 搴旂敤浜庝笂琛屾暟鎹畬鏁存�ф鏌ュ強涓婄嚎鏁版嵁澶勭悊绫�
+ */
+ public static final int firstPriority = 1 ;
+
+ /**
+ * 褰撻�氳繃娉ㄨВ鏌ユ壘鍔熻兘鐮佽В鏋愮被鏃讹紝鑻ユ湭鎵惧埌锛岄偅涔堥噰鐢╝nyCode娉ㄨВ鐨勫姛鑳界爜瑙f瀽绫�
+ * anyCode琛ㄧず闄ょ殑涓撻棬娉ㄨВ鐨勫姛鑳界爜瑙f瀽绫诲锛屽叾浠栧姛鑳界爜鍏堕兘鑳借В鏋�
+ * AnnotationCode榛樿娉ㄨВ鏄痑nyCode
+ */
+ public static final String anyCode = "anyCode" ;
+
+ /**
+ * 闈炴硶鏁版嵁闀垮害
+ * 渚嬪锛氭暟鎹ご閮ㄦ槸姝g‘鐨勶紝浣嗗悎娉曟暟鎹粨灏炬�讳笉鍑虹幇锛岃涓烘鏁版嵁鍨冨溇鏁版嵁
+ */
+ public static final int errorMaxLength = 1280 ;
+
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/ProtocolUnit.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/ProtocolUnit.java
new file mode 100644
index 0000000..87020e3
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/ProtocolUnit.java
@@ -0,0 +1,93 @@
+package com.dy.common.mw.protocol;
+
+import java.util.Collection;
+import java.util.HashMap;
+
+import com.dy.common.mw.UnitAdapterInterface;
+import com.dy.common.mw.UnitInterface;
+import com.dy.common.mw.UnitStartedCallbackInterface;
+
+
+public class ProtocolUnit implements UnitInterface {
+
+ private static final ProtocolUnit instance = new ProtocolUnit() ;
+
+ public ProtocolUnitAdapter adapter ;
+
+ private ProtocolUnit(){}
+
+ public static ProtocolUnit getInstance(){
+ return instance ;
+ }
+
+ @Override
+ public void setAdapter(UnitAdapterInterface adapter) throws Exception {
+ if(adapter == null){
+ throw new Exception("鍗忚妯″潡閫傞厤鍣ㄥ璞′笉鑳戒负绌猴紒") ;
+ }
+ this.adapter = (ProtocolUnitAdapter)adapter ;
+
+ ProtocolConfigVo vo = this.adapter.getConfig() ;
+ if(vo == null){
+ throw new Exception("鍗忚妯″潡閰嶇疆瀵硅薄涓嶈兘涓虹┖锛�") ;
+ }
+ if(vo.centerAddr < 0 || vo.centerAddr > 4){//浜戞帶鍒朵腑蹇冨湴鍧�鏄�0
+ throw new Exception("鍗忚妯″潡閰嶇疆瀵硅薄灞炴�т腑蹇冨湴鍧�鍙兘鏄�0銆�1銆�2銆�3銆�4 锛�") ;
+ }
+ }
+
+ /**
+ * 鍚姩妯″潡
+ */
+ public void start(UnitStartedCallbackInterface callback) throws Exception {
+ //寰楀埌鍞竴瀹炰緥锛� 骞跺湪鐢熸垚鍞竴瀹炰緥鏃讹紝鎵弿娉ㄨВ绫�
+ AnnotationScan.getIntance() ;
+
+ //鍚勪釜鍗忚椹卞姩绫绘壂鎻忚嚜宸辩殑鍔熻兘鐮佹敞瑙�
+ HashMap<String, AnnotationDriverVo> drivers = ProtocolCach.getDriverMap() ;
+ Collection<String> colDrivers = drivers.keySet() ;
+ String totalProtocols = null ;
+ for(String protocolName : colDrivers){
+ if(totalProtocols == null){
+ totalProtocols = protocolName ;
+ }else{
+ totalProtocols += "锛�" + protocolName ;
+ }
+ Driver dri = ProtocolCach.getDriver(protocolName) ;
+ if(dri != null){
+ dri.scanAnnotationCode();
+ }
+ }
+ if(adapter.getConfig().showStartInfo){
+ System.out.println("鍗忚妯″潡鎴愬姛鍚姩锛�"
+ + "鏀寔鐨勫崗璁細" + totalProtocols );
+ }
+ callback.call(null);
+ }
+
+ /**
+ * 鏄惁鍙湁涓�涓崗璁�
+ * @return 缁撴灉
+ */
+ @SuppressWarnings("unused")
+ public boolean isOnlyOneProtocol(){
+ HashMap<String, AnnotationDriverVo> drivers = ProtocolCach.getDriverMap() ;
+ return drivers.size() == 1 ;
+ }
+
+ @Override
+ public void stop(UnitStartedCallbackInterface callback) {
+ }
+
+ /*
+ public static void main(String[] args) throws Exception{
+ ProtocolUnit protoUnit = ProtocolUnit.getInstance();
+ protoUnit.start(new UnitStartedCallbackInterface(){
+ @Override
+ public void call(Object obj) {
+ }
+ });
+ }
+ */
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/ProtocolUnitAdapter.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/ProtocolUnitAdapter.java
new file mode 100644
index 0000000..91ab2f0
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/ProtocolUnitAdapter.java
@@ -0,0 +1,30 @@
+package com.dy.common.mw.protocol;
+
+import com.dy.common.mw.UnitAdapterInterface;
+
+
+public interface ProtocolUnitAdapter extends UnitAdapterInterface{
+ /**
+ * 寰楀埌鏈ā鍧楀弬鏁伴厤缃璞�
+ * @return ProtocolConfigVo
+ */
+ ProtocolConfigVo getConfig() ;
+ /**
+ * 鍗曠嚎绋嬬幆澧冧腑杩愯锛屽緱鍒板崟涓鐞哛TU涓嬭鏁版嵁鐨刟ction鎵ц瀵硅薄
+ * @param protocolName
+ * @return MidResultAction
+ */
+ MidResultAction getSingleActionToRtu(String protocolName) ;
+ /**
+ * 鍗曠嚎绋嬬幆澧冧腑杩愯锛屽緱鍒板崟涓鐞哛TU涓婅鏁版嵁鐨刟ction鎵ц瀵硅薄
+ * @param protocolName
+ * @return MidResultAction
+ */
+ MidResultAction getSingleActionFromRtu(String protocolName) ;
+ /**
+ * 鍗曠嚎绋嬬幆澧冧腑杩愯锛屽緱鍒板崟涓鐞嗗嚭閿欑殑action鎵ц瀵硅薄
+ * @param protocolName
+ * @return MidResultAction
+ */
+ MidResultAction getSingleActionError(String protocolName) ;
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/aepRtuStatus/OnOffLineVo.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/aepRtuStatus/OnOffLineVo.java
new file mode 100644
index 0000000..bde7b9e
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/aepRtuStatus/OnOffLineVo.java
@@ -0,0 +1,87 @@
+package com.dy.common.mw.protocol.aepRtuStatus;
+
+import com.alibaba.fastjson2.JSON ;
+
+/**
+ * 涓婁笅绾垮�煎璞�
+ * 鍙湁搴旂敤鐢典俊骞冲彴鏃舵湁鏁�
+ */
+@SuppressWarnings("unused")
+public class OnOffLineVo {
+
+ public String rtuAddr; //:"862592059434970"
+ public String deviceId; //:"59a4d90bf7a04a4d3523fe15d6f3f",
+ public String productId; //:"15410798",
+ public String ipv4Address; //:"117.132.195.213",
+ public Boolean onTrueOffFalse ;
+
+ public String toString(){
+ String s = "rtuAddr: " + rtuAddr ;
+ s += "\ndeviceId锛�" + deviceId ;
+ s += "\nproductId锛�" + productId ;
+ s += "\nipv4Address锛�" + ipv4Address ;
+ s += "\nonTrueOffFalse锛�" + onTrueOffFalse ;
+ return s ;
+ }
+
+ /**
+ * 瀵硅薄杞垚json
+ * @return json
+ * @throws Exception 寮傚父
+ */
+ public String toJson()throws Exception{
+ try{
+ return JSON.toJSONString(this) ;
+ }catch(Exception e){
+ throw new Exception(e.getMessage() , e ) ;
+ }
+ }
+ /**
+ * json杞垚瀵硅薄
+ * @param json json
+ * @return OnOffLineVo
+ * @throws Exception 寮傚父
+ */
+ public static OnOffLineVo jsonToObject(String json)throws Exception{
+ try{
+ return JSON.parseObject(json, OnOffLineVo.class) ;
+ }catch(Exception e){
+ throw new Exception(e.getMessage() , e ) ;
+ }
+ }
+
+ public String getRtuAddr() {
+ return rtuAddr;
+ }
+ public void setRtuAddr(String rtuAddr) {
+ this.rtuAddr = rtuAddr;
+ }
+ public String getDeviceId() {
+ return deviceId;
+ }
+ public void setDeviceId(String deviceId) {
+ this.deviceId = deviceId;
+ }
+ public String getProductId() {
+ return productId;
+ }
+ public void setProductId(String productId) {
+ this.productId = productId;
+ }
+ @SuppressWarnings("unused")
+ public String getIpv4Address() {
+ return ipv4Address;
+ }
+ @SuppressWarnings("unused")
+ public void setIpv4Address(String ipv4Address) {
+ this.ipv4Address = ipv4Address;
+ }
+ @SuppressWarnings("unused")
+ public Boolean getOnTrueOffFalse() {
+ return onTrueOffFalse;
+ }
+ @SuppressWarnings("unused")
+ public void setOnTrueOffFalse(Boolean onTrueOffFalse) {
+ this.onTrueOffFalse = onTrueOffFalse;
+ }
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/CodeV1_0_1.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/CodeV1_0_1.java
new file mode 100644
index 0000000..4a82844
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/CodeV1_0_1.java
@@ -0,0 +1,35 @@
+package com.dy.common.mw.protocol.pMeterV1_0_1;
+
+public class CodeV1_0_1 {
+ //鍔熻兘鐮佷负瀛楃涓诧紝鍗佸叚杩涘埗鏁版嵁
+ public static final String cd_01 = "01" ;//瀹氭椂锛堝懆鏈燂級涓婃姤
+ public static final String cd_02 = "02" ;//瀹炴椂(瑙﹀彂)涓婃姤
+ public static final String cd_03 = "03" ;//浜嬩欢涓婃姤
+ public static final String cd_04 = "04" ;//寮�闃�
+ public static final String cd_05 = "05" ;//鍏抽榾
+ public static final String cd_06 = "06" ;//闃�闂ㄥ姩浣滅粨鏋�
+
+ public static String getCodeName(String code) {
+ String name = (code.equals(cd_01) ? "瀹氭椂涓婃姤 " :
+ (code.equals(cd_02) ? "瑙﹀彂涓婃姤" :
+ (code.equals(cd_03) ? "浜嬩欢涓婃姤" :
+ (code.equals(cd_04) ? "寮�闃�" :
+ (code.equals(cd_05) ? "鍏抽榾" :
+ (code.equals(cd_06) ? "闃�闂ㄥ姩浣滅粨鏋�" :
+ "")))))) ;
+ return name ;
+ }
+
+ /**
+ * 鏄惁涓烘湁鏁堝姛鑳界爜
+ * @param code
+ * @return
+ */
+ public static boolean isValid(String code){
+ String name = getCodeName(code) ;
+ if(name != null && !name.equals("")){
+ return true ;
+ }
+ return false ;
+ }
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/CommonV1_0_1.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/CommonV1_0_1.java
new file mode 100644
index 0000000..5d8478f
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/CommonV1_0_1.java
@@ -0,0 +1,166 @@
+package com.dy.common.mw.protocol.pMeterV1_0_1;
+
+import com.dy.common.util.ByteUtil;
+import com.dy.common.util.ByteUtilUnsigned;
+
+
+public class CommonV1_0_1 {
+ /**
+ * 妫�鏌ュご
+ * @param bs
+ * @return
+ * @throws Exception
+ */
+ public Boolean isThisProtocolHead(byte[] bs) throws Exception{
+ if(bs == null){
+ return null ;
+ }else if(bs.length >= (ProtocolConstantV1_0_1.versionIndex + 1)
+ && bs[0] == ProtocolConstantV1_0_1.P_Head_Byte){
+ String vs = this.parseVersion(bs) ;
+ if(vs.equals(ProtocolConstantV1_0_1.version)){
+ return true ;
+ }else{
+ return false ;
+ }
+ }else{
+ return false ;
+ }
+ }
+
+ /**
+ * 妫�鏌ュご
+ * @param bs
+ * @return
+ * @throws Exception
+ */
+ public void checkHead(byte[] bs) throws Exception{
+ if(bs.length >= 1 && bs[0] == ProtocolConstantV1_0_1.P_Head_Byte){
+ return ;
+ }else{
+ throw new Exception("涓婅鏁版嵁甯уご涓嶆纭紒") ;
+ }
+ }
+
+ /**
+ * 妫�鏌ュ熬
+ * @param bs
+ * @return
+ * @throws Exception
+ */
+ public void checkTail(byte[] bs) throws Exception{
+ if(bs.length >= 1 && bs[bs.length - 1] == ProtocolConstantV1_0_1.P_Tail_Byte){
+ return ;
+ }else{
+ throw new Exception("涓婅鏁版嵁灏句笉姝g‘锛�") ;
+ }
+ }
+
+
+
+ /**
+ * 鏍¢獙鍜屾鏌�
+ * @param bs
+ * @param userdataLen
+ * @param hasPackages
+ * @return
+ * @throws Exception
+ */
+ public boolean checkCrc(byte[] bs) throws Exception {
+ byte he = 0 ;
+ for(int i = 0 ; i <= bs.length - 3 ; i++){
+ he = (byte)(he + bs[i]) ;
+ }
+ if(bs[bs.length - 2] == he){
+ return true ;
+ }else{
+ return false ;
+ }
+ }
+
+ /**
+ * 鏍¢獙鍜屾鏌�
+ * @param bs
+ * @param userdataLen
+ * @param hasPackages
+ * @return
+ * @throws Exception
+ */
+ public String checkCrc_str(byte[] bs) throws Exception {
+ byte[] he = new byte[1] ;
+ for(int i = 0 ; i <= bs.length - 3 ; i++){
+ he[0] = (byte)(he[0] + bs[i]) ;
+ }
+ short hes = ByteUtilUnsigned.byte2Byte(he, 0);
+ short heOrg = ByteUtilUnsigned.byte2Byte(bs, bs.length - 2);
+ if(hes == heOrg){
+ return null ;
+ }else{
+ return "璁$畻鏍¢獙鍜屾槸:" + hes + "锛屼笂浼犳牎楠屽拰鏄�" + heOrg ;
+ }
+ }
+
+ /**
+ * 鍒嗘瀽鐗堟湰鍙�
+ * @param bs
+ * @return
+ * @throws Exception
+ */
+ public String parseVersion(byte[] bs)throws Exception{
+ Short ver = ByteUtilUnsigned.byte2Byte(bs, ProtocolConstantV1_0_1.versionIndex) ;
+ char[] cs = ("" + ver).toCharArray() ;
+ String vs = "" ;
+ for(byte i = 0 ; i < cs.length; i++){
+ if(i == 0){
+ vs += "" + cs[i] ;
+ }else{
+ vs += "." + cs[i] ;
+ }
+ }
+ return vs ;
+ }
+
+
+ /**
+ * 鍒嗘瀽鏁版嵁瀛楄妭鏁�
+ * @param bs
+ * @return
+ * @throws Exception
+ */
+ public int parseDataLen(byte[] bs)throws Exception{
+ return ByteUtilUnsigned.bytes2Short_BE(bs, ProtocolConstantV1_0_1.dataLenIndex_start) ;
+ }
+
+
+ /**
+ * 鍒嗘瀽IMEI鍙�
+ * @param bs
+ * @return
+ * @throws Exception
+ */
+ public String parseRtuAddr(byte[] bs)throws Exception{
+ return "" + ByteUtil.BCD2Long_BE(bs, ProtocolConstantV1_0_1.rtuAddrIndex_start, ProtocolConstantV1_0_1.rtuAddrIndex_end) ;
+ }
+
+
+ /**
+ * 鍒嗘瀽琛ㄥ彿
+ * @param bs
+ * @return
+ * @throws Exception
+ */
+ public String parseMeterNo(byte[] bs)throws Exception{
+ return "" + ByteUtil.BCD2Long_BE(bs, ProtocolConstantV1_0_1.meterNoIndex_start, ProtocolConstantV1_0_1.meterNoIndex_end) ;
+ }
+
+
+ /**
+ * 鍒嗘瀽鍔熻兘鐮�
+ * @param bs
+ * @return
+ * @throws Exception
+ */
+ public String parseCode(byte[] bs)throws Exception{
+ return ByteUtil.bytes2Hex(bs, false, ProtocolConstantV1_0_1.codeIndex, 1) ;
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/DataCd01Vo.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/DataCd01Vo.java
new file mode 100644
index 0000000..a9f2d76
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/DataCd01Vo.java
@@ -0,0 +1,133 @@
+package com.dy.common.mw.protocol.pMeterV1_0_1;
+
+import java.util.List;
+
+//鍛ㄦ湡涓婃姤
+public class DataCd01Vo {
+ //浠ヤ笅鏁版嵁閮芥槸24锛�0锛夋椂鏁寸偣閲囬泦鐨勬暟鎹�
+ public String dt ;//涓婃姤鏃堕棿(鏍煎紡 yyyy-mm-dd hh:mm:ss)
+ public String dataDt ;//鏁版嵁鏃堕棿(鏍煎紡 yyyy-mm-dd)
+ public Float totalAmount ;//绱鐢ㄦ按閲�
+ public Float totalAmountPerDay ;//鏃ョ粨鐢ㄦ按閲�
+ public Float volt ;//鐢垫睜鐢靛帇
+ public Float signal ;//淇″彿寮哄害
+ public Byte valveSta ;//闃�闂ㄧ姸鎬�: 00闃�寮�锛�01闃�鍏�
+ public Byte alarmValve ;//闃�闂ㄦ姤璀�: 1鎶ヨ锛�0鏃�
+ public Byte alarmMagnetism ;//寮虹鎶ヨ: 1鎶ヨ锛�0鏃�
+ public Byte alarmVolt ;//鐢靛帇娆犲帇鎶ヨ: 1鎶ヨ锛�0鏃�
+ public List<Float> values ;//鍛ㄦ湡涓婃姤鏁版嵁
+ public Short gap ;//瀵嗛噰鏁版嵁闂撮殧锛堝垎閽燂級
+
+ public boolean isAlarm(){
+ boolean flag = false ;
+ if(valveSta != null && valveSta.intValue() == 1){//闃�闂ㄧ姸鎬�(0:闃�寮� 1:闃�鍏�)
+ flag = true ;
+ }
+ if(alarmValve != null && alarmValve.intValue() == 1){//闃�闂ㄥ紓甯稿憡璀� 1 闃�闂ㄥ紓甯革紝0 闃�闂ㄦ甯�
+ flag = true ;
+ }
+ if(alarmVolt != null && alarmVolt.intValue() == 1){//鐢垫睜娆犲帇鍛婅 1鍛婅锛�0鏃犲憡璀�
+ flag = true ;
+ }
+ if(alarmMagnetism != null && alarmMagnetism.intValue() == 1){//纾佸共鎵板憡璀� 1鍛婅锛�0鏃犲憡璀�
+ flag = true ;
+ }
+ return flag ;
+ }
+ public String toString(){
+ StringBuffer sb = new StringBuffer() ;
+ sb.append(" 瀹氭椂涓婃姤 : \n") ;
+ sb.append(" 缁堢鏃堕棿 : " + dt + "\n") ;
+ sb.append(" 鏁版嵁鏃堕棿 : " + dataDt + "\n") ;
+ sb.append(" 鍐荤粨绱姘撮噺 : " + totalAmount + "\n") ;
+ sb.append(" 鏃ョ疮璁℃按閲� : " + totalAmountPerDay + "\n") ;
+ sb.append(" 鐢靛帇 : " + volt + "\n") ;
+ sb.append(" 淇″彿寮哄害 : " + signal + "\n") ;
+ sb.append(" 闃�闂ㄧ姸鎬� : " + valveSta + "锛�" + (valveSta==0?"闃�寮�":"闃�鍏�") + "锛塡n") ;
+ sb.append(" 闃�闂ㄦ姤璀� : " + alarmValve + "锛�" + (alarmValve==0?"姝e父":"鎶ヨ") + "锛塡n") ;
+ sb.append(" 寮虹鎶ヨ : " + alarmMagnetism + "锛�" + (alarmMagnetism==0?"姝e父":"鎶ヨ") + "锛塡n") ;
+ sb.append(" 娆犲帇鎶ヨ : " + alarmVolt + "锛�" + (alarmVolt==0?"姝e父":"鎶ヨ") + "锛塡n") ;
+ sb.append(" 瀵嗛噰鏁版嵁闂撮殧 : " + gap + "锛堝垎閽燂級\n") ;
+ sb.append(" 瀵嗛噰鏁版嵁锛歕n") ;
+ if(values != null && values.size() > 0){
+ for(int i = 0 ; i < values.size(); i++){
+ sb.append(" " + (i + 1) + "鏃剁敤姘撮噺锛�" + values.get(i) + "\n") ;
+ }
+ }
+ return sb.toString() ;
+ }
+ public String getDt() {
+ return dt;
+ }
+ public void setDt(String dt) {
+ this.dt = dt;
+ }
+ public String getDataDt() {
+ return dataDt;
+ }
+ public void setDataDt(String dataDt) {
+ this.dataDt = dataDt;
+ }
+ public Float getTotalAmount() {
+ return totalAmount;
+ }
+ public void setTotalAmount(Float totalAmount) {
+ this.totalAmount = totalAmount;
+ }
+ public Float getTotalAmountPerDay() {
+ return totalAmountPerDay;
+ }
+ public void setTotalAmountPerDay(Float totalAmountPerDay) {
+ this.totalAmountPerDay = totalAmountPerDay;
+ }
+ public Float getVolt() {
+ return volt;
+ }
+ public void setVolt(Float volt) {
+ this.volt = volt;
+ }
+ public Float getSignal() {
+ return signal;
+ }
+ public void setSignal(Float signal) {
+ this.signal = signal;
+ }
+ public Byte getValveSta() {
+ return valveSta;
+ }
+ public void setValveSta(Byte valveSta) {
+ this.valveSta = valveSta;
+ }
+ public Byte getAlarmValve() {
+ return alarmValve;
+ }
+ public void setAlarmValve(Byte alarmValve) {
+ this.alarmValve = alarmValve;
+ }
+ public Byte getAlarmMagnetism() {
+ return alarmMagnetism;
+ }
+ public void setAlarmMagnetism(Byte alarmMagnetism) {
+ this.alarmMagnetism = alarmMagnetism;
+ }
+ public Byte getAlarmVolt() {
+ return alarmVolt;
+ }
+ public void setAlarmVolt(Byte alarmVolt) {
+ this.alarmVolt = alarmVolt;
+ }
+ public List<Float> getValues() {
+ return values;
+ }
+ public void setValues(List<Float> values) {
+ this.values = values;
+ }
+ public Short getGap() {
+ return gap;
+ }
+ public void setGap(Short gap) {
+ this.gap = gap;
+ }
+
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/DataCd02Vo.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/DataCd02Vo.java
new file mode 100644
index 0000000..99c9ee3
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/DataCd02Vo.java
@@ -0,0 +1,94 @@
+package com.dy.common.mw.protocol.pMeterV1_0_1;
+
+//瀹炴椂(瑙﹀彂)涓婃姤
+public class DataCd02Vo {
+ //浠ヤ笅鏁版嵁閮芥槸涓婃姤鏃跺埢鐨勬暟鎹�
+ public String dt ;//涓婃姤鏃堕棿(鏍煎紡 yyyy-mm-dd hh:mm:ss)
+ public Float totalAmount ;
+ public Float volt ;
+ public Float signal ;//淇″彿寮哄害
+ public Byte valveSta ;//闃�闂ㄧ姸鎬�: 00闃�寮�锛�01闃�鍏�
+ public Byte alarmValve ;//闃�闂ㄦ姤璀�
+ public Byte alarmMagnetism ;//寮虹鎶ヨ
+ public Byte alarmVolt ;//鐢靛帇娆犲帇鎶ヨ
+
+
+ public boolean isAlarm(){
+ boolean flag = false ;
+ if(valveSta != null && valveSta.intValue() == 1){//闃�闂ㄧ姸鎬�(0:闃�寮� 1:闃�鍏�)
+ flag = true ;
+ }
+ if(alarmValve != null && alarmValve.intValue() == 1){//闃�闂ㄥ紓甯稿憡璀� 1 闃�闂ㄥ紓甯革紝0 闃�闂ㄦ甯�
+ flag = true ;
+ }
+ if(alarmVolt != null && alarmVolt.intValue() == 1){//鐢垫睜娆犲帇鍛婅 1鍛婅锛�0鏃犲憡璀�
+ flag = true ;
+ }
+ if(alarmMagnetism != null && alarmMagnetism.intValue() == 1){//纾佸共鎵板憡璀� 1鍛婅锛�0鏃犲憡璀�
+ flag = true ;
+ }
+ return flag ;
+ }
+
+ public String toString(){
+ StringBuffer sb = new StringBuffer() ;
+ sb.append(" 瑙﹀彂涓婃姤 : \n") ;
+ sb.append(" 缁堢鏃堕棿 : " + dt + "\n") ;
+ sb.append(" 鍐荤粨绱姘撮噺 : " + totalAmount + "\n") ;
+ sb.append(" 鐢靛帇 : " + volt + "\n") ;
+ sb.append(" 淇″彿寮哄害 : " + signal + "\n") ;
+ sb.append(" 闃�闂ㄧ姸鎬� : " + valveSta + "锛�" + (valveSta==0?"闃�寮�":"闃�鍏�") + "锛塡n") ;
+ sb.append(" 闃�闂ㄦ姤璀� : " + alarmValve + "锛�" + (alarmValve==0?"姝e父":"鎶ヨ") + "锛塡n") ;
+ sb.append(" 寮虹鎶ヨ : " + alarmMagnetism + "锛�" + (alarmMagnetism==0?"姝e父":"鎶ヨ") + "锛塡n") ;
+ sb.append(" 娆犲帇鎶ヨ : " + alarmVolt + "锛�" + (alarmVolt==0?"姝e父":"鎶ヨ") + "锛塡n") ;
+ return sb.toString() ;
+ }
+ public String getDt() {
+ return dt;
+ }
+ public void setDt(String dt) {
+ this.dt = dt;
+ }
+ public Float getTotalAmount() {
+ return totalAmount;
+ }
+ public void setTotalAmount(Float totalAmount) {
+ this.totalAmount = totalAmount;
+ }
+ public Float getVolt() {
+ return volt;
+ }
+ public void setVolt(Float volt) {
+ this.volt = volt;
+ }
+ public Float getSignal() {
+ return signal;
+ }
+ public void setSignal(Float signal) {
+ this.signal = signal;
+ }
+ public Byte getValveSta() {
+ return valveSta;
+ }
+ public void setValveSta(Byte valveSta) {
+ this.valveSta = valveSta;
+ }
+ public Byte getAlarmValve() {
+ return alarmValve;
+ }
+ public void setAlarmValve(Byte alarmValve) {
+ this.alarmValve = alarmValve;
+ }
+ public Byte getAlarmMagnetism() {
+ return alarmMagnetism;
+ }
+ public void setAlarmMagnetism(Byte alarmMagnetism) {
+ this.alarmMagnetism = alarmMagnetism;
+ }
+ public Byte getAlarmVolt() {
+ return alarmVolt;
+ }
+ public void setAlarmVolt(Byte alarmVolt) {
+ this.alarmVolt = alarmVolt;
+ }
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/DataCd03Vo.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/DataCd03Vo.java
new file mode 100644
index 0000000..3331af9
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/DataCd03Vo.java
@@ -0,0 +1,78 @@
+package com.dy.common.mw.protocol.pMeterV1_0_1;
+
+//浜嬩欢涓婃姤
+public class DataCd03Vo {
+ //浠ヤ笅鏁版嵁閮芥槸涓婃姤鏃跺埢鐨勬暟鎹�
+ public String dt ;//涓婃姤鏃堕棿(鏍煎紡 yyyy-mm-dd hh:mm:ss)
+ public Float volt ;
+ public Byte valveSta ;//闃�闂ㄧ姸鎬�: 00闃�寮�锛�01闃�鍏�
+ public Byte alarmValve ;//闃�闂ㄦ姤璀�
+ public Byte alarmMagnetism ;//寮虹鎶ヨ
+ public Byte alarmVolt ;//鐢靛帇娆犲帇鎶ヨ
+
+ public boolean isAlarm(){
+ boolean flag = false ;
+ if(valveSta != null && valveSta.intValue() == 1){//闃�闂ㄧ姸鎬�(0:闃�寮� 1:闃�鍏�)
+ flag = true ;
+ }
+ if(alarmValve != null && alarmValve.intValue() == 1){//闃�闂ㄥ紓甯稿憡璀� 1 闃�闂ㄥ紓甯革紝0 闃�闂ㄦ甯�
+ flag = true ;
+ }
+ if(alarmVolt != null && alarmVolt.intValue() == 1){//鐢垫睜娆犲帇鍛婅 1鍛婅锛�0鏃犲憡璀�
+ flag = true ;
+ }
+ if(alarmMagnetism != null && alarmMagnetism.intValue() == 1){//纾佸共鎵板憡璀� 1鍛婅锛�0鏃犲憡璀�
+ flag = true ;
+ }
+ return flag ;
+ }
+
+ public String toString(){
+ StringBuffer sb = new StringBuffer() ;
+ sb.append(" 浜嬩欢涓婃姤 : \n") ;
+ sb.append(" 缁堢鏃堕棿 : " + dt + "\n") ;
+ sb.append(" 鐢靛帇 : " + volt + "\n") ;
+ sb.append(" 闃�闂ㄧ姸鎬� : " + valveSta + "锛�" + (valveSta==0?"闃�寮�":"闃�鍏�") + "锛塡n") ;
+ sb.append(" 闃�闂ㄦ姤璀� : " + alarmValve + "锛�" + (alarmValve==0?"姝e父":"鎶ヨ") + "锛塡n") ;
+ sb.append(" 寮虹鎶ヨ : " + alarmMagnetism + "锛�" + (alarmMagnetism==0?"姝e父":"鎶ヨ") + "锛塡n") ;
+ sb.append(" 娆犲帇鎶ヨ : " + alarmVolt + "锛�" + (alarmVolt==0?"姝e父":"鎶ヨ") + "锛塡n") ;
+ return sb.toString() ;
+ }
+ public String getDt() {
+ return dt;
+ }
+ public void setDt(String dt) {
+ this.dt = dt;
+ }
+ public Float getVolt() {
+ return volt;
+ }
+ public void setVolt(Float volt) {
+ this.volt = volt;
+ }
+ public Byte getValveSta() {
+ return valveSta;
+ }
+ public void setValveSta(Byte valveSta) {
+ this.valveSta = valveSta;
+ }
+ public Byte getAlarmValve() {
+ return alarmValve;
+ }
+ public void setAlarmValve(Byte alarmValve) {
+ this.alarmValve = alarmValve;
+ }
+ public Byte getAlarmMagnetism() {
+ return alarmMagnetism;
+ }
+ public void setAlarmMagnetism(Byte alarmMagnetism) {
+ this.alarmMagnetism = alarmMagnetism;
+ }
+ public Byte getAlarmVolt() {
+ return alarmVolt;
+ }
+ public void setAlarmVolt(Byte alarmVolt) {
+ this.alarmVolt = alarmVolt;
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/DataCd0405Vo.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/DataCd0405Vo.java
new file mode 100644
index 0000000..4b43380
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/DataCd0405Vo.java
@@ -0,0 +1,81 @@
+package com.dy.common.mw.protocol.pMeterV1_0_1;
+
+public class DataCd0405Vo {
+
+ public Byte open1_close2 ;//寮�闃�鏄�1锛屽叧闃�鏄�2
+
+ public Byte state ;//寮�鍏抽榾鎿嶄綔缁撴灉锛氬紑鍏冲埌浣嶏細01H锛� 寮�鍏宠秴鏃讹細02H 鐢垫祦瓒呴檺锛�03H
+
+ //浠ヤ笅鏁版嵁閮芥槸涓婃姤鏃跺埢鐨勬暟鎹�
+ public String dt ;//涓婃姤鏃堕棿(鏍煎紡 yyyy-mm-dd hh:mm:ss)
+
+ public String toString(){
+ StringBuffer sb = new StringBuffer() ;
+ if(open1_close2 != null && open1_close2.byteValue() == 1){
+ if(state != null && state.byteValue() == 1){
+ sb.append(" 寮�闃�缁撴灉 : 寮�鍒颁綅\n") ;
+ }else if(state != null && state.byteValue() == 2){
+ sb.append(" 寮�闃�缁撴灉 : 瓒呮椂\n") ;
+ }else if(state != null && state.byteValue() == 2){
+ sb.append(" 寮�闃�缁撴灉 : 鐢垫祦瓒呴檺\n") ;
+ }
+ }else if(open1_close2 != null && open1_close2.byteValue() == 2){
+ if(state != null && state.byteValue() == 1){
+ sb.append(" 鍏抽榾缁撴灉 : 鍏冲埌浣峔n") ;
+ }else if(state != null && state.byteValue() == 2){
+ sb.append(" 鍏抽榾缁撴灉 : 瓒呮椂\n") ;
+ }else if(state != null && state.byteValue() == 2){
+ sb.append(" 鍏抽榾缁撴灉 : 鐢垫祦瓒呴檺\n") ;
+ }
+ }
+ sb.append(" 缁堢鏃堕棿 : " + dt + "\n") ;
+ return sb.toString() ;
+ }
+
+ /**
+ * 鐢卞叾浜х敓鍛戒护鏃ュ織锛屽苟瀛樺偍鍒版暟鎹簱涓�
+ * @return
+ */
+ public String resultInfo(){
+ StringBuffer sb = new StringBuffer() ;
+ if(open1_close2 != null && open1_close2.byteValue() == 1){
+ if(state != null && state.byteValue() == 1){
+ sb.append(" 寮�闃�缁撴灉 : 寮�鍒颁綅\n") ;
+ }else if(state != null && state.byteValue() == 2){
+ sb.append(" 寮�闃�缁撴灉 : 瓒呮椂\n") ;
+ }else if(state != null && state.byteValue() == 2){
+ sb.append(" 寮�闃�缁撴灉 : 鐢垫祦瓒呴檺\n") ;
+ }
+ }else if(open1_close2 != null && open1_close2.byteValue() == 2){
+ if(state != null && state.byteValue() == 1){
+ sb.append(" 鍏抽榾缁撴灉 : 鍏冲埌浣峔n") ;
+ }else if(state != null && state.byteValue() == 2){
+ sb.append(" 鍏抽榾缁撴灉 : 瓒呮椂\n") ;
+ }else if(state != null && state.byteValue() == 2){
+ sb.append(" 鍏抽榾缁撴灉 : 鐢垫祦瓒呴檺\n") ;
+ }
+ }
+ sb.append(" 缁堢鏃堕棿 : " + dt + "\n") ;
+ return sb.toString() ;
+ }
+
+ public Byte getOpen1_close2() {
+ return open1_close2;
+ }
+ public void setOpen1_close2(Byte open1_close2) {
+ this.open1_close2 = open1_close2;
+ }
+ public Byte getState() {
+ return state;
+ }
+ public void setState(Byte sate) {
+ this.state = sate;
+ }
+ public String getDt() {
+ return dt;
+ }
+ public void setDt(String dt) {
+ this.dt = dt;
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/DataCd06Vo.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/DataCd06Vo.java
new file mode 100644
index 0000000..a4784fd
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/DataCd06Vo.java
@@ -0,0 +1,41 @@
+package com.dy.common.mw.protocol.pMeterV1_0_1;
+
+//寮�鍏抽榾缁撴灉涓婃姤
+public class DataCd06Vo {
+ public String dt ;//涓婃姤鏃堕棿(鏍煎紡 yyyy-mm-dd hh:mm:ss)
+ public Byte valveRes ;//闃�闂ㄥ姩浣滅粨鏋�: //0, 鍏冲埌浣�; 1, 寮�鍒颁綅; 2, 瓒呮椂; 3, 鍫佃浆; 4, 娲楅榾鎴愬姛
+
+ public boolean isAlarm(){
+ if(valveRes != null && (valveRes.intValue() == 2 || valveRes.intValue() == 3)){//2 瓒呮椂 3鍫佃浆
+ return true ;
+ }
+ return false ;
+ }
+
+ public String toString(){
+ StringBuffer sb = new StringBuffer() ;
+ sb.append(" 寮�鍏抽榾缁撴灉涓婃姤 : \n") ;
+ sb.append(" 缁堢鏃堕棿 : " + dt + "\n") ;
+ sb.append(" 闃�闂ㄥ姩浣滅粨鏋� : " + valveRes + "锛�" + (valveRes==0?"鍏冲埌浣�":(valveRes==1?"寮�鍒颁綅":(valveRes==2?"瓒呮椂":(valveRes==3?"鍫佃浆":(valveRes==4?"娲楅榾鎴愬姛":""))))) + "锛塡n") ;
+ return sb.toString() ;
+ }
+
+ public String getDt() {
+ return dt;
+ }
+
+ public void setDt(String dt) {
+ this.dt = dt;
+ }
+
+ public Byte getValveRes() {
+ return valveRes;
+ }
+
+ public void setValveRes(Byte valveRes) {
+ this.valveRes = valveRes;
+ }
+
+
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/DataV1_0_1.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/DataV1_0_1.java
new file mode 100644
index 0000000..5f9d4cf
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/DataV1_0_1.java
@@ -0,0 +1,136 @@
+package com.dy.common.mw.protocol.pMeterV1_0_1;
+
+public class DataV1_0_1 implements java.io.Serializable{
+
+ private static final long serialVersionUID = 202211271110001L;
+
+ public static String ALIAS = DataV1_0_1.class.getName() ;
+
+ public String rtuAddr ;//RtuAddr
+ public String meterNo ;//姘磋〃鍙�
+ public String version ;//鍗忚鐗堟湰鍙�
+
+ public DataCd01Vo dataCd01Vo ;//鍛ㄦ湡涓婃姤鏁版嵁
+ public DataCd02Vo dataCd02Vo ;//瀹炴椂锛堣Е鍙戯級涓婃姤鏁版嵁
+ public DataCd03Vo dataCd03Vo ;//浜嬩欢鎶�
+ public DataCd0405Vo dataCd0405Vo ;//寮�鍏抽榾鍥炴墽
+ public DataCd06Vo dataCd06Vo ;//寮�鍏抽榾缁撴灉
+
+ public String dt ;//閫氫俊涓棿浠朵骇鐢熷彂鎶ユ椂闂�(yyyy-MM-dd hh:mm:ss)
+
+
+ public String toString(){
+ StringBuffer sb = new StringBuffer() ;
+ sb.append(" 鐢典俊IMEI鍙� : " + (rtuAddr==null?"":rtuAddr) + "\n") ;
+ sb.append(" 姘磋〃鍙� : " + (meterNo==null?"":meterNo) + "\n") ;
+ sb.append(" 鍗忚鐗堟湰鍙�:" + version + "\n") ;
+ sb.append(" 缁堢鏁版嵁:\n") ;
+ if(dataCd01Vo != null){
+ sb.append(dataCd01Vo.toString()) ;
+ }
+ if(dataCd02Vo != null){
+ sb.append(dataCd02Vo.toString()) ;
+ }
+ if(dataCd03Vo != null){
+ sb.append(dataCd03Vo.toString()) ;
+ }
+ if(dataCd0405Vo != null){
+ sb.append(dataCd0405Vo.toString()) ;
+ }
+ if(dataCd06Vo != null){
+ sb.append(dataCd06Vo.toString()) ;
+ }
+ return sb.toString() ;
+ }
+
+ /**
+ * 鐢卞叾浜х敓鍛戒护鏃ュ織
+ * @return
+ */
+ public String resultInfo(){
+ if(dataCd0405Vo != null){
+ return dataCd0405Vo.resultInfo() ;
+ }
+ return "" ;
+ }
+
+
+ public String getRtuAddr() {
+ return rtuAddr;
+ }
+ public void setRtuAddr(String rtuAddr) {
+ this.rtuAddr = rtuAddr;
+ }
+
+ public String getMeterNo() {
+ return meterNo;
+ }
+
+
+ public void setMeterNo(String meterNo) {
+ this.meterNo = meterNo;
+ }
+
+
+ public String getVersion() {
+ return version;
+ }
+ public void setVersion(String version) {
+ this.version = version;
+ }
+ public String getDt() {
+ return dt;
+ }
+ public void setDt(String dt) {
+ this.dt = dt;
+ }
+
+
+ public DataCd01Vo getDataCd01Vo() {
+ return dataCd01Vo;
+ }
+
+
+ public void setDataCd01Vo(DataCd01Vo dataCd01Vo) {
+ this.dataCd01Vo = dataCd01Vo;
+ }
+
+
+ public DataCd02Vo getDataCd02Vo() {
+ return dataCd02Vo;
+ }
+
+
+ public void setDataCd02Vo(DataCd02Vo dataCd02Vo) {
+ this.dataCd02Vo = dataCd02Vo;
+ }
+
+
+ public DataCd03Vo getDataCd03Vo() {
+ return dataCd03Vo;
+ }
+
+
+ public void setDataCd03Vo(DataCd03Vo dataCd03Vo) {
+ this.dataCd03Vo = dataCd03Vo;
+ }
+
+
+ public DataCd0405Vo getDataCd0405Vo() {
+ return dataCd0405Vo;
+ }
+
+
+ public void setDataCd0405Vo(DataCd0405Vo dataCd0405Vo) {
+ this.dataCd0405Vo = dataCd0405Vo;
+ }
+
+ public DataCd06Vo getDataCd06Vo() {
+ return dataCd06Vo;
+ }
+
+ public void setDataCd06Vo(DataCd06Vo dataCd06Vo) {
+ this.dataCd06Vo = dataCd06Vo;
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/DriverV1_0_1.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/DriverV1_0_1.java
new file mode 100644
index 0000000..a3a1648
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/DriverV1_0_1.java
@@ -0,0 +1,188 @@
+package com.dy.common.mw.protocol.pMeterV1_0_1;
+
+import java.net.URI;
+import java.net.URL;
+
+import com.dy.common.mw.protocol.AnnotationDriver;
+import com.dy.common.mw.protocol.CodeParse;
+import com.dy.common.mw.protocol.CodeParseCallback;
+import com.dy.common.mw.protocol.Command;
+import com.dy.common.mw.protocol.Data;
+import com.dy.common.mw.protocol.Driver;
+import com.dy.common.mw.protocol.DriverParserDataCallback;
+import com.dy.common.mw.protocol.MidResult;
+import com.dy.common.mw.protocol.MidResultError;
+import com.dy.common.util.DateTime;
+
+@AnnotationDriver(name=ProtocolConstantV1_0_1.protocolName)
+public class DriverV1_0_1 extends Driver {
+
+ private static String scanRootPackage = "com.dy.common.mw.protocol.pMeterV1_0_1." ;
+
+ //鍦―river涓槸鍗曚緥锛岄殢Driver鐨勫崟渚嬪璞″湪鍗曠嚎绋嬩腑杩愯
+ private ParseParamsForUpV1_0_1 upCpParams ;
+ private ParseParamsForDownV1_0_1 downCpParams ;
+
+ private Boolean reportOrResponse_trueOrFalse = null ;
+ private String rtuAddrInData = null ;
+ private String meterNoInData = null ;
+
+ public DriverV1_0_1(){
+ upCpParams = new ParseParamsForUpV1_0_1() ;
+ downCpParams = new ParseParamsForDownV1_0_1() ;
+ }
+
+
+ /**
+ * 鎵弿璇嗗埆鍔熻兘鐮佹敞瑙g被
+ */
+ @Override
+ public void scanAnnotationCode() throws Exception{
+ if(!scanRootPackage.endsWith(".")){
+ scanRootPackage += "." ;
+ }
+ URL url = this.getClass().getResource("/" + scanRootPackage.replace('.', '/'));
+ URI uri = new URI(url.toString());
+ super.doScanAnnotationCode(this, ProtocolConstantV1_0_1.protocolName, uri, scanRootPackage) ;
+ }
+ /**
+ * 瑙f瀽涓婅鏁版嵁
+ * @param isLowPower 鏄惁鍦ㄤ綆鍔熻�楃幆澧冧笅杩愯
+ * @param rtuAddr
+ * @param upBuffer
+ * @param callback
+ * @param upHex
+ * @return
+ */
+ @Override
+ public MidResult[] parseData(Boolean isLowPower, String rtuAddr, byte[] upBuffer, String upHex, DriverParserDataCallback callback, Object... params) {
+ return parseData(isLowPower, rtuAddr, null, null, upBuffer, upHex, callback) ;
+ }
+ /**
+ * 瑙f瀽涓婅鏁版嵁
+ * @param isLowPower 鏄惁鍦ㄤ綆鍔熻�楃幆澧冧笅杩愯
+ * @param rtuAddr
+ * @param productId 鐢典俊骞冲彴浜у搧ID锛屽綋涓嶅湪鐢典俊骞冲彴涓繍琛屾椂锛屼负null
+ * @param deviceId 鐢典俊骞冲彴璁惧ID锛屽綋涓嶅湪鐢典俊骞冲彴涓繍琛屾椂锛屼负null
+ * @param upBuffer
+ * @param callback
+ * @param upHex
+ * @return
+ */
+ @Override
+ public MidResult[] parseData(Boolean isLowPower, String rtuAddr, Integer productId, String deviceId, byte[] upBuffer, String upHex, DriverParserDataCallback callback, Object... params) {
+ reportOrResponse_trueOrFalse = null ;
+ boolean isFail = false ;
+ String meterNo = null ;
+ String upCode = "" ;
+ try{
+ CommonV1_0_1 cp = new CommonV1_0_1() ;
+ cp.checkHead(upBuffer) ;
+ cp.checkTail(upBuffer) ;
+ String crcStr = cp.checkCrc_str(upBuffer) ;
+ if(crcStr != null){
+ return new MidResult[]{(new MidResultError(ProtocolConstantV1_0_1.protocolName, rtuAddr, null, "涓ラ噸閿欒锛屼笂琛屾暟鎹瓹RC妫�鏌ュけ璐ワ紝" + crcStr, null))} ;
+ }
+ rtuAddr = cp.parseRtuAddr(upBuffer) ;
+ upCode = cp.parseCode(upBuffer) ;
+ if(upCode == null){
+ return new MidResult[]{(new MidResultError(ProtocolConstantV1_0_1.protocolName, rtuAddr, null, "涓ラ噸閿欒锛屾湭鑳戒粠涓婅鏁版嵁涓В鏋愬嚭鍔熻兘鐮侊紒", null))} ;
+ }
+ //Integer dataLen = cp.parseFrameLen(upBuffer) ;
+ Data upData = new Data() ;
+ upData.setRtuAddr(rtuAddr) ;
+ meterNo = cp.parseMeterNo(upBuffer) ;
+ upData.setMeterNo(meterNo) ;
+ upData.setProtocol(ProtocolConstantV1_0_1.protocolName);
+ upData.setCode(upCode) ;
+ upData.setHex(upHex) ;
+
+
+ DataV1_0_1 dV1_0_1 = new DataV1_0_1() ;
+ dV1_0_1.version = cp.parseVersion(upBuffer) ;
+ dV1_0_1.rtuAddr = rtuAddr ;
+ dV1_0_1.meterNo = meterNo ;
+ dV1_0_1.meterNo = cp.parseMeterNo(upBuffer) ;
+ dV1_0_1.dt = DateTime.yyyy_MM_dd_HH_mm_ss() ;
+
+ upData.setSubData(dV1_0_1) ;
+
+ this.upCpParams.clear();
+ this.upCpParams.setValue(ProtocolConstantV1_0_1.protocolName,
+ rtuAddr,
+ meterNo,
+ productId,
+ deviceId,
+ upCode,
+ upHex,
+ upBuffer,
+ upData);
+ CodeParse codeParse = this.getUpCodeParser(upCode) ;
+ if(codeParse == null){
+ return new MidResult[]{(new MidResultError(ProtocolConstantV1_0_1.protocolName, rtuAddr, meterNo, "涓ラ噸閿欒锛屾湭鑳藉緱鍒颁笂琛屾暟鎹姛鑳界爜" + upCode + "澶勭悊绫�!", null))} ;
+ }else{
+ return codeParse.parse(isLowPower, this.upCpParams, new CodeParseCallback(){
+ @Override
+ public void callback(Boolean flag) {
+ reportOrResponse_trueOrFalse = flag ;
+ rtuAddrInData = dV1_0_1.getRtuAddr() ;
+ meterNoInData = dV1_0_1.getMeterNo() ;
+ }
+ });
+ }
+
+ } catch (Exception e) {
+ isFail = true ;
+ return new MidResult[]{(new MidResultError(ProtocolConstantV1_0_1.protocolName, rtuAddr, meterNo, "涓ラ噸閿欒锛屽垎鏋怰tu鏁版嵁鍑洪敊锛佹暟鎹负锛�" + upHex + (e.getMessage() == null?"":("锛屽嚭閿欎俊鎭細" + e.getMessage())), e))} ;
+ } finally{
+ callback.callback(rtuAddr, meterNo, upCode, upHex, reportOrResponse_trueOrFalse, isFail, rtuAddrInData, meterNoInData);
+ }
+ }
+ /**
+ * 鏋勯�犱笅琛屾暟鎹紙鍛戒护锛�
+ * @param isLowPower 鏄惁鍦ㄤ綆鍔熻�楃幆澧冧笅杩愯
+ * @param command 鍛戒护
+ * @return
+ */
+ @Override
+ public MidResult[] createCommand(Boolean isLowPower, Command command, Object... params) {
+ String rtuAddr = command.getRtuAddr() ;
+ if(rtuAddr == null){
+ return new MidResult[]{(new MidResultError(ProtocolConstantV1_0_1.protocolName, null, null, "涓ラ噸閿欒锛屽懡浠や腑IMEI鍙蜂负绌猴紝涓嶈兘鏋勫缓浠讳綍鍛戒护锛�", null))} ;
+ }
+ String meterNo = command.getMeterNo() ;
+ if(meterNo == null){
+ return new MidResult[]{(new MidResultError(ProtocolConstantV1_0_1.protocolName, null, null, "涓ラ噸閿欒锛屽懡浠や腑姘磋〃鍙蜂负绌猴紝涓嶈兘鏋勫缓浠讳綍鍛戒护锛�", null))} ;
+ }
+ try {
+ String commandCode = command.getCode() ;
+
+ this.downCpParams.clear();
+ this.downCpParams.setValue(
+ ProtocolConstantV1_0_1.protocolName,
+ rtuAddr,
+ meterNo,
+ command.getProductId(), //鐢典俊骞冲彴浜у搧ID锛屽綋涓嶅湪鐢典俊骞冲彴杩愯鏃讹紝涓簄ull
+ command.getDeviceId(), //鐢典俊骞冲彴璁惧ID锛屽綋涓嶅湪鐢典俊骞冲彴杩愯鏃讹紝涓簄ull
+ command.getId(),
+ commandCode,
+ command.getParam(),
+ command.getAttachment());
+
+ if(commandCode == null){
+ return new MidResult[]{(new MidResultError(ProtocolConstantV1_0_1.protocolName, rtuAddr, meterNo, "涓ラ噸閿欒锛屽懡浠や腑鍔熻兘鐮佷负绌猴紝涓嶈兘鏋勫缓浠讳綍鍛戒护锛�", null))} ;
+ }else{
+ CodeParse codeParse = this.getDownCodeParser(commandCode) ;
+ if(codeParse == null){
+ return new MidResult[]{(new MidResultError(ProtocolConstantV1_0_1.protocolName, rtuAddr, meterNo, "涓ラ噸閿欒锛屾湭鑳藉緱鍒颁笅琛屾暟鎹姛鑳界爜" + commandCode + "澶勭悊绫�!", null))} ;
+ }else{
+ return codeParse.parse(isLowPower, this.downCpParams, null);
+ }
+ }
+ } catch (Exception e) {
+ return new MidResult[]{(new MidResultError(ProtocolConstantV1_0_1.protocolName, rtuAddr, meterNo, "涓ラ噸閿欒锛屾瀯閫犱笅琛屾暟鎹嚭閿欙紒鍛戒护涓猴細" + command.toString(), e))} ;
+ }
+ }
+
+
+}
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/OnLineV1_0_1.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/OnLineV1_0_1.java
new file mode 100644
index 0000000..149800b
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/OnLineV1_0_1.java
@@ -0,0 +1,42 @@
+package com.dy.common.mw.protocol.pMeterV1_0_1;
+
+import com.dy.common.mw.protocol.AnnotationOnLine;
+import com.dy.common.mw.protocol.OnLine;
+
+@AnnotationOnLine(
+ protocolName = ProtocolConstantV1_0_1.protocolName,
+ priority = ProtocolConstantV1_0_1.priority)
+public class OnLineV1_0_1 implements OnLine{
+
+ /**
+ * 瀵逛笂绾挎暟鎹繘琛屽垎鏋�
+ * @param aepImei 鐢典俊骞冲彴浼犳潵鐨処MEI鍙�
+ * @param bs
+ * @return
+ */
+ @Override
+ public OnLineResult parse(String aepImei, byte[] upBuf)throws Exception {
+ OnLineResult olr = new OnLineResult() ;
+ CommonV1_0_1 cp = new CommonV1_0_1() ;
+ Boolean flag = cp.isThisProtocolHead(upBuf) ;
+ if(flag == null){
+ //鍑洪敊
+ olr.result = OnLine.OnLineAction_fail ;
+ olr.rtuAddr = null ;
+ olr.meterNo = null ;
+ }else if(!flag.booleanValue()){
+ //涓嶆槸鏈崗璁暟鎹�
+ olr.result = OnLine.OnLineAction_success_noMe ;
+ olr.rtuAddr = null ;
+ olr.meterNo = null ;
+ }else{
+ //鏄湰鍗忚鏁版嵁
+ olr.result = OnLine.OnLineAction_success ;
+ olr.rtuAddr = cp.parseRtuAddr(upBuf) ;
+ olr.meterNo = cp.parseMeterNo(upBuf) ;
+ olr.protocolName = ProtocolConstantV1_0_1.protocolName ;
+ }
+ return olr;
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/ParseParamsForDownV1_0_1.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/ParseParamsForDownV1_0_1.java
new file mode 100644
index 0000000..862ab0c
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/ParseParamsForDownV1_0_1.java
@@ -0,0 +1,52 @@
+package com.dy.common.mw.protocol.pMeterV1_0_1;
+
+import com.dy.common.mw.protocol.CodeParseParams;
+
+public class ParseParamsForDownV1_0_1 implements CodeParseParams{
+
+ public String protocolName ;
+ public String rtuAddr ;//IMEI鍙凤紙鐢典俊骞冲彴璁惧IMEI锛�
+ public String meterNo ;//姘磋〃鍙�
+ public Integer productId ;//鐢典俊骞冲彴浜у搧ID锛屽綋涓嶅湪鐢典俊骞冲彴杩愯鏃讹紝涓簄ull
+ public String deviceId ;//鐢典俊骞冲彴璁惧ID锛屽綋涓嶅湪鐢典俊骞冲彴杩愯鏃讹紝涓簄ull
+ public String commandId ;
+ public String commandCode ;
+ public Object param ;
+ public Object attachment ;
+
+ public ParseParamsForDownV1_0_1(){}
+
+ public void clear(){
+ this.protocolName = null ;
+ this.rtuAddr = null ;
+ this.meterNo = null ;
+ this.productId = null ;
+ this.deviceId = null ;
+ this.commandId = null ;
+ this.commandCode = null ;
+ this.param = null ;
+ this.attachment = null ;
+ }
+
+ public void setValue(
+ String protocolName,
+ String rtuAddr,
+ String meterNo,
+ Integer productId,
+ String deviceId,
+ String commandId,
+ String commandCode,
+ Object param,
+ Object attachment ){
+ this.protocolName = protocolName ;
+ this.rtuAddr = rtuAddr ;
+ this.meterNo = meterNo ;
+ this.productId = productId ;
+ this.deviceId = deviceId ;
+ this.commandId = commandId ;
+ this.commandCode = commandCode ;
+ this.param = param ;
+ this.attachment = attachment ;
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/ParseParamsForUpV1_0_1.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/ParseParamsForUpV1_0_1.java
new file mode 100644
index 0000000..988ddc1
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/ParseParamsForUpV1_0_1.java
@@ -0,0 +1,51 @@
+package com.dy.common.mw.protocol.pMeterV1_0_1;
+
+import com.dy.common.mw.protocol.CodeParseParams;
+import com.dy.common.mw.protocol.Data;
+
+public class ParseParamsForUpV1_0_1 implements CodeParseParams{
+
+ public String protocolName ;//鍗忚鍚嶇О
+ public String rtuAddr ;//IMEI鍙�(IMEI鍙�)
+ public String meterNo ;//姘磋〃鍙�
+ public Integer productId ;//鐢典俊骞冲彴浜у搧ID锛屽綋涓嶅湪鐢典俊骞冲彴杩愯鏃讹紝涓簄ull
+ public String deviceId ;//鐢典俊骞冲彴璁惧ID锛屽綋涓嶅湪鐢典俊骞冲彴杩愯鏃讹紝涓簄ull
+ public String upCode ;//涓婅鎶ユ枃鏁版嵁涓殑鍔熻兘鐮�
+ public String upHex ;//琛屾姤鏂囨暟鎹崄鍏繘鍒跺舰寮�
+ public byte[] upBuffer ;//琛屾姤鏂囨暟鎹瓧鑺傛暟缁�
+ public Data data ;//瑙f瀽鍚庣殑鏁版嵁
+
+ public ParseParamsForUpV1_0_1(){}
+
+ public void clear(){
+ this.protocolName = null ;
+ this.rtuAddr = null ;
+ this.meterNo = null ;
+ this.productId = null ;
+ this.deviceId = null ;
+ this.upCode = null ;
+ this.upHex = null ;
+ this.upBuffer = null ;
+ this.data = null ;
+ }
+
+ public void setValue(String protocolName,
+ String rtuAddr,
+ String meterNo,
+ Integer productId,
+ String deviceId,
+ String upCode,
+ String upHex,
+ byte[] upBuffer,
+ Data data){
+ this.protocolName = protocolName ;
+ this.rtuAddr = rtuAddr ;
+ this.meterNo = meterNo ;
+ this.productId = productId ;
+ this.deviceId = deviceId ;
+ this.upCode = upCode ;
+ this.upHex = upHex ;
+ this.upBuffer = upBuffer ;
+ this.data = data ;
+ }
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/PrefixedDataAvailableV1_0_1.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/PrefixedDataAvailableV1_0_1.java
new file mode 100644
index 0000000..63ec806
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/PrefixedDataAvailableV1_0_1.java
@@ -0,0 +1,125 @@
+package com.dy.common.mw.protocol.pMeterV1_0_1;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.mina.core.buffer.BufferDataException;
+import org.apache.mina.core.buffer.IoBuffer;
+
+import com.dy.common.mw.channel.tcp.PrefixedDataAvailableStatus;
+import com.dy.common.mw.protocol.AnnotationPrefixedDataAvailable;
+import com.dy.common.mw.protocol.PrefixedDataAvailable;
+import com.dy.common.util.ByteUtil;
+
+
+@AnnotationPrefixedDataAvailable(
+ protocolName = ProtocolConstantV1_0_1.protocolName,
+ priority = ProtocolConstantV1_0_1.priority,
+ onLineDataMinLength = ProtocolConstantV1_0_1.onLineDataMinLength,
+ headMinLength = ProtocolConstantV1_0_1.headMinLength)
+public class PrefixedDataAvailableV1_0_1 implements PrefixedDataAvailable {
+
+ private static Logger log = LogManager.getLogger(PrefixedDataAvailableV1_0_1.class) ;
+
+ private static String protocolName = ProtocolConstantV1_0_1.protocolName ;
+
+
+ /**
+ * 鍒嗘瀽涓婄嚎鏁版嵁(缃戠粶杩炴帴鍚庣涓�鍖呮暟鎹�)鏄惁鍙幏寰�
+ * @param in
+ * @param remain 涓�瀹氭椂澶т簬0鐨勬暟鎹�
+ * @param minDataLength 鏈�灏忔暟鎹暱搴�
+ * @param maxDataLength 鏈�澶ф暟鎹暱搴︼紝杈惧埌鎴栬秴杩囨闀垮害锛岃涓烘槸鍨冨溇鏁版嵁銆備緥濡傦細鏁版嵁澶撮儴鏄纭殑锛屼絾鍚堟硶鏁版嵁缁撳熬鎬讳笉鍑虹幇锛岃涓烘鏁版嵁鍨冨溇鏁版嵁
+ * @return 涓嶆槸鏈崗璁暟鎹椂杩斿洖绌�
+ * @throws Exception
+ */
+ public PrefixedDataAvailableStatus forOnLine(IoBuffer in,
+ int remain,
+ int minDataLength, //瀵瑰簲ProtocolConstantV2_0.onLineDataMinLength
+ int maxDataLength //瀵瑰簲ProtocolConstant.errorMaxLength
+ ) throws Exception {
+
+ int oldPosition = in.position() ;
+ byte[] preByte = new byte[remain];
+ in.get(preByte) ;
+ //in.position(0) ;//閿欒鐢ㄦ硶锛屽鏋滃彂鐢熺矘鍖呮暟鎹紝灏嗕細姝诲惊鐜�
+ in.position(oldPosition) ;
+
+ return this.doForData(preByte, minDataLength, maxDataLength) ;
+ }
+
+ /**
+ * 鍒嗘瀽涓婄嚎鍚�(缃戠粶杩炴帴鍚庨潪绗竴鍖呮暟鎹�)鏄惁鍙幏寰�
+ * @param in
+ * @param protocolConf Rtu閰嶇疆
+ * @param maxDataLength
+ * @return
+ * @throws Exception
+ */
+ @Override
+ public PrefixedDataAvailableStatus forUpData(IoBuffer in,
+ int remain,
+ int minDataLength,
+ int maxDataLength) throws Exception {
+ int oldPosition = in.position() ;
+ byte[] preByte = new byte[remain];
+ in.get(preByte) ;
+ //in.position(0) ;//閿欒鐢ㄦ硶锛屽鏋滃彂鐢熺矘鍖呮暟鎹紝灏嗕細姝诲惊鐜�
+ in.position(oldPosition) ;
+
+ return this.doForData(preByte, minDataLength, maxDataLength) ;
+
+ }
+ /**
+ * 杩涜鍒ゆ柇
+ * @param preByte
+ * @param maxDataLength
+ * @return
+ */
+ private PrefixedDataAvailableStatus doForData(byte[] preByte, int minDataLength, int maxDataLength) throws Exception{
+ int remain = preByte.length ;
+
+ if (remain < minDataLength) {
+ log.warn("鍩轰簬鍗忚锛�" + protocolName + "锛夊垽鏂暟鎹ご閮ㄥ彂鐢熸柇鍖呯幇璞°��") ;
+ return new PrefixedDataAvailableStatus().breaked() ;
+ }
+
+ if(remain >= maxDataLength){
+ //瓒呭嚭浜嗘渶澶ч暱搴﹂檺鍒�,渚嬪锛氭暟鎹ご閮ㄦ槸姝g‘鐨勶紝浣嗗悎娉曟暟鎹粨灏炬�讳笉鍑虹幇锛岃涓烘鏁版嵁鍨冨溇鏁版嵁
+ return new PrefixedDataAvailableStatus().rubbish(remain) ;
+ }
+
+
+ CommonV1_0_1 parseCommon = new CommonV1_0_1();
+ boolean isThisProtocolData = parseCommon.isThisProtocolHead(preByte) ;
+
+ if(!isThisProtocolData){
+ //涓嶆槸鏈崗璁暟鎹�
+ return null ;
+ }
+
+ Integer dataLen = parseCommon.parseDataLen(preByte) ;
+
+ String headHex = ByteUtil.bytes2Hex(preByte, true) ;
+
+ if(dataLen == null){
+ throw new BufferDataException("鏀跺埌鏁版嵁涔嬪抚鍓嶉儴锛�" + headHex + "锛屼絾涓ラ噸閿欒锛屽湪杩涜鏂寘涓庣矘鍖呮鏌ユ椂锛屾湭鑳藉緱鍒版暟鎹抚鐨勯暱搴︺��");
+ }
+
+ if (dataLen <= 0 || dataLen > maxDataLength) {
+ throw new BufferDataException("鏀跺埌鏁版嵁涔嬪抚鍓嶉儴锛�" + headHex + "锛屼絾涓ラ噸閿欒锛屽湪杩涜鏂寘涓庣矘鍖呮鏌ユ椂锛屾暟鎹抚鐨勯暱搴�(" + dataLen + ")瓒呭嚭鍚堟硶鑼冨洿銆�");
+ }
+
+ if(remain == dataLen){
+ //涓嶆柇涓嶇矘
+ return new PrefixedDataAvailableStatus().completed(dataLen) ;
+ }else if(remain > dataLen){
+ log.warn("鏀跺埌鏁版嵁涔嬪抚鍓嶉儴锛�" + headHex + "锛屼絾鍙戠敓绮樺寘鐜拌薄銆�") ;
+ return new PrefixedDataAvailableStatus().adjoined(dataLen) ;
+ }else{
+ // remain < dataLen
+ log.warn("鏀跺埌鏁版嵁涔嬪抚鍓嶉儴锛�" + headHex + "锛屼絾鍙戠敓鏂寘鐜拌薄銆�") ;
+ return new PrefixedDataAvailableStatus().breaked() ;
+ }
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/ProtocolConstantV1_0_1.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/ProtocolConstantV1_0_1.java
new file mode 100644
index 0000000..a12d6ff
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/ProtocolConstantV1_0_1.java
@@ -0,0 +1,54 @@
+package com.dy.common.mw.protocol.pMeterV1_0_1;
+
+public class ProtocolConstantV1_0_1 {
+
+ public static final String version = "1.0.1" ;
+ public static final Byte versionByte = 101 ;
+
+ /**
+ * 娉ㄨВ鐩稿叧
+ */
+ public static final String protocolName = "meterV1_0_1" ;
+ public static final int priority = 1 ;//浼樺厛绾�
+ /**
+ * RTU涓婄嚎鏁版嵁锛堜笂绾垮悗绗竴鍖呮暟鎹級鏈�灏忛暱搴︼紝璁剧疆璇ュ睘鎬т互澶囪繘琛屽畬鏁存�ф鏌ワ紝
+ * 鍗虫柇鍖呮鏌ワ紝浣垮敖鍙兘鏀跺叏涓婄嚎鏁版嵁锛堝彇鍊艰寖鍥�1-100锛�
+ */
+ public static final int onLineDataMinLength = 30 ;//閲囩敤闃�鎺у洖鎵э紙鍏堕暱搴︽渶鐭級鐨勫瓧鑺傛暟
+
+ /**
+ * RTU涓婃姤鏁版嵁鐨勫ご閮ㄦ渶灏忛暱搴︼紝涓婃姤鏁版嵁涓紝鍙栬繖涓渶灏忛暱搴︾殑閮ㄥ垎鏁版嵁涓紝
+ * 瑕佷竴瀹氬寘鍚暟鎹抚闀垮害锛屼互澶囧彇鍑烘暟鎹抚闀垮害鏉ワ紝杩涜瀹屾暣鎬ф鏌ワ紝
+ * 鍗虫柇鍖呬笌绮樺寘妫�鏌�(鍙栧�艰寖鍥�0-100锛屽叾涓彇鍊间负0鏃讹紝琛ㄧずheadMinLength鏁版嵁鏃犱綔鐢紝鐢卞崗璁疄鐜版潵鎺у埗)
+ */
+ public static final int headMinLength = 3 ;
+
+
+ //甯ц捣濮�
+ public static final byte P_Head_Byte = (byte)0x68 ;
+ public static final byte P_Tail_Byte = (byte)0x16 ;
+
+ public static final String P_Head_Hex = "68" ;
+ public static final String P_Tail_Hex = "16" ;
+
+ public static final byte downBsHeadLen = 21 ;//涓嬭鏁版嵁澶撮儴(寮�濮嬭嚦鍔熻兘鐮佹墍鍦ㄥ瓧鑺�)
+ public static final byte downBsTailLen = 2 ;//涓嬭鏁版嵁灏鹃儴(鏍¢獙鍜屾墍鍦ㄥ瓧鑺傝嚦鏈�鍚�)
+
+ /**
+ * 鎵�鍦ㄥ瓧鑺傛暟缁勭殑浣嶇疆锛堜笅鏍囷級
+ */
+ public static final int dataLenIndex_start = 1 ;//甯ч暱搴︽墍鍦� 瀛楄妭鏁扮粍璧峰涓嬫爣
+ public static final int dataLenIndex_end = 2 ;//甯ч暱搴︽墍鍦� 瀛楄妭鏁扮粍鎴涓嬫爣
+ public static final int versionIndex = 3 ;//鐗堟湰鍙峰瓧鑺傛暟缁勪笅鏍�
+ public static final int rtuAddrIndex_start = 4 ;//閫氳妯″潡 IMEI 璧峰瀛楄妭鏁扮粍涓嬫爣
+ public static final int rtuAddrIndex_end = 11 ;//閫氳妯″潡 IMEI 鎴瀛楄妭鏁扮粍涓嬫爣
+ public static final int meterNoIndex_start = 12 ;//琛ㄥ彿璧峰瀛楄妭鏁扮粍涓嬫爣
+ public static final int meterNoIndex_end = 19 ;//琛ㄥ彿鎴瀛楄妭鏁扮粍涓嬫爣
+ public static final int codeIndex = 20 ;//鍔熻兘鐮佸瓧鑺傛暟缁勪笅鏍�
+ //public static final int dtIndex_start = 13 ;////鏃ユ湡寮�濮嬪瓧鑺傛暟缁勪笅鏍�
+ //public static final int dtIndex_end = 18 ;////鏃ユ湡鎴瀛楄妭鏁扮粍涓嬫爣
+ //public static final int signalIndex_start = 28 ;//淇″彿寮哄害寮�濮嬪瓧鑺傛暟缁勪笅鏍�
+ //public static final int signalIndex_end = 29 ;//淇″彿寮哄害鎴瀛楄妭鏁扮粍涓嬫爣
+
+
+}
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/parse/Cd_01_Up.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/parse/Cd_01_Up.java
new file mode 100644
index 0000000..0c47f3b
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/parse/Cd_01_Up.java
@@ -0,0 +1,168 @@
+package com.dy.common.mw.protocol.pMeterV1_0_1.parse;
+
+import java.util.ArrayList;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import com.dy.common.mw.protocol.AnnotationCodeUp;
+import com.dy.common.mw.protocol.CodeParse;
+import com.dy.common.mw.protocol.CodeParseCallback;
+import com.dy.common.mw.protocol.CodeParseParams;
+import com.dy.common.mw.protocol.Command;
+import com.dy.common.mw.protocol.Data;
+import com.dy.common.mw.protocol.MidResult;
+import com.dy.common.mw.protocol.MidResultFromRtu;
+import com.dy.common.mw.protocol.MidResultToRtu;
+import com.dy.common.mw.protocol.pMeterV1_0_1.*;
+import com.dy.common.util.ByteUtil;
+import com.dy.common.util.ByteUtilUnsigned;
+import com.dy.common.util.DateTime;
+
+@AnnotationCodeUp(ifAny={
+ CodeV1_0_1.cd_01
+})
+public class Cd_01_Up implements CodeParse{
+
+ private static Logger log = LogManager.getLogger(Cd_01_Up.class);
+
+ /**
+ * 鍒嗘瀽涓婅鏁版嵁
+ */
+ @Override
+ public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception {
+ ParseParamsForUpV1_0_1 para = (ParseParamsForUpV1_0_1)params ;
+ int bsLen = new CommonV1_0_1().parseDataLen(para.upBuffer) ;
+ if(bsLen > 0){
+ this.doParse(para.upBuffer,
+ bsLen,
+ para.upCode,
+ para.data) ;
+ }
+ log.info("鍒嗘瀽涓婅鏁版嵁<" + CodeV1_0_1.getCodeName(para.upCode) + " 姘磋〃鍙�=" + para.meterNo + ">:\n" + para.data.toString());
+
+ MidResultFromRtu midRs = new MidResultFromRtu() ;
+ midRs.protocolName = para.protocolName ;//鍗忚鍚嶇О
+ midRs.rtuAddr = para.rtuAddr ;//IMEI鍙�
+ midRs.meterNo = para.meterNo ;//姘磋〃鍙�
+ midRs.productId = para.productId ;//鐢典俊骞冲彴浜у搧ID锛屽綋涓嶅湪鐢典俊骞冲彴杩愯鏃讹紝涓簄ull
+ midRs.deviceId = para.deviceId ;//鐢典俊骞冲彴璁惧ID锛屽綋涓嶅湪鐢典俊骞冲彴杩愯鏃讹紝涓簄ull
+ midRs.upCode = para.upCode ;//涓婅鏁版嵁涓殑鍔熻兘鐮�
+ midRs.upHex = para.upHex ;//涓婅鏁版嵁鍗佸叚杩涘埗褰㈠紡
+ midRs.upBuffer = para.upBuffer ;//涓婅鏁版嵁瀛楄妭鏁扮粍
+ midRs.data = para.data ;//瑙f瀽鍚庣殑鏁版嵁
+
+ midRs.reportOrResponse_trueOrFalse = true ;//涓诲姩涓婃姤
+
+ String confirmComCode = CodeV1_0_1.cd_01 ;
+ ParseParamsForDownV1_0_1 downCpParams = new ParseParamsForDownV1_0_1() ;
+ downCpParams.setValue(
+ ProtocolConstantV1_0_1.protocolName,
+ para.rtuAddr,
+ para.meterNo,
+ para.productId,
+ para.deviceId,
+ Command.defaultId,
+ confirmComCode,
+ null,
+ null);
+ //鏋勯�犱笂鎶ョ‘璁ゅ簲绛�
+ byte[] data = new Cd_XY_Down().doParse(downCpParams) ;
+
+ MidResultToRtu confirmCommand = new MidResultToRtu() ;
+ confirmCommand.protocolName = para.protocolName ;//鍗忚鍚嶇О
+ confirmCommand.rtuAddr = para.rtuAddr ;//IMEI鍙�
+ confirmCommand.meterNo = para.meterNo ;//姘磋〃鍙�
+ confirmCommand.productId = para.productId ;//鐢典俊骞冲彴浜у搧ID锛屽綋涓嶅湪鐢典俊骞冲彴杩愯鏃讹紝涓簄ull
+ confirmCommand.deviceId = para.deviceId ;//鐢典俊骞冲彴璁惧ID锛屽綋涓嶅湪鐢典俊骞冲彴杩愯鏃讹紝涓簄ull
+ confirmCommand.commandId = Command.defaultId ;//鍛戒护ID锛屽彂璧峰懡浠ょ殑瀹㈡埛绔�(web绔�)鐢熸垚锛屼互鍖归厤鍛戒护缁撴灉
+ confirmCommand.downCode = confirmComCode ;//涓嬭鍛戒护鍔熻兘鐮�;
+ confirmCommand.downBuffer = data ;//涓嬭鍛戒护鏁版嵁
+ confirmCommand.downBufHex = ByteUtil.bytes2Hex(data, true) ;//涓嬭鍛戒护鏁版嵁鍗佸叚杩涘埗褰㈠紡
+ confirmCommand.hasResponse = false ;//鏄惁鏈夊簲绛�
+ confirmCommand.maxSendTimes = 1 ;//鍛戒护鏈�澶у彂閫佹鏁�(褰撴敹涓嶅埌搴旂瓟鏃讹紝灏嗛噸鍙�2娆�)锛屽鏋滀笉璁剧疆锛屽懡浠ょ紦瀛樺櫒杩涜琛ュ厖璁剧疆
+ confirmCommand.isSendFirst = true ;//纭鍛戒护锛屼紭鍏堝彂閫�
+ confirmCommand.isCachForOffLine = false ;//RTU涓嶅湪绾匡紝鍛戒护鏄惁缂撳瓨
+
+ callback.callback(midRs.reportOrResponse_trueOrFalse);
+ return new MidResult[]{midRs, confirmCommand} ;
+ }
+ /**
+ * 鎵ц鍒嗘瀽
+ * @param bs
+ * @param bsLen瀛楄妭闀垮害锛堟�诲寘闀匡紝鍖呮嫭鍖呭ご鍜屽寘灏撅級
+ * @param dataCode
+ * @param index
+ * @param contentDataEndIndex
+ * @param data
+ * @throws Exception
+ */
+ protected void doParse(byte[] bs, int bsLen, String dataCode, Data data) throws Exception {
+ DataV1_0_1 dV1 = (DataV1_0_1)data.getSubData() ;
+ DataCd01Vo cdData = new DataCd01Vo() ;
+ dV1.dataCd01Vo = cdData ;
+
+ int index = ProtocolConstantV1_0_1.codeIndex + 1 ;
+
+ cdData.dt = "20" + ByteUtil.BCD2String_BE(bs, index, index++)
+ + "-" + ByteUtil.BCD2String_BE(bs, index, index++)
+ + "-" + ByteUtil.BCD2String_BE(bs, index, index++)
+ + " " + ByteUtil.BCD2String_BE(bs, index, index++)
+ + ":" + ByteUtil.BCD2String_BE(bs, index, index++)
+ + ":" + ByteUtil.BCD2String_BE(bs, index, index) ;
+ int[] ymdhms = DateTime.yyyy_MM_dd_HH_MM_SS_2_ymdhmsGroup(cdData.dt) ;
+ String yesterday = DateTime.yesterday_yyyy_MM_dd(ymdhms[0], ymdhms[1], ymdhms[2]);
+ cdData.dataDt = yesterday ;
+
+ index++ ;
+ if(!ByteUtilUnsigned.bytesIsAll0xFF(bs, index, 4)){
+ //褰揜TU瀹炴涓婃姤鏃讹紝鍥犳湭鍒濆鍖栦笂鎶ョ殑鏄� 0xFFFF
+ cdData.totalAmount = ByteUtilUnsigned.bytes2Int_BE(bs, index)/100.0f ;
+ }else{
+ cdData.totalAmount = 0.0f ;
+ }
+
+ index += 4 ;
+ if(!ByteUtilUnsigned.bytesIsAll0xFF(bs, index, 4)){
+ //褰揜TU瀹炴涓婃姤鏃讹紝鍥犳湭鍒濆鍖栦笂鎶ョ殑鏄� 0xFFFF
+ cdData.totalAmountPerDay = ByteUtilUnsigned.bytes2Int_BE(bs, index)/100.0f ;
+ }else{
+ cdData.totalAmountPerDay = 0.0f ;
+ }
+
+ index += 4 ;
+ cdData.volt = ByteUtilUnsigned.byte2Byte(bs, index)/10.0f ;
+
+ index += 1 ;
+ cdData.signal = 0.0f + ByteUtilUnsigned.bytes2Short_BE(bs, index) ;
+
+ index += 2 ;
+ byte staAlarm = bs[index] ;
+ cdData.valveSta = (byte)(staAlarm & 1) ;
+ staAlarm = (byte)(staAlarm >> 2) ;
+ cdData.alarmValve = (byte)(staAlarm & 1) ;
+ staAlarm = (byte)(staAlarm >> 1) ;
+ cdData.alarmMagnetism = (byte)(staAlarm & 1) ;
+ staAlarm = (byte)(staAlarm >> 1) ;
+ cdData.alarmVolt = (byte)(staAlarm & 1) ;
+
+ index++ ;
+ cdData.values = new ArrayList<Float>() ;
+ for(byte i = 0; (i < (byte)24 && index < (bsLen - 2)); i++){
+ if(!ByteUtilUnsigned.bytesIsAll0xFF(bs, index, 2)){
+ //褰揜TU瀹炴涓婃姤鏃讹紝鍥犳湭鍒濆鍖栦笂鎶ョ殑鏄� 0xFFFF
+ Integer v = ByteUtilUnsigned.bytes2Short_BE(bs, index) ;
+ if(v >= Integer.MAX_VALUE){
+ //鏍规嵁鍗忚锛屽綋缁堢娌℃湁璁板綍鏁版嵁锛屾暟鎹唴瀹规槸ffff ffff
+ v = 0 ;
+ }
+ cdData.values.add(v/100.0f) ;
+ }else{
+ cdData.values.add(0.0f) ;
+ }
+ index += 2 ;
+ }
+
+ cdData.gap = 60 ;//鏍规嵁褰撳墠姘磋〃瀹炵幇锛屽瘑閲囨暟鎹噰闆嗛棿闅旀槸60鍒嗛挓
+ }
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/parse/Cd_02_Up.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/parse/Cd_02_Up.java
new file mode 100644
index 0000000..4d3f5cc
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/parse/Cd_02_Up.java
@@ -0,0 +1,136 @@
+package com.dy.common.mw.protocol.pMeterV1_0_1.parse;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import com.dy.common.mw.protocol.AnnotationCodeUp;
+import com.dy.common.mw.protocol.CodeParse;
+import com.dy.common.mw.protocol.CodeParseCallback;
+import com.dy.common.mw.protocol.CodeParseParams;
+import com.dy.common.mw.protocol.Command;
+import com.dy.common.mw.protocol.Data;
+import com.dy.common.mw.protocol.MidResult;
+import com.dy.common.mw.protocol.MidResultFromRtu;
+import com.dy.common.mw.protocol.MidResultToRtu;
+import com.dy.common.mw.protocol.pMeterV1_0_1.*;
+import com.dy.common.util.ByteUtil;
+import com.dy.common.util.ByteUtilUnsigned;
+
+@AnnotationCodeUp(ifAny={
+ CodeV1_0_1.cd_02
+})
+public class Cd_02_Up implements CodeParse{
+
+ private static Logger log = LogManager.getLogger(Cd_02_Up.class);
+
+ /**
+ * 鍒嗘瀽涓婅鏁版嵁
+ */
+ @Override
+ public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception {
+ ParseParamsForUpV1_0_1 para = (ParseParamsForUpV1_0_1)params ;
+ int bsLen = new CommonV1_0_1().parseDataLen(para.upBuffer) ;
+ if(bsLen > 0){
+ this.doParse(para.upBuffer,
+ bsLen,
+ para.upCode,
+ para.data) ;
+ }
+ log.info("鍒嗘瀽涓婅鏁版嵁<" + CodeV1_0_1.getCodeName(para.upCode) + " 姘磋〃鍙�=" + para.meterNo + ">:\n" + para.data.toString());
+
+ MidResultFromRtu midRs = new MidResultFromRtu() ;
+ midRs.protocolName = para.protocolName ;//鍗忚鍚嶇О
+ midRs.rtuAddr = para.rtuAddr ;//IMEI鍙�
+ midRs.meterNo = para.meterNo ;//姘磋〃鍙�
+ midRs.productId = para.productId ;//鐢典俊骞冲彴浜у搧ID锛屽綋涓嶅湪鐢典俊骞冲彴杩愯鏃讹紝涓簄ull
+ midRs.deviceId = para.deviceId ;//鐢典俊骞冲彴璁惧ID锛屽綋涓嶅湪鐢典俊骞冲彴杩愯鏃讹紝涓簄ull
+ midRs.upCode = para.upCode ;//涓婅鏁版嵁涓殑鍔熻兘鐮�
+ midRs.upHex = para.upHex ;//涓婅鏁版嵁鍗佸叚杩涘埗褰㈠紡
+ midRs.upBuffer = para.upBuffer ;//涓婅鏁版嵁瀛楄妭鏁扮粍
+ midRs.data = para.data ;//瑙f瀽鍚庣殑鏁版嵁
+
+ midRs.reportOrResponse_trueOrFalse = true ;//涓诲姩涓婃姤
+
+ String confirmComCode = CodeV1_0_1.cd_02 ;
+ ParseParamsForDownV1_0_1 downCpParams = new ParseParamsForDownV1_0_1() ;
+ downCpParams.setValue(
+ ProtocolConstantV1_0_1.protocolName,
+ para.rtuAddr,
+ para.meterNo,
+ para.productId,
+ para.deviceId,
+ Command.defaultId,
+ confirmComCode,
+ null,
+ null);
+ //鏋勯�犱笂鎶ョ‘璁ゅ簲绛�
+ byte[] data = new Cd_XY_Down().doParse(downCpParams) ;
+
+ MidResultToRtu confirmCommand = new MidResultToRtu() ;
+ confirmCommand.protocolName = para.protocolName ;//鍗忚鍚嶇О
+ confirmCommand.rtuAddr = para.rtuAddr ;//IMEI鍙�
+ confirmCommand.meterNo = para.meterNo ;//姘磋〃鍙�
+ confirmCommand.productId = para.productId ;//鐢典俊骞冲彴浜у搧ID锛屽綋涓嶅湪鐢典俊骞冲彴杩愯鏃讹紝涓簄ull
+ confirmCommand.deviceId = para.deviceId ;//鐢典俊骞冲彴璁惧ID锛屽綋涓嶅湪鐢典俊骞冲彴杩愯鏃讹紝涓簄ull
+ confirmCommand.commandId = Command.defaultId ;//鍛戒护ID锛屽彂璧峰懡浠ょ殑瀹㈡埛绔�(web绔�)鐢熸垚锛屼互鍖归厤鍛戒护缁撴灉
+ confirmCommand.downCode = confirmComCode ;//涓嬭鍛戒护鍔熻兘鐮�;
+ confirmCommand.downBuffer = data ;//涓嬭鍛戒护鏁版嵁
+ confirmCommand.downBufHex = ByteUtil.bytes2Hex(data, true) ;//涓嬭鍛戒护鏁版嵁鍗佸叚杩涘埗褰㈠紡
+ confirmCommand.hasResponse = false ;//鏄惁鏈夊簲绛�
+ confirmCommand.maxSendTimes = 1 ;//鍛戒护鏈�澶у彂閫佹鏁�(褰撴敹涓嶅埌搴旂瓟鏃讹紝灏嗛噸鍙�2娆�)锛屽鏋滀笉璁剧疆锛屽懡浠ょ紦瀛樺櫒杩涜琛ュ厖璁剧疆
+ confirmCommand.isSendFirst = true ;//纭鍛戒护锛屼紭鍏堝彂閫�
+ confirmCommand.isCachForOffLine = false ;//RTU涓嶅湪绾匡紝鍛戒护鏄惁缂撳瓨
+
+ callback.callback(midRs.reportOrResponse_trueOrFalse);
+ return new MidResult[]{midRs, confirmCommand} ;
+ }
+ /**
+ * 鎵ц鍒嗘瀽
+ * @param bs
+ * @param bsLen瀛楄妭闀垮害锛堟�诲寘闀匡紝鍖呮嫭鍖呭ご鍜屽寘灏撅級
+ * @param dataCode
+ * @param index
+ * @param contentDataEndIndex
+ * @param data
+ * @throws Exception
+ */
+ protected void doParse(byte[] bs, int bsLen, String dataCode, Data data) throws Exception {
+ DataV1_0_1 dV1 = (DataV1_0_1)data.getSubData() ;
+ DataCd02Vo cdData = new DataCd02Vo() ;
+ dV1.dataCd02Vo = cdData ;
+
+ int index = ProtocolConstantV1_0_1.codeIndex + 1 ;
+
+ cdData.dt = "20" + ByteUtil.BCD2String_BE(bs, index, index++)
+ + "-" + ByteUtil.BCD2String_BE(bs, index, index++)
+ + "-" + ByteUtil.BCD2String_BE(bs, index, index++)
+ + " " + ByteUtil.BCD2String_BE(bs, index, index++)
+ + ":" + ByteUtil.BCD2String_BE(bs, index, index++)
+ + ":" + ByteUtil.BCD2String_BE(bs, index, index) ;
+
+ index++ ;
+ if(!ByteUtilUnsigned.bytesIsAll0xFF(bs, index, 4)){
+ //褰揜TU瀹炴涓婃姤鏃讹紝鍥犳湭鍒濆鍖栦笂鎶ョ殑瀛楄妭鏄� 0xFF
+ cdData.totalAmount = ByteUtilUnsigned.bytes2Int_BE(bs, index)/100.0f;
+ }else{
+ cdData.totalAmount = 0.0f ;
+ }
+
+ index += 4 ;
+ cdData.volt = ByteUtilUnsigned.byte2Byte(bs, index)/10.0f ;
+
+ index += 1 ;
+ cdData.signal = 0.0f + ByteUtilUnsigned.bytes2Short_BE(bs, index) ;
+
+ index += 2 ;
+ byte staAlarm = bs[index] ;
+ cdData.valveSta = (byte)(staAlarm & 1) ;
+ staAlarm = (byte)(staAlarm >> 2) ;
+ cdData.alarmValve = (byte)(staAlarm & 1) ;
+ staAlarm = (byte)(staAlarm >> 1) ;
+ cdData.alarmMagnetism = (byte)(staAlarm & 1) ;
+ staAlarm = (byte)(staAlarm >> 1) ;
+ cdData.alarmVolt = (byte)(staAlarm & 1) ;
+
+ }
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/parse/Cd_03_Up.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/parse/Cd_03_Up.java
new file mode 100644
index 0000000..0be46e9
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/parse/Cd_03_Up.java
@@ -0,0 +1,124 @@
+package com.dy.common.mw.protocol.pMeterV1_0_1.parse;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import com.dy.common.mw.protocol.AnnotationCodeUp;
+import com.dy.common.mw.protocol.CodeParse;
+import com.dy.common.mw.protocol.CodeParseCallback;
+import com.dy.common.mw.protocol.CodeParseParams;
+import com.dy.common.mw.protocol.Command;
+import com.dy.common.mw.protocol.Data;
+import com.dy.common.mw.protocol.MidResult;
+import com.dy.common.mw.protocol.MidResultFromRtu;
+import com.dy.common.mw.protocol.MidResultToRtu;
+import com.dy.common.mw.protocol.pMeterV1_0_1.*;
+import com.dy.common.util.ByteUtil;
+import com.dy.common.util.ByteUtilUnsigned;
+
+@AnnotationCodeUp(ifAny={
+ CodeV1_0_1.cd_03
+})
+public class Cd_03_Up implements CodeParse{
+
+ private static Logger log = LogManager.getLogger(Cd_03_Up.class);
+
+ /**
+ * 鍒嗘瀽涓婅鏁版嵁
+ */
+ @Override
+ public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception {
+ ParseParamsForUpV1_0_1 para = (ParseParamsForUpV1_0_1)params ;
+ int bsLen = new CommonV1_0_1().parseDataLen(para.upBuffer) ;
+ if(bsLen > 0){
+ this.doParse(para.upBuffer,
+ bsLen,
+ para.upCode,
+ para.data) ;
+ }
+ log.info("鍒嗘瀽涓婅鏁版嵁<" + CodeV1_0_1.getCodeName(para.upCode) + " 姘磋〃鍙�=" + para.meterNo + ">:\n" + para.data.toString());
+
+ MidResultFromRtu midRs = new MidResultFromRtu() ;
+ midRs.protocolName = para.protocolName ;//鍗忚鍚嶇О
+ midRs.rtuAddr = para.rtuAddr ;//IMEI鍙�
+ midRs.meterNo = para.meterNo ;//姘磋〃鍙�
+ midRs.productId = para.productId ;//鐢典俊骞冲彴浜у搧ID锛屽綋涓嶅湪鐢典俊骞冲彴杩愯鏃讹紝涓簄ull
+ midRs.deviceId = para.deviceId ;//鐢典俊骞冲彴璁惧ID锛屽綋涓嶅湪鐢典俊骞冲彴杩愯鏃讹紝涓簄ull
+ midRs.upCode = para.upCode ;//涓婅鏁版嵁涓殑鍔熻兘鐮�
+ midRs.upHex = para.upHex ;//涓婅鏁版嵁鍗佸叚杩涘埗褰㈠紡
+ midRs.upBuffer = para.upBuffer ;//涓婅鏁版嵁瀛楄妭鏁扮粍
+ midRs.data = para.data ;//瑙f瀽鍚庣殑鏁版嵁
+
+ midRs.reportOrResponse_trueOrFalse = true ;//涓诲姩涓婃姤
+
+ String confirmComCode = CodeV1_0_1.cd_03 ;
+ ParseParamsForDownV1_0_1 downCpParams = new ParseParamsForDownV1_0_1() ;
+ downCpParams.setValue(
+ ProtocolConstantV1_0_1.protocolName,
+ para.rtuAddr,
+ para.meterNo,
+ para.productId,
+ para.deviceId,
+ Command.defaultId,
+ confirmComCode,
+ null,
+ null);
+ //鏋勯�犱笂鎶ョ‘璁ゅ簲绛�
+ byte[] data = new Cd_XY_Down().doParse(downCpParams) ;
+
+ MidResultToRtu confirmCommand = new MidResultToRtu() ;
+ confirmCommand.protocolName = para.protocolName ;//鍗忚鍚嶇О
+ confirmCommand.rtuAddr = para.rtuAddr ;//IMEI鍙�
+ confirmCommand.meterNo = para.meterNo ;//姘磋〃鍙�
+ confirmCommand.productId = para.productId ;//鐢典俊骞冲彴浜у搧ID锛屽綋涓嶅湪鐢典俊骞冲彴杩愯鏃讹紝涓簄ull
+ confirmCommand.deviceId = para.deviceId ;//鐢典俊骞冲彴璁惧ID锛屽綋涓嶅湪鐢典俊骞冲彴杩愯鏃讹紝涓簄ull
+ confirmCommand.commandId = Command.defaultId ;//鍛戒护ID锛屽彂璧峰懡浠ょ殑瀹㈡埛绔�(web绔�)鐢熸垚锛屼互鍖归厤鍛戒护缁撴灉
+ confirmCommand.downCode = confirmComCode ;//涓嬭鍛戒护鍔熻兘鐮�;
+ confirmCommand.downBuffer = data ;//涓嬭鍛戒护鏁版嵁
+ confirmCommand.downBufHex = ByteUtil.bytes2Hex(data, true) ;//涓嬭鍛戒护鏁版嵁鍗佸叚杩涘埗褰㈠紡
+ confirmCommand.hasResponse = false ;//鏄惁鏈夊簲绛�
+ confirmCommand.maxSendTimes = 1 ;//鍛戒护鏈�澶у彂閫佹鏁�(褰撴敹涓嶅埌搴旂瓟鏃讹紝灏嗛噸鍙�2娆�)锛屽鏋滀笉璁剧疆锛屽懡浠ょ紦瀛樺櫒杩涜琛ュ厖璁剧疆
+ confirmCommand.isSendFirst = true ;//纭鍛戒护锛屼紭鍏堝彂閫�
+ confirmCommand.isCachForOffLine = false ;//RTU涓嶅湪绾匡紝鍛戒护鏄惁缂撳瓨
+
+ callback.callback(midRs.reportOrResponse_trueOrFalse);
+ return new MidResult[]{midRs, confirmCommand} ;
+ }
+ /**
+ * 鎵ц鍒嗘瀽
+ * @param bs
+ * @param bsLen瀛楄妭闀垮害锛堟�诲寘闀匡紝鍖呮嫭鍖呭ご鍜屽寘灏撅級
+ * @param dataCode
+ * @param index
+ * @param contentDataEndIndex
+ * @param data
+ * @throws Exception
+ */
+ protected void doParse(byte[] bs, int bsLen, String dataCode, Data data) throws Exception {
+ DataV1_0_1 dV1 = (DataV1_0_1)data.getSubData() ;
+ DataCd03Vo cdData = new DataCd03Vo() ;
+ dV1.dataCd03Vo = cdData ;
+
+ int index = ProtocolConstantV1_0_1.codeIndex + 1 ;
+
+ cdData.dt = "20" + ByteUtil.BCD2String_BE(bs, index, index++)
+ + "-" + ByteUtil.BCD2String_BE(bs, index, index++)
+ + "-" + ByteUtil.BCD2String_BE(bs, index, index++)
+ + " " + ByteUtil.BCD2String_BE(bs, index, index++)
+ + ":" + ByteUtil.BCD2String_BE(bs, index, index++)
+ + ":" + ByteUtil.BCD2String_BE(bs, index, index) ;
+
+ index++ ;
+ cdData.volt = ByteUtilUnsigned.bytes2Short_BE(bs, index)/10.0f ;
+
+ index++ ;
+ byte staAlarm = bs[index] ;
+ cdData.valveSta = (byte)(staAlarm & 1) ;
+ staAlarm = (byte)(staAlarm >> 2) ;
+ cdData.alarmValve = (byte)(staAlarm & 1) ;
+ staAlarm = (byte)(staAlarm >> 1) ;
+ cdData.alarmMagnetism = (byte)(staAlarm & 1) ;
+ staAlarm = (byte)(staAlarm >> 1) ;
+ cdData.alarmVolt = (byte)(staAlarm & 1) ;
+ }
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/parse/Cd_0405_Up.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/parse/Cd_0405_Up.java
new file mode 100644
index 0000000..f9433e2
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/parse/Cd_0405_Up.java
@@ -0,0 +1,88 @@
+package com.dy.common.mw.protocol.pMeterV1_0_1.parse;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import com.dy.common.mw.protocol.AnnotationCodeUp;
+import com.dy.common.mw.protocol.CodeParse;
+import com.dy.common.mw.protocol.CodeParseCallback;
+import com.dy.common.mw.protocol.CodeParseParams;
+import com.dy.common.mw.protocol.Data;
+import com.dy.common.mw.protocol.MidResult;
+import com.dy.common.mw.protocol.MidResultFromRtu;
+import com.dy.common.mw.protocol.pMeterV1_0_1.*;
+import com.dy.common.util.ByteUtil;
+
+@AnnotationCodeUp(ifAny={
+ CodeV1_0_1.cd_04,
+ CodeV1_0_1.cd_05
+})
+public class Cd_0405_Up implements CodeParse{
+
+ private static Logger log = LogManager.getLogger(Cd_0405_Up.class);
+
+ /**
+ * 鍒嗘瀽涓婅鏁版嵁
+ */
+ @Override
+ public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception {
+ ParseParamsForUpV1_0_1 para = (ParseParamsForUpV1_0_1)params ;
+ int bsLen = new CommonV1_0_1().parseDataLen(para.upBuffer) ;
+ if(bsLen > 0){
+ this.doParse(para.upBuffer,
+ bsLen,
+ para.upCode,
+ para.data) ;
+ }
+ log.info("鍒嗘瀽涓婅鏁版嵁<" + CodeV1_0_1.getCodeName(para.upCode) + " 姘磋〃鍙�=" + para.meterNo + ">:\n" + para.data.toString());
+
+ MidResultFromRtu midRs = new MidResultFromRtu() ;
+ midRs.protocolName = para.protocolName ;//鍗忚鍚嶇О
+ midRs.rtuAddr = para.rtuAddr ;//IMEI鍙�
+ midRs.meterNo = para.meterNo ;//姘磋〃鍙�
+ midRs.productId = para.productId ;//鐢典俊骞冲彴浜у搧ID锛屽綋涓嶅湪鐢典俊骞冲彴杩愯鏃讹紝涓簄ull
+ midRs.deviceId = para.deviceId ;//鐢典俊骞冲彴璁惧ID锛屽綋涓嶅湪鐢典俊骞冲彴杩愯鏃讹紝涓簄ull
+ midRs.upCode = para.upCode ;//涓婅鏁版嵁涓殑鍔熻兘鐮�
+ midRs.upHex = para.upHex ;//涓婅鏁版嵁鍗佸叚杩涘埗褰㈠紡
+ midRs.upBuffer = para.upBuffer ;//涓婅鏁版嵁瀛楄妭鏁扮粍
+ midRs.data = para.data ;//瑙f瀽鍚庣殑鏁版嵁
+
+ midRs.reportOrResponse_trueOrFalse = false ;//鍛戒护鍥炴壂
+
+ callback.callback(midRs.reportOrResponse_trueOrFalse);
+ return new MidResult[]{midRs} ;
+ }
+ /**
+ * 鎵ц鍒嗘瀽
+ * @param bs
+ * @param bsLen瀛楄妭闀垮害锛堟�诲寘闀匡紝鍖呮嫭鍖呭ご鍜屽寘灏撅級
+ * @param dataCode
+ * @param index
+ * @param contentDataEndIndex
+ * @param data
+ * @throws Exception
+ */
+ protected void doParse(byte[] bs, int bsLen, String dataCode, Data data) throws Exception {
+ DataV1_0_1 dV1 = (DataV1_0_1)data.getSubData() ;
+ DataCd0405Vo cdData = new DataCd0405Vo() ;
+ dV1.dataCd0405Vo = cdData ;
+
+ if(dataCode.equals(CodeV1_0_1.cd_04)){
+ cdData.open1_close2 = 1 ;
+ } else if(dataCode.equals(CodeV1_0_1.cd_05)){
+ cdData.open1_close2 = 2 ;
+ }
+
+ int index = ProtocolConstantV1_0_1.codeIndex + 1 ;
+ cdData.dt = "20" + ByteUtil.BCD2String_BE(bs, index, index++)
+ + "-" + ByteUtil.BCD2String_BE(bs, index, index++)
+ + "-" + ByteUtil.BCD2String_BE(bs, index, index++)
+ + " " + ByteUtil.BCD2String_BE(bs, index, index++)
+ + ":" + ByteUtil.BCD2String_BE(bs, index, index++)
+ + ":" + ByteUtil.BCD2String_BE(bs, index, index) ;
+
+ index ++ ;
+ cdData.state = bs[index] ;
+
+ }
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/parse/Cd_06_Down.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/parse/Cd_06_Down.java
new file mode 100644
index 0000000..1bcee3e
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/parse/Cd_06_Down.java
@@ -0,0 +1,117 @@
+package com.dy.common.mw.protocol.pMeterV1_0_1.parse;
+
+import com.dy.common.mw.protocol.AnnotationCodeDown;
+import com.dy.common.mw.protocol.CodeParse;
+import com.dy.common.mw.protocol.CodeParseCallback;
+import com.dy.common.mw.protocol.CodeParseParams;
+import com.dy.common.mw.protocol.MidResult;
+import com.dy.common.mw.protocol.MidResultToRtu;
+import com.dy.common.mw.protocol.pMeterV1_0_1.*;
+import com.dy.common.util.ByteUtil;
+import com.dy.common.util.ByteUtilUnsigned;
+import com.dy.common.util.DateTime;
+
+@AnnotationCodeDown(ifAny={
+ CodeV1_0_1.cd_06
+})
+public class Cd_06_Down implements CodeParse{
+
+ //private static Logger log = LogManager.getLogger(Cd_XY_Down.class);
+
+ @Override
+ public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback) throws Exception {
+ ParseParamsForDownV1_0_1 para = (ParseParamsForDownV1_0_1) params ;
+ byte[] bs = this.doParse(para) ;
+
+ MidResultToRtu midRs = new MidResultToRtu() ;
+ midRs.protocolName = para.protocolName ;//鍗忚鍚嶇О
+ midRs.rtuAddr = para.rtuAddr ;//IMEI鍙凤紙鐢典俊骞冲彴璁惧IMEI锛�
+ midRs.meterNo = para.meterNo ;//姘磋〃鍙�
+ midRs.productId = para.productId ;//鐢典俊骞冲彴浜у搧ID锛屽綋涓嶅湪鐢典俊骞冲彴杩愯鏃讹紝涓簄ull
+ midRs.deviceId = para.deviceId ;//鐢典俊骞冲彴璁惧ID锛屽綋涓嶅湪鐢典俊骞冲彴杩愯鏃讹紝涓簄ull
+ midRs.commandId = para.commandId ;//鍛戒护ID锛屽彂璧峰懡浠ょ殑瀹㈡埛绔�(web绔�)鐢熸垚锛屼互鍖归厤鍛戒护缁撴灉
+ midRs.downCode = para.commandCode ;//涓嬭鍛戒护鍔熻兘鐮�;
+ midRs.downBuffer = bs ;//涓嬭鍛戒护鏁版嵁
+ midRs.downBufHex = ByteUtil.bytes2Hex(bs, true) ;//涓嬭鍛戒护鏁版嵁鍗佸叚杩涘埗褰㈠紡
+ midRs.hasResponse = true ;//鏄惁鏈夊簲绛�
+ midRs.maxSendTimes = null ;//鍛戒护鏈�澶у彂閫佹鏁�(褰撴敹涓嶅埌搴旂瓟鏃讹紝灏嗛噸鍙�)锛屽鏋滀笉璁剧疆锛屽懡浠ょ紦瀛樺櫒杩涜琛ュ厖璁剧疆
+ midRs.isCachForOffLine = true ;//RTU涓嶅湪绾匡紝鍛戒护鏄惁缂撳瓨锛屼綆鍔熻�楁椂涓簍rue
+
+ //瀵筊TU涓婅鏁版嵁鐨勫簲绛�
+ midRs.hasResponse = false ;//鏄惁鏈夊簲绛�
+ midRs.maxSendTimes = 1 ;//瀵筊TU涓婅鏁版嵁搴旂瓟锛屾墍浠ュ彧闇�鍙戜竴娆�
+ if(isLowPower != null && isLowPower.booleanValue()){
+ //浣庡姛鑰楁椂
+ midRs.isQuickSend = true ;
+ }
+
+ return new MidResult[]{midRs} ;
+ }
+ /**
+ * 鏋勯�犱笅琛屾暟鎹�
+ * @param params
+ * @return
+ * @throws Exception
+ */
+ public byte[] doParse(ParseParamsForDownV1_0_1 para) throws Exception {
+ byte[] bytes = null ;
+ byte[] bsHead = new byte[ProtocolConstantV1_0_1.downBsHeadLen] ;
+ byte index = 0 ;
+ bsHead[index] = ProtocolConstantV1_0_1.P_Head_Byte ;
+ index++ ;
+ bsHead[index] = 0 ;//甯ч暱搴�
+ index++ ;
+ bsHead[index] = 0 ;//甯ч暱搴�
+
+ index++ ;
+ bsHead[index] = ProtocolConstantV1_0_1.versionByte ;//鍗忚鐗堟湰鍙�
+ index++ ;
+
+ String rtuAddr = para.rtuAddr ;
+ while(true){
+ if(rtuAddr.length() >= 16){
+ break ;
+ }else{
+ rtuAddr = "0" + rtuAddr ;
+ }
+ }
+
+ ByteUtil.string2BCD_BE(bsHead, rtuAddr, index) ;//IMEI鍙�
+ index += 8 ;
+ String meterNo = para.meterNo ;
+ while(true){
+ if(meterNo.length() >= 16){
+ break ;
+ }else{
+ meterNo = "0" + meterNo ;
+ }
+ }
+ ByteUtil.string2BCD_BE(bsHead, meterNo, index) ;//姘磋〃鍙�
+ index += 8 ;
+
+ ByteUtil.hex2Bytes(para.commandCode, bsHead, index) ;
+
+ byte[] bs = new byte[7] ;
+ bs[0] = ((Byte)para.param).byteValue();//闃�闂ㄥ姩浣滅粨鏋滃洖浼�
+ ByteUtil.string2BCD_BE(bs, DateTime.yyMMddhhmmss(), 1) ;
+
+ bytes = ByteUtil.bytesMerge(bsHead, bs) ;
+
+ int len = bytes.length + ProtocolConstantV1_0_1.downBsTailLen ;
+ ByteUtilUnsigned.short2Bytes_BE(bytes, len, ProtocolConstantV1_0_1.dataLenIndex_start);
+
+
+ byte he = 0 ;
+ for(int i = 0 ; i < bytes.length; i++){
+ he += bytes[i] ;
+ }
+
+ bs = new byte[ProtocolConstantV1_0_1.downBsTailLen] ;
+ ByteUtilUnsigned.byte2Byte(bs, he, 0) ;
+ bs[1] = ProtocolConstantV1_0_1.P_Tail_Byte ;
+ bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+ return bytes ;
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/parse/Cd_06_Up.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/parse/Cd_06_Up.java
new file mode 100644
index 0000000..5cd2f7d
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/parse/Cd_06_Up.java
@@ -0,0 +1,120 @@
+package com.dy.common.mw.protocol.pMeterV1_0_1.parse;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import com.dy.common.mw.protocol.AnnotationCodeUp;
+import com.dy.common.mw.protocol.CodeParse;
+import com.dy.common.mw.protocol.CodeParseCallback;
+import com.dy.common.mw.protocol.CodeParseParams;
+import com.dy.common.mw.protocol.Command;
+import com.dy.common.mw.protocol.Data;
+import com.dy.common.mw.protocol.MidResult;
+import com.dy.common.mw.protocol.MidResultFromRtu;
+import com.dy.common.mw.protocol.MidResultToRtu;
+import com.dy.common.mw.protocol.pMeterV1_0_1.*;
+import com.dy.common.util.ByteUtil;
+
+@AnnotationCodeUp(ifAny={
+ CodeV1_0_1.cd_06
+})
+public class Cd_06_Up implements CodeParse{
+
+ private static Logger log = LogManager.getLogger(Cd_06_Up.class);
+
+ /**
+ * 鍒嗘瀽涓婅鏁版嵁
+ */
+ @Override
+ public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception {
+ ParseParamsForUpV1_0_1 para = (ParseParamsForUpV1_0_1)params ;
+ int bsLen = new CommonV1_0_1().parseDataLen(para.upBuffer) ;
+ if(bsLen > 0){
+ this.doParse(para.upBuffer,
+ bsLen,
+ para.upCode,
+ para.data) ;
+ }
+ log.info("鍒嗘瀽涓婅鏁版嵁<" + CodeV1_0_1.getCodeName(para.upCode) + " 姘磋〃鍙�=" + para.meterNo + ">:\n" + para.data.toString());
+
+ MidResultFromRtu midRs = new MidResultFromRtu() ;
+ midRs.protocolName = para.protocolName ;//鍗忚鍚嶇О
+ midRs.rtuAddr = para.rtuAddr ;//IMEI鍙�
+ midRs.meterNo = para.meterNo ;//姘磋〃鍙�
+ midRs.productId = para.productId ;//鐢典俊骞冲彴浜у搧ID锛屽綋涓嶅湪鐢典俊骞冲彴杩愯鏃讹紝涓簄ull
+ midRs.deviceId = para.deviceId ;//鐢典俊骞冲彴璁惧ID锛屽綋涓嶅湪鐢典俊骞冲彴杩愯鏃讹紝涓簄ull
+ midRs.upCode = para.upCode ;//涓婅鏁版嵁涓殑鍔熻兘鐮�
+ midRs.upHex = para.upHex ;//涓婅鏁版嵁鍗佸叚杩涘埗褰㈠紡
+ midRs.upBuffer = para.upBuffer ;//涓婅鏁版嵁瀛楄妭鏁扮粍
+ midRs.data = para.data ;//瑙f瀽鍚庣殑鏁版嵁
+
+ midRs.reportOrResponse_trueOrFalse = true ;//涓诲姩涓婃姤
+
+ String confirmComCode = CodeV1_0_1.cd_06 ;
+ ParseParamsForDownV1_0_1 downCpParams = new ParseParamsForDownV1_0_1() ;
+ downCpParams.setValue(
+ ProtocolConstantV1_0_1.protocolName,
+ para.rtuAddr,
+ para.meterNo,
+ para.productId,
+ para.deviceId,
+ Command.defaultId,
+ confirmComCode,
+ ((DataV1_0_1)para.data.getSubData()).dataCd06Vo.valveRes,
+ null);
+ //鏋勯�犱笂鎶ョ‘璁ゅ簲绛�
+ byte[] data = new Cd_06_Down().doParse(downCpParams) ;
+
+ MidResultToRtu confirmCommand = new MidResultToRtu() ;
+ confirmCommand.protocolName = para.protocolName ;//鍗忚鍚嶇О
+ confirmCommand.rtuAddr = para.rtuAddr ;//IMEI鍙�
+ confirmCommand.meterNo = para.meterNo ;//姘磋〃鍙�
+ confirmCommand.productId = para.productId ;//鐢典俊骞冲彴浜у搧ID锛屽綋涓嶅湪鐢典俊骞冲彴杩愯鏃讹紝涓簄ull
+ confirmCommand.deviceId = para.deviceId ;//鐢典俊骞冲彴璁惧ID锛屽綋涓嶅湪鐢典俊骞冲彴杩愯鏃讹紝涓簄ull
+ confirmCommand.commandId = Command.defaultId ;//鍛戒护ID锛屽彂璧峰懡浠ょ殑瀹㈡埛绔�(web绔�)鐢熸垚锛屼互鍖归厤鍛戒护缁撴灉
+ confirmCommand.downCode = confirmComCode ;//涓嬭鍛戒护鍔熻兘鐮�;
+ confirmCommand.downBuffer = data ;//涓嬭鍛戒护鏁版嵁
+ confirmCommand.downBufHex = ByteUtil.bytes2Hex(data, true) ;//涓嬭鍛戒护鏁版嵁鍗佸叚杩涘埗褰㈠紡
+ confirmCommand.hasResponse = false ;//鏄惁鏈夊簲绛�
+ confirmCommand.maxSendTimes = 1 ;//鍛戒护鏈�澶у彂閫佹鏁�(褰撴敹涓嶅埌搴旂瓟鏃讹紝灏嗛噸鍙�2娆�)锛屽鏋滀笉璁剧疆锛屽懡浠ょ紦瀛樺櫒杩涜琛ュ厖璁剧疆
+ confirmCommand.isSendFirst = true ;//纭鍛戒护锛屼紭鍏堝彂閫�
+ confirmCommand.isCachForOffLine = false ;//RTU涓嶅湪绾匡紝鍛戒护鏄惁缂撳瓨
+
+ callback.callback(midRs.reportOrResponse_trueOrFalse);
+ return new MidResult[]{midRs, confirmCommand} ;
+ }
+ /**
+ * 鎵ц鍒嗘瀽
+ * @param bs
+ * @param bsLen瀛楄妭闀垮害锛堟�诲寘闀匡紝鍖呮嫭鍖呭ご鍜屽寘灏撅級
+ * @param dataCode
+ * @param index
+ * @param contentDataEndIndex
+ * @param data
+ * @throws Exception
+ */
+ protected void doParse(byte[] bs, int bsLen, String dataCode, Data data) throws Exception {
+ DataV1_0_1 dV1 = (DataV1_0_1)data.getSubData() ;
+ DataCd06Vo cdData = new DataCd06Vo() ;
+ dV1.dataCd06Vo = cdData ;
+
+ int index = ProtocolConstantV1_0_1.codeIndex + 1 ;
+ cdData.valveRes = bs[index] ;
+
+ /* 浜轰负璁剧疆鎶ヨ鐘舵�佽繘琛屾祴璇�
+ if(cdData.valveRes == 0){
+ cdData.valveRes = 2 ;
+ }else if(cdData.valveRes == 1){
+ cdData.valveRes = 3 ;
+ }
+ */
+
+ index++ ;
+ cdData.dt = "20" + ByteUtil.BCD2String_BE(bs, index, index++)
+ + "-" + ByteUtil.BCD2String_BE(bs, index, index++)
+ + "-" + ByteUtil.BCD2String_BE(bs, index, index++)
+ + " " + ByteUtil.BCD2String_BE(bs, index, index++)
+ + ":" + ByteUtil.BCD2String_BE(bs, index, index++)
+ + ":" + ByteUtil.BCD2String_BE(bs, index, index) ;
+ }
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/parse/Cd_XY_Down.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/parse/Cd_XY_Down.java
new file mode 100644
index 0000000..118bf27
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/parse/Cd_XY_Down.java
@@ -0,0 +1,126 @@
+package com.dy.common.mw.protocol.pMeterV1_0_1.parse;
+
+import com.dy.common.mw.protocol.AnnotationCodeDown;
+import com.dy.common.mw.protocol.CodeParse;
+import com.dy.common.mw.protocol.CodeParseCallback;
+import com.dy.common.mw.protocol.CodeParseParams;
+import com.dy.common.mw.protocol.MidResult;
+import com.dy.common.mw.protocol.MidResultToRtu;
+import com.dy.common.mw.protocol.pMeterV1_0_1.*;
+import com.dy.common.util.ByteUtil;
+import com.dy.common.util.ByteUtilUnsigned;
+import com.dy.common.util.DateTime;
+
+@AnnotationCodeDown(ifAny={
+ CodeV1_0_1.cd_01,
+ CodeV1_0_1.cd_02,
+ CodeV1_0_1.cd_03,
+ CodeV1_0_1.cd_04,
+ CodeV1_0_1.cd_05
+})
+public class Cd_XY_Down implements CodeParse{
+
+ //private static Logger log = LogManager.getLogger(Cd_XY_Down.class);
+
+ @Override
+ public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback) throws Exception {
+ ParseParamsForDownV1_0_1 para = (ParseParamsForDownV1_0_1) params ;
+ byte[] bs = this.doParse(para) ;
+
+ MidResultToRtu midRs = new MidResultToRtu() ;
+ midRs.protocolName = para.protocolName ;//鍗忚鍚嶇О
+ midRs.rtuAddr = para.rtuAddr ;//IMEI鍙凤紙鐢典俊骞冲彴璁惧IMEI锛�
+ midRs.meterNo = para.meterNo ;//姘磋〃鍙�
+ midRs.productId = para.productId ;//鐢典俊骞冲彴浜у搧ID锛屽綋涓嶅湪鐢典俊骞冲彴杩愯鏃讹紝涓簄ull
+ midRs.deviceId = para.deviceId ;//鐢典俊骞冲彴璁惧ID锛屽綋涓嶅湪鐢典俊骞冲彴杩愯鏃讹紝涓簄ull
+ midRs.commandId = para.commandId ;//鍛戒护ID锛屽彂璧峰懡浠ょ殑瀹㈡埛绔�(web绔�)鐢熸垚锛屼互鍖归厤鍛戒护缁撴灉
+ midRs.downCode = para.commandCode ;//涓嬭鍛戒护鍔熻兘鐮�;
+ midRs.downBuffer = bs ;//涓嬭鍛戒护鏁版嵁
+ midRs.downBufHex = ByteUtil.bytes2Hex(bs, true) ;//涓嬭鍛戒护鏁版嵁鍗佸叚杩涘埗褰㈠紡
+ midRs.hasResponse = true ;//鏄惁鏈夊簲绛�
+ midRs.maxSendTimes = null ;//鍛戒护鏈�澶у彂閫佹鏁�(褰撴敹涓嶅埌搴旂瓟鏃讹紝灏嗛噸鍙�)锛屽鏋滀笉璁剧疆锛屽懡浠ょ紦瀛樺櫒杩涜琛ュ厖璁剧疆
+ midRs.isCachForOffLine = true ;//RTU涓嶅湪绾匡紝鍛戒护鏄惁缂撳瓨锛屼綆鍔熻�楁椂涓簍rue
+
+ if(para.commandCode != null && (
+ para.commandCode.equals(CodeV1_0_1.cd_01) ||
+ para.commandCode.equals(CodeV1_0_1.cd_02) ||
+ para.commandCode.equals(CodeV1_0_1.cd_03)
+ )){
+ //瀵筊TU涓婅鏁版嵁鐨勫簲绛�
+ midRs.hasResponse = false ;//鏄惁鏈夊簲绛�
+ midRs.maxSendTimes = 1 ;//瀵筊TU涓婅鏁版嵁搴旂瓟锛屾墍浠ュ彧闇�鍙戜竴娆�
+ if(isLowPower != null && isLowPower.booleanValue()){
+ //浣庡姛鑰楁椂
+ midRs.isQuickSend = true ;
+ }
+ }
+
+ return new MidResult[]{midRs} ;
+ }
+ /**
+ * 鏋勯�犱笅琛屾暟鎹�
+ * @param params
+ * @return
+ * @throws Exception
+ */
+ public byte[] doParse(ParseParamsForDownV1_0_1 para) throws Exception {
+ byte[] bytes = null ;
+ byte[] bsHead = new byte[ProtocolConstantV1_0_1.downBsHeadLen] ;
+ byte index = 0 ;
+ bsHead[index] = ProtocolConstantV1_0_1.P_Head_Byte ;
+ index++ ;
+ bsHead[index] = 0 ;//甯ч暱搴�
+ index++ ;
+ bsHead[index] = 0 ;//甯ч暱搴�
+
+ index++ ;
+ bsHead[index] = ProtocolConstantV1_0_1.versionByte ;//鍗忚鐗堟湰鍙�
+ index++ ;
+
+ String rtuAddr = para.rtuAddr ;
+ while(true){
+ if(rtuAddr.length() >= 16){
+ break ;
+ }else{
+ rtuAddr = "0" + rtuAddr ;
+ }
+ }
+
+ ByteUtil.string2BCD_BE(bsHead, rtuAddr, index) ;//IMEI鍙�
+ index += 8 ;
+ String meterNo = para.meterNo ;
+ while(true){
+ if(meterNo.length() >= 16){
+ break ;
+ }else{
+ meterNo = "0" + meterNo ;
+ }
+ }
+ ByteUtil.string2BCD_BE(bsHead, meterNo, index) ;//姘磋〃鍙�
+ index += 8 ;
+
+ ByteUtil.hex2Bytes(para.commandCode, bsHead, index) ;
+
+ byte[] bs = new byte[6] ;
+ ByteUtil.string2BCD_BE(bs, DateTime.yyMMddhhmmss(), 0) ;
+
+ bytes = ByteUtil.bytesMerge(bsHead, bs) ;
+
+ int len = bytes.length + ProtocolConstantV1_0_1.downBsTailLen ;
+ ByteUtilUnsigned.short2Bytes_BE(bytes, len, ProtocolConstantV1_0_1.dataLenIndex_start);
+
+
+ byte he = 0 ;
+ for(int i = 0 ; i < bytes.length; i++){
+ he += bytes[i] ;
+ }
+
+ bs = new byte[ProtocolConstantV1_0_1.downBsTailLen] ;
+ ByteUtilUnsigned.byte2Byte(bs, he, 0) ;
+ bs[1] = ProtocolConstantV1_0_1.P_Tail_Byte ;
+ bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+ return bytes ;
+ }
+
+}
diff --git "a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/\350\257\264\346\230\216.txt" "b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/\350\257\264\346\230\216.txt"
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ "b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/\350\257\264\346\230\216.txt"
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/rtuStatus/RtuStatuz.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/rtuStatus/RtuStatuz.java
new file mode 100644
index 0000000..89a5057
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/rtuStatus/RtuStatuz.java
@@ -0,0 +1,10 @@
+package com.dy.common.mw.protocol.rtuStatus;
+
+//鐢ㄧ被鍚峈tuStatuz鑰屼笉鏄疪tuStatus,鍥犱负涓巆om.dy.dataMw.protocol.local.RtuStatus鍐茬獊
+public class RtuStatuz implements java.io.Serializable{
+
+ private static final long serialVersionUID = 201606281038001L;
+
+ public String rtuAddr ;
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/rtuStatus/StCommandResult.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/rtuStatus/StCommandResult.java
new file mode 100644
index 0000000..3a953d4
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/rtuStatus/StCommandResult.java
@@ -0,0 +1,10 @@
+package com.dy.common.mw.protocol.rtuStatus;
+
+public class StCommandResult extends RtuStatuz {
+
+ private static final long serialVersionUID = 201606281038002L;
+
+ public Boolean isSuccess ;
+ public Boolean fail2Success ;
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/rtuStatus/StDownData.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/rtuStatus/StDownData.java
new file mode 100644
index 0000000..584e7b0
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/rtuStatus/StDownData.java
@@ -0,0 +1,8 @@
+package com.dy.common.mw.protocol.rtuStatus;
+
+public class StDownData extends RtuStatuz {
+
+ private static final long serialVersionUID = 201606281038003L;
+
+ public Integer downBufferLen ;
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/rtuStatus/StOnOffLine.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/rtuStatus/StOnOffLine.java
new file mode 100644
index 0000000..17cdd35
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/rtuStatus/StOnOffLine.java
@@ -0,0 +1,11 @@
+package com.dy.common.mw.protocol.rtuStatus;
+
+public class StOnOffLine extends RtuStatuz {
+
+ private static final long serialVersionUID = 201606281038004L;
+
+ public Boolean onOff_trueFalse ;
+ public String ip ;
+ public Integer port ;
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/rtuStatus/StPumpStatus.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/rtuStatus/StPumpStatus.java
new file mode 100644
index 0000000..d02bab3
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/rtuStatus/StPumpStatus.java
@@ -0,0 +1,9 @@
+package com.dy.common.mw.protocol.rtuStatus;
+
+public class StPumpStatus extends RtuStatuz {
+
+ private static final long serialVersionUID = 201706241034001L;
+
+ public Integer pumpStatus ;//0锛氭车鍚姩浜嗭紝1娉靛仠姝紝null鏈煡鎬�
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/rtuStatus/StUpData.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/rtuStatus/StUpData.java
new file mode 100644
index 0000000..2c042e1
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/rtuStatus/StUpData.java
@@ -0,0 +1,10 @@
+package com.dy.common.mw.protocol.rtuStatus;
+
+public class StUpData extends RtuStatuz {
+
+ private static final long serialVersionUID = 201606281038005L;
+
+ public Integer upBufferLen ;
+
+ public boolean isReport ;
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/support/SupportUnit.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/support/SupportUnit.java
new file mode 100644
index 0000000..ea7216e
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/support/SupportUnit.java
@@ -0,0 +1,112 @@
+package com.dy.common.mw.support;
+
+
+import com.dy.common.threadPool.TreadPoolFactory;
+import com.dy.common.mw.UnitAdapterInterface;
+import com.dy.common.mw.UnitInterface;
+import com.dy.common.mw.UnitStartedCallbackInterface;
+
+public class SupportUnit implements UnitInterface {
+
+ private final static SupportUnit instance = new SupportUnit() ;
+ private static boolean started = false ;
+
+ private SupportUnitAdapter adapter ;
+
+ private SupportUnitConfigVo confVo ;
+
+
+ private SupportUnit(){}
+
+ public static SupportUnit getInstance(){
+ return instance ;
+ }
+
+ @Override
+ public void setAdapter(UnitAdapterInterface adapter) throws Exception {
+ if(adapter == null){
+ throw new Exception("鏀寔妯″潡閫傞厤鍣ㄥ璞′笉鑳戒负绌猴紒") ;
+ }
+
+ this.adapter = (SupportUnitAdapter)adapter ;
+ this.confVo = this.adapter.getConfig() ;
+ if(this.confVo == null){
+ throw new Exception("鏀寔妯″潡閰嶇疆瀵硅薄涓嶈兘涓虹┖锛�") ;
+ }
+ }
+
+ @Override
+ public void start(UnitStartedCallbackInterface callback) throws Exception {
+ if(!started){
+ started = true ;
+ if(confVo.enableThreadPool){
+ TreadPoolFactory.initThreadPoolShort("鐭换鍔″伐浣滅嚎绋嬫睜",
+ this.confVo.short_maxThread,
+ this.confVo.short_minThread,
+ this.confVo.short_freeTimeout,
+ this.confVo.short_busyTimeout);
+ TreadPoolFactory.initThreadPoolLong("闀夸换鍔″伐浣滅嚎绋嬫睜",
+ this.confVo.long_maxThread,
+ this.confVo.long_minThread,
+ this.confVo.long_freeTimeout,
+ this.confVo.long_busyTimeout);
+
+ if(this.confVo.showStartInfo){
+ System.out.println("绾跨▼姹犳ā鍧楁垚鍔熷惎鍔�");
+ }
+ }
+ callback.call(null);
+ }
+ }
+
+ @Override
+ public void stop(UnitStartedCallbackInterface callback) throws Exception {
+ }
+
+
+ public static void main(String[] args) throws Exception{
+ SupportUnitConfigVo supVo = new SupportUnitConfigVo() ;
+ //鐭伐浣滄椂闀跨嚎绋嬫睜锛岀嚎绋嬭礋璐g敤鏃惰緝鐭殑宸ヤ綔浠诲姟
+ supVo.short_maxThread = 100 ;
+ supVo.short_freeTimeout = 5 ;
+ supVo.short_busyTimeout = 60 ;
+ //闀垮伐浣滄椂闀跨嚎绋嬫睜锛岀嚎绋嬭礋璐g敤鏃惰緝闀跨殑宸ヤ綔浠诲姟
+ supVo.long_maxThread = 200 ;
+ if(supVo.long_maxThread < 0){
+ supVo.long_maxThread = -1 ;
+ }
+ supVo.long_minThread = 0 ;
+ supVo.long_freeTimeout = 60 ;
+ supVo.long_busyTimeout = -1 ;
+ if(supVo.long_busyTimeout < 0){
+ supVo.long_busyTimeout = -1 ;
+ }
+
+ supVo.enableThreadPool = true ;
+
+ supVo.showStartInfo = true ;
+
+ SupportUnit supUnit = SupportUnit.getInstance() ;
+
+ AdapterImp_SupportUnit supAdap = new AdapterImp_SupportUnit();
+ supAdap.setConfig(supVo);
+ supUnit.setAdapter(supAdap);
+ supUnit.start(obj -> {
+ });
+ }
+ private static class AdapterImp_SupportUnit implements SupportUnitAdapter {
+
+ private SupportUnitConfigVo configVo = null ;
+
+ @Override
+ public SupportUnitConfigVo getConfig() {
+ return this.configVo;
+ }
+
+ public void setConfig(SupportUnitConfigVo configVo) {
+ this.configVo = configVo;
+ }
+
+
+ }
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/support/SupportUnitAdapter.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/support/SupportUnitAdapter.java
new file mode 100644
index 0000000..ba0e4fe
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/support/SupportUnitAdapter.java
@@ -0,0 +1,8 @@
+package com.dy.common.mw.support;
+
+import com.dy.common.mw.UnitAdapterInterface;
+
+public interface SupportUnitAdapter extends UnitAdapterInterface {
+
+ SupportUnitConfigVo getConfig() ;
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/support/SupportUnitConfigVo.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/support/SupportUnitConfigVo.java
new file mode 100644
index 0000000..7c312a2
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/support/SupportUnitConfigVo.java
@@ -0,0 +1,34 @@
+package com.dy.common.mw.support;
+
+public class SupportUnitConfigVo {
+
+ public boolean enableThreadPool ;
+
+ //鐭换鍔$嚎绋嬫睜
+ public int short_maxThread ;
+ public int short_minThread ;
+ public long short_freeTimeout;
+ public long short_busyTimeout ;
+
+ //闀夸换鍔$嚎绋嬫睜
+ public int long_maxThread ;
+ public int long_minThread ;
+ public long long_freeTimeout;
+ public long long_busyTimeout ;
+
+ //鍗曚釜Ssdb鎺ヨ繛姹犻厤缃枃浠�
+ public String singleSsdbPoolXmlFile ;
+ //澶氫釜Ssdb鎺ヨ繛姹犻厤缃枃浠�
+ public String multiSsdbPoolXmlFile ;
+
+ //Redis闆嗙兢閰嶇疆鏂囦欢
+ public String redisClusterXmlFile ;
+ //鍗曚釜Redis鎺ヨ繛姹犻厤缃枃浠�
+ public String singleRedisPoolXmlFile ;
+ //澶氫釜Redis鎺ヨ繛姹犻厤缃枃浠�
+ public String multiRedisPoolXmlFile ;
+
+ public Boolean showStartInfo; //鏄惁鍦ㄦ帶鍒跺彴涓婃樉绀轰俊鎭�
+
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/AsciiPic.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/AsciiPic.java
new file mode 100644
index 0000000..53f71b7
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/AsciiPic.java
@@ -0,0 +1,91 @@
+package com.dy.common.util;
+
+import javax.imageio.ImageIO;
+import javax.swing.*;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+/**
+ * 鍥剧墖杞寲Ascii
+ */
+public class AsciiPic {
+
+ /**
+ * 灏唅mage杞崲鎴� BufferedImage
+ *
+ */
+ public static BufferedImage toBufferedImage(Image image) {
+ if (image instanceof BufferedImage) {
+ return (BufferedImage)image;
+ }
+
+ // 鍔犺浇鎵�鏈夊儚绱�
+ image = new ImageIcon(image).getImage();
+ BufferedImage bImage = null;
+ GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
+ try {
+ int transparency = Transparency.OPAQUE;
+
+ // 鍒涘缓buffer鍥惧儚
+ GraphicsDevice gs = ge.getDefaultScreenDevice();
+ GraphicsConfiguration gc = gs.getDefaultConfiguration();
+ bImage = gc.createCompatibleImage(image.getWidth(null), image.getHeight(null), transparency);
+ } catch (HeadlessException e) {
+ e.printStackTrace();
+ }
+ if (bImage == null) {
+ int type = BufferedImage.TYPE_INT_RGB;
+ bImage = new BufferedImage(image.getWidth(null), image.getHeight(null), type);
+ }
+ // 澶嶅埗
+ Graphics g = bImage.createGraphics();
+ // 璧嬪��
+ g.drawImage(image, 0, 0, null);
+ g.dispose();
+ return bImage;
+ }
+
+ public static Image creatImage(String ImgPath) {
+ Image srcImg = null;
+ try {
+ srcImg = ImageIO.read(new FileInputStream(ImgPath));
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ }
+ Image smallImg = null ;
+ if(srcImg != null){
+ //鍙栨簮鍥�
+ int width = 60; //鍋囪瑕佺缉灏忓埌200鐐瑰儚绱�
+ int height = srcImg.getHeight(null)*60/srcImg.getWidth(null);//鎸夋瘮渚嬶紝灏嗛珮搴︾缉鍑�
+ smallImg = srcImg.getScaledInstance(width, height, Image.SCALE_SMOOTH);//缂╁皬
+ }
+ return smallImg;
+ }
+
+ /**
+ * @param bfImage 鍥剧墖璺緞
+ */
+ public static void createAsciiPic(BufferedImage bfImage) throws IOException {
+ final String base = "@#&$O";// 瀛楃涓茬敱澶嶆潅鍒扮畝鍗�
+ for (int y = 0; y < bfImage.getHeight(); y += 2) {
+ for (int x = 0; x < bfImage.getWidth(); x++) {
+ final int pixel = bfImage.getRGB(x, y);
+ final int r = (pixel & 0xff0000) >> 16, g = (pixel & 0xff00) >> 8, b = pixel & 0xff;
+ final float gray = 0.299f * r + 0.578f * g + 0.114f * b;
+ final int index = Math.round(gray * (base.length() + 1) / 255);
+ System.out.print(index >= base.length() ? " " : String.valueOf(base.charAt(index)));
+ }
+ System.out.println();
+ }
+ }
+
+ public static void main(final String[] args) {
+ try {
+ AsciiPic.createAsciiPic(toBufferedImage(creatImage("DY.png")));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+}
\ No newline at end of file
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
new file mode 100644
index 0000000..09f307c
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/CRC16.java
@@ -0,0 +1,126 @@
+package com.dy.common.util;
+
+
+@SuppressWarnings("unused")
+public final class CRC16 {
+
+ /*
+ * 16浣嶇殑CRC鍊兼槸鏃犵鍙蜂袱瀛楄妭鏁存暟锛�
+ * @param b 瀛楄妭鏁扮粍
+ * @return CRC
+
+ public int CRC(byte[] b) {
+ int crc = 0xFFFF;
+ int len = b.length;
+ for (int j = 0 ; j < len; j++) {
+ crc = crc ^ ((b[j] + 256) % 256) ;//杞崲鎴愭棤绗﹀彿鏁帮紝鍥犱负缁堢瀹炵幇(C璇█鎴栨眹缂栬瑷�)閮界敤鐨勬槸鏃犵鍙锋暟
+ for (int i = 0; i < 8; i++) {
+ if ((crc & 0x0001) == 0x0001) {
+ crc = (crc >> 1) ^ 0xA001;
+ } else {
+ crc = crc >> 1;
+ }
+ }
+ }
+ return crc;
+ }
+ */
+
+ /**
+ * 16浣嶇殑CRC鍊兼槸鏃犵鍙蜂袱瀛楄妭鏁存暟锛�
+ * @param b 瀛楄妭鏁扮粍
+ * @param startIndex 寮�濮嬩笅鏍�
+ * @param endIndex 鎴涓嬫爣
+ * @return CRC
+ */
+ @SuppressWarnings("unused")
+ public int CRC(byte[] b, int startIndex, int endIndex) {
+ int crc = 0xFFFF;
+ for (int j = startIndex ; j <= endIndex; j++) {
+ crc = crc ^ ((b[j] + 256) % 256) ;//杞崲鎴愭棤绗﹀彿鏁帮紝鍥犱负缁堢瀹炵幇(C璇█鎴栨眹缂栬瑷�)閮界敤鐨勬槸鏃犵鍙锋暟
+ for (int i = 0; i < 8; i++) {
+ if ((crc & 0x0001) == 0x0001) {
+ crc = (crc >> 1) ^ 0xA001;
+ } else {
+ crc = crc >> 1;
+ }
+ }
+ }
+ return 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
+ };
+
+ /**
+ * 16浣嶇殑CRC鍊� 锛屾煡琛ㄦ硶
+ * @param bs 瀛楄妭鏁扮粍
+ * @return CRC
+ */
+ @SuppressWarnings("unused")
+ public int CRC_table(byte[] bs) {
+ int x ;
+ int crc = 0xffff;
+ if(bs != null && bs.length > 0){
+ for(byte b : bs){
+ x = crc ^ b ;
+ crc = (crc >> 8) ^ crc16_rev_table[x & 0x00FF];
+ }
+ }
+ return crc ;
+ }
+
+
+ /**
+ * 鏁版嵁楂樹綅鍦ㄤ綆瀛楄妭(鏁扮粍涓嬫爣灏�)锛屾暟鎹綆浣嶅湪楂樺瓧鑺�(鏁扮粍涓嬫爣澶�)锛�
+ * 渚嬪258杩欎釜鏁帮紝鏀捐繘鍥涗釜瀛楄妭鏁扮粍b涓細
+ * b[0](浣庡瓧鑺�)=0锛�
+ * b[1](娆′綆瀛楄妭)=0锛�
+ * b[2](娆¢珮瀛楄妭)=1(鏁版嵁楂樹綅)锛�
+ * b[3](楂樺瓧鑺�)=2(鏁版嵁浣庝綅)锛�
+ * @param c 鏁存暟
+ * @return 杞垚鐨勬暟缁�
+ */
+ public byte[] CRC2bytes(int c) {
+ byte[] crc = new byte[2];
+ System.arraycopy(new byte[] {(byte)(c / 256) }, 0, crc, 0, 1);
+ System.arraycopy(new byte[] {(byte)(c - ((c / 256) * 256)) }, 0, crc, 1, 1);
+ return crc;
+ }
+
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/CRC8_for_2_0.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/CRC8_for_2_0.java
new file mode 100644
index 0000000..047c0d7
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/CRC8_for_2_0.java
@@ -0,0 +1,21 @@
+package com.dy.common.util;
+
+@SuppressWarnings("unused")
+public class CRC8_for_2_0 {
+
+ @SuppressWarnings("unused")
+ public int CRC8(byte[] b, int from , int end){
+ int crc = 0;
+ for(int i = from ; i <= end ; i++){
+ crc = crc ^ (b[i]);
+ for(int j = 0; j < 8; j++) {
+ if((crc & 0x80)!=0) {
+ crc ^= 0xe5;
+ }
+ crc *= 2;
+ }
+ }
+ return crc;
+ }
+
+}
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/Callback.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/Callback.java
new file mode 100644
index 0000000..a71b25d
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/Callback.java
@@ -0,0 +1,8 @@
+package com.dy.common.util;
+
+
+public interface Callback {
+ void call(Object obj) ;
+ void call(Object... objs) ;
+ void exception(Exception e) ;
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ClassScan.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ClassScan.java
new file mode 100644
index 0000000..5b37f19
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ClassScan.java
@@ -0,0 +1,90 @@
+package com.dy.common.util;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.logging.Logger;
+
+@SuppressWarnings("unused")
+public class ClassScan {
+
+ private static final Logger logger = Logger.getLogger(ClassScan.class.getName());
+
+
+ /**
+ * 鍦ㄦ寚瀹氱殑URL璺緞涓悳绱lass
+ *
+ * @param uris 瑕佹悳绱㈢殑java鏂囦欢URI,涓嶈兘鐢║RL绫诲瀷锛屽洜涓篣RL璺緞涓湁涓枃灏嗗け璐�
+ * @param rootPackage 瑕佹悳绱㈢殑java鏂囦欢鐨勫寘璺緞
+ */
+ public List<String> searchClassFromUrl(URI[] uris, String rootPackage){
+ List<String> classNames = new ArrayList<>() ;
+ for (URI uri : uris) {
+ try {
+ File file = new File(uri.getPath());
+ if (!file.exists()){
+ throw new FileNotFoundException();
+ }
+ this.doSearchClass(file, rootPackage ,classNames);
+ } catch (Exception ex) {
+ logger.throwing(ClassScan.class.getName(), "searchClassFromUrl", ex);
+ }
+ }
+ return classNames ;
+ }
+
+ /**
+ * 鍦ㄦ寚瀹氱殑jar鏂囦欢涓悳绱lass
+ * @param file 瑕佹悳绱㈢殑jar鏂囦欢
+ */
+ public List<String> searchClassFromArchive(JarFile file) {
+ List<String> classNames = new ArrayList<>() ;
+ for (Enumeration<JarEntry> enumeration = file.entries(); enumeration.hasMoreElements();) {
+ JarEntry entry = enumeration.nextElement();
+ if (entry.getName().endsWith(".class")) {
+ classNames.add(file.getName()) ;
+ }
+ }
+ return classNames ;
+ }
+
+ /**
+ * 鎼滅储鎸囧畾鏂囦欢澶逛笅灞傜骇閲岀殑class
+ * @param dir 鏂囦欢澶�
+ * @param rootPackage 鏍瑰寘
+ * @param classNames 绫诲悕绉伴泦鍚�
+ */
+ private void doSearchClass(File dir, String rootPackage, List<String> classNames) {
+ String path ;
+ if (dir.isDirectory()) {
+ File[] fs = dir.listFiles() ;
+ if(fs != null && fs.length > 0){
+ for (File f : fs){
+ //鍙悳褰撳墠鏂囦欢澶逛腑鏂囦欢
+ this.doSearchClass(f, rootPackage, classNames);
+ }
+ }
+ return;
+ }
+ if (dir.getName().endsWith(".class")) {
+ path = dir.getAbsolutePath() ;
+ path = path.replace('/', '.') ;
+ path = path.replace('\\', '.') ;
+ path = path.substring(path.indexOf(rootPackage)) ;
+ classNames.add(path) ;
+ } else if (dir.getName().endsWith(".zip") || dir.getName().endsWith(".jar")) {
+ try {
+ this.searchClassFromArchive(new JarFile(dir));
+ } catch (IOException ex) {
+ logger.throwing(ClassScan.class.getName(), "doSearchClass", ex);
+ }
+ }
+ }
+
+}
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
new file mode 100644
index 0000000..1491ef3
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/CreateRandom.java
@@ -0,0 +1,121 @@
+package com.dy.common.util;
+
+import java.util.Random;
+
+@SuppressWarnings("unused")
+public class CreateRandom {
+
+ public static int random(int max, int min){
+ return new Random().nextInt(max) % (max - min + 1) + min;
+ }
+
+ /*
+ 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));
+ }
+ */
+
+ /**
+ * 4浣嶉殢鏈烘暟鎹�
+ * @return 闅忔満鏁�
+ */
+ public static int Random_4(){
+ return new Random().nextInt(9999) % (9999 - 1000 + 1) + 1000;
+ }
+ /**
+ * 5浣嶉殢鏈烘暟鎹�
+ * @return 闅忔満鏁�
+ */
+ public static int Random_5(){
+ return new Random().nextInt(99999) % (99999 - 10000 + 1) + 10000;
+ }
+ /**
+ * 6浣嶉殢鏈烘暟鎹�
+ * @return 闅忔満鏁�
+ */
+ public static int Random_6(){
+ return new Random().nextInt(999999) % (999999 - 100000 + 1) + 100000;
+ }
+
+
+ /**
+ * 鍒涘缓scape浣嶉殢鏈烘暟
+ * @param scape 浣嶆暟
+ * @return 闅忔満鏁�
+ */
+ public String create(int scape){
+ if(scape < 1){
+ scape = 6 ;
+ }
+ double d = Math.random();
+ String s = String.valueOf(d);
+ int index ;
+ String ss ;
+ try{
+ index = s.indexOf('.') + 1;
+ ss = s.substring(index , index + scape);
+ } catch(Exception e){
+ ss = "740414";
+ }
+ return ss ;
+ }
+
+ /**
+ * 鍒涘缓涓や釜鏁存暟涔嬮棿鐨勯殢鏈烘暟
+ * @param min 鏈�灏忔暟
+ * @param max 鏈�澶ф暟
+ * @return 闅忔満鏁�
+ */
+ public static int create_between(int min , int max){
+ if(max < min){
+ return min ;
+ }
+ if(max - min < min/2){
+ return min ;
+ }
+ String minStr = String.valueOf(min) ;
+ int len = minStr.length() ;
+ char minFirst = minStr.charAt(0) ;
+ double d = Math.random();
+ d = d * 10000000 ;
+ String s = String.valueOf(d);
+ s = minFirst + s ;
+ s = s.substring(0 ,len) ;
+ int n = Integer.parseInt(s) ;
+ if(n < min || n > max){
+ n = create_between(min , max) ;
+ }
+ return n ;
+ }
+
+
+ /**
+ * 寰楀埌涓�涓皬浜巑ax鐨勯殢鏈烘暟
+ * @param max 鏈�澶ф暟
+ * @return 闅忔満鏁�
+ */
+ public int create_less(int max){
+ if(max > 9){
+ max = 9 ;
+ }
+ double d = Math.random();
+ int n = 0;
+ int m;
+ String s = String.valueOf(d);
+ for(int i = 4 ; i < s.length() ; i++){
+ m = Integer.parseInt(s.charAt(i)+"");
+ if(m < max){
+ n = m ;
+ break ;
+ }
+ }
+ return n ;
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/DateTime.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/DateTime.java
new file mode 100644
index 0000000..1e04eeb
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/DateTime.java
@@ -0,0 +1,1636 @@
+package com.dy.common.util;
+
+import java.util.*;
+import java.text.SimpleDateFormat;
+import java.util.GregorianCalendar ;
+
+@SuppressWarnings("unused")
+public class DateTime {
+
+ private static String yearPreFix = null ;//骞村害鍓嶄袱浣�
+
+ //寰楀埌骞村害鍓嶄袱浣�
+ public static String yearPreFix(){
+ if(yearPreFix == null){
+ yearPreFix = yyyy().substring(0,2) ;
+ }
+ return yearPreFix ;
+ }
+
+ public static long getTime(){
+ return new Date().getTime() ;
+ }
+ public static long getTime(String y_M_d_H_m_s) throws Exception{
+ return dateFrom_yyyy_MM_dd_HH_mm_ss(y_M_d_H_m_s).getTime() ;
+ }
+ public static Date getDate(Long time){
+ return new Date(time) ;
+ }
+
+ public static String yyyy() {
+ return new SimpleDateFormat("yyyy", Locale.CHINA).format(new Date(System.currentTimeMillis()));
+ }
+ public static String yyyy(Date date) {
+ return new SimpleDateFormat("yyyy", Locale.CHINA).format(date);
+ }
+ public static String yyyy(String yyyy) {
+ return new SimpleDateFormat("yyyy", Locale.CHINA).format(yyyy);
+ }
+ public static String yy() {
+ return new SimpleDateFormat("yy", Locale.CHINA).format(new Date(System.currentTimeMillis()));
+ }
+
+ public static String MM() {
+ return new SimpleDateFormat("MM", Locale.CHINA).format(new Date(System.currentTimeMillis()));
+ }
+
+ public static String dd() {
+ return new SimpleDateFormat("dd", Locale.CHINA).format(new Date(System.currentTimeMillis()));
+ }
+
+ public static String HH() {
+ return new SimpleDateFormat("HH", Locale.CHINA).format(new Date(System.currentTimeMillis()));
+ }
+
+ public static String mm() {
+ return new SimpleDateFormat("mm", Locale.CHINA).format(new Date(System.currentTimeMillis()));
+ }
+
+ public static String ss() {
+ return new SimpleDateFormat("ss", Locale.CHINA).format(new Date(System.currentTimeMillis()));
+ }
+
+ public static String week(){
+ return new SimpleDateFormat("EE", Locale.CHINA).format(System.currentTimeMillis());
+ }
+
+
+ //////////////////////////////////////////////////////////////
+ public static String MM_dd() {
+ return new SimpleDateFormat("MM-dd", Locale.CHINA).format(System.currentTimeMillis());
+ }
+ public static String MMdd() {
+ return new SimpleDateFormat("MMdd", Locale.CHINA).format(System.currentTimeMillis());
+ }
+
+
+ //////////////////////////////////////////////////////////////
+
+ public static String yyyy_MM_dd_HH_mm_ss() {
+ return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(System.currentTimeMillis());
+ }
+ public static String yyyy_MM_dd_HH_mm() {
+ return new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA).format(System.currentTimeMillis());
+ }
+ public static String yyyy_MM_dd_HH() {
+ return new SimpleDateFormat("yyyy-MM-dd HH", Locale.CHINA).format(System.currentTimeMillis());
+ }
+ public static String yyyy_MM_dd() {
+ return new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA).format(System.currentTimeMillis());
+ }
+ public static String yyyy_MM() {
+ return new SimpleDateFormat("yyyy-MM", Locale.CHINA).format(System.currentTimeMillis());
+ }
+
+
+ public static String yyyy_MM_dd_HH_mm_ss(Date date) {
+ return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(date);
+ }
+ public static String yyyy_MM_dd_HH_mm(Date date) {
+ return new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA).format(date);
+ }
+ public static String yyyy_MM_dd_HH(Date date) {
+ return new SimpleDateFormat("yyyy-MM-dd HH", Locale.CHINA).format(date);
+ }
+ public static String yyyy_MM_dd(Date date) {
+ return new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA).format(date);
+ }
+ public static String yyyy_MM(Date date) {
+ return new SimpleDateFormat("yyyy-MM", Locale.CHINA).format(date);
+ }
+
+
+ public static String yyyy_MM_dd_HH_mm_ss(String date) {
+ return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(date);
+ }
+ public static String yyyy_MM_dd_HH_mm(String date) {
+ return new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA).format(date);
+ }
+ public static String yyyy_MM_dd_HH(String date) {
+ return new SimpleDateFormat("yyyy-MM-dd HH", Locale.CHINA).format(date);
+ }
+ public static String yyyy_MM_dd(String date) {
+ return new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA).format(date);
+ }
+ public static String yyyy_MM(String date) {
+ return new SimpleDateFormat("yyyy-MM", Locale.CHINA).format(date);
+ }
+
+ public static String yyyyMMddHHmmss() {
+ return new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).format(System.currentTimeMillis());
+ }
+ public static String yyyyMMddHHmm() {
+ return new SimpleDateFormat("yyyyMMddHHmm", Locale.CHINA).format(System.currentTimeMillis());
+ }
+ public static String yyyyMMddHH() {
+ return new SimpleDateFormat("yyyyMMddHH", Locale.CHINA).format(System.currentTimeMillis());
+ }
+ public static String yyyyMMdd() {
+ return new SimpleDateFormat("yyyyMMdd", Locale.CHINA).format(System.currentTimeMillis());
+ }
+ public static String yyyyMM() {
+ return new SimpleDateFormat("yyyyMM", Locale.CHINA).format(System.currentTimeMillis());
+ }
+
+ public static String yyyyMMddHHmmss(Date date) {
+ return new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).format(date);
+ }
+ public static String yyyyMMddHHmm(Date date) {
+ return new SimpleDateFormat("yyyyMMddHHmm", Locale.CHINA).format(date);
+ }
+ public static String yyyyMMddHH(Date date) {
+ return new SimpleDateFormat("yyyyMMddHH", Locale.CHINA).format(date);
+ }
+ public static String yyyyMMdd(Date date) {
+ return new SimpleDateFormat("yyyyMMdd", Locale.CHINA).format(date);
+ }
+ public static String yyyyMM(Date date) {
+ return new SimpleDateFormat("yyyyMM", Locale.CHINA).format(date);
+ }
+
+ public static String yyyyMMddHHmmss(String date) {
+ return new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).format(date);
+ }
+ public static String yyyyMMddHHmm(String date) {
+ return new SimpleDateFormat("yyyyMMddHHmm", Locale.CHINA).format(date);
+ }
+ public static String yyyyMMddHH(String date) {
+ return new SimpleDateFormat("yyyyMMddHH", Locale.CHINA).format(date);
+ }
+ public static String yyyyMMdd(String date) {
+ return new SimpleDateFormat("yyyyMMdd", Locale.CHINA).format(date);
+ }
+ public static String yyyyMM(String date) {
+ return new SimpleDateFormat("yyyyMM", Locale.CHINA).format(date);
+ }
+
+ //////////////////////////////////////////////////////////////
+
+ public static String yy_MM_dd_HH_mm_ss() {
+ return new SimpleDateFormat("yy-MM-dd HH:mm:ss", Locale.CHINA).format(System.currentTimeMillis());
+ }
+ public static String yy_MM_dd_HH_mm() {
+ return new SimpleDateFormat("yy-MM-dd HH:mm", Locale.CHINA).format(System.currentTimeMillis());
+ }
+ public static String yy_MM_dd_HH() {
+ return new SimpleDateFormat("yy-MM-dd HH", Locale.CHINA).format(System.currentTimeMillis());
+ }
+ public static String yy_MM_dd() {
+ return new SimpleDateFormat("yy-MM-dd", Locale.CHINA).format(System.currentTimeMillis());
+ }
+ public static String yy_MM() {
+ return new SimpleDateFormat("yy-MM", Locale.CHINA).format(System.currentTimeMillis());
+ }
+
+
+ public static String yy_MM_dd_HH_mm_ss(Date date) {
+ return new SimpleDateFormat("yy-MM-dd HH:mm:ss", Locale.CHINA).format(date);
+ }
+ public static String yy_MM_dd_HH_mm(Date date) {
+ return new SimpleDateFormat("yy-MM-dd HH:mm", Locale.CHINA).format(date);
+ }
+ public static String yy_MM_dd_HH(Date date) {
+ return new SimpleDateFormat("yy-MM-dd HH", Locale.CHINA).format(date);
+ }
+ public static String yy_MM_dd(Date date) {
+ return new SimpleDateFormat("yy-MM-dd", Locale.CHINA).format(date);
+ }
+ public static String yy_MM(Date date) {
+ return new SimpleDateFormat("yy-MM", Locale.CHINA).format(date);
+ }
+
+
+ public static String yy_MM_dd_HH_mm_ss(String date) {
+ return new SimpleDateFormat("yy-MM-dd HH:mm:ss", Locale.CHINA).format(date);
+ }
+ public static String yy_MM_dd_HH_mm(String date) {
+ return new SimpleDateFormat("yy-MM-dd HH:mm", Locale.CHINA).format(date);
+ }
+ public static String yy_MM_dd_HH(String date) {
+ return new SimpleDateFormat("yy-MM-dd HH", Locale.CHINA).format(date);
+ }
+ public static String yy_MM_dd(String date) {
+ return new SimpleDateFormat("yy-MM-dd", Locale.CHINA).format(date);
+ }
+ public static String yy_MM(String date) {
+ return new SimpleDateFormat("yy-MM", Locale.CHINA).format(date);
+ }
+
+ public static String yyMMddhhmmss() {
+ return new SimpleDateFormat("yyMMddHHmmss", Locale.CHINA).format(System.currentTimeMillis());
+ }
+ public static String yyMMddhhmm() {
+ return new SimpleDateFormat("yyMMddHHmm", Locale.CHINA).format(System.currentTimeMillis());
+ }
+ public static String yyMMddhh() {
+ return new SimpleDateFormat("yyMMddHH", Locale.CHINA).format(System.currentTimeMillis());
+ }
+ public static String yyMMdd() {
+ return new SimpleDateFormat("yyMMdd", Locale.CHINA).format(System.currentTimeMillis());
+ }
+ public static String yyMM() {
+ return new SimpleDateFormat("yyMM", Locale.CHINA).format(System.currentTimeMillis());
+ }
+
+
+ public static String yyMMddhhmmssSSS() {
+ return new SimpleDateFormat("yyMMddHHmmssSSS", Locale.CHINA).format(System.currentTimeMillis());
+ }
+
+ public static String yyMMddhhmmss(Date date) {
+ return new SimpleDateFormat("yyMMddHHmmss", Locale.CHINA).format(date);
+ }
+ public static String yyMMddhhmm(Date date) {
+ return new SimpleDateFormat("yyMMddHHmm", Locale.CHINA).format(date);
+ }
+ public static String yyMMddhh(Date date) {
+ return new SimpleDateFormat("yyMMddHH", Locale.CHINA).format(date);
+ }
+ public static String yyMMdd(Date date) {
+ return new SimpleDateFormat("yyMMdd", Locale.CHINA).format(date);
+ }
+ public static String yyMM(Date date) {
+ return new SimpleDateFormat("yyMM", Locale.CHINA).format(date);
+ }
+
+ public static String yyMMddhhmmss(String date) {
+ return new SimpleDateFormat("yyMMddHHmmss", Locale.CHINA).format(date);
+ }
+ public static String yyMMddhhmm(String date) {
+ return new SimpleDateFormat("yyMMddHHmm", Locale.CHINA).format(date);
+ }
+ public static String yyMMddhh(String date) {
+ return new SimpleDateFormat("yyMMddHH", Locale.CHINA).format(date);
+ }
+ public static String yyMMdd(String date) {
+ return new SimpleDateFormat("yyMMdd", Locale.CHINA).format(date);
+ }
+ public static String yyMM(String date) {
+ return new SimpleDateFormat("yyMM", Locale.CHINA).format(date);
+ }
+
+
+ //////////////////////////////////////////////////////////////
+
+ public static String yyyyMMdd_HH_mm_ss() {
+ return new SimpleDateFormat("yyyyMMdd HH:mm:ss", Locale.CHINA).format(System.currentTimeMillis());
+ }
+ public static String yyyyMMdd_HH_mm() {
+ return new SimpleDateFormat("yyyyMMdd HH:mm", Locale.CHINA).format(System.currentTimeMillis());
+ }
+ public static String yyyyMMdd_HH() {
+ return new SimpleDateFormat("yyyyMMdd HH", Locale.CHINA).format(System.currentTimeMillis());
+ }
+
+ public static String yyyyMMdd_HH_mm_ss(Date date) {
+ return new SimpleDateFormat("yyyyMMdd HH:mm:ss", Locale.CHINA).format(date);
+ }
+ public static String yyyyMMdd_HH_mm(Date date) {
+ return new SimpleDateFormat("yyyyMMdd HH:mm", Locale.CHINA).format(date);
+ }
+ public static String yyyyMMdd_HH(Date date) {
+ return new SimpleDateFormat("yyyyMMdd HH", Locale.CHINA).format(date);
+ }
+
+
+ public static String yyyyMMdd_HH_mm_ss(String date) {
+ return new SimpleDateFormat("yyyyMMdd HH:mm:ss", Locale.CHINA).format(date);
+ }
+ public static String yyyyMMdd_HH_mm(String date) {
+ return new SimpleDateFormat("yyyyMMdd HH:mm", Locale.CHINA).format(date);
+ }
+ public static String yyyyMMdd_HH(String date) {
+ return new SimpleDateFormat("yyyyMMdd HH", Locale.CHINA).format(date);
+ }
+
+
+
+ //////////////////////////////////////////////////////////////
+
+ public static String yyMMdd_HH_mm_ss() {
+ return new SimpleDateFormat("yyMMdd HH:mm:ss", Locale.CHINA).format(System.currentTimeMillis());
+ }
+ public static String yyMMdd_HH_mm() {
+ return new SimpleDateFormat("yyMMdd HH:mm", Locale.CHINA).format(System.currentTimeMillis());
+ }
+ public static String yyMMdd_HH() {
+ return new SimpleDateFormat("yyMMdd HH", Locale.CHINA).format(System.currentTimeMillis());
+ }
+
+ public static String yyMMdd_HH_mm_ss(Date date) {
+ return new SimpleDateFormat("yyMMdd HH:mm:ss", Locale.CHINA).format(date);
+ }
+ public static String yyMMdd_HH_mm(Date date) {
+ return new SimpleDateFormat("yyMMdd HH:mm", Locale.CHINA).format(date);
+ }
+ public static String yyMMdd_HH(Date date) {
+ return new SimpleDateFormat("yyMMdd HH", Locale.CHINA).format(date);
+ }
+
+
+ public static String yyMMdd_HH_mm_ss(String date) {
+ return new SimpleDateFormat("yyMMdd HH:mm:ss", Locale.CHINA).format(date);
+ }
+ public static String yyMMdd_HH_mm(String date) {
+ return new SimpleDateFormat("yyMMdd HH:mm", Locale.CHINA).format(date);
+ }
+ public static String yyMMdd_HH(String date) {
+ return new SimpleDateFormat("yyMMdd HH", Locale.CHINA).format(date);
+ }
+
+ /////////////////////////////////////////
+
+
+ public static String dd_hh_mm_ss() {
+ return new SimpleDateFormat("ddHH:mm:ss", Locale.CHINA).format(System.currentTimeMillis());
+ }
+ public static String ddhhmmss() {
+ return new SimpleDateFormat("ddHHmmss", Locale.CHINA).format(System.currentTimeMillis());
+ }
+
+ public static String hh_mm_ss() {
+ return new SimpleDateFormat("HH:mm:ss", Locale.CHINA).format(System.currentTimeMillis());
+ }
+ public static String hhmmss() {
+ return new SimpleDateFormat("HHmmss", Locale.CHINA).format(System.currentTimeMillis());
+ }
+ public static String hh_mm() {
+ return new SimpleDateFormat("HH:mm", Locale.CHINA).format(System.currentTimeMillis());
+ }
+ public static String hhmm() {
+ return new SimpleDateFormat("HHmm", Locale.CHINA).format(System.currentTimeMillis());
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+
+ public static Date dateFrom_yyyy_MM_dd_HH_mm_ss(String yyyy_MM_dd_HH_mm_ss) throws Exception {
+ return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).parse(yyyy_MM_dd_HH_mm_ss);
+ }
+ public static Date dateFrom_yyyy_MM_dd_HH_mm(String yyyy_MM_dd_HH_mm) throws Exception {
+ return new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA).parse(yyyy_MM_dd_HH_mm);
+ }
+ public static Date dateFrom_yyyy_MM_dd_HH(String yyyy_MM_dd_HH) throws Exception {
+ return new SimpleDateFormat("yyyy-MM-dd HH", Locale.CHINA).parse(yyyy_MM_dd_HH);
+ }
+ public static Date dateFrom_yyyy_MM_dd(String yyyy_MM_dd) throws Exception {
+ return new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA).parse(yyyy_MM_dd);
+ }
+
+ public static Date dateFrom_yyyyMMddHHmmss(String yyyyMMddHHmmss) throws Exception {
+ return new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).parse(yyyyMMddHHmmss);
+ }
+ public static Date dateFrom_yyyyMMddHHmm(String yyyyMMddHHmm) throws Exception {
+ return new SimpleDateFormat("yyyyMMddHHmm", Locale.CHINA).parse(yyyyMMddHHmm);
+ }
+ public static Date dateFrom_yyyyMMddHH(String yyyyMMddHH) throws Exception {
+ return new SimpleDateFormat("yyyyMMddHH", Locale.CHINA).parse(yyyyMMddHH);
+ }
+ public static Date dateFrom_yyyyMMdd(String yyyyMMdd) throws Exception {
+ return new SimpleDateFormat("yyyyMMdd", Locale.CHINA).parse(yyyyMMdd);
+ }
+
+ public static Date dateFrom_yyMMddHHmmss(String yyMMddHHmmss) throws Exception {
+ return new SimpleDateFormat("yyMMddHHmmss", Locale.CHINA).parse(yyMMddHHmmss);
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+
+ //鏄熸湡涓�锛歁onday 鏄熸湡浜�:Tuesday 鏄熸湡涓夛細Wednesday鏄熸湡鍥涳細Thursday鏄熸湡浜旓細Friday鏄熸湡鍏細Saturday鏄熸湡鏃ワ細Sunday
+ //杩斿洖 Mon, Tue Wed Thu Fri Sat Sun
+ public static String week_Str(){
+ return new SimpleDateFormat("EE", Locale.CHINA).format(System.currentTimeMillis());
+ }
+ public static Integer week_Int(){
+ String str = week_Str() ;
+ return switch (str) {
+ case "Mon" -> 1;
+ case "Tue" -> 2;
+ case "Wed" -> 3;
+ case "Thu" -> 4;
+ case "Fri" -> 5;
+ case "Sat" -> 6;
+ case "Sun" -> 7;
+ default -> 0;
+ };
+ }
+ /**
+ * 涓や釜鏃ユ湡闂寸浉宸閽熸暟
+ */
+ public static long secondsBetweenyyyy_MM_dd_HH_mm_ss(String yyyy_MM_dd_HH_mm_ss_1 , String yyyy_MM_dd_HH_mm_ss_2)throws Exception{
+ return ((dateFrom_yyyy_MM_dd_HH_mm_ss(yyyy_MM_dd_HH_mm_ss_1).getTime()-dateFrom_yyyy_MM_dd_HH_mm_ss(yyyy_MM_dd_HH_mm_ss_2).getTime())/1000);
+ }
+ /**
+ * 涓や釜鏃ユ湡闂寸浉宸閽熸暟
+ */
+ public static long secondsBetweenyyyyMMddHHmmss(String yyyyMMddHHmmss_1 , String yyyyMMddHHmmss_2)throws Exception{
+ return ((dateFrom_yyyyMMddHHmmss(yyyyMMddHHmmss_1).getTime()-dateFrom_yyyyMMddHHmmss(yyyyMMddHHmmss_2).getTime())/1000) ;
+ }
+ /**
+ * 涓や釜鏃ユ湡闂寸浉宸垎閽熸暟
+ */
+ public static long minutesBetweenyyyy_MM_dd_HH_mm(String yyyy_MM_dd_HH_mm_1 , String yyyy_MM_dd_HH_mm_2)throws Exception{
+ return ((dateFrom_yyyy_MM_dd_HH_mm(yyyy_MM_dd_HH_mm_1).getTime()-dateFrom_yyyy_MM_dd_HH_mm(yyyy_MM_dd_HH_mm_2).getTime())/1000)/60 ;
+ }
+ /**
+ * 涓や釜鏃ユ湡闂寸浉宸垎閽熸暟
+ */
+ public static long minutesBetweenyyyyMMddHHmm(String yyyyMMddHHmm_1 , String yyyyMMddHHmm_2)throws Exception{
+ return ((dateFrom_yyyyMMddHHmm(yyyyMMddHHmm_1).getTime()-dateFrom_yyyyMMddHHmm(yyyyMMddHHmm_2).getTime())/1000)/60 ;
+ }
+ /**
+ * 涓や釜鏃ユ湡鐩稿樊灏忔椂鏁�
+ */
+ public static long hoursBetweenyyyy_MM_dd_HH(String yyyy_MM_dd_HH_1 , String yyyy_MM_dd_HH_2)throws Exception{
+ return (((dateFrom_yyyy_MM_dd_HH(yyyy_MM_dd_HH_1).getTime()-dateFrom_yyyy_MM_dd_HH(yyyy_MM_dd_HH_2).getTime())/1000)/60)/60 ;
+ }
+ /**
+ * 涓や釜鏃ユ湡鐩稿樊灏忔椂鏁�
+ */
+ public static long hoursBetweenyyyyMMddHH(String yyyyMMddHH_1 , String yyyyMMddHH_2)throws Exception{
+ return (((dateFrom_yyyy_MM_dd_HH(yyyyMMddHH_1).getTime()-dateFrom_yyyy_MM_dd_HH(yyyyMMddHH_2).getTime())/1000)/60)/60 ;
+ }
+ /**
+ * 涓や釜鏃ユ湡鐩稿樊澶╂暟
+ */
+ public static long daysBetweenyyyy_MM_dd(String yyyy_MM_dd_1 , String yyyy_MM_dd_2)throws Exception{
+ return ((((dateFrom_yyyy_MM_dd(yyyy_MM_dd_1).getTime()-dateFrom_yyyy_MM_dd(yyyy_MM_dd_2).getTime())/1000)/60)/60)/24 ;
+ }
+ /**
+ * 涓や釜鏃ユ湡鐩稿樊澶╂暟
+ */
+ public static long daysBetweenyyyyMMdd(String yyyyMMdd_1 , String yyyyMMdd_2)throws Exception{
+ return ((((dateFrom_yyyy_MM_dd(yyyyMMdd_1).getTime()-dateFrom_yyyy_MM_dd(yyyyMMdd_2).getTime())/1000)/60)/60)/24 ;
+ }
+
+ public static Date dateFrom_MM_dd(String MM_dd) throws Exception {
+ return new SimpleDateFormat(MM_dd, Locale.CHINA).parse(MM_dd);
+ }
+ /**
+ * 涓や釜鏃ユ湡鐩稿樊澶╂暟
+ */
+ public static long daysBetweenMM_dd(String MM_dd_1 , String MM_dd_2)throws Exception{
+ return ((((dateFrom_MM_dd(MM_dd_1).getTime()-dateFrom_MM_dd(MM_dd_2).getTime())/1000)/60)/60)/24 ;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+
+ /**
+ * 瀛楃涓插瀷鏃ユ湡(2009-09-10)杞垚骞存湀鏃ユ暟缁�
+ * @param yyyy_MM_DD 骞存湀鏃�
+ * @return 骞存湀鏃ユ暟缁�
+ */
+ public static int[] yyyy_MM_dd_2_ymdGroup(String yyyy_MM_DD){
+ int y = Integer.parseInt(yyyy_MM_DD.substring(0 , 4)) ;
+ int m = Integer.parseInt(yyyy_MM_DD.substring(5 , 7)) ;
+ int d = Integer.parseInt(yyyy_MM_DD.substring(8 , 10)) ;
+ return new int[]{y,m,d} ;
+ }
+ /**
+ * 瀛楃涓插瀷鏃ユ湡(2009-09-10 00)杞垚骞存湀鏃ユ椂鏁扮粍
+ * @param yyyy_MM_DD_HH 骞存湀鏃ユ椂
+ * @return 骞存湀鏃ユ椂鏁扮粍
+ */
+ public static int[] yyyy_MM_dd_HH_2_ymdhGroup(String yyyy_MM_DD_HH){
+ int y = Integer.parseInt(yyyy_MM_DD_HH.substring(0 , 4)) ;
+ int m = Integer.parseInt(yyyy_MM_DD_HH.substring(5 , 7)) ;
+ int d = Integer.parseInt(yyyy_MM_DD_HH.substring(8 , 10)) ;
+ int h = Integer.parseInt(yyyy_MM_DD_HH.substring(11 , 13)) ;
+ return new int[]{y,m,d,h} ;
+ }
+ /**
+ * 瀛楃涓插瀷鏃ユ湡(2009-09-10 00:00)杞垚骞存湀鏃ユ椂鍒嗘暟缁�
+ * @param yyyy_MM_DD_HH_MM 骞存湀鏃ユ椂鍒�
+ * @return 骞存湀鏃ユ椂鍒嗘暟缁�
+ */
+ public static int[] yyyy_MM_dd_HH_MM_2_ymdhmGroup(String yyyy_MM_DD_HH_MM){
+ int y = Integer.parseInt(yyyy_MM_DD_HH_MM.substring(0 , 4)) ;
+ int m = Integer.parseInt(yyyy_MM_DD_HH_MM.substring(5 , 7)) ;
+ int d = Integer.parseInt(yyyy_MM_DD_HH_MM.substring(8 , 10)) ;
+ int h = Integer.parseInt(yyyy_MM_DD_HH_MM.substring(11 , 13)) ;
+ int mm = Integer.parseInt(yyyy_MM_DD_HH_MM.substring(14 , 16)) ;
+ return new int[]{y,m,d,h,mm} ;
+ }
+ /**
+ * 瀛楃涓插瀷鏃ユ湡(2009-09-10 00:00)杞垚骞存湀鏃ユ椂鍒嗙鏁扮粍
+ * @param yyyy_MM_DD_HH_MM_SS 骞存湀鏃ユ椂鍒嗙
+ * @return 骞存湀鏃ユ椂鍒嗙鏁扮粍
+ */
+ public static int[] yyyy_MM_dd_HH_MM_SS_2_ymdhmsGroup(String yyyy_MM_DD_HH_MM_SS){
+ int y = Integer.parseInt(yyyy_MM_DD_HH_MM_SS.substring(0 , 4)) ;
+ int m = Integer.parseInt(yyyy_MM_DD_HH_MM_SS.substring(5 , 7)) ;
+ int d = Integer.parseInt(yyyy_MM_DD_HH_MM_SS.substring(8 , 10)) ;
+ int h = Integer.parseInt(yyyy_MM_DD_HH_MM_SS.substring(11 , 13)) ;
+ int mm = Integer.parseInt(yyyy_MM_DD_HH_MM_SS.substring(14 , 16)) ;
+ int s = Integer.parseInt(yyyy_MM_DD_HH_MM_SS.substring(17 , 19)) ;
+ return new int[]{y,m,d,h,mm,s} ;
+ }
+
+ /**
+ * 骞存湀鏃ユ椂鍒嗙鏁扮粍杞瓧绗︿覆
+ * @param yymdhms 骞存湀鏃ユ椂鍒嗙鏁扮粍
+ * @return 骞存湀鏃ユ椂鍒嗙绗︿覆
+ */
+ public static String dateGroupTo_yyyy_MM_dd_HH_mm_ss(int[] yymdhms){
+ if(yymdhms[0] > 2000){
+ return yymdhms[0] + "-" +
+ (yymdhms[1] < 10 ? ("0" + yymdhms[1]) : yymdhms[1]) + "-" +
+ (yymdhms[2] < 10 ? ("0" + yymdhms[2]) : yymdhms[2]) + " " +
+ (yymdhms[3] < 10 ? ("0" + yymdhms[3]) : yymdhms[3]) + ":" +
+ (yymdhms[4] < 10 ? ("0" + yymdhms[4]) : yymdhms[4]) + ":" +
+ (yymdhms[5] < 10 ? ("0" + yymdhms[5]) : yymdhms[5]) ;
+ }else{
+ return Integer.parseInt(yyyy())/100 + yymdhms[0] + "-" +
+ (yymdhms[1] < 10 ? ("0" + yymdhms[1]) : yymdhms[1]) + "-" +
+ (yymdhms[2] < 10 ? ("0" + yymdhms[2]) : yymdhms[2]) + " " +
+ (yymdhms[3] < 10 ? ("0" + yymdhms[3]) : yymdhms[3]) + ":" +
+ (yymdhms[4] < 10 ? ("0" + yymdhms[4]) : yymdhms[4]) + ":" +
+ (yymdhms[5] < 10 ? ("0" + yymdhms[5]) : yymdhms[5]) ;
+
+ }
+ }
+
+ public static String dateGroupTo_yyyy_MM_dd_HH_mm_ss(Integer[] yymdhms){
+ if(yymdhms[0] > 2000){
+ return yymdhms[0] + "-" +
+ (yymdhms[1] < 10 ? ("0" + yymdhms[1]) : yymdhms[1]) + "-" +
+ (yymdhms[2] < 10 ? ("0" + yymdhms[2]) : yymdhms[2]) + " " +
+ (yymdhms[3] < 10 ? ("0" + yymdhms[3]) : yymdhms[3]) + ":" +
+ (yymdhms[4] < 10 ? ("0" + yymdhms[4]) : yymdhms[4]) + ":" +
+ (yymdhms[5] < 10 ? ("0" + yymdhms[5]) : yymdhms[5]) ;
+ }else{
+ return Integer.parseInt(yyyy())/100 + yymdhms[0] + "-" +
+ (yymdhms[1] < 10 ? ("0" + yymdhms[1]) : yymdhms[1]) + "-" +
+ (yymdhms[2] < 10 ? ("0" + yymdhms[2]) : yymdhms[2]) + " " +
+ (yymdhms[3] < 10 ? ("0" + yymdhms[3]) : yymdhms[3]) + ":" +
+ (yymdhms[4] < 10 ? ("0" + yymdhms[4]) : yymdhms[4]) + ":" +
+ (yymdhms[5] < 10 ? ("0" + yymdhms[5]) : yymdhms[5]) ;
+
+ }
+ }
+
+
+ //////////////////////////////////////////////////////////////////////////
+ /**
+ * 寰楀埌杩囧幓x鍒嗛挓瀵瑰簲鐨勬棩鏈�
+ * @param xMin X鍒嗛挓
+ * @return 姣
+ */
+ public static Long lastXMinuteTime(int xMin) {
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.MINUTE, -xMin);
+ Date date = cal.getTime() ;
+ return date.getTime() ;
+ }
+
+
+ /**
+ * 寰楀埌杩囧幓x灏忔椂瀵瑰簲鐨勬棩鏈�
+ * @param yyyy_MM_dd_HH 鎸囧畾骞存湀鏃ユ椂
+ * @param xhour x灏忔椂 X灏忔椂
+ * @return 骞存湀鏃ユ椂
+ */
+ public static String lastXHour_yyyy_MM_dd_HH(String yyyy_MM_dd_HH , int xhour) throws Exception {
+ Date d = new SimpleDateFormat("yyyy-MM-dd HH", Locale.CHINA).parse(yyyy_MM_dd_HH);
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(d);
+ cal.add(Calendar.HOUR_OF_DAY, -xhour);
+ Date date = cal.getTime() ;
+ return DateTime.yyyy_MM_dd_HH(date) ;
+ }
+ /**
+ * 寰楀埌杩囧幓x灏忔椂瀵瑰簲鐨勬棩鏈�
+ * @param yyyy_MM_dd_HH_mm 鎸囧畾骞存湀鏃ユ椂鍒�
+ * @param xhour x灏忔椂 X灏忔椂
+ * @return 骞存湀鏃ユ椂
+ */
+ public static String lastXHour_yyyy_MM_dd_HH_mm(String yyyy_MM_dd_HH_mm , int xhour) throws Exception {
+ Date d = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA).parse(yyyy_MM_dd_HH_mm);
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(d);
+ cal.add(Calendar.HOUR_OF_DAY, -xhour);
+ Date date = cal.getTime() ;
+ return DateTime.yyyy_MM_dd_HH_mm(date) ;
+ }
+ /**
+ * 寰楀埌杩囧幓x灏忔椂瀵瑰簲鐨勬棩鏈�
+ * @param yyyy_MM_dd_HH_mm_ss 鎸囧畾骞存湀鏃ユ椂鍒嗙
+ * @param xhour x灏忔椂 X灏忔椂
+ * @return 骞存湀鏃ユ椂鍒嗙
+ */
+ public static String lastXHour_yyyy_MM_dd_HH_mm_ss(String yyyy_MM_dd_HH_mm_ss , int xhour) throws Exception {
+ Date d = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).parse(yyyy_MM_dd_HH_mm_ss);
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(d);
+ cal.add(Calendar.HOUR_OF_DAY, -xhour);
+ Date date = cal.getTime() ;
+ return DateTime.yyyy_MM_dd_HH_mm_ss(date) ;
+ }
+ /**
+ * 寰楀埌杩囧幓x灏忔椂瀵瑰簲鐨勬棩鏈�
+ * @param yyyyMMddHH 鎸囧畾骞存湀鏃ユ椂
+ * @param xhour x灏忔椂 x灏忔椂
+ * @return 骞存湀鏃ユ椂鍒嗙
+ */
+ public static String lastXHour_yyyyMMddHH(String yyyyMMddHH , int xhour) throws Exception {
+ Date d = new SimpleDateFormat("yyyyMMddHH", Locale.CHINA).parse(yyyyMMddHH);
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(d);
+ cal.add(Calendar.HOUR_OF_DAY, -xhour);
+ Date date = cal.getTime() ;
+ return DateTime.yyyyMMddHH(date) ;
+ }
+ /**
+ * 寰楀埌杩囧幓x灏忔椂瀵瑰簲鐨勬棩鏈�
+ * @param yyyyMMddHHmm 鎸囧畾骞存湀鏃ユ椂鍒�
+ * @param xhour x灏忔椂 x灏忔椂
+ * @return 骞存湀鏃ユ椂鍒�
+ */
+ public static String lastXHour_yyyyMMddHHmm(String yyyyMMddHHmm , int xhour) throws Exception {
+ Date d = new SimpleDateFormat("yyyyMMddHHmm", Locale.CHINA).parse(yyyyMMddHHmm);
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(d);
+ cal.add(Calendar.HOUR_OF_DAY, -xhour);
+ Date date = cal.getTime() ;
+ return DateTime.yyyyMMddHHmm(date) ;
+ }
+ /**
+ * 寰楀埌鍓峹灏忔椂瀵瑰簲鐨勬棩鏈�
+ * @param yyyyMMddHHmmss 鎸囧畾骞存湀鏃ユ椂鍒嗙
+ * @param xhour x灏忔椂 x灏忔椂
+ * @return 骞存湀鏃ユ椂鍒嗙
+ */
+ public static String lastXHour_yyyyMMddHHmmss(String yyyyMMddHHmmss , int xhour) throws Exception {
+ Date d = new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).parse(yyyyMMddHHmmss);
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(d);
+ cal.add(Calendar.HOUR_OF_DAY, -xhour);
+ Date date = cal.getTime() ;
+ return DateTime.yyyyMMddHHmmss(date) ;
+ }
+
+
+ /**
+ * 寰楀埌x灏忔椂鍓嶅搴旂殑鏃ユ湡(骞存湀鏃ユ椂)
+ * @param xhour x灏忔椂 x灏忔椂
+ * @return 骞存湀鏃ユ椂
+ */
+ public static String lastXHour_yyyy_MM_dd_HH(int xhour){
+ Date date = new Date();
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.HOUR_OF_DAY, -xhour);
+ date.setTime(cal.getTimeInMillis());
+ return DateTime.yyyy_MM_dd_HH(date) ;
+ }
+ /**
+ * 寰楀埌x灏忔椂鍓嶅搴旂殑鏃ユ湡(骞存湀鏃ユ椂鍒�)
+ * @param xhour x灏忔椂 x灏忔椂
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static String lastXHour_yyyy_MM_dd_HH_mm(int xhour){
+ Date date = new Date();
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.HOUR_OF_DAY, -xhour);
+ date.setTime(cal.getTimeInMillis());
+ return DateTime.yyyy_MM_dd_HH_mm(date) ;
+ }
+ /**
+ * 寰楀埌x灏忔椂鍓嶅搴旂殑鏃ユ湡(骞存湀鏃ユ椂鍒嗙)
+ * @param xhour x灏忔椂 x灏忔椂
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static String lastXHour_yyyy_MM_dd_HH_mm_ss(int xhour){
+ Date date = new Date();
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.HOUR_OF_DAY, -xhour);
+ date.setTime(cal.getTimeInMillis());
+ return DateTime.yyyy_MM_dd_HH_mm_ss(date) ;
+ }
+ /**
+ * 寰楀埌x灏忔椂鍓嶅搴旂殑鏃ユ湡(骞存湀鏃ユ椂)
+ * @param xhour x灏忔椂 x灏忔椂
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static String lastXHour_yyyyMMddHH(int xhour){
+ Date date = new Date();
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.HOUR_OF_DAY, -xhour);
+ date.setTime(cal.getTimeInMillis());
+ return DateTime.yyyyMMddHH(date) ;
+ }
+ /**
+ * 寰楀埌x灏忔椂鍓嶅搴旂殑鏃ユ湡(骞存湀鏃ユ椂鍒�)
+ * @param xhour x灏忔椂 x灏忔椂
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static String lastXHour_yyyyMMddHHmm(int xhour){
+ Date date = new Date();
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.HOUR_OF_DAY, -xhour);
+ date.setTime(cal.getTimeInMillis());
+ return DateTime.yyyyMMddHHmm(date) ;
+ }
+ /**
+ * 寰楀埌x灏忔椂鍓嶅搴旂殑鏃ユ湡(骞存湀鏃ユ椂鍒嗙)
+ * @param xhour x灏忔椂 x灏忔椂
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static String lastXHour_yyyyMMddHHmmss(int xhour){
+ Date date = new Date();
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.HOUR_OF_DAY, -xhour);
+ date.setTime(cal.getTimeInMillis());
+ return DateTime.yyyyMMddHHmmss(date) ;
+ }
+
+ //////////////////////////////////////////////////////////////////
+ /**
+ * 寰楀埌灏嗘潵x鍒嗛挓瀵瑰簲鐨勬棩鏈�
+ * @param yyyy_MM_dd_HH_mm_ss 鎸囧畾骞存湀鏃ユ椂鍒嗙
+ * @param xminute x鍒嗛挓
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static String nextXMinute_yyyy_MM_dd_HH_mm_ss(String yyyy_MM_dd_HH_mm_ss , int xminute) throws Exception {
+ Date d = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).parse(yyyy_MM_dd_HH_mm_ss);
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(d);
+ cal.add(Calendar.MINUTE, xminute);
+ Date date = cal.getTime() ;
+ return DateTime.yyyy_MM_dd_HH_mm_ss(date) ;
+ }
+
+
+ /**
+ * 寰楀埌灏嗘潵x灏忔椂瀵瑰簲鐨勬棩鏈�
+ * @param yyyy_MM_dd_HH 鎸囧畾骞存湀鏃ユ椂
+ * @param xhour x灏忔椂
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static String nextXHour_yyyy_MM_dd_HH(String yyyy_MM_dd_HH , int xhour) throws Exception {
+ Date d = new SimpleDateFormat("yyyy-MM-dd HH", Locale.CHINA).parse(yyyy_MM_dd_HH);
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(d);
+ cal.add(Calendar.HOUR_OF_DAY, xhour);
+ Date date = cal.getTime() ;
+ return DateTime.yyyy_MM_dd_HH(date) ;
+ }
+ /**
+ * 寰楀埌灏嗘潵x灏忔椂瀵瑰簲鐨勬棩鏈�
+ * @param yyyy_MM_dd_HH_mm 鎸囧畾骞存湀鏃ユ椂鍒�
+ * @param xhour x灏忔椂
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static String nextXHour_yyyy_MM_dd_HH_mm(String yyyy_MM_dd_HH_mm , int xhour) throws Exception {
+ Date d = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA).parse(yyyy_MM_dd_HH_mm);
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(d);
+ cal.add(Calendar.HOUR_OF_DAY, xhour);
+ Date date = cal.getTime() ;
+ return DateTime.yyyy_MM_dd_HH_mm(date) ;
+ }
+ /**
+ * 寰楀埌灏嗘潵x灏忔椂瀵瑰簲鐨勬棩鏈�
+ * @param yyyy_MM_dd_HH_mm_ss 鎸囧畾骞存湀鏃ユ椂鍒嗙
+ * @param xhour x灏忔椂
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static String nextXHour_yyyy_MM_dd_HH_mm_ss(String yyyy_MM_dd_HH_mm_ss , int xhour) throws Exception {
+ Date d = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).parse(yyyy_MM_dd_HH_mm_ss);
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(d);
+ cal.add(Calendar.HOUR_OF_DAY, xhour);
+ Date date = cal.getTime() ;
+ return DateTime.yyyy_MM_dd_HH_mm_ss(date) ;
+ }
+ /**
+ * 寰楀埌灏嗘潵x灏忔椂瀵瑰簲鐨勬棩鏈�
+ * @param yyyyMMddHH 鎸囧畾骞存湀鏃ユ椂
+ * @param xhour x灏忔椂
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static String nextXHour_yyyyMMddHH(String yyyyMMddHH , int xhour) throws Exception {
+ Date d = new SimpleDateFormat("yyyyMMddHH", Locale.CHINA).parse(yyyyMMddHH);
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(d);
+ cal.add(Calendar.HOUR_OF_DAY, xhour);
+ Date date = cal.getTime() ;
+ return DateTime.yyyyMMddHH(date) ;
+ }
+ /**
+ * 寰楀埌灏嗘潵x灏忔椂瀵瑰簲鐨勬棩鏈�
+ * @param yyyyMMddHHmm 鎸囧畾骞存湀鏃ユ椂鍒�
+ * @param xhour x灏忔椂
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static String nextXHour_yyyyMMddHHmm(String yyyyMMddHHmm , int xhour) throws Exception {
+ Date d = new SimpleDateFormat("yyyyMMddHHmm", Locale.CHINA).parse(yyyyMMddHHmm);
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(d);
+ cal.add(Calendar.HOUR_OF_DAY, xhour);
+ Date date = cal.getTime() ;
+ return DateTime.yyyyMMddHHmm(date) ;
+ } /**
+ * 寰楀埌灏嗘潵x灏忔椂瀵瑰簲鐨勬棩鏈�
+ * @param yyyyMMddHHmmss 鎸囧畾骞存湀鏃ユ椂鍒嗙
+ * @param xhour x灏忔椂
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static String nextXHour_yyyyMMddHHmmss(String yyyyMMddHHmmss , int xhour) throws Exception {
+ Date d = new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).parse(yyyyMMddHHmmss);
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(d);
+ cal.add(Calendar.HOUR_OF_DAY, xhour);
+ Date date = cal.getTime() ;
+ return DateTime.yyyyMMddHHmmss(date) ;
+ }
+
+
+ /**
+ * 寰楀埌x灏忔椂鍚庡搴旂殑鏃ユ湡(骞存湀鏃ユ椂)
+ * @param xhour x灏忔椂
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static String nextXHour_yyyy_MM_dd_HH(int xhour){
+ Date date = new Date();
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.HOUR_OF_DAY, xhour);
+ date.setTime(cal.getTimeInMillis());
+ return DateTime.yyyy_MM_dd_HH(date) ;
+ }
+ /**
+ * 寰楀埌x灏忔椂鍚庡搴旂殑鏃ユ湡(骞存湀鏃ユ椂鍒�)
+ * @param xhour x灏忔椂
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static String nextXHour_yyyy_MM_dd_HH_mm(int xhour){
+ Date date = new Date();
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.HOUR_OF_DAY, xhour);
+ date.setTime(cal.getTimeInMillis());
+ return DateTime.yyyy_MM_dd_HH_mm(date) ;
+ }
+ /**
+ * 寰楀埌x灏忔椂鍚庡搴旂殑鏃ユ湡(骞存湀鏃ユ椂鍒嗙)
+ * @param xhour x灏忔椂
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static String nextXHour_yyyy_MM_dd_HH_mm_ss(int xhour){
+ Date date = new Date();
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.HOUR_OF_DAY, xhour);
+ date.setTime(cal.getTimeInMillis());
+ return DateTime.yyyy_MM_dd_HH_mm_ss(date) ;
+ }
+
+
+ /**
+ * 寰楀埌x灏忔椂鍚庡搴旂殑鏃ユ湡(骞存湀鏃ユ椂)
+ * @param xhour x灏忔椂
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static String nextXHour_yyyyMMddHH(int xhour){
+ Date date = new Date();
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.HOUR_OF_DAY, xhour);
+ date.setTime(cal.getTimeInMillis());
+ return DateTime.yyyyMMddHH(date) ;
+ }
+ /**
+ * 寰楀埌x灏忔椂鍚庡搴旂殑鏃ユ湡(骞存湀鏃ユ椂鍒�)
+ * @param xhour x灏忔椂
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static String nextXHour_yyyyMMddHHmm(int xhour){
+ Date date = new Date();
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.HOUR_OF_DAY, xhour);
+ date.setTime(cal.getTimeInMillis());
+ return DateTime.yyyyMMddHHmm(date) ;
+ }
+ /**
+ * 寰楀埌x灏忔椂鍚庡搴旂殑鏃ユ湡(骞存湀鏃ユ椂鍒嗙)
+ * @param xhour x灏忔椂
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static String nextXHour_yyyyMMddHHmmss(int xhour){
+ Date date = new Date();
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.HOUR_OF_DAY, xhour);
+ date.setTime(cal.getTimeInMillis());
+ return DateTime.yyyyMMddHHmmss(date) ;
+ }
+
+
+
+ //////////////////////////////////////////////////////////////////////////
+
+ /**
+ * 寰楀埌杩囧幓x澶╂棩鏈�
+ * @param yyyy_MM_dd 鎸囧畾骞存湀鏃�
+ * @param xday x鏃�
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static String lastXDay_yyyy_MM_dd(String yyyy_MM_dd , int xday) throws Exception {
+ Date d = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA).parse(yyyy_MM_dd);
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(d);
+ cal.add(Calendar.DAY_OF_YEAR, -xday);
+ Date date = cal.getTime() ;
+ return DateTime.yyyy_MM_dd(date) ;
+ }
+ /**
+ * 寰楀埌杩囧幓x澶╂棩鏈�
+ * @param yyyyMMdd 鎸囧畾骞存湀鏃�
+ * @param xday x鏃�
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static String lastXDay_yyyyMMdd(String yyyyMMdd , int xday) throws Exception {
+ Date d = new SimpleDateFormat("yyyyMMdd", Locale.CHINA).parse(yyyyMMdd);
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(d);
+ cal.add(Calendar.DAY_OF_YEAR, -xday);
+ Date date = cal.getTime() ;
+ return DateTime.yyyyMMdd(date) ;
+ }
+ /**
+ * 寰楀埌杩囧幓x澶╂棩鏈�
+ * @param xday x鏃�
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static String lastXDay_yyyy_MM_dd(int xday){
+ Date date = new Date();
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.DAY_OF_YEAR, -xday);
+ date.setTime(cal.getTimeInMillis());
+ return DateTime.yyyy_MM_dd(date) ;
+ }
+ /**
+ * 寰楀埌杩囧幓x澶╂棩鏈�
+ * @param xday x鏃�
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static String lastXDay_yyyy_MM_dd_HH_ss(int xday){
+ Date date = new Date();
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.DAY_OF_YEAR, -xday);
+ date.setTime(cal.getTimeInMillis());
+ return DateTime.yyyy_MM_dd_HH_mm_ss(date) ;
+ }
+ /**
+ * 寰楀埌杩囧幓x澶╂棩鏈�
+ * @param xday x鏃�
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static String lastXDay_yyyyMMdd(int xday){
+ Date date = new Date();
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.DAY_OF_YEAR, -xday);
+ date.setTime(cal.getTimeInMillis());
+ return DateTime.yyyyMMdd(date) ;
+ }
+
+
+ ////////////////////////////////////////////////////////////
+
+
+ /**
+ * 寰楀埌灏嗘潵x澶╂棩鏈�
+ * @param yyyy_MM_dd 鎸囧畾骞存湀鏃�
+ * @param xday x鏃�
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static String nextXDay_yyyy_MM_dd(String yyyy_MM_dd , int xday) throws Exception {
+ Date d = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA).parse(yyyy_MM_dd);
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(d);
+ cal.add(Calendar.DAY_OF_YEAR, xday);
+ Date date = cal.getTime() ;
+ return DateTime.yyyy_MM_dd(date) ;
+ }
+ /**
+ * 寰楀埌灏嗘潵x澶╂棩鏈�
+ * @param yyyyMMdd 鎸囧畾骞存湀鏃�
+ * @param xday x鏃�
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static String nextXDay_yyyyMMdd(String yyyyMMdd , int xday) throws Exception {
+ Date d = new SimpleDateFormat("yyyyMMdd", Locale.CHINA).parse(yyyyMMdd);
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(d);
+ cal.add(Calendar.DAY_OF_YEAR, xday);
+ Date date = cal.getTime() ;
+ return DateTime.yyyyMMdd(date) ;
+ }
+ /**
+ * 寰楀埌灏嗘潵x澶╂棩鏈�
+ * @param xday x鏃�
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static String nextXDay_yyyy_MM_dd(int xday){
+ Date date = new Date();
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.DAY_OF_YEAR, xday);
+ date.setTime(cal.getTimeInMillis());
+ return DateTime.yyyy_MM_dd(date) ;
+ }
+ /**
+ * 寰楀埌灏嗘潵x澶╂棩鏈�
+ * @param xday x鏃�
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static String nextXDay_yyyyMMdd(int xday){
+ Date date = new Date();
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.DAY_OF_YEAR, xday);
+ date.setTime(cal.getTimeInMillis());
+ return DateTime.yyyyMMdd(date) ;
+ }
+
+
+ ////////////////////////////////////////////////////////////
+
+
+ /**
+ * 寰楀埌鏄ㄥぉ
+ * @param thisYear 骞�
+ * @param thisMonth 鏈�
+ * @param thisDay 鏃�
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static String yesterday_yyyy_MM_dd(int thisYear , int thisMonth , int thisDay){
+ int yesterday ;
+ int lastYear ;
+ int lastMonth ;
+ if(thisDay == 1){
+ if(thisMonth == 1 || thisMonth == 2 || thisMonth == 4 || thisMonth == 6 || thisMonth == 8 || thisMonth == 9 || thisMonth == 11 ){
+ yesterday = 31 ;
+ }else if( thisMonth == 3){
+ if(isLeapYear(thisYear)){
+ yesterday = 29 ;
+ }else{
+ yesterday = 28 ;
+ }
+ }else {
+ yesterday = 30 ;
+ }
+
+ if(thisMonth == 1){
+ lastYear = thisYear - 1 ;
+ lastMonth = 12 ;
+ }else{
+ lastYear = thisYear ;
+ lastMonth = thisMonth - 1 ;
+ }
+ }else{
+ yesterday = thisDay - 1 ;
+ lastMonth = thisMonth ;
+ lastYear = thisYear ;
+ }
+ //褰揜TU鐨勬棩鏈熸湭鍒濆鍖栨椂锛屼細鍑虹幇thisDay=0锛岃繖鏃秚hisDay-1 = -1
+ if(yesterday < 0){
+ yesterday = 0 ;
+ }
+ if(lastMonth < 0){
+ lastMonth = 0 ;
+ }
+ if(lastYear < 0){
+ lastYear = 0 ;
+ }
+ return lastYear + "-"
+ + (lastMonth > 9?(lastMonth + ""):("0" + lastMonth)) + "-"
+ + (yesterday > 9?(yesterday + ""):("0" + yesterday)) ;
+
+ }
+
+
+ /**
+ * 寰楀埌鏄ㄥぉ
+ * @param thisYear 骞�
+ * @param thisMonth 鏈�
+ * @param thisDay 鏃�
+ * @param thisHour 鏃�
+ * @param thisMinute 鍒�
+ * @param thisSecond 绉�
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static String yesterday_yyyy_MM_dd_hh_mm_ss(int thisYear , int thisMonth , int thisDay, int thisHour, int thisMinute, int thisSecond){
+ int yesterday;
+ int lastYear;
+ int lastMonth;
+ if(thisDay == 1){
+ if(thisMonth == 1 || thisMonth == 2 || thisMonth == 4 || thisMonth == 6 || thisMonth == 8 || thisMonth == 9 || thisMonth == 11 ){
+ yesterday = 31 ;
+ }else if( thisMonth == 3){
+ if(isLeapYear(thisYear)){
+ yesterday = 29 ;
+ }else{
+ yesterday = 28 ;
+ }
+ }else {
+ yesterday = 30 ;
+ }
+
+ if(thisMonth == 1){
+ lastYear = thisYear - 1 ;
+ lastMonth = 12 ;
+ }else{
+ lastYear = thisYear ;
+ lastMonth = thisMonth - 1 ;
+ }
+ }else{
+ yesterday = thisDay - 1 ;
+ lastMonth = thisMonth ;
+ lastYear = thisYear ;
+ }
+ return lastYear + "-"
+ + (lastMonth > 9?(lastMonth + ""):("0" + lastMonth)) + "-"
+ + (yesterday > 9?(yesterday + ""):("0" + yesterday)) + " "
+ + (thisHour > 9?(thisHour + ""):("0" + thisHour)) + ":"
+ + (thisMinute > 9?(thisMinute + ""):("0" + thisMinute)) + ":"
+ + (thisSecond > 9?(thisSecond + ""):("0" + thisSecond));
+
+ }
+
+ /**
+ * 寰楀埌鏄庡ぉ
+ * @param thisYear 骞�
+ * @param thisMonth 鏈�
+ * @param thisDay 鏃�
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static String tomorrow_yyyy_MM_dd(int thisYear , int thisMonth , int thisDay){
+ int tomorrow = 0 ;
+ int year = 0 ;
+ int month = 0 ;
+ if(thisDay == 31){
+ if(thisMonth == 1 || thisMonth == 3 || thisMonth == 5 || thisMonth == 7 || thisMonth == 8 || thisMonth == 10){
+ year = thisYear ;
+ month = thisMonth + 1 ;
+ tomorrow = 1 ;
+ }else if(thisMonth == 12){
+ year = thisYear + 1 ;
+ month = 1 ;
+ tomorrow = 1 ;
+ }
+ }else if(thisDay == 30){
+ if(thisMonth == 4 || thisMonth == 6 || thisMonth == 9 || thisMonth == 11){
+ year = thisYear ;
+ month = thisMonth + 1 ;
+ tomorrow = 1 ;
+ }else{
+ year = thisYear ;
+ month = thisMonth ;
+ tomorrow = 31 ;
+ }
+ }else if(thisDay == 29){
+ if(thisMonth == 2){
+ year = thisYear ;
+ month = thisMonth + 1 ;
+ tomorrow = 1 ;
+ }else{
+ year = thisYear ;
+ month = thisMonth ;
+ tomorrow = 30 ;
+ }
+ }else if(thisDay == 28){
+ if(thisMonth == 2){
+ if(!isLeapYear(thisYear)){
+ year = thisYear ;
+ month = thisMonth + 1 ;
+ tomorrow = 1 ;
+ }else{
+ year = thisYear ;
+ month = thisMonth ;
+ tomorrow = 29 ;
+ }
+ }else{
+ year = thisYear ;
+ month = thisMonth ;
+ tomorrow = 29 ;
+ }
+ }else{
+ year = thisYear ;
+ month = thisMonth ;
+ tomorrow = thisDay + 1 ;
+ }
+ return year + "-"
+ + (month > 9?(month + ""):("0" + month)) + "-"
+ + (tomorrow > 9?(tomorrow + ""):("0" + tomorrow)) ;
+ }
+
+
+ ///////////////////////////////////////////////////
+
+ /**
+ * 寰楀埌涓婃湀浠�
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static String lastMonth_ym(){
+ Date date = new Date();
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.DAY_OF_YEAR, -((Integer.parseInt(dd()))));
+ date.setTime(cal.getTimeInMillis());
+ return DateTime.yyyy_MM(date) ;
+ }
+ /**
+ * 寰楀埌涓婃湀浠�
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static String lastMonth_ym(int thisMonth){
+ Date date = new Date();
+ Calendar cal = Calendar.getInstance();
+ if(thisMonth == 2){
+ cal.add(Calendar.DAY_OF_YEAR, - 30);
+ }else{
+ cal.add(Calendar.DAY_OF_YEAR, - 32);
+ }
+ date.setTime(cal.getTimeInMillis());
+ return DateTime.yyyy_MM(date) ;
+ }
+ /**
+ * 寰楀埌涓婃湀浠�
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static String lastMonth_ym(int year , int thisMonth){
+ thisMonth = thisMonth - 1 ;
+ if(thisMonth == 0){
+ year = year - 1 ;
+ thisMonth = 12 ;
+ }
+ return ("" + year) + "-" + (thisMonth<10?("0"+thisMonth):(""+thisMonth)) ;
+ }
+ /**
+ * 寰楀埌涓婃湀浠�
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static String lastMonth_ymd(int year , int thisMonth , int thisDate){
+ thisMonth = thisMonth - 1 ;
+ if(thisMonth == 0){
+ year = year - 1 ;
+ thisMonth = 12 ;
+ }
+ if(thisMonth == 2){
+ if(isLeapYear(year)){
+ if(thisDate > 29){
+ thisDate = 29 ;
+ }
+ }else{
+ if(thisDate > 28){
+ thisDate = 28 ;
+ }
+ }
+ }else if(thisMonth == 4 || thisMonth == 6 || thisMonth == 9 || thisMonth == 11){
+ if(thisDate > 30){
+ thisDate = 30 ;
+ }
+
+ }
+ return ("" + year) + "-" + (thisMonth<10?("0"+thisMonth):(""+thisMonth)) + "-" + (thisDate<10?("0"+thisDate):(""+thisDate)) ;
+ }
+ /**
+ * 寰楀埌涓婁笂鏈堜唤
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static String lastLastMonth_ym(){
+ Date date = new Date();
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.DAY_OF_YEAR, -((Integer.parseInt(dd())) + 32));
+ date.setTime(cal.getTimeInMillis());
+ return DateTime.yyyy_MM(date) ;
+ }
+ /**
+ * 寰楀埌涓婂勾搴�
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static String lastYear(){
+ Date date = new Date();
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.DAY_OF_YEAR, - 365);
+ date.setTime(cal.getTimeInMillis());
+ return DateTime.yyyy(date) ;
+ }
+
+ /**
+ * d1姣攄2鏃ユ湡鏇磋繎杩斿洖1(d1>d2),鐩哥瓑杩斿洖0锛屾洿杩滆繑鍥�-1(d1<d2)
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static int compareDateStrByChar(String d1 , String d2){
+ int r = 0 ;
+ if(d1 == null || d2 == null || d1.length() != d2.length()){
+ return r ;
+ }
+ for(int i = 0 ; i < d1.length() ; i++){
+ if(d1.charAt(i)>d2.charAt(i)){
+ return 1 ;
+ }else{
+ if(d1.charAt(i)<d2.charAt(i)){
+ return -1 ;
+ }
+ }
+ }
+ return r ;
+ }
+ /**
+ * 涓や釜鏃ユ湡姣旇緝(鏍煎紡濡� 2008-09-09 00:00:00)
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static boolean oneCompareTow( String one , String two){
+ one = one.replaceAll("-", "") ;
+ one = one.replaceAll(" ", "") ;
+ one = one.replaceAll(":", "") ;
+ two = two.replaceAll("-", "") ;
+ two = two.replaceAll(" ", "") ;
+ two = two.replaceAll(":", "") ;
+ long onel = Long.parseLong(one) ;
+ long twol = Long.parseLong(two) ;
+ return onel >= twol ;
+ }
+
+ /**
+ * 瀛楃涓插瀷杞彉涓烘暣鏁�
+ * @return 杞崲鍚庢棩鏈�
+ */
+ public static long dateTime_str2int(String str){
+ if(str == null || str.trim().equals("")){
+ return 0L ;
+ }
+ str = str.replaceAll("-", "") ;
+ str = str.replaceAll(":", "") ;
+ str = str.replaceAll(" ", "") ;
+ return Long.parseLong(str) ;
+ }
+
+
+ public static String[] yearGroup1() {
+ int thisYear = Integer.parseInt((new SimpleDateFormat("yyyy"))
+ .format(System.currentTimeMillis()));
+ int len = (thisYear - 2005) + 1;
+ String[] years = new String[len];
+ for (int i = 0; i < len; i++)
+ years[i] = "" + (thisYear - i);
+
+ return years;
+ }
+
+ public static String[] yearGroup2() {
+ return new String[]{"1900", "1901", "1902", "1903", "1904", "1905",
+ "1906", "1907", "1908", "1909", "1910", "1911", "1912", "1913",
+ "1914", "1915", "1916", "1917", "1918", "1919", "1920", "1921",
+ "1922", "1923", "1924", "1925", "1926", "1927", "1928", "1929",
+ "1930", "1931", "1932", "1933", "1934", "1935", "1936", "1937",
+ "1938", "1939", "1940", "1941", "1942", "1943", "1944", "1945",
+ "1946", "1947", "1948", "1949", "1950", "1951", "1952", "1953",
+ "1954", "1955", "1956", "1957", "1958", "1959", "1960", "1961",
+ "1962", "1963", "1964", "1965", "1966", "1967", "1968", "1969",
+ "1970", "1971", "1972", "1973", "1974", "1975", "1976", "1977",
+ "1978", "1979", "1980", "1981", "1982", "1983", "1984", "1985",
+ "1986", "1987", "1988", "1989", "1990", "1991", "1992", "1993",
+ "1994", "1995", "1996", "1997", "1998", "1999", "2000", "2001",
+ "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009",
+ "2010", "2011", "2012", "2013", "2014", "2015", "2016", "2017",
+ "2018", "2019", "2020", "2021", "2022", "2023", "2024", "2025",
+ "2026", "2027", "2028", "2029"};
+ }
+
+ public static String[] monthGroup() {
+ return new String[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10",
+ "11", "12" };
+ }
+
+ public static String[] dateGroup() {
+ return new String[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10",
+ "11", "12", "13", "14", "15", "16", "17", "18", "19", "20",
+ "21", "22", "23", "24", "25", "26", "27", "28", "29", "30",
+ "31" };
+ }
+
+ public static String[] timeGroup() {
+ return new String[] { "00", "01", "02", "03", "04", "05", "06", "07", "08",
+ "09", "11", "12", "13", "14", "15", "16", "17", "18", "19",
+ "20", "21", "22", "23" };
+ }
+
+
+ public static String getWeek(int wk) {
+ if (wk == 1) {
+ return "鏃�";
+ } else if (wk == 2) {
+ return "涓�";
+ } else if (wk == 3) {
+ return "浜�";
+ } else if (wk == 4) {
+ return "涓�";
+ } else if (wk == 5) {
+ return "鍥�";
+ } else if (wk == 6) {
+ return "浜�";
+ } else if (wk == 7) {
+ return "鍏�";
+ }
+ return "";
+ }
+
+ /**
+ * 鍒ゆ柇鏄惁涓烘鼎骞�
+ * @param year 骞�
+ * @return true鎴杅alse
+ */
+ public static boolean isLeapYear(int year) {
+ return new GregorianCalendar().isLeapYear(year) ;
+ }
+
+
+ /**
+ * 寰楀埌浠庝粖澶╄捣寰�鍓嶄竴涓湀鐨勬棩鏈熷垪琛�
+ * 瑕佹眰涓嶈兘瀛樺湪涓や釜浠ヤ笂鏈堢殑鏃ユ湡锛堝涓婃湀鏄簩鏈堬紝浠婂ぉ鏄�3鏈�1鏃ワ級
+ * 涓嶅寘鎷綋澶╂棩鏈熷強涓婃湀浠戒笌褰撳墠鏃ョ浉鍚岀殑鏃ユ湡
+ * @return 鏁扮粍
+ */
+ public static ArrayList<MonthDateVO> createOneMonthDate(){
+ ArrayList<MonthDateVO> list = new ArrayList<>() ;
+
+ int year = Integer.parseInt(yyyy()) ;
+ int month = Integer.parseInt(MM()) ;
+ int date = Integer.parseInt(dd()) ;
+
+ int beforeYear = year ;
+ int beforeMonth = month - 1 ;
+ int beforeDate = 31 ;
+ //int thisTotal = date ;
+ int beforeTotal = 31 - date ;
+ if(month == 1){
+ beforeYear = year - 1 ;
+ beforeMonth = 12 ;
+ beforeDate = 31 ;
+ }
+ if(month == 3){
+ beforeMonth = 2 ;
+ if(isLeapYear(year)){
+ beforeDate = 29 ;
+ if(beforeTotal > 29){
+ beforeTotal = 29 ;
+ }
+ }else{
+ beforeDate = 28 ;
+ if(beforeTotal > 28){
+ beforeTotal = 28 ;
+ }
+ }
+
+ }
+ switch (month) {
+ case 2 -> {
+ beforeMonth = 1;
+ beforeDate = 31;
+ }
+ case 4 -> {
+ beforeMonth = 3;
+ beforeDate = 31;
+ }
+ case 5 -> {
+ beforeMonth = 4;
+ beforeDate = 30;
+ }
+ case 6 -> {
+ beforeMonth = 5;
+ beforeDate = 31;
+ }
+ case 7 -> {
+ beforeMonth = 6;
+ beforeDate = 30;
+ }
+ case 8 -> {
+ beforeMonth = 7;
+ beforeDate = 31;
+ }
+ case 9 -> {
+ beforeMonth = 8;
+ beforeDate = 31;
+ }
+ case 10 -> {
+ beforeMonth = 9;
+ beforeDate = 30;
+ }
+ case 11 -> {
+ beforeMonth = 10;
+ beforeDate = 31;
+ }
+ case 12 -> {
+ beforeMonth = 11;
+ beforeDate = 30;
+ }
+ }
+ int n = 0 ;
+ for(int i = date ; i > 0 ; i--){
+ MonthDateVO vo = new MonthDateVO() ;
+ vo.setDate(year + "-" + month + "-" + (date - n)) ;
+ vo.setIndex(date - n + "") ;
+ if(date - n != date){
+ list.add(vo) ;
+ }
+ n++ ;
+ }
+ n = 0 ;
+ for(int i = beforeTotal ; i > 0 ; i--){
+ MonthDateVO vo = new MonthDateVO() ;
+ vo.setDate(beforeYear + "-" + beforeMonth + "-" + (beforeDate - n)) ;
+ vo.setIndex(beforeDate - n + "") ;
+ if(beforeDate - n != date){
+ list.add(vo) ;
+ }
+ n++ ;
+ }
+ return list ;
+ }
+
+
+ /**
+ * 灏�2009-02-12鏍煎紡鐨勬棩鏈熷垎瑙d负骞� 鏈� 鏃ュ瓧绗︿覆鏁扮粍
+ * @param ymd 骞存湀鏃�
+ * @return 瀛楃涓叉暟缁�
+ */
+ public static String[] altYmd(String ymd){
+ if(ymd == null || ymd.length() < 10){
+ return null ;
+ }
+ String[] s = new String[3] ;
+ s[0] = ymd.substring(0 , 4) ;
+ s[1] = ymd.substring(5 , 7) ;
+ if(s[1].charAt(0) == '0'){
+ s[1] = s[1].substring(1) ;
+ }
+ s[2] = ymd.substring(8,10) ;
+ if(s[2].charAt(0) == '0'){
+ s[2] = s[2].substring(1) ;
+ }
+ return s ;
+ }
+ /**
+ * 灏�2009-02-12鏍煎紡鐨勬棩鏈熷垎瑙d负骞� 鏈� 鏃ュ瓧绗︿覆鏁扮粍
+ * @param ymdhms 骞存湀鏃ユ椂鍒嗙
+ * @return 鏁扮粍
+ */
+ public static int[] altYmdhms(String ymdhms) throws Exception{
+ if(ymdhms == null || ymdhms.length() != 19){
+ throw new Exception("涓婃湡鏍煎紡涓嶆纭紝姝g‘鐨勬牸寮忎负 yyyy-MM-dd hh:mm:ss") ;
+ }
+ String[] sg1 = ymdhms.split(" ") ;
+ String[] sg1_1 = sg1[0].split("-") ;
+ String[] sg1_2 = sg1[1].split(":") ;
+
+ int[] ig = new int[6] ;
+ ig[0] = Integer.parseInt(sg1_1[0]) ;
+ ig[1] = Integer.parseInt(sg1_1[1]) ;
+ ig[2] = Integer.parseInt(sg1_1[2]) ;
+
+ ig[3] = Integer.parseInt(sg1_2[0]) ;
+ ig[4] = Integer.parseInt(sg1_2[1]) ;
+ ig[5] = Integer.parseInt(sg1_2[2]) ;
+
+ return ig ;
+ }
+
+
+ public static class MonthDateVO {
+
+ public String date ;
+ public String index ;
+ public String getDate() {
+ return date;
+ }
+ public void setDate(String date) {
+ this.date = date;
+ }
+ public String getIndex() {
+ return index;
+ }
+ public void setIndex(String index) {
+ this.index = index;
+ }
+
+ }
+
+
+ public static void main(String[] args){
+ Long now = getTime() ;
+ System.out.println(now);
+// Long t = lastXMinuteTime(1) ;
+// System.out.println(t);
+
+ //3951840342
+ Date dt = getDate(1447857387L) ;
+ String s = yyyy_MM_dd_HH_mm_ss(dt);
+ System.out.println(s);
+ }
+
+
+}
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
new file mode 100644
index 0000000..aa3d138
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ThreadJob.java
@@ -0,0 +1,29 @@
+package com.dy.common.util;
+
+
+@SuppressWarnings("unused")
+public abstract class ThreadJob {
+ public void start(Callback callback){
+ new Thread(() -> {
+ Exception[] exe = {null} ;
+ Object[] obj = {null} ;
+ try {
+ obj[0] = execute() ;
+ }catch(Exception e){
+ e.printStackTrace();
+ exe[0] = e ;
+ }finally {
+ if(callback != null){
+ if(exe[0] != null){
+ callback.exception(exe[0]);
+ }else{
+ callback.call(obj[0]);
+ }
+ }
+ }
+ }).start();
+ }
+
+ public abstract Object execute() throws Exception ;
+}
+
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/.gitignore b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/.gitignore
new file mode 100644
index 0000000..549e00a
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/.gitignore
@@ -0,0 +1,33 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/.mvn/wrapper/maven-wrapper.jar b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/.mvn/wrapper/maven-wrapper.jar
new file mode 100644
index 0000000..cb28b0e
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/.mvn/wrapper/maven-wrapper.jar
Binary files differ
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/.mvn/wrapper/maven-wrapper.properties b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/.mvn/wrapper/maven-wrapper.properties
new file mode 100644
index 0000000..5f0536e
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/.mvn/wrapper/maven-wrapper.properties
@@ -0,0 +1,2 @@
+distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip
+wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/mvnw b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/mvnw
new file mode 100644
index 0000000..66df285
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/mvnw
@@ -0,0 +1,308 @@
+#!/bin/sh
+# ----------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# ----------------------------------------------------------------------------
+
+# ----------------------------------------------------------------------------
+# Apache Maven Wrapper startup batch script, version 3.2.0
+#
+# Required ENV vars:
+# ------------------
+# JAVA_HOME - location of a JDK home dir
+#
+# Optional ENV vars
+# -----------------
+# MAVEN_OPTS - parameters passed to the Java VM when running Maven
+# e.g. to debug Maven itself, use
+# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+# ----------------------------------------------------------------------------
+
+if [ -z "$MAVEN_SKIP_RC" ] ; then
+
+ if [ -f /usr/local/etc/mavenrc ] ; then
+ . /usr/local/etc/mavenrc
+ fi
+
+ if [ -f /etc/mavenrc ] ; then
+ . /etc/mavenrc
+ fi
+
+ if [ -f "$HOME/.mavenrc" ] ; then
+ . "$HOME/.mavenrc"
+ fi
+
+fi
+
+# OS specific support. $var _must_ be set to either true or false.
+cygwin=false;
+darwin=false;
+mingw=false
+case "$(uname)" in
+ CYGWIN*) cygwin=true ;;
+ MINGW*) mingw=true;;
+ Darwin*) darwin=true
+ # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
+ # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
+ if [ -z "$JAVA_HOME" ]; then
+ if [ -x "/usr/libexec/java_home" ]; then
+ JAVA_HOME="$(/usr/libexec/java_home)"; export JAVA_HOME
+ else
+ JAVA_HOME="/Library/Java/Home"; export JAVA_HOME
+ fi
+ fi
+ ;;
+esac
+
+if [ -z "$JAVA_HOME" ] ; then
+ if [ -r /etc/gentoo-release ] ; then
+ JAVA_HOME=$(java-config --jre-home)
+ fi
+fi
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched
+if $cygwin ; then
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME=$(cygpath --unix "$JAVA_HOME")
+ [ -n "$CLASSPATH" ] &&
+ CLASSPATH=$(cygpath --path --unix "$CLASSPATH")
+fi
+
+# For Mingw, ensure paths are in UNIX format before anything is touched
+if $mingw ; then
+ [ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] &&
+ JAVA_HOME="$(cd "$JAVA_HOME" || (echo "cannot cd into $JAVA_HOME."; exit 1); pwd)"
+fi
+
+if [ -z "$JAVA_HOME" ]; then
+ javaExecutable="$(which javac)"
+ if [ -n "$javaExecutable" ] && ! [ "$(expr "\"$javaExecutable\"" : '\([^ ]*\)')" = "no" ]; then
+ # readlink(1) is not available as standard on Solaris 10.
+ readLink=$(which readlink)
+ if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then
+ if $darwin ; then
+ javaHome="$(dirname "\"$javaExecutable\"")"
+ javaExecutable="$(cd "\"$javaHome\"" && pwd -P)/javac"
+ else
+ javaExecutable="$(readlink -f "\"$javaExecutable\"")"
+ fi
+ javaHome="$(dirname "\"$javaExecutable\"")"
+ javaHome=$(expr "$javaHome" : '\(.*\)/bin')
+ JAVA_HOME="$javaHome"
+ export JAVA_HOME
+ fi
+ fi
+fi
+
+if [ -z "$JAVACMD" ] ; then
+ if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ else
+ JAVACMD="$(\unset -f command 2>/dev/null; \command -v java)"
+ fi
+fi
+
+if [ ! -x "$JAVACMD" ] ; then
+ echo "Error: JAVA_HOME is not defined correctly." >&2
+ echo " We cannot execute $JAVACMD" >&2
+ exit 1
+fi
+
+if [ -z "$JAVA_HOME" ] ; then
+ echo "Warning: JAVA_HOME environment variable is not set."
+fi
+
+# traverses directory structure from process work directory to filesystem root
+# first directory with .mvn subdirectory is considered project base directory
+find_maven_basedir() {
+ if [ -z "$1" ]
+ then
+ echo "Path not specified to find_maven_basedir"
+ return 1
+ fi
+
+ basedir="$1"
+ wdir="$1"
+ while [ "$wdir" != '/' ] ; do
+ if [ -d "$wdir"/.mvn ] ; then
+ basedir=$wdir
+ break
+ fi
+ # workaround for JBEAP-8937 (on Solaris 10/Sparc)
+ if [ -d "${wdir}" ]; then
+ wdir=$(cd "$wdir/.." || exit 1; pwd)
+ fi
+ # end of workaround
+ done
+ printf '%s' "$(cd "$basedir" || exit 1; pwd)"
+}
+
+# concatenates all lines of a file
+concat_lines() {
+ if [ -f "$1" ]; then
+ # Remove \r in case we run on Windows within Git Bash
+ # and check out the repository with auto CRLF management
+ # enabled. Otherwise, we may read lines that are delimited with
+ # \r\n and produce $'-Xarg\r' rather than -Xarg due to word
+ # splitting rules.
+ tr -s '\r\n' ' ' < "$1"
+ fi
+}
+
+log() {
+ if [ "$MVNW_VERBOSE" = true ]; then
+ printf '%s\n' "$1"
+ fi
+}
+
+BASE_DIR=$(find_maven_basedir "$(dirname "$0")")
+if [ -z "$BASE_DIR" ]; then
+ exit 1;
+fi
+
+MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR
+log "$MAVEN_PROJECTBASEDIR"
+
+##########################################################################################
+# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+# This allows using the maven wrapper in projects that prohibit checking in binary data.
+##########################################################################################
+wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar"
+if [ -r "$wrapperJarPath" ]; then
+ log "Found $wrapperJarPath"
+else
+ log "Couldn't find $wrapperJarPath, downloading it ..."
+
+ if [ -n "$MVNW_REPOURL" ]; then
+ wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
+ else
+ wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
+ fi
+ while IFS="=" read -r key value; do
+ # Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' )
+ safeValue=$(echo "$value" | tr -d '\r')
+ case "$key" in (wrapperUrl) wrapperUrl="$safeValue"; break ;;
+ esac
+ done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties"
+ log "Downloading from: $wrapperUrl"
+
+ if $cygwin; then
+ wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath")
+ fi
+
+ if command -v wget > /dev/null; then
+ log "Found wget ... using wget"
+ [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet"
+ if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
+ wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
+ else
+ wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
+ fi
+ elif command -v curl > /dev/null; then
+ log "Found curl ... using curl"
+ [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent"
+ if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
+ curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath"
+ else
+ curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath"
+ fi
+ else
+ log "Falling back to using Java to download"
+ javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java"
+ javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class"
+ # For Cygwin, switch paths to Windows format before running javac
+ if $cygwin; then
+ javaSource=$(cygpath --path --windows "$javaSource")
+ javaClass=$(cygpath --path --windows "$javaClass")
+ fi
+ if [ -e "$javaSource" ]; then
+ if [ ! -e "$javaClass" ]; then
+ log " - Compiling MavenWrapperDownloader.java ..."
+ ("$JAVA_HOME/bin/javac" "$javaSource")
+ fi
+ if [ -e "$javaClass" ]; then
+ log " - Running MavenWrapperDownloader.java ..."
+ ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath"
+ fi
+ fi
+ fi
+fi
+##########################################################################################
+# End of extension
+##########################################################################################
+
+# If specified, validate the SHA-256 sum of the Maven wrapper jar file
+wrapperSha256Sum=""
+while IFS="=" read -r key value; do
+ case "$key" in (wrapperSha256Sum) wrapperSha256Sum=$value; break ;;
+ esac
+done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties"
+if [ -n "$wrapperSha256Sum" ]; then
+ wrapperSha256Result=false
+ if command -v sha256sum > /dev/null; then
+ if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c > /dev/null 2>&1; then
+ wrapperSha256Result=true
+ fi
+ elif command -v shasum > /dev/null; then
+ if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c > /dev/null 2>&1; then
+ wrapperSha256Result=true
+ fi
+ else
+ echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available."
+ echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties."
+ exit 1
+ fi
+ if [ $wrapperSha256Result = false ]; then
+ echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2
+ echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2
+ echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2
+ exit 1
+ fi
+fi
+
+MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin; then
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME")
+ [ -n "$CLASSPATH" ] &&
+ CLASSPATH=$(cygpath --path --windows "$CLASSPATH")
+ [ -n "$MAVEN_PROJECTBASEDIR" ] &&
+ MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR")
+fi
+
+# Provide a "standardized" way to retrieve the CLI args that will
+# work with both Windows and non-Windows executions.
+MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*"
+export MAVEN_CMD_LINE_ARGS
+
+WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+# shellcheck disable=SC2086 # safe args
+exec "$JAVACMD" \
+ $MAVEN_OPTS \
+ $MAVEN_DEBUG_OPTS \
+ -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
+ "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
+ ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/mvnw.cmd b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/mvnw.cmd
new file mode 100644
index 0000000..95ba6f5
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/mvnw.cmd
@@ -0,0 +1,205 @@
+@REM ----------------------------------------------------------------------------
+@REM Licensed to the Apache Software Foundation (ASF) under one
+@REM or more contributor license agreements. See the NOTICE file
+@REM distributed with this work for additional information
+@REM regarding copyright ownership. The ASF licenses this file
+@REM to you under the Apache License, Version 2.0 (the
+@REM "License"); you may not use this file except in compliance
+@REM with the License. You may obtain a copy of the License at
+@REM
+@REM https://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing,
+@REM software distributed under the License is distributed on an
+@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+@REM KIND, either express or implied. See the License for the
+@REM specific language governing permissions and limitations
+@REM under the License.
+@REM ----------------------------------------------------------------------------
+
+@REM ----------------------------------------------------------------------------
+@REM Apache Maven Wrapper startup batch script, version 3.2.0
+@REM
+@REM Required ENV vars:
+@REM JAVA_HOME - location of a JDK home dir
+@REM
+@REM Optional ENV vars
+@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
+@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
+@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
+@REM e.g. to debug Maven itself, use
+@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+@REM ----------------------------------------------------------------------------
+
+@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
+@echo off
+@REM set title of command window
+title %0
+@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
+@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
+
+@REM set %HOME% to equivalent of $HOME
+if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
+
+@REM Execute a user defined script before this one
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
+@REM check for pre script, once with legacy .bat ending and once with .cmd ending
+if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
+if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
+:skipRcPre
+
+@setlocal
+
+set ERROR_CODE=0
+
+@REM To isolate internal variables from possible post scripts, we use another setlocal
+@setlocal
+
+@REM ==== START VALIDATION ====
+if not "%JAVA_HOME%" == "" goto OkJHome
+
+echo.
+echo Error: JAVA_HOME not found in your environment. >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+:OkJHome
+if exist "%JAVA_HOME%\bin\java.exe" goto init
+
+echo.
+echo Error: JAVA_HOME is set to an invalid directory. >&2
+echo JAVA_HOME = "%JAVA_HOME%" >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+@REM ==== END VALIDATION ====
+
+:init
+
+@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
+@REM Fallback to current working directory if not found.
+
+set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
+IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
+
+set EXEC_DIR=%CD%
+set WDIR=%EXEC_DIR%
+:findBaseDir
+IF EXIST "%WDIR%"\.mvn goto baseDirFound
+cd ..
+IF "%WDIR%"=="%CD%" goto baseDirNotFound
+set WDIR=%CD%
+goto findBaseDir
+
+:baseDirFound
+set MAVEN_PROJECTBASEDIR=%WDIR%
+cd "%EXEC_DIR%"
+goto endDetectBaseDir
+
+:baseDirNotFound
+set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
+cd "%EXEC_DIR%"
+
+:endDetectBaseDir
+
+IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
+
+@setlocal EnableExtensions EnableDelayedExpansion
+for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
+@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
+
+:endReadAdditionalConfig
+
+SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
+set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
+set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
+
+FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
+ IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B
+)
+
+@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
+if exist %WRAPPER_JAR% (
+ if "%MVNW_VERBOSE%" == "true" (
+ echo Found %WRAPPER_JAR%
+ )
+) else (
+ if not "%MVNW_REPOURL%" == "" (
+ SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
+ )
+ if "%MVNW_VERBOSE%" == "true" (
+ echo Couldn't find %WRAPPER_JAR%, downloading it ...
+ echo Downloading from: %WRAPPER_URL%
+ )
+
+ powershell -Command "&{"^
+ "$webclient = new-object System.Net.WebClient;"^
+ "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
+ "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
+ "}"^
+ "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^
+ "}"
+ if "%MVNW_VERBOSE%" == "true" (
+ echo Finished downloading %WRAPPER_JAR%
+ )
+)
+@REM End of extension
+
+@REM If specified, validate the SHA-256 sum of the Maven wrapper jar file
+SET WRAPPER_SHA_256_SUM=""
+FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
+ IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B
+)
+IF NOT %WRAPPER_SHA_256_SUM%=="" (
+ powershell -Command "&{"^
+ "$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^
+ "If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^
+ " Write-Output 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^
+ " Write-Output 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^
+ " Write-Output 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^
+ " exit 1;"^
+ "}"^
+ "}"
+ if ERRORLEVEL 1 goto error
+)
+
+@REM Provide a "standardized" way to retrieve the CLI args that will
+@REM work with both Windows and non-Windows executions.
+set MAVEN_CMD_LINE_ARGS=%*
+
+%MAVEN_JAVA_EXE% ^
+ %JVM_CONFIG_MAVEN_PROPS% ^
+ %MAVEN_OPTS% ^
+ %MAVEN_DEBUG_OPTS% ^
+ -classpath %WRAPPER_JAR% ^
+ "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
+ %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
+if ERRORLEVEL 1 goto error
+goto end
+
+:error
+set ERROR_CODE=1
+
+:end
+@endlocal & set ERROR_CODE=%ERROR_CODE%
+
+if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
+@REM check for post script, once with legacy .bat ending and once with .cmd ending
+if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
+if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
+:skipRcPost
+
+@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
+if "%MAVEN_BATCH_PAUSE%"=="on" pause
+
+if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
+
+cmd /C exit /B %ERROR_CODE%
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/pom.xml b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/pom.xml
new file mode 100644
index 0000000..e7c78e3
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/pom.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>pipIrr-mw</artifactId>
+ <groupId>com.dy</groupId>
+ <version>1.0.0</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <packaging>jar</packaging>
+ <artifactId>pipIrr-mw-accept</artifactId>
+ <name>pipIrr-mw-accept</name>
+ <description>閫氫俊涓棿浠�</description>
+
+ <dependencies>
+ <!-- apache mina -->
+ <dependency>
+ <groupId>org.apache.mina</groupId>
+ <artifactId>mina-core</artifactId>
+ <version>2.2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.mina</groupId>
+ <artifactId>mina-filter-compression</artifactId>
+ <version>2.2.1</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/PipIrrMwAcceptApplication.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/PipIrrMwAcceptApplication.java
new file mode 100644
index 0000000..bae96a4
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/PipIrrMwAcceptApplication.java
@@ -0,0 +1,36 @@
+package com.dy.aceMw;
+
+import com.dy.common.multiDataSource.EnableMultiDataSource;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.EnableAspectJAutoProxy;
+
+@SpringBootApplication
+@EnableAspectJAutoProxy
+@EnableMultiDataSource
+@ComponentScan(basePackages = {"com.dy.common", "com.dy.pipIrrGlobal", "com.dy.aceMw"})
+@MapperScan(basePackages={"com.dy.pipIrrGlobal.daoBa"})
+public class PipIrrMwAcceptApplication implements CommandLineRunner {
+
+ public static void main(String[] args) {
+ SpringApplication.run(PipIrrMwAcceptApplication.class, args);
+ }
+
+ @Override
+ public void run(String... args) throws Exception {
+ try{
+ //绛夊緟鏁版嵁搴撳垵濮嬪寲瀹屾垚
+ Thread.sleep(1000L);
+ }catch (Exception e){}
+ finally {
+ this.startAceSv() ;
+ }
+ }
+
+ private void startAceSv(){
+
+ }
+}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/resource/ResourceUnit.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/resource/ResourceUnit.java
new file mode 100644
index 0000000..e846f1f
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/resource/ResourceUnit.java
@@ -0,0 +1,150 @@
+package com.dy.aceMw.resource;
+
+import java.io.File;
+import java.text.DecimalFormat;
+import java.util.Date;
+import java.util.TreeMap;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.springframework.context.ApplicationContext;
+
+import com.dy.common.mw.UnitAdapterInterface;
+import com.dy.common.mw.UnitInterface;
+import com.dy.common.mw.UnitStartedCallbackInterface;
+import com.dy.aceMw.resource.rtuLog.RtuLogManager;
+import com.dy.aceMw.resource.rtuLog.RtuLogNode;
+import com.dy.common.util.DateTime;
+
+public class ResourceUnit implements UnitInterface {
+
+ private static final Logger log = LogManager.getLogger(ResourceUnit.class) ;
+
+ private static final ResourceUnit instance = new ResourceUnit() ;
+
+ //private static SupportUnit supUnit ;
+ public static ResourceUnitAdapter adapter ;
+ public static ResourceUnitConfigVo confVo ;
+
+ public static ApplicationContext springContext ;
+
+ private ResourceUnit(){}
+
+ @SuppressWarnings("unused")
+ public static ResourceUnit getInstance(){
+ return instance ;
+ }
+
+ @Override
+ public void setAdapter(UnitAdapterInterface adapter) throws Exception {
+ if(adapter == null){
+ throw new Exception("璧勬簮妯″潡閫傞厤鍣ㄥ璞′笉鑳戒负绌猴紒") ;
+ }
+ ResourceUnit.adapter = (ResourceUnitAdapter)adapter ;
+ ResourceUnit.confVo = ResourceUnit.adapter.getConfig() ;
+ if(ResourceUnit.confVo == null){
+ throw new Exception("璧勬簮妯″潡閰嶇疆瀵硅薄涓嶈兘涓虹┖锛�") ;
+ }
+ }
+
+ /*
+ * 璁剧疆鏀寔鍗曞厓
+ * @param supUnit
+ public void setSupportUnit(SupportUnit supUnit){
+ ResourceUnit.supUnit = supUnit ;
+ }*/
+
+ /**
+ * 璁剧疆spring涓婁笅鏂�
+ * @param springContext Spring瀹瑰櫒涓婁笅鏂囧璞�
+ */
+ @SuppressWarnings("unused")
+ public void setSpringContext(ApplicationContext springContext) {
+ ResourceUnit.springContext = springContext ;
+ }
+ @Override
+ public void start(UnitStartedCallbackInterface callback) throws Exception {
+ if(confVo.enableSpringHibernate && ResourceUnit.springContext == null){
+ throw new Exception("Spring涓婁笅鏂囧璞℃湭璁剧疆锛�") ;
+ }
+ callback.call(null) ;
+ System.out.println("璧勬簮妯″潡鎴愬姛鍚姩");
+ }
+
+ @Override
+ public void stop(UnitStartedCallbackInterface callback) {
+ }
+
+ /**
+ * 璁板綍Rtu鏃ュ織
+ * @param node 鏃ュ織闃熷垪涓殑鑺傜偣瀵硅薄
+ */
+ @SuppressWarnings("unused")
+ public void rtuLog(RtuLogNode node){
+ if(node != null && node.rtuAddr != null && node.content != null){
+ try {
+ RtuLogManager.getInstance().pushRtuLog(node);
+ } catch (Exception e) {
+ log.error(e);
+ }
+ }
+ }
+
+
+ /**
+ * 寰楀埌Rtu鎵�鏈夋棩蹇楁枃浠�
+ * @param rtuAddr 鎺у埗鍣ㄥ湴鍧�
+ * @return 鏂囦欢鍒楄〃锛堟枃浠跺悕绉帮紝鏂囦欢澶у皬锛屾枃浠舵渶鍚庝慨鏀规椂闂达級
+ */
+ @SuppressWarnings("unused")
+ public TreeMap<String, String[]> listLogFiles(String rtuAddr){
+ File f = new File(ResourceUnit.confVo.rtuLogDir) ;
+ TreeMap<String, String[]> map = new TreeMap<>() ;
+ if(f.isDirectory()){
+ File[] fs = f.listFiles() ;
+ if(fs != null && fs.length > 0){
+ String fileName ;
+ for(File ff : fs){
+ if(ff != null){
+ fileName = ff.getName() ;
+ if(fileName.startsWith(rtuAddr)){
+ String[] ss = new String[3] ;
+ ss[0] = ff.getName() ;
+ ss[1] = formatFileSize(ff.length()) ;
+ ss[2] = DateTime.yyyy_MM_dd_HH_mm_ss(new Date(ff.lastModified())) ;
+ map.put(ss[0], ss) ;
+ }
+ }
+ }
+ }
+ }
+ return map ;
+ }
+
+ /**
+ * 寰楀埌涓�涓棩蹇楁枃浠�
+ * @param fileName 鏂囦欢鍚嶇О
+ */
+ @SuppressWarnings("unused")
+ public File getLogFile(String fileName){
+ return new File(ResourceUnit.confVo.rtuLogDir + fileName);
+ }
+
+ private String formatFileSize(long fileS) {//閫氳繃File鐨� length()鏂规硶鏁板�间紶鍏�
+ DecimalFormat df = new DecimalFormat("#.00");
+ String fileSizeString;
+ if (fileS < 1024) {
+ fileSizeString = df.format((double) fileS) + " B";
+ } else if (fileS < 1048576) {
+ fileSizeString = df.format((double) fileS / 1024) + " K";
+ } else if (fileS < 1073741824) {
+ fileSizeString = df.format((double) fileS / 1048576) + " M";
+ } else {
+ fileSizeString = df.format((double) fileS / 1073741824) + " G";
+ }
+ return fileSizeString;
+ }
+
+
+
+}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/resource/ResourceUnitAdapter.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/resource/ResourceUnitAdapter.java
new file mode 100644
index 0000000..4a7210f
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/resource/ResourceUnitAdapter.java
@@ -0,0 +1,9 @@
+package com.dy.aceMw.resource;
+
+import com.dy.common.mw.UnitAdapterInterface;
+
+public interface ResourceUnitAdapter extends UnitAdapterInterface {
+
+ ResourceUnitConfigVo getConfig() ;
+
+}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/resource/ResourceUnitConfigVo.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/resource/ResourceUnitConfigVo.java
new file mode 100644
index 0000000..8f634f3
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/resource/ResourceUnitConfigVo.java
@@ -0,0 +1,27 @@
+package com.dy.aceMw.resource;
+
+
+public class ResourceUnitConfigVo {
+
+ public Boolean enableSpringHibernate ;
+
+ //RTU鏃ュ織鏂囦欢瀛樺偍鐩綍(鐩稿鐩綍)
+ public String rtuLogDir ;
+ //RTU鏃ュ織鏂囦欢鏈�澶у瓧鑺傛暟(KB)
+ public int rtuLogFileMaxSize ;
+ //RTU鏃ュ織鏂囦欢鏈�澶ф枃浠舵暟
+ public int rtuLogFileMaxCount ;
+
+ //Rtu鐘舵�佺洃瑙嗛棿闅�(鍒嗛挓)
+ @SuppressWarnings("unused")
+ public int monitorInterval = 2 ;
+
+ //Rtu鐘舵�佸瓨鏁版嵁搴撻棿闅�(鍒嗛挓)
+ @SuppressWarnings("unused")
+ public int saveDbInterval = 10 ;
+
+ //Rtu鐘舵�佹棤鏁版嵁涓婁紶杈惧埌姝ゅ�硷紝鍒欒涓轰笉鍦ㄧ嚎浜�(鍒嗛挓)
+ @SuppressWarnings("unused")
+ public int noUpDataLimitTime = 30 ;
+
+}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/resource/rtuLog/RtuLogManager.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/resource/rtuLog/RtuLogManager.java
new file mode 100644
index 0000000..60704e6
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/resource/rtuLog/RtuLogManager.java
@@ -0,0 +1,242 @@
+package com.dy.aceMw.resource.rtuLog;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+
+import com.dy.aceMw.resource.ResourceUnit;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import com.dy.common.util.DateTime;
+import com.dy.common.queue.Queue;
+import com.dy.common.threadPool.ThreadPool;
+import com.dy.common.threadPool.TreadPoolFactory;
+
+public class RtuLogManager {
+
+ private static final Logger log = LogManager.getLogger(RtuLogManager.class) ;
+
+ private static final RtuLogManager instance = new RtuLogManager() ;
+
+ private static final Queue logQueue = new Queue("rtuLogQueue") ;
+
+ private static final Integer maxNodeAddWorkThread = 500 ;//缂撳瓨杈惧埌杩欎釜鏁伴噺锛屽皢澧炲姞绾跨▼
+ private static final Integer maxWorkThread = 5 ;//鏈�澶у伐浣滅嚎绋嬫暟
+ private static int workThread = 0 ;//宸ヤ綔绾跨▼鏁�
+
+ private RtuLogManager(){
+ }
+ @SuppressWarnings("unused")
+ public static RtuLogManager getInstance(){
+ return instance ;
+ }
+
+ /**
+ * 璁剧疆闃熷垪闄愬埗
+ * @param warnSize 闃熷垪鑺傜偣鏁伴噺 鎶ヨ鍊�
+ * @param maxSize 闃熷垪鑺傜偣鏁伴噺 鏈�澶у��
+ */
+ @SuppressWarnings("unused")
+ public void setQueueLimit(int warnSize, int maxSize){
+ logQueue.setLimit(warnSize, maxSize);
+ }
+
+ /**
+ * 鍔犲叆Rtu鏃ュ織鏁版嵁
+ * 鍦ㄥ崟绾跨▼涓墽琛�
+ * @param logNodeObj 鏃ュ織闃熷垪鑺傜偣瀵硅薄
+ * @throws Exception 寮傚父
+ */
+ public void pushRtuLog(RtuLogNode logNodeObj) throws Exception{
+ logQueue.pushTail(logNodeObj);
+ //鍦ㄥ崟绾跨▼涓墽琛�
+ if(workThread <= 0){
+ startWorkThread() ;
+ }
+ }
+
+ /**
+ * 鍚姩宸ヤ綔绾跨▼宸ヤ綔
+ */
+ private void startWorkThread(){
+ workThread ++ ;
+ try {
+ TreadPoolFactory.getThreadPoolShort().putJob(new ThreadPool.Job() {
+ public void execute() {
+ while(logQueue.size() > 0){
+ RtuLogNode node ;
+ if(workThread > 1){
+ synchronized(logQueue){
+ node = (RtuLogNode)logQueue.pop() ;
+ }
+ }else{
+ node = (RtuLogNode)logQueue.pop() ;
+ }
+ if(node != null){
+ //鏃ュ織鏂囦欢瀛樺偍
+ log(node.rtuAddr, node.content) ;
+ }
+
+ if(RtuLogManager.logQueue.size() > maxNodeAddWorkThread){
+ if(workThread < maxWorkThread){
+ synchronized(maxWorkThread){
+ if(workThread < maxWorkThread){
+ startWorkThread() ;
+ }
+ }
+ }
+ }
+ }
+ workThread -- ;
+ if(workThread < 0){
+ workThread = 0 ;
+ }
+ }
+
+
+ /*
+ * 寮哄埗鍋滄execute鏂规硶涓墽琛岀殑姝诲惊鐜伐浣�
+ */
+ @Override
+ public void destroy() {
+ //鍐嶅皢鍚姩锛岄槻姝㈡棤绾跨▼澶勭悊浜�
+ startWorkThread() ;
+ }
+
+ /**
+ * execute鏂规硶涓皟鐢ㄦ鏂规硶鍒ゆ柇鏄惁缁撴潫姝诲惊鐜伐浣�
+ */
+ @Override
+ public boolean isDestroy() {
+ return false;
+ }
+ }) ;
+ }catch(Exception e){
+ log.error(e);
+ workThread -- ;
+ if(workThread < 0){
+ workThread = 0 ;
+ }
+ }
+ }
+
+ /**
+ * 璁板綍Rtu鏃ュ織
+ * @param rtuAddr 鎺у埗鍣ㄥ湴鍧�
+ * @param conent 鏃ュ織鍐呭
+ */
+ private void log(String rtuAddr , String conent){
+ File f = getFileForWrite(ResourceUnit.confVo.rtuLogDir , rtuAddr.trim()) ;
+ if(f != null){
+ writeLog(f , DateTime.yyyy_MM_dd_HH_mm_ss() + " " + conent) ;
+ }else{
+ log.error("涓嶈兘寰楀埌鍦板潃涓�:" + rtuAddr + "鐨凴tu鏃ュ織鏂囦欢锛�") ;
+ }
+ }
+
+ /**
+ * 寰楀埌鏃ュ織鏂囦欢
+ * @param path 鏂囦欢璺緞
+ * @param rtuAddr 鎺у埗鍣ㄥ湴鍧�
+ * @return 鏃ュ織鏂囦欢
+ */
+ private File getFileForWrite(String path , String rtuAddr) {
+ File dir = new File(path) ;
+ if(!dir.exists()){
+ if(!dir.mkdirs()){
+ return null ;
+ }
+ }
+ File f = new File(path + rtuAddr + ".log");
+ FileInputStream in = null;
+ try {
+ if (f.exists()) {
+ in = new FileInputStream(f);
+ if(in.available() >= ResourceUnit.confVo.rtuLogFileMaxSize){
+ in.close() ;//蹇呴』鍔犱笂姝よ鍙�
+ File oldestLog = new File(path + rtuAddr + ".log." + (ResourceUnit.confVo.rtuLogFileMaxCount - 1)) ;
+ if(oldestLog.exists()){
+ if(!oldestLog.delete()){
+ return null ;
+ }
+ }
+ for(int i = (ResourceUnit.confVo.rtuLogFileMaxCount - 2) ; i > 0 ; i--){
+ File oldLog = new File(path + rtuAddr + ".log." + i) ;
+ if(oldLog.exists()){
+ if(!oldLog.renameTo(new File(path + rtuAddr + ".log." + (i + 1)))){
+ return null ;
+ }
+ if(!oldLog.delete()){
+ return null ;
+ }
+ }
+ }
+ if(!f.renameTo(new File(path + rtuAddr + ".log." + 1))){
+ return null ;
+ }
+ if(!f.delete()){
+ return null ;
+ }
+
+ f = new File(path + rtuAddr + ".log");
+ if(!f.exists()){
+ if(f.createNewFile()){
+ return f ;
+ }else{
+ return null ;
+ }
+ }
+ }else{
+ return f ;
+ }
+ }else{
+ if(f.createNewFile()){
+ return f ;
+ }else{
+ return null ;
+ }
+ }
+ } catch (Exception e) {
+ log.error("寰楀埌Rtu(" + rtuAddr + ")鏃ュ織鏂囦欢鏃跺嚭閿�" , e) ;
+ }finally{
+ try {
+ if (in != null) {
+ in.close();
+ }
+ } catch (IOException e) {
+ log.error("鍏抽棴Rtu鏃ュ織鏂囦欢(" + f.getName() + ")璇诲叆娴佹椂鍑洪敊" , e) ;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * 鍚戞枃浠朵腑鍐欏叆鏃ュ織
+ * @param f 鏂囦欢
+ * @param conent 鏃ュ織鍐呭
+ */
+ private void writeLog(File f, String conent) {
+ if (f.exists()) {
+ BufferedWriter out = null;
+ try {
+ out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f, true))); // 鍙傛暟涓簍rue锛岃〃绀鸿拷鍔犲唴瀹�
+ out.write(conent + "\n");
+ } catch (Exception e) {
+ log.error("鍐欏叆Rtu鏃ュ織鏂囦欢(" + f.getName() + ")鏃跺嚭閿�" , e) ;
+ } finally {
+ try {
+ if (out != null) {
+ out.close();
+ }
+ } catch (IOException e) {
+ log.error("鍏抽棴Rtu鏃ュ織鏂囦欢(" + f.getName() + ")鍐欏嚭娴佹椂鍑洪敊" , e) ;
+ }
+ }
+ }
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/resource/rtuLog/RtuLogNode.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/resource/rtuLog/RtuLogNode.java
new file mode 100644
index 0000000..c83541e
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/resource/rtuLog/RtuLogNode.java
@@ -0,0 +1,14 @@
+package com.dy.aceMw.resource.rtuLog;
+
+import com.dy.common.queue.NodeObj;
+
+public class RtuLogNode implements NodeObj {
+
+ public String rtuAddr ;
+ public String content ;
+
+ public RtuLogNode(String rtuAddr, String content){
+ this.rtuAddr = rtuAddr ;
+ this.content = content ;
+ }
+}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/ServerProperties.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/ServerProperties.java
new file mode 100644
index 0000000..5ce6d7f
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/ServerProperties.java
@@ -0,0 +1,30 @@
+package com.dy.aceMw.server;
+
+public class ServerProperties {
+
+ //鏄惁涓轰綆鍔熻��
+ public static Boolean isLowPower = false ;
+ //鍦ㄦ敮鎸佸閫氫俊鍗忚鏃讹紝鍙湁RTU涓婄嚎浜嗭紝鎵嶈兘璇嗗埆鍑鸿RTU瀹為檯鐢ㄧ殑閫氫俊鍗忚锛岃繘鑰岀敤姝ゅ崗璁В鏋愪笂琛屾暟鎹強鏋勯�犱笅琛屽懡浠ゃ��
+ //濡傛灉RTU鏈浘涓婄嚎锛堥�氫俊涓棿浠跺惎鍔ㄥ悗璇TU鏈浘涓婄嚎锛夛紝閭d箞鍦ㄥ悜瀹冨彂閫佷笅琛屽懡浠ゆ椂锛屼笉鑳藉垽鏂嚭鍏堕噰鐢ㄧ殑鍗忚锛屼篃涓嶈兘鏋勯�犲懡浠わ紝灏ゅ叾鏄綆鍔熻�楁儏鍐典笅锛屼笉涓婄嚎鏄甯哥幇璞°��
+ // 褰撳彧鏈変竴涓崗璁儏鍐典笅锛屽湪RTU鏈浘涓婄嚎鏃讹紝涔熻兘鐢ㄦ鍗忚鏋勯�犲懡浠ゅ苟缂撳瓨涓嬫潵锛屽挨鍏堕�傚悎浣庡姛鑰楁儏鍐点��
+ //onlyOne=true: 閫氫俊涓棿浠跺綋鍓嶅彧鏈変竴涓崗璁�
+ public static Boolean onlyOneProtocol = false ;
+ //涓嬭鍛戒护鍏佽鍙戦�佺殑鏈�澶ф鏁癤锛屽嵆鍏佽閲嶅彂X-1
+ public static Byte downComandMaxResendTimes = 3 ;
+
+ //閽堝涓�涓猂TU锛屼笅鍙戝懡浠ょ殑鏃堕棿闂撮殧
+ public static Long commandSendInterval = 5 * 1000L ;
+
+ //鍛戒护宸茬粡鍙戦�佽揪鏈�澶ф鏁帮紝浠嶆湭鏀跺埌鍛戒护缁撴灉锛岄渶瑕佸湪缂撳瓨缁х画绛夊緟锛屽叾绛夊緟鏈�澶ф椂闀�
+ public static Long cachWaitResultTimeout = 15 * 1000L ;
+
+ //涓嶅湪绾跨紦瀛樼殑鍛戒护鏈�澶х紦瀛樻椂闀�
+ public static Long offLineCachTimeout = 60 * 1000L ;
+
+ //TCP涓婅鏁版嵁鏃跺埢缂撳瓨鏃堕暱锛屽綋杈惧埌鏃堕暱鏃讹紝TCP涓婅鏁版嵁鏃跺埢琚竻绌猴紝閲囩敤TCP涓婅鏁版嵁鏃跺埢鐩殑鏄紝闃绘涓婃暟鎹悓鏃朵笅鍙戞暟鎹紝鍥犱负RTU澶勭悊涓嶈繃鏉�
+ public static Long lastUpDataTimeLive = 1 * 1000L ;
+
+ //鏁版嵁搴撴暟鎹甶d鐢熸垚鍣ㄧ殑id鍚庣紑锛�0鏄粯璁ょ殑鍚庣紑锛屼竴鑸瑆eb绯荤粺搴旂敤锛屾暟鎹腑闂翠欢id鍚庣紑澶т簬绛変簬1
+ public static Integer dbDataIdSuffix = 1 ;
+
+}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/MidResultActionError.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/MidResultActionError.java
new file mode 100644
index 0000000..a7e192d
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/MidResultActionError.java
@@ -0,0 +1,26 @@
+package com.dy.aceMw.server.forTcp;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import com.dy.common.mw.protocol.MidResult;
+import com.dy.common.mw.protocol.MidResultError;
+import com.dy.common.mw.protocol.MidResultAction;
+
+public class MidResultActionError implements MidResultAction {
+
+ private static Logger log = LogManager.getLogger(MidResultActionError.class.getName());
+
+
+ @Override
+ public void doAction(MidResult result) {
+ if(result != null && result instanceof MidResultError){
+ MidResultError rs = (MidResultError)result ;
+ log.error("瑙f瀽鎴栨瀯閫�" + (rs.protocolName==null?"":("閫氫俊鍗忚" + rs.protocolName + "鐨�")) + "RTU" + (rs.rtuAddr==null?"":("(鍦板潃" + rs.rtuAddr + ")" )) + "鏁版嵁鍑洪敊" + (rs.message == null?"":("锛�" + rs.message)));
+ if(rs.e != null){
+ log.error(rs.e);
+ rs.e.printStackTrace();
+ }
+ }
+ }
+}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/MidResultActionFromRtu.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/MidResultActionFromRtu.java
new file mode 100644
index 0000000..f629bc9
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/MidResultActionFromRtu.java
@@ -0,0 +1,57 @@
+package com.dy.aceMw.server.forTcp;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import com.dy.aceMw.server.forMq.ToMqMessageCach;
+import com.dy.common.mw.protocol.MidResult;
+import com.dy.common.mw.protocol.MidResultAction;
+import com.dy.common.mw.protocol.MidResultFromRtu;
+import com.dy.common.mw.protocol.MidResultToRtu;
+import com.dy.common.util.rtuMq.MessageType;
+
+public class MidResultActionFromRtu implements MidResultAction {
+
+ private static Logger log = LogManager.getLogger(MidResultActionFromRtu.class) ;
+
+ @Override
+ public void doAction(MidResult result) {
+ if(result != null && result instanceof MidResultFromRtu){
+ //濡傛灉姝ゅ闇�瑕佹洿澶氱殑閫昏緫澶勭悊锛屽彲浠ョ敓鎴愪竴涓换鍔$被锛堝疄鐜癈oreTask锛夊璞¤繘琛屽鐞�
+ //褰撳墠锛屽鐞嗙洿鎺ヨ繘琛�
+ MidResultFromRtu resFromRtu = (MidResultFromRtu)result ;
+ if(!resFromRtu.reportOrResponse_trueOrFalse){
+ //鍛戒护搴旂瓟
+ //姝ゅ瀹炵幇锛屼笌浠ュ墠涓嶄竴鏍凤紝
+ //浠ュ墠瀹炵幇锛氬尮閰嶅懡浠ゆ槸浠庡悗鍚戝墠鍖归厤锛�
+ //褰撳墠瀹炵幇锛屽尮閰嶅懡浠ゆ槸浠庡墠鍚戝悗鍖归厤锛屽師鍥狅細涓句緥锛屽綋鎵归噺涓嬪彂琛ュ彫鍛戒护锛屽鏋滀粠鍚庡尮閰嶏紝鍒欏墠闈㈠懡浠や細涓嬪彂澶氭锛屽嵆涓�涓笂鎶ユ鏁版嵁浼氳ˉ鍙娆�
+ MidResultToRtu resToRtu = TcpDownCommandCach.matchFromHead(resFromRtu) ;
+ if(resToRtu != null){
+ //鍖归厤鍒颁笅鍙戠殑鍛戒护
+ resFromRtu.setCommandId(resToRtu.commandId) ;
+ this.sendResult(false, resFromRtu);
+ }else{
+ this.sendResult(false, resFromRtu);
+ //鏈尮閰嶅埌涓嬪彂鐨勫懡浠わ紝鍛戒护鍦ㄧ紦瀛樺洜瓒呮椂琚竻闄や簡
+ RtuStatusDealer.commandFail2Success(resFromRtu.rtuAddr) ;
+ }
+ }else{
+ //涓诲姩涓婃姤鏁版嵁
+ this.sendResult(true, resFromRtu);
+ }
+ }
+ }
+ private void sendResult(boolean reportOrResponse_trueOrFalse, MidResultFromRtu resFromRtu){
+ try{
+ String json = resFromRtu.data.toJson() ;
+ if(reportOrResponse_trueOrFalse){
+ ToMqMessageCach.cachObj(MessageType.RtuAutoReport, json);
+ }else{
+ ToMqMessageCach.cachObj(MessageType.RtuCmdResponse, json);
+ }
+ }catch(Exception e){
+ log.error(e.getMessage(), e);
+ }
+
+ }
+}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/MidResultActionToRtu.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/MidResultActionToRtu.java
new file mode 100644
index 0000000..33e2417
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/MidResultActionToRtu.java
@@ -0,0 +1,25 @@
+package com.dy.aceMw.server.forTcp;
+
+import org.apache.logging.log4j.*;
+
+import com.dy.common.mw.protocol.MidResult;
+import com.dy.common.mw.protocol.MidResultAction;
+import com.dy.common.mw.protocol.MidResultToRtu;
+
+public class MidResultActionToRtu implements MidResultAction {
+
+ private static Logger log = LogManager.getLogger(MidResultActionToRtu.class.getName()) ;
+
+ @Override
+ public void doAction(MidResult result) {
+ if(result != null && result instanceof MidResultToRtu){
+ try {
+ MidResultToRtu resToRtu = (MidResultToRtu)result ;
+ TcpDownCommandCach.cachCommand(resToRtu);
+ log.info("涓嬭鍛戒护(toRtu)" + resToRtu.downCode + "涓棿缁撴灉宸茬粡鏀惧叆涓嬭鍛戒护缂撳瓨涓�");
+ } catch (Exception e) {
+ log.error(e);
+ }
+ }
+ }
+}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/RtuLogDealer.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/RtuLogDealer.java
new file mode 100644
index 0000000..013c6ad
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/RtuLogDealer.java
@@ -0,0 +1,34 @@
+package com.dy.aceMw.server.forTcp;
+
+import org.apache.logging.log4j.*;
+
+import com.dy.commu.resource.ResourceUnit;
+import com.dy.commu.resource.rtuLog.RtuLogNode;
+
+
+public class RtuLogDealer {
+ private static Logger log = LogManager.getLogger(RtuLogDealer.class.getName()) ;
+ /**
+ * 璁板綍Rtu鏃ュ織
+ * @param rtuAddr
+ * @param content
+ */
+ public static void log(String rtuAddr, String content){
+ if(rtuAddr == null || rtuAddr.trim().equals("")){
+ log.error("涓ラ噸閿欒锛岃褰昍tu鏃ュ織鏃讹紝rtu鍦板潃鏈彁渚涳紒") ;
+ return ;
+ }
+ if(content == null || content.equals("")){
+ log.error("涓ラ噸閿欒锛岃褰昍tu鏃ュ織鏃讹紝鏃ュ織鍐呭鏈彁渚涳紒") ;
+ return ;
+ }
+ RtuLogNode logNode = new RtuLogNode(rtuAddr, content) ;
+
+ ResourceUnit.getInstance().rtuLog(logNode);
+
+ /////////////////////
+ // 鎴栬�呭悜娑堟伅涓棿浠跺彂娑堟伅
+ ////////////////////
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/RtuSessionStatus.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/RtuSessionStatus.java
new file mode 100644
index 0000000..e41bde4
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/RtuSessionStatus.java
@@ -0,0 +1,10 @@
+package com.dy.aceMw.server.forTcp;
+
+public class RtuSessionStatus {
+
+ public String rtuAddr ;
+ public Boolean onTrueOffLine ;//鍦ㄧ嚎鎯呭喌
+ public String ip ;//RTU绔疘P
+ public Integer port ;//RTU绔鍙�
+
+}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/RtuStatusDealer.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/RtuStatusDealer.java
new file mode 100644
index 0000000..a08b459
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/RtuStatusDealer.java
@@ -0,0 +1,146 @@
+package com.dy.aceMw.server.forTcp;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import com.dy.common.mw.protocol.rtuStatus.StCommandResult;
+import com.dy.common.mw.protocol.rtuStatus.StDownData;
+import com.dy.common.mw.protocol.rtuStatus.StOnOffLine;
+import com.dy.common.mw.protocol.rtuStatus.StUpData;
+
+public class RtuStatusDealer {
+ private static Logger log = LogManager.getLogger(RtuStatusDealer.class.getName()) ;
+
+
+ public static void onOffLine(RtuSessionStatus sta){
+ StOnOffLine st = new StOnOffLine() ;
+ st.rtuAddr = sta.rtuAddr ;
+ st.onOff_trueFalse = sta.onTrueOffLine ;
+ st.ip = sta.ip ;
+ st.port = sta.port ;
+
+// if(member == null){
+// log.error("鍑洪敊锛屾湭鑳藉緱鍒板鐞哛TU锛堝湴鍧�涓�" + sta.rtuAddr + "锛夌姸鎬佹暟鎹殑鏁版嵁涓棿浠讹紝鍙兘鏁版嵁涓棿浠舵湭鍚姩鎴栬劚绂荤殑闆嗙兢锛�");
+// }else{
+// log.info("閫氱煡鏁版嵁涓棿浠讹紙" + member.toString() + "锛夛紝RTU锛堝湴鍧�涓�" + sta.rtuAddr + "锛夊湪绾匡紒");
+// new JgIoHandler().sendP2P(member, st);
+// }
+ }
+
+ public static void onLine(String rtuAddr, String ip, Integer port){
+ StOnOffLine st = new StOnOffLine() ;
+ st.rtuAddr = rtuAddr ;
+ st.onOff_trueFalse = true ;
+ st.ip = ip ;
+ st.port = port ;
+
+// Address member = JgUnit.getInstance().getJgMembers().getDataMwMemberByRtuAddr(rtuAddr) ;
+// if(member == null){
+// log.error("鍑洪敊锛屾湭鑳藉緱鍒板鐞哛TU锛堝湴鍧�涓�" + rtuAddr + "锛夌姸鎬佹暟鎹殑鏁版嵁涓棿浠讹紝鍙兘鏁版嵁涓棿浠舵湭鍚姩鎴栬劚绂荤殑闆嗙兢锛�");
+// }else{
+// log.info("閫氱煡鏁版嵁涓棿浠讹紙" + member.toString() + "锛夛紝RTU锛堝湴鍧�涓�" + rtuAddr + "锛夊湪绾匡紒");
+// new JgIoHandler().sendP2P(member, st);
+// }
+ }
+
+ public static void offLine(String rtuAddr){
+ StOnOffLine st = new StOnOffLine() ;
+ st.rtuAddr = rtuAddr ;
+ st.onOff_trueFalse = false ;
+
+// Address member = JgUnit.getInstance().getJgMembers().getDataMwMemberByRtuAddr(rtuAddr) ;
+// if(member == null){
+// log.error("鍑洪敊锛屾湭鑳藉緱鍒板鐞哛TU锛堝湴鍧�涓�" + rtuAddr + "锛夌姸鎬佹暟鎹殑鏁版嵁涓棿浠讹紝鍙兘鏁版嵁涓棿浠舵湭鍚姩鎴栬劚绂荤殑闆嗙兢锛�");
+// }else{
+// log.info("閫氱煡鏁版嵁涓棿浠讹紙" + member.toString() + "锛夛紝RTU锛堝湴鍧�涓�" + rtuAddr + "锛夌绾匡紒");
+// new JgIoHandler().sendP2P(member, st);
+// }
+ }
+
+ public static void upData(String rtuAddr, Integer bufferLen){
+ StUpData st = new StUpData() ;
+ st.rtuAddr = rtuAddr ;
+ st.upBufferLen = bufferLen ;
+ st.isReport = false ;
+
+// Address member = JgUnit.getInstance().getJgMembers().getDataMwMemberByRtuAddr(rtuAddr) ;
+// if(member == null){
+// log.error("鍑洪敊锛屾湭鑳藉緱鍒板鐞哛TU锛堝湴鍧�涓�" + rtuAddr + "锛夌姸鎬佹暟鎹殑鏁版嵁涓棿浠讹紝鍙兘鏁版嵁涓棿浠舵湭鍚姩鎴栬劚绂荤殑闆嗙兢锛�");
+// }else{
+// log.info("閫氱煡鏁版嵁涓棿浠讹紙" + member.toString() + "锛夛紝RTU锛堝湴鍧�涓�" + rtuAddr + "锛変笂琛屾暟鎹紒");
+// new JgIoHandler().sendP2P(member, st);
+// }
+ }
+
+ public static void upReport(String rtuAddr, Integer bufferLen){
+ StUpData st = new StUpData() ;
+ st.rtuAddr = rtuAddr ;
+ st.upBufferLen = bufferLen ;
+ st.isReport = true ;
+
+// Address member = JgUnit.getInstance().getJgMembers().getDataMwMemberByRtuAddr(rtuAddr) ;
+// if(member == null){
+// log.error("鍑洪敊锛屾湭鑳藉緱鍒板鐞哛TU锛堝湴鍧�涓�" + rtuAddr + "锛夌姸鎬佹暟鎹殑鏁版嵁涓棿浠讹紝鍙兘鏁版嵁涓棿浠舵湭鍚姩鎴栬劚绂荤殑闆嗙兢锛�");
+// }else{
+// log.info("閫氱煡鏁版嵁涓棿浠讹紙" + member.toString() + "锛夛紝RTU锛堝湴鍧�涓�" + rtuAddr + "锛変笂鎶ユ暟鎹紒");
+// new JgIoHandler().sendP2P(member, st);
+// }
+ }
+
+ public static void downData(String rtuAddr, Integer bufferLen){
+ StDownData st = new StDownData() ;
+ st.rtuAddr = rtuAddr ;
+ st.downBufferLen = bufferLen ;
+
+// Address member = JgUnit.getInstance().getJgMembers().getDataMwMemberByRtuAddr(rtuAddr) ;
+// if(member == null){
+// log.error("鍑洪敊锛屾湭鑳藉緱鍒板鐞哛TU锛堝湴鍧�涓�" + rtuAddr + "锛夌姸鎬佹暟鎹殑鏁版嵁涓棿浠讹紝鍙兘鏁版嵁涓棿浠舵湭鍚姩鎴栬劚绂荤殑闆嗙兢锛�");
+// }else{
+// log.info("閫氱煡鏁版嵁涓棿浠讹紙" + member.toString() + "锛夛紝RTU锛堝湴鍧�涓�" + rtuAddr + "锛変笅琛屾暟鎹紒");
+// new JgIoHandler().sendP2P(member, st);
+// }
+ }
+
+ public static void commandSuccess(String rtuAddr){
+ StCommandResult st = new StCommandResult() ;
+ st.rtuAddr = rtuAddr ;
+ st.isSuccess = true ;
+
+// Address member = JgUnit.getInstance().getJgMembers().getDataMwMemberByRtuAddr(rtuAddr) ;
+// if(member == null){
+// log.error("鍑洪敊锛屾湭鑳藉緱鍒板鐞哛TU锛堝湴鍧�涓�" + rtuAddr + "锛夌姸鎬佹暟鎹殑鏁版嵁涓棿浠讹紝鍙兘鏁版嵁涓棿浠舵湭鍚姩鎴栬劚绂荤殑闆嗙兢锛�");
+// }else{
+// log.info("閫氱煡鏁版嵁涓棿浠讹紙" + member.toString() + "锛夛紝RTU锛堝湴鍧�涓�" + rtuAddr + "锛夊懡浠ゆ垚鍔燂紒");
+// new JgIoHandler().sendP2P(member, st);
+// }
+ }
+
+ public static void commandFailure(String rtuAddr){
+ StCommandResult st = new StCommandResult() ;
+ st.rtuAddr = rtuAddr ;
+ st.isSuccess = false ;
+
+// Address member = JgUnit.getInstance().getJgMembers().getDataMwMemberByRtuAddr(rtuAddr) ;
+// if(member == null){
+// log.error("鍑洪敊锛屾湭鑳藉緱鍒板鐞哛TU锛堝湴鍧�涓�" + rtuAddr + "锛夌姸鎬佹暟鎹殑鏁版嵁涓棿浠讹紝鍙兘鏁版嵁涓棿浠舵湭鍚姩鎴栬劚绂荤殑闆嗙兢锛�");
+// }else{
+// log.info("閫氱煡鏁版嵁涓棿浠讹紙" + member.toString() + "锛夛紝RTU锛堝湴鍧�涓�" + rtuAddr + "锛夊懡浠ゅけ璐ワ紒");
+// new JgIoHandler().sendP2P(member, st);
+// }
+ }
+
+ public static void commandFail2Success(String rtuAddr){
+ StCommandResult st = new StCommandResult() ;
+ st.rtuAddr = rtuAddr ;
+ st.fail2Success = true ;
+
+// Address member = JgUnit.getInstance().getJgMembers().getDataMwMemberByRtuAddr(rtuAddr) ;
+// if(member == null){
+// log.error("鍑洪敊锛屾湭鑳藉緱鍒板鐞哛TU锛堝湴鍧�涓�" + rtuAddr + "锛夌姸鎬佹暟鎹殑鏁版嵁涓棿浠讹紝鍙兘鏁版嵁涓棿浠舵湭鍚姩鎴栬劚绂荤殑闆嗙兢锛�");
+// }else{
+// log.info("閫氱煡鏁版嵁涓棿浠讹紙" + member.toString() + "锛夛紝RTU锛堝湴鍧�涓�" + rtuAddr + "锛夊懡浠ょ敱澶辫触杞垚鍔燂紒");
+// new JgIoHandler().sendP2P(member, st);
+// }
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpDownCommandCach.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpDownCommandCach.java
new file mode 100644
index 0000000..fcdf427
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpDownCommandCach.java
@@ -0,0 +1,129 @@
+package com.dy.aceMw.server.forTcp;
+
+
+import com.dy.common.queue.Node;
+import com.dy.common.queue.Queue;
+import com.dy.common.mw.protocol.MidResultFromRtu;
+import com.dy.common.mw.protocol.MidResultToRtu;
+import com.dy.aceMw.server.ServerProperties;
+
+/**
+ * 闈炵嚎绋嬪畨鍏ㄧ殑锛屽彧鑳藉湪鍗曠嚎绋嬩腑杩愯
+ */
+public class TcpDownCommandCach {
+
+ //TCP涓嬭鍛戒护缂撳瓨闃熷垪
+ private static Queue cachQueue = new Queue("tcpDownComandQueue") ;
+
+ private static TcpDownCommandCach instance = new TcpDownCommandCach() ;
+
+ private TcpDownCommandCach(){
+ cachQueue.setLimit(990000, 1000000);
+ }
+
+ public static TcpDownCommandCach getInstance(){
+ return instance ;
+ }
+
+ /**
+ * 缂撳瓨鍛戒护
+ * @param result
+ * @throws Exception
+ */
+ public static void cachCommand(MidResultToRtu result) throws Exception{
+ if(result != null){
+ if(result.maxSendTimes == null){
+ //璁剧疆鏈�澶у彂閫佹鏁�
+ result.maxSendTimes = ServerProperties.downComandMaxResendTimes ;
+ }
+ if(result.isSendFirst){
+ cachQueue.pushHead(new TcpDownCommandObj(result));
+ }else{
+ cachQueue.pushTail(new TcpDownCommandObj(result));
+ }
+ }
+ }
+
+ /**
+ * 鍖归厤鍛戒护缁撴灉
+ * @param rsFromRtu
+ * @return
+ */
+ public static MidResultToRtu matchFromHead(MidResultFromRtu rsFromRtu){
+ MidResultToRtu res = null ;
+ TcpDownCommandObj obj = null ;
+ Node node = cachQueue.getFirstNode() ;
+ while(node != null && node.obj != null){
+ obj = (TcpDownCommandObj)node.obj;
+ res = obj.result ;
+ if(res != null
+ && res.rtuAddr.equals(rsFromRtu.rtuAddr)
+ && res.downCode.equals(rsFromRtu.upCode)){
+ obj.onceReceivedResult = true ;//鏍囪瘑宸茬粡鏀跺埌鍛戒护缁撴灉
+ return res ;
+ }else{
+ node = node.pre ;
+ }
+ }
+
+ return null ;
+ }
+
+ /**
+ * 鍖归厤鍛戒护缁撴灉
+ * @param rsFromRtu
+ * @return
+ */
+ public static MidResultToRtu matchFromTail(MidResultFromRtu rsFromRtu){
+ MidResultToRtu res = null ;
+ TcpDownCommandObj obj = null ;
+ Node node = cachQueue.getLastNode() ;
+ while(node != null && node.obj != null){
+ obj = (TcpDownCommandObj)node.obj;
+ res = obj.result ;
+ if(res != null
+ && res.rtuAddr.equals(rsFromRtu.rtuAddr)
+ && res.downCode.equals(rsFromRtu.upCode)){
+ obj.onceReceivedResult = true ;//鏍囪瘑宸茬粡鏀跺埌鍛戒护缁撴灉
+ return res ;
+ }else{
+ node = node.pre ;
+ }
+ }
+
+ return null ;
+ }
+
+ /**
+ * 寰楀埌绗竴涓妭鐐�
+ * @return
+ */
+ public static Node getFirstQueueNode(){
+ return cachQueue.getFirstNode() ;
+ }
+
+ /**
+ * 寰楀埌鏈�鍚庝竴涓妭鐐�
+ * @return
+ */
+ public static Node getLastQueueNode(){
+ return cachQueue.getLastNode() ;
+ }
+
+ /**
+ * 绉婚櫎鑺傜偣
+ * @param node
+ */
+ public static void removeNode(Node node){
+ cachQueue.remove(node);
+ }
+
+ /**
+ * 缂撳瓨鐨勮妭鐐规暟
+ * @param node
+ */
+ public static Integer size(){
+ return cachQueue.size() ;
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpDownCommandObj.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpDownCommandObj.java
new file mode 100644
index 0000000..40dad55
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpDownCommandObj.java
@@ -0,0 +1,98 @@
+package com.dy.aceMw.server.forTcp;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import com.dy.common.queue.NodeObj;
+import com.dy.common.mw.protocol.MidResultToRtu;
+import com.dy.aceMw.server.ServerProperties;
+
+public class TcpDownCommandObj implements NodeObj{
+
+ private static Logger log = LogManager.getLogger(TcpDownCommandObj.class.getName());
+
+ public MidResultToRtu result ;//涓嬭鍛戒护
+ public Long cachTime ;//缂撳瓨鏃跺埢
+ public Long lastSendStamp ;//涓婃鍙戦�佹椂鍒�
+ public byte sendedTimes ;//宸茬粡鍙戦�佹鏁�
+ public boolean onceReceivedResult ;//宸茬粡鏀跺埌鍛戒护搴旂瓟
+
+ public TcpDownCommandObj(MidResultToRtu result){
+ this.result = result ;
+ this.cachTime = System.currentTimeMillis() ;
+ this.lastSendStamp = 0L ;
+ this.sendedTimes = 0 ;
+ this.onceReceivedResult = false ;
+ }
+
+ /**
+ * 鑷繁澶勭悊鑷繁
+ * @param now
+ * @return
+ */
+ public boolean dealSelf(Long now){
+ boolean removeNodeFromCach = false ;
+ if(this.onceReceivedResult){
+ //宸茬粡鏀跺埌鍛戒护缁撴灉
+ removeNodeFromCach = true ;
+ //璁板綍鐘舵��
+ RtuStatusDealer.commandSuccess(this.result.rtuAddr);
+ return removeNodeFromCach ;
+ }
+ if(this.sendedTimes >= this.result.maxSendTimes){
+ //鍙戦�佹鏁拌揪鍒版渶澶у��
+ if(now - this.lastSendStamp >= ServerProperties.cachWaitResultTimeout){
+ //瓒呮椂
+ removeNodeFromCach = true ;
+ //璁板綍鐘舵��
+ RtuStatusDealer.commandFailure(this.result.rtuAddr);
+ }
+ return removeNodeFromCach ;
+ }
+
+ TcpSession tcpSe = TcpSessionCach.getTcpSession(this.result.rtuAddr) ;
+ Boolean flag = TcpSessionCach.isConnect(this.result.rtuAddr) ;
+ if(tcpSe == null || flag == null || !flag.booleanValue()){
+ //鏈浘涓婄嚎鎴栦笉鍦ㄧ嚎
+ if(!this.result.isCachForOffLine){
+ //涓嶅湪绾垮懡浠や笉缂撳瓨
+ removeNodeFromCach = true ;
+ }else{
+ //涓嶅湪绾垮懡浠ょ紦瀛�
+ if(now - this.cachTime >= ServerProperties.offLineCachTimeout){
+ //缂撳瓨瓒呮椂
+ removeNodeFromCach = true ;
+ }
+ }
+ return removeNodeFromCach ;
+ }
+
+ if(tcpSe.lastUpDataTime != null){
+ //璇存槑涓婅鏁版嵁鏃跺埢鏈夋晥锛屽嵆姝ゆ椂绂讳笂琛屾暟鎹椂鍒诲お杩戯紝杩樹笉鑳戒笅琛屾暟鎹紝寤惰繜涓�涓�
+ return false ;
+ }
+
+ Long lastSendStamp = tcpSe.lastDownComTime ;
+ if(lastSendStamp == null || (now - lastSendStamp >= ServerProperties.commandSendInterval)){
+ //鏈敹鍒板懡浠ょ粨鏋滐紝鏈揪鍒版渶澶у彂閫佹鏁帮紝RTU鍦ㄧ嚎锛岃秴杩囧懡浠ら棿涓嬪彂闂撮殧锛屼互涓婃弧瓒冲彂閫佸懡浠ゆ潯浠讹紝鎵ц鍙戦�佸懡浠�
+ tcpSe.ioSession.write(this.result.downBuffer) ;
+ tcpSe.lastDownComTime = now ;
+ if(!this.result.hasResponse){
+ //鏃犲簲绛�
+ removeNodeFromCach = true ;
+ }
+
+ this.sendedTimes++ ;
+ this.lastSendStamp = now ;
+
+ //璁板綍鏃ュ織
+ RtuLogDealer.log(this.result.rtuAddr, "涓嬭鏁版嵁 " + this.result.downCode + "锛�" + this.result.downBufHex);
+ //璁板綍鐘舵��
+ RtuStatusDealer.downData(this.result.rtuAddr, this.result.downBuffer.length);
+
+ log.info("涓嬭RTU锛堝湴鍧�=" + this.result.rtuAddr + "锛夊懡浠わ紙鍔熻兘鐮�=" + this.result.downCode + "锛� " + this.result.downBufHex ) ;
+ }
+
+ return removeNodeFromCach ;
+ }
+}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpIoSessionCallback.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpIoSessionCallback.java
new file mode 100644
index 0000000..e120d56
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpIoSessionCallback.java
@@ -0,0 +1,81 @@
+package com.dy.aceMw.server.forTcp;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.mina.core.session.IoSession;
+
+import com.dy.common.mw.channel.tcp.TcpIoSessionAttrIdIsRtuAddr;
+import com.dy.common.mw.channel.tcp.TcpIoSessionEventCallback;
+import com.dy.common.mw.core.CoreUnit;
+import com.dy.aceMw.server.tasks.RtuUpTask;
+
+public class TcpIoSessionCallback implements TcpIoSessionEventCallback{
+
+ private static Logger log = LogManager.getLogger(TcpIoSessionCallback.class.getName());
+
+ /**
+ * 缃戠粶杩炴帴鎵撳紑
+ */
+ public void sessionOpened(IoSession session) throws Exception {
+ log.info("缃戠粶杩炴帴寤虹珛锛岀粓绔綉鍧�鏄細" + session.getRemoteAddress().toString()) ;
+ }
+
+ /**
+ * 缃戠粶杩炴帴鍏抽棴
+ */
+ @Override
+ public void sessionClosed(IoSession session) throws Exception {
+ if(session != null){
+ String rtuAddr = (String)session.getAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrIdKey) ;
+
+ if(rtuAddr != null){
+ //璁板綍鐘舵��
+ RtuStatusDealer.offLine(rtuAddr);
+ }
+
+ log.info("缃戠粶杩炴帴鍏抽棴锛�"
+ + (rtuAddr==null?"":("缁堢鍦板潃鏄細" + rtuAddr))) ;
+ //+ (session==null?"":(session.getRemoteAddress() == null?"":(session.getRemoteAddress().toString()==null?"":("缁堢缃戝潃鏄細" + session.getRemoteAddress().toString()))))) ;
+ }
+ }
+ /**
+ * 鍙戠敓寮傚父
+ */
+ public void exceptionCaught(IoSession session, Throwable cause) throws Exception {
+ if(session != null && cause != null){
+ String rtuAddr = (String)session.getAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrIdKey) ;
+ log.error("缃戠粶浼氳瘽鍙戠敓寮傚父锛�"
+ + (rtuAddr==null?"":("缁堢鍦板潃鏄細" + rtuAddr))
+ + (session==null?"":(session.getRemoteAddress() != null?("缁堢缃戝潃鏄細" + session.getRemoteAddress().toString()):""))
+ + "\n寮傚父娑堟伅锛�" + cause.getMessage(), cause);
+ }
+ }
+
+ /**
+ * TCP閫氶亾鍙戦�佸畬鏁版嵁鍚庯紝鍥炶皟鐨勬柟娉曪紝杩涜鍚庣画鏁版嵁澶勭悊
+ */
+ public void messageSended(IoSession session, Object message) throws Exception {
+ String rtuAddr = (String)session.getAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrIdKey) ;
+ log.info("缃戠粶鍙戦�佷簡鏁版嵁锛�"
+ + (rtuAddr==null?"":("缁堢鍦板潃鏄細" + rtuAddr))
+ + (session==null?"":(session.getRemoteAddress() != null?("缁堢缃戝潃鏄細" + session.getRemoteAddress().toString()):"")) );
+ }
+
+ /**
+ * TCP閫氶亾鎺ユ敹鍒版暟鎹紝鍥炶皟鐨勬柟娉曪紝杩涜鏁版嵁澶勭悊
+ * 姝ゆ柟娉曡皟鐢ㄥ悗锛屼笂琛屾暟鎹劚绂讳簡NIO绾跨▼锛岃繘鍏ヤ簡鏍稿績绾跨▼
+ */
+ @Override
+ public void messageReceived(IoSession session, Object message)throws Exception {
+ if(session != null && message != null){
+ RtuUpTask task = new RtuUpTask() ;
+ task.data = new Object[]{session, (byte[])message} ;
+ try{
+ CoreUnit.getInstance().pushCoreTask(task);
+ }catch(Exception e){
+ log.error(e.getMessage(), e);
+ }
+ }
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpSession.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpSession.java
new file mode 100644
index 0000000..85ba2bb
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpSession.java
@@ -0,0 +1,12 @@
+package com.dy.aceMw.server.forTcp;
+
+import org.apache.mina.core.session.IoSession;
+
+
+public class TcpSession {
+
+ public IoSession ioSession ;//IoSession瀵硅薄
+ public String protocolName ;//閫氫俊鍗忚鍚嶇О
+ public Long lastDownComTime ;//涓婃涓嬪彂鍛戒护鏃跺埢(姣鏃跺埢 System.currentTimeMillis())
+ public Long lastUpDataTime ;//涓婃鏀跺埌涓婅鏁版嵁鏃跺埢(姣鏃跺埢 System.currentTimeMillis())
+}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpSessionCach.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpSessionCach.java
new file mode 100644
index 0000000..5a97810
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpSessionCach.java
@@ -0,0 +1,202 @@
+package com.dy.aceMw.server.forTcp;
+
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map.Entry;
+
+import org.apache.mina.core.session.IoSession;
+
+import com.dy.aceMw.server.ServerProperties;
+
+
+public class TcpSessionCach {
+
+ /**
+ * 鐢℉ashtable鑰屼笉鐢℉ashMap鍘熷洜锛�
+ * Hashtable绾跨▼瀹夊叏鐨�
+ * HashMap绾跨▼涓嶅畨鍏ㄧ殑
+ * 澶氱嚎绋嬪sessionTable璇诲嚭鎴栧瓨鍏ワ紝鍙兘浜х敓寮傚父
+ * 铏界劧鏄崟涓富绾跨▼锛屼絾鍦↗groups web鎴愬憳鏌ヨ鍦ㄧ嚎鎯呭喌鏃讹紝Jgroups鐨勭嚎绋嬬洿鎺ヤ镜鍏ワ紝浠庤�屽舰鎴愬绾跨▼鐜锛屽绾跨▼閬嶅巻鏃讹紝Map鎴愬憳鏁伴噺鏈夊彉鍖栧氨浼氫骇鐢熷紓甯�
+ */
+ private static Hashtable<String, TcpSession> sessionTable = new Hashtable<String, TcpSession>() ;
+
+ /**
+ * 鍔犲叆鏂扮殑IoSession
+ * @param rtuAddr
+ * @param protocolName
+ * @param ioSession
+ */
+ public static void putNewTcpSession(String rtuAddr, String protocolName, IoSession ioSession){
+ TcpSession tcpSe = sessionTable.get(rtuAddr) ;
+ if(tcpSe == null){
+ tcpSe = new TcpSession() ;
+ tcpSe.protocolName = protocolName ;
+ tcpSe.ioSession = ioSession ;
+ sessionTable.put(rtuAddr, tcpSe) ;
+ }else{
+ tcpSe.ioSession = ioSession ;
+ }
+ }
+
+ /**
+ * 鏇存柊IoSession瀵瑰簲鐨剅tuAddr
+ * @param oldRtuAddr
+ * @param newRtuAddr
+ * @param protocolName
+ * @param ioSession
+ */
+ public static void changeRtuAddr(String oldRtuAddr, String newRtuAddr, String protocolName, IoSession ioSession){
+ TcpSession tcpSe = sessionTable.get(oldRtuAddr) ;
+ if(tcpSe == null){
+ putNewTcpSession(newRtuAddr, protocolName, ioSession) ;
+ }else{
+ sessionTable.remove(oldRtuAddr) ;
+ sessionTable.put(newRtuAddr, tcpSe) ;
+ }
+ }
+
+ /**
+ * 寰楀埌TcpSession
+ * @param rtuAddr
+ * @return
+ */
+ public static TcpSession getTcpSession(String rtuAddr){
+ return sessionTable.get(rtuAddr) ;
+ }
+
+ /**
+ * 寰楀埌Tcp閫氫俊鍗忚鍚嶇О
+ * @param rtuAddr
+ * @return
+ */
+ public static String getTcpProtocolName(String rtuAddr){
+ TcpSession tcpSe = sessionTable.get(rtuAddr) ;
+ if(tcpSe != null){
+ return tcpSe.protocolName ;
+ }else{
+ return null ;
+ }
+ }
+
+ /**
+ * 寰楀埌鎵�鏈夊湪绾挎儏鍐�
+ * @return
+ */
+ public static HashMap<String, Boolean> allOnLine(){
+ HashMap<String, Boolean> map = new HashMap<String, Boolean>();
+ Iterator<Entry<String, TcpSession>> it = sessionTable.entrySet().iterator() ;
+ Entry<String, TcpSession> entry = null ;
+ while(it.hasNext()){
+ entry = it.next() ;
+ map.put(entry.getKey(), entry.getValue().ioSession.isConnected()) ;
+ }
+ return map ;
+ }
+ /**
+ * 寰楀埌鎵�鏈塕TU杩炴帴鐘舵�佹儏鍐�
+ * @return
+ */
+ public static List<RtuSessionStatus> allConnectStauts(){
+ 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
+ * @return
+ */
+ public static Boolean isConnect(String rtuAddr){
+ TcpSession tcpSe = sessionTable.get(rtuAddr) ;
+ if(tcpSe != null){
+ return tcpSe.ioSession.isConnected() ;
+ }
+ return null ;
+ }
+
+ /**
+ * 閫氳繃IoSession杈撳嚭鏁版嵁
+ * @param rtuAddr
+ * @param data
+ * @throws Exception
+ */
+ public static void write(String rtuAddr, byte[] data) throws Exception{
+ TcpSession tcpSe = sessionTable.get(rtuAddr) ;
+ if(tcpSe != null){
+ if(tcpSe.ioSession.isConnected()){
+ tcpSe.ioSession.write(data) ;
+ }else{
+ throw new Exception("Rtu杩炴帴宸茬粡鍏抽棴!") ;
+ }
+ }else{
+ throw new Exception("Rtu鏈浘涓婄嚎!") ;
+ }
+ }
+
+ /**
+ * 璁剧疆涓婅鏁版嵁鏃跺埢
+ * @param rtuAddr
+ */
+ public static void cachUpDataTime(String rtuAddr){
+ TcpSession tcpSe = sessionTable.get(rtuAddr) ;
+ if(tcpSe != null){
+ tcpSe.lastUpDataTime = System.currentTimeMillis() ;
+ }
+ }
+
+ /**
+ * 鏇存柊涓婅鏁版嵁鏃跺埢
+ * 褰撲笂琛屾暟鎹椂鍒诲凡缁忚繃鍘讳竴瀹氭椂闀匡紝涓婅鏁版嵁鏃跺埢娓呯┖
+ */
+ public static void updateUpDataTime(Long now){
+ Iterator<TcpSession> it = sessionTable.values().iterator() ;
+ TcpSession tcpSe = null ;
+ 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-accept/src/main/java/com/dy/aceMw/server/tasks/RtuDownTask.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/RtuDownTask.java
new file mode 100644
index 0000000..410f43c
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/RtuDownTask.java
@@ -0,0 +1,69 @@
+package com.dy.aceMw.server.tasks;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import com.dy.common.mw.core.CoreTask;
+import com.dy.common.mw.protocol.MidResult;
+import com.dy.common.mw.protocol.Command;
+import com.dy.common.mw.protocol.Driver;
+import com.dy.common.mw.protocol.ProtocolCach;
+import com.dy.aceMw.server.ServerProperties;
+import com.dy.aceMw.server.forTcp.TcpSessionCach;
+
+/**
+ * 浠巜eb涓氬姟绯荤粺鍙戝悜RTU鐨勫懡浠や换鍔�
+ * @author Administrator
+ *
+ */
+public class RtuDownTask extends CoreTask {
+
+ private static Logger log = LogManager.getLogger(RtuDownTask.class.getName());
+
+ @Override
+ public Integer excute() {
+ Command com = (Command)this.data ;
+ try {
+ log.info("涓嬪彂杩滅▼鍛戒护" + com.getCode() + "鐨勬牳蹇冧换鍔″紑濮嬫墽琛�");
+ this.deal(com);
+ } catch (Exception e) {
+ log.error("澶勭悊涓嬭鍛戒护鍑洪敊" + (e.getMessage()==null?"!":("锛�" + e.getMessage())) ,e);
+ }
+ return null ;
+ }
+
+ /**
+ * 澶勭悊鍛戒护
+ * @param webJgroupName
+ * @param com
+ * @throws Exception
+ */
+ private void deal(Command com) throws Exception{
+ String rtuAddr = com.getRtuAddr() ;
+ //鍓嶉潰宸茬粡鍒ゆ柇rtuAddr涓虹┖鎯呭喌锛岃嚦姝ゅ叾涓嶄负绌�
+ Driver dri = null ;
+ String protocolName = TcpSessionCach.getTcpProtocolName(rtuAddr) ;
+ if(protocolName == null){
+ //RTU鏈浘涓婄嚎
+ int count = ProtocolCach.driverCount() ;
+ if(count == 1){
+ //鍙湁涓�涓崗璁�
+ dri = ProtocolCach.getFirstDriver() ;
+ }
+ }else{
+ dri = ProtocolCach.getDriver(protocolName) ;
+ }
+ if(dri == null){
+ log.error("涓ラ噸閿欒锛屾湭鑳藉緱鍒板崗璁�" + protocolName + "椹卞姩绫诲疄渚嬶紒");
+ }else{
+ MidResult[] actions = dri.createCommand(ServerProperties.isLowPower, com) ;
+ log.info("涓嬪彂杩滅▼鍛戒护" + com.getCode() + "鐢卞崗璁┍鍔ㄦ瀯閫犲畬鎴�");
+ if(actions != null){
+ for(MidResult act : actions){
+ act.action();
+ }
+ }
+ }
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/RtuUpTask.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/RtuUpTask.java
new file mode 100644
index 0000000..802461e
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/RtuUpTask.java
@@ -0,0 +1,193 @@
+package com.dy.aceMw.server.tasks;
+
+import java.net.InetSocketAddress;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.mina.core.session.IoSession;
+
+import com.dy.common.mw.channel.tcp.TcpIoSessionAttrIdIsRtuAddr;
+import com.dy.common.mw.channel.tcp.TcpUnit;
+import com.dy.common.mw.core.CoreTask;
+import com.dy.common.mw.protocol.DriverParserDataCallback;
+import com.dy.common.mw.protocol.MidResult;
+import com.dy.common.mw.protocol.Driver;
+import com.dy.common.mw.protocol.OnLine;
+import com.dy.common.mw.protocol.OnLineHandle;
+import com.dy.common.mw.protocol.ProtocolCach;
+import com.dy.aceMw.server.ServerProperties;
+import com.dy.aceMw.server.forTcp.RtuLogDealer;
+import com.dy.aceMw.server.forTcp.RtuStatusDealer;
+import com.dy.aceMw.server.forTcp.TcpSessionCach;
+import com.dy.common.util.ByteUtil;
+
+public class RtuUpTask extends CoreTask {
+
+ private static Logger log = LogManager.getLogger(RtuUpTask.class.getName());
+
+ @Override
+ public Integer excute() {
+ Object[] os = (Object[])this.data ;
+ IoSession session = (IoSession)os[0] ;
+ byte[] upBuf = (byte[])os[1] ;
+ try {
+ this.upData(session, upBuf);
+ } catch (Exception e) {
+ log.error("瑙f瀽涓婅鏁版嵁鍑洪敊" + (e.getMessage()==null?"!":("锛�" + e.getMessage())) ,e);
+ }
+ return null ;
+ }
+
+ /**
+ * RTU涓婅鏁版嵁
+ * @param session
+ * @param upBuf
+ */
+ private void upData(IoSession session, byte[] upBuf) throws Exception{
+ if(upBuf == null){
+ log.error("鍑洪敊锛屾敹鍒癛TU鐨勬暟鎹负绌猴紒") ;
+ return ;
+ }
+ String upHex = null ;
+ try {
+ upHex = ByteUtil.bytes2Hex(upBuf , true) ;
+ log.info("鏀跺埌RTU鏁版嵁:" + upHex) ;
+ } catch (Exception e) {
+ e.printStackTrace();
+ log.error("灏嗘暟鎹浆鎹负鍗佸叚杩涘埗鏃跺嚭閿欙紒" ) ;
+ }
+ String rtuAddr = (String)session.getAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrIdKey) ;
+ String protocolName = null ;
+ boolean isOnLine = false ;
+ if(rtuAddr == null){
+ //璇存槑鍒氬缓绔嬬綉缁滆繛鎺ワ紝姝ゆ暟鎹簲璇ユ槸涓婄嚎鏁版嵁
+ isOnLine = true ;
+ String[] rtuAddrProtocolName = this.parseOnLine(session, upBuf) ;
+ if(rtuAddrProtocolName != null && rtuAddrProtocolName.length == 2){
+ //瑙f瀽涓婄嚎鏁版嵁鎴愬姛锛屽苟瑙f瀽鍑篟TU鍦板潃鍙婇�氫俊鍗忚鍚嶇О
+ rtuAddr = rtuAddrProtocolName[0] ;
+ protocolName = rtuAddrProtocolName[1] ;
+
+ if(rtuAddr != null && protocolName != null){
+ //璁剧疆session鐨勫睘鎬D
+ TcpUnit.getInstance().setIoSessionArrId(session, rtuAddr);
+ //缂撳瓨session
+ TcpSessionCach.putNewTcpSession(rtuAddr, protocolName, session);
+
+ log.info("RTU(鍦板潃锛�" + rtuAddr + ")涓婄嚎浜嗐��") ;
+ }
+ }
+ }
+
+ if(rtuAddr != null){
+ if(protocolName == null){
+ protocolName = TcpSessionCach.getTcpProtocolName(rtuAddr) ;
+ }
+
+ //璁剧疆鏀跺埌鏁版嵁鏃跺埢
+ TcpSessionCach.cachUpDataTime(rtuAddr);
+
+ if(protocolName != null){
+ //瀵逛笂琛屾暟鎹繘琛屽鐞�
+ this.dealUpData(session, rtuAddr, protocolName, isOnLine, upBuf, upHex) ;
+ }
+ }
+ }
+
+ /**
+ * 瑙f瀽涓婄嚎鏁版嵁
+ * @param session
+ * @param upBuf
+ */
+ private String[] parseOnLine(IoSession session, byte[] upBuf){
+ String rtuAddr = null ;
+ String protocolName = null ;
+ try {
+ OnLine.OnLineResult rs = new OnLineHandle().parse(upBuf) ;
+ if(rs == null
+ || rs.result == OnLine.OnLineAction_fail
+ || rs.result == OnLine.OnLineAction_success_noMe){
+ log.error("涓ラ噸閿欒锛岃В鏋愪笂绾挎暟鎹け璐� 锛�" ) ;
+ }else if(rs.result == OnLine.OnLineAction_success){
+ if(rs.rtuAddr == null){
+ log.error("涓ラ噸閿欒锛岃В鏋愪笂绾跨粨鏋滀腑RTU鍦板潃涓虹┖ 锛�" ) ;
+ }else{
+ rtuAddr = rs.rtuAddr ;
+ }
+ if(rs.protocolName == null){
+ log.error("涓ラ噸閿欒锛岃В鏋愪笂绾跨粨鏋滀腑鍗忚鍚嶇О涓虹┖ 锛�" ) ;
+ }else{
+ protocolName = rs.protocolName ;
+ }
+ }else if(rs.result == OnLine.OnLineAction_success_response){
+ if(rs.remoteData != null && rs.remoteData.length > 0){
+ session.write(rs.remoteData) ;
+ }else{
+ log.error("涓ラ噸閿欒锛岃В鏋愪笂绾挎垚鍔燂紝骞堕渶瑕佸洖鍐欐暟鎹紝浣嗘暟鎹负绌� 锛�" ) ;
+ }
+ }
+ } catch (Exception e) {
+ log.error("涓ラ噸閿欒锛屽垎鏋愪笂绾挎暟鎹椂浜х敓寮傚父 锛乗n" + e.getMessage() , e) ;
+ }
+ return new String[]{rtuAddr, protocolName} ;
+ }
+
+
+ /**
+ * 澶勭悊涓婅鏁版嵁
+ * @param session
+ * @param rtuAddr
+ * @param upBuf
+ * @param upHex
+ * @throws Exception
+ */
+ private void dealUpData(IoSession session, String rtuAddrAtHead, String protocolName, boolean isOnLine, byte[] upBuf, String upHex) throws Exception{
+ Driver dri = ProtocolCach.getDriver(protocolName) ;
+ if(dri == null){
+ log.error("涓ラ噸閿欒锛屾湭鑳藉緱鍒板崗璁�" + protocolName + "椹卞姩绫诲疄渚嬶紒");
+ }else{
+ MidResult[] midRses = dri.parseData(ServerProperties.isLowPower, rtuAddrAtHead, upBuf, upHex, new DriverParserDataCallback(){
+ @Override
+ public void callback(String rtuAddrAtHead, String meterNoAtHead, String code, String upHex, Boolean reportOrResponse_trueOrFalse, boolean parseFail, String rtuAddrInData, String meterNoInData) {
+ //鏇存柊缁堢鐘舵��
+ if(rtuAddrInData != null && !rtuAddrInData.equals(rtuAddrAtHead)){
+ //鏁版嵁澶翠腑鐨凴TU鍦板潃涓庢暟鎹腑鐨凴TU鍦板潃涓嶄竴鑷达紝鏇存崲鎴愭暟鎹腑鐨凴TU鍦板潃
+ TcpSessionCach.changeRtuAddr(rtuAddrAtHead, rtuAddrInData, protocolName, session);
+ session.setAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrIdKey, rtuAddrInData) ;
+ }
+
+ String rtuAddr = null ;
+ if(rtuAddrInData != null){
+ rtuAddr = rtuAddrInData ;
+ }else{
+ rtuAddr = rtuAddrAtHead ;
+ }
+
+ InetSocketAddress sa = (InetSocketAddress)session.getRemoteAddress() ;
+ if(isOnLine){
+ //涓婄嚎浜�
+ RtuStatusDealer.onLine(rtuAddr, sa.getAddress().getHostAddress(), sa.getPort());
+ }
+ if(reportOrResponse_trueOrFalse != null && reportOrResponse_trueOrFalse.booleanValue()){
+ RtuStatusDealer.upReport(rtuAddr, upBuf.length) ;
+ }else{
+ RtuStatusDealer.upData(rtuAddr, upBuf.length) ;
+ }
+
+ //璁板綍鏃ュ織
+ if(parseFail){
+ RtuLogDealer.log(rtuAddr, (isOnLine?"涓婄嚎鏁版嵁 ":"涓婅鏁版嵁 ") + "" + code + "锛�" + upHex + "锛堣В鏋愬け璐ワ級");
+ }else{
+ RtuLogDealer.log(rtuAddr, (isOnLine?"涓婄嚎鏁版嵁 ":"涓婅鏁版嵁 ") + "" + code + "锛�" + upHex);
+ }
+ }
+ }) ;
+ if(midRses != null){
+ for(MidResult rs : midRses){
+ rs.action();
+ }
+ }
+ }
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/ToRtuConstantTask.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/ToRtuConstantTask.java
new file mode 100644
index 0000000..dc93cb9
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/ToRtuConstantTask.java
@@ -0,0 +1,93 @@
+package com.dy.aceMw.server.tasks;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import com.dy.common.queue.Node;
+import com.dy.common.mw.core.CoreTask;
+import com.dy.aceMw.server.forTcp.TcpDownCommandCach;
+import com.dy.aceMw.server.forTcp.TcpDownCommandObj;
+import com.dy.aceMw.server.forTcp.TcpSessionCach;
+
+/**
+ * 澶勭悊RTU涓嬭鍛戒护鏁版嵁鐨勬亽涔呬换鍔�
+ */
+public class ToRtuConstantTask extends CoreTask {
+
+ private static Logger log = LogManager.getLogger(ToRtuConstantTask.class.getName());
+
+ /**
+ * 鍦ㄥ崟绾跨▼鐜涓繍琛�
+ */
+ @Override
+ public Integer excute() {
+ try{
+ Long now = System.currentTimeMillis() ;
+ dealTcpSession(now) ;
+ return dealDownCommand(now) ;
+ }catch(Exception e){
+ log.error(e);
+ }
+ return null ;
+ }
+ /**
+ * 澶勭悊TCP缂撳瓨涓殑鍚勪釜TCP Session鐨勪笂琛屾暟鎹椂鍒�
+ */
+ private void dealTcpSession(Long now){
+ TcpSessionCach.updateUpDataTime(now) ;
+ }
+
+ /**
+ * 澶勭悊涓嬭鍛戒护
+ */
+ public Integer dealDownCommand(Long now) {
+ try{
+ Node first = TcpDownCommandCach.getFirstQueueNode() ;
+ if(first != null){
+ Integer count = TcpDownCommandCach.size() ;
+ Node last = TcpDownCommandCach.getLastQueueNode() ;
+ this.doDealDownCommand(now, first, last);
+ return count ;
+ }
+ }catch(Exception e){
+ log.error(e);
+ }
+ return null ;
+ }
+ /**
+ * 澶勭悊缂撳瓨鐨勪笅琛屽懡浠よ妭鐐�
+ * @param now
+ * @param first
+ * @param last
+ */
+ private void doDealDownCommand(Long now, Node first, Node last){
+ if(first != null){
+ //鍦╠ealNode鏂规硶涓紝鍙兘瑕佹妸first浠庨槦鍒椾腑绉婚櫎锛岃繖鏃秄irst.next涓虹┖锛屾墍浠ユ彁鍓嶆妸first.next鍙栧嚭鏉�
+ Node next = first.next ;
+ dealNode(now, first) ;
+ if(last != null && first != last){
+ doDealDownCommand(now, next, last) ;
+ }else if(last != null && first == last){
+ //鍋滄
+ }else if(last == null){
+ //杩欑鎯呭喌涓嶄細瀛樺湪
+ doDealDownCommand(now, next, last) ;
+ }
+ }
+ }
+
+ /**
+ * 澶勭悊涓�涓妭鐐�
+ * @param now
+ * @param node
+ */
+ private void dealNode(Long now, Node node){
+ TcpDownCommandObj obj = (TcpDownCommandObj)node.obj ;
+ boolean removeNode = obj.dealSelf(now) ;
+ if(removeNode){
+ TcpDownCommandCach.removeNode(node);
+ }
+ }
+
+
+}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/resources/application-database.yml b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/resources/application-database.yml
new file mode 100644
index 0000000..b4dbdab
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/resources/application-database.yml
@@ -0,0 +1,8 @@
+# 鏁版嵁婧愰厤缃�
+spring:
+ #澶氭暟鎹簮闇�瑕侀厤缃�
+ main:
+ allow-bean-definition-overriding: true #璁剧疆涓簍rue鏃讹紝鍚庡畾涔夌殑bean浼氳鐩栦箣鍓嶅畾涔夌殑鐩稿悓鍚嶇О鐨刡ean
+ datasource: #閰嶇疆鏁版嵁婧�
+ #澶氫釜鏁版嵁婧愬悕绉板湪姝ら厤缃紝瑕佹眰涓巗pring銆俤atasource銆俒ym][pj]涓殑涓�鑷�
+ names: ym
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/resources/application.yml b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/resources/application.yml
new file mode 100644
index 0000000..002e3ed
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/resources/application.yml
@@ -0,0 +1,18 @@
+spring:
+ profiles:
+ include: global, database, database-ym
+
+#actutor鐨剋eb绔彛
+management:
+ server:
+ port: ${pipIrr.accMw.actutorPort}
+#web鏈嶅姟绔彛锛宼omcat榛樿鏄�8080
+server:
+ port: ${pipIrr.accMw.webPort}
+ servlet:
+ context-path: /accMw #web璁块棶涓婁笅鏂囪矾寰�
+ context-parameters:
+ #GenerateIdSetSuffixListener涓簲鐢紝鍙栧�艰寖鍥存槸0-99
+ idSuffix: ${pipIrr.accMw.idSuffix}
+ #ConfigListener涓簲鐢�
+ #configFileNames: config-global.xml,config-demo.xml
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/resources/config.xml b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/resources/config.xml
new file mode 100644
index 0000000..7e3ad06
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/resources/config.xml
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<config>
+ <server name="閫氫俊涓棿浠�" showStartInfo="true" company="http://www.dyjs.com"/>
+ <!--
+ 鍩烘湰閰嶇疆
+ isLowPower: 鏄惁涓轰綆鍔熻��
+ onlyOneProtocol锛氬湪鏀寔澶氶�氫俊鍗忚鏃讹紝鍙湁RTU涓婄嚎浜嗭紝鎵嶈兘璇嗗埆鍑鸿RTU瀹為檯鐢ㄧ殑閫氫俊鍗忚锛岃繘鑰岀敤姝ゅ崗璁В鏋愪笂琛屾暟鎹強鏋勯�犱笅琛屽懡浠ゃ��
+ 濡傛灉RTU鏈浘涓婄嚎锛堥�氫俊涓棿浠跺惎鍔ㄥ悗璇TU鏈浘涓婄嚎锛夛紝閭d箞鍦ㄥ悜瀹冨彂閫佷笅琛屽懡浠ゆ椂锛屼笉鑳藉垽鏂嚭鍏堕噰鐢ㄧ殑鍗忚锛屼篃涓嶈兘鏋勯�犲懡浠わ紝灏ゅ叾鏄綆鍔熻�楁儏鍐典笅锛屼笉涓婄嚎鏄甯哥幇璞°��
+ 褰撳彧鏈変竴涓崗璁儏鍐典笅锛屽湪RTU鏈浘涓婄嚎鏃讹紝涔熻兘鐢ㄦ鍗忚鏋勯�犲懡浠ゅ苟缂撳瓨涓嬫潵锛屽挨鍏堕�傚悎浣庡姛鑰楁儏鍐点��
+ onlyOneProtocol=true: 閫氫俊涓棿浠跺綋鍓嶅彧鏈変竴涓崗璁�
+ downComandMaxResendTimes: 涓嬭鍛戒护鍏佽鍙戦�佺殑鏈�澶ф鏁癤锛屽嵆鍏佽閲嶅彂X-1
+ commandSendInterval: 閽堝涓�涓猂TU锛屼笅鍙戝懡浠ょ殑鏃堕棿闂撮殧(绉�)
+ cachWaitResultTimeout: 鍛戒护宸茬粡鍙戦�佽揪鏈�澶ф鏁帮紝浠嶆湭鏀跺埌鍛戒护缁撴灉锛岄渶瑕佸湪缂撳瓨缁х画绛夊緟锛屽叾绛夊緟鏈�澶ф椂闀�(绉�)锛屾湰绯荤粺RTU锛屽浜庡紑鍏虫车鍛戒护锛屽叾鍏堟墽琛屽紑鍏虫车鎶ワ紝鐒跺悗鍐嶈繘琛屽懡浠ゅ簲绛旓紝鎵�浠ユ鍊� 瑕佸ぇ涓�浜�
+ offLineCachTimeout: 涓嶅湪绾跨紦瀛樼殑鍛戒护鏈�澶х紦瀛樻椂闀�(绉�)
+ lastUpDataTimeLive: TCP涓婅鏁版嵁鏃跺埢缂撳瓨鏃堕暱(绉�)锛屽綋杈惧埌鏃堕暱鏃讹紝TCP涓婅鏁版嵁鏃跺埢琚竻绌猴紝閲囩敤TCP涓婅鏁版嵁鏃跺埢鐩殑鏄紝闃绘涓婅鏁版嵁鍚屾椂涓嬪彂鏁版嵁锛屽洜涓篟TU澶勭悊涓嶈繃鏉�(缁忓垵娆″疄楠岋紝1绉掕繕鏄湁闂锛�2绉掓棤闂)
+ dbDataIdSuffix锛氭暟鎹簱鏁版嵁id鐢熸垚鍣ㄧ殑id鍚庣紑锛�0鏄粯璁ょ殑鍚庣紑锛屼竴鑸瑆eb绯荤粺搴旂敤锛屾暟鎹腑闂翠欢id鍚庣紑澶т簬绛変簬1
+ -->
+ <base
+ isLowPower="false"
+ onlyOneProtocol="true"
+ downComandMaxResendTimes="1"
+ commandSendInterval="3"
+ cachWaitResultTimeout="60"
+ offLineCachTimeout="86400"
+ lastUpDataTimeLive="1"
+ dbDataIdSuffix="1"
+ />
+
+ <!--
+ centerAddr: 涓績鍦板潃锛屽綋鍓嶏紝鍦ㄦ埛琛ㄧ郴缁熶腑鐨勶紝centerAddr鏈敤鍒�
+ synchroRtuClock: 鏄惁瀵筊TU鏍℃椂
+ synchroRtuClockTimepieces锛氬綋RTU涓庢湇鍔″櫒鏃堕挓鐩稿樊涓�瀹氭绉掞紙閰嶇疆鏂囦欢鏄閽燂級鍚庯紝杩涜鏍℃椂
+ -->
+ <protocol
+ centerAddr="1"
+ synchroRtuClock="true"
+ synchroRtuClockTimepieces="300000"
+ />
+
+
+ <!-- 杞欢鍗囩骇 -->
+ <updateRtuSoft enable="true">
+ <soft1 enable="true" oldVersionName="meter_v2_0,meter_v1_0" >
+ <newVersion newVersionName="meter_v3_0" file="rtuSoft/meter_v3_0.txt"></newVersion>
+ </soft1>
+ <!--
+ <soft2 enable="false" oldVersionName="rtu_v1_0,rtu_v2_0,rtu_v3_0" >
+ <newVersion newVersionName="rtu_v4_0" file="rtuSoft/rtu_v4_0.txt"></newVersion>
+ </soft2>
+ -->
+ </updateRtuSoft>
+
+ <!--
+ 鏀寔妯″潡
+ 鐭伐浣滄椂闀跨嚎绋嬫睜锛岀嚎绋嬭礋璐g敤鏃惰緝鐭殑宸ヤ綔浠诲姟
+ short_maxThread锛� 姹犱腑鏈�澶х嚎绋嬫暟涓烘墍鏈塁PU鏍告暟+1
+ short_minThread锛� 姹犱腑鏈�灏忕嚎绋嬫暟
+ short_freeTimeout锛� 绾跨▼鏁扮┖闂叉椂闀匡紝鑻ユ睜涓嚎绋嬫暟閲忓ぇ浜巑inThread锛屼笖鏈夌殑绾跨▼绌洪棽鏃堕暱瓒呰繃freeTimeout锛屽垯娓呴櫎璇ョ嚎绋嬶紝涓轰簡涓嶆竻闄わ紝鎶妋inThread涓巑axThread璁剧疆鐩哥瓑
+ short_busyTimeout锛氱嚎绋嬩笉闂存柇宸ヤ綔鏃堕暱锛堝崟浣嶄负绉�)瓒呮椂闄愶紝璁や负绾跨▼宸茬粡浜嗗穿婧冿紝灏嗗己鍒舵竻闄わ紝鐭伐浣滄椂闀胯缃负5绉�
+ 闀垮伐浣滄椂闀跨嚎绋嬫睜锛岀嚎绋嬭礋璐g敤鏃惰緝闀跨殑宸ヤ綔浠诲姟锛屼緥濡備粠Redis涓彇缂撳瓨鐨凴TU涓婅鏁版嵁
+ long_maxThread锛� 姹犱腑鏈�澶х嚎绋嬫暟,鑻ヤ负-1锛屼笉鍙楅檺鍒�
+ long_minThread锛� 姹犱腑鏈�灏忕嚎绋嬫暟
+ long_freeTimeout锛� 绾跨▼鏁扮┖闂叉椂闀匡紝鑻ユ睜涓嚎绋嬫暟閲忓ぇ浜巑inThread锛屼笖鏈夌殑绾跨▼绌洪棽鏃堕暱瓒呰繃freeTimeout锛屽垯娓呴櫎璇ョ嚎绋�
+ long_busyTimeout锛氱嚎绋嬩笉闂存柇宸ヤ綔鏃堕暱锛堝崟浣嶄负绉�)瓒呮椂闄愶紝鑻ヤ负-1锛屼笉鍙楅檺鍒�
+ enableThreadPool锛氭槸鍚﹀惎鐢ㄧ嚎绋嬫睜
+ enableSpringHibernate锛氭槸鍚﹀惎鐢⊿pring+Hibernate
+ springXmlFile锛� Spring+Hibernate閰嶇疆鏂囦欢
+ -->
+ <support
+ short_maxThread="100"
+ short_minThread="5"
+ short_freeTimeout="60"
+ short_busyTimeout="5"
+ long_maxThread="200"
+ long_minThread="0"
+ long_freeTimeout="60"
+ long_busyTimeout="-1"
+ enableThreadPool="true"
+ enableSpringHibernate="false"
+ springXmlFile="config/spring.xml"
+ />
+
+ <!--
+ 璧勬簮妯″潡
+ rtuLogDir锛歊TU鏃ュ織鏂囦欢瀛樺偍鐩綍(鐩稿鐩綍)
+ rtuLogFileMaxSize锛歊TU鏃ュ織鏂囦欢鏈�澶у瓧鑺傛暟(KB)
+ rtuLogFileMaxCount锛歊TU鏃ュ織鏂囦欢鏈�澶ф枃浠舵暟
+ monitorInterval锛歊tu鐘舵�佺洃瑙嗛棿闅�(鍒嗛挓)
+ saveDbInterval锛歊tu鐘舵�佸瓨鏁版嵁搴撻棿闅�(鍒嗛挓)
+ -->
+ <resource
+ rtuLogDir="rtuLogs/"
+ rtuLogFileMaxSize="1000000"
+ rtuLogFileMaxCount="2"
+ monitorInterval="2"
+ saveDbInterval="10"
+ />
+
+
+ <!--
+ port锛歳mi鏈嶅姟绔彛鍙�
+ context锛歳mi鏈嶅姟涓婁笅鏂�
+ -->
+ <rmi enable="true"
+ port="65400"
+ context="rtuMw"
+ />
+
+ <!--
+ sleepBigBusy锛氫富绾跨▼澶у繖鏃舵瘡娆℃墽琛岄棿闅旀椂闀匡紙姣锛�
+ sleepSmallBusy锛氫富绾跨▼灏忓繖鏃舵瘡娆℃墽琛岄棿闅旀椂闀匡紙姣锛�
+ queueWarnSize: 缂撳瓨闃熷垪鑺傜偣鏁拌鍛婃暟閲�
+ queueMaxSize: 缂撳瓨闃熷垪鑺傜偣鏁版渶澶ф暟閲�
+ -->
+ <core
+ sleepBigBusy="100"
+ sleepSmallBusy="500"
+ queueWarnSize="100000"
+ queueMaxSize="300000"
+ />
+
+ <!--
+ port锛氱鍙�
+ processors锛� Mina IO 澶勭悊涓婁笅琛屾暟鎹殑绾跨▼鏁帮紝涓�鑸槸CPU鎬绘牳鏁�+1
+ idle: 鍙戝憜鏃堕暱锛堢锛�
+ -->
+ <tcp enable="true"
+ port="60000"
+ processors="3"
+ idle="10"
+ />
+
+</config>
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/resources/log4j2.yml b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/resources/log4j2.yml
new file mode 100644
index 0000000..c2dcc3f
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/resources/log4j2.yml
@@ -0,0 +1,73 @@
+Configuration:
+ #status锛岃繖涓敤浜庤缃甽og4j2鑷韩鍐呴儴鐨勪俊鎭緭鍑猴紝鍙互涓嶈缃紝褰撹缃垚trace鏃讹紝浣犱細鐪嬪埌log4j2鍐呴儴鍚勭璇︾粏杈撳嚭锛涘彲浠ヨ缃垚Off(鍏抽棴)鎴朎rror(鍙緭鍑洪敊璇俊鎭�)
+ status: Error
+
+ Properties: # 瀹氫箟鍏ㄥ眬鍙橀噺
+ Property:
+ #鏃ュ織鏂囦欢瀛樺偍鐨勭洰褰�
+ - name: log.path
+ value: ./logs
+ #鏃ュ織鏂囦欢瀛樺偍鍚嶇О
+ - name: project.name
+ value: aceMw
+
+ #瀹氫箟杈撳嚭鍣紝鍙互杈撳嚭鍒版帶鍒跺彴鍜屾枃浠�.
+ Appenders:
+ #杈撳嚭鍒版帶鍒跺彴
+ Console:
+ #Appender鍛藉悕
+ name: CONSOLE
+ target: SYSTEM_OUT
+ ThresholdFilter:
+ level: debug #杈撳嚭鏃ュ織绾у埆锛岃緭鍑烘棩蹇楁椂锛岄鍏堢敱Loggers.Root.level鎴朙oggers.Logger.level鍒ゆ柇鏄惁杈撳嚭锛岀劧鍚庡啀鐢辨湰level鍒ゆ柇鏄惁杈撳嚭
+ onMatch: ACCEPT #onMatch=ACCEPT 澶т簬绛変簬 "level" 閰嶇疆鐨勭瓑绾у湴鏃ュ織杈撳嚭
+ onMismatch: DENY #onMismatch=DENY 灏忎簬 "level" 閰嶇疆鐨勭瓑绾у湴鏃ュ織涓嶈緭鍑�
+ #鏃ュ織鍐呭鏍峰紡
+ PatternLayout:
+ #%n-鎹㈣
+ #%m-鏃ュ織鍐呭锛岃緭鍑轰唬鐮佷腑鎸囧畾鐨勬棩蹇椾俊鎭�
+ #%p-杈撳嚭浼樺厛绾э紝鍗矰EBUG,INFO,WARN,ERROR,FATAL
+ #%r-绋嬪簭鍚姩鍒扮幇鍦ㄧ殑姣鏁�
+ #%%- 杈撳嚭涓�涓�"%" 瀛楃
+ #%t-褰撳墠绾跨▼鍚�
+ #%d-鏃ユ湡鍜屾椂闂�, 甯哥敤鐨勬牸寮忔湁%d{DATE},%d{ABSOLUTE},%d{HH:mm:ss,SSS},%d{ddMMyyyyHH:mm:ss,SSS}
+ #%l-鍚�%F%L%C%M
+ #%F-java婧愭枃浠跺悕
+ #%L-java婧愮爜琛屾暟
+ #%C-java绫诲悕,%C{1}杈撳嚭鏈�鍚庝竴涓厓绱�
+ #%M-java鏂规硶鍚�
+ pattern: "%d{yyyy-MM-dd HH:mm:ss,SSS}:%4p %t (%C.%M:%L) - %m%n"
+ # 杈撳嚭鍒版枃浠讹紝瓒呰繃10MB褰掓。
+ RollingFile:
+ - name: ROLLING_FILE
+ ignoreExceptions: false
+ fileName: ${log.path}/${project.name}.log
+ filePattern: "${log.path}/$${date:yyyy-MM}/${project.name}-%d{yyyy-MM-dd}-%i.log.gz"
+ ThresholdFilter:
+ level: error #杈撳嚭鏃ュ織绾у埆锛岃緭鍑烘棩蹇楁椂锛岄鍏堢敱Loggers.Root.level鎴朙oggers.Logger.level鍒ゆ柇鏄惁杈撳嚭锛岀劧鍚庡啀鐢辨湰level鍒ゆ柇鏄惁杈撳嚭
+ onMatch: ACCEPT #onMatch=ACCEPT 澶т簬绛変簬 "level" 閰嶇疆鐨勭瓑绾у湴鏃ュ織杈撳嚭
+ onMismatch: DENY #onMismatch=DENY 灏忎簬 "level" 閰嶇疆鐨勭瓑绾у湴鏃ュ織涓嶈緭鍑�
+ #鏃ュ織鍐呭鏍峰紡
+ PatternLayout:
+ pattern: "%d{yyyy-MM-dd HH:mm:ss,SSS}:%4p %t (%C.%M:%L) - %m%n"
+ Policies:
+ SizeBasedTriggeringPolicy:
+ size: "10 MB"
+ DefaultRolloverStrategy:
+ max: 1000
+
+ Loggers:
+ Root:
+ level: info #鏃ュ織杈撳嚭绾у埆锛屽叡鏈�8涓骇鍒紝鎸夌収浠庝綆鍒伴珮涓猴細all < trace < debug < info < warn < error < fatal < off
+ AppenderRef: #Root鐨勫瓙鑺傜偣锛岀敤鏉ユ寚瀹氳鏃ュ織杈撳嚭鍒板摢涓狝ppender.
+ - ref: CONSOLE #杈撳嚭鏃ュ織鏃讹紝棣栧厛鐢辨湰level鍒ゆ柇鏄惁杈撳嚭锛岀劧鍚庡啀鐢变笂闈㈢殑Appenders.Console.ThresholdFilter.level鍒ゆ柇鏄惁杈撳嚭
+ - ref: ROLLING_FILE #杈撳嚭鏃ュ織鏃讹紝棣栧厛鐢辨湰level鍒ゆ柇鏄惁杈撳嚭锛岀劧鍚庡啀鐢变笂闈㈢殑Appenders.RollingFile.ThresholdFilter.level鍒ゆ柇鏄惁杈撳嚭
+ # 涓哄寘閰嶇疆鐗规畩鐨凩og绾у埆锛屾柟渚胯皟璇曪紝
+ # 涓嶅彈Loggers.Root.level闄愬埗
+ Logger:
+ - name: com.dy.pipIrrGlobal.daoBa
+ additivity: false #鍘婚櫎閲嶅鐨刲og
+ level: debug #杈撳嚭鏃ュ織绾у埆
+ AppenderRef:
+ - ref: CONSOLE #杈撳嚭鏃ュ織鏃讹紝棣栧厛鐢辨湰.level鍒ゆ柇鏄惁杈撳嚭锛岀劧鍚庡啀鐢变笂闈㈢殑Appenders.Console.ThresholdFilter.level鍒ゆ柇鏄惁杈撳嚭
+ - ref: ROLLING_FILE #杈撳嚭鏃ュ織鏃讹紝棣栧厛鐢辨湰level鍒ゆ柇鏄惁杈撳嚭锛岀劧鍚庡啀鐢变笂闈㈢殑Appenders.RollingFile.ThresholdFilter.level鍒ゆ柇鏄惁杈撳嚭
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/test/java/com/dy/aceMw/PipIrrMwAcceptApplicationTests.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/test/java/com/dy/aceMw/PipIrrMwAcceptApplicationTests.java
new file mode 100644
index 0000000..5e86982
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/test/java/com/dy/aceMw/PipIrrMwAcceptApplicationTests.java
@@ -0,0 +1,13 @@
+package com.dy.aceMw;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class PipIrrMwAcceptApplicationTests {
+
+ @Test
+ void contextLoads() {
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw.iml b/pipIrr-platform/pipIrr-mw/pipIrr-mw.iml
index 95903ab..754c7d6 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw.iml
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw.iml
@@ -26,6 +26,7 @@
<orderEntry type="library" name="Maven: org.springframework:spring-beans:6.0.11" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:6.0.11" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aop:6.0.11" level="project" />
+ <orderEntry type="library" name="Maven: org.springframework:spring-context:6.0.11" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-expression:6.0.11" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.springframework.boot:spring-boot-devtools:3.1.3" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:3.1.3" level="project" />
@@ -97,44 +98,6 @@
<orderEntry type="library" name="Maven: cn.hutool:hutool-all:5.8.21" level="project" />
<orderEntry type="library" name="Maven: org.jdom:jdom2:2.0.6.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.dubbo:dubbo:3.2.7" level="project" />
- <orderEntry type="library" name="Maven: org.springframework:spring-context:6.0.11" level="project" />
- <orderEntry type="library" name="Maven: com.alibaba.spring:spring-context-support:1.0.11" level="project" />
- <orderEntry type="library" name="Maven: org.javassist:javassist:3.21.0-GA" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-all:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-buffer:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-codec:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-codec-dns:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-codec-haproxy:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-codec-http:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-codec-http2:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-codec-memcache:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-codec-mqtt:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-codec-redis:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-codec-smtp:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-codec-socks:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-codec-stomp:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-codec-xml:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-common:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-handler:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-transport-native-unix-common:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-handler-proxy:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-handler-ssl-ocsp:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-resolver:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-resolver-dns:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-transport:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-transport-rxtx:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-transport-sctp:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-transport-udt:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-transport-classes-epoll:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-transport-classes-kqueue:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-resolver-dns-classes-macos:4.1.94.Final" level="project" />
- <orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-transport-native-epoll:linux-x86_64:4.1.94.Final" level="project" />
- <orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-transport-native-epoll:linux-aarch_64:4.1.94.Final" level="project" />
- <orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-transport-native-kqueue:osx-x86_64:4.1.94.Final" level="project" />
- <orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-transport-native-kqueue:osx-aarch_64:4.1.94.Final" level="project" />
- <orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-resolver-dns-native-macos:osx-x86_64:4.1.94.Final" level="project" />
- <orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-resolver-dns-native-macos:osx-aarch_64:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: com.alibaba:hessian-lite:3.2.13" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:3.1.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:3.1.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:3.1.3" level="project" />
diff --git a/pipIrr-platform/pipIrr-mw/pom.xml b/pipIrr-platform/pipIrr-mw/pom.xml
index 68c7047..780ceef 100644
--- a/pipIrr-platform/pipIrr-mw/pom.xml
+++ b/pipIrr-platform/pipIrr-mw/pom.xml
@@ -153,6 +153,36 @@
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
<version>3.2.7</version>
+ <exclusions>
+ <exclusion>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-all</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.yaml</groupId>
+ <artifactId>snakeyaml</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.alibaba.spring</groupId>
+ <artifactId>spring-context-support</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.alibaba.fastjson2</groupId>
+ <artifactId>fastjson2</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.alibaba</groupId>
+ <artifactId>hessian-lite</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.javassist</groupId>
+ <artifactId>javassist</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<!-- 娴嬭瘯 -->
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web.iml b/pipIrr-platform/pipIrr-web/pipIrr-web.iml
index d4e8f14..b162fa6 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web.iml
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web.iml
@@ -34,6 +34,7 @@
<orderEntry type="library" name="Maven: org.springframework:spring-beans:6.0.11" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:6.0.11" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aop:6.0.11" level="project" />
+ <orderEntry type="library" name="Maven: org.springframework:spring-context:6.0.11" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-expression:6.0.11" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-validation:3.1.3" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:10.1.12" level="project" />
@@ -111,44 +112,6 @@
<orderEntry type="library" name="Maven: cn.hutool:hutool-all:5.8.21" level="project" />
<orderEntry type="library" name="Maven: org.jdom:jdom2:2.0.6.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.dubbo:dubbo:3.2.7" level="project" />
- <orderEntry type="library" name="Maven: org.springframework:spring-context:6.0.11" level="project" />
- <orderEntry type="library" name="Maven: com.alibaba.spring:spring-context-support:1.0.11" level="project" />
- <orderEntry type="library" name="Maven: org.javassist:javassist:3.21.0-GA" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-all:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-buffer:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-codec:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-codec-dns:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-codec-haproxy:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-codec-http:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-codec-http2:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-codec-memcache:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-codec-mqtt:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-codec-redis:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-codec-smtp:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-codec-socks:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-codec-stomp:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-codec-xml:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-common:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-handler:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-transport-native-unix-common:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-handler-proxy:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-handler-ssl-ocsp:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-resolver:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-resolver-dns:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-transport:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-transport-rxtx:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-transport-sctp:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-transport-udt:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-transport-classes-epoll:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-transport-classes-kqueue:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: io.netty:netty-resolver-dns-classes-macos:4.1.94.Final" level="project" />
- <orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-transport-native-epoll:linux-x86_64:4.1.94.Final" level="project" />
- <orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-transport-native-epoll:linux-aarch_64:4.1.94.Final" level="project" />
- <orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-transport-native-kqueue:osx-x86_64:4.1.94.Final" level="project" />
- <orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-transport-native-kqueue:osx-aarch_64:4.1.94.Final" level="project" />
- <orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-resolver-dns-native-macos:osx-x86_64:4.1.94.Final" level="project" />
- <orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-resolver-dns-native-macos:osx-aarch_64:4.1.94.Final" level="project" />
- <orderEntry type="library" name="Maven: com.alibaba:hessian-lite:3.2.13" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:3.1.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:3.1.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:3.1.3" level="project" />
diff --git a/pipIrr-platform/pipIrr-web/pom.xml b/pipIrr-platform/pipIrr-web/pom.xml
index 0c81025..568c48c 100644
--- a/pipIrr-platform/pipIrr-web/pom.xml
+++ b/pipIrr-platform/pipIrr-web/pom.xml
@@ -167,6 +167,36 @@
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
<version>3.2.7</version>
+ <exclusions>
+ <exclusion>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-all</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.yaml</groupId>
+ <artifactId>snakeyaml</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.alibaba.spring</groupId>
+ <artifactId>spring-context-support</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.alibaba.fastjson2</groupId>
+ <artifactId>fastjson2</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.alibaba</groupId>
+ <artifactId>hessian-lite</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.javassist</groupId>
+ <artifactId>javassist</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<!-- 娴嬭瘯 -->
--
Gitblit v1.8.0