| | |
| | | import com.ruoyi.device.discovery.DeviceDiscoveryCandidateStore.CollectorCandidate; |
| | | import com.ruoyi.system.mapper.TCollectorMapper; |
| | | |
| | | /** 将模拟采集器的发现和实时状态写入 Redis,不回写正式 MySQL 记录。 */ |
| | | /** 将模拟采集器的发现写入 Redis,并同步已登记采集器的实时在线事实。 */ |
| | | @Component |
| | | public class DevelopmentCollectorStatusSynchronizer |
| | | { |
| | |
| | | private final TCollectorMapper collectorMapper; |
| | | |
| | | @Autowired |
| | | public DevelopmentCollectorStatusSynchronizer(BtsDevelopmentSimulator simulator, |
| | | DeviceDiscoveryCandidateStore candidateStore) |
| | | { |
| | | this(simulator, candidateStore, null); |
| | | } |
| | | |
| | | public DevelopmentCollectorStatusSynchronizer(BtsDevelopmentSimulator simulator, |
| | | DeviceDiscoveryCandidateStore candidateStore, TCollectorMapper collectorMapper) |
| | | { |
| | |
| | | observedAt.plus(Duration.ofSeconds(30)))) |
| | | .toList(); |
| | | candidateStore.replaceCollectors(BtsDevelopmentSimulator.ADAPTER_CODE, candidates); |
| | | if (collectorMapper != null) |
| | | { |
| | | candidates.forEach(candidate -> collectorMapper.updateRegisteredObservation(candidate.deviceCode(), |
| | | candidate.online() ? "ONLINE" : "OFFLINE")); |
| | | } |
| | | candidates.forEach(candidate -> collectorMapper.updateRegisteredObservation(candidate.deviceCode(), |
| | | candidate.online() ? "ONLINE" : "OFFLINE")); |
| | | } |
| | | } |