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
a57bd496
Commit
a57bd496
authored
Jul 16, 2020
by
qinxunjia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化逻辑
parent
c5086574
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
496 additions
and
49 deletions
+496
-49
MachineIdConfig.java
src/main/java/com/bgy/config/MachineIdConfig.java
+218
-0
SnowFlake.java
src/main/java/com/bgy/config/SnowFlake.java
+185
-0
BgyApi.java
src/main/java/com/bgy/sms/channel/api/BgyApi.java
+6
-20
DmHubApi.java
src/main/java/com/bgy/sms/channel/api/DmHubApi.java
+6
-5
BgySmsService.java
...n/java/com/bgy/sms/channel/bgy/service/BgySmsService.java
+2
-1
BgySmsServiceImpl.java
...m/bgy/sms/channel/bgy/service/impl/BgySmsServiceImpl.java
+28
-11
BGYResponse.java
src/main/java/com/bgy/sms/channel/dto/BGYResponse.java
+38
-0
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
-2
MessageServiceImpl.java
...ain/java/com/bgy/sms/service/impl/MessageServiceImpl.java
+4
-4
XiaoShuServiceImpl.java
...ain/java/com/bgy/sms/service/impl/XiaoShuServiceImpl.java
+4
-2
application.yml
src/main/resources/application.yml
+1
-1
XiaoShuMapper.xml
src/main/resources/mapper/XiaoShuMapper.xml
+2
-2
No files found.
src/main/java/com/bgy/config/MachineIdConfig.java
0 → 100644
View file @
a57bd496
//package com.bgy.config;
//
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.data.redis.core.RedisTemplate;
//import org.springframework.data.redis.core.StringRedisTemplate;
//
//import javax.annotation.PreDestroy;
//import javax.annotation.Resource;
//import java.net.InetAddress;
//import java.net.UnknownHostException;
//import java.util.Date;
//import java.util.Timer;
//import java.util.TimerTask;
//import java.util.concurrent.TimeUnit;
//
//@Configuration
//@Slf4j
//public class MachineIdConfig {
// @Resource
// private StringRedisTemplate redisTemplate;
//
// @Value("${snowFlake.dataCenter}")
// private Integer dataCenterId;
//
// @Value("${snowFlake.appName}")
// private String APP_NAME;
//
// /**
// * 机器id
// */
// public static Integer machineId;
// /**
// * 本地ip地址
// */
// private static String localIp;
//
// /**
// * 获取ip地址
// *
// * @return
// * @throws UnknownHostException
// */
// private String getIPAddress() throws UnknownHostException {
// InetAddress address = InetAddress.getLocalHost();
// return address.getHostAddress();
// }
//
// /**
// * hash机器IP初始化一个机器ID
// */
// @Bean
// public SnowFlake initMachineId() throws Exception {
// localIp = getIPAddress(); // 192.168.0.233
//
// Long ip_ = Long.parseLong(localIp.replaceAll("\\.", ""));// 1921680233
// //
// machineId = ip_.hashCode() % 32;// 0-31
// // 创建一个机器ID
// createMachineId();
//
// log.info("初始化 machine_id :{}", machineId);
// return new SnowFlake(machineId, dataCenterId);
// }
//
// /**
// * 容器销毁前清除注册记录
// */
// @PreDestroy
// public void destroyMachineId() {
// redisTemplate.delete(APP_NAME + dataCenterId + machineId);
// }
//
//
// /**
// * 主方法:首先获取机器 IP 并 % 32 得到 0-31
// * 使用 业务名 + 组名 + IP 作为 Redis 的 key,机器IP作为 value,存储到Redis中
// *
// * @return
// */
// public Integer createMachineId() {
// try {
// // 向redis注册,并设置超时时间
// log.info("注册一个机器ID到Redis " + machineId + " IP:" + localIp);
// Boolean flag = registerMachine(machineId, localIp);
// // 注册成功
// if (flag) {
// // 启动一个线程更新超时时间
// updateExpTimeThread();
// // 返回机器Id
// log.info("Redis中端口没有冲突 " + machineId + " IP:" + localIp);
// return machineId;
// }
// // 注册失败,可能原因 Hash%32 的结果冲突
// if (!checkIfCanRegister()) {
// // 如果 0-31 已经用完,使用 32-64之间随机的ID
// getRandomMachineId();
// createMachineId();
// } else {
// // 如果存在剩余的ID
// log.warn("Redis中端口冲突了,使用 0-31 之间未占用的Id " + machineId + " IP:" + localIp);
// createMachineId();
// }
// } catch (Exception e) {
// // 获取 32 - 63 之间的随机Id
// // 返回机器Id
// log.error("Redis连接异常,不能正确注册雪花机器号 " + machineId + " IP:" + localIp, e);
// log.warn("使用临时方案,获取 32 - 63 之间的随机数作为机器号,请及时检查Redis连接");
// getRandomMachineId();
// return machineId;
// }
// return machineId;
// }
//
// /**
// * 检查是否被注册满了
// *
// * @return
// */
// private Boolean checkIfCanRegister() {
// // 判断0~31这个区间段的机器IP是否被占满
//
// Boolean flag = true;
// for (int i = 0; i < 32; i++) {
// flag = redisTemplate.hasKey(APP_NAME + dataCenterId + i);
// // 如果不存在。设置机器Id为这个不存在的数字
// if (!flag) {
// machineId = i;
// break;
// }
// }
// return !flag;
//
// }
//
// /**
// * 1.更新超時時間
// * 注意,更新前检查是否存在机器ip占用情况
// */
// private void updateExpTimeThread() {
// // 开启一个线程执行定时任务:
// // 每23小时更新一次超时时间
// new Timer(localIp).schedule(new TimerTask() {
// @Override
// public void run() {
// // 检查缓存中的ip与本机ip是否一致, 一致则更新时间,不一致则重新获取一个机器id
// Boolean b = checkIsLocalIp(String.valueOf(machineId));
// if (b) {
// log.info("IP一致,更新超时时间 ip:{},machineId:{}, time:{}", localIp, machineId, new Date());
// redisTemplate.expire(APP_NAME + dataCenterId + machineId, 60 * 60 * 24, TimeUnit.SECONDS);
// } else {
// // IP冲突
// log.info("重新生成机器ID ip:{},machineId:{}, time:{}", localIp, machineId, new Date());
// // 重新生成机器ID,并且更改雪花中的机器ID
// getRandomMachineId();
// // 重新生成并注册机器id
// createMachineId();
// // 更改雪花中的机器ID
// SnowFlake.setWorkerId(machineId);
// // 结束当前任务
// log.info("Timer->thread->name:{}", Thread.currentThread().getName());
// this.cancel();
// }
// }
// }, 10 * 1000, 1000 * 60 * 60 * 23);
// }
//
// /**
// * 获取32-63随机数
// */
// public void getRandomMachineId() {
// machineId = (int) (Math.random() * 31) + 31;
// }
//
//
// /**
// * 检查Redis中对应Key的Value是否是本机IP
// *
// * @param mechineId
// * @return
// */
// private Boolean checkIsLocalIp(String mechineId) {
// String ip = redisTemplate.opsForValue().get(APP_NAME + dataCenterId + mechineId);
// log.info("checkIsLocalIp->ip:{}", ip);
// return localIp.equals(ip);
// }
//
// /**
// * 1.注册机器
// * 2.设置超时时间
// *
// * @param machineId 取值为0~31
// * @return
// */
// private Boolean registerMachine(Integer machineId, String localIp) throws Exception {
// // try with resources 写法,出异常会释放括号内的资源 Java7特性
//
// // key 业务号 + 数据中心ID + 机器ID value 机器IP
// Long result = jedis.setnx(APP_NAME + dataCenterId + machineId, localIp);
// if (result == 1) {
// // 过期时间 1 天
// redisTemplate.expire(APP_NAME + dataCenterId + machineId, 60 * 60 * 24, TimeUnit.SECONDS);
// return true;
// } else {
// // 如果Key存在,判断Value和当前IP是否一致,一致则返回True
// String value = redisTemplate.opsForValue().get(APP_NAME + dataCenterId + machineId);
// if (localIp.equals(value)) {
// // IP一致,注册机器ID成功
// redisTemplate.expire(APP_NAME + dataCenterId + machineId, 60 * 60 * 24, TimeUnit.SECONDS);
// return true;
// }
// return false;
// }
//
// }
//}
src/main/java/com/bgy/config/SnowFlake.java
0 → 100644
View file @
a57bd496
//package com.bgy.config;
//
//import org.springframework.context.annotation.Configuration;
//
///**
// * 功能:分布式ID生成工具类
// *
// */
//@Configuration
//public class SnowFlake {
// /**
// * 开始时间截 (2019-09-08) 服务一旦运行过之后不能修改。会导致ID生成重复
// */
// private final long twepoch = 1567872000000L;
//
// /**
// * 机器Id所占的位数 0 - 64
// */
// private final long workerIdBits = 6L;
//
// /**
// * 工作组Id所占的位数 0 - 16
// */
// private final long dataCenterIdBits = 4L;
//
// /**
// * 支持的最大机器id,结果是63 (这个移位算法可以很快的计算出几位二进制数所能表示的最大十进制数)
// */
// private final long maxWorkerId = -1L ^ (-1L << workerIdBits);
//
// /**
// * 支持的最大数据标识id,结果是15
// */
// private final long maxDatacenterId = -1L ^ (-1L << dataCenterIdBits);
//
// /**
// * 序列在id中占的位数
// */
// private final long sequenceBits = 12L;
//
// /**
// * 机器ID向左移12位
// */
// private final long workerIdShift = sequenceBits;
//
// /**
// * 数据标识id向左移17位(12+5)
// */
// private final long datacenterIdShift = sequenceBits + workerIdBits;
//
// /**
// * 时间截向左移22位(5+5+12)
// */
// private final long timestampLeftShift = sequenceBits + workerIdBits + dataCenterIdBits;
//
// /**
// * 生成序列的掩码,这里为4095 (0b111111111111=0xfff=4095)
// */
// private final long sequenceMask = -1L ^ (-1L << sequenceBits);
//
// /**
// * 工作机器ID(0~63)
// */
// private static long workerId;
//
// /**
// * 数据中心ID(0~16)
// */
// private long datacenterId;
//
// /**
// * 毫秒内序列(0~4095)
// */
// private long sequence = 0L;
//
// /**
// * 上次生成ID的时间截
// */
// private long lastTimestamp = -1L;
//
// //==============================Constructors=====================================
//
// /**
// * 构造函数
// *
// * @param workerId 工作ID (0~63)
// * @param datacenterId 数据中心ID (0~15)
// */
// public SnowFlake(long workerId, long datacenterId) {
// if (workerId > maxWorkerId || workerId < 0) {
// throw new IllegalArgumentException(String.format("机器ID必须小于 %d 且大于 0", maxWorkerId));
// }
// if (datacenterId > maxDatacenterId || datacenterId < 0) {
// throw new IllegalArgumentException(String.format("工作组ID必须小于 %d 且大于 0", maxDatacenterId));
// }
// this.workerId = workerId;
// this.datacenterId = datacenterId;
// }
//
// /**
// * 构造函数
// *
// */
// public SnowFlake() {
// this.workerId = 0;
// this.datacenterId = 0;
// }
//
// /**
// * 获得下一个ID (该方法是线程安全的)
// *
// * @return SnowFlakeId
// */
// public synchronized long nextId() {
// long timestamp = timeGen();
//
// //如果当前时间小于上一次ID生成的时间戳,说明系统时钟回退过这个时候应当抛出异常
// if (timestamp < lastTimestamp) {
// throw new RuntimeException(
// String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp));
// }
//
// // 如果是同一时间生成的,则进行毫秒内序列
// if (lastTimestamp == timestamp) {
// sequence = (sequence + 1) & sequenceMask;
// // 毫秒内序列溢出
// if (sequence == 0) {
// // 阻塞到下一个毫秒,获得新的时间戳
// timestamp = tilNextMillis(lastTimestamp);
// }
// }
// //时间戳改变,毫秒内序列重置
// else {
// sequence = 0L;
// }
//
// // 上次生成ID的时间截
// lastTimestamp = timestamp;
//
// // 移位并通过或运算拼到一起组成64位的ID
// return ((timestamp - twepoch) << timestampLeftShift) //
// | (datacenterId << datacenterIdShift) //
// | (workerId << workerIdShift) //
// | sequence;
// }
//
// /**
// * 阻塞到下一个毫秒,直到获得新的时间戳
// *
// * @param lastTimestamp 上次生成ID的时间截
// * @return 当前时间戳
// */
// protected long tilNextMillis(long lastTimestamp) {
// long timestamp = timeGen();
// while (timestamp <= lastTimestamp) {
// timestamp = timeGen();
// }
// return timestamp;
// }
//
// /**
// * 返回以毫秒为单位的当前时间
// *
// * @return 当前时间(毫秒)
// */
// protected long timeGen() {
// return System.currentTimeMillis();
// }
//
// public long getWorkerId() {
// return workerId;
// }
//
// public static void setWorkerId(long workerId) {
// SnowFlake.workerId = workerId;
// }
//
// public long getDatacenterId() {
// return datacenterId;
// }
//
// public void setDatacenterId(long datacenterId) {
// this.datacenterId = datacenterId;
// }
//}
\ No newline at end of file
src/main/java/com/bgy/sms/channel/api/BgyApi.java
View file @
a57bd496
...
...
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import
com.bgy.sms.channel.bgy.dto.TemplateNotify
;
import
com.bgy.sms.channel.bgy.dto.ReportDto
;
import
com.bgy.sms.channel.bgy.service.BgySmsService
;
import
com.bgy.sms.channel.dto.BGYResponse
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -20,32 +21,17 @@ public class BgyApi {
private
BgySmsService
bgySmsService
;
@PostMapping
(
"/templateNotify"
)
public
String
notify
(
@RequestBody
TemplateNotify
templateNotify
)
{
public
BGYResponse
notify
(
@RequestBody
TemplateNotify
templateNotify
)
{
log
.
info
(
"碧桂园异步通知接口入参:{}"
,
JSONObject
.
toJSONString
(
templateNotify
));
String
response
=
"success"
;
BGYResponse
response
=
null
;
try
{
bgySmsService
.
asyncNotify
(
templateNotify
);
response
=
bgySmsService
.
asyncNotify
(
templateNotify
);
}
catch
(
Exception
e
)
{
log
.
error
(
"处理创建模板异步通知异常:"
,
e
);
response
=
"fail"
;
response
=
new
BGYResponse
(
500
,
"系统异常"
)
;
}
log
.
info
(
"碧桂园异步通知接口出参:{}"
,
response
);
log
.
info
(
"碧桂园异步通知接口出参:{}"
,
JSONObject
.
toJSONString
(
response
)
);
return
response
;
}
// @GetMapping("/report")
// public String report(ReportDto report) {
// log.info("回送报告接口入参:{}", JSONObject.toJSONString(report));
// String response = "success";
// try {
//// CLBizResponse responses = chuangLanSmsService.report(report);
// } catch (Exception e) {
// log.error("处理回执逻辑异常:", e);
// response = "fail";
// }
// log.info("碧桂园异步通知接口出参:{}", response);
// return response;
// }
//
}
src/main/java/com/bgy/sms/channel/api/DmHubApi.java
View file @
a57bd496
...
...
@@ -40,15 +40,16 @@ public class DmHubApi {
try
{
boolean
checkResult
=
this
.
checkSignature
(
timestamp
,
signature
);
if
(!
checkResult
)
{
return
new
DmHubResponse
(
"555"
,
"接口请求签名校验不通过"
);
response
=
new
DmHubResponse
(
"555"
,
"接口请求签名校验不通过"
);
log
.
info
(
"**********创建模板接口出参*******:{}"
,
JSONObject
.
toJSONString
(
response
));
return
response
;
}
response
=
messageService
.
createTemplate
(
params
);
messageService
.
createTemplate
(
params
);
}
catch
(
Exception
e
)
{
log
.
error
(
"创建模板短信异常"
,
e
);
response
=
new
DmHubResponse
(
"999"
,
"创建模板短信异常"
);
new
DmHubResponse
(
"999"
,
"创建模板短信异常"
);
}
log
.
info
(
"**********创建模板接口出参*******:{}"
,
JSONObject
.
toJSONString
(
response
));
return
response
;
return
null
;
}
/**
...
...
src/main/java/com/bgy/sms/channel/bgy/service/BgySmsService.java
View file @
a57bd496
...
...
@@ -3,6 +3,7 @@ package com.bgy.sms.channel.bgy.service;
import
com.alibaba.fastjson.JSONObject
;
import
com.bgy.sms.channel.bgy.dto.CLBizResponse
;
import
com.bgy.sms.channel.bgy.dto.TemplateNotify
;
import
com.bgy.sms.channel.dto.BGYResponse
;
import
java.util.List
;
...
...
@@ -15,5 +16,5 @@ public interface BgySmsService {
CLBizResponse
createTemplate
(
String
content
,
String
account
,
String
templateType
,
String
pkID
)
throws
Exception
;
void
asyncNotify
(
TemplateNotify
templateNotify
);
BGYResponse
asyncNotify
(
TemplateNotify
templateNotify
);
}
src/main/java/com/bgy/sms/channel/bgy/service/impl/BgySmsServiceImpl.java
View file @
a57bd496
...
...
@@ -9,9 +9,11 @@ import com.bgy.sms.channel.bgy.dto.TemplateNotify;
import
com.bgy.sms.channel.bgy.service.BgySmsService
;
import
com.bgy.sms.channel.bgy.utils.SendSmsUtil
;
import
com.bgy.sms.channel.dmHub.service.DmHubService
;
import
com.bgy.sms.channel.dto.BGYResponse
;
import
com.bgy.sms.config.ResponseCode
;
import
com.bgy.sms.repository.domain.SmsTemplateInfo
;
import
com.bgy.sms.service.SmsTemplateService
;
import
com.bgy.sms.service.XiaoShuService
;
import
com.bgy.util.HttpUtil
;
import
com.bgy.util.Md5Util
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -38,6 +40,9 @@ public class BgySmsServiceImpl implements BgySmsService {
private
static
final
String
retMsg
=
"msg"
;
// 响应描述
private
static
final
String
createTemplateData
=
"data"
;
// 创建模板响应数据
private
static
final
String
REJECTED
=
"rejected"
;
// 创建模板响应数据
private
static
final
String
APPROVED
=
"approved"
;
// 创建模板响应数据
private
static
final
String
notificationId
=
"49"
;
// 碧桂园通知类短信ID
private
static
final
String
marketingId
=
"52"
;
// 碧桂园营销类短信ID
...
...
@@ -49,6 +54,9 @@ public class BgySmsServiceImpl implements BgySmsService {
@Autowired
private
SmsTemplateService
smsTemplateService
;
@Autowired
private
XiaoShuService
xiaoShuService
;
@Override
public
CLBizResponse
sendSms
(
String
mobile
,
String
content
,
String
areaId
,
String
api
)
throws
Exception
{
log
.
info
(
"进入碧桂园短信发送接口"
);
...
...
@@ -62,7 +70,8 @@ public class BgySmsServiceImpl implements BgySmsService {
requestParams
.
put
(
"api"
,
api
);
requestParams
.
put
(
"appId"
,
appId
);
requestParams
.
put
(
"security"
,
Md5Util
.
encrypt
(
appId
+
securityCode
.
toUpperCase
()));
requestParams
.
put
(
"areaId"
,
areaId
);
requestParams
.
put
(
"areaId"
,
BgySMSConfig
.
areaId
);
requestParams
.
put
(
"subModule"
,
areaId
);
requestParams
.
put
(
"content"
,
content
);
requestParams
.
put
(
"mobile"
,
mobile
);
log
.
info
(
"碧桂园短信接口参数:{}"
,
requestParams
);
...
...
@@ -95,7 +104,8 @@ public class BgySmsServiceImpl implements BgySmsService {
requestParams
.
put
(
"api"
,
api
);
requestParams
.
put
(
"appId"
,
appId
);
requestParams
.
put
(
"security"
,
Md5Util
.
encrypt
(
appId
+
securityCode
.
toUpperCase
()));
requestParams
.
put
(
"areaId"
,
areaId
);
requestParams
.
put
(
"areaId"
,
BgySMSConfig
.
areaId
);
requestParams
.
put
(
"subModule"
,
areaId
);
requestParams
.
put
(
"templateId"
,
templateId
);
requestParams
.
put
(
"data"
,
data
);
log
.
info
(
"碧桂园短信接口参数:{}"
,
requestParams
);
...
...
@@ -123,9 +133,10 @@ public class BgySmsServiceImpl implements BgySmsService {
* 处理短信模板的通知
*
* @param templateNotify
* @return
*/
@Override
public
void
asyncNotify
(
TemplateNotify
templateNotify
)
{
public
BGYResponse
asyncNotify
(
TemplateNotify
templateNotify
)
{
log
.
info
(
"碧桂园短信模板审核通知接口入参:{}"
,
templateNotify
);
//模板流水号
String
templateRecordId
=
templateNotify
.
getData
();
...
...
@@ -133,18 +144,24 @@ public class BgySmsServiceImpl implements BgySmsService {
String
auditReason
=
templateNotify
.
getAuditReason
();
SmsTemplateInfo
smsTemplateInfo
=
smsTemplateService
.
selectOne
(
new
EntityWrapper
<
SmsTemplateInfo
>().
eq
(
"template_record_id"
,
templateRecordId
));
if
(
smsTemplateInfo
==
null
)
{
throw
new
RuntimeException
(
ResponseCode
.
NO_TEMPLATE
.
getMsg
()
);
return
new
BGYResponse
(
2
,
"未找到短信模板"
);
}
SmsTemplateInfo
updateInfo
=
new
SmsTemplateInfo
();
updateInfo
.
setId
(
smsTemplateInfo
.
getId
());
String
dmhubStatue
=
null
;
if
(
"1"
.
equals
(
status
))
{
smsTemplateInfo
.
setStatus
(
"normal"
);
smsTemplateInfo
.
setLastUpdated
(
new
Date
());
updateInfo
.
setStatus
(
"normal"
);
dmhubStatue
=
APPROVED
;
updateInfo
.
setLastUpdated
(
new
Date
());
}
else
{
smsTemplateInfo
.
setStatus
(
"abnormal"
);
dmhubStatue
=
REJECTED
;
updateInfo
.
setStatus
(
"abnormal"
);
}
smsTemplateInfo
.
setUpRejectMsg
(
auditReason
);
smsTemplateInfo
.
setLastUpdated
(
new
Date
());
smsTemplateService
.
updateById
(
smsTemplateInfo
);
updateInfo
.
setUpRejectMsg
(
auditReason
);
updateInfo
.
setLastUpdated
(
new
Date
());
smsTemplateService
.
updateById
(
updateInfo
);
xiaoShuService
.
updateDmhubSmsTempStatus
(
dmhubStatue
,
smsTemplateInfo
.
getDmTemplateId
());
return
new
BGYResponse
();
}
...
...
src/main/java/com/bgy/sms/channel/dto/BGYResponse.java
0 → 100644
View file @
a57bd496
package
com
.
bgy
.
sms
.
channel
.
dto
;
import
java.io.Serializable
;
public
class
BGYResponse
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
int
ret
;
private
String
err
;
public
BGYResponse
(
int
ret
,
String
err
)
{
this
.
ret
=
ret
;
this
.
err
=
err
;
}
public
BGYResponse
()
{
this
.
ret
=
0
;
this
.
err
=
"成功"
;
}
public
int
getRet
()
{
return
ret
;
}
public
void
setRet
(
int
ret
)
{
this
.
ret
=
ret
;
}
public
String
getErr
()
{
return
err
;
}
public
void
setErr
(
String
err
)
{
this
.
err
=
err
;
}
}
src/main/java/com/bgy/sms/repository/mapper/XiaoShuMapper.java
View file @
a57bd496
...
...
@@ -5,5 +5,5 @@ import org.apache.ibatis.annotations.Param;
public
interface
XiaoShuMapper
{
String
getLoginNameByTempId
(
@Param
(
"tempId"
)
String
templateId
);
void
update
SmsTemplateStatus
(
@Param
(
"tempId"
)
String
template
Id
);
void
update
DmhubTemp
(
@Param
(
"status"
)
String
status
,
@Param
(
"tempId"
)
String
temp
Id
);
}
src/main/java/com/bgy/sms/service/XiaoShuService.java
View file @
a57bd496
...
...
@@ -3,6 +3,5 @@ package com.bgy.sms.service;
public
interface
XiaoShuService
{
String
selectUserIdByTemplate
(
String
templateId
);
void
updateSmsTemplateStatus
(
String
templateId
);
void
updateDmhubSmsTempStatus
(
String
dmhubStatue
,
String
dmTemplateId
);
}
src/main/java/com/bgy/sms/service/impl/MessageServiceImpl.java
View file @
a57bd496
...
...
@@ -105,7 +105,6 @@ public class MessageServiceImpl implements MessageService {
if
(
StringUtils
.
isBlank
(
account
))
{
return
new
DmHubResponse
(
ResponseCode
.
NO_USER_ID
);
}
xiaoShuService
.
updateSmsTemplateStatus
(
templateId
);
response
=
bgySmsService
.
createTemplate
(
bgySendStr
,
account
,
TEMPLATETYPE
,
pkID
);
String
code
=
response
.
getCode
();
String
msg
=
response
.
getMsg
();
...
...
@@ -303,7 +302,7 @@ public class MessageServiceImpl implements MessageService {
sysRecordInfo
.
setStatus
(
ResponseCode
.
SUCCESS
.
getCode
());
sysRecordInfo
.
setStatusDesc
(
response
.
getMsg
());
sysRecordService
.
insert
(
sysRecordInfo
);
return
new
DmHubResponse
(
ResponseCode
.
SUCCESS
.
getCode
(),
ResponseCode
.
SUCCESS
.
getMsg
()
);
return
new
DmHubResponse
(
ResponseCode
.
SUCCESS
);
}
else
{
sysRecordInfo
.
setStatus
(
ResponseCode
.
UPSTREAM_FAIL
.
getCode
());
sysRecordInfo
.
setStatusDesc
(
response
.
getMsg
());
...
...
@@ -495,7 +494,8 @@ public class MessageServiceImpl implements MessageService {
return
new
DmHubResponse
(
"999"
,
"插件服务系统异常"
);
}
}
else
{
}
else
{
// 变量短信
Set
<
Map
.
Entry
<
String
,
List
<
String
>>>
entries
=
paramsMap
.
entrySet
();
List
<
JSONObject
>
list
=
new
ArrayList
<>();
...
...
@@ -521,7 +521,7 @@ public class MessageServiceImpl implements MessageService {
sysRecordInfo
.
setStatus
(
ResponseCode
.
SUCCESS
.
getCode
());
sysRecordInfo
.
setStatusDesc
(
response
.
getMsg
());
sysRecordService
.
insert
(
sysRecordInfo
);
return
new
DmHubResponse
(
ResponseCode
.
SUCCESS
.
getCode
(),
ResponseCode
.
SUCCESS
.
getMsg
()
);
return
new
DmHubResponse
(
ResponseCode
.
SUCCESS
);
}
else
{
sysRecordInfo
.
setChargeNum
(
list
.
size
());
sysRecordInfo
.
setMobile
(
mobiles
.
deleteCharAt
(
mobiles
.
length
()
-
1
).
toString
());
...
...
src/main/java/com/bgy/sms/service/impl/XiaoShuServiceImpl.java
View file @
a57bd496
...
...
@@ -21,9 +21,11 @@ public class XiaoShuServiceImpl implements XiaoShuService {
return
loginName
;
}
@Override
@DB
(
value
=
DataSourceType
.
DB2
)
public
void
update
SmsTemplateStatus
(
String
t
emplateId
)
{
xiaoShuMapper
.
update
SmsTemplateStatus
(
t
emplateId
);
public
void
update
DmhubSmsTempStatus
(
String
dmhubStatue
,
String
dmT
emplateId
)
{
xiaoShuMapper
.
update
DmhubTemp
(
dmhubStatue
,
dmT
emplateId
);
}
}
src/main/resources/application.yml
View file @
a57bd496
...
...
@@ -8,7 +8,7 @@ info:
spring
:
profiles
:
active
:
dev
active
:
test
mybatis-plus
:
mapper-locations
:
classpath:mapper/*.xml
...
...
src/main/resources/mapper/XiaoShuMapper.xml
View file @
a57bd496
...
...
@@ -7,8 +7,8 @@
where B.id = #{tempId}
</select>
<update
id=
"update
SmsTemplateStatus
"
parameterType=
"string"
>
update sms_template set status =
'applying'
where id = #{tempId}
<update
id=
"update
DmhubTemp
"
parameterType=
"string"
>
update sms_template set status =
#{status}
where id = #{tempId}
</update>
</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