短信增加异常处理,会议通知BUG修改
正在显示
2 个修改的文件
包含
21 行增加
和
4 行删除
... | @@ -9,6 +9,7 @@ import lombok.extern.slf4j.Slf4j; | ... | @@ -9,6 +9,7 @@ import lombok.extern.slf4j.Slf4j; |
9 | import org.apache.commons.lang.StringUtils; | 9 | import org.apache.commons.lang.StringUtils; |
10 | import org.springframework.http.RequestEntity; | 10 | import org.springframework.http.RequestEntity; |
11 | import org.springframework.http.ResponseEntity; | 11 | import org.springframework.http.ResponseEntity; |
12 | import org.springframework.http.client.SimpleClientHttpRequestFactory; | ||
12 | import org.springframework.stereotype.Service; | 13 | import org.springframework.stereotype.Service; |
13 | import org.springframework.web.client.RestTemplate; | 14 | import org.springframework.web.client.RestTemplate; |
14 | 15 | ||
... | @@ -22,13 +23,26 @@ import java.util.Map; | ... | @@ -22,13 +23,26 @@ import java.util.Map; |
22 | @Slf4j | 23 | @Slf4j |
23 | @Service | 24 | @Service |
24 | public class AliSmsUtil { | 25 | public class AliSmsUtil { |
25 | static String url = "http://47.104.23.94:8088/"; | 26 | static String URL = "http://47.104.23.94:8088/sms/send"; |
26 | static String signName = "金控数矿"; | 27 | static String signName = "金控数矿"; |
27 | // 项目id(每个项目独立使用) | 28 | // 项目id(每个项目独立使用) |
28 | static String projectId = "556a0a9d-5a78-400e-bf10-24fa14a1a925"; | 29 | static String projectId = "556a0a9d-5a78-400e-bf10-24fa14a1a925"; |
29 | // 项目accessKey(每个项目独立使用) | 30 | // 项目accessKey(每个项目独立使用) |
30 | static String accessKey = "9a1832e31135dc5bd72590580dc89943b68554dd8d26af0021af84aae7259773"; | 31 | static String accessKey = "9a1832e31135dc5bd72590580dc89943b68554dd8d26af0021af84aae7259773"; |
31 | static RestTemplate restTemplate = new RestTemplate(); | 32 | // 设置连接超时和读取超时 |
33 | static int connectionTimeout = 5000; | ||
34 | static int readTimeout = 5000; | ||
35 | // 使用 RestTemplate 发送请求 | ||
36 | static RestTemplate restTemplate = createRestTemplate(); | ||
37 | |||
38 | // 创建带有超时设置的 RestTemplate | ||
39 | private static RestTemplate createRestTemplate() { | ||
40 | // 设置连接超时和读取超时 | ||
41 | SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory(); | ||
42 | factory.setConnectTimeout(connectionTimeout); // 设置连接超时 | ||
43 | factory.setReadTimeout(readTimeout); // 设置读取超时 | ||
44 | return new RestTemplate(factory); | ||
45 | } | ||
32 | 46 | ||
33 | /** | 47 | /** |
34 | * | 48 | * |
... | @@ -49,7 +63,7 @@ public class AliSmsUtil { | ... | @@ -49,7 +63,7 @@ public class AliSmsUtil { |
49 | requestBody.put("sign_name", signName); | 63 | requestBody.put("sign_name", signName); |
50 | requestBody.put("project_id", projectId); | 64 | requestBody.put("project_id", projectId); |
51 | requestBody.put("access_key", accessKey); | 65 | requestBody.put("access_key", accessKey); |
52 | requestEntity = RequestEntity.post(new URI(url + "sms/send")) | 66 | requestEntity = RequestEntity.post(new URI(URL)) |
53 | .header("content-type","application/json") | 67 | .header("content-type","application/json") |
54 | .body(requestBody, Map.class); | 68 | .body(requestBody, Map.class); |
55 | responseEntity = restTemplate.exchange(requestEntity, Map.class); | 69 | responseEntity = restTemplate.exchange(requestEntity, Map.class); |
... | @@ -63,7 +77,7 @@ public class AliSmsUtil { | ... | @@ -63,7 +77,7 @@ public class AliSmsUtil { |
63 | ok = false; | 77 | ok = false; |
64 | log.error(String.format("阿里短信发送失败 请求=%s 响应=%s", | 78 | log.error(String.format("阿里短信发送失败 请求=%s 响应=%s", |
65 | requestEntity == null ? "" : requestEntity.toString() , | 79 | requestEntity == null ? "" : requestEntity.toString() , |
66 | responseEntity == null ? "" : responseEntity.toString()), e); | 80 | responseEntity == null ? "" : responseEntity.toString())); |
67 | } | 81 | } |
68 | return ok; | 82 | return ok; |
69 | } | 83 | } |
... | @@ -150,5 +164,6 @@ public class AliSmsUtil { | ... | @@ -150,5 +164,6 @@ public class AliSmsUtil { |
150 | aliCode.setProduct("数字化企业大脑"); | 164 | aliCode.setProduct("数字化企业大脑"); |
151 | aliCode.setType("login"); | 165 | aliCode.setType("login"); |
152 | sendCodeMsg(aliCode); | 166 | sendCodeMsg(aliCode); |
167 | System.out.println("==================短信发送完成===================="); | ||
153 | } | 168 | } |
154 | } | 169 | } | ... | ... |
... | @@ -133,9 +133,11 @@ public class AjhMeetingSendController { | ... | @@ -133,9 +133,11 @@ public class AjhMeetingSendController { |
133 | newList.add(ajhMeetingSend); | 133 | newList.add(ajhMeetingSend); |
134 | } | 134 | } |
135 | } | 135 | } |
136 | if(newList.size() > 0){ | ||
136 | ajhMeetingSendService.updateBatchById(newList); | 137 | ajhMeetingSendService.updateBatchById(newList); |
137 | } | 138 | } |
138 | } | 139 | } |
140 | } | ||
139 | 141 | ||
140 | @AutoLog(value = "会议记录-数量统计") | 142 | @AutoLog(value = "会议记录-数量统计") |
141 | @ApiOperation(value="会议记录-数量统计", notes="会议记录-数量统计") | 143 | @ApiOperation(value="会议记录-数量统计", notes="会议记录-数量统计") | ... | ... |
-
请 注册 或 登录 后发表评论