Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gass-device-report
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
耿迪迪
gass-device-report
Commits
b3694a7e
Commit
b3694a7e
authored
Sep 13, 2021
by
耿迪迪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
压力表上报 gengdidi
parent
14c2f6fd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
129 additions
and
7 deletions
+129
-7
FlowmeterDecryptReportedData.java
.../gassdevicereport/netty/FlowmeterDecryptReportedData.java
+3
-3
PressureDecryptReportedData.java
...g/gassdevicereport/netty/PressureDecryptReportedData.java
+121
-0
ServerHandler.java
...java/com/zehong/gassdevicereport/netty/ServerHandler.java
+4
-3
application.yml
src/main/resources/application.yml
+1
-1
No files found.
src/main/java/com/zehong/gassdevicereport/netty/DecryptReportedData.java
→
src/main/java/com/zehong/gassdevicereport/netty/
Flowmeter
DecryptReportedData.java
View file @
b3694a7e
...
@@ -10,15 +10,15 @@ import java.text.ParseException;
...
@@ -10,15 +10,15 @@ import java.text.ParseException;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.Date
;
public
class
DecryptReportedData
{
public
class
Flowmeter
DecryptReportedData
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
DecryptReportedData
.
class
);
private
Logger
logger
=
LoggerFactory
.
getLogger
(
Flowmeter
DecryptReportedData
.
class
);
private
String
reportedDataStr
;
private
String
reportedDataStr
;
private
String
deviceType
;
private
String
deviceType
;
public
DecryptReportedData
(
String
reportedDataStr
,
String
deviceType
)
{
public
FlowmeterDecryptReportedData
(
String
reportedDataStr
,
String
deviceType
)
{
this
.
reportedDataStr
=
reportedDataStr
;
this
.
reportedDataStr
=
reportedDataStr
;
this
.
deviceType
=
deviceType
;
this
.
deviceType
=
deviceType
;
}
}
...
...
src/main/java/com/zehong/gassdevicereport/netty/PressureDecryptReportedData.java
0 → 100644
View file @
b3694a7e
package
com
.
zehong
.
gassdevicereport
.
netty
;
import
com.zehong.gassdevicereport.entity.TDeviceReportData
;
import
com.zehong.gassdevicereport.utils.HexUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.math.BigDecimal
;
public
class
PressureDecryptReportedData
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
PressureDecryptReportedData
.
class
);
private
String
reportedDataStr
;
private
String
deviceType
;
public
PressureDecryptReportedData
(
String
reportedDataStr
)
{
this
.
reportedDataStr
=
reportedDataStr
;
}
public
TDeviceReportData
getReportedData
(){
try
{
TDeviceReportData
tDeviceReportData
=
new
TDeviceReportData
();
//设备编号
tDeviceReportData
.
setDeviceNum
(
getDeviceNum
());
//设备类型
getDeviceType
();
//设备状态
String
deviceStatus
=
getDeviceStatus
();
tDeviceReportData
.
setDeviceStatus
(
deviceStatus
);
float
pressure
=
HexUtils
.
hexToFloat
(
reportedDataStr
.
substring
(
34
,
42
));
tDeviceReportData
.
setPressure
(
new
BigDecimal
(
pressure
));
return
tDeviceReportData
;
}
catch
(
Exception
e
)
{
logger
.
error
(
"上报数据组装数据报错!"
+
e
);
}
return
null
;
}
/**
* 获取设备编号
* @return
*/
private
String
getDeviceNum
(){
String
deviceNum
=
reportedDataStr
.
substring
(
0
,
30
);
StringBuilder
deviceNumStr
=
new
StringBuilder
(
""
);
for
(
int
i
=
0
;
i
<
deviceNum
.
length
();
i
+=
2
){
String
code
=
deviceNum
.
substring
(
i
,
i
+
2
);
byte
codeByte
=
HexUtils
.
hexToByte
(
code
);
deviceNumStr
.
append
(
codeByte
);
}
return
deviceNum
.
toString
();
}
/**
* 截取加密串获取设备类型
* @return
*/
private
void
getDeviceType
(){
String
deviceTypeNum
=
reportedDataStr
.
substring
(
30
,
32
);
switch
(
deviceTypeNum
){
case
"A0"
:
this
.
deviceType
=
"ZH11-NB家用报警器"
;
break
;
case
"A1"
:
this
.
deviceType
=
"JT-ZH85N家用报警器"
;
break
;
case
"A2"
:
this
.
deviceType
=
"燃气压力监测仪"
;
break
;
case
"A3"
:
this
.
deviceType
=
"消防水压监测仪"
;
break
;
default
:
break
;
}
}
/**
* 设备状态字段 16进制转为二进制 高位或地位不足8位时左边补0
* @return
*/
private
String
getDeviceStatus
(){
String
deviceStatus
=
reportedDataStr
.
substring
(
32
,
34
);
switch
(
deviceStatus
){
case
"01"
:
deviceStatus
=
"预热"
;
break
;
case
"02"
:
deviceStatus
=
"正常"
;
break
;
case
"03"
:
deviceStatus
=
"传感器故障"
;
break
;
case
"04"
:
deviceStatus
=
"报警"
;
break
;
case
"05"
:
deviceStatus
=
"低报"
;
break
;
case
"06"
:
deviceStatus
=
"高报"
;
break
;
case
"07"
:
deviceStatus
=
"通讯故障"
;
break
;
case
"08"
:
deviceStatus
=
"超量程"
;
break
;
case
"1x"
:
deviceStatus
=
"电池电量低"
;
break
;
default
:
break
;
}
return
deviceType
+
":"
+
deviceStatus
;
}
}
src/main/java/com/zehong/gassdevicereport/netty/ServerHandler.java
View file @
b3694a7e
...
@@ -85,10 +85,11 @@ public class ServerHandler extends ChannelInboundHandlerAdapter {
...
@@ -85,10 +85,11 @@ public class ServerHandler extends ChannelInboundHandlerAdapter {
int
port
=
channel
.
localAddress
().
getPort
();
int
port
=
channel
.
localAddress
().
getPort
();
TDeviceReportData
tDeviceReportData
;
TDeviceReportData
tDeviceReportData
;
if
(
7397
==
port
){
if
(
7397
==
port
){
tDeviceReportData
=
new
DecryptReportedData
(
msgStr
,
"nacangEVC300"
).
getReportedData
();
tDeviceReportData
=
new
FlowmeterDecryptReportedData
(
msgStr
,
"nacangEVC300"
).
getReportedData
();
}
else
if
(
7398
==
port
){
tDeviceReportData
=
new
FlowmeterDecryptReportedData
(
msgStr
,
"tianxinCPUcard"
).
getReportedData
();
}
else
{
}
else
{
tDeviceReportData
=
new
DecryptReportedData
(
msgStr
,
"tianxinCPUcard"
).
getReportedData
();
tDeviceReportData
=
new
PressureDecryptReportedData
(
msgStr
).
getReportedData
();
}
}
//缓存设备信息
//缓存设备信息
ReciveReportData
reciveReportData
=
new
ReciveReportData
();
ReciveReportData
reciveReportData
=
new
ReciveReportData
();
...
...
src/main/resources/application.yml
View file @
b3694a7e
...
@@ -64,4 +64,4 @@ logging:
...
@@ -64,4 +64,4 @@ logging:
webSocektUrl
:
http://localhost:8903/gassafety/websocket/send
webSocektUrl
:
http://localhost:8903/gassafety/websocket/send
netty
:
netty
:
ports
:
7397,7398
ports
:
7397,7398
,7399
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment