@ -42,8 +42,6 @@ public class BatchDeviceMessageProcessor {
@Resource
@Resource
private TdengineBatchConfig < TdengineDataVo > tdengineBatchConfig ;
private TdengineBatchConfig < TdengineDataVo > tdengineBatchConfig ;
@Resource
@Resource
private TdengineBatchConfig < AlarmMessageLog > alarmProcessor ;
@Resource
private HandDetectorService handDetectorService ;
private HandDetectorService handDetectorService ;
@Resource
@Resource
private HandAlarmService handAlarmService ;
private HandAlarmService handAlarmService ;
@ -207,11 +205,6 @@ public class BatchDeviceMessageProcessor {
log . debug ( "[批量持久化] 处理日志: {} 条" , context . processedLogs . size ( ) ) ;
log . debug ( "[批量持久化] 处理日志: {} 条" , context . processedLogs . size ( ) ) ;
}
}
// 3. 批量保存报警消息日志
if ( ! context . alarmMessageLogs . isEmpty ( ) ) {
alarmProcessor . addToBatch ( context . alarmMessageLogs ) ;
log . debug ( "[批量持久化] 报警消息: {} 条" , context . alarmMessageLogs . size ( ) ) ;
}
// 4. 批量创建气体报警
// 4. 批量创建气体报警
if ( ! context . gasAlarmsToCreate . isEmpty ( ) ) {
if ( ! context . gasAlarmsToCreate . isEmpty ( ) ) {
// 2. 批量保存
// 2. 批量保存
@ -851,25 +844,16 @@ public class BatchDeviceMessageProcessor {
String msgContent = String . format ( "%s%s,%s气体浓度为%s" ,
String msgContent = String . format ( "%s%s,%s气体浓度为%s" ,
handVo . getUserName ( ) , statusText , gasName , valueStr ) ;
handVo . getUserName ( ) , statusText , gasName , valueStr ) ;
// 记录报警消息日志
AlarmMessageLog alarmMessageLog = new AlarmMessageLog ( ) ;
alarmMessageLog . setDetectorId ( handVo . getId ( ) ) ;
alarmMessageLog . setHolderName ( handVo . getUserName ( ) ) ;
alarmMessageLog . setSn ( handVo . getSn ( ) ) ;
alarmMessageLog . setDeptId ( handVo . getDeptId ( ) ) ;
alarmMessageLog . setTenantId ( handVo . getTenantId ( ) ) ;
alarmMessageLog . setMessage ( msgContent ) ;
alarmMessageLog . setRemark ( "系统自动触发报警推送" ) ;
try {
try {
AlarmDispatchEvent event = new AlarmDispatchEvent (
AlarmDispatchEvent event = new AlarmDispatchEvent (
handVo . getId ( ) ,
handVo . getDeptId ( ) ,
handVo . getDeptId ( ) ,
handVo . getTenantId ( ) ,
handVo . getTenantId ( ) ,
handVo . getSn ( ) ,
handVo . getSn ( ) ,
handVo . getUserName ( ) ,
msgContent
msgContent
) ;
) ;
// 使用 sourceSn 作为 Key,保证同一个部门/设备的报警排队有序处理
// 使用 sourceSn 作为 Key,保证同一个部门/设备的报警排队有序处理
String key = handVo . getSn ( ) ;
String key = handVo . getSn ( ) ;
String json = JsonUtils . toJsonString ( event ) ;
String json = JsonUtils . toJsonString ( event ) ;
@ -878,7 +862,6 @@ public class BatchDeviceMessageProcessor {
log . error ( "[报警推送] 准备推送数据失败" , e ) ;
log . error ( "[报警推送] 准备推送数据失败" , e ) ;
}
}
context . alarmMessageLogs . add ( alarmMessageLog ) ;
}
}
@ -942,7 +925,6 @@ public class BatchDeviceMessageProcessor {
// 待保存的日志
// 待保存的日志
List < HandOriginalLog > originalLogs = new ArrayList < > ( ) ;
List < HandOriginalLog > originalLogs = new ArrayList < > ( ) ;
List < TdengineDataVo > processedLogs = new ArrayList < > ( ) ;
List < TdengineDataVo > processedLogs = new ArrayList < > ( ) ;
List < AlarmMessageLog > alarmMessageLogs = new ArrayList < > ( ) ;
// 待保存的报警
// 待保存的报警
List < HandAlarmDO > gasAlarmsToCreate = new ArrayList < > ( ) ;
List < HandAlarmDO > gasAlarmsToCreate = new ArrayList < > ( ) ;