xiaoyi
2026-10-28 8eb62ee0efe77e264cd48b3f1fd835e9b8430318
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package cn.iocoder.yudao.module.mes.framework.collect.config;
 
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
 
/**
 * MES 数采配置
 *
 * @author 超级管理员
 */
@Component
@ConfigurationProperties(prefix = "yudao.mes.collect")
@Data
public class MesCollectProperties {
 
    /**
     * 报文格式:注塑机 /YLCY/IMM 协议(报文带 topic 字段,主题末段为报文类型)
     */
    public static final String FORMAT_YLCY = "ylcy";
    /**
     * 报文格式:设备网关协议(主题固定 gateway/xxx,报文首层 key 为设备名,值为属性字典)
     */
    public static final String FORMAT_GATEWAY = "gateway";
 
    private Mqtt mqtt = new Mqtt();
    private Retention retention = new Retention();
 
    @Data
    public static class Mqtt {
 
        /**
         * 是否启用数采 MQTT 订阅
         */
        private Boolean enabled = false;
        /**
         * Broker 地址,例如 tcp://36.213.90.123:1883
         */
        private String url;
        private String username;
        private String password;
        /**
         * 客户端 ID 前缀
         */
        private String clientIdPrefix = "mes-collect";
        /**
         * 主题前缀,例如 /YLCY/IMM、gateway
         */
        private String topicPrefix = "/YLCY/IMM";
        /**
         * 报文格式,见 {@link MesCollectProperties#FORMAT_YLCY}、{@link MesCollectProperties#FORMAT_GATEWAY}
         */
        private String format = FORMAT_YLCY;
        /**
         * 显式指定订阅主题,多个用逗号分隔;为空时按 format + topicPrefix 自动推导
         */
        private String topics;
        private Integer qos = 0;
        private Integer keepAlive = 65;
        private Integer connectionTimeout = 10;
        /**
         * 报警主题后缀,报文 topic 字段或主题末段命中时按报警处理
         */
        private String alarmTopicSuffix = "wm";
 
        /**
         * 是否为设备网关格式报文
         */
        public boolean isGatewayFormat() {
            return FORMAT_GATEWAY.equalsIgnoreCase(format == null ? "" : format.trim());
        }
 
    }
 
    @Data
    public static class Retention {
 
        /**
         * 原始报文保留天数
         */
        private Integer rawDays = 7;
        /**
         * 实时历史保留天数
         */
        private Integer realtimeDays = 30;
        /**
         * 单次清理条数
         */
        private Integer batchSize = 50000;
 
    }
 
}