Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
yang_shj 1 year ago
parent
commit
5f366fe79d
  1. 7
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java
  2. 40
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/VideoMqttConsumer.java
  3. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java

7
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java

@ -3,6 +3,7 @@ package com.hnac.hzims.alarm.mqtt;
import com.hnac.hzinfo.subscribe.AnalysisSubscribe; import com.hnac.hzinfo.subscribe.AnalysisSubscribe;
import com.hnac.hzinfo.subscribe.DroolsSoeSubscribe; import com.hnac.hzinfo.subscribe.DroolsSoeSubscribe;
import com.hnac.hzinfo.subscribe.HZ3000SoeSubscribe; import com.hnac.hzinfo.subscribe.HZ3000SoeSubscribe;
import com.hnac.hzinfo.subscribe.SoeSubscribe;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.MqttAsyncClient; import org.eclipse.paho.client.mqttv3.MqttAsyncClient;
import org.eclipse.paho.client.mqttv3.MqttException; import org.eclipse.paho.client.mqttv3.MqttException;
@ -27,6 +28,8 @@ public class MqttConfig {
DroolsMqttConsumer droolsMqttConsumer; DroolsMqttConsumer droolsMqttConsumer;
@Autowired @Autowired
HZ300MqttConsumer hz300MqttConsumer; HZ300MqttConsumer hz300MqttConsumer;
@Autowired
VideoMqttConsumer videoMqttConsumer;
@Value("${hzims.mqtt.url}") @Value("${hzims.mqtt.url}")
private String mqtt_fdp_url; private String mqtt_fdp_url;
@Value("${hzims.mqtt.group}") @Value("${hzims.mqtt.group}")
@ -61,6 +64,10 @@ public class MqttConfig {
HZ3000SoeSubscribe hz3000SoeSubscribe = new HZ3000SoeSubscribe(); HZ3000SoeSubscribe hz3000SoeSubscribe = new HZ3000SoeSubscribe();
MqttAsyncClient hz3000Client = hz3000SoeSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), hz300MqttConsumer); MqttAsyncClient hz3000Client = hz3000SoeSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), hz300MqttConsumer);
log.info(hz3000Client.toString()); log.info(hz3000Client.toString());
//视频
SoeSubscribe subscribe = new SoeSubscribe();
MqttAsyncClient videoClient = subscribe.subscribe(mqttConfig, Collections.singletonList("#"), videoMqttConsumer);
log.info(videoClient.toString());
}catch (MqttException e){ }catch (MqttException e){
log.error(e.toString()) ; log.error(e.toString()) ;
} }

40
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/VideoMqttConsumer.java

@ -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);
}
}
}

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java

@ -1549,7 +1549,7 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl<ImsDutyMainMapper, I
if (CollectionUtil.isNotEmpty(imsSchedulingVos)){ if (CollectionUtil.isNotEmpty(imsSchedulingVos)){
return R.data(imsSchedulingVos); return R.data(imsSchedulingVos);
} }
return R.fail("暂无排班计划"); return R.success("暂无排班计划");
} }

Loading…
Cancel
Save