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); } }