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
11268dbc
Commit
11268dbc
authored
Apr 21, 2022
by
李成龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
气瓶预警消息
parent
462f2ce7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
2 deletions
+47
-2
CylWarningMsgAction.java
.../amos/boot/module/tzs/biz/action/CylWarningMsgAction.java
+47
-2
No files found.
amos-boot-module/amos-boot-module-biz/amos-boot-module-tzs-biz/src/main/java/com/yeejoin/amos/boot/module/tzs/biz/action/CylWarningMsgAction.java
View file @
11268dbc
package
com
.
yeejoin
.
amos
.
boot
.
module
.
tzs
.
biz
.
action
;
import
java.io.UnsupportedEncodingException
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Method
;
import
java.util.Date
;
import
java.util.Map
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
org.eclipse.paho.client.mqttv3.MqttException
;
import
org.slf4j.Logger
;
...
...
@@ -54,6 +58,7 @@ public class CylWarningMsgAction{
CylWarningMsgDto
cylWarningMsgDto
=
(
CylWarningMsgDto
)
bizobj
;
//更新气瓶等级
logger
.
info
(
"更新气瓶等级:"
+
level
);
logger
.
info
(
"预警区间:"
+
cylWarningMsgDto
.
getNum
());
cylinderInfoServiceImpl
.
updateEarlyWarningLevel
(
cylWarningMsgDto
.
getCylSeq
(),
level
);
//增加消息日志数据
MsgLog
msgLog
=
new
MsgLog
();
...
...
@@ -69,7 +74,7 @@ public class CylWarningMsgAction{
logger
.
info
(
"增加消息日志数据:"
+
msgLog
.
toString
());
//发送web消息
try
{
emqKeeper
.
getMqttClient
().
publish
(
cylpushTopic
,
text
.
getBytes
(
"UTF-8"
),
2
,
false
);
emqKeeper
.
getMqttClient
().
publish
(
cylpushTopic
,
instedParams
(
text
,
cylWarningMsgDto
)
.
getBytes
(
"UTF-8"
),
2
,
false
);
logger
.
info
(
"气瓶预警消息发送成功:"
);
}
catch
(
MqttException
e
)
{
e
.
printStackTrace
();
...
...
@@ -103,11 +108,51 @@ public class CylWarningMsgAction{
wechatMessageDto1
.
setTemplateId
(
templateId_Warning
);
Map
<
String
,
String
>
data1
=
Maps
.
newHashMap
();
data1
.
put
(
"first"
,
"【陕西特种设备安全监察局】风险预警提醒"
);
data1
.
put
(
"keyword1"
,
text
);
data1
.
put
(
"keyword1"
,
instedParams
(
text
,
cylWarningMsgDto
)
);
data1
.
put
(
"keyword2"
,
DateUtils
.
date2LongStr
(
new
Date
()));
wechatMessageDto1
.
setData
(
data1
);
wechatServiceImpl
.
sendWechatModelMessage
(
wechatRelation
.
getOpenId
(),
wechatMessageDto1
);
logger
.
info
(
"公众号消息发送成功:"
);
}
}
private
String
instedParams
(
String
content
,
CylWarningMsgDto
contingencyRo
)
{
// Map<String, String> strengthMap = this.getStrengthMap(contingencyRo);
// for (String key : strengthMap.keySet())
// content = content.replaceAll("\\$\\{" + key + "}", strengthMap.get(key));
Field
[]
fields
=
contingencyRo
.
getClass
().
getDeclaredFields
();
Method
getMethod
=
null
;
try
{
for
(
Field
field
:
fields
)
{
if
(
field
.
getName
().
equals
(
"serialVersionUID"
))
continue
;
String
fileNameInMethod
=
String
.
valueOf
(
field
.
getName
().
charAt
(
0
)).
toUpperCase
()
+
field
.
getName
().
substring
(
1
);
getMethod
=
contingencyRo
.
getClass
().
getMethod
(
"get"
+
fileNameInMethod
);
String
value
=
String
.
valueOf
(
getMethod
.
invoke
(
contingencyRo
));
content
=
content
.
replaceAll
(
"\\$\\{"
+
field
.
getName
()
+
"}"
,
value
);
}
content
=
getNative
(
content
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
content
;
}
public
String
getNative
(
String
str
)
{
Pattern
p
=
Pattern
.
compile
(
"\\$\\{(.*?)\\}"
);
Matcher
m
=
p
.
matcher
(
str
);
while
(
m
.
find
())
{
String
parameter
=
m
.
group
();
Object
parametervalue
=
ELEvaluationContext
.
getValue
(
parameter
.
substring
(
1
,
parameter
.
length
()
-
1
));
if
(
parametervalue
!=
null
)
str
=
str
.
replace
(
parameter
,
parametervalue
!=
null
?
parametervalue
.
toString
()
:
null
);
}
return
str
;
}
}
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