class AggRecordRankDimension implements MeasurementDimension {

        @Override
        public DimensionDefinition getDefinition() {
            return CommonDimensionDefinition.agg;
        }

        @Override
        public DataType getValueType() {
            return IntType.GLOBAL;
        }

        @Override
        public ConfigMetadata getParams() {
            return aggConfigMetadata;
        }

        @Override
        public boolean isRealTime() {
            return false;
        }

        public AggregationQueryParam createQueryParam(MeasurementParameter parameter) {<FILL_FUNCTION_BODY>}

        @Override
        public Flux<SimpleMeasurementValue> getValue(MeasurementParameter parameter) {

            Comparator<AggregationData> comparator;
            if (Objects.equals(parameter.getString("order",""), "asc")){
                 comparator = Comparator.comparingLong(d-> d.getLong("count", 0L));
            }else {
                comparator = Comparator.<AggregationData>comparingLong(d-> d.getLong("count", 0L)).reversed();
            }

            AggregationQueryParam param = createQueryParam(parameter);

            return Flux.defer(() -> param
                .execute(timeSeriesManager.getService(AlarmTimeSeriesMetric.alarmStreamMetrics())::aggregation)
                .groupBy(a -> a.getString("targetId", null))
                .flatMap(fluxGroup -> fluxGroup.reduce(AggregationData::merge))
                .sort(comparator)
                .map(data -> SimpleMeasurementValue.of(new SimpleResult(data), 0))
            )
                .take(param.getLimit());
        }

        @Getter
        @Setter
        @AllArgsConstructor
        @NoArgsConstructor
        class SimpleResult {

            private String targetId;

            private String targetName;

            private long count;

            public SimpleResult(AggregationData data) {
                String targetId = data.getString("targetId", "");
                this.setCount(data.getLong("count", 0L));
                this.setTargetName(data.getString("targetName", targetId));
                this.setTargetId(data.getString("targetId", ""));
            }
        }
    }

            return AggregationQueryParam
                .of()
                .groupBy(parameter.getString("group", "targetId"))
                .sum("count", "count")
                .agg("targetId", Aggregation.TOP)
                .filter(query -> query
                    .where("name", "record-agg")
                    .where("targetType", parameter.getString("targetType", null))
                )
                .limit(parameter.getInt("limit").orElse(1))
                .from(parameter
                          .getDate("from")
                          .orElseGet(() -> Date
                              .from(LocalDateTime
                                        .now()
                                        .plusDays(-1)
                                        .atZone(ZoneId.systemDefault())
                                        .toInstant())))
                .to(parameter.getDate("to").orElse(new Date()));
        
<methods>public void <init>(org.jetlinks.community.dashboard.MeasurementDefinition) ,public org.jetlinks.community.dashboard.supports.StaticMeasurement addDimension(org.jetlinks.community.dashboard.MeasurementDimension) ,public Mono<org.jetlinks.community.dashboard.MeasurementDimension> getDimension(java.lang.String) ,public Flux<org.jetlinks.community.dashboard.MeasurementDimension> getDimensions() <variables>private org.jetlinks.community.dashboard.MeasurementDefinition definition,private Map<java.lang.String,org.jetlinks.community.dashboard.MeasurementDimension> dimensions