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
561456b1
Commit
561456b1
authored
Apr 24, 2020
by
qinxunjia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化正则
parent
509a4926
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
163 additions
and
32 deletions
+163
-32
ChuangLanApi.java
src/main/java/com/jz/sms/api/ChuangLanApi.java
+15
-10
ReportDto.java
src/main/java/com/jz/sms/chuanglan/dto/ReportDto.java
+116
-0
ChuangLanSmsService.java
...ava/com/jz/sms/chuanglan/service/ChuangLanSmsService.java
+4
-1
ChuangLanSmsServiceImpl.java
...z/sms/chuanglan/service/impl/ChuangLanSmsServiceImpl.java
+26
-6
MessageServiceImpl.java
...main/java/com/jz/sms/service/impl/MessageServiceImpl.java
+2
-15
No files found.
src/main/java/com/jz/sms/api/ChuangLanApi.java
View file @
561456b1
...
...
@@ -2,6 +2,7 @@ package com.jz.sms.api;
import
com.jz.sms.chuanglan.dto.CLNotifyRequest
;
import
com.jz.sms.chuanglan.dto.ReportDto
;
import
com.jz.sms.chuanglan.service.ChuangLanSmsService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -18,16 +19,6 @@ import java.util.regex.Pattern;
@RestController
public
class
ChuangLanApi
{
public
static
void
main
(
String
[]
args
)
{
String
regex
=
"\\$\\{([^'}]*)'\\}"
;
Pattern
pattern
=
Pattern
.
compile
(
regex
);
Matcher
matcher
=
pattern
.
matcher
(
"你需要${a522}匹${555'}配的字符串"
);
while
(
matcher
.
find
())
{
System
.
out
.
println
(
matcher
.
group
());
}
}
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
ChuangLanApi
.
class
);
@Autowired
...
...
@@ -44,4 +35,18 @@ public class ChuangLanApi {
log
.
info
(
"创蓝异步通知接口出参:{}"
,
response
);
return
response
;
}
@PostMapping
(
"/report"
)
public
String
report
(
@RequestParam
ReportDto
report
)
{
log
.
info
(
"回送报告接口入参:{}"
,
report
);
chuangLanSmsService
.
report
(
report
);
String
response
=
"success"
;
log
.
info
(
"创蓝异步通知接口出参:{}"
,
response
);
return
response
;
}
}
src/main/java/com/jz/sms/chuanglan/dto/ReportDto.java
0 → 100644
View file @
561456b1
package
com
.
jz
.
sms
.
chuanglan
.
dto
;
public
class
ReportDto
{
//receiver=admin
//&pswd=12345
//&msgid=17041010383624511
//&reportTime=1704101038
//&mobile=15700000004
//¬ifyTime=170410103838
//&uid=17041010383624511
//&length=1
//&status=DELIVRD
//&statusDesc=短信发送成功
private
String
receiver
;
private
String
pswd
;
private
String
msgid
;
private
String
reportTime
;
private
String
mobile
;
private
String
notifyTime
;
private
String
uid
;
private
String
length
;
private
String
status
;
private
String
statusDesc
;
public
String
getReceiver
()
{
return
receiver
;
}
public
void
setReceiver
(
String
receiver
)
{
this
.
receiver
=
receiver
;
}
public
String
getPswd
()
{
return
pswd
;
}
public
void
setPswd
(
String
pswd
)
{
this
.
pswd
=
pswd
;
}
public
String
getMsgid
()
{
return
msgid
;
}
public
void
setMsgid
(
String
msgid
)
{
this
.
msgid
=
msgid
;
}
public
String
getReportTime
()
{
return
reportTime
;
}
public
void
setReportTime
(
String
reportTime
)
{
this
.
reportTime
=
reportTime
;
}
public
String
getMobile
()
{
return
mobile
;
}
public
void
setMobile
(
String
mobile
)
{
this
.
mobile
=
mobile
;
}
public
String
getNotifyTime
()
{
return
notifyTime
;
}
public
void
setNotifyTime
(
String
notifyTime
)
{
this
.
notifyTime
=
notifyTime
;
}
public
String
getUid
()
{
return
uid
;
}
public
void
setUid
(
String
uid
)
{
this
.
uid
=
uid
;
}
public
String
getLength
()
{
return
length
;
}
public
void
setLength
(
String
length
)
{
this
.
length
=
length
;
}
public
String
getStatus
()
{
return
status
;
}
public
void
setStatus
(
String
status
)
{
this
.
status
=
status
;
}
public
String
getStatusDesc
()
{
return
statusDesc
;
}
public
void
setStatusDesc
(
String
statusDesc
)
{
this
.
statusDesc
=
statusDesc
;
}
}
src/main/java/com/jz/sms/chuanglan/service/ChuangLanSmsService.java
View file @
561456b1
...
...
@@ -3,6 +3,7 @@ package com.jz.sms.chuanglan.service;
import
com.jz.sms.chuanglan.dto.CLNotifyRequest
;
import
com.jz.sms.chuanglan.dto.CLSendSMSResponse
;
import
com.jz.sms.chuanglan.dto.CLTemplateResponse
;
import
com.jz.sms.chuanglan.dto.ReportDto
;
import
com.jz.sms.dto.*
;
public
interface
ChuangLanSmsService
{
...
...
@@ -17,4 +18,6 @@ public interface ChuangLanSmsService {
CLSendSMSResponse
sendByVariable
(
String
batchId
,
String
content
,
String
sendParams
,
String
type
)
throws
Exception
;
void
asyncNotify
(
CLNotifyRequest
notifyInfo
);
void
report
(
ReportDto
report
);
}
src/main/java/com/jz/sms/chuanglan/service/impl/ChuangLanSmsServiceImpl.java
View file @
561456b1
...
...
@@ -5,10 +5,7 @@ import com.alibaba.fastjson.JSON;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
com.jz.sms.api.BizController
;
import
com.jz.sms.chuanglan.dto.CLNotifyRequest
;
import
com.jz.sms.chuanglan.dto.CLSendFixedRequest
;
import
com.jz.sms.chuanglan.dto.CLSendSMSResponse
;
import
com.jz.sms.chuanglan.dto.CLTemplateResponse
;
import
com.jz.sms.chuanglan.dto.*
;
import
com.jz.sms.chuanglan.service.ChuangLanSmsService
;
import
com.jz.sms.chuanglan.utils.ChuangLanSmsUtil
;
import
com.jz.sms.chuanglan.config.ChuangLanSMSConfig
;
...
...
@@ -27,6 +24,8 @@ import org.springframework.stereotype.Service;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
@SuppressWarnings
(
"DuplicatedCode"
)
...
...
@@ -137,8 +136,8 @@ public class ChuangLanSmsServiceImpl implements ChuangLanSmsService {
CLSendFixedRequest
request
=
new
CLSendFixedRequest
(
account
,
password
,
content
,
params
,
"true"
,
batchId
);
String
requestJson
=
JSONObject
.
toJSONString
(
request
);
log
.
info
(
"【{}】发送固定内容短信,请求上游数据为:{}
"
,
batchId
,
requestJson
);
String
responseStr
=
ChuangLanSmsUtil
.
sendSmsByPost
(
ChuangLanSMSConfig
.
send
Fixed
,
requestJson
);
log
.
info
(
"【{}】发送固定内容短信,请求上游数据为:{}
,\r\n请求地址为:{}"
,
batchId
,
requestJson
,
ChuangLanSMSConfig
.
sendVariable
);
String
responseStr
=
ChuangLanSmsUtil
.
sendSmsByPost
(
ChuangLanSMSConfig
.
send
Variable
,
requestJson
);
log
.
info
(
"【{}】发送固定内容短信,上游返回数据为:{}"
,
batchId
,
responseStr
);
if
(
StringUtils
.
isBlank
(
responseStr
))
{
...
...
@@ -165,4 +164,25 @@ public class ChuangLanSmsServiceImpl implements ChuangLanSmsService {
log
.
error
(
"短信模板审核不通过,原因:{}"
,
msg
);
}
}
@Override
public
void
report
(
ReportDto
report
)
{
String
uid
=
report
.
getUid
();
}
public
static
void
main
(
String
[]
args
)
{
String
s
=
"\"亲爱的${name@0!\"\"},你当前是${stage@10!\"\"},请点击链接升级 ${surl!'abc.ddd.cvdfa?fadfadfihjfiahkck?daa=${acd}'} 回TD退订\""
;
String
p
=
"((?:\\$\\{surl.*'\\}))|\\$\\{[^}]+\\}"
;
Pattern
pt
=
Pattern
.
compile
(
p
);
Matcher
matcher
=
pt
.
matcher
(
s
);
while
(
matcher
.
find
())
{
String
group
=
matcher
.
group
();
System
.
err
.
println
(
group
);
}
System
.
err
.
println
(
11
);
}
}
src/main/java/com/jz/sms/service/impl/MessageServiceImpl.java
View file @
561456b1
...
...
@@ -116,7 +116,8 @@ public class MessageServiceImpl implements MessageService {
* @return
*/
public
TemplateChangeBean
dmHub2ChuangLanSend
(
String
content
)
{
String
regex
=
"\\$\\{[^}]+\\}"
;
// String regex = "\\$\\{[^}]+\\}";
String
regex
=
"((?:\\$\\{surl.*'\\}))|\\$\\{[^}]+\\}"
;
Pattern
pattern
=
Pattern
.
compile
(
regex
);
Matcher
matcher
=
pattern
.
matcher
(
content
);
...
...
@@ -129,25 +130,11 @@ public class MessageServiceImpl implements MessageService {
if
(
groups
.
isEmpty
())
{
return
new
TemplateChangeBean
(
content
,
arr
);
}
int
idx
=
content
.
indexOf
(
"${surl!'"
);
if
(
idx
>=
0
)
{
String
substring
=
content
.
substring
(
idx
);
System
.
out
.
println
(
substring
);
int
i1
=
substring
.
indexOf
(
"'}"
);
System
.
out
.
println
(
i1
);
String
substring1
=
substring
.
substring
(
0
,
i1
+
2
);
System
.
out
.
println
(
substring1
);
System
.
out
.
println
(
content
);
substring1
=
Matcher
.
quoteReplacement
(
substring1
);
substring1
=
escapeRegex
(
substring1
);
content
=
content
.
replaceAll
(
substring1
,
"\\{\\$var\\}"
);
}
for
(
String
g
:
groups
)
{
String
t
=
g
;
g
=
Matcher
.
quoteReplacement
(
g
);
g
=
escapeRegex
(
g
);
content
=
content
.
replaceAll
(
g
,
"\\{\\$var\\}"
);
}
arr
.
addAll
(
groups
);
...
...
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