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
904fe89d
Commit
904fe89d
authored
Nov 06, 2025
by
junshizhonglangjiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1 上电断电调整
2 查询设备信息调整
parent
0158886c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
18 deletions
+13
-18
application-test.yml
zhmes-agecal-admin/src/main/resources/application-test.yml
+1
-1
application.yml
zhmes-agecal-admin/src/main/resources/application.yml
+1
-1
ModbusMasterPool.java
.../java/com/zehong/system/modbus/util/ModbusMasterPool.java
+0
-2
RobotArmCommandServiceImpl.java
...ehong/system/service/impl/RobotArmCommandServiceImpl.java
+8
-5
BaseDeviceCommJob.java
...m/zehong/system/task/DeviceCommJob/BaseDeviceCommJob.java
+3
-9
No files found.
zhmes-agecal-admin/src/main/resources/application-test.yml
View file @
904fe89d
...
...
@@ -24,7 +24,7 @@ spring:
maxActive
:
50
# 最大连接数增加到50,考虑72个Job并发 + 业务连接
# 2. 连接获取优化(解决Quartz获取连接超时问题)
maxWait
:
5
000
# 获取连接最大等待时间5秒,避免Quartz线程阻塞
maxWait
:
30
000
# 获取连接最大等待时间5秒,避免Quartz线程阻塞
# 3. 连接保活核心配置(解决"discard long time none received connection"警告)
timeBetweenEvictionRunsMillis
:
30000
# 检测间隔30秒,更频繁检查连接有效性
...
...
zhmes-agecal-admin/src/main/resources/application.yml
View file @
904fe89d
...
...
@@ -47,7 +47,7 @@ token:
# 令牌密钥
secret
:
abcdefghijklmnopqrstuvwxyz
# 令牌有效期(默认30分钟)
expireTime
:
30
expireTime
:
30
00000
# MyBatis配置
mybatis
:
...
...
zhmes-agecal-system/src/main/java/com/zehong/system/modbus/util/ModbusMasterPool.java
View file @
904fe89d
...
...
@@ -21,7 +21,6 @@ import java.util.concurrent.ConcurrentHashMap;
* @date 2025/9/25
* @description TODO
*/
@Component
public
class
ModbusMasterPool
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
ModbusMasterPool
.
class
);
...
...
@@ -213,7 +212,6 @@ public class ModbusMasterPool {
/**
* 容器关闭时销毁所有连接池(避免资源泄漏)
*/
@PostConstruct
public
void
init
()
{
log
.
info
(
"ModbusMasterPool初始化成功"
);
// JVM关闭钩子:确保容器关闭时销毁所有池
...
...
zhmes-agecal-system/src/main/java/com/zehong/system/service/impl/RobotArmCommandServiceImpl.java
View file @
904fe89d
...
...
@@ -132,11 +132,13 @@ public class RobotArmCommandServiceImpl implements IRobotArmCommandService
TEquipmentInfo
tEquipmentInfo
=
equipmentInfoMapper
.
selectTEquipmentInfoByCode
(
split
[
0
]);
int
layer
=
Integer
.
parseInt
(
split
[
0
]);
int
layer
=
Integer
.
parseInt
(
split
[
1
]);
int
registerOffsetInt
=
layer
-
1
;
try
{
ModbusMaster
master
=
Modbus4jUtils
.
getMaster
(
tEquipmentInfo
.
getfPowerOutageIp
(),
tEquipmentInfo
.
getfPowerOutagePort
());
Modbus4jUtils
.
writeCoil
(
master
,
1
,
layer
,
false
);
Modbus4jUtils
.
writeCoil
(
master
,
1
,
registerOffsetInt
,
false
);
log
.
info
(
"已发送断电指令 - 设备:{} 层:{}"
,
tEquipmentInfo
.
getfEquipmentCode
(),
layer
);
master
.
destroy
();
}
catch
(
ModbusTransportException
|
ModbusInitException
e
)
{
...
...
@@ -356,9 +358,10 @@ public class RobotArmCommandServiceImpl implements IRobotArmCommandService
throw
new
RuntimeException
(
"托盘不存在"
);
}
if
(!
"0"
.
equals
(
tTrayInfo
.
getfStatus
()))
{
throw
new
RuntimeException
(
"托盘未解绑,请联系管理员"
);
}
// 20251104 上料 不需要看托盘状态了
// if(!"0".equals(tTrayInfo.getfStatus())) {
// throw new RuntimeException("托盘未解绑,请联系管理员");
// }
TStoreyInfo
tStoreyInfo
=
storeyInfoMapper
.
selectNearestFreeStorey
();
if
(
tStoreyInfo
!=
null
)
{
...
...
zhmes-agecal-system/src/main/java/com/zehong/system/task/DeviceCommJob/BaseDeviceCommJob.java
View file @
904fe89d
...
...
@@ -63,9 +63,6 @@ public abstract class BaseDeviceCommJob implements Job {
@Resource
protected
ModbusResultHandler
resultHandler
;
@Resource
private
ModbusMasterPool
modbusMasterPool
;
@Resource
private
Scheduler
scheduler
;
...
...
@@ -89,7 +86,6 @@ public abstract class BaseDeviceCommJob implements Job {
// 新增:校验依赖是否为null
log
.
info
(
"=== 依赖注入校验 ==="
);
log
.
info
(
"modbusMasterPool: {}"
,
modbusMasterPool
==
null
?
"NULL"
:
"OK"
);
log
.
info
(
"scheduler: {}"
,
scheduler
==
null
?
"NULL"
:
"OK"
);
log
.
info
(
"palletDeviceBindingMapper: {}"
,
palletDeviceBindingMapper
==
null
?
"NULL"
:
"OK"
);
log
.
info
(
"alarmDataService: {}"
,
alarmDataService
==
null
?
"NULL"
:
"OK"
);
...
...
@@ -249,8 +245,8 @@ public abstract class BaseDeviceCommJob implements Job {
* Modbus读取(带重试,连接用完即时销毁)
*/
private
int
[]
readModbusWithRetry
(
String
ip
,
int
port
,
int
deviceId
)
throws
Exception
{
// 1. 从连接池借连接(超时3秒
)
ModbusMaster
master
=
modbusMasterPool
.
borrow
Master
(
ip
,
port
);
// 1. 从连接池借连接(超时3秒
ModbusMaster
master
=
Modbus4jUtils
.
get
Master
(
ip
,
port
);
for
(
int
retry
=
0
;
retry
<=
CUSTOM_RETRY_TIMES
;
retry
++)
{
try
{
// 2. 读取寄存器
...
...
@@ -269,9 +265,7 @@ public abstract class BaseDeviceCommJob implements Job {
log
.
info
(
"Modbus读取异常,重试:retry={}, port={}, deviceId={}"
,
retry
,
port
,
deviceId
,
e
);
}
finally
{
// 3. 无论成功/失败,归还连接到池(关键:避免连接泄漏)
if
(
master
!=
null
)
{
modbusMasterPool
.
returnMaster
(
ip
,
port
,
master
);
}
master
.
destroy
();
}
}
log
.
info
(
"Modbus读取无有效结果:ip="
+
ip
+
", port="
+
port
+
", deviceId="
+
deviceId
);
...
...
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