| | |
| | | private static final String TESTING = "1"; |
| | | private static final String ONLINE = "0"; |
| | | private static final String OFFLINE = "1"; |
| | | private static final Set<DeviceWorkStatus> ACTIVE_WORK_STATUSES = Set.of(DeviceWorkStatus.WORKING, |
| | | DeviceWorkStatus.PAUSED, DeviceWorkStatus.PROTECTED, DeviceWorkStatus.SYNCHRONIZING, |
| | | DeviceWorkStatus.LIT, DeviceWorkStatus.WAITING_TIMEOUT, DeviceWorkStatus.WAITING_START, |
| | | DeviceWorkStatus.LOCKED); |
| | | |
| | | private final TDetectionCabinetMapper detectionCabinetMapper; |
| | | private final DeviceDiscoveryCandidateStore candidateStore; |
| | |
| | | |
| | | /** |
| | | * 读取未过期且未登记的候选,离线设备仍保留身份并可选择。 |
| | | * 测试占用状态由实时通道工作状态聚合;测试归属留待后续绑定闭环确认。 |
| | | * 发现只返回设备事实,不从通道工作状态推断系统测试关系。 |
| | | * |
| | | * @return 可供选择的检测柜设备摘要 |
| | | */ |
| | |
| | | Set<String> registeredCodes = Set.copyOf(detectionCabinetMapper.selectRegisteredCabinetCodes()); |
| | | return candidateStore.snapshot(Instant.now()).cabinets().stream() |
| | | .filter(candidate -> !registeredCodes.contains(candidate.deviceCode())) |
| | | .map(candidate -> { |
| | | boolean active = candidate.online() && isActive(candidate); |
| | | return new DiscoveredCabinetVo( |
| | | .map(candidate -> new DiscoveredCabinetVo( |
| | | candidate.deviceCode(), candidate.ip(), candidate.mac(), candidate.name(), |
| | | candidate.manufacturer(), candidate.model(), candidate.channels().size(), candidate.online() ? "在线" : "离线", |
| | | active ? "测试中" : "空闲", |
| | | active ? "待确认" : "-"); |
| | | }) |
| | | candidate.manufacturer(), candidate.model(), candidate.channels().size(), candidate.online() ? "在线" : "离线")) |
| | | .toList(); |
| | | } |
| | | |
| | |
| | | private String stableCandidateKey(String adapterCode, Integer devtype, Integer devid) |
| | | { |
| | | return adapterCode + "-" + devtype + "-" + devid; |
| | | } |
| | | |
| | | private boolean isActive(CabinetCandidate candidate) |
| | | { |
| | | return candidate.channels().stream().anyMatch(channel -> ACTIVE_WORK_STATUSES.contains(channel.workStatus())); |
| | | } |
| | | |
| | | /** 将设备观测状态转换为最终数据库允许的通道事实状态。 */ |