43e5381e 张雷

短信增加异常处理,会议通知BUG修改

1 个父辈 0e765740
......@@ -9,6 +9,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
......@@ -22,13 +23,26 @@ import java.util.Map;
@Slf4j
@Service
public class AliSmsUtil {
static String url = "http://47.104.23.94:8088/";
static String URL = "http://47.104.23.94:8088/sms/send";
static String signName = "金控数矿";
// 项目id(每个项目独立使用)
static String projectId = "556a0a9d-5a78-400e-bf10-24fa14a1a925";
// 项目accessKey(每个项目独立使用)
static String accessKey = "9a1832e31135dc5bd72590580dc89943b68554dd8d26af0021af84aae7259773";
static RestTemplate restTemplate = new RestTemplate();
// 设置连接超时和读取超时
static int connectionTimeout = 5000;
static int readTimeout = 5000;
// 使用 RestTemplate 发送请求
static RestTemplate restTemplate = createRestTemplate();
// 创建带有超时设置的 RestTemplate
private static RestTemplate createRestTemplate() {
// 设置连接超时和读取超时
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
factory.setConnectTimeout(connectionTimeout); // 设置连接超时
factory.setReadTimeout(readTimeout); // 设置读取超时
return new RestTemplate(factory);
}
/**
*
......@@ -49,7 +63,7 @@ public class AliSmsUtil {
requestBody.put("sign_name", signName);
requestBody.put("project_id", projectId);
requestBody.put("access_key", accessKey);
requestEntity = RequestEntity.post(new URI(url + "sms/send"))
requestEntity = RequestEntity.post(new URI(URL))
.header("content-type","application/json")
.body(requestBody, Map.class);
responseEntity = restTemplate.exchange(requestEntity, Map.class);
......@@ -63,7 +77,7 @@ public class AliSmsUtil {
ok = false;
log.error(String.format("阿里短信发送失败 请求=%s 响应=%s",
requestEntity == null ? "" : requestEntity.toString() ,
responseEntity == null ? "" : responseEntity.toString()), e);
responseEntity == null ? "" : responseEntity.toString()));
}
return ok;
}
......@@ -150,5 +164,6 @@ public class AliSmsUtil {
aliCode.setProduct("数字化企业大脑");
aliCode.setType("login");
sendCodeMsg(aliCode);
System.out.println("==================短信发送完成====================");
}
}
......
......@@ -133,9 +133,11 @@ public class AjhMeetingSendController {
newList.add(ajhMeetingSend);
}
}
if(newList.size() > 0){
ajhMeetingSendService.updateBatchById(newList);
}
}
}
@AutoLog(value = "会议记录-数量统计")
@ApiOperation(value="会议记录-数量统计", notes="会议记录-数量统计")
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!