|
|
@@ -64,20 +64,31 @@ public class DataCollector {
|
|
|
//请求地址
|
|
|
String url = endpoint.getUrl() + ScadaPlatformMetadata.Uri.REAL_TIME_DATA;
|
|
|
|
|
|
+ //数据即可
|
|
|
+ List<ScadaPlatformData> allItems = new ArrayList<>();
|
|
|
//设备
|
|
|
List<Device> devices = deviceRegistry.findAll(ScadaPlatformMetadata.NAME);
|
|
|
|
|
|
- //参数
|
|
|
- Map<String, Object> params = ScadaPlatformMetadata.getRealTimeDataParams(devices);
|
|
|
- //请求结果项
|
|
|
- List<ScadaPlatformData> items = callingUtil.request(url, HttpMethod.GET, params, Collections.emptyList(),
|
|
|
- new TypeReference<ScadaPlatformDataResult<List<ScadaPlatformData>>>() {
|
|
|
- });
|
|
|
- LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, BIZ_TYPE, CLASS_NAME
|
|
|
- , String.format("拉取数据成功,数据量:%d", items.size()));
|
|
|
+ //遍历设备,并请求数据
|
|
|
+ for (Device device : devices) {
|
|
|
+ LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, BIZ_TYPE, CLASS_NAME
|
|
|
+ , String.format("开始拉去数据,采集标签:%s",
|
|
|
+ device.getTags().stream().map(DeviceTag::getTag).collect(Collectors.joining(","))));
|
|
|
+
|
|
|
+ //参数
|
|
|
+ Map<String, Object> params = ScadaPlatformMetadata.getRealTimeDataParams(Collections.singletonList(device));
|
|
|
+ //请求结果项
|
|
|
+ List<ScadaPlatformData> items = callingUtil.request(url, HttpMethod.GET, params, Collections.emptyList(),
|
|
|
+ new TypeReference<ScadaPlatformDataResult<List<ScadaPlatformData>>>() {
|
|
|
+ });
|
|
|
+
|
|
|
+ LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, BIZ_TYPE, CLASS_NAME
|
|
|
+ , String.format("拉取数据成功,数据量:%d", items.size()));
|
|
|
+ allItems.addAll(items);
|
|
|
+ }
|
|
|
|
|
|
//构建influxdb
|
|
|
- List<Point> points = items.parallelStream().map(d -> d.toPoint(devices)).collect(Collectors.toList());
|
|
|
+ List<Point> points = allItems.parallelStream().map(d -> d.toPoint(devices)).collect(Collectors.toList());
|
|
|
//写入influxDb
|
|
|
influxDbUtil.write(points);
|
|
|
|