视频数据统计修改
This commit is contained in:
1 parent
0280cf3f0b
commit
c387d44501
2 files changed
+26
-24
No files matched your search
@@ -74,11 +74,6 @@
|
|||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.whvcse</groupId>
|
|
||||||
<artifactId>easy-captcha</artifactId>
|
|
||||||
<version>1.6.2</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bouncycastle</groupId>
|
<groupId>org.bouncycastle</groupId>
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package net.hzvtc.service.impl;
|
|||||||
import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
||||||
import co.elastic.clients.elasticsearch._types.FieldValue;
|
import co.elastic.clients.elasticsearch._types.FieldValue;
|
||||||
import co.elastic.clients.elasticsearch._types.SortOrder;
|
import co.elastic.clients.elasticsearch._types.SortOrder;
|
||||||
import co.elastic.clients.elasticsearch._types.Time;
|
|
||||||
import co.elastic.clients.elasticsearch._types.aggregations.*;
|
import co.elastic.clients.elasticsearch._types.aggregations.*;
|
||||||
import co.elastic.clients.elasticsearch._types.query_dsl.BoolQuery;
|
import co.elastic.clients.elasticsearch._types.query_dsl.BoolQuery;
|
||||||
import co.elastic.clients.elasticsearch.core.SearchRequest;
|
import co.elastic.clients.elasticsearch.core.SearchRequest;
|
||||||
@@ -1310,7 +1309,7 @@ public class EsRecordReportServiceImpl implements EsRecordReportService {
|
|||||||
JSONObject obj = new JSONObject();
|
JSONObject obj = new JSONObject();
|
||||||
obj.put("speciesId", speciesId);
|
obj.put("speciesId", speciesId);
|
||||||
obj.put("speciesName", getSpeciesNameByName(speciesId, birdMap));
|
obj.put("speciesName", getSpeciesNameByName(speciesId, birdMap));
|
||||||
obj.put("count", (int) bucket.aggregations().get("sum_value").sum().value());
|
obj.put("count", (int) bucket.aggregations().get("parent_docs").reverseNested().aggregations().get("doc_count").valueCount().value());
|
||||||
array.add(obj);
|
array.add(obj);
|
||||||
});
|
});
|
||||||
object.put("list", array);
|
object.put("list", array);
|
||||||
@@ -1363,7 +1362,7 @@ public class EsRecordReportServiceImpl implements EsRecordReportService {
|
|||||||
searchRequest = new SearchRequest.Builder().index(validIndexName) //
|
searchRequest = new SearchRequest.Builder().index(validIndexName) //
|
||||||
.query(q -> q.bool(boolQueryBuilder.build())).size(0) //
|
.query(q -> q.bool(boolQueryBuilder.build())).size(0) //
|
||||||
.aggregations("by_record_time", agg -> agg.dateHistogram(t -> t.field("record_time").timeZone("+08:00")//
|
.aggregations("by_record_time", agg -> agg.dateHistogram(t -> t.field("record_time").timeZone("+08:00")//
|
||||||
.calendarInterval(CalendarInterval.Hour).format("HH").offset(Time.of(tm -> tm.time("-6h"))))//
|
.calendarInterval(CalendarInterval.Hour).format("HH"))//
|
||||||
.aggregations("by_media_type", mt -> mt.terms(t -> t.field("media_type").size(10)).aggregations("by_species_id", m -> m.terms(t -> t.field("species_id").size(10000))//
|
.aggregations("by_media_type", mt -> mt.terms(t -> t.field("media_type").size(10)).aggregations("by_species_id", m -> m.terms(t -> t.field("species_id").size(10000))//
|
||||||
.aggregations("sum_value", sumAgg -> sumAgg.sum(sm -> sm.field("count")))))).build();
|
.aggregations("sum_value", sumAgg -> sumAgg.sum(sm -> sm.field("count")))))).build();
|
||||||
} else {
|
} else {
|
||||||
@@ -1699,7 +1698,9 @@ public class EsRecordReportServiceImpl implements EsRecordReportService {
|
|||||||
List<FieldValue> fieldValues = idList.stream().map(FieldValue::of).collect(Collectors.toList());
|
List<FieldValue> fieldValues = idList.stream().map(FieldValue::of).collect(Collectors.toList());
|
||||||
return f.filter(ft -> ft.terms(t2 -> t2.field("items.species_id").terms(v -> v.value(fieldValues)))).aggregations("by_species_id",
|
return f.filter(ft -> ft.terms(t2 -> t2.field("items.species_id").terms(v -> v.value(fieldValues)))).aggregations("by_species_id",
|
||||||
d -> d.terms(t2 -> t2.field("items.species_id").size(10000)).aggregations("sum_value",
|
d -> d.terms(t2 -> t2.field("items.species_id").size(10000)).aggregations("sum_value",
|
||||||
sumAgg -> sumAgg.sum(m -> m.field("items.count"))));
|
sumAgg -> sumAgg.sum(m -> m.field("items.count"))).aggregations("parent_docs",
|
||||||
|
rn -> rn.reverseNested(r -> r).aggregations("doc_count",
|
||||||
|
vc -> vc.valueCount(m -> m.field("id")))));
|
||||||
} else {
|
} else {
|
||||||
String excludeIds = param.getString("excludeIds");
|
String excludeIds = param.getString("excludeIds");
|
||||||
if (excludeIds != null && !excludeIds.isEmpty()) {
|
if (excludeIds != null && !excludeIds.isEmpty()) {
|
||||||
@@ -1713,11 +1714,15 @@ public class EsRecordReportServiceImpl implements EsRecordReportService {
|
|||||||
return f.filter(ft -> ft.bool(b -> b.mustNot(mn -> mn.terms(t2 -> t2.field("items.species_id")
|
return f.filter(ft -> ft.bool(b -> b.mustNot(mn -> mn.terms(t2 -> t2.field("items.species_id")
|
||||||
.terms(v -> v.value(fieldValues)))))).aggregations("by_species_id",
|
.terms(v -> v.value(fieldValues)))))).aggregations("by_species_id",
|
||||||
d -> d.terms(t2 -> t2.field("items.species_id").size(10000))
|
d -> d.terms(t2 -> t2.field("items.species_id").size(10000))
|
||||||
.aggregations("sum_value", sumAgg -> sumAgg.sum(m -> m.field("items.count"))));
|
.aggregations("sum_value", sumAgg -> sumAgg.sum(m -> m.field("items.count")))
|
||||||
|
.aggregations("parent_docs", rn -> rn.reverseNested(r -> r)
|
||||||
|
.aggregations("doc_count", vc -> vc.valueCount(m -> m.field("id")))));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return f.aggregations("by_species_id", d -> d.terms(t2 -> t2.field("items.species_id").size(10000))
|
return f.aggregations("by_species_id", d -> d.terms(t2 -> t2.field("items.species_id").size(10000))
|
||||||
.aggregations("sum_value", sumAgg -> sumAgg.sum(m -> m.field("items.count"))));
|
.aggregations("sum_value", sumAgg -> sumAgg.sum(m -> m.field("items.count")))
|
||||||
|
.aggregations("parent_docs", rn -> rn.reverseNested(r -> r)
|
||||||
|
.aggregations("doc_count", vc -> vc.valueCount(m -> m.field("id")))));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1734,7 +1739,7 @@ public class EsRecordReportServiceImpl implements EsRecordReportService {
|
|||||||
.format(dateFormat)//
|
.format(dateFormat)//
|
||||||
.minDocCount(0)).aggregations("by_media_type", mt -> mt.terms(t -> t.field("media_type").size(10))
|
.minDocCount(0)).aggregations("by_media_type", mt -> mt.terms(t -> t.field("media_type").size(10))
|
||||||
.aggregations("by_species_id", d -> d.terms(s -> s.field("species_id").size(10000))
|
.aggregations("by_species_id", d -> d.terms(s -> s.field("species_id").size(10000))
|
||||||
.aggregations("sum_value", sumAgg -> sumAgg.sum(m -> m.field("count")))))).build();
|
.aggregations("media_count", m -> m.cardinality(c2 -> c2.field("media_id")))))).build();
|
||||||
try {
|
try {
|
||||||
SearchResponse<Void> searchResponse = elasticsearchClient.search(searchRequest, Void.class);
|
SearchResponse<Void> searchResponse = elasticsearchClient.search(searchRequest, Void.class);
|
||||||
List<JSONObject> array = new ArrayList<>();
|
List<JSONObject> array = new ArrayList<>();
|
||||||
@@ -1762,9 +1767,9 @@ public class EsRecordReportServiceImpl implements EsRecordReportService {
|
|||||||
obj = new JSONObject();
|
obj = new JSONObject();
|
||||||
obj.put("speciesId", speciesId);
|
obj.put("speciesId", speciesId);
|
||||||
obj.put("speciesName", getSpeciesNameByName(speciesId, birdMap));
|
obj.put("speciesName", getSpeciesNameByName(speciesId, birdMap));
|
||||||
obj.put(key, (int) bucket.aggregations().get("sum_value").sum().value());
|
obj.put(key, (int) bucket.aggregations().get("media_count").cardinality().value());
|
||||||
} else {
|
} else {
|
||||||
obj.put(key, (int) bucket.aggregations().get("sum_value").sum().value());
|
obj.put(key, (int) bucket.aggregations().get("media_count").cardinality().value());
|
||||||
}
|
}
|
||||||
map.put(speciesId, obj);
|
map.put(speciesId, obj);
|
||||||
});
|
});
|
||||||
@@ -1824,9 +1829,9 @@ public class EsRecordReportServiceImpl implements EsRecordReportService {
|
|||||||
obj = new JSONObject();
|
obj = new JSONObject();
|
||||||
obj.put("speciesId", speciesId);
|
obj.put("speciesId", speciesId);
|
||||||
obj.put("speciesName", getSpeciesNameByName(speciesId, birdMap));
|
obj.put("speciesName", getSpeciesNameByName(speciesId, birdMap));
|
||||||
obj.put(key, (int) bucket.aggregations().get("sum_value").sum().value());
|
obj.put(key, (int) bucket.aggregations().get("parent_docs").reverseNested().aggregations().get("doc_count").valueCount().value());
|
||||||
} else {
|
} else {
|
||||||
obj.put(key, (int) bucket.aggregations().get("sum_value").sum().value());
|
obj.put(key, (int) bucket.aggregations().get("parent_docs").reverseNested().aggregations().get("doc_count").valueCount().value());
|
||||||
}
|
}
|
||||||
map.put(speciesId, obj);
|
map.put(speciesId, obj);
|
||||||
});
|
});
|
||||||
@@ -1940,7 +1945,9 @@ public class EsRecordReportServiceImpl implements EsRecordReportService {
|
|||||||
.aggregations("by_device_id", Aggregation.of(a -> a.terms(TermsAggregation.of(t -> t.field("device_id").size(10000))) //
|
.aggregations("by_device_id", Aggregation.of(a -> a.terms(TermsAggregation.of(t -> t.field("device_id").size(10000))) //
|
||||||
.aggregations("by_media_type", Aggregation.of(mt -> mt.terms(TermsAggregation.of(t -> t.field("media_type").size(10))) //
|
.aggregations("by_media_type", Aggregation.of(mt -> mt.terms(TermsAggregation.of(t -> t.field("media_type").size(10))) //
|
||||||
.aggregations("items_path", Aggregation.of(n -> n.nested(ne -> ne.path("items")) //
|
.aggregations("items_path", Aggregation.of(n -> n.nested(ne -> ne.path("items")) //
|
||||||
.aggregations("by_species_id", Aggregation.of(c -> c.terms(TermsAggregation.of(t -> t.field("items.species_id").size(10000))))))))))).build();
|
.aggregations("by_species_id", Aggregation.of(c -> c.terms(TermsAggregation.of(t -> t.field("items.species_id").size(10000)))
|
||||||
|
.aggregations("parent_docs", Aggregation.of(rn -> rn.reverseNested(r -> r)
|
||||||
|
.aggregations("doc_count", Aggregation.of(vc -> vc.valueCount(m -> m.field("id")))))))))))))).build();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Map<Long, String> birdMap = new HashMap<>();
|
Map<Long, String> birdMap = new HashMap<>();
|
||||||
@@ -1972,7 +1979,7 @@ public class EsRecordReportServiceImpl implements EsRecordReportService {
|
|||||||
long speciesId = speciesBucket.key();
|
long speciesId = speciesBucket.key();
|
||||||
sub.put("speciesId", speciesId);
|
sub.put("speciesId", speciesId);
|
||||||
sub.put("speciesName", getSpeciesNameByName(speciesId, birdMap));
|
sub.put("speciesName", getSpeciesNameByName(speciesId, birdMap));
|
||||||
sub.put("count", speciesBucket.docCount());
|
sub.put("count", (int) speciesBucket.aggregations().get("parent_docs").reverseNested().aggregations().get("doc_count").valueCount().value());
|
||||||
// 根据媒体类型分类存放,2通常代表图片,3通常代表视频
|
// 根据媒体类型分类存放,2通常代表图片,3通常代表视频
|
||||||
if (mediaType == 2) {
|
if (mediaType == 2) {
|
||||||
imgList.add(sub);
|
imgList.add(sub);
|
||||||
@@ -2132,8 +2139,8 @@ public class EsRecordReportServiceImpl implements EsRecordReportService {
|
|||||||
.query(q -> q.bool(boolQueryBuilder.build())).size(0) //
|
.query(q -> q.bool(boolQueryBuilder.build())).size(0) //
|
||||||
.aggregations("by_media_type", Aggregation.of(a -> a.terms(TermsAggregation.of(t -> t.field("media_type").size(10) //
|
.aggregations("by_media_type", Aggregation.of(a -> a.terms(TermsAggregation.of(t -> t.field("media_type").size(10) //
|
||||||
))//
|
))//
|
||||||
.aggregations("by_species_id", Aggregation.of(c -> c.terms(TermsAggregation.of(t -> t.field("species_id").size(10000))).aggregations("sum_value",//
|
.aggregations("by_species_id", Aggregation.of(c -> c.terms(TermsAggregation.of(t -> t.field("species_id").size(10000)))
|
||||||
sumAgg -> sumAgg.sum(m -> m.field("count"))))))).build();
|
.aggregations("media_count", Aggregation.of(m -> m.cardinality(c2 -> c2.field("media_id")))))))).build();
|
||||||
try {
|
try {
|
||||||
SearchResponse<Void> searchResponse = elasticsearchClient.search(searchRequest, Void.class);
|
SearchResponse<Void> searchResponse = elasticsearchClient.search(searchRequest, Void.class);
|
||||||
Map<String, Aggregate> aggregations = searchResponse.aggregations();
|
Map<String, Aggregate> aggregations = searchResponse.aggregations();
|
||||||
@@ -2153,9 +2160,9 @@ public class EsRecordReportServiceImpl implements EsRecordReportService {
|
|||||||
obj = new JSONObject();
|
obj = new JSONObject();
|
||||||
obj.put("speciesId", speciesId);
|
obj.put("speciesId", speciesId);
|
||||||
obj.put("speciesName", getSpeciesNameByName(speciesId, birdMap));
|
obj.put("speciesName", getSpeciesNameByName(speciesId, birdMap));
|
||||||
obj.put(key, (int) bucket.aggregations().get("sum_value").sum().value());
|
obj.put(key, (int) bucket.aggregations().get("media_count").cardinality().value());
|
||||||
} else {
|
} else {
|
||||||
obj.put(key, (int) bucket.aggregations().get("sum_value").sum().value());
|
obj.put(key, (int) bucket.aggregations().get("media_count").cardinality().value());
|
||||||
}
|
}
|
||||||
map.put(speciesId, obj);
|
map.put(speciesId, obj);
|
||||||
});
|
});
|
||||||
@@ -2342,9 +2349,9 @@ public class EsRecordReportServiceImpl implements EsRecordReportService {
|
|||||||
obj = new JSONObject();
|
obj = new JSONObject();
|
||||||
obj.put("speciesId", speciesId);
|
obj.put("speciesId", speciesId);
|
||||||
obj.put("speciesName", getSpeciesNameByName(speciesId, birdMap));
|
obj.put("speciesName", getSpeciesNameByName(speciesId, birdMap));
|
||||||
obj.put(key, (int) bucket.aggregations().get("sum_value").sum().value());
|
obj.put(key, (int) bucket.aggregations().get("parent_docs").reverseNested().aggregations().get("doc_count").valueCount().value());
|
||||||
} else {
|
} else {
|
||||||
obj.put(key, (int) bucket.aggregations().get("sum_value").sum().value());
|
obj.put(key, (int) bucket.aggregations().get("parent_docs").reverseNested().aggregations().get("doc_count").valueCount().value());
|
||||||
}
|
}
|
||||||
map.put(speciesId, obj);
|
map.put(speciesId, obj);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user