jiazx0107@163.com
2023-11-18 41cd6c8db40bceb08290828ae0d4fc5caeea7147
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
package com.fzzy.gateway.hx2023.service;
 
import com.bstek.dorado.annotation.Expose;
import com.fzzy.api.data.GatewayDeviceType;
import com.fzzy.gateway.api.GatewayRemoteManager;
import com.fzzy.gateway.api.GatewayRemoteService;
import com.fzzy.gateway.data.BaseReqData;
import com.fzzy.gateway.entity.GatewayConf;
import com.fzzy.gateway.entity.GatewayDevice;
import com.fzzy.gateway.service.GatewayConfService;
 
 
import com.fzzy.gateway.service.GatewayDeviceService;
import org.springframework.stereotype.Component;
 
import javax.annotation.Resource;
 
import java.util.List;
 
/**
 * 当前接口,初始化相关
 */
@Component
public class ApiInitService {
 
    @Resource
    private GatewayConfService confService;
    @Resource
    private GatewayDeviceService deviceService;
    @Resource
    private GatewayRemoteManager gatewayRemoteManager;
 
 
    /**
     * apiInitService#init
     */
    @Expose
    public void init() {
 
        List<GatewayConf> list = confService.listAll();
 
        if (null == list || list.isEmpty()) {
            return;
        }
 
        GatewayRemoteService gatewayRemoteService;
        for (GatewayConf gatewayConf : list) {
            gatewayRemoteService = gatewayRemoteManager.getRemoteService(gatewayConf.getPushProtocol());
            gatewayRemoteService.init(gatewayConf);
        }
 
    }
 
 
    public void updateDeviceCache() {
        deviceService.flushCache();
    }
 
    public void initAllLpr() {
        List<GatewayDevice> list = deviceService.listAll();
 
        if (null == list || list.isEmpty()) {
            return;
        }
 
        BaseReqData reqData;
        int i = 1;
        for (GatewayDevice device : list) {
 
            if (!GatewayDeviceType.TYPE_02.getCode().equals(device.getType())) {
                continue;
            }
 
            reqData = new BaseReqData(device);
            reqData.setIndex(i);
            gatewayRemoteManager.getSyncLprService(device.getSyncProtocol()).initLpr(reqData);
            i++;
        }
    }
}