refactor: 优化设备数据查询
This commit is contained in:
parent
73fa7607e9
commit
0b6c8451d3
|
|
@ -104,8 +104,10 @@ class ElasticSearchRowModeQueryOperations extends RowModeQueryOperationsBase {
|
|||
if (property == null || thingId == null || value == null) {
|
||||
return null;
|
||||
}
|
||||
return ThingPropertyDetail
|
||||
.of(TimeSeriesData.of(ts, data), properties.get(property));
|
||||
|
||||
return applyProperty(ThingPropertyDetail
|
||||
.of(TimeSeriesData.of(ts, data), properties.get(property)),
|
||||
data);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,8 +41,11 @@ public abstract class RowModeQueryOperationsBase extends AbstractQueryOperations
|
|||
|
||||
return this
|
||||
.doQuery(metric, query)
|
||||
.mapNotNull(data -> ThingPropertyDetail
|
||||
.of(data, properties.get(data.getString(ThingsDataConstants.COLUMN_PROPERTY_ID, null))))
|
||||
.mapNotNull(data -> this
|
||||
.applyProperty(
|
||||
ThingPropertyDetail
|
||||
.of(data, properties.get(data.getString(ThingsDataConstants.COLUMN_PROPERTY_ID, null))),
|
||||
data.getData()))
|
||||
;
|
||||
}
|
||||
|
||||
|
|
@ -58,10 +61,24 @@ public abstract class RowModeQueryOperationsBase extends AbstractQueryOperations
|
|||
.clone()
|
||||
.toQuery()
|
||||
.and(ThingsDataConstants.COLUMN_PROPERTY_ID, e.getKey()))
|
||||
.mapNotNull(data -> ThingPropertyDetail.of(data, properties.get(data.getString(ThingsDataConstants.COLUMN_PROPERTY_ID, null)))),
|
||||
.mapNotNull(data -> this
|
||||
.applyProperty(
|
||||
ThingPropertyDetail
|
||||
.of(data, properties.get(data.getString(ThingsDataConstants.COLUMN_PROPERTY_ID, null))),
|
||||
data.getData())),
|
||||
16);
|
||||
}
|
||||
|
||||
protected ThingPropertyDetail applyProperty(ThingPropertyDetail detail, Map<String, Object> data) {
|
||||
if (detail == null) {
|
||||
return null;
|
||||
}
|
||||
if (detail.getThingId() == null) {
|
||||
detail.thingId((String) data.get(metricBuilder.getThingIdProperty()));
|
||||
}
|
||||
return detail;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final Mono<PagerResult<ThingPropertyDetail>> queryPropertyPage(@Nonnull QueryParamEntity param,
|
||||
@Nonnull ThingMetadata metadata,
|
||||
|
|
@ -76,8 +93,11 @@ public abstract class RowModeQueryOperationsBase extends AbstractQueryOperations
|
|||
return this
|
||||
.doQueryPage(metric,
|
||||
query,
|
||||
data -> ThingPropertyDetail
|
||||
.of(data, properties.get(data.getString(ThingsDataConstants.COLUMN_PROPERTY_ID, null))));
|
||||
data -> this
|
||||
.applyProperty(
|
||||
ThingPropertyDetail
|
||||
.of(data, properties.get(data.getString(ThingsDataConstants.COLUMN_PROPERTY_ID, null))),
|
||||
data.getData()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in New Issue