|
|
@@ -4,6 +4,8 @@ import cn.hutool.core.collection.CollectionUtil;
|
|
4
|
4
|
import cn.hutool.json.JSONObject;
|
|
5
|
5
|
import com.ruoyi.common.constant.Constants;
|
|
6
|
6
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
7
|
+import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
8
|
+import com.ruoyi.common.core.domain.model.LoginBody;
|
|
7
|
9
|
import com.ruoyi.common.enums.SMSStatusEnum;
|
|
8
|
10
|
import com.ruoyi.system.domain.entity.shortmessage.MeetingInfo;
|
|
9
|
11
|
import com.ruoyi.system.domain.entity.shortmessage.MsSmsSendHistoryRecord;
|
|
|
@@ -11,6 +13,7 @@ import com.ruoyi.system.domain.entity.sms.MsSmsSendHistoryRecordParam;
|
|
11
|
13
|
import com.ruoyi.system.domain.entity.sms.MsSmsSendRecordParam;
|
|
12
|
14
|
import com.ruoyi.system.domain.entity.sms.MsSmsTemplate;
|
|
13
|
15
|
import com.ruoyi.system.domain.entity.sms.MsSmsTemplateParam;
|
|
|
16
|
+import com.ruoyi.system.mapper.SysUserMapper;
|
|
14
|
17
|
import com.ruoyi.system.mapper.shortmessage.MeetingInfoMapper;
|
|
15
|
18
|
import com.ruoyi.system.mapper.shortmessage.MsSmsSendHistoryRecordMapper;
|
|
16
|
19
|
import com.ruoyi.system.mapper.sms.MsSmsSendHistoryRecordParamMapper;
|
|
|
@@ -56,11 +59,11 @@ public class ShortMessageServiceImpl implements ShortMessageService {
|
|
56
|
59
|
@Override
|
|
57
|
60
|
public List<SmsSendRecord> smsSendRecordList(SmsSendRecord smsSendRecord) {
|
|
58
|
61
|
List<SmsSendRecord> records = smsRecordMapper.getSmsSendRecord(smsSendRecord);
|
|
59
|
|
- if(CollectionUtil.isEmpty(records)){
|
|
|
62
|
+ if (CollectionUtil.isEmpty(records)) {
|
|
60
|
63
|
return null;
|
|
61
|
64
|
}
|
|
62
|
65
|
List<Long> templateIds = records.stream().map(SmsSendRecord::getMsSmsTemplateId).collect(Collectors.toList());
|
|
63
|
|
- if(CollectionUtil.isEmpty(templateIds)){
|
|
|
66
|
+ if (CollectionUtil.isEmpty(templateIds)) {
|
|
64
|
67
|
return records;
|
|
65
|
68
|
}
|
|
66
|
69
|
List<Long> ids = records.stream().map(SmsSendRecord::getId).collect(Collectors.toList());
|
|
|
@@ -68,14 +71,14 @@ public class ShortMessageServiceImpl implements ShortMessageService {
|
|
68
|
71
|
Example recordParamExam = new Example(MsSmsSendRecordParam.class);
|
|
69
|
72
|
recordParamExam.createCriteria().andIn("smsRecordId", ids);
|
|
70
|
73
|
List<MsSmsSendRecordParam> recordParams = recordParamMapper.selectByExample(recordParamExam);
|
|
71
|
|
- if(CollectionUtil.isEmpty(recordParams)){
|
|
|
74
|
+ if (CollectionUtil.isEmpty(recordParams)) {
|
|
72
|
75
|
return records;
|
|
73
|
76
|
}
|
|
74
|
77
|
// 根据模板id查询模板参数
|
|
75
|
78
|
Example templateParamExam = new Example(MsSmsTemplateParam.class);
|
|
76
|
79
|
templateParamExam.createCriteria().andIn("smsTemplateId", templateIds);
|
|
77
|
80
|
List<MsSmsTemplateParam> templateParams = templateParamMapper.selectByExample(templateParamExam);
|
|
78
|
|
- if(CollectionUtil.isEmpty(templateParams)){
|
|
|
81
|
+ if (CollectionUtil.isEmpty(templateParams)) {
|
|
79
|
82
|
return records;
|
|
80
|
83
|
}
|
|
81
|
84
|
// 根据模板id对模板参数分组
|
|
|
@@ -85,17 +88,17 @@ public class ShortMessageServiceImpl implements ShortMessageService {
|
|
85
|
88
|
Map<Long, List<String>> recordParamContentMap = new HashMap<>();
|
|
86
|
89
|
for (MsSmsSendRecordParam recordParam : recordParams) {
|
|
87
|
90
|
List<String> list = recordParamContentMap.get(recordParam.getSmsRecordId());
|
|
88
|
|
- if(CollectionUtil.isEmpty(list)){
|
|
89
|
|
- list=new ArrayList<>();
|
|
|
91
|
+ if (CollectionUtil.isEmpty(list)) {
|
|
|
92
|
+ list = new ArrayList<>();
|
|
90
|
93
|
}
|
|
91
|
94
|
list.add(recordParam.getParamValue());
|
|
92
|
|
- recordParamContentMap.put(recordParam.getSmsRecordId(),list);
|
|
|
95
|
+ recordParamContentMap.put(recordParam.getSmsRecordId(), list);
|
|
93
|
96
|
}
|
|
94
|
97
|
// 根据模板id查询模板
|
|
95
|
98
|
Example templateExam = new Example(MsSmsTemplate.class);
|
|
96
|
99
|
templateExam.createCriteria().andIn("id", templateIds);
|
|
97
|
100
|
List<MsSmsTemplate> templates = templateMapper.selectByExample(templateExam);
|
|
98
|
|
- if(CollectionUtil.isEmpty(templates)){
|
|
|
101
|
+ if (CollectionUtil.isEmpty(templates)) {
|
|
99
|
102
|
return records;
|
|
100
|
103
|
}
|
|
101
|
104
|
// 根据主键id获取模板内容
|
|
|
@@ -103,28 +106,28 @@ public class ShortMessageServiceImpl implements ShortMessageService {
|
|
103
|
106
|
Map<Long, String> templateIdMap = templates.stream().collect(Collectors.toMap(MsSmsTemplate::getId, MsSmsTemplate::getTemplateId, (k1, k2) -> k2));
|
|
104
|
107
|
// 组装模板内容
|
|
105
|
108
|
for (SmsSendRecord record : records) {
|
|
106
|
|
- if(record.getMsSmsTemplateId()==null){
|
|
|
109
|
+ if (record.getMsSmsTemplateId() == null) {
|
|
107
|
110
|
continue;
|
|
108
|
111
|
}
|
|
109
|
|
- if(!templateMap.containsKey(record.getMsSmsTemplateId())){
|
|
|
112
|
+ if (!templateMap.containsKey(record.getMsSmsTemplateId())) {
|
|
110
|
113
|
continue;
|
|
111
|
114
|
}
|
|
112
|
115
|
|
|
113
|
|
- if(!recordParamContentMap.containsKey(record.getId())){
|
|
|
116
|
+ if (!recordParamContentMap.containsKey(record.getId())) {
|
|
114
|
117
|
continue;
|
|
115
|
118
|
}
|
|
116
|
|
- if(templateIdMap.containsKey(record.getMsSmsTemplateId())){
|
|
117
|
|
- record.setTemplateId(templateIdMap.get(record.getMsSmsTemplateId()));
|
|
|
119
|
+ if (templateIdMap.containsKey(record.getMsSmsTemplateId())) {
|
|
|
120
|
+ record.setTemplateId(templateIdMap.get(record.getMsSmsTemplateId()));
|
|
118
|
121
|
}
|
|
119
|
122
|
String templateContent = templateMap.get(record.getMsSmsTemplateId());
|
|
120
|
123
|
record.setTemplateContent(templateContent);
|
|
121
|
124
|
List<String> recordParamList = recordParamContentMap.get(record.getId());
|
|
122
|
|
- if(recordParamContentMap.containsKey(record.getId()) && templateParamMap.containsKey(record.getMsSmsTemplateId())){
|
|
|
125
|
+ if (recordParamContentMap.containsKey(record.getId()) && templateParamMap.containsKey(record.getMsSmsTemplateId())) {
|
|
123
|
126
|
List<MsSmsTemplateParam> templateParamList = templateParamMap.get(record.getMsSmsTemplateId());
|
|
124
|
127
|
ArrayList<MsSmsTemplateParam> copyParamList = new ArrayList<>();
|
|
125
|
128
|
for (int i = 0; i < templateParamList.size(); i++) {
|
|
126
|
129
|
MsSmsTemplateParam templateParam = templateParamList.get(i);
|
|
127
|
|
- MsSmsTemplateParam msSmsTemplateParam =new MsSmsTemplateParam();
|
|
|
130
|
+ MsSmsTemplateParam msSmsTemplateParam = new MsSmsTemplateParam();
|
|
128
|
131
|
msSmsTemplateParam.setParam(templateParam.getParam());
|
|
129
|
132
|
msSmsTemplateParam.setSmsTemplateId(templateParam.getSmsTemplateId());
|
|
130
|
133
|
msSmsTemplateParam.setParamName(templateParam.getParamName());
|
|
|
@@ -136,8 +139,8 @@ public class ShortMessageServiceImpl implements ShortMessageService {
|
|
136
|
139
|
|
|
137
|
140
|
}
|
|
138
|
141
|
// 按顺序替换占位符
|
|
139
|
|
- if(CollectionUtil.isNotEmpty(recordParamList)){
|
|
140
|
|
- recordParamList.add(0,"0");
|
|
|
142
|
+ if (CollectionUtil.isNotEmpty(recordParamList)) {
|
|
|
143
|
+ recordParamList.add(0, "0");
|
|
141
|
144
|
|
|
142
|
145
|
// 将List<String>转换为String[]数组
|
|
143
|
146
|
String[] paramArray = recordParamList.toArray(new String[recordParamList.size()]);
|
|
|
@@ -150,6 +153,7 @@ public class ShortMessageServiceImpl implements ShortMessageService {
|
|
150
|
153
|
|
|
151
|
154
|
return records;
|
|
152
|
155
|
}
|
|
|
156
|
+
|
|
153
|
157
|
/**
|
|
154
|
158
|
* 新增发送历史记录
|
|
155
|
159
|
*
|
|
|
@@ -157,19 +161,19 @@ public class ShortMessageServiceImpl implements ShortMessageService {
|
|
157
|
161
|
*/
|
|
158
|
162
|
@Transactional
|
|
159
|
163
|
@Override
|
|
160
|
|
- public void insertShortMessageHistoryRecord(SmsSendRecord smsSendRecord,List<MsSmsSendRecordParam> recordParams) {
|
|
161
|
|
- if(smsSendRecord!=null){
|
|
162
|
|
- MsSmsSendHistoryRecord historyRecord=new MsSmsSendHistoryRecord();
|
|
163
|
|
- BeanUtils.copyProperties(smsSendRecord,historyRecord);
|
|
|
164
|
+ public void insertShortMessageHistoryRecord(SmsSendRecord smsSendRecord, List<MsSmsSendRecordParam> recordParams) {
|
|
|
165
|
+ if (smsSendRecord != null) {
|
|
|
166
|
+ MsSmsSendHistoryRecord historyRecord = new MsSmsSendHistoryRecord();
|
|
|
167
|
+ BeanUtils.copyProperties(smsSendRecord, historyRecord);
|
|
164
|
168
|
historyRecord.setId(null);
|
|
165
|
169
|
historyRecord.setParentId(smsSendRecord.getId());
|
|
166
|
170
|
int i = msSmsSendHistoryRecordMapper.insert(historyRecord);
|
|
167
|
|
- if(i>0 && CollectionUtil.isNotEmpty(recordParams)){
|
|
|
171
|
+ if (i > 0 && CollectionUtil.isNotEmpty(recordParams)) {
|
|
168
|
172
|
// 新增参数表
|
|
169
|
173
|
List<MsSmsSendHistoryRecordParam> historyRecordParams = new ArrayList<>();
|
|
170
|
174
|
for (MsSmsSendRecordParam templateParam : recordParams) {
|
|
171
|
175
|
MsSmsSendHistoryRecordParam recordParam = new MsSmsSendHistoryRecordParam();
|
|
172
|
|
- BeanUtils.copyProperties(templateParam,recordParam);
|
|
|
176
|
+ BeanUtils.copyProperties(templateParam, recordParam);
|
|
173
|
177
|
recordParam.setId(null);
|
|
174
|
178
|
recordParam.setSmsRecordHistoryId(historyRecord.getId());
|
|
175
|
179
|
historyRecordParams.add(recordParam);
|
|
|
@@ -189,7 +193,7 @@ public class ShortMessageServiceImpl implements ShortMessageService {
|
|
189
|
193
|
if (reSendMessageVO != null && reSendMessageVO.getTemplateId() != null && reSendMessageVO.getPhone() != null && reSendMessageVO.getTemplateParams() != null && reSendMessageVO.getTemplateParams().size() > 0 && reSendMessageVO.getId() != null) {
|
|
190
|
194
|
// 根据id查询短信记录
|
|
191
|
195
|
SmsSendRecord smsSendRecord = smsRecordMapper.selectById(reSendMessageVO.getId());
|
|
192
|
|
- if(smsSendRecord == null){
|
|
|
196
|
+ if (smsSendRecord == null) {
|
|
193
|
197
|
return AjaxResult.warn("短信记录不存在");
|
|
194
|
198
|
}
|
|
195
|
199
|
|
|
|
@@ -204,16 +208,16 @@ public class ShortMessageServiceImpl implements ShortMessageService {
|
|
204
|
208
|
// 修改sid和状态
|
|
205
|
209
|
if (resultObj.get("status") != null && !resultObj.get("status").equals(SMSStatusEnum.FAIL.getCode())) {
|
|
206
|
210
|
smsSendRecord.setSendStatus(SMSStatusEnum.SENDING.getCode());
|
|
207
|
|
- smsSendRecord.setSid(resultObj.get("sid")==null?null:resultObj.get("sid").toString());
|
|
|
211
|
+ smsSendRecord.setSid(resultObj.get("sid") == null ? null : resultObj.get("sid").toString());
|
|
208
|
212
|
smsSendRecord.setReason(null);
|
|
209
|
213
|
// 修改
|
|
210
|
214
|
smsRecordMapper.update(smsSendRecord);
|
|
211
|
215
|
|
|
212
|
216
|
return AjaxResult.success("重新发送成功");
|
|
213
|
217
|
} else {
|
|
214
|
|
- smsSendRecord.setSid(resultObj.get("sid")==null?null:resultObj.get("sid").toString());
|
|
|
218
|
+ smsSendRecord.setSid(resultObj.get("sid") == null ? null : resultObj.get("sid").toString());
|
|
215
|
219
|
smsSendRecord.setSendStatus(SMSStatusEnum.FAIL.getCode());
|
|
216
|
|
- smsSendRecord.setSid(resultObj.get("reason")==null?null:resultObj.get("reason").toString());
|
|
|
220
|
+ smsSendRecord.setSid(resultObj.get("reason") == null ? null : resultObj.get("reason").toString());
|
|
217
|
221
|
// 修改
|
|
218
|
222
|
smsRecordMapper.update(smsSendRecord);
|
|
219
|
223
|
return AjaxResult.warn("重新发送失败");
|