Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
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
项目统一框架
amos-boot-biz
Commits
51b78d3d
Commit
51b78d3d
authored
Mar 12, 2024
by
zhangsen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
任务22978
消防泵等事件告警模块问题处理
parent
5424cf2c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
6 deletions
+44
-6
EquipmentIotMqttReceiveConfig.java
...oin/equipmanage/config/EquipmentIotMqttReceiveConfig.java
+2
-2
KafkaConsumerService.java
.../com/yeejoin/amos/message/kafka/KafkaConsumerService.java
+38
-2
application-dev.properties
...ils-message/src/main/resources/application-dev.properties
+4
-2
No files found.
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/config/EquipmentIotMqttReceiveConfig.java
View file @
51b78d3d
...
@@ -126,7 +126,7 @@ public class EquipmentIotMqttReceiveConfig {
...
@@ -126,7 +126,7 @@ public class EquipmentIotMqttReceiveConfig {
list
.
add
(
"+/+/event"
);
// 添加iot事件监听
list
.
add
(
"+/+/event"
);
// 添加iot事件监听
list
.
add
(
"+/+/transmit"
);
// 添加交换站事件监听
list
.
add
(
"+/+/transmit"
);
// 添加交换站事件监听
list
.
add
(
"+/+/perspective"
);
// 添加交换站事件监听
list
.
add
(
"+/+/perspective"
);
// 添加交换站事件监听
list
.
add
(
"+/+/
shaoshan"
);
// 添加换流站韶山监听事件
list
.
add
(
"+/+/
eventAlarm"
);
// 添加换流站韶山监听事件 --- shaoshan 修改为 eventAlarm:事件告警 - 统一
String
[]
arr
=
list
.
toArray
(
new
String
[
list
.
size
()]);
String
[]
arr
=
list
.
toArray
(
new
String
[
list
.
size
()]);
adapter
=
new
MqttPahoMessageDrivenChannelAdapter
(
clientId
+
"_inbound"
,
mqttPahoClientFactory
(),
arr
);
adapter
=
new
MqttPahoMessageDrivenChannelAdapter
(
clientId
+
"_inbound"
,
mqttPahoClientFactory
(),
arr
);
adapter
.
setCompletionTimeout
(
completionTimeout
);
adapter
.
setCompletionTimeout
(
completionTimeout
);
...
@@ -152,7 +152,7 @@ public class EquipmentIotMqttReceiveConfig {
...
@@ -152,7 +152,7 @@ public class EquipmentIotMqttReceiveConfig {
mqttEventReceiveService
.
handlerMqttIncrementMessage
(
topic
,
msg
);
mqttEventReceiveService
.
handlerMqttIncrementMessage
(
topic
,
msg
);
}
else
if
(
dataType
.
equals
(
"transmit"
)
&&
StringUtil
.
isNotEmpty
(
msg
)){
// 遥信遥测信号
}
else
if
(
dataType
.
equals
(
"transmit"
)
&&
StringUtil
.
isNotEmpty
(
msg
)){
// 遥信遥测信号
mqttReceiveService
.
handlerMqttRomaMessage
(
topic
,
msg
);
mqttReceiveService
.
handlerMqttRomaMessage
(
topic
,
msg
);
}
else
if
(
dataType
.
equals
(
"
shaoshan
"
)
&&
StringUtil
.
isNotEmpty
(
msg
)){
// 告警信号
}
else
if
(
dataType
.
equals
(
"
eventAlarm
"
)
&&
StringUtil
.
isNotEmpty
(
msg
)){
// 告警信号
mqttReceiveService
.
handlerMqttStationMessage
(
topic
,
msg
);
mqttReceiveService
.
handlerMqttStationMessage
(
topic
,
msg
);
}
}
}
}
...
...
amos-boot-utils/amos-boot-utils-message/src/main/java/com/yeejoin/amos/message/kafka/KafkaConsumerService.java
View file @
51b78d3d
package
com
.
yeejoin
.
amos
.
message
.
kafka
;
package
com
.
yeejoin
.
amos
.
message
.
kafka
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
net.sf.json.JSONArray
;
import
net.sf.json.JSONObject
;
import
net.sf.json.JSONObject
;
import
org.apache.kafka.clients.consumer.ConsumerRecord
;
import
org.apache.kafka.clients.consumer.ConsumerRecord
;
import
org.eclipse.paho.client.mqttv3.MqttException
;
import
org.eclipse.paho.client.mqttv3.MqttException
;
...
@@ -22,7 +23,7 @@ import java.util.Optional;
...
@@ -22,7 +23,7 @@ import java.util.Optional;
@Service
@Service
public
class
KafkaConsumerService
{
public
class
KafkaConsumerService
{
private
static
final
String
MQTT_TOPIC
=
"romaSite/data/transmit"
;
private
static
final
String
MQTT_TOPIC
=
"romaSite/data/transmit"
;
private
static
final
String
MQTT_TOPIC_
SHAOSHAN
=
"romaSite/data/shaoshan
"
;
private
static
final
String
MQTT_TOPIC_
EVENT_ALARM
=
"romaSite/data/eventAlarm
"
;
@Autowired
@Autowired
protected
EmqKeeper
emqKeeper
;
protected
EmqKeeper
emqKeeper
;
...
@@ -83,7 +84,42 @@ public class KafkaConsumerService {
...
@@ -83,7 +84,42 @@ public class KafkaConsumerService {
try
{
try
{
JSONObject
messageObj
=
JSONObject
.
fromObject
(
record
.
value
());
JSONObject
messageObj
=
JSONObject
.
fromObject
(
record
.
value
());
JSONObject
data
=
messageObj
.
getJSONObject
(
"body"
);
JSONObject
data
=
messageObj
.
getJSONObject
(
"body"
);
emqKeeper
.
getMqttClient
().
publish
(
MQTT_TOPIC_SHAOSHAN
,
data
.
toString
().
getBytes
(
StandardCharsets
.
UTF_8
),
0
,
false
);
emqKeeper
.
getMqttClient
().
publish
(
MQTT_TOPIC_EVENT_ALARM
,
data
.
toString
().
getBytes
(
StandardCharsets
.
UTF_8
),
0
,
false
);
ack
.
acknowledge
();
}
catch
(
MqttException
e
)
{
log
.
error
(
"解析数据失败,{}"
,
e
.
getMessage
());
}
}
}
/**
* 事件告警对接Kafka
* @param record record
* @param ack ack
* groupId = kafkaConsumerGroup
*/
@KafkaListener
(
id
=
"kafkaConsumerEventAlarm"
,
groupId
=
"kafkaConsumerGroupEventAlarm"
,
topics
=
"#{'${queue.kafka.eventAlarm.topics}'.split(',')}"
,
containerFactory
=
"kafkaRomaContainerFactory"
)
public
void
kafkaConsumerEventAlarm
(
ConsumerRecord
<?,
String
>
record
,
Acknowledgment
ack
)
{
Optional
<?>
message
=
Optional
.
ofNullable
(
record
.
value
());
if
(
message
.
isPresent
())
{
try
{
JSONObject
messageObj
=
JSONObject
.
fromObject
(
record
.
value
());
JSONArray
dataArray
=
messageObj
.
getJSONArray
(
"data"
);
JSONArray
jsonArray
=
new
JSONArray
();
String
timestamp
=
""
;
for
(
Object
obj
:
dataArray
)
{
JSONObject
finallyObj
=
new
JSONObject
();
com
.
alibaba
.
fastjson
.
JSONObject
detail
=
com
.
alibaba
.
fastjson
.
JSONObject
.
parseObject
(
com
.
alibaba
.
fastjson
.
JSONObject
.
toJSONString
(
obj
));
finallyObj
.
put
(
"eventtextL1"
,
detail
.
get
(
"description"
));
finallyObj
.
put
(
"pointId"
,
detail
.
get
(
"astId"
));
finallyObj
.
put
(
"time"
,
detail
.
get
(
"dateTime"
));
jsonArray
.
add
(
finallyObj
);
timestamp
=
detail
.
get
(
"dateTime"
).
toString
();
}
JSONObject
jsonObjectMessage
=
new
JSONObject
();
jsonObjectMessage
.
put
(
"warns"
,
jsonArray
);
jsonObjectMessage
.
put
(
"timestamp"
,
timestamp
);
emqKeeper
.
getMqttClient
().
publish
(
MQTT_TOPIC_EVENT_ALARM
,
jsonObjectMessage
.
toString
().
getBytes
(
StandardCharsets
.
UTF_8
),
0
,
false
);
ack
.
acknowledge
();
ack
.
acknowledge
();
}
catch
(
MqttException
e
)
{
}
catch
(
MqttException
e
)
{
log
.
error
(
"解析数据失败,{}"
,
e
.
getMessage
());
log
.
error
(
"解析数据失败,{}"
,
e
.
getMessage
());
...
...
amos-boot-utils/amos-boot-utils-message/src/main/resources/application-dev.properties
View file @
51b78d3d
...
@@ -97,4 +97,7 @@ emq.topic=emq.xf.created,emq.iot.created,emq.patrol.created,emq.sign.created,emq
...
@@ -97,4 +97,7 @@ emq.topic=emq.xf.created,emq.iot.created,emq.patrol.created,emq.sign.created,emq
#自定义Kafka配置对接交换站
#自定义Kafka配置对接交换站
queue.kafka.topics
=
null
queue.kafka.topics
=
null
kafka.auto-startup
=
false
kafka.auto-startup
=
false
\ No newline at end of file
#事件告警对接Kafka主题
queue.kafka.eventAlarm.topics
=
JKXT2BP-GJ-Topic-site
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