package com.mes.interaction;
|
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.stereotype.Component;
|
|
import java.util.Collections;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* 交互注册中心
|
*/
|
@Slf4j
|
@Component
|
public class DeviceInteractionRegistry {
|
|
private final Map<String, DeviceInteraction> interactionMap = new HashMap<>();
|
|
public DeviceInteractionRegistry(List<DeviceInteraction> interactions) {
|
if (interactions != null) {
|
for (DeviceInteraction interaction : interactions) {
|
if (interaction.getDeviceType() != null) {
|
interactionMap.put(interaction.getDeviceType(), interaction);
|
log.info("注册设备交互: {}", interaction.getDeviceType());
|
}
|
}
|
}
|
}
|
|
public DeviceInteraction getInteraction(String deviceType) {
|
if (deviceType == null) {
|
return null;
|
}
|
return interactionMap.get(deviceType);
|
}
|
|
public Map<String, DeviceInteraction> getInteractions() {
|
return Collections.unmodifiableMap(interactionMap);
|
}
|
}
|