package com.iailab.module.data.channel.common.service; import com.iailab.module.data.channel.http.entity.HttpApiEntity; import com.iailab.module.data.channel.http.service.HttpApiService; import com.iailab.module.data.channel.kio.entity.ChannelKioDeviceEntity; import com.iailab.module.data.channel.kio.service.ChannelKioDeviceService; import com.iailab.module.data.channel.modbus.dto.ChannelModBusDeviceDTO; import com.iailab.module.data.channel.modbus.entity.ChannelModBusDeviceEntity; import com.iailab.module.data.channel.modbus.service.ChannelModbusDeviceService; import com.iailab.module.data.channel.opcda.dto.ChannelOPCDADeviceDTO; import com.iailab.module.data.channel.opcda.entity.ChannelOPCDADeviceEntity; import com.iailab.module.data.channel.opcda.service.ChannelOPCDADeviceService; import com.iailab.module.data.channel.opcua.dto.ChannelOPCUADeviceDTO; import com.iailab.module.data.channel.opcua.entity.ChannelOPCUADeviceEntity; import com.iailab.module.data.channel.opcua.service.ChannelOPCUADeviceService; import com.iailab.module.data.common.enums.DataSourceType; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @author PanZhibao * @Description * @createTime 2024年10月31日 */ @Component public class ChannelSourceService { @Autowired private ChannelOPCDADeviceService channelOPCDADeviceService; @Autowired private ChannelOPCUADeviceService channelOPCUADeviceService; @Autowired private ChannelModbusDeviceService channelModbusDeviceService; @Autowired private ChannelKioDeviceService channelKioDeviceService; @Autowired private HttpApiService httpApiService; public Map> getSourcesId() { Map> result = new HashMap<>(); Map opcdaMap = new HashMap<>(); List opcdaList = channelOPCDADeviceService.list(new HashMap<>()); opcdaList.forEach(opcda -> { opcdaMap.put(opcda.getServerName(), opcda.getId()); }); result.put(DataSourceType.OPCDA.getCode(), opcdaMap); Map opcuaMap = new HashMap<>(); List opcuaList = channelOPCUADeviceService.list(new HashMap<>()); opcuaList.forEach(opcUa -> { opcuaMap.put(opcUa.getServerName(), opcUa.getId()); }); result.put(DataSourceType.OPCUA.getCode(), opcuaMap); Map modbusMap = new HashMap<>(); List modbusList = channelModbusDeviceService.list(new HashMap<>()); modbusList.forEach(modbus -> { modbusMap.put(modbus.getName(), modbus.getId()); }); result.put(DataSourceType.ModBus.getCode(), modbusMap); Map kioMap = new HashMap<>(); List kioList = channelKioDeviceService.list(new HashMap<>()); kioList.forEach(kio -> { kioMap.put(kio.getInstanceName(), kio.getId()); }); result.put(DataSourceType.KIO.getCode(), kioMap); Map httpMap = new HashMap<>(); List httpList = httpApiService.list(); httpList.forEach(http -> { httpMap.put(http.getCode(), http.getId()); }); result.put(DataSourceType.HTTP.getCode(), httpMap); return result; } }