|
|
1
|
+package com.iot.scheduler.service;
|
|
|
2
|
+
|
|
|
3
|
+import com.alibaba.fastjson.JSON;
|
|
|
4
|
+import com.iot.scheduler.model.XkdDeviceData;
|
|
|
5
|
+import com.iot.scheduler.model.XkdDeviceInfo;
|
|
|
6
|
+import com.zaxxer.hikari.HikariConfig;
|
|
|
7
|
+import com.zaxxer.hikari.HikariDataSource;
|
|
|
8
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
9
|
+import org.apache.http.Consts;
|
|
|
10
|
+import org.apache.http.HttpEntity;
|
|
|
11
|
+import org.apache.http.client.methods.CloseableHttpResponse;
|
|
|
12
|
+import org.apache.http.client.methods.HttpPost;
|
|
|
13
|
+import org.apache.http.entity.ContentType;
|
|
|
14
|
+import org.apache.http.entity.StringEntity;
|
|
|
15
|
+import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
16
|
+import org.apache.http.impl.client.HttpClients;
|
|
|
17
|
+import org.apache.poi.ss.usermodel.Row;
|
|
|
18
|
+import org.apache.poi.ss.usermodel.Sheet;
|
|
|
19
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
|
20
|
+import org.apache.poi.ss.usermodel.WorkbookFactory;
|
|
|
21
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
22
|
+import org.springframework.stereotype.Service;
|
|
|
23
|
+
|
|
|
24
|
+import java.io.*;
|
|
|
25
|
+import java.sql.*;
|
|
|
26
|
+import java.text.SimpleDateFormat;
|
|
|
27
|
+import java.time.ZonedDateTime;
|
|
|
28
|
+import java.time.format.DateTimeFormatter;
|
|
|
29
|
+import java.util.*;
|
|
|
30
|
+import java.util.Date;
|
|
|
31
|
+
|
|
|
32
|
+/**
|
|
|
33
|
+ * 新康达设备属性上报
|
|
|
34
|
+ */
|
|
|
35
|
+@Service
|
|
|
36
|
+@Slf4j
|
|
|
37
|
+public class XinkangdaDeviceReportService {
|
|
|
38
|
+
|
|
|
39
|
+ @Value("${xkd.third.devicesRegisterUrl:http://117.64.210.63:8087/api/v1/devices/register}")
|
|
|
40
|
+ private String devicesRegisterUrl;
|
|
|
41
|
+
|
|
|
42
|
+ @Value("${xkd.third.dataUploadUrl:http://117.64.210.63:8087/api/v1/data/upload}")
|
|
|
43
|
+ private String dataUploadUrl;
|
|
|
44
|
+
|
|
|
45
|
+ @Value("${xkd.third.enterpriseId:PLMOKNJIB8}")
|
|
|
46
|
+ private String enterpriseId;
|
|
|
47
|
+
|
|
|
48
|
+ @Value("${xkd.third.apiKey:UiOpAsDfGhJkLzXcVbNmQwEr6TyUiOpAsD}")
|
|
|
49
|
+ private String apiKey;
|
|
|
50
|
+
|
|
|
51
|
+ @Value("${xkd.third.jdbcUrl:jdbc:postgresql://192.168.0.61:5433/thingskit}")
|
|
|
52
|
+ private String jdbcUrl;
|
|
|
53
|
+
|
|
|
54
|
+ @Value("${xkd.third.jdbcUserName:postgres}")
|
|
|
55
|
+ private String jdbcUserName;
|
|
|
56
|
+
|
|
|
57
|
+ @Value("${xkd.third.jdbcPassword:postgres}")
|
|
|
58
|
+ private String jdbcPassword;
|
|
|
59
|
+
|
|
|
60
|
+ @Value("${xkd.third.selectSql:SELECT * FROM ts_kv_dictionary;}")
|
|
|
61
|
+ private String selectSql;
|
|
|
62
|
+
|
|
|
63
|
+
|
|
|
64
|
+ /**
|
|
|
65
|
+ * 批量企业设备上报
|
|
|
66
|
+ */
|
|
|
67
|
+ public void batchDeviceReport() {
|
|
|
68
|
+ List<Object> needSyncDataList = initConnectAndSelectData();
|
|
|
69
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmssSSS");
|
|
|
70
|
+ String dataBatch = simpleDateFormat.format(new Date());
|
|
|
71
|
+
|
|
|
72
|
+ ZonedDateTime now = ZonedDateTime.now();
|
|
|
73
|
+ String iso8601 = now.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME);
|
|
|
74
|
+ for (int i = 0; i < needSyncDataList.size(); i++) {
|
|
|
75
|
+ Object needSyncData = needSyncDataList.get(i);
|
|
|
76
|
+ try {
|
|
|
77
|
+ List<Object> dataList = (ArrayList) needSyncData;
|
|
|
78
|
+ String deviceId = dataList.get(0).toString();
|
|
|
79
|
+
|
|
|
80
|
+ log.info("开始处理设备[{}]的数据,进度: {}/{}", deviceId, i + 1, needSyncDataList.size());
|
|
|
81
|
+
|
|
|
82
|
+ XkdDeviceData data = new XkdDeviceData();
|
|
|
83
|
+ data.setDeviceId(deviceId);
|
|
|
84
|
+ String status = dataList.get(2).toString();
|
|
|
85
|
+ data.setStatus(status);
|
|
|
86
|
+ data.setDataBatch(dataBatch);
|
|
|
87
|
+ data.setCollectionTime(iso8601);
|
|
|
88
|
+ data.setAlarm(false);
|
|
|
89
|
+ data.setAlarmName("无");
|
|
|
90
|
+ data.setEfficiency(86.7D);
|
|
|
91
|
+
|
|
|
92
|
+ boolean sendResult = sendDataUpload(data);
|
|
|
93
|
+ } catch (Exception e) {
|
|
|
94
|
+
|
|
|
95
|
+ }
|
|
|
96
|
+ }
|
|
|
97
|
+ }
|
|
|
98
|
+
|
|
|
99
|
+ private List<Object> initConnectAndSelectData() {
|
|
|
100
|
+ Connection connection = null;
|
|
|
101
|
+ PreparedStatement statement = null;
|
|
|
102
|
+ ResultSet resultSet = null;
|
|
|
103
|
+ HikariDataSource dataSource = null;
|
|
|
104
|
+ List<Object> resultList = new ArrayList<>();
|
|
|
105
|
+
|
|
|
106
|
+ log.info("开始连接数据库,URL: {}", jdbcUrl);
|
|
|
107
|
+
|
|
|
108
|
+ try {
|
|
|
109
|
+ HikariConfig config = new HikariConfig();
|
|
|
110
|
+ config.setJdbcUrl(jdbcUrl);
|
|
|
111
|
+ config.setUsername(jdbcUserName);
|
|
|
112
|
+ config.setPassword(jdbcPassword);
|
|
|
113
|
+ config.setDriverClassName("org.postgresql.Driver");
|
|
|
114
|
+ config.setMaximumPoolSize(5);
|
|
|
115
|
+ config.setMinimumIdle(5);
|
|
|
116
|
+ config.setConnectionTimeout(60000);
|
|
|
117
|
+ config.setConnectionTestQuery("SELECT 1");
|
|
|
118
|
+
|
|
|
119
|
+ dataSource = new HikariDataSource(config);
|
|
|
120
|
+ log.info("Hikari连接池配置完成");
|
|
|
121
|
+
|
|
|
122
|
+ connection = dataSource.getConnection();
|
|
|
123
|
+ log.info("数据库连接成功");
|
|
|
124
|
+
|
|
|
125
|
+ statement = connection.prepareStatement(selectSql);
|
|
|
126
|
+ log.info("执行SQL查询: {}", selectSql);
|
|
|
127
|
+
|
|
|
128
|
+ resultSet = statement.executeQuery();
|
|
|
129
|
+ ResultSetMetaData metaData = resultSet.getMetaData();
|
|
|
130
|
+ int columnCount = metaData.getColumnCount();
|
|
|
131
|
+ log.info("查询结果集元数据获取成功,共{}列", columnCount);
|
|
|
132
|
+
|
|
|
133
|
+ int rowCount = 0;
|
|
|
134
|
+ while (resultSet.next()) {
|
|
|
135
|
+ List<Object> result = new ArrayList<>(columnCount);
|
|
|
136
|
+ for (int index = 1; index <= columnCount; index++) {
|
|
|
137
|
+ int columnType = metaData.getColumnType(index);
|
|
|
138
|
+ Object value = getTypedValue(resultSet, index, columnType);
|
|
|
139
|
+ result.add(value);
|
|
|
140
|
+ }
|
|
|
141
|
+ resultList.add(result);
|
|
|
142
|
+ rowCount++;
|
|
|
143
|
+
|
|
|
144
|
+ // 每处理1000行记录一次日志
|
|
|
145
|
+ if (rowCount % 1000 == 0) {
|
|
|
146
|
+ log.info("已处理{}行数据", rowCount);
|
|
|
147
|
+ }
|
|
|
148
|
+ }
|
|
|
149
|
+
|
|
|
150
|
+ log.info("数据查询完成,共获取{}行数据", rowCount);
|
|
|
151
|
+
|
|
|
152
|
+ } catch (SQLException e) {
|
|
|
153
|
+ log.error("数据库操作异常,URL: {}, 用户名: {}", jdbcUrl, jdbcUserName, e);
|
|
|
154
|
+ } catch (Exception e) {
|
|
|
155
|
+ log.error("初始化数据库连接或查询数据时发生异常", e);
|
|
|
156
|
+ } finally {
|
|
|
157
|
+ // 释放资源
|
|
|
158
|
+ try {
|
|
|
159
|
+ if (resultSet != null) resultSet.close();
|
|
|
160
|
+ if (statement != null) statement.close();
|
|
|
161
|
+ if (connection != null) connection.close();
|
|
|
162
|
+ log.info("数据库连接资源已释放");
|
|
|
163
|
+ } catch (SQLException e) {
|
|
|
164
|
+ log.error("关闭数据库资源时发生异常", e);
|
|
|
165
|
+ }
|
|
|
166
|
+
|
|
|
167
|
+ if (dataSource != null) {
|
|
|
168
|
+ try {
|
|
|
169
|
+ dataSource.close();
|
|
|
170
|
+ log.info("HikariDataSource连接池已关闭");
|
|
|
171
|
+ } catch (Exception e) {
|
|
|
172
|
+ log.error("关闭HikariDataSource连接池时发生异常", e);
|
|
|
173
|
+ }
|
|
|
174
|
+ }
|
|
|
175
|
+ }
|
|
|
176
|
+
|
|
|
177
|
+ log.info("数据库操作完成,返回{}条记录", resultList.size());
|
|
|
178
|
+ return resultList;
|
|
|
179
|
+ }
|
|
|
180
|
+
|
|
|
181
|
+ private Object getTypedValue(ResultSet rs, int index, int sqlType) throws SQLException {
|
|
|
182
|
+ Object value;
|
|
|
183
|
+
|
|
|
184
|
+ try {
|
|
|
185
|
+ switch (sqlType) {
|
|
|
186
|
+ case Types.BIT:
|
|
|
187
|
+ case Types.BOOLEAN:
|
|
|
188
|
+ value = rs.getBoolean(index);
|
|
|
189
|
+ return rs.wasNull() ? null : value;
|
|
|
190
|
+
|
|
|
191
|
+ case Types.TINYINT:
|
|
|
192
|
+ case Types.SMALLINT:
|
|
|
193
|
+ case Types.INTEGER:
|
|
|
194
|
+ value = rs.getInt(index);
|
|
|
195
|
+ return rs.wasNull() ? null : value;
|
|
|
196
|
+
|
|
|
197
|
+ case Types.BIGINT:
|
|
|
198
|
+ value = rs.getLong(index);
|
|
|
199
|
+ return rs.wasNull() ? null : value;
|
|
|
200
|
+
|
|
|
201
|
+ case Types.FLOAT:
|
|
|
202
|
+ case Types.REAL:
|
|
|
203
|
+ value = rs.getFloat(index);
|
|
|
204
|
+ return rs.wasNull() ? null : value;
|
|
|
205
|
+
|
|
|
206
|
+ case Types.DOUBLE:
|
|
|
207
|
+ value = rs.getDouble(index);
|
|
|
208
|
+ return rs.wasNull() ? null : value;
|
|
|
209
|
+
|
|
|
210
|
+ case Types.NUMERIC:
|
|
|
211
|
+ case Types.DECIMAL:
|
|
|
212
|
+ value = rs.getBigDecimal(index);
|
|
|
213
|
+ return rs.wasNull() ? null : value;
|
|
|
214
|
+
|
|
|
215
|
+ case Types.CHAR:
|
|
|
216
|
+ case Types.VARCHAR:
|
|
|
217
|
+ case Types.LONGVARCHAR:
|
|
|
218
|
+ case Types.NCHAR:
|
|
|
219
|
+ case Types.NVARCHAR:
|
|
|
220
|
+ case Types.LONGNVARCHAR:
|
|
|
221
|
+ value = rs.getString(index);
|
|
|
222
|
+ return rs.wasNull() ? null : value;
|
|
|
223
|
+
|
|
|
224
|
+ case Types.DATE:
|
|
|
225
|
+ java.sql.Date date = rs.getDate(index);
|
|
|
226
|
+ return date != null ? date.toLocalDate() : null;
|
|
|
227
|
+
|
|
|
228
|
+ case Types.TIME:
|
|
|
229
|
+ Time time = rs.getTime(index);
|
|
|
230
|
+ return time != null ? time.toLocalTime() : null;
|
|
|
231
|
+
|
|
|
232
|
+ case Types.TIMESTAMP:
|
|
|
233
|
+ Timestamp timestamp = rs.getTimestamp(index);
|
|
|
234
|
+ return timestamp != null ? timestamp.toLocalDateTime() : null;
|
|
|
235
|
+
|
|
|
236
|
+ case Types.BINARY:
|
|
|
237
|
+ case Types.VARBINARY:
|
|
|
238
|
+ case Types.LONGVARBINARY:
|
|
|
239
|
+ value = rs.getBytes(index);
|
|
|
240
|
+ return rs.wasNull() ? null : value;
|
|
|
241
|
+
|
|
|
242
|
+ case Types.BLOB:
|
|
|
243
|
+ value = rs.getBlob(index);
|
|
|
244
|
+ return rs.wasNull() ? null : value;
|
|
|
245
|
+
|
|
|
246
|
+ case Types.CLOB:
|
|
|
247
|
+ value = rs.getClob(index);
|
|
|
248
|
+ return rs.wasNull() ? null : value;
|
|
|
249
|
+
|
|
|
250
|
+ default:
|
|
|
251
|
+ value = rs.getObject(index);
|
|
|
252
|
+ return rs.wasNull() ? null : value;
|
|
|
253
|
+ }
|
|
|
254
|
+ } catch (SQLException e) {
|
|
|
255
|
+ log.error("获取结果集第{}列数据时发生异常,数据类型: {}", index, sqlType, e);
|
|
|
256
|
+ throw e;
|
|
|
257
|
+ }
|
|
|
258
|
+ }
|
|
|
259
|
+
|
|
|
260
|
+// private void dataUpload(XkdDeviceInfo info) {
|
|
|
261
|
+// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmssSSS");
|
|
|
262
|
+// String dataBatch = simpleDateFormat.format(new Date());
|
|
|
263
|
+// XkdDeviceData data = new XkdDeviceData();
|
|
|
264
|
+// data.setDeviceId(info.getDeviceId());
|
|
|
265
|
+// data.setDataBatch(dataBatch);
|
|
|
266
|
+// ZonedDateTime now = ZonedDateTime.now();
|
|
|
267
|
+// String iso8601 = now.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME);
|
|
|
268
|
+// data.setCollectionTime(iso8601);
|
|
|
269
|
+// data.setStatus("RUN");
|
|
|
270
|
+// data.setAlarm(false);
|
|
|
271
|
+// data.setAlarmName("无");
|
|
|
272
|
+// data.setEfficiency(78D);
|
|
|
273
|
+//
|
|
|
274
|
+// sendDataUpload(data);
|
|
|
275
|
+// }
|
|
|
276
|
+
|
|
|
277
|
+ private boolean sendDataUpload(XkdDeviceData data) {
|
|
|
278
|
+ String deviceId = data.getDeviceId();
|
|
|
279
|
+ log.info("开始上报设备[{}]的数据,请求URL: {}", deviceId, dataUploadUrl);
|
|
|
280
|
+
|
|
|
281
|
+ HttpPost httpPost = new HttpPost(dataUploadUrl);
|
|
|
282
|
+ CloseableHttpClient httpClient = HttpClients.createDefault();
|
|
|
283
|
+ String requestBody = JSON.toJSONString(data);
|
|
|
284
|
+
|
|
|
285
|
+ log.info("设备[{}]上报请求体: {}", deviceId, requestBody);
|
|
|
286
|
+
|
|
|
287
|
+ StringEntity entity = new StringEntity(requestBody, ContentType.create("application/json", Consts.UTF_8));
|
|
|
288
|
+ httpPost.setEntity(entity);
|
|
|
289
|
+ httpPost.setHeader("Content-Type", "application/json;charset=UTF-8");
|
|
|
290
|
+ httpPost.setHeader("X-Enterprise-ID", enterpriseId);
|
|
|
291
|
+ httpPost.setHeader("X-API-Key", apiKey);
|
|
|
292
|
+
|
|
|
293
|
+ try (CloseableHttpResponse execute = httpClient.execute(httpPost)) {
|
|
|
294
|
+ int statusCode = execute.getStatusLine().getStatusCode();
|
|
|
295
|
+
|
|
|
296
|
+ HttpEntity res = execute.getEntity();
|
|
|
297
|
+ String responseBody = "";
|
|
|
298
|
+ if (res != null) {
|
|
|
299
|
+ try (InputStream is = res.getContent();
|
|
|
300
|
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
|
|
|
301
|
+ byte[] buf = new byte[128];
|
|
|
302
|
+ int len;
|
|
|
303
|
+ while ((len = is.read(buf)) != -1) {
|
|
|
304
|
+ byteArrayOutputStream.write(buf, 0, len);
|
|
|
305
|
+ }
|
|
|
306
|
+ responseBody = byteArrayOutputStream.toString("UTF-8");
|
|
|
307
|
+ }
|
|
|
308
|
+ }
|
|
|
309
|
+
|
|
|
310
|
+ log.info("设备[{}]上报响应,状态码: {},响应内容: {}", deviceId, statusCode, responseBody);
|
|
|
311
|
+
|
|
|
312
|
+ if (statusCode >= 200 && statusCode < 300) {
|
|
|
313
|
+ return true;
|
|
|
314
|
+ } else {
|
|
|
315
|
+ log.error("设备[{}]上报失败,HTTP状态码: {},响应: {}", deviceId, statusCode, responseBody);
|
|
|
316
|
+ return false;
|
|
|
317
|
+ }
|
|
|
318
|
+
|
|
|
319
|
+ } catch (IOException e) {
|
|
|
320
|
+ log.error("设备[{}]上报请求发生IO异常", deviceId, e);
|
|
|
321
|
+ return false;
|
|
|
322
|
+ } finally {
|
|
|
323
|
+ try {
|
|
|
324
|
+ httpClient.close();
|
|
|
325
|
+ } catch (IOException e) {
|
|
|
326
|
+ log.error("关闭HTTP客户端时发生异常", e);
|
|
|
327
|
+ }
|
|
|
328
|
+ }
|
|
|
329
|
+ }
|
|
|
330
|
+
|
|
|
331
|
+ // 设备注册,只需要执行一次,本地执行完成
|
|
|
332
|
+ public void devicesRegister() {
|
|
|
333
|
+ String filePath = "C:\\Users\\PC\\Desktop\\xdkdevice.xlsx";
|
|
|
334
|
+ try (InputStream in = new FileInputStream(new File(filePath));
|
|
|
335
|
+ // 使用 WorkbookFactory 自动根据文件格式创建合适的 Workbook
|
|
|
336
|
+ Workbook workbook = WorkbookFactory.create(in)) {
|
|
|
337
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
338
|
+ int lastRowNum = sheet.getLastRowNum();
|
|
|
339
|
+ for (int index = 1; index <= lastRowNum; index++) {
|
|
|
340
|
+ Row row = sheet.getRow(index);
|
|
|
341
|
+ XkdDeviceInfo info = new XkdDeviceInfo();
|
|
|
342
|
+ info.setDeviceId(row.getCell(4).getStringCellValue());
|
|
|
343
|
+ info.setDeviceName(row.getCell(3).getStringCellValue());
|
|
|
344
|
+ info.setDeviceType(row.getCell(5).getStringCellValue());
|
|
|
345
|
+ info.setLocation(row.getCell(1).getStringCellValue() + "-" + row.getCell(2).getStringCellValue());
|
|
|
346
|
+ sendReportDevice(info);
|
|
|
347
|
+// dataUpload(info);
|
|
|
348
|
+ }
|
|
|
349
|
+ } catch (Exception e) {
|
|
|
350
|
+ e.printStackTrace();
|
|
|
351
|
+ }
|
|
|
352
|
+ }
|
|
|
353
|
+
|
|
|
354
|
+ private boolean sendReportDevice(XkdDeviceInfo info) {
|
|
|
355
|
+ String deviceId = info.getDeviceId();
|
|
|
356
|
+ log.info("开始上报设备[{}]的数据,请求URL: {}", deviceId, devicesRegisterUrl);
|
|
|
357
|
+
|
|
|
358
|
+ HttpPost httpPost = new HttpPost(devicesRegisterUrl);
|
|
|
359
|
+ CloseableHttpClient httpClient = HttpClients.createDefault();
|
|
|
360
|
+ String requestBody = JSON.toJSONString(info);
|
|
|
361
|
+
|
|
|
362
|
+ log.info("设备[{}]上报请求体: {}", deviceId, requestBody);
|
|
|
363
|
+
|
|
|
364
|
+ StringEntity entity = new StringEntity(requestBody, ContentType.create("application/json", Consts.UTF_8));
|
|
|
365
|
+ httpPost.setEntity(entity);
|
|
|
366
|
+ httpPost.setHeader("Content-Type", "application/json;charset=UTF-8");
|
|
|
367
|
+ httpPost.setHeader("X-Enterprise-ID", enterpriseId);
|
|
|
368
|
+ httpPost.setHeader("X-API-Key", apiKey);
|
|
|
369
|
+
|
|
|
370
|
+ try (CloseableHttpResponse execute = httpClient.execute(httpPost)) {
|
|
|
371
|
+ int statusCode = execute.getStatusLine().getStatusCode();
|
|
|
372
|
+
|
|
|
373
|
+ HttpEntity res = execute.getEntity();
|
|
|
374
|
+ String responseBody = "";
|
|
|
375
|
+ if (res != null) {
|
|
|
376
|
+ try (InputStream is = res.getContent();
|
|
|
377
|
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
|
|
|
378
|
+ byte[] buf = new byte[128];
|
|
|
379
|
+ int len;
|
|
|
380
|
+ while ((len = is.read(buf)) != -1) {
|
|
|
381
|
+ byteArrayOutputStream.write(buf, 0, len);
|
|
|
382
|
+ }
|
|
|
383
|
+ responseBody = byteArrayOutputStream.toString("UTF-8");
|
|
|
384
|
+ }
|
|
|
385
|
+ }
|
|
|
386
|
+
|
|
|
387
|
+ log.info("设备[{}]上报响应,状态码: {},响应内容: {}", deviceId, statusCode, responseBody);
|
|
|
388
|
+
|
|
|
389
|
+ if (statusCode >= 200 && statusCode < 300) {
|
|
|
390
|
+ return true;
|
|
|
391
|
+ } else {
|
|
|
392
|
+ log.error("设备[{}]上报失败,HTTP状态码: {},响应: {}", deviceId, statusCode, responseBody);
|
|
|
393
|
+ return false;
|
|
|
394
|
+ }
|
|
|
395
|
+
|
|
|
396
|
+ } catch (IOException e) {
|
|
|
397
|
+ log.error("设备[{}]上报请求发生IO异常", deviceId, e);
|
|
|
398
|
+ return false;
|
|
|
399
|
+ } finally {
|
|
|
400
|
+ try {
|
|
|
401
|
+ httpClient.close();
|
|
|
402
|
+ } catch (IOException e) {
|
|
|
403
|
+ log.error("关闭HTTP客户端时发生异常", e);
|
|
|
404
|
+ }
|
|
|
405
|
+ }
|
|
|
406
|
+ }
|
|
|
407
|
+} |
...
|
...
|
|