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
767e04f9
Commit
767e04f9
authored
Jul 16, 2020
by
qinxunjia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改ID生成方式
parent
a57bd496
Changes
16
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
363 additions
and
341 deletions
+363
-341
DmHubApi.java
src/main/java/com/bgy/sms/channel/api/DmHubApi.java
+9
-5
BgySmsServiceImpl.java
...m/bgy/sms/channel/bgy/service/impl/BgySmsServiceImpl.java
+1
-1
DmBatchInfo.java
src/main/java/com/bgy/sms/repository/domain/DmBatchInfo.java
+3
-3
DmCodeInfo.java
src/main/java/com/bgy/sms/repository/domain/DmCodeInfo.java
+3
-3
SmsTemplateInfo.java
...n/java/com/bgy/sms/repository/domain/SmsTemplateInfo.java
+3
-3
SysBatchInfo.java
...main/java/com/bgy/sms/repository/domain/SysBatchInfo.java
+6
-6
SysRecordInfo.java
...ain/java/com/bgy/sms/repository/domain/SysRecordInfo.java
+6
-6
XiaoShuMapper.java
...ain/java/com/bgy/sms/repository/mapper/XiaoShuMapper.java
+1
-1
XiaoShuService.java
src/main/java/com/bgy/sms/service/XiaoShuService.java
+1
-1
MessageServiceImpl.java
...ain/java/com/bgy/sms/service/impl/MessageServiceImpl.java
+27
-20
XiaoShuServiceImpl.java
...ain/java/com/bgy/sms/service/impl/XiaoShuServiceImpl.java
+2
-2
Id.java
src/main/java/com/bgy/util/id/Id.java
+193
-193
IdHandler.java
src/main/java/com/bgy/util/id/IdHandler.java
+27
-27
SystemClock.java
src/main/java/com/bgy/util/id/SystemClock.java
+69
-69
UUIDUtils.java
src/main/java/com/bgy/util/id/UUIDUtils.java
+11
-0
XiaoShuMapper.xml
src/main/resources/mapper/XiaoShuMapper.xml
+1
-1
No files found.
src/main/java/com/bgy/sms/channel/api/DmHubApi.java
View file @
767e04f9
...
@@ -5,6 +5,7 @@ import com.bgy.sms.channel.dmHub.config.DmHubConfig;
...
@@ -5,6 +5,7 @@ import com.bgy.sms.channel.dmHub.config.DmHubConfig;
import
com.bgy.sms.channel.dto.*
;
import
com.bgy.sms.channel.dto.*
;
import
com.bgy.sms.config.ResponseCode
;
import
com.bgy.sms.config.ResponseCode
;
import
com.bgy.sms.service.MessageService
;
import
com.bgy.sms.service.MessageService
;
import
com.bgy.sms.service.XiaoShuService
;
import
com.bgy.util.Md5Util
;
import
com.bgy.util.Md5Util
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -20,6 +21,11 @@ public class DmHubApi {
...
@@ -20,6 +21,11 @@ public class DmHubApi {
@Autowired
@Autowired
private
MessageService
messageService
;
private
MessageService
messageService
;
@Autowired
private
XiaoShuService
xiaoShuService
;
private
static
final
String
REJECTED
=
"rejected"
;
// 创建模板响应数据
private
static
final
String
APPROVED
=
"approved"
;
// 创建模板响应数据
@GetMapping
(
"/ping"
)
@GetMapping
(
"/ping"
)
public
String
ping
()
{
public
String
ping
()
{
...
@@ -34,22 +40,20 @@ public class DmHubApi {
...
@@ -34,22 +40,20 @@ public class DmHubApi {
* @return
* @return
*/
*/
@PostMapping
(
"/sms/template"
)
@PostMapping
(
"/sms/template"
)
public
DmHubResponse
template
(
@RequestBody
DmHubTemplateRequest
params
,
String
appId
,
String
timestamp
,
String
signature
)
{
public
void
template
(
@RequestBody
DmHubTemplateRequest
params
,
String
appId
,
String
timestamp
,
String
signature
)
{
log
.
info
(
"**********创建模板接口入参*******:{},\r\n appId:{},timestamp:{},signature:{}"
,
JSONObject
.
toJSONString
(
params
),
appId
,
timestamp
,
signature
);
log
.
info
(
"**********创建模板接口入参*******:{},\r\n appId:{},timestamp:{},signature:{}"
,
JSONObject
.
toJSONString
(
params
),
appId
,
timestamp
,
signature
);
DmHubResponse
response
;
DmHubResponse
response
;
try
{
try
{
boolean
checkResult
=
this
.
checkSignature
(
timestamp
,
signature
);
boolean
checkResult
=
this
.
checkSignature
(
timestamp
,
signature
);
if
(!
checkResult
)
{
if
(!
checkResult
)
{
response
=
new
DmHubResponse
(
"555"
,
"接口请求签名校验不通过"
);
xiaoShuService
.
updateDmhubSmsTempStatus
(
REJECTED
,
params
.
getTemplateId
(),
"接口请求签名校验不通过"
);
log
.
info
(
"**********创建模板接口出参*******:{}"
,
JSONObject
.
toJSONString
(
response
));
log
.
info
(
"**********创建模板接口出参*******:{}"
,
"接口请求签名校验不通过"
);
return
response
;
}
}
messageService
.
createTemplate
(
params
);
messageService
.
createTemplate
(
params
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"创建模板短信异常"
,
e
);
log
.
error
(
"创建模板短信异常"
,
e
);
new
DmHubResponse
(
"999"
,
"创建模板短信异常"
);
new
DmHubResponse
(
"999"
,
"创建模板短信异常"
);
}
}
return
null
;
}
}
/**
/**
...
...
src/main/java/com/bgy/sms/channel/bgy/service/impl/BgySmsServiceImpl.java
View file @
767e04f9
...
@@ -160,7 +160,7 @@ public class BgySmsServiceImpl implements BgySmsService {
...
@@ -160,7 +160,7 @@ public class BgySmsServiceImpl implements BgySmsService {
updateInfo
.
setUpRejectMsg
(
auditReason
);
updateInfo
.
setUpRejectMsg
(
auditReason
);
updateInfo
.
setLastUpdated
(
new
Date
());
updateInfo
.
setLastUpdated
(
new
Date
());
smsTemplateService
.
updateById
(
updateInfo
);
smsTemplateService
.
updateById
(
updateInfo
);
xiaoShuService
.
updateDmhubSmsTempStatus
(
dmhubStatue
,
smsTemplateInfo
.
getDmTemplateId
());
xiaoShuService
.
updateDmhubSmsTempStatus
(
dmhubStatue
,
smsTemplateInfo
.
getDmTemplateId
()
,
auditReason
);
return
new
BGYResponse
();
return
new
BGYResponse
();
}
}
...
...
src/main/java/com/bgy/sms/repository/domain/DmBatchInfo.java
View file @
767e04f9
...
@@ -9,7 +9,7 @@ import java.util.Date;
...
@@ -9,7 +9,7 @@ import java.util.Date;
public
class
DmBatchInfo
{
public
class
DmBatchInfo
{
private
Lo
ng
id
;
private
Stri
ng
id
;
private
String
dmBatchId
;
private
String
dmBatchId
;
...
@@ -26,11 +26,11 @@ public class DmBatchInfo {
...
@@ -26,11 +26,11 @@ public class DmBatchInfo {
private
Date
lastUpdated
;
private
Date
lastUpdated
;
public
Lo
ng
getId
()
{
public
Stri
ng
getId
()
{
return
id
;
return
id
;
}
}
public
void
setId
(
Lo
ng
id
)
{
public
void
setId
(
Stri
ng
id
)
{
this
.
id
=
id
;
this
.
id
=
id
;
}
}
...
...
src/main/java/com/bgy/sms/repository/domain/DmCodeInfo.java
View file @
767e04f9
...
@@ -9,7 +9,7 @@ import java.util.Date;
...
@@ -9,7 +9,7 @@ import java.util.Date;
public
class
DmCodeInfo
{
public
class
DmCodeInfo
{
private
Lo
ng
id
;
private
Stri
ng
id
;
private
String
mobile
;
private
String
mobile
;
...
@@ -19,11 +19,11 @@ public class DmCodeInfo {
...
@@ -19,11 +19,11 @@ public class DmCodeInfo {
private
Date
dateCreated
;
private
Date
dateCreated
;
public
Lo
ng
getId
()
{
public
Stri
ng
getId
()
{
return
id
;
return
id
;
}
}
public
void
setId
(
Lo
ng
id
)
{
public
void
setId
(
Stri
ng
id
)
{
this
.
id
=
id
;
this
.
id
=
id
;
}
}
...
...
src/main/java/com/bgy/sms/repository/domain/SmsTemplateInfo.java
View file @
767e04f9
...
@@ -10,7 +10,7 @@ import java.util.Date;
...
@@ -10,7 +10,7 @@ import java.util.Date;
public
class
SmsTemplateInfo
{
public
class
SmsTemplateInfo
{
private
Lo
ng
id
;
private
Stri
ng
id
;
private
String
dmTemplateId
;
private
String
dmTemplateId
;
...
@@ -91,11 +91,11 @@ public class SmsTemplateInfo {
...
@@ -91,11 +91,11 @@ public class SmsTemplateInfo {
this
.
tenantId
=
tenantId
;
this
.
tenantId
=
tenantId
;
}
}
public
Lo
ng
getId
()
{
public
Stri
ng
getId
()
{
return
id
;
return
id
;
}
}
public
void
setId
(
Lo
ng
id
)
{
public
void
setId
(
Stri
ng
id
)
{
this
.
id
=
id
;
this
.
id
=
id
;
}
}
...
...
src/main/java/com/bgy/sms/repository/domain/SysBatchInfo.java
View file @
767e04f9
...
@@ -7,13 +7,13 @@ import java.util.Date;
...
@@ -7,13 +7,13 @@ import java.util.Date;
@TableName
(
"sys_batch"
)
@TableName
(
"sys_batch"
)
public
class
SysBatchInfo
{
public
class
SysBatchInfo
{
private
Lo
ng
id
;
private
Stri
ng
id
;
private
String
dmBatchId
;
private
String
dmBatchId
;
private
String
dmTemplateId
;
private
String
dmTemplateId
;
private
Lo
ng
batchId
;
private
Stri
ng
batchId
;
private
String
report
;
private
String
report
;
...
@@ -31,11 +31,11 @@ public class SysBatchInfo {
...
@@ -31,11 +31,11 @@ public class SysBatchInfo {
private
Date
lastUpdated
;
private
Date
lastUpdated
;
public
Lo
ng
getId
()
{
public
Stri
ng
getId
()
{
return
id
;
return
id
;
}
}
public
void
setId
(
Lo
ng
id
)
{
public
void
setId
(
Stri
ng
id
)
{
this
.
id
=
id
;
this
.
id
=
id
;
}
}
...
@@ -55,11 +55,11 @@ public class SysBatchInfo {
...
@@ -55,11 +55,11 @@ public class SysBatchInfo {
this
.
dmTemplateId
=
dmTemplateId
;
this
.
dmTemplateId
=
dmTemplateId
;
}
}
public
Lo
ng
getBatchId
()
{
public
Stri
ng
getBatchId
()
{
return
batchId
;
return
batchId
;
}
}
public
void
setBatchId
(
Lo
ng
batchId
)
{
public
void
setBatchId
(
Stri
ng
batchId
)
{
this
.
batchId
=
batchId
;
this
.
batchId
=
batchId
;
}
}
...
...
src/main/java/com/bgy/sms/repository/domain/SysRecordInfo.java
View file @
767e04f9
...
@@ -7,9 +7,9 @@ import java.util.Date;
...
@@ -7,9 +7,9 @@ import java.util.Date;
@TableName
(
"sms_record"
)
@TableName
(
"sms_record"
)
public
class
SysRecordInfo
{
public
class
SysRecordInfo
{
private
Lo
ng
id
;
private
Stri
ng
id
;
private
Lo
ng
sysBatchId
;
private
Stri
ng
sysBatchId
;
private
String
mobile
;
private
String
mobile
;
...
@@ -39,19 +39,19 @@ public class SysRecordInfo {
...
@@ -39,19 +39,19 @@ public class SysRecordInfo {
this
.
areaId
=
areaId
;
this
.
areaId
=
areaId
;
}
}
public
Lo
ng
getId
()
{
public
Stri
ng
getId
()
{
return
id
;
return
id
;
}
}
public
void
setId
(
Lo
ng
id
)
{
public
void
setId
(
Stri
ng
id
)
{
this
.
id
=
id
;
this
.
id
=
id
;
}
}
public
Lo
ng
getSysBatchId
()
{
public
Stri
ng
getSysBatchId
()
{
return
sysBatchId
;
return
sysBatchId
;
}
}
public
void
setSysBatchId
(
Lo
ng
sysBatchId
)
{
public
void
setSysBatchId
(
Stri
ng
sysBatchId
)
{
this
.
sysBatchId
=
sysBatchId
;
this
.
sysBatchId
=
sysBatchId
;
}
}
...
...
src/main/java/com/bgy/sms/repository/mapper/XiaoShuMapper.java
View file @
767e04f9
...
@@ -5,5 +5,5 @@ import org.apache.ibatis.annotations.Param;
...
@@ -5,5 +5,5 @@ import org.apache.ibatis.annotations.Param;
public
interface
XiaoShuMapper
{
public
interface
XiaoShuMapper
{
String
getLoginNameByTempId
(
@Param
(
"tempId"
)
String
templateId
);
String
getLoginNameByTempId
(
@Param
(
"tempId"
)
String
templateId
);
void
updateDmhubTemp
(
@Param
(
"status"
)
String
status
,
@Param
(
"tempId"
)
String
tempId
);
void
updateDmhubTemp
(
@Param
(
"status"
)
String
status
,
@Param
(
"tempId"
)
String
tempId
,
@Param
(
"desc"
)
String
desc
);
}
}
src/main/java/com/bgy/sms/service/XiaoShuService.java
View file @
767e04f9
...
@@ -3,5 +3,5 @@ package com.bgy.sms.service;
...
@@ -3,5 +3,5 @@ package com.bgy.sms.service;
public
interface
XiaoShuService
{
public
interface
XiaoShuService
{
String
selectUserIdByTemplate
(
String
templateId
);
String
selectUserIdByTemplate
(
String
templateId
);
void
updateDmhubSmsTempStatus
(
String
dmhubStatue
,
String
dmTemplateId
);
void
updateDmhubSmsTempStatus
(
String
dmhubStatue
,
String
dmTemplateId
,
String
desc
);
}
}
src/main/java/com/bgy/sms/service/impl/MessageServiceImpl.java
View file @
767e04f9
...
@@ -11,7 +11,7 @@ import com.bgy.sms.config.ResponseCode;
...
@@ -11,7 +11,7 @@ import com.bgy.sms.config.ResponseCode;
import
com.bgy.sms.repository.domain.*
;
import
com.bgy.sms.repository.domain.*
;
import
com.bgy.sms.service.*
;
import
com.bgy.sms.service.*
;
import
com.bgy.sms.service.bean.TemplateChangeBean
;
import
com.bgy.sms.service.bean.TemplateChangeBean
;
import
com.bgy.util.id.
IdHandler
;
import
com.bgy.util.id.
UUIDUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -47,6 +47,9 @@ public class MessageServiceImpl implements MessageService {
...
@@ -47,6 +47,9 @@ public class MessageServiceImpl implements MessageService {
@Autowired
@Autowired
private
XiaoShuService
xiaoShuService
;
private
XiaoShuService
xiaoShuService
;
private
static
final
String
REJECTED
=
"rejected"
;
// 创建模板响应数据
private
static
final
String
APPROVED
=
"approved"
;
// 创建模板响应数据
/**
/**
* 短信模板创建
* 短信模板创建
*
*
...
@@ -58,14 +61,14 @@ public class MessageServiceImpl implements MessageService {
...
@@ -58,14 +61,14 @@ public class MessageServiceImpl implements MessageService {
log
.
info
(
"进入创建短信模板业务逻辑,入参:{}"
,
requestDTO
);
log
.
info
(
"进入创建短信模板业务逻辑,入参:{}"
,
requestDTO
);
DmHubResponse
responseDTO
=
new
DmHubResponse
(
ResponseCode
.
SUCCESS
);
DmHubResponse
responseDTO
=
new
DmHubResponse
(
ResponseCode
.
SUCCESS
);
String
templateId
=
null
;
try
{
try
{
String
templateContent
=
requestDTO
.
getTemplateContent
();
String
templateContent
=
requestDTO
.
getTemplateContent
();
String
signature
=
requestDTO
.
getSignature
();
String
signature
=
requestDTO
.
getSignature
();
String
smsType
=
requestDTO
.
getSmsType
();
String
smsType
=
requestDTO
.
getSmsType
();
String
tenantId
=
requestDTO
.
getTenantId
();
String
tenantId
=
requestDTO
.
getTenantId
();
String
templateId
=
requestDTO
.
getTemplateId
();
templateId
=
requestDTO
.
getTemplateId
();
String
templateName
=
requestDTO
.
getTemplateName
();
String
templateName
=
requestDTO
.
getTemplateName
();
// 替换模板格式,保存适合碧桂园发送短信的模板,避免发送时修改模板格式
// 替换模板格式,保存适合碧桂园发送短信的模板,避免发送时修改模板格式
TemplateChangeBean
bean
=
dmHub2BgyTemplateSend
(
templateContent
);
TemplateChangeBean
bean
=
dmHub2BgyTemplateSend
(
templateContent
);
String
bgySendStr
=
bean
.
getUpSendStr
();
String
bgySendStr
=
bean
.
getUpSendStr
();
...
@@ -73,6 +76,7 @@ public class MessageServiceImpl implements MessageService {
...
@@ -73,6 +76,7 @@ public class MessageServiceImpl implements MessageService {
SmsTemplateInfo
dbInfo
=
smsTemplateService
.
selectOne
(
new
EntityWrapper
<
SmsTemplateInfo
>().
eq
(
"dm_template_id"
,
templateId
));
SmsTemplateInfo
dbInfo
=
smsTemplateService
.
selectOne
(
new
EntityWrapper
<
SmsTemplateInfo
>().
eq
(
"dm_template_id"
,
templateId
));
if
(
dbInfo
!=
null
)
{
if
(
dbInfo
!=
null
)
{
log
.
error
(
"Dm Hub请求创建模板,模板id已存在,模板id:【{}】"
,
templateId
);
log
.
error
(
"Dm Hub请求创建模板,模板id已存在,模板id:【{}】"
,
templateId
);
xiaoShuService
.
updateDmhubSmsTempStatus
(
REJECTED
,
templateId
,
"模板id已存在,请重新创建"
);
return
new
DmHubResponse
(
ResponseCode
.
TEMPLATE_ALREADY_EXISTED
);
return
new
DmHubResponse
(
ResponseCode
.
TEMPLATE_ALREADY_EXISTED
);
}
}
SmsTemplateInfo
info
=
new
SmsTemplateInfo
();
SmsTemplateInfo
info
=
new
SmsTemplateInfo
();
...
@@ -80,7 +84,7 @@ public class MessageServiceImpl implements MessageService {
...
@@ -80,7 +84,7 @@ public class MessageServiceImpl implements MessageService {
info
.
setType
(
smsType
);
info
.
setType
(
smsType
);
info
.
setDmTemplateId
(
templateId
);
info
.
setDmTemplateId
(
templateId
);
info
.
setTenantId
(
tenantId
);
info
.
setTenantId
(
tenantId
);
info
.
setId
(
IdHandler
.
nex
tId
());
info
.
setId
(
UUIDUtils
.
ge
tId
());
info
.
setSignature
(
signature
);
info
.
setSignature
(
signature
);
info
.
setTemplateName
(
templateName
);
info
.
setTemplateName
(
templateName
);
info
.
setDateCreated
(
new
Date
());
info
.
setDateCreated
(
new
Date
());
...
@@ -91,9 +95,10 @@ public class MessageServiceImpl implements MessageService {
...
@@ -91,9 +95,10 @@ public class MessageServiceImpl implements MessageService {
boolean
insert
=
smsTemplateService
.
insert
(
info
);
boolean
insert
=
smsTemplateService
.
insert
(
info
);
if
(!
insert
)
{
if
(!
insert
)
{
log
.
error
(
"模板插入DB异常:【{}】"
,
JSONObject
.
toJSONString
(
info
));
log
.
error
(
"模板插入DB异常:【{}】"
,
JSONObject
.
toJSONString
(
info
));
xiaoShuService
.
updateDmhubSmsTempStatus
(
REJECTED
,
templateId
,
"插件系统异常"
);
return
new
DmHubResponse
(
ResponseCode
.
SYSTEM_ERROR
);
return
new
DmHubResponse
(
ResponseCode
.
SYSTEM_ERROR
);
}
else
{
}
else
{
String
pkID
=
info
.
getId
()
+
""
;
String
pkID
=
info
.
getId
();
String
TEMPLATETYPE
=
""
;
String
TEMPLATETYPE
=
""
;
if
(
"marketing"
.
equals
(
smsType
))
{
if
(
"marketing"
.
equals
(
smsType
))
{
TEMPLATETYPE
=
"52"
;
TEMPLATETYPE
=
"52"
;
...
@@ -103,6 +108,7 @@ public class MessageServiceImpl implements MessageService {
...
@@ -103,6 +108,7 @@ public class MessageServiceImpl implements MessageService {
CLBizResponse
response
=
new
CLBizResponse
();
CLBizResponse
response
=
new
CLBizResponse
();
String
account
=
xiaoShuService
.
selectUserIdByTemplate
(
templateId
);
String
account
=
xiaoShuService
.
selectUserIdByTemplate
(
templateId
);
if
(
StringUtils
.
isBlank
(
account
))
{
if
(
StringUtils
.
isBlank
(
account
))
{
xiaoShuService
.
updateDmhubSmsTempStatus
(
REJECTED
,
templateId
,
"未找到当前登录用户的售楼系统ID"
);
return
new
DmHubResponse
(
ResponseCode
.
NO_USER_ID
);
return
new
DmHubResponse
(
ResponseCode
.
NO_USER_ID
);
}
}
response
=
bgySmsService
.
createTemplate
(
bgySendStr
,
account
,
TEMPLATETYPE
,
pkID
);
response
=
bgySmsService
.
createTemplate
(
bgySendStr
,
account
,
TEMPLATETYPE
,
pkID
);
...
@@ -111,15 +117,19 @@ public class MessageServiceImpl implements MessageService {
...
@@ -111,15 +117,19 @@ public class MessageServiceImpl implements MessageService {
if
(
code
.
equals
(
ResponseCode
.
SUCCESS
.
getCode
()))
{
if
(
code
.
equals
(
ResponseCode
.
SUCCESS
.
getCode
()))
{
SmsTemplateInfo
updateInfo
=
new
SmsTemplateInfo
();
SmsTemplateInfo
updateInfo
=
new
SmsTemplateInfo
();
updateInfo
.
setTemplateRecordId
(
msg
);
updateInfo
.
setTemplateRecordId
(
msg
);
updateInfo
.
setId
(
Long
.
parseLong
(
pkID
)
);
updateInfo
.
setId
(
pkID
);
smsTemplateService
.
updateById
(
updateInfo
);
smsTemplateService
.
updateById
(
updateInfo
);
return
new
DmHubResponse
(
ResponseCode
.
SUCCESS
);
return
new
DmHubResponse
(
ResponseCode
.
SUCCESS
);
}
else
{
}
else
{
xiaoShuService
.
updateDmhubSmsTempStatus
(
REJECTED
,
templateId
,
msg
);
return
new
DmHubResponse
(
code
,
msg
);
return
new
DmHubResponse
(
code
,
msg
);
}
}
}
}
}
catch
(
Exception
exception
)
{
}
catch
(
Exception
exception
)
{
log
.
error
(
"创建模板业务逻辑异常,错误信息"
,
exception
);
log
.
error
(
"创建模板业务逻辑异常,错误信息"
,
exception
);
if
(!
StringUtils
.
isBlank
(
templateId
))
{
xiaoShuService
.
updateDmhubSmsTempStatus
(
REJECTED
,
templateId
,
"插件系统异常"
);
}
responseDTO
=
new
DmHubResponse
(
ResponseCode
.
SYSTEM_ERROR
);
responseDTO
=
new
DmHubResponse
(
ResponseCode
.
SYSTEM_ERROR
);
}
}
return
responseDTO
;
return
responseDTO
;
...
@@ -252,10 +262,10 @@ public class MessageServiceImpl implements MessageService {
...
@@ -252,10 +262,10 @@ public class MessageServiceImpl implements MessageService {
String
type
=
templateInfo
.
getType
();
String
type
=
templateInfo
.
getType
();
// 3、记录批次信息
// 3、记录批次信息
SysBatchInfo
sysBatchInfo
=
new
SysBatchInfo
();
SysBatchInfo
sysBatchInfo
=
new
SysBatchInfo
();
long
sysBatchId
=
IdHandler
.
nex
tId
();
String
sysBatchId
=
UUIDUtils
.
ge
tId
();
sysBatchInfo
.
setBatchId
(
sysBatchId
);
sysBatchInfo
.
setBatchId
(
sysBatchId
);
sysBatchInfo
.
setDmBatchId
(
dmHubBatchId
);
sysBatchInfo
.
setDmBatchId
(
dmHubBatchId
);
sysBatchInfo
.
setId
(
IdHandler
.
nex
tId
());
sysBatchInfo
.
setId
(
UUIDUtils
.
ge
tId
());
sysBatchInfo
.
setDmTemplateId
(
templateId
);
sysBatchInfo
.
setDmTemplateId
(
templateId
);
sysBatchInfo
.
setReport
(
"1"
);
sysBatchInfo
.
setReport
(
"1"
);
sysBatchInfo
.
setSmsNum
(
1
);
sysBatchInfo
.
setSmsNum
(
1
);
...
@@ -280,13 +290,11 @@ public class MessageServiceImpl implements MessageService {
...
@@ -280,13 +290,11 @@ public class MessageServiceImpl implements MessageService {
}
else
{
}
else
{
api
=
"SendNotifySMS"
;
api
=
"SendNotifySMS"
;
}
}
response
=
bgySmsService
.
sendSms
(
mobile
,
content
,
channelAccount
,
api
);
response
=
bgySmsService
.
sendSms
(
mobile
,
content
,
channelAccount
,
api
);
//4.短信发送记录
//4.短信发送记录
SysRecordInfo
sysRecordInfo
=
new
SysRecordInfo
();
SysRecordInfo
sysRecordInfo
=
new
SysRecordInfo
();
sysRecordInfo
.
setId
(
IdHandler
.
nex
tId
());
sysRecordInfo
.
setId
(
UUIDUtils
.
ge
tId
());
long
sysRecordInfoBatchId
=
IdHandler
.
nex
tId
();
String
sysRecordInfoBatchId
=
UUIDUtils
.
ge
tId
();
sysRecordInfo
.
setSysBatchId
(
sysRecordInfoBatchId
);
sysRecordInfo
.
setSysBatchId
(
sysRecordInfoBatchId
);
sysRecordInfo
.
setMobile
(
mobile
);
sysRecordInfo
.
setMobile
(
mobile
);
sysRecordInfo
.
setChargeNum
(
1
);
sysRecordInfo
.
setChargeNum
(
1
);
...
@@ -324,7 +332,7 @@ public class MessageServiceImpl implements MessageService {
...
@@ -324,7 +332,7 @@ public class MessageServiceImpl implements MessageService {
String
content
=
"您的验证码是:"
+
code
;
String
content
=
"您的验证码是:"
+
code
;
try
{
try
{
DmCodeInfo
codeInfo
=
new
DmCodeInfo
();
DmCodeInfo
codeInfo
=
new
DmCodeInfo
();
codeInfo
.
setId
(
IdHandler
.
nex
tId
());
codeInfo
.
setId
(
UUIDUtils
.
ge
tId
());
codeInfo
.
setAreaId
(
BgySMSConfig
.
areaId
);
codeInfo
.
setAreaId
(
BgySMSConfig
.
areaId
);
codeInfo
.
setCode
(
code
);
codeInfo
.
setCode
(
code
);
codeInfo
.
setMobile
(
mobile
);
codeInfo
.
setMobile
(
mobile
);
...
@@ -428,17 +436,17 @@ public class MessageServiceImpl implements MessageService {
...
@@ -428,17 +436,17 @@ public class MessageServiceImpl implements MessageService {
dmInfo
.
setDmBatchId
(
batchId
);
dmInfo
.
setDmBatchId
(
batchId
);
dmInfo
.
setDmTemplateId
(
templateId
);
dmInfo
.
setDmTemplateId
(
templateId
);
dmInfo
.
setSmsNum
(
data
.
size
());
dmInfo
.
setSmsNum
(
data
.
size
());
dmInfo
.
setId
(
IdHandler
.
nex
tId
());
dmInfo
.
setId
(
UUIDUtils
.
ge
tId
());
dmInfo
.
setDateCreated
(
new
Date
());
dmInfo
.
setDateCreated
(
new
Date
());
dmInfo
.
setLastUpdated
(
new
Date
());
dmInfo
.
setLastUpdated
(
new
Date
());
dmBatchService
.
insert
(
dmInfo
);
dmBatchService
.
insert
(
dmInfo
);
SysBatchInfo
info
=
new
SysBatchInfo
();
SysBatchInfo
info
=
new
SysBatchInfo
();
info
.
setId
(
info
.
getBatchId
());
String
sysBatchId
=
UUIDUtils
.
getId
();
info
.
setId
(
sysBatchId
);
info
.
setDmBatchId
(
batchId
);
info
.
setDmBatchId
(
batchId
);
info
.
setSmsNum
(
data
.
size
());
info
.
setSmsNum
(
data
.
size
());
info
.
setDmTemplateId
(
templateId
);
info
.
setDmTemplateId
(
templateId
);
Long
sysBatchId
=
IdHandler
.
nextId
();
info
.
setBatchId
(
sysBatchId
);
info
.
setBatchId
(
sysBatchId
);
info
.
setDateCreated
(
new
Date
());
info
.
setDateCreated
(
new
Date
());
info
.
setLastUpdated
(
new
Date
());
info
.
setLastUpdated
(
new
Date
());
...
@@ -447,8 +455,8 @@ public class MessageServiceImpl implements MessageService {
...
@@ -447,8 +455,8 @@ public class MessageServiceImpl implements MessageService {
//4.短信发送记录
//4.短信发送记录
SysRecordInfo
sysRecordInfo
=
new
SysRecordInfo
();
SysRecordInfo
sysRecordInfo
=
new
SysRecordInfo
();
sysRecordInfo
.
setId
(
IdHandler
.
nex
tId
());
sysRecordInfo
.
setId
(
UUIDUtils
.
ge
tId
());
long
sysRecordInfoBatchId
=
IdHandler
.
nex
tId
();
String
sysRecordInfoBatchId
=
UUIDUtils
.
ge
tId
();
sysRecordInfo
.
setSysBatchId
(
sysRecordInfoBatchId
);
sysRecordInfo
.
setSysBatchId
(
sysRecordInfoBatchId
);
Date
date
=
new
Date
();
Date
date
=
new
Date
();
sysRecordInfo
.
setDateCreated
(
date
);
sysRecordInfo
.
setDateCreated
(
date
);
...
@@ -494,8 +502,7 @@ public class MessageServiceImpl implements MessageService {
...
@@ -494,8 +502,7 @@ public class MessageServiceImpl implements MessageService {
return
new
DmHubResponse
(
"999"
,
"插件服务系统异常"
);
return
new
DmHubResponse
(
"999"
,
"插件服务系统异常"
);
}
}
}
}
else
{
else
{
// 变量短信
// 变量短信
Set
<
Map
.
Entry
<
String
,
List
<
String
>>>
entries
=
paramsMap
.
entrySet
();
Set
<
Map
.
Entry
<
String
,
List
<
String
>>>
entries
=
paramsMap
.
entrySet
();
List
<
JSONObject
>
list
=
new
ArrayList
<>();
List
<
JSONObject
>
list
=
new
ArrayList
<>();
...
...
src/main/java/com/bgy/sms/service/impl/XiaoShuServiceImpl.java
View file @
767e04f9
...
@@ -25,7 +25,7 @@ public class XiaoShuServiceImpl implements XiaoShuService {
...
@@ -25,7 +25,7 @@ public class XiaoShuServiceImpl implements XiaoShuService {
@Override
@Override
@DB
(
value
=
DataSourceType
.
DB2
)
@DB
(
value
=
DataSourceType
.
DB2
)
public
void
updateDmhubSmsTempStatus
(
String
dmhubStatue
,
String
dmTemplateId
)
{
public
void
updateDmhubSmsTempStatus
(
String
dmhubStatue
,
String
dmTemplateId
,
String
desc
)
{
xiaoShuMapper
.
updateDmhubTemp
(
dmhubStatue
,
dmTemplateId
);
xiaoShuMapper
.
updateDmhubTemp
(
dmhubStatue
,
dmTemplateId
,
desc
);
}
}
}
}
src/main/java/com/bgy/util/id/Id.java
View file @
767e04f9
This diff is collapsed.
Click to expand it.
src/main/java/com/bgy/util/id/IdHandler.java
View file @
767e04f9
package
com
.
bgy
.
util
.
id
;
//
package com.bgy.util.id;
//
//
public
class
IdHandler
{
//
public class IdHandler {
private
IdHandler
()
{
//
private IdHandler() {
super
();
//
super();
}
//
}
//
private
static
final
Id
id
=
new
Id
(
0
,
0
);
//
private static final Id id = new Id(0, 0);
//
public
static
Id
getInstance
()
{
//
public static Id getInstance() {
return
id
;
//
return id;
}
//
}
//
public
static
long
nextId
()
{
//
public static long nextId() {
return
id
.
nextId
();
//
return id.nextId();
}
//
}
//
public
static
String
nextIdStr
()
{
//
public static String nextIdStr() {
return
String
.
valueOf
(
nextId
());
//
return String.valueOf(nextId());
}
//
}
//
public
static
void
main
(
String
[]
args
)
{
//
public static void main(String[] args) {
//
}
//
}
//
}
//
}
src/main/java/com/bgy/util/id/SystemClock.java
View file @
767e04f9
package
com
.
bgy
.
util
.
id
;
//
package com.bgy.util.id;
//
import
java.sql.Timestamp
;
//
import java.sql.Timestamp;
import
java.util.concurrent.Executors
;
//
import java.util.concurrent.Executors;
import
java.util.concurrent.ScheduledExecutorService
;
//
import java.util.concurrent.ScheduledExecutorService;
import
java.util.concurrent.ThreadFactory
;
//
import java.util.concurrent.ThreadFactory;
import
java.util.concurrent.TimeUnit
;
//
import java.util.concurrent.TimeUnit;
import
java.util.concurrent.atomic.AtomicLong
;
//
import java.util.concurrent.atomic.AtomicLong;
//
/**
/
//
**
* 高并发场景下System.currentTimeMillis()的性能问题的优化
//
* 高并发场景下System.currentTimeMillis()的性能问题的优化
* <p><p>
//
* <p><p>
* System.currentTimeMillis()的调用比new一个普通对象要耗时的多(具体耗时高出多少我还没测试过,有人说是100倍左右)<p>
//
* System.currentTimeMillis()的调用比new一个普通对象要耗时的多(具体耗时高出多少我还没测试过,有人说是100倍左右)<p>
* System.currentTimeMillis()之所以慢是因为去跟系统打了一次交道<p>
//
* System.currentTimeMillis()之所以慢是因为去跟系统打了一次交道<p>
* 后台定时更新时钟,JVM退出时,线程自动回收<p>
//
* 后台定时更新时钟,JVM退出时,线程自动回收<p>
* 10亿:43410,206,210.72815533980582%<p>
//
* 10亿:43410,206,210.72815533980582%<p>
* 1亿:4699,29,162.0344827586207%<p>
//
* 1亿:4699,29,162.0344827586207%<p>
* 1000万:480,12,40.0%<p>
//
* 1000万:480,12,40.0%<p>
* 100万:50,10,5.0%<p>
//
* 100万:50,10,5.0%<p>
*
//
*
* @author lry
//
* @author lry
*/
//
*/
public
class
SystemClock
{
//
public class SystemClock {
//
private
final
long
period
;
//
private final long period;
private
final
AtomicLong
now
;
//
private final AtomicLong now;
//
private
SystemClock
(
long
period
)
{
//
private SystemClock(long period) {
this
.
period
=
period
;
//
this.period = period;
this
.
now
=
new
AtomicLong
(
System
.
currentTimeMillis
());
//
this.now = new AtomicLong(System.currentTimeMillis());
scheduleClockUpdating
();
//
scheduleClockUpdating();
}
//
}
//
private
static
class
InstanceHolder
{
//
private static class InstanceHolder {
public
static
final
SystemClock
INSTANCE
=
new
SystemClock
(
1
);
//
public static final SystemClock INSTANCE = new SystemClock(1);
}
//
}
//
private
static
SystemClock
instance
()
{
//
private static SystemClock instance() {
return
InstanceHolder
.
INSTANCE
;
//
return InstanceHolder.INSTANCE;
}
//
}
//
private
void
scheduleClockUpdating
()
{
//
private void scheduleClockUpdating() {
ScheduledExecutorService
scheduler
=
Executors
.
newSingleThreadScheduledExecutor
(
new
ThreadFactory
()
{
//
ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
public
Thread
newThread
(
Runnable
runnable
)
{
//
public Thread newThread(Runnable runnable) {
Thread
thread
=
new
Thread
(
runnable
,
"System Clock"
);
//
Thread thread = new Thread(runnable, "System Clock");
thread
.
setDaemon
(
true
);
//
thread.setDaemon(true);
return
thread
;
//
return thread;
}
//
}
});
//
});
scheduler
.
scheduleAtFixedRate
(
new
Runnable
()
{
//
scheduler.scheduleAtFixedRate(new Runnable() {
public
void
run
()
{
//
public void run() {
now
.
set
(
System
.
currentTimeMillis
());
//
now.set(System.currentTimeMillis());
}
//
}
},
period
,
period
,
TimeUnit
.
MILLISECONDS
);
//
}, period, period, TimeUnit.MILLISECONDS);
}
//
}
//
private
long
currentTimeMillis
()
{
//
private long currentTimeMillis() {
return
now
.
get
();
//
return now.get();
}
//
}
//
public
static
long
now
()
{
//
public static long now() {
return
instance
().
currentTimeMillis
();
//
return instance().currentTimeMillis();
}
//
}
//
public
static
String
nowDate
()
{
//
public static String nowDate() {
return
new
Timestamp
(
instance
().
currentTimeMillis
()).
toString
();
//
return new Timestamp(instance().currentTimeMillis()).toString();
}
//
}
//
}
//
}
src/main/java/com/bgy/util/id/UUIDUtils.java
0 → 100644
View file @
767e04f9
package
com
.
bgy
.
util
.
id
;
import
java.util.UUID
;
public
class
UUIDUtils
{
public
static
String
getId
()
{
String
id
=
UUID
.
randomUUID
().
toString
().
replaceAll
(
"-"
,
""
);
return
id
;
}
}
src/main/resources/mapper/XiaoShuMapper.xml
View file @
767e04f9
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
</select>
</select>
<update
id=
"updateDmhubTemp"
parameterType=
"string"
>
<update
id=
"updateDmhubTemp"
parameterType=
"string"
>
update sms_template set status = #{status} where id = #{tempId}
update sms_template set status = #{status}
,reject_msg = #{desc}
where id = #{tempId}
</update>
</update>
</mapper>
</mapper>
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