Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dmhub-plugin
Project
Project
Details
Activity
Releases
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
qinxunjia
dmhub-plugin
Commits
c468940a
Commit
c468940a
authored
Jun 17, 2020
by
qinxunjia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
发送短信获取不到参数的问题
parent
7ce0a5b5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
19 deletions
+41
-19
MessageServiceImpl.java
...ain/java/com/bgy/sms/service/impl/MessageServiceImpl.java
+41
-19
No files found.
src/main/java/com/bgy/sms/service/impl/MessageServiceImpl.java
View file @
c468940a
...
...
@@ -196,7 +196,6 @@ public class MessageServiceImpl implements MessageService {
String
smsType
=
templateInfo
.
getType
();
// 封装参数
List
<
String
>
paramList
=
new
ArrayList
<>();
Set
<
String
>
keys
=
data
.
keySet
();
String
mobile
=
data
.
getString
(
"_audienceId"
);
data
.
remove
(
"name"
);
data
.
remove
(
"id"
);
...
...
@@ -204,18 +203,16 @@ public class MessageServiceImpl implements MessageService {
log
.
info
(
"data信息:{}"
,
data
);
if
(!
data
.
isEmpty
())
{
List
<
String
>
paramsList
=
new
ArrayList
<>();
StringBuffer
sb
=
new
StringBuffer
();
Map
<
String
,
String
>
retMap
=
new
HashMap
<>();
getKeyAndValue
(
data
,
paramsList
,
sb
,
retMap
);
for
(
Object
parm
:
paramsArr
)
{
String
s
=
parm
.
toString
();
for
(
String
key
:
keys
)
{
String
newKey
=
key
;
Object
value
=
data
.
get
(
key
);
if
(
value
instanceof
JSONObject
||
value
instanceof
Map
)
{
StringBuilder
keyBuffer
=
new
StringBuilder
(
key
);
value
=
getKeyValue
(
value
,
keyBuffer
);
newKey
=
keyBuffer
.
toString
();
}
for
(
String
newKeyStr
:
paramsList
)
{
String
newKey
=
newKeyStr
.
substring
(
1
);
if
(
s
.
contains
(
newKey
))
{
paramList
.
add
(
value
.
toString
(
));
paramList
.
add
(
retMap
.
get
(
newKeyStr
));
}
}
}
...
...
@@ -433,18 +430,16 @@ public class MessageServiceImpl implements MessageService {
mobileList
.
add
(
mobile
);
List
<
String
>
list
=
new
ArrayList
<>();
if
(!
json
.
isEmpty
())
{
List
<
String
>
paramsList
=
new
ArrayList
<>();
StringBuffer
sb
=
new
StringBuffer
();
Map
<
String
,
String
>
retMap
=
new
HashMap
<>();
getKeyAndValue
(
json
,
paramsList
,
sb
,
retMap
);
for
(
Object
parm
:
paramsArr
)
{
String
s
=
parm
.
toString
();
for
(
String
key
:
keys
)
{
String
newKey
=
key
;
Object
value
=
json
.
get
(
key
);
if
(
value
instanceof
JSONObject
||
value
instanceof
Map
)
{
StringBuilder
keyBuffer
=
new
StringBuilder
(
key
);
value
=
getKeyValue
(
value
,
keyBuffer
);
newKey
=
keyBuffer
.
toString
();
}
for
(
String
newKeyStr
:
paramsList
)
{
String
newKey
=
newKeyStr
.
substring
(
1
);
if
(
s
.
contains
(
newKey
))
{
list
.
add
(
value
.
toString
());
list
.
add
(
retMap
.
get
(
newKeyStr
)
.
toString
());
}
}
paramsMap
.
put
(
mobile
,
list
);
...
...
@@ -521,6 +516,33 @@ public class MessageServiceImpl implements MessageService {
return
new
DmHubResponse
(
ResponseCode
.
SUCCESS
);
}
private
static
void
getKeyAndValue
(
JSONObject
json
,
List
<
String
>
keyList
,
StringBuffer
keyBuffer
,
Map
<
String
,
String
>
paramsMap
)
{
Set
<
String
>
keys
=
json
.
keySet
();
for
(
String
key
:
keys
)
{
keyBuffer
.
append
(
"."
).
append
(
key
);
Object
info
=
json
.
get
(
key
);
StringBuffer
tempInfo
=
new
StringBuffer
();
if
(
info
instanceof
JSONObject
||
info
instanceof
Map
)
{
String
s
=
JSONObject
.
toJSONString
(
info
);
JSONObject
valueJson
=
JSONObject
.
parseObject
(
s
);
getKeyAndValue
(
valueJson
,
keyList
,
keyBuffer
,
paramsMap
);
int
key1
=
keyBuffer
.
indexOf
(
key
);
String
substring
=
keyBuffer
.
substring
(
0
,
key1
-
1
);
System
.
out
.
println
(
substring
);
keyBuffer
=
new
StringBuffer
(
substring
);
}
else
{
paramsMap
.
put
(
keyBuffer
.
toString
(),
info
.
toString
());
keyList
.
add
(
keyBuffer
.
toString
());
int
key1
=
keyBuffer
.
indexOf
(
key
);
String
substring
=
keyBuffer
.
substring
(
0
,
key1
-
1
);
System
.
out
.
println
(
substring
);
keyBuffer
=
new
StringBuffer
(
substring
);
}
}
}
private
String
getKeyValue
(
Object
value
,
StringBuilder
keyBuffer
)
{
String
s
=
JSONObject
.
toJSONString
(
value
);
JSONObject
valueJson
=
JSONObject
.
parseObject
(
s
);
...
...
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