CZT
2023-09-14 db72a27d10fdc4de0926fb8c7cc411ec0d4ea51b
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
package com.ld.igds.protocol.iot;
 
import com.ld.igds.data.ConfigData;
import com.ld.igds.protocol.iot.height.server.IotServerEngine;
import com.ld.igds.protocol.iot.n2.fzzy.server.N2FzzyServerEngine;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
 
/**
 * 可以根据配置文件灵活调整
 * 配置随系统自动启动服务 -- 执行顺序20-29
 */
@Component(ServerRunner.BEAN_ID)
@Order(value = 23)
public class ServerRunner implements CommandLineRunner {
 
    public static final String BEAN_ID = "iot.serverRunner";
 
    @Autowired
    private ConfigData configData;
    @Autowired
    private IotServerEngine iotServerEngine;
    @Autowired
    private N2FzzyServerEngine fzzyServerEngine;
 
    @Override
    public void run(String... strings) throws Exception {
 
        if ("dev".equals(configData.getActive())) {
            iotServerEngine.start(IotServerEngine.PORT);
            fzzyServerEngine.start(9307);
            return;
        }
 
        if (configData.getActive().indexOf("pro") >= 0) {
            iotServerEngine.start(IotServerEngine.PORT);
            fzzyServerEngine.start(9307);
        }
    }
}