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
373b4d94
Commit
373b4d94
authored
Sep 23, 2025
by
wanghao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1测试上电断电操作
parent
b89df233
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
19 deletions
+57
-19
ModbusResultHandler.java
...com/zehong/system/modbus/handler/ModbusResultHandler.java
+6
-3
NettyUdpServerHandler.java
...om/zehong/system/netty/handler/NettyUdpServerHandler.java
+0
-3
DeviceTaskScheduler.java
...main/java/com/zehong/system/task/DeviceTaskScheduler.java
+49
-13
TrayInformation.vue
...gecal-web/src/views/screen/components/TrayInformation.vue
+2
-0
No files found.
zhmes-agecal-system/src/main/java/com/zehong/system/modbus/handler/ModbusResultHandler.java
View file @
373b4d94
...
@@ -10,6 +10,8 @@ import com.zehong.system.modbus.business.DeviceStatusReaderAndTimeSetter;
...
@@ -10,6 +10,8 @@ import com.zehong.system.modbus.business.DeviceStatusReaderAndTimeSetter;
import
com.zehong.system.modbus.handler.dto.DeviceStatusReaderDto
;
import
com.zehong.system.modbus.handler.dto.DeviceStatusReaderDto
;
import
com.zehong.system.modbus.util.Modbus4jUtils
;
import
com.zehong.system.modbus.util.Modbus4jUtils
;
import
com.zehong.system.service.ITEquipmentAlarmDataService
;
import
com.zehong.system.service.ITEquipmentAlarmDataService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
...
@@ -29,6 +31,7 @@ import java.util.function.Predicate;
...
@@ -29,6 +31,7 @@ import java.util.function.Predicate;
@Component
@Component
public
class
ModbusResultHandler
implements
Consumer
<
DeviceStatusReaderDto
>
{
public
class
ModbusResultHandler
implements
Consumer
<
DeviceStatusReaderDto
>
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
ModbusResultHandler
.
class
);
@Resource
@Resource
private
ITEquipmentAlarmDataService
alarmDataService
;
private
ITEquipmentAlarmDataService
alarmDataService
;
...
@@ -61,14 +64,14 @@ public class ModbusResultHandler implements Consumer<DeviceStatusReaderDto> {
...
@@ -61,14 +64,14 @@ public class ModbusResultHandler implements Consumer<DeviceStatusReaderDto> {
try
{
try
{
ModbusMaster
master
=
Modbus4jUtils
.
getMaster
(
ip
,
port
);
ModbusMaster
master
=
Modbus4jUtils
.
getMaster
(
ip
,
port
);
System
.
out
.
println
(
">>> 回调处理["
+
Thread
.
currentThread
().
getName
()
+
"]: 接收到新数据"
);
log
.
info
(
">>> 回调处理: 接收到新数据"
+
Thread
.
currentThread
().
getName
()
+
"]: 接收到新数据"
);
System
.
out
.
println
(
" 数据: "
+
Arrays
.
toString
(
data
));
log
.
info
(
" 数据: "
+
Arrays
.
toString
(
data
));
if
(
data
.
length
>=
2
)
{
if
(
data
.
length
>=
2
)
{
// 给点位设置状态
// 给点位设置状态
palletDeviceBinding
.
setStatus
(
data
[
1
]
+
""
);
palletDeviceBinding
.
setStatus
(
data
[
1
]
+
""
);
System
.
out
.
println
(
" >>> 注意: 第二个寄存器值为1 或者 3 或者 4 允许写时间!"
);
log
.
info
(
" >>> 注意: 第二个寄存器值为1 或者 3 或者 4 允许写时间!"
);
if
(
data
[
1
]
==
1
||
data
[
1
]
==
3
||
data
[
1
]
==
4
)
{
if
(
data
[
1
]
==
1
||
data
[
1
]
==
3
||
data
[
1
]
==
4
)
{
Calendar
cal
=
Calendar
.
getInstance
();
Calendar
cal
=
Calendar
.
getInstance
();
...
...
zhmes-agecal-system/src/main/java/com/zehong/system/netty/handler/NettyUdpServerHandler.java
View file @
373b4d94
...
@@ -44,9 +44,6 @@ public class NettyUdpServerHandler extends SimpleChannelInboundHandler<DatagramP
...
@@ -44,9 +44,6 @@ public class NettyUdpServerHandler extends SimpleChannelInboundHandler<DatagramP
private
static
final
SimpleDateFormat
DATE_FORMATTER
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
private
static
final
SimpleDateFormat
DATE_FORMATTER
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
private
static
final
SimpleDateFormat
TIME_FORMATTER
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
private
static
final
SimpleDateFormat
TIME_FORMATTER
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
private
volatile
long
lastActivityTime
=
System
.
currentTimeMillis
();
private
volatile
long
lastActivityTime
=
System
.
currentTimeMillis
();
@Resource
private
NettyUdpServerHandler
nettyUdpServerHandler
;
/**
/**
* 当前正在处理的指令信息
* 当前正在处理的指令信息
*/
*/
...
...
zhmes-agecal-system/src/main/java/com/zehong/system/task/DeviceTaskScheduler.java
View file @
373b4d94
package
com
.
zehong
.
system
.
task
;
package
com
.
zehong
.
system
.
task
;
import
org.quartz.*
;
import
org.quartz.*
;
import
org.quartz.spi.OperableTrigger
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -9,6 +10,7 @@ import javax.annotation.Resource;
...
@@ -9,6 +10,7 @@ import javax.annotation.Resource;
import
java.time.Instant
;
import
java.time.Instant
;
import
java.time.temporal.ChronoUnit
;
import
java.time.temporal.ChronoUnit
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
/**
/**
* @author lenovo
* @author lenovo
...
@@ -43,35 +45,69 @@ public class DeviceTaskScheduler {
...
@@ -43,35 +45,69 @@ public class DeviceTaskScheduler {
* 创建每小时通信任务
* 创建每小时通信任务
*/
*/
private
void
createHourlyCommunicationJob
(
Long
fStoreyId
)
throws
SchedulerException
{
private
void
createHourlyCommunicationJob
(
Long
fStoreyId
)
throws
SchedulerException
{
// 1. 构建任务唯一标识(JobKey = jobId + 任务组名)
// // 1. 构建任务唯一标识(JobKey = jobId + 任务组名)
// String jobId = "COMM_" + fStoreyId;
// JobKey jobKey = new JobKey(jobId, JOB_GROUP);
// // 构建触发器唯一标识(TriggerKey = jobId + "_TRIGGER" + 触发器组名)
// TriggerKey triggerKey = new TriggerKey(jobId + "_TRIGGER", TRIGGER_GROUP);
//
// // 2. 准备JobDetail(与原有逻辑一致,仅初始化不提交)
// String fStoreyIdStr = fStoreyId.toString();
// JobDetail job = JobBuilder.newJob(DeviceCommunicationJob.class)
// .withIdentity(jobKey) // 直接用构建好的JobKey,避免重复编码
// .usingJobData("fStoreyId", fStoreyIdStr)
// .storeDurably() // 保留原有持久化配置
// .build();
//
// // 3. 准备新触发器(Cron调度,与原有逻辑一致)
// Trigger newTrigger = TriggerBuilder.newTrigger()
// .withIdentity(triggerKey) // 用构建好的TriggerKey
// .withSchedule(CronScheduleBuilder.cronSchedule("0 0/2 * * * ?")) // 测试每2分钟执行,后续可改回0 0 * * * ?
// .build();
//
// // 4. 分场景处理:存在则更新,不存在则创建
// if (scheduler.checkExists(jobKey)) {
// // 任务已存在:更新触发器(替换旧触发器为新触发器)
// Date updatedTime = scheduler.rescheduleJob(triggerKey, newTrigger);
// log.info("每小时通信任务[{}]已存在,成功更新触发器,下次执行时间:{}", jobId, updatedTime);
// } else {
// // 任务不存在:创建JobDetail和触发器
// scheduler.scheduleJob(job, newTrigger);
// log.info("每小时通信任务[{}]不存在,成功创建任务及触发器", jobId);
// }
String
jobId
=
"COMM_"
+
fStoreyId
;
String
jobId
=
"COMM_"
+
fStoreyId
;
JobKey
jobKey
=
new
JobKey
(
jobId
,
JOB_GROUP
);
JobKey
jobKey
=
new
JobKey
(
jobId
,
JOB_GROUP
);
// 构建触发器唯一标识(TriggerKey = jobId + "_TRIGGER" + 触发器组名)
TriggerKey
triggerKey
=
new
TriggerKey
(
jobId
+
"_TRIGGER"
,
TRIGGER_GROUP
);
TriggerKey
triggerKey
=
new
TriggerKey
(
jobId
+
"_TRIGGER"
,
TRIGGER_GROUP
);
//
2. 准备JobDetail(与原有逻辑一致,仅初始化不提交)
//
构建JobDetail
String
fStoreyIdStr
=
fStoreyId
.
toString
();
String
fStoreyIdStr
=
fStoreyId
.
toString
();
JobDetail
job
=
JobBuilder
.
newJob
(
DeviceCommunicationJob
.
class
)
JobDetail
job
=
JobBuilder
.
newJob
(
DeviceCommunicationJob
.
class
)
.
withIdentity
(
jobKey
)
// 直接用构建好的JobKey,避免重复编码
.
withIdentity
(
jobKey
)
.
usingJobData
(
"fStoreyId"
,
fStoreyIdStr
)
.
usingJobData
(
"fStoreyId"
,
fStoreyIdStr
)
.
storeDurably
()
// 保留原有持久化配置
.
storeDurably
()
.
build
();
.
build
();
//
3. 准备新触发器(Cron调度,与原有逻辑一致
)
//
构建Cron触发器(核心优化
)
Trigger
newTrigger
=
TriggerBuilder
.
newTrigger
()
Trigger
newTrigger
=
TriggerBuilder
.
newTrigger
()
.
withIdentity
(
triggerKey
)
// 用构建好的TriggerKey
.
withIdentity
(
triggerKey
)
.
withSchedule
(
CronScheduleBuilder
.
cronSchedule
(
"0 0/2 * * * ?"
))
// 测试每2分钟执行,后续可改回0 0 * * * ?
.
withSchedule
(
CronScheduleBuilder
.
cronSchedule
(
"0 0/2 * * * ?"
)
// 处理错过的触发:立即执行一次,然后按原计划继续
.
withMisfireHandlingInstructionFireAndProceed
())
// 显式设置永不结束(避免意外终止)
.
endAt
(
Date
.
from
(
Instant
.
MAX
))
.
build
();
.
build
();
// 4. 分场景处理:存在则更新,不存在则创建
// 打印未来5次执行时间,验证是否每2分钟一次
List
<
Date
>
nextFireTimes
=
TriggerUtils
.
computeFireTimes
((
OperableTrigger
)
newTrigger
,
null
,
5
);
log
.
info
(
"任务[{}]的Cron表达式:0 0/2 * * * ?,未来5次执行时间:{}"
,
jobId
,
nextFireTimes
);
// 存在则更新,不存在则创建
if
(
scheduler
.
checkExists
(
jobKey
))
{
if
(
scheduler
.
checkExists
(
jobKey
))
{
// 任务已存在:更新触发器(替换旧触发器为新触发器)
Date
updatedTime
=
scheduler
.
rescheduleJob
(
triggerKey
,
newTrigger
);
Date
updatedTime
=
scheduler
.
rescheduleJob
(
triggerKey
,
newTrigger
);
log
.
info
(
"
每小时通信任务[{}]已存在,成功
更新触发器,下次执行时间:{}"
,
jobId
,
updatedTime
);
log
.
info
(
"
任务[{}]已存在,
更新触发器,下次执行时间:{}"
,
jobId
,
updatedTime
);
}
else
{
}
else
{
// 任务不存在:创建JobDetail和触发器
scheduler
.
scheduleJob
(
job
,
newTrigger
);
scheduler
.
scheduleJob
(
job
,
newTrigger
);
log
.
info
(
"
每小时通信任务[{}]不存在,成功创建任务及触发器"
,
jobId
);
log
.
info
(
"
任务[{}]创建成功,首次执行时间:{}"
,
jobId
,
nextFireTimes
.
get
(
0
)
);
}
}
}
}
...
...
zhmes-agecal-web/src/views/screen/components/TrayInformation.vue
View file @
373b4d94
...
@@ -51,6 +51,7 @@
...
@@ -51,6 +51,7 @@
<el-table-column
prop=
"status"
label=
"状态"
align=
"center"
>
<el-table-column
prop=
"status"
label=
"状态"
align=
"center"
>
<
template
slot-scope=
"scope"
>
<
template
slot-scope=
"scope"
>
<el-tag
:type=
"statusTagType(scope.row.fStatus)"
v-if=
"scope.row.fStatus === '1'"
class=
"status-tag"
>
运行中
</el-tag>
<el-tag
:type=
"statusTagType(scope.row.fStatus)"
v-if=
"scope.row.fStatus === '1'"
class=
"status-tag"
>
运行中
</el-tag>
<el-tag
:type=
"statusTagType(scope.row.fStatus)"
v-if=
"scope.row.fStatus === '2'"
class=
"status-tag"
>
质检完成
</el-tag>
<el-tag
:type=
"statusTagType(scope.row.fStatus)"
v-else
class=
"status-tag"
>
空闲
</el-tag>
<el-tag
:type=
"statusTagType(scope.row.fStatus)"
v-else
class=
"status-tag"
>
空闲
</el-tag>
</
template
>
</
template
>
</el-table-column>
</el-table-column>
...
@@ -175,6 +176,7 @@ export default {
...
@@ -175,6 +176,7 @@ export default {
statusTagType
(
status
)
{
statusTagType
(
status
)
{
const
statusMap
=
{
const
statusMap
=
{
'0'
:
'success'
,
'0'
:
'success'
,
'2'
:
'warning'
,
'1'
:
'primary'
,
'1'
:
'primary'
,
};
};
return
statusMap
[
status
]
||
'info'
;
return
statusMap
[
status
]
||
'info'
;
...
...
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