jiazx0107@163.com
2023-05-17 620eab6cca2bc9ef9ea6d3067a0a5ba1deadbd1c
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
package com.ld.igds.io.impl;
 
import com.ld.igds.models.DeviceSer;
import com.ld.igds.util.ContextUtil;
 
import lombok.extern.slf4j.Slf4j;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import com.ld.igds.common.CoreSerService;
import com.ld.igds.constant.Constant;
import com.ld.igds.io.notify.ServerNotifyInvoker;
 
/**
 * 实现服务通知接口,主要是分机上下线通知
 *
 * @author Andy
 */
@Slf4j
@Component(ServerNotifyInvokerImpl.BEAN_ID)
public class ServerNotifyInvokerImpl implements ServerNotifyInvoker {
 
    @Autowired
    private CoreSerService serService;
 
    @Override
    public void connectDestory(String businessKey, String ip, Integer port) {
        // 根据IP和端口号更新分机状态,离线
        log.warn("连接被销毁,KEY={}", businessKey);
 
        serService.updateStatusByIp(Constant.YN_N, ip, port);
    }
 
    @Override
    public void connectActive(String businessKey, String ip, Integer port) {
        // 根据IP和端口号更新分机状态,在线
        log.info("连接被激活,KEY={}", businessKey);
 
        serService.updateStatusByIp(Constant.YN_Y, ip, port);
    }
 
    @Override
    public DeviceSer getDeviceSer(String companyId, String address, Integer port) {
        if (null == companyId) {
            companyId = ContextUtil.getDefaultCompanyId();
        }
        return serService.getCacheSerByIp(companyId, address);
    }
 
}