|
@@ -3,13 +3,14 @@ package com.ruoyi.system.service.impl;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
-import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
-import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
+import com.aliyun.dysmsapi20170525.models.SendBatchSmsRequest;
|
|
|
+import com.aliyun.dysmsapi20170525.models.SendBatchSmsResponse;
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
+import com.ruoyi.common.utils.SendSmsUtils;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
import com.ruoyi.system.domain.InvestigateDispositionTable;
|
|
|
import com.ruoyi.system.domain.InvestigateUser;
|
|
|
-import com.ruoyi.system.domain.SysUserRole;
|
|
|
import com.ruoyi.system.mapper.InvestigateDispositionTableMapper;
|
|
|
import com.ruoyi.system.mapper.InvestigateUserMapper;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -69,15 +70,70 @@ public class InvestigateTableServiceImpl implements IInvestigateTableService {
|
|
|
List<InvestigateUser> investigateUserList = investigateTable.getInvestigateUserList();
|
|
|
investigateTable.setCipher(getCode(4));
|
|
|
int i = investigateTableMapper.insertInvestigateTable(investigateTable);
|
|
|
- if (investigateUserList != null) {
|
|
|
+ Long investigateTableId = investigateTable.getInvestigateTableId();
|
|
|
+ if (investigateUserList != null && investigateUserList.size() > 0) {
|
|
|
for (InvestigateUser investigateUser : investigateUserList) {
|
|
|
investigateUser.setInvestigateId(investigateTable.getInvestigateTableId());
|
|
|
}
|
|
|
investigateUserMapper.batchDispositionUser(investigateUserList);
|
|
|
+ //发送短信
|
|
|
+ sendBatchSmsTable(investigateTableId,investigateUserList);
|
|
|
}
|
|
|
return i;
|
|
|
}
|
|
|
|
|
|
+ public static void sendBatchSmsTable(Long investigateTableId, List<InvestigateUser> investigateUserList) {
|
|
|
+ for (InvestigateUser investigateUser : investigateUserList) {
|
|
|
+ StringBuffer phoneNumberJson = new StringBuffer();
|
|
|
+ StringBuffer templateParamJson = new StringBuffer();
|
|
|
+ StringBuffer signNameJson = new StringBuffer();
|
|
|
+ phoneNumberJson.append("[");
|
|
|
+ templateParamJson.append("[");
|
|
|
+ signNameJson.append("[");
|
|
|
+
|
|
|
+ // 防止有空行,手机号是必须要有的
|
|
|
+ String phone = investigateUser.getPhonenumber();
|
|
|
+ if (StringUtils.isEmpty(phone)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ phoneNumberJson.append("\"" + phone + "\",");
|
|
|
+ signNameJson.append("\"中新云\",");
|
|
|
+ //发送短信
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("number", investigateTableId);
|
|
|
+ templateParamJson.append(jsonObject).append(",");
|
|
|
+
|
|
|
+
|
|
|
+ phoneNumberJson.deleteCharAt(phoneNumberJson.length() - 1);//移除最后一个逗号字符,
|
|
|
+ templateParamJson.deleteCharAt(templateParamJson.length() - 1);//移除最后一个逗号字符
|
|
|
+ signNameJson.deleteCharAt(signNameJson.length() - 1);
|
|
|
+ phoneNumberJson.append("]");
|
|
|
+ templateParamJson.append("]");
|
|
|
+ signNameJson.append("]");
|
|
|
+
|
|
|
+ long startTimeSql = System.currentTimeMillis();
|
|
|
+ SendBatchSmsRequest sendBatchSmsRequest = new SendBatchSmsRequest();
|
|
|
+ //组装电话号码
|
|
|
+ sendBatchSmsRequest.setPhoneNumberJson(phoneNumberJson.toString());
|
|
|
+ //签名名称
|
|
|
+ sendBatchSmsRequest.setSignNameJson(signNameJson.toString());
|
|
|
+ //替换参数
|
|
|
+ sendBatchSmsRequest.setTemplateParamJson(templateParamJson.toString());
|
|
|
+ //固定的模板名称
|
|
|
+ sendBatchSmsRequest.setTemplateCode("SMS_463622836");
|
|
|
+ long startTimeSend = System.currentTimeMillis();
|
|
|
+ SendBatchSmsResponse sendBatchSmsResponse = SendSmsUtils.sendBatchSms(sendBatchSmsRequest);
|
|
|
+ long endTimeSend = System.currentTimeMillis() - startTimeSend;
|
|
|
+ System.out.println("执行批量下发短信接口请求:" + endTimeSend + "ms");
|
|
|
+ String code = sendBatchSmsResponse.getBody().getCode();
|
|
|
+ if (sendBatchSmsResponse.getBody().getCode() != null && "OK".equals(code)) {
|
|
|
+ System.out.println("批量短信发送成功");
|
|
|
+ } else {
|
|
|
+ System.out.println("批量短信发送失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//生成X位验证码
|
|
|
public static String getCode(Integer num) {
|
|
|
String[] codes = {"1", "2", "3", "4", "5", "6", "7", "8", "9"};
|