| | |
| | | package com.iailab.module.data.channel.kio.collector; |
| | | |
| | | import com.iailab.module.data.channel.kio.entity.ChannelKioDeviceEntity; |
| | | import com.iailab.module.data.channel.kio.service.ChannelKioDeviceService; |
| | | import com.iailab.module.data.common.enums.DataSourceType; |
| | | import com.iailab.module.data.common.utils.TagUtils; |
| | | import com.iailab.module.data.channel.kio.dto.ChannelKioDeviceDTO; |
| | | import com.iailab.module.data.channel.kio.service.ChannelKioDeviceService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | |
| | | |
| | | private Map<String, KingIOClient> clientMap = new ConcurrentHashMap<>(); |
| | | |
| | | private Map<String, ChannelKioDeviceDTO> deviceMap = new HashMap<>(); |
| | | private Map<String, ChannelKioDeviceEntity> deviceMap = new HashMap<>(); |
| | | |
| | | public synchronized KingIOClient getClient(String sourceId) throws Exception { |
| | | if (!clientMap.containsKey(sourceId)) { |
| | | ChannelKioDeviceDTO deviceDto = channelKioDeviceService.get(sourceId); |
| | | deviceMap.put(sourceId, deviceDto); |
| | | KingIOClient kingIOClient = new KingIOClient(deviceDto.getInstanceName()); |
| | | ChannelKioDeviceEntity deviceEntity = channelKioDeviceService.info(sourceId); |
| | | deviceMap.put(sourceId, deviceEntity); |
| | | KingIOClient kingIOClient = new KingIOClient(deviceEntity.getInstanceName()); |
| | | clientMap.put(sourceId, kingIOClient); |
| | | if (!kingIOClient.login(deviceDto.getAddress(), deviceDto.getPort(), deviceDto.getUsername(), deviceDto.getPassword())) { |
| | | if (!kingIOClient.login(deviceEntity.getAddress(), deviceEntity.getPort(), deviceEntity.getUsername(), deviceEntity.getPassword())) { |
| | | throw new Exception("登录异常"); |
| | | } |
| | | } |