yang_shj
1 year ago
3 changed files with 48 additions and 1 deletions
@ -0,0 +1,40 @@ |
|||||||
|
package com.hnac.hzims.alarm.mqtt; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
import com.hnac.hzims.alarm.entity.AlarmEntity; |
||||||
|
import com.hnac.hzims.alarm.handle.service.VideoAlarmService; |
||||||
|
import com.hnac.hzims.alarm.monitor.service.AlarmSaveService; |
||||||
|
import com.hnac.hzinfo.subscribe.SubscribeCallBack; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* |
||||||
|
* @Author: ty |
||||||
|
*/ |
||||||
|
|
||||||
|
@Service |
||||||
|
@Slf4j |
||||||
|
public class VideoMqttConsumer implements SubscribeCallBack { |
||||||
|
@Autowired |
||||||
|
private VideoAlarmService videoAlarmService; |
||||||
|
@Autowired |
||||||
|
private AlarmSaveService alarmSaveService; |
||||||
|
@Override |
||||||
|
public void onMessage(Map<String, Object> data) { |
||||||
|
System.out.println("监听到消息"+data.toString()); |
||||||
|
String s = JSONObject.toJSONString(data); |
||||||
|
//消费代码
|
||||||
|
List<AlarmEntity> alarmEntities = videoAlarmService.receiveMessage(s); |
||||||
|
//统一数据处理
|
||||||
|
try { |
||||||
|
alarmSaveService.save(alarmEntities); |
||||||
|
}catch (Exception e){ |
||||||
|
log.error("HZ3000告警数据处理报错(HZ300Alarm):"+e); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue