提交 | 用户 | 时间
|
01d6f8
|
1 |
package com.iailab.module.data.channel.common.service; |
潘 |
2 |
|
|
3 |
import com.iailab.module.data.channel.http.entity.HttpApiEntity; |
|
4 |
import com.iailab.module.data.channel.http.service.HttpApiService; |
|
5 |
import com.iailab.module.data.channel.kio.entity.ChannelKioDeviceEntity; |
|
6 |
import com.iailab.module.data.channel.kio.service.ChannelKioDeviceService; |
|
7 |
import com.iailab.module.data.channel.modbus.dto.ChannelModBusDeviceDTO; |
|
8 |
import com.iailab.module.data.channel.modbus.entity.ChannelModBusDeviceEntity; |
|
9 |
import com.iailab.module.data.channel.modbus.service.ChannelModbusDeviceService; |
|
10 |
import com.iailab.module.data.channel.opcda.dto.ChannelOPCDADeviceDTO; |
|
11 |
import com.iailab.module.data.channel.opcda.entity.ChannelOPCDADeviceEntity; |
|
12 |
import com.iailab.module.data.channel.opcda.service.ChannelOPCDADeviceService; |
|
13 |
import com.iailab.module.data.channel.opcua.dto.ChannelOPCUADeviceDTO; |
|
14 |
import com.iailab.module.data.channel.opcua.entity.ChannelOPCUADeviceEntity; |
|
15 |
import com.iailab.module.data.channel.opcua.service.ChannelOPCUADeviceService; |
|
16 |
import com.iailab.module.data.common.enums.DataSourceType; |
|
17 |
import org.springframework.beans.factory.annotation.Autowired; |
|
18 |
import org.springframework.stereotype.Component; |
|
19 |
|
|
20 |
import java.util.HashMap; |
|
21 |
import java.util.List; |
|
22 |
import java.util.Map; |
|
23 |
|
|
24 |
/** |
|
25 |
* @author PanZhibao |
|
26 |
* @Description |
|
27 |
* @createTime 2024年10月31日 |
|
28 |
*/ |
|
29 |
@Component |
|
30 |
public class ChannelSourceService { |
|
31 |
|
|
32 |
@Autowired |
|
33 |
private ChannelOPCDADeviceService channelOPCDADeviceService; |
|
34 |
|
|
35 |
@Autowired |
|
36 |
private ChannelOPCUADeviceService channelOPCUADeviceService; |
|
37 |
|
|
38 |
@Autowired |
|
39 |
private ChannelModbusDeviceService channelModbusDeviceService; |
|
40 |
|
|
41 |
@Autowired |
|
42 |
private ChannelKioDeviceService channelKioDeviceService; |
|
43 |
|
|
44 |
@Autowired |
|
45 |
private HttpApiService httpApiService; |
|
46 |
|
|
47 |
public Map<String, Map<String, String>> getSourcesId() { |
|
48 |
|
|
49 |
Map<String, Map<String, String>> result = new HashMap<>(); |
|
50 |
|
|
51 |
Map<String, String> opcdaMap = new HashMap<>(); |
|
52 |
List<ChannelOPCDADeviceEntity> opcdaList = channelOPCDADeviceService.list(new HashMap<>()); |
|
53 |
opcdaList.forEach(opcda -> { |
|
54 |
opcdaMap.put(opcda.getServerName(), opcda.getId()); |
|
55 |
}); |
|
56 |
result.put(DataSourceType.OPCDA.getCode(), opcdaMap); |
|
57 |
|
|
58 |
Map<String, String> opcuaMap = new HashMap<>(); |
|
59 |
List<ChannelOPCUADeviceEntity> opcuaList = channelOPCUADeviceService.list(new HashMap<>()); |
|
60 |
opcuaList.forEach(opcUa -> { |
|
61 |
opcuaMap.put(opcUa.getServerName(), opcUa.getId()); |
|
62 |
}); |
|
63 |
result.put(DataSourceType.OPCUA.getCode(), opcuaMap); |
|
64 |
|
|
65 |
Map<String, String> modbusMap = new HashMap<>(); |
|
66 |
List<ChannelModBusDeviceEntity> modbusList = channelModbusDeviceService.list(new HashMap<>()); |
|
67 |
modbusList.forEach(modbus -> { |
|
68 |
modbusMap.put(modbus.getName(), modbus.getId()); |
|
69 |
}); |
|
70 |
result.put(DataSourceType.ModBus.getCode(), modbusMap); |
|
71 |
|
|
72 |
Map<String, String> kioMap = new HashMap<>(); |
|
73 |
List<ChannelKioDeviceEntity> kioList = channelKioDeviceService.list(new HashMap<>()); |
|
74 |
kioList.forEach(kio -> { |
|
75 |
kioMap.put(kio.getInstanceName(), kio.getId()); |
|
76 |
}); |
|
77 |
result.put(DataSourceType.KIO.getCode(), kioMap); |
|
78 |
|
|
79 |
Map<String, String> httpMap = new HashMap<>(); |
|
80 |
List<HttpApiEntity> httpList = httpApiService.list(); |
|
81 |
httpList.forEach(http -> { |
|
82 |
httpMap.put(http.getCode(), http.getId()); |
|
83 |
}); |
|
84 |
result.put(DataSourceType.HTTP.getCode(), httpMap); |
|
85 |
|
|
86 |
return result; |
|
87 |
} |
|
88 |
} |