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
277ecdc7
Commit
277ecdc7
authored
Nov 15, 2024
by
litengwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
messgae修改
parent
8f69a4e0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
KafkaConsumerService.java
.../com/yeejoin/amos/message/kafka/KafkaConsumerService.java
+4
-3
No files found.
amos-boot-utils/amos-boot-utils-message/src/main/java/com/yeejoin/amos/message/kafka/KafkaConsumerService.java
View file @
277ecdc7
package
com
.
yeejoin
.
amos
.
message
.
kafka
;
import
com.alibaba.excel.metadata.Sheet
;
import
com.alibaba.fastjson.JSON
;
import
com.yeejoin.amos.message.utils.ClassToJsonUtil
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -82,7 +83,7 @@ public class KafkaConsumerService implements ApplicationRunner {
com
.
alibaba
.
fastjson
.
JSONObject
jsonObj
=
ClassToJsonUtil
.
class2json
(
object
,
commonMessage
,
record
.
topic
());
if
((
StringUtils
.
isEmpty
(
filePath
))
||
(
CollectionUtils
.
isEmpty
(
codeListInfo
))
||
(!
ObjectUtils
.
isEmpty
(
jsonObj
)
&&
Boolean
.
TRUE
.
equals
(
isSendEmq
(
jsonObj
))))
{
log
.
info
(
"kafka上报mqtt数据:{}"
,
JSON
.
toJSONString
(
jsonObj
));
emqKeeper
.
getMqttClient
().
publish
(
String
.
valueOf
(
jsonObj
.
get
(
"mqTopic"
)),
JSON
.
toJSONString
(
jsonObj
).
getBytes
(
"UTF-8"
),
0
,
false
);
emqKeeper
.
getMqttClient
().
publish
(
String
.
valueOf
(
jsonObj
.
get
(
"mqTopic"
)),
JSON
.
toJSONString
(
jsonObj
).
getBytes
(
"UTF-8"
),
2
,
false
);
}
}
}
catch
(
MqttException
e
)
{
...
...
@@ -108,7 +109,7 @@ public class KafkaConsumerService implements ApplicationRunner {
if
(
messageObj
.
has
(
"topic"
))
{
topic
=
messageObj
.
getString
(
"topic"
);
data
=
messageObj
.
getJSONObject
(
"data"
);
emqKeeper
.
getMqttClient
().
publish
(
topic
,
data
.
toString
().
getBytes
(
StandardCharsets
.
UTF_8
),
0
,
false
);
emqKeeper
.
getMqttClient
().
publish
(
topic
,
data
.
toString
().
getBytes
(
StandardCharsets
.
UTF_8
),
2
,
false
);
ack
.
acknowledge
();
log
.
info
(
"消息转发成功"
+
messageObj
);
}
...
...
@@ -140,7 +141,7 @@ public class KafkaConsumerService implements ApplicationRunner {
public
static
List
<
String
>
readExcelFile
(
String
filePath
)
{
try
(
FileInputStream
fis
=
new
FileInputStream
(
new
File
(
filePath
));
Workbook
workbook
=
new
XSSFWorkbook
(
fis
))
{
Sheet
sheet
=
workbook
.
getSheetAt
(
0
);
// 获取第一个工作表
com
.
alibaba
.
excel
.
metadata
.
Sheet
sheet
=
workbook
.
getSheetAt
(
0
);
// 获取第一个工作表
List
<
String
>
list
=
getColumnData
(
sheet
);
// 在这里处理list中的数据,例如打印、存储等操作
return
list
;
...
...
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