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
7be8dd0d
Commit
7be8dd0d
authored
Apr 22, 2020
by
qinxunjia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化
parent
b80c7b07
Changes
20
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
410 additions
and
40 deletions
+410
-40
pom.xml
pom.xml
+5
-0
BizController.java
src/main/java/com/jz/sms/api/BizController.java
+10
-3
XfaceClSendFiexdRequestDTO.java
...a/com/jz/sms/chuanlan/dto/XfaceClSendFiexdRequestDTO.java
+3
-3
XfaceClSendFiexdResponseDTO.java
.../com/jz/sms/chuanlan/dto/XfaceClSendFiexdResponseDTO.java
+13
-1
XfaceClSendVariableRequestDTO.java
...om/jz/sms/chuanlan/dto/XfaceClSendVariableRequestDTO.java
+1
-1
XfaceClSendVariableResponseDTO.java
...m/jz/sms/chuanlan/dto/XfaceClSendVariableResponseDTO.java
+1
-1
XfaceClTemplateRequestDTO.java
...va/com/jz/sms/chuanlan/dto/XfaceClTemplateRequestDTO.java
+1
-1
XfaceClTemplateResponseDTO.java
...a/com/jz/sms/chuanlan/dto/XfaceClTemplateResponseDTO.java
+1
-1
ChuanLanSmsService.java
.../java/com/jz/sms/chuanlan/service/ChuanLanSmsService.java
+5
-2
ChuanLanSmsServiceImpl.java
.../jz/sms/chuanlan/service/impl/ChuanLanSmsServiceImpl.java
+82
-5
ChuangLanSmsUtil.java
...main/java/com/jz/sms/chuanlan/utils/ChuangLanSmsUtil.java
+70
-0
XfaceDmHubTemplateRequestDTO.java
...ain/java/com/jz/sms/dto/XfaceDmHubTemplateRequestDTO.java
+62
-0
DmBatchInfo.java
src/main/java/com/jz/sms/repository/domain/DmBatchInfo.java
+4
-0
SmsTemplateInfo.java
...in/java/com/jz/sms/repository/domain/SmsTemplateInfo.java
+25
-0
SysBatchInfo.java
src/main/java/com/jz/sms/repository/domain/SysBatchInfo.java
+13
-0
SmsTemplateService.java
src/main/java/com/jz/sms/service/SmsTemplateService.java
+7
-0
SysBatchService.java
src/main/java/com/jz/sms/service/SysBatchService.java
+4
-0
MessageServiceImpl.java
...main/java/com/jz/sms/service/impl/MessageServiceImpl.java
+80
-22
SmsTemplateServiceImpl.java
.../java/com/jz/sms/service/impl/SmsTemplateServiceImpl.java
+11
-0
SysBatchServiceImpl.java
...ain/java/com/jz/sms/service/impl/SysBatchServiceImpl.java
+12
-0
No files found.
pom.xml
View file @
7be8dd0d
...
@@ -70,6 +70,11 @@
...
@@ -70,6 +70,11 @@
<artifactId>
mybatis-plus-boot-starter
</artifactId>
<artifactId>
mybatis-plus-boot-starter
</artifactId>
<version>
2.3
</version>
<version>
2.3
</version>
</dependency>
</dependency>
<dependency>
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-lang3
</artifactId>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
<finalName>
dmhub-plugin
</finalName>
<finalName>
dmhub-plugin
</finalName>
...
...
src/main/java/com/jz/sms/api/BizController.java
View file @
7be8dd0d
package
com
.
jz
.
sms
.
api
;
package
com
.
jz
.
sms
.
api
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jz.sms.chuanlan.service.ChuanLanSmsService
;
import
com.jz.sms.chuanlan.service.ChuanLanSmsService
;
import
com.jz.sms.dto.XfaceDmHubTemplateRequestDTO
;
import
com.jz.sms.dto.XfaceDmHubTemplateRequestDTO
;
import
com.jz.sms.dto.XfaceDmHubTemplateResponseDTO
;
import
com.jz.sms.dto.XfaceDmHubTemplateResponseDTO
;
import
com.jz.sms.service.MessageService
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpRequest
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.Enumeration
;
import
java.util.Map
;
import
java.util.Map
;
@RestController
@RestController
...
@@ -18,7 +23,7 @@ public class BizController {
...
@@ -18,7 +23,7 @@ public class BizController {
@Autowired
@Autowired
private
ChuanLanSmsService
s
ervice
;
private
MessageService
messageS
ervice
;
/**
/**
...
@@ -27,8 +32,10 @@ public class BizController {
...
@@ -27,8 +32,10 @@ public class BizController {
* @return
* @return
*/
*/
@PostMapping
(
"/sms/template"
)
@PostMapping
(
"/sms/template"
)
public
String
template
(
@RequestParam
Map
<
String
,
Object
>
params
)
{
public
String
template
(
@RequestBody
XfaceDmHubTemplateRequestDTO
params
)
{
log
.
info
(
"**********创建模板入参*******:{}"
,
params
);
log
.
info
(
"**********创建模板入参*******:{}"
,
JSONObject
.
toJSONString
(
params
));
XfaceDmHubTemplateResponseDTO
template
=
messageService
.
createTemplate
(
params
);
return
"ok"
;
return
"ok"
;
}
}
...
...
src/main/java/com/jz/sms/dto/XfaceClSendFiexdRequestDTO.java
→
src/main/java/com/jz/sms/
chuanlan/
dto/XfaceClSendFiexdRequestDTO.java
View file @
7be8dd0d
package
com
.
jz
.
sms
.
dto
;
package
com
.
jz
.
sms
.
chuanlan
.
dto
;
public
class
XfaceClSendFiexdRequestDTO
{
public
class
XfaceClSendFiexdRequestDTO
{
...
@@ -58,14 +58,14 @@ public class XfaceClSendFiexdRequestDTO {
...
@@ -58,14 +58,14 @@ public class XfaceClSendFiexdRequestDTO {
this
.
report
=
report
;
this
.
report
=
report
;
}
}
public
XfaceClSendFiexdRequestDTO
(
String
account
,
String
password
,
String
msg
,
String
phone
,
String
report
,
String
sendtime
)
{
public
XfaceClSendFiexdRequestDTO
(
String
account
,
String
password
,
String
msg
,
String
phone
,
String
report
,
String
uid
)
{
super
();
super
();
this
.
account
=
account
;
this
.
account
=
account
;
this
.
password
=
password
;
this
.
password
=
password
;
this
.
msg
=
msg
;
this
.
msg
=
msg
;
this
.
phone
=
phone
;
this
.
phone
=
phone
;
this
.
sendtime
=
sendtime
;
this
.
report
=
report
;
this
.
report
=
report
;
this
.
uid
=
uid
;
}
}
public
XfaceClSendFiexdRequestDTO
(
String
account
,
String
password
,
String
msg
,
String
phone
,
String
sendtime
,
String
report
,
String
uid
)
{
public
XfaceClSendFiexdRequestDTO
(
String
account
,
String
password
,
String
msg
,
String
phone
,
String
sendtime
,
String
report
,
String
uid
)
{
...
...
src/main/java/com/jz/sms/dto/XfaceClSendFiexdResponseDTO.java
→
src/main/java/com/jz/sms/
chuanlan/
dto/XfaceClSendFiexdResponseDTO.java
View file @
7be8dd0d
package
com
.
jz
.
sms
.
dto
;
package
com
.
jz
.
sms
.
chuanlan
.
dto
;
import
com.jz.sms.util.DateUtil
;
import
java.text.DateFormat
;
public
class
XfaceClSendFiexdResponseDTO
{
public
class
XfaceClSendFiexdResponseDTO
{
/**
/**
...
@@ -18,6 +22,14 @@ public class XfaceClSendFiexdResponseDTO {
...
@@ -18,6 +22,14 @@ public class XfaceClSendFiexdResponseDTO {
*/
*/
private
String
code
;
private
String
code
;
public
XfaceClSendFiexdResponseDTO
(){}
public
XfaceClSendFiexdResponseDTO
(
String
code
,
String
errorMsg
){
this
.
code
=
code
;
this
.
errorMsg
=
errorMsg
;
}
public
String
getTime
()
{
public
String
getTime
()
{
return
time
;
return
time
;
}
}
...
...
src/main/java/com/jz/sms/dto/XfaceClSendVariableRequestDTO.java
→
src/main/java/com/jz/sms/
chuanlan/
dto/XfaceClSendVariableRequestDTO.java
View file @
7be8dd0d
package
com
.
jz
.
sms
.
dto
;
package
com
.
jz
.
sms
.
chuanlan
.
dto
;
public
class
XfaceClSendVariableRequestDTO
{
public
class
XfaceClSendVariableRequestDTO
{
...
...
src/main/java/com/jz/sms/dto/XfaceClSendVariableResponseDTO.java
→
src/main/java/com/jz/sms/
chuanlan/
dto/XfaceClSendVariableResponseDTO.java
View file @
7be8dd0d
package
com
.
jz
.
sms
.
dto
;
package
com
.
jz
.
sms
.
chuanlan
.
dto
;
public
class
XfaceClSendVariableResponseDTO
{
public
class
XfaceClSendVariableResponseDTO
{
/**
/**
...
...
src/main/java/com/jz/sms/dto/XfaceClTemplateRequestDTO.java
→
src/main/java/com/jz/sms/
chuanlan/
dto/XfaceClTemplateRequestDTO.java
View file @
7be8dd0d
package
com
.
jz
.
sms
.
dto
;
package
com
.
jz
.
sms
.
chuanlan
.
dto
;
public
class
XfaceClTemplateRequestDTO
{
public
class
XfaceClTemplateRequestDTO
{
}
}
src/main/java/com/jz/sms/dto/XfaceClTemplateResponseDTO.java
→
src/main/java/com/jz/sms/
chuanlan/
dto/XfaceClTemplateResponseDTO.java
View file @
7be8dd0d
package
com
.
jz
.
sms
.
dto
;
package
com
.
jz
.
sms
.
chuanlan
.
dto
;
public
class
XfaceClTemplateResponseDTO
{
public
class
XfaceClTemplateResponseDTO
{
}
}
src/main/java/com/jz/sms/chuanlan/service/ChuanLanSmsService.java
View file @
7be8dd0d
package
com
.
jz
.
sms
.
chuanlan
.
service
;
package
com
.
jz
.
sms
.
chuanlan
.
service
;
import
com.jz.sms.chuanlan.dto.XfaceClSendFiexdResponseDTO
;
import
com.jz.sms.dto.*
;
import
com.jz.sms.dto.*
;
import
java.util.List
;
public
interface
ChuanLanSmsService
{
public
interface
ChuanLanSmsService
{
XfaceDmHubTemplateResponseDTO
createTemplate
(
XfaceDmHubTemplateRequestDTO
requestDTO
);
XfaceDmHubTemplateResponseDTO
createTemplate
(
XfaceDmHubTemplateRequestDTO
requestDTO
);
Xface
DmHubSendResponseDTO
sendByFixed
(
XfaceDmHubSendRequestDTO
requestDTO
)
;
Xface
ClSendFiexdResponseDTO
sendByFixed
(
String
batchId
,
String
content
,
List
<
String
>
phoneList
,
String
type
)
throws
Exception
;
Xface
DmHubSendResponseDTO
sendByVariable
(
XfaceDmHubSendRequestDTO
requestDTO
)
;
Xface
ClSendFiexdResponseDTO
sendByVariable
(
String
batchId
,
String
content
,
List
<
String
>
phoneList
,
String
type
)
throws
Exception
;
XfaceDmHubSendResponseDTO
sendBatchByFixed
(
XfaceDmHubSendRequestDTO
requestDTO
);
XfaceDmHubSendResponseDTO
sendBatchByFixed
(
XfaceDmHubSendRequestDTO
requestDTO
);
...
...
src/main/java/com/jz/sms/chuanlan/service/impl/ChuanLanSmsServiceImpl.java
View file @
7be8dd0d
package
com
.
jz
.
sms
.
chuanlan
.
service
.
impl
;
package
com
.
jz
.
sms
.
chuanlan
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jz.sms.api.BizController
;
import
com.jz.sms.chuanlan.dto.XfaceClSendFiexdRequestDTO
;
import
com.jz.sms.chuanlan.dto.XfaceClSendFiexdResponseDTO
;
import
com.jz.sms.chuanlan.dto.XfaceClTemplateRequestDTO
;
import
com.jz.sms.chuanlan.dto.XfaceClTemplateResponseDTO
;
import
com.jz.sms.chuanlan.service.ChuanLanSmsService
;
import
com.jz.sms.chuanlan.service.ChuanLanSmsService
;
import
com.jz.sms.chuanlan.utils.ChuangLanSmsUtil
;
import
com.jz.sms.config.SMSConfig
;
import
com.jz.sms.dto.*
;
import
com.jz.sms.dto.*
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
sun.swing.StringUIClientPropertyKey
;
import
java.util.ArrayList
;
import
java.util.List
;
@SuppressWarnings
(
"DuplicatedCode"
)
@Service
@Service
public
class
ChuanLanSmsServiceImpl
implements
ChuanLanSmsService
{
public
class
ChuanLanSmsServiceImpl
implements
ChuanLanSmsService
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
BizController
.
class
);
@Override
@Override
public
XfaceDmHubTemplateResponseDTO
createTemplate
(
XfaceDmHubTemplateRequestDTO
requestDTO
)
{
public
XfaceDmHubTemplateResponseDTO
createTemplate
(
XfaceDmHubTemplateRequestDTO
requestDTO
)
{
...
@@ -18,7 +36,6 @@ public class ChuanLanSmsServiceImpl implements ChuanLanSmsService {
...
@@ -18,7 +36,6 @@ public class ChuanLanSmsServiceImpl implements ChuanLanSmsService {
*/
*/
XfaceClTemplateRequestDTO
clRequestDto
=
new
XfaceClTemplateRequestDTO
();
XfaceClTemplateRequestDTO
clRequestDto
=
new
XfaceClTemplateRequestDTO
();
XfaceClTemplateResponseDTO
clResponseDTO
=
new
XfaceClTemplateResponseDTO
();
XfaceClTemplateResponseDTO
clResponseDTO
=
new
XfaceClTemplateResponseDTO
();
/**
/**
* 调用结果包装到DM Hub Response中
* 调用结果包装到DM Hub Response中
*/
*/
...
@@ -28,16 +45,76 @@ public class ChuanLanSmsServiceImpl implements ChuanLanSmsService {
...
@@ -28,16 +45,76 @@ public class ChuanLanSmsServiceImpl implements ChuanLanSmsService {
}
}
@Override
@Override
public
XfaceDmHubSendResponseDTO
sendByFixed
(
XfaceDmHubSendRequestDTO
requestDTO
)
{
public
XfaceClSendFiexdResponseDTO
sendByFixed
(
String
batchId
,
String
content
,
List
<
String
>
phoneList
,
String
type
)
throws
Exception
{
String
account
;
String
password
;
if
(
"notification"
.
equals
(
type
))
{
account
=
SMSConfig
.
notificationAccount
;
password
=
SMSConfig
.
notificationPassword
;
log
.
info
(
"发送短信的模式为:{通知类}"
);
}
else
if
(
"marketing"
.
equals
(
type
))
{
account
=
SMSConfig
.
marketingAccount
;
password
=
SMSConfig
.
marketingPassword
;
log
.
info
(
"发送短信的模式为:{营销类}"
);
}
else
{
log
.
info
(
"发送短信的模式为:{未知类型}"
);
throw
new
Exception
(
"123"
);
}
XfaceClSendFiexdRequestDTO
request
=
new
XfaceClSendFiexdRequestDTO
(
account
,
password
,
content
,
listToString
(
phoneList
),
"true"
,
batchId
);
return
null
;
String
requestJson
=
JSONObject
.
toJSONString
(
request
);
log
.
info
(
"【{}】发送固定内容短信,请求上游数据为:{}"
,
batchId
,
requestJson
);
String
responseStr
=
ChuangLanSmsUtil
.
sendSmsByPost
(
SMSConfig
.
sendFixed
,
requestJson
);
log
.
info
(
"【{}】发送固定内容短信,上游返回数据为:{}"
,
batchId
,
requestJson
);
if
(
StringUtils
.
isBlank
(
responseStr
))
{
return
new
XfaceClSendFiexdResponseDTO
(
"500"
,
"渠道同步响应为空"
);
}
XfaceClSendFiexdResponseDTO
response
=
JSON
.
parseObject
(
responseStr
,
XfaceClSendFiexdResponseDTO
.
class
);
return
response
;
}
private
String
listToString
(
List
<
String
>
list
)
{
String
s
=
list
.
toString
();
return
s
;
}
public
static
void
main
(
String
[]
args
)
{
List
<
String
>
arr
=
new
ArrayList
<>();
arr
.
add
(
"aa,444"
);
System
.
out
.
printf
(
arr
.
toString
());
}
}
@Override
@Override
public
XfaceDmHubSendResponseDTO
sendByVariable
(
XfaceDmHubSendRequestDTO
requestDTO
)
{
public
XfaceClSendFiexdResponseDTO
sendByVariable
(
String
batchId
,
String
content
,
List
<
String
>
params
,
String
type
)
throws
Exception
{
String
account
;
String
password
;
if
(
"notification"
.
equals
(
type
))
{
account
=
SMSConfig
.
notificationAccount
;
password
=
SMSConfig
.
notificationPassword
;
log
.
info
(
"发送短信的模式为:{通知类}"
);
}
else
if
(
"marketing"
.
equals
(
type
))
{
account
=
SMSConfig
.
marketingAccount
;
password
=
SMSConfig
.
marketingPassword
;
log
.
info
(
"发送短信的模式为:{营销类}"
);
}
else
{
log
.
info
(
"发送短信的模式为:{未知类型}"
);
throw
new
Exception
(
"123"
);
}
return
null
;
XfaceClSendFiexdRequestDTO
request
=
new
XfaceClSendFiexdRequestDTO
(
account
,
password
,
content
,
listToString
(
params
),
"true"
,
batchId
);
String
requestJson
=
JSONObject
.
toJSONString
(
request
);
log
.
info
(
"【{}】发送固定内容短信,请求上游数据为:{}"
,
batchId
,
requestJson
);
String
responseStr
=
ChuangLanSmsUtil
.
sendSmsByPost
(
SMSConfig
.
sendFixed
,
requestJson
);
log
.
info
(
"【{}】发送固定内容短信,上游返回数据为:{}"
,
batchId
,
requestJson
);
if
(
StringUtils
.
isBlank
(
responseStr
))
{
return
new
XfaceClSendFiexdResponseDTO
(
"500"
,
"渠道同步响应为空"
);
}
XfaceClSendFiexdResponseDTO
response
=
JSON
.
parseObject
(
responseStr
,
XfaceClSendFiexdResponseDTO
.
class
);
return
response
;
}
}
@Override
@Override
...
...
src/main/java/com/jz/sms/chuanlan/utils/ChuangLanSmsUtil.java
0 → 100644
View file @
7be8dd0d
package
com
.
jz
.
sms
.
chuanlan
.
utils
;
import
java.io.BufferedReader
;
import
java.io.InputStreamReader
;
import
java.io.OutputStream
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
//import java.io.PrintWriter;
/**
*
* @author tianyh
* @Description:HTTP 请求
*/
public
class
ChuangLanSmsUtil
{
/**
*
* @author tianyh
* @Description
* @param path
* @param postContent
* @return String
* @throws
*/
public
static
String
sendSmsByPost
(
String
path
,
String
postContent
)
{
URL
url
=
null
;
try
{
url
=
new
URL
(
path
);
HttpURLConnection
httpURLConnection
=
(
HttpURLConnection
)
url
.
openConnection
();
httpURLConnection
.
setRequestMethod
(
"POST"
);
// 提交模式
httpURLConnection
.
setConnectTimeout
(
10000
);
//连接超时 单位毫秒
httpURLConnection
.
setReadTimeout
(
10000
);
//读取超时 单位毫秒
// 发送POST请求必须设置如下两行
httpURLConnection
.
setDoOutput
(
true
);
httpURLConnection
.
setDoInput
(
true
);
httpURLConnection
.
setRequestProperty
(
"Charset"
,
"UTF-8"
);
httpURLConnection
.
setRequestProperty
(
"Content-Type"
,
"application/json"
);
// PrintWriter printWriter = new PrintWriter(httpURLConnection.getOutputStream());
// printWriter.write(postContent);
// printWriter.flush();
httpURLConnection
.
connect
();
OutputStream
os
=
httpURLConnection
.
getOutputStream
();
os
.
write
(
postContent
.
getBytes
(
"UTF-8"
));
os
.
flush
();
StringBuilder
sb
=
new
StringBuilder
();
int
httpRspCode
=
httpURLConnection
.
getResponseCode
();
if
(
httpRspCode
==
HttpURLConnection
.
HTTP_OK
)
{
// 开始获取数据
BufferedReader
br
=
new
BufferedReader
(
new
InputStreamReader
(
httpURLConnection
.
getInputStream
(),
"utf-8"
));
String
line
=
null
;
while
((
line
=
br
.
readLine
())
!=
null
)
{
sb
.
append
(
line
);
}
br
.
close
();
return
sb
.
toString
();
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
}
src/main/java/com/jz/sms/dto/XfaceDmHubTemplateRequestDTO.java
View file @
7be8dd0d
package
com
.
jz
.
sms
.
dto
;
package
com
.
jz
.
sms
.
dto
;
public
class
XfaceDmHubTemplateRequestDTO
{
public
class
XfaceDmHubTemplateRequestDTO
{
private
String
tenantId
;
private
String
templateId
;
private
String
templateContent
;
private
String
smsType
;
private
String
signature
;
private
String
templateName
;
public
String
getTenantId
()
{
return
tenantId
;
}
public
void
setTenantId
(
String
tenantId
)
{
this
.
tenantId
=
tenantId
;
}
public
String
getTemplateId
()
{
return
templateId
;
}
public
void
setTemplateId
(
String
templateId
)
{
this
.
templateId
=
templateId
;
}
public
String
getTemplateContent
()
{
return
templateContent
;
}
public
void
setTemplateContent
(
String
templateContent
)
{
this
.
templateContent
=
templateContent
;
}
public
String
getSmsType
()
{
return
smsType
;
}
public
void
setSmsType
(
String
smsType
)
{
this
.
smsType
=
smsType
;
}
public
String
getSignature
()
{
return
signature
;
}
public
void
setSignature
(
String
signature
)
{
this
.
signature
=
signature
;
}
public
String
getTemplateName
()
{
return
templateName
;
}
public
void
setTemplateName
(
String
templateName
)
{
this
.
templateName
=
templateName
;
}
}
}
src/main/java/com/jz/sms/repository/domain/DmBatchInfo.java
View file @
7be8dd0d
package
com
.
jz
.
sms
.
repository
.
domain
;
package
com
.
jz
.
sms
.
repository
.
domain
;
import
com.baomidou.mybatisplus.annotations.TableName
;
import
java.util.Date
;
import
java.util.Date
;
@TableName
(
"dm_batch"
)
public
class
DmBatchInfo
{
public
class
DmBatchInfo
{
...
...
src/main/java/com/jz/sms/repository/domain/SmsTemplateInfo.java
View file @
7be8dd0d
package
com
.
jz
.
sms
.
repository
.
domain
;
package
com
.
jz
.
sms
.
repository
.
domain
;
import
com.baomidou.mybatisplus.annotations.TableName
;
import
java.util.Date
;
import
java.util.Date
;
@TableName
(
"sms_template"
)
public
class
SmsTemplateInfo
{
public
class
SmsTemplateInfo
{
...
@@ -19,6 +23,10 @@ public class SmsTemplateInfo {
...
@@ -19,6 +23,10 @@ public class SmsTemplateInfo {
private
Date
lastUpdated
;
private
Date
lastUpdated
;
private
String
signature
;
private
String
tenantId
;
public
SmsTemplateInfo
()
{
public
SmsTemplateInfo
()
{
}
}
...
@@ -27,6 +35,23 @@ public class SmsTemplateInfo {
...
@@ -27,6 +35,23 @@ public class SmsTemplateInfo {
this
.
dmTemplateId
=
dmTemplateId
;
this
.
dmTemplateId
=
dmTemplateId
;
}
}
public
String
getSignature
()
{
return
signature
;
}
public
void
setSignature
(
String
signature
)
{
this
.
signature
=
signature
;
}
public
String
getTenantId
()
{
return
tenantId
;
}
public
void
setTenantId
(
String
tenantId
)
{
this
.
tenantId
=
tenantId
;
}
public
Long
getId
()
{
public
Long
getId
()
{
return
id
;
return
id
;
}
}
...
...
src/main/java/com/jz/sms/repository/domain/SysBatchInfo.java
View file @
7be8dd0d
package
com
.
jz
.
sms
.
repository
.
domain
;
package
com
.
jz
.
sms
.
repository
.
domain
;
import
com.baomidou.mybatisplus.annotations.TableName
;
import
java.util.Date
;
import
java.util.Date
;
@TableName
(
"sys_batch"
)
public
class
SysBatchInfo
{
public
class
SysBatchInfo
{
private
Long
id
;
private
Long
id
;
...
@@ -14,6 +17,8 @@ public class SysBatchInfo {
...
@@ -14,6 +17,8 @@ public class SysBatchInfo {
private
String
report
;
private
String
report
;
private
Integer
smsNum
;
private
String
extend
;
private
String
extend
;
private
String
msgId
;
private
String
msgId
;
...
@@ -113,4 +118,12 @@ public class SysBatchInfo {
...
@@ -113,4 +118,12 @@ public class SysBatchInfo {
public
void
setLastUpdated
(
Date
lastUpdated
)
{
public
void
setLastUpdated
(
Date
lastUpdated
)
{
this
.
lastUpdated
=
lastUpdated
;
this
.
lastUpdated
=
lastUpdated
;
}
}
public
Integer
getSmsNum
()
{
return
smsNum
;
}
public
void
setSmsNum
(
Integer
smsNum
)
{
this
.
smsNum
=
smsNum
;
}
}
}
src/main/java/com/jz/sms/service/SmsTemplateService.java
0 → 100644
View file @
7be8dd0d
package
com
.
jz
.
sms
.
service
;
import
com.baomidou.mybatisplus.service.IService
;
import
com.jz.sms.repository.domain.SmsTemplateInfo
;
public
interface
SmsTemplateService
extends
IService
<
SmsTemplateInfo
>
{
}
src/main/java/com/jz/sms/service/SysBatchService.java
0 → 100644
View file @
7be8dd0d
package
com
.
jz
.
sms
.
service
;
public
interface
SysBatchService
{
}
src/main/java/com/jz/sms/service/impl/MessageServiceImpl.java
View file @
7be8dd0d
package
com
.
jz
.
sms
.
service
.
impl
;
package
com
.
jz
.
sms
.
service
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
com.jz.sms.api.BizController
;
import
com.jz.sms.chuanlan.dto.XfaceClSendFiexdResponseDTO
;
import
com.jz.sms.chuanlan.service.ChuanLanSmsService
;
import
com.jz.sms.chuanlan.service.ChuanLanSmsService
;
import
com.jz.sms.dto.*
;
import
com.jz.sms.dto.*
;
import
com.jz.sms.repository.domain.SmsTemplateInfo
;
import
com.jz.sms.repository.domain.SysBatchInfo
;
import
com.jz.sms.repository.mapper.SysBatchMapper
;
import
com.jz.sms.repository.mapper.SysBatchMapper
;
import
com.jz.sms.repository.mapper.TemplateMapper
;
import
com.jz.sms.repository.mapper.TemplateMapper
;
import
com.jz.sms.service.MessageService
;
import
com.jz.sms.service.MessageService
;
import
com.jz.sms.service.SmsTemplateService
;
import
com.jz.sms.util.id.IdHandler
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
@Service
@Service
public
class
MessageServiceImpl
implements
MessageService
{
public
class
MessageServiceImpl
implements
MessageService
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
MessageServiceImpl
.
class
);
@Autowired
@Autowired
private
SysBatch
Mapper
sysBatchMapper
;
private
SysBatch
ServiceImpl
sysBatchService
;
//
@Autowired
@Autowired
private
TemplateMapper
templateMapper
;
private
SmsTemplateService
smsTemplateService
;
@Autowired
@Autowired
private
ChuanLanSmsService
chuanLanSmsService
;
private
ChuanLanSmsService
chuanLanSmsService
;
...
@@ -30,13 +46,32 @@ public class MessageServiceImpl implements MessageService {
...
@@ -30,13 +46,32 @@ public class MessageServiceImpl implements MessageService {
*/
*/
@Override
@Override
public
XfaceDmHubTemplateResponseDTO
createTemplate
(
XfaceDmHubTemplateRequestDTO
requestDTO
)
{
public
XfaceDmHubTemplateResponseDTO
createTemplate
(
XfaceDmHubTemplateRequestDTO
requestDTO
)
{
log
.
info
(
"进入创建短信模板业务逻辑,入参:{}"
,
requestDTO
);
XfaceDmHubTemplateResponseDTO
responseDTO
=
new
XfaceDmHubTemplateResponseDTO
();
XfaceDmHubTemplateResponseDTO
responseDTO
=
new
XfaceDmHubTemplateResponseDTO
();
try
{
try
{
// XfaceClTemplateRequestDTO clTemplateRequestDTO = new XfaceClTemplateRequestDTO();
String
templateContent
=
requestDTO
.
getTemplateContent
();
// XfaceClTemplateResponseDTO clTemplateResponseDTO = new XfaceClTemplateResponseDTO();
String
signature
=
requestDTO
.
getSignature
();
// logger.info("短信通道请求URL:"+url);
String
smsType
=
requestDTO
.
getSmsType
();
// logger.info("短信通道返回内容:"+responseStr);
String
tenantId
=
requestDTO
.
getTenantId
();
String
templateId
=
requestDTO
.
getTemplateId
();
String
templateName
=
requestDTO
.
getTemplateName
();
SmsTemplateInfo
info
=
new
SmsTemplateInfo
();
info
.
setContent
(
templateContent
);
info
.
setType
(
smsType
);
info
.
setDmTemplateId
(
templateId
);
info
.
setTenantId
(
tenantId
);
info
.
setId
(
IdHandler
.
nextId
());
boolean
insert
=
smsTemplateService
.
insert
(
info
);
if
(!
insert
)
{
//TODO 发送告警
}
}
catch
(
Exception
exception
)
{
}
catch
(
Exception
exception
)
{
// 记录异常日志
// 记录异常日志
throw
exception
;
throw
exception
;
...
@@ -46,27 +81,50 @@ public class MessageServiceImpl implements MessageService {
...
@@ -46,27 +81,50 @@ public class MessageServiceImpl implements MessageService {
}
}
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRED
)
public
XfaceDmHubSendResponseDTO
send
(
XfaceDmHubSendRequestDTO
requestDTO
)
{
public
XfaceDmHubSendResponseDTO
send
(
XfaceDmHubSendRequestDTO
requestDTO
)
{
try
{
try
{
String
dmHubBatchId
=
requestDTO
.
getBatchId
();
String
dmHubBatchId
=
requestDTO
.
getBatchId
();
String
templateId
=
requestDTO
.
getTemplateId
();
String
templateId
=
requestDTO
.
getTemplateId
();
String
audienceIdType
=
requestDTO
.
getAudienceIdType
();
String
audienceIdType
=
requestDTO
.
getAudienceIdType
();
JSONObject
data
=
requestDTO
.
getData
();
JSONObject
data
=
requestDTO
.
getData
();
// 获取模板信息
// 1、获取模板信息
// SmsTemplateInfo templateInfo = templateMapper.selectOne(new SmsTemplateInfo(templateId));
SmsTemplateInfo
templateInfo
=
smsTemplateService
.
selectOne
(
new
EntityWrapper
<
SmsTemplateInfo
>().
eq
(
"dm_template_id"
,
dmHubBatchId
));
// if (null == templateInfo) {
if
(
null
==
templateInfo
)
{
// return null;
return
null
;
// }
}
//
// String content = templateInfo.getContent();
// 2、根据请求信息获取用户的手机号码(此处不考虑配置DMHUB系统不是SMS的情况),直接拿请求体中的_audienceId字段值,该值为手机号码
// String smsType = templateInfo.getType();
String
phone
=
data
.
getString
(
"_audienceId"
);
//
List
<
String
>
phoneList
=
new
ArrayList
<>();
// // 系统记录批次,不管是单发还是批量发送都当是批量发送处理
phoneList
.
add
(
phone
);
// SysBatchInfo info = new SysBatchInfo();
String
type
=
templateInfo
.
getType
();
// info.setBatchId(IdHandler.nextId());
// Integer insert = sysBatchMapper.insert(info);
// 3、记录批次信息
SysBatchInfo
sysBatchInfo
=
new
SysBatchInfo
();
// chuanLanSmsService.sendByFixed(content);
sysBatchInfo
.
setBatchId
(
IdHandler
.
nextId
());
sysBatchInfo
.
setDmBatchId
(
dmHubBatchId
);
sysBatchInfo
.
setId
(
IdHandler
.
nextId
());
sysBatchInfo
.
setDmTemplateId
(
templateId
);
sysBatchInfo
.
setReport
(
"1"
);
sysBatchInfo
.
setSmsNum
(
1
);
sysBatchInfo
.
setDateCreated
(
new
Date
());
sysBatchInfo
.
setLastUpdated
(
new
Date
());
boolean
insert
=
sysBatchService
.
insert
(
sysBatchInfo
);
// 判断模板是固定短信还是变量短信
String
content
=
templateInfo
.
getContent
();
if
(
content
.
contains
(
"${"
))
{
// TODO 判断方式待定
// 变量模板
// 3、模板参数文本替换。获取模板中的动态参内容,替换成创蓝需要的格式${var}.将请求中的参数信息和模板中的变量名对应起来,封装创蓝请求参数
XfaceClSendFiexdResponseDTO
chuanglanResponse
=
chuanLanSmsService
.
sendByFixed
(
dmHubBatchId
,
content
,
phoneList
,
type
);
}
else
{
// 固定模板
// 4、封裝數據
chuanLanSmsService
.
sendByVariable
(
dmHubBatchId
,
content
,
phoneList
,
type
);
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
...
src/main/java/com/jz/sms/service/impl/SmsTemplateServiceImpl.java
0 → 100644
View file @
7be8dd0d
package
com
.
jz
.
sms
.
service
.
impl
;
import
com.baomidou.mybatisplus.service.impl.ServiceImpl
;
import
com.jz.sms.repository.domain.SmsTemplateInfo
;
import
com.jz.sms.repository.mapper.TemplateMapper
;
import
com.jz.sms.service.SmsTemplateService
;
import
org.springframework.stereotype.Service
;
@Service
public
class
SmsTemplateServiceImpl
extends
ServiceImpl
<
TemplateMapper
,
SmsTemplateInfo
>
implements
SmsTemplateService
{
}
src/main/java/com/jz/sms/service/impl/SysBatchServiceImpl.java
0 → 100644
View file @
7be8dd0d
package
com
.
jz
.
sms
.
service
.
impl
;
import
com.baomidou.mybatisplus.service.impl.ServiceImpl
;
import
com.jz.sms.repository.domain.SysBatchInfo
;
import
com.jz.sms.repository.mapper.SysBatchMapper
;
import
com.jz.sms.service.SysBatchService
;
import
org.springframework.stereotype.Service
;
@Service
public
class
SysBatchServiceImpl
extends
ServiceImpl
<
SysBatchMapper
,
SysBatchInfo
>
implements
SysBatchService
{
}
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