Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
黄嘉阳
/
iot-platform-server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e0b542d9
authored
Oct 09, 2023
by
李小龙
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix: 语音短信模板
parent
ab289d3e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
19 deletions
server-common/src/main/java/com/makeit/utils/msg/sender/SmsMsgSender.java
server-common/src/main/java/com/makeit/utils/msg/sender/SmsMsgSender.java
View file @
e0b542d9
...
...
@@ -19,7 +19,6 @@ import java.net.URLEncoder;
import
java.util.Collection
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.stream.Collectors
;
@Component
@Slf4j
...
...
@@ -49,25 +48,31 @@ public class SmsMsgSender implements IMsgSender{
Date
now
=
new
Date
();
String
time
=
String
.
valueOf
(
now
.
getTime
());
Collection
<
String
>
receiverList
=
msgDTO
.
getReceiverList
();
String
receiverJoin
=
receiverList
.
stream
().
collect
(
Collectors
.
joining
(
","
));
HashMap
<
String
,
String
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"uid"
,
smsConfig
.
getUid
());
//md5-32位( md5-16位(登录密码)+ time )
String
md16
=
CryptoUtil
.
md5_16
(
smsConfig
.
getPwd
());
String
md32
=
CryptoUtil
.
md5
(
md16
+
time
);
paramMap
.
put
(
"pwd"
,
md32
);
paramMap
.
put
(
"time"
,
time
);
paramMap
.
put
(
"mobile"
,
receiverJoin
);
paramMap
.
put
(
"content"
,
URLEncoder
.
encode
(
msgDTO
.
getOriContent
(),
"UTF-8"
));
String
resStr
=
HttpClient
.
sendJSONPostRequest
(
smsConfig
.
getUrl
(),
paramMap
,
new
HttpHeaders
(),
String
.
class
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
resStr
);
String
status
=
String
.
valueOf
(
jsonObject
.
get
(
"status"
));
if
(!
StringUtils
.
equals
(
status
,
"0"
))
{
log
.
error
(
"发送短信失败:"
+
jsonObject
.
get
(
"status_code"
));
throw
new
BusinessException
((
String
)
jsonObject
.
get
(
"status_code"
));
}
else
{
log
.
info
(
"发送短信成功"
);
for
(
String
receiver
:
receiverList
)
{
try
{
HashMap
<
String
,
String
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"uid"
,
smsConfig
.
getUid
());
//md5-32位( md5-16位(登录密码)+ time )
String
md16
=
CryptoUtil
.
md5_16
(
smsConfig
.
getPwd
());
String
md32
=
CryptoUtil
.
md5
(
md16
+
time
);
paramMap
.
put
(
"pwd"
,
md32
);
paramMap
.
put
(
"time"
,
time
);
paramMap
.
put
(
"mobile"
,
receiver
);
paramMap
.
put
(
"content"
,
URLEncoder
.
encode
(
msgDTO
.
getOriContent
(),
"UTF-8"
));
String
resStr
=
HttpClient
.
sendJSONPostRequest
(
smsConfig
.
getUrl
(),
paramMap
,
new
HttpHeaders
(),
String
.
class
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
resStr
);
String
status
=
String
.
valueOf
(
jsonObject
.
get
(
"status"
));
if
(!
StringUtils
.
equals
(
status
,
"0"
))
{
log
.
error
(
"发送短信失败:"
+
jsonObject
.
get
(
"status_code"
));
throw
new
BusinessException
((
String
)
jsonObject
.
get
(
"status_code"
));
}
else
{
log
.
info
(
"发送短信成功"
);
}
}
catch
(
Exception
e
){
log
.
error
(
"发送短信异常:"
,
msgDTO
,
e
);
}
}
}
catch
(
Exception
e
){
log
.
error
(
"发送短信异常:"
,
msgDTO
,
e
);
}
...
...
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