| | |
| | | if (collector == null) throw new ServiceException("采集器信息不能为空"); |
| | | collector.setCollectorCode(trimToNull(collector.getCollectorCode())); |
| | | CollectorCandidate candidate = candidateStore.findCollector(collector.getCollectorCode(), Instant.now()) |
| | | .filter(CollectorCandidate::online) |
| | | .orElseThrow(() -> new ServiceException("请先选择在线的发现候选设备")); |
| | | .orElseThrow(() -> new ServiceException("请先选择有效的发现候选设备")); |
| | | collector.setIpAddress(candidate.ip()); |
| | | collector.setMacAddress(candidate.mac()); |
| | | collector.setChannelCount(candidate.channelCount()); |
| | |
| | | collector.setDelFlag("0"); |
| | | collector.setCreateTime(new Date()); |
| | | int rows = collectorMapper.insertCollector(collector); |
| | | // 登记瞬间同步候选事实,避免正式记录暂时显示为离线且没有最近观测时间。 |
| | | // 登记只确认来源身份,在线与离线事实都按候选原样同步。 |
| | | collectorMapper.updateRegisteredObservation(collector.getCollectorCode(), |
| | | candidate.online() ? "ONLINE" : "OFFLINE"); |
| | | return rows; |