Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
Z
zhmes-agecal
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
耿迪迪
zhmes-agecal
Commits
16a45a69
Commit
16a45a69
authored
Jun 05, 2025
by
wanghao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1 每次读取后 关闭 socket连接
parent
223e5917
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
50 deletions
+56
-50
ZhMesAgecalApplication.java
...dmin/src/main/java/com/zehong/ZhMesAgecalApplication.java
+2
-0
EquipmentDataCollection.java
...ong/web/controller/equipment/EquipmentDataCollection.java
+45
-47
ReceiverThread.java
...main/java/com/zehong/common/utils/TCP/ReceiverThread.java
+5
-1
TCPClient.java
.../src/main/java/com/zehong/common/utils/TCP/TCPClient.java
+4
-2
No files found.
zhmes-agecal-admin/src/main/java/com/zehong/ZhMesAgecalApplication.java
View file @
16a45a69
...
...
@@ -3,12 +3,14 @@ package com.zehong;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
/**
* 启动程序
*
* @author zehong
*/
@EnableScheduling
@SpringBootApplication
(
exclude
=
{
DataSourceAutoConfiguration
.
class
})
public
class
ZhMesAgecalApplication
{
...
...
zhmes-agecal-admin/src/main/java/com/zehong/web/controller/equipment/EquipmentDataCollection.java
View file @
16a45a69
...
...
@@ -53,7 +53,6 @@ public class EquipmentDataCollection {
log
.
error
(
"设备列表查询结果为空"
);
throw
new
Exception
(
"无设备信息!"
);
}
if
(
equipmentInfos
.
size
()
>
0
){
String
sendMsg
=
"00010000000601040000000A"
;
String
receiveMsg
;
...
...
@@ -76,7 +75,7 @@ public class EquipmentDataCollection {
alarmData
.
setfEquipmentCode
(
info
.
getfEquipmentCode
());
alarmData
.
setfAlarmData
(
"老化柜IP或端口号为空"
);
tEquipmentAlarmDataService
.
insertTEquipmentAlarmData
(
alarmData
);
}
else
if
(
receiveMsg
.
length
()
==
58
)
{
}
else
{
// 解析服务器返回信息
// 示例:00 01 00 00 00 17 01 04 14 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
String
flag
=
receiveMsg
.
substring
(
18
,
58
);
...
...
@@ -110,7 +109,6 @@ public class EquipmentDataCollection {
}
}
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
...
...
zhmes-agecal-common/src/main/java/com/zehong/common/utils/TCP/ReceiverThread.java
View file @
16a45a69
...
...
@@ -12,7 +12,7 @@ import java.net.Socket;
*
* @author zehong
*/
public
class
ReceiverThread
extends
Thread
implements
Runnable
{
public
class
ReceiverThread
extends
Thread
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
ReceiverThread
.
class
);
public
static
String
hexResponse
;
private
final
Socket
socket
;
...
...
@@ -34,7 +34,11 @@ public class ReceiverThread extends Thread implements Runnable {
// 将接收到的字节转换为十六进制字符串显示
hexResponse
=
HexUtils
.
bytesToHex
(
responseBytes
);
log
.
info
(
"收到服务器响应: "
+
hexResponse
);
if
(
hexResponse
.
length
()
==
58
)
{
socket
.
close
();
}
}
log
.
info
(
"解析完了啊啊啊啊啊: "
+
hexResponse
);
}
catch
(
IOException
e
)
{
log
.
error
(
"接收数据失败: "
+
e
.
getMessage
());
}
...
...
zhmes-agecal-common/src/main/java/com/zehong/common/utils/TCP/TCPClient.java
View file @
16a45a69
...
...
@@ -34,13 +34,15 @@ public class TCPClient {
log
.
info
(
"已发送数据: "
+
sendMsg
);
receiverThread
=
new
ReceiverThread
(
socket
);
hexResponse
=
receiverThread
.
hexResponse
;
receiverThread
.
start
();
//
receiverThread.join();
receiverThread
.
join
();
hexResponse
=
ReceiverThread
.
hexResponse
;
}
catch
(
IOException
e
)
{
System
.
err
.
println
(
"通信异常: "
+
e
.
getMessage
());
e
.
printStackTrace
();
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
return
hexResponse
;
...
...
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