Commit f320569f2c46ebca8ea88c4bbbe23d9b63539e94
1 parent
44838510
perf:【iot】优化 IotTcpClient 代码
Showing
2 changed files
with
3 additions
and
7 deletions
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/data/action/IotTcpDataRuleAction.java
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/data/action/tcp/IotTcpClient.java
| 1 | 1 | package cn.iocoder.yudao.module.iot.service.rule.data.action.tcp; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.util.ObjUtil; | |
| 3 | 4 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; |
| 4 | 5 | import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage; |
| 5 | 6 | import cn.iocoder.yudao.module.iot.dal.dataobject.rule.config.IotDataSinkTcpConfig; |
| ... | ... | @@ -31,8 +32,6 @@ public class IotTcpClient { |
| 31 | 32 | private final Integer connectTimeoutMs; |
| 32 | 33 | private final Integer readTimeoutMs; |
| 33 | 34 | private final Boolean ssl; |
| 34 | - // TODO @puhui999:sslCertPath 是不是没在用? | |
| 35 | - private final String sslCertPath; | |
| 36 | 35 | private final String dataFormat; |
| 37 | 36 | |
| 38 | 37 | private Socket socket; |
| ... | ... | @@ -41,15 +40,13 @@ public class IotTcpClient { |
| 41 | 40 | private final AtomicBoolean connected = new AtomicBoolean(false); |
| 42 | 41 | |
| 43 | 42 | public IotTcpClient(String host, Integer port, Integer connectTimeoutMs, Integer readTimeoutMs, |
| 44 | - Boolean ssl, String sslCertPath, String dataFormat) { | |
| 43 | + Boolean ssl, String dataFormat) { | |
| 45 | 44 | this.host = host; |
| 46 | 45 | this.port = port; |
| 47 | 46 | this.connectTimeoutMs = connectTimeoutMs != null ? connectTimeoutMs : IotDataSinkTcpConfig.DEFAULT_CONNECT_TIMEOUT_MS; |
| 48 | 47 | this.readTimeoutMs = readTimeoutMs != null ? readTimeoutMs : IotDataSinkTcpConfig.DEFAULT_READ_TIMEOUT_MS; |
| 49 | 48 | this.ssl = ssl != null ? ssl : IotDataSinkTcpConfig.DEFAULT_SSL; |
| 50 | - this.sslCertPath = sslCertPath; | |
| 51 | - // TODO @puhui999:可以使用 StrUtil.defaultIfBlank 方法简化 | |
| 52 | - this.dataFormat = dataFormat != null ? dataFormat : IotDataSinkTcpConfig.DEFAULT_DATA_FORMAT; | |
| 49 | + this.dataFormat = ObjUtil.defaultIfBlank(dataFormat, IotDataSinkTcpConfig.DEFAULT_DATA_FORMAT); | |
| 53 | 50 | } |
| 54 | 51 | |
| 55 | 52 | /** | ... | ... |