自动化立体仓库 - WMS系统
zwl
2 天以前 909cc78ba290cefc3c4623eff234e85ca0140e6d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package com.zy.iot.config;
 
import com.zy.iot.entity.IotTopicConfig;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
 
import java.util.LinkedHashMap;
import java.util.Map;
 
@Data
@Component
@ConfigurationProperties(prefix = "iot")
public class IotProperties {
 
    private boolean enabled;
 
    private String endpoint;
 
    private Integer port = 8883;
 
    private String thingName;
 
    private String clientId;
 
    private boolean cleanSession;
 
    private boolean automaticReconnect = true;
 
    private Integer keepAliveSeconds = 60;
 
    private Integer connectionTimeoutSeconds = 10;
 
    private String persistenceDir;
 
    private String caCertPath;
 
    private String clientCertPath;
 
    private String privateKeyPath;
 
    private IotTopicConfig topics = new IotTopicConfig();
 
    private Map<String, Integer> pickStationMappings = new LinkedHashMap<>();
 
    public String getResolvedClientId() {
        if (clientId != null && clientId.trim().length() > 0) {
            return clientId.trim();
        }
        return thingName;
    }
 
    public boolean isTlsEnabled() {
        String serverUri = getServerUri();
        return serverUri != null && serverUri.startsWith("ssl://");
    }
 
    public String getServerUri() {
        if (endpoint == null || endpoint.trim().length() == 0) {
            return null;
        }
        String trimmed = endpoint.trim();
        if (trimmed.startsWith("ssl://") || trimmed.startsWith("tcp://")) {
            return trimmed;
        }
        int resolvedPort = port == null ? 8883 : port;
        return "ssl://" + trimmed + ":" + resolvedPort;
    }
}