Commit 5f7a0854 by xmh

添加gateId

1 parent ed467aee
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
<dependency> <dependency>
<groupId>com.viontech.keliu</groupId> <groupId>com.viontech.keliu</groupId>
<artifactId>AlgApiClient</artifactId> <artifactId>AlgApiClient</artifactId>
<version>6.0.8-SNAPSHOT</version> <version>6.0.9-SNAPSHOT</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>javax</groupId> <groupId>javax</groupId>
......
package com.viontech.match.service; package com.viontech.match.service;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.viontech.keliu.model.BodyFeature; import com.viontech.keliu.model.BodyFeature;
import com.viontech.keliu.model.FaceFeature; import com.viontech.keliu.model.FaceFeature;
import com.viontech.keliu.model.Person; import com.viontech.keliu.model.Person;
...@@ -10,6 +9,8 @@ import com.viontech.match.entity.vo.RequestVo; ...@@ -10,6 +9,8 @@ import com.viontech.match.entity.vo.RequestVo;
import com.viontech.match.entity.vo.ResponseVo; import com.viontech.match.entity.vo.ResponseVo;
import com.viontech.match.util.Utils; import com.viontech.match.util.Utils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.ElasticsearchStatusException; import org.elasticsearch.ElasticsearchStatusException;
import org.elasticsearch.action.bulk.BulkRequest; import org.elasticsearch.action.bulk.BulkRequest;
import org.elasticsearch.action.bulk.BulkResponse; import org.elasticsearch.action.bulk.BulkResponse;
...@@ -63,8 +64,6 @@ public class PersonService { ...@@ -63,8 +64,6 @@ public class PersonService {
private RestHighLevelClient client; private RestHighLevelClient client;
@Resource @Resource
private PoolService poolService; private PoolService poolService;
@Resource
private ObjectMapper objectMapper;
/** /**
* 人员比对 * 人员比对
...@@ -91,7 +90,7 @@ public class PersonService { ...@@ -91,7 +90,7 @@ public class PersonService {
if (poolId != null) { if (poolId != null) {
poolIds.add(poolId); poolIds.add(poolId);
} }
log.info("人员匹配操作开始,PoolIds:[{}]", poolIds.toString()); log.info("人员匹配操作开始,PoolIds:[{}]", poolIds);
try { try {
for (String id : poolIds) { for (String id : poolIds) {
Pool pool = new Pool(); Pool pool = new Pool();
...@@ -116,7 +115,7 @@ public class PersonService { ...@@ -116,7 +115,7 @@ public class PersonService {
} }
success.setMatch(1); success.setMatch(1);
success.setPersonPoolStatus(poolStatus); success.setPersonPoolStatus(poolStatus);
log.info("人员匹配操作完成,PoolIds:[{}}", poolIds.toString()); log.info("人员匹配操作完成,PoolIds:[{}}", poolIds);
return success; return success;
} catch (ElasticsearchStatusException e) { } catch (ElasticsearchStatusException e) {
if (e.status() == RestStatus.BAD_REQUEST && e.getDetailedMessage().contains(Constant.CLASS_CAST_EXCEPTION)) { if (e.status() == RestStatus.BAD_REQUEST && e.getDetailedMessage().contains(Constant.CLASS_CAST_EXCEPTION)) {
...@@ -182,22 +181,24 @@ public class PersonService { ...@@ -182,22 +181,24 @@ public class PersonService {
Integer bodyType = person.getBodyType(); Integer bodyType = person.getBodyType();
String personChannelSerialNum = person.getChannelSerialNum(); String personChannelSerialNum = person.getChannelSerialNum();
List<FaceFeature> faceFeatures = person.getFaceFeatures(); List<FaceFeature> faceFeatures = person.getFaceFeatures();
if (faceFeatures != null && faceFeatures.size() > 0) { if (CollectionUtils.isNotEmpty(faceFeatures)) {
for (FaceFeature faceFeature : faceFeatures) { for (FaceFeature faceFeature : faceFeatures) {
Double[] feature = faceFeature.getFeature(); Double[] feature = faceFeature.getFeature();
if (feature != null && feature.length == Constant.FACE_FEATURE_DIMS) { if (feature != null && feature.length == Constant.FACE_FEATURE_DIMS) {
String fid = faceFeature.getFid(); String fid = faceFeature.getFid();
String unid = faceFeature.getUnid(); String unid = faceFeature.getUnid();
Long gateId = faceFeature.getGateId();
IndexRequest indexRequest = new IndexRequest(poolId) IndexRequest indexRequest = new IndexRequest(poolId)
.source(XContentType.JSON, "personId", personId, "unid", unid, .source(XContentType.JSON, "personId", personId, "unid", unid,
"data", feature, "fid", fid, "age", age, "gender", gender, "body_type", bodyType, "data", feature, "fid", fid, "age", age, "gender", gender, "body_type", bodyType,
"counttime", personCountTime == null ? null : Constant.DATE_FORMAT.get().format(personCountTime), "channelSerialNum", personChannelSerialNum); "counttime", personCountTime == null ? null : Constant.DATE_FORMAT.get().format(personCountTime),
"channelSerialNum", personChannelSerialNum, "gateId", gateId);
bulkRequest.add(indexRequest); bulkRequest.add(indexRequest);
} }
} }
} }
List<BodyFeature> bodyFeatures = person.getBodyFeatures(); List<BodyFeature> bodyFeatures = person.getBodyFeatures();
if (bodyFeatures != null && bodyFeatures.size() > 0) { if (CollectionUtils.isNotEmpty(bodyFeatures)) {
for (BodyFeature bodyFeature : bodyFeatures) { for (BodyFeature bodyFeature : bodyFeatures) {
Double[] feature = bodyFeature.getFeature(); Double[] feature = bodyFeature.getFeature();
if (feature == null || feature.length < Constant.BODY_FEATURE_DIMS_2048) { if (feature == null || feature.length < Constant.BODY_FEATURE_DIMS_2048) {
...@@ -212,12 +213,14 @@ public class PersonService { ...@@ -212,12 +213,14 @@ public class PersonService {
String fid = bodyFeature.getBid(); String fid = bodyFeature.getBid();
String unid = bodyFeature.getUnid(); String unid = bodyFeature.getUnid();
Long gateId = bodyFeature.getGateId();
Date counttime = bodyFeature.getCounttime() == null ? personCountTime : bodyFeature.getCounttime(); Date counttime = bodyFeature.getCounttime() == null ? personCountTime : bodyFeature.getCounttime();
String channelSerialNum = bodyFeature.getChannelSerialNum() == null ? personChannelSerialNum : person.getChannelSerialNum(); String channelSerialNum = bodyFeature.getChannelSerialNum() == null ? personChannelSerialNum : person.getChannelSerialNum();
IndexRequest indexRequest = new IndexRequest(poolId) IndexRequest indexRequest = new IndexRequest(poolId)
.source(XContentType.JSON, "personId", personId, "unid", unid, .source(XContentType.JSON, "personId", personId, "unid", unid,
"body", feature, "fid", fid, "age", age, "gender", gender, "body_type", bodyType, "body", feature, "fid", fid, "age", age, "gender", gender, "body_type", bodyType,
"counttime", counttime == null ? null : Constant.DATE_FORMAT.get().format(counttime), "channelSerialNum", channelSerialNum); "counttime", counttime == null ? null : Constant.DATE_FORMAT.get().format(counttime)
, "channelSerialNum", channelSerialNum, "gateId", gateId);
bulkRequest.add(indexRequest); bulkRequest.add(indexRequest);
} }
} }
...@@ -282,7 +285,7 @@ public class PersonService { ...@@ -282,7 +285,7 @@ public class PersonService {
private void matchFace(String poolId, List<Person> matchResult, Person person, Integer size, Boolean agg) throws Exception { private void matchFace(String poolId, List<Person> matchResult, Person person, Integer size, Boolean agg) throws Exception {
List<FaceFeature> faceFeatures = person.getFaceFeatures(); List<FaceFeature> faceFeatures = person.getFaceFeatures();
if (faceFeatures != null && faceFeatures.size() > 0) { if (CollectionUtils.isNotEmpty(faceFeatures)) {
for (FaceFeature faceFeature : faceFeatures) { for (FaceFeature faceFeature : faceFeatures) {
Double[] feature = faceFeature.getFeature(); Double[] feature = faceFeature.getFeature();
if (feature == null || feature.length != Constant.FACE_FEATURE_DIMS) { if (feature == null || feature.length != Constant.FACE_FEATURE_DIMS) {
...@@ -300,7 +303,7 @@ public class PersonService { ...@@ -300,7 +303,7 @@ public class PersonService {
private void matchBody(String poolId, List<Person> matchResult, Person person, Integer size, Boolean agg) throws Exception { private void matchBody(String poolId, List<Person> matchResult, Person person, Integer size, Boolean agg) throws Exception {
List<BodyFeature> bodyFeatures = person.getBodyFeatures(); List<BodyFeature> bodyFeatures = person.getBodyFeatures();
if (bodyFeatures != null && bodyFeatures.size() > 0) { if (CollectionUtils.isNotEmpty(bodyFeatures)) {
for (BodyFeature faceFeature : bodyFeatures) { for (BodyFeature faceFeature : bodyFeatures) {
Double[] feature = faceFeature.getFeature(); Double[] feature = faceFeature.getFeature();
if (feature == null || feature.length < Constant.BODY_FEATURE_DIMS_2048) { if (feature == null || feature.length < Constant.BODY_FEATURE_DIMS_2048) {
...@@ -338,10 +341,18 @@ public class PersonService { ...@@ -338,10 +341,18 @@ public class PersonService {
// 根据通道号过滤 // 根据通道号过滤
List<String> channelSerialNums = person.getChannelSerialNums(); List<String> channelSerialNums = person.getChannelSerialNums();
if (channelSerialNums != null && channelSerialNums.size() > 0) { if (CollectionUtils.isNotEmpty(channelSerialNums)) {
boolQuery.filter(QueryBuilders.termsQuery("channelSerialNum", channelSerialNums)); boolQuery.filter(QueryBuilders.termsQuery("channelSerialNum", channelSerialNums));
} }
if (person.getPersonUnid() != null && !person.getPersonUnid().equals("")) {
// 根据监控点id进行过滤
List<Long> gateIdIn = person.getGateIdIn();
if (CollectionUtils.isNotEmpty(gateIdIn)) {
boolQuery.filter(QueryBuilders.termsQuery("gateId", gateIdIn));
}
// 根据人的ID进行过滤
if (StringUtils.isNotEmpty(person.getPersonUnid())) {
boolQuery.filter(QueryBuilders.termQuery("personId", person.getPersonUnid())); boolQuery.filter(QueryBuilders.termQuery("personId", person.getPersonUnid()));
} }
...@@ -359,7 +370,6 @@ public class PersonService { ...@@ -359,7 +370,6 @@ public class PersonService {
boolQuery.filter(rangeQueryBuilder); boolQuery.filter(rangeQueryBuilder);
} }
ScriptScoreQueryBuilder queryBuilder = QueryBuilders.scriptScoreQuery(boolQuery, script); ScriptScoreQueryBuilder queryBuilder = QueryBuilders.scriptScoreQuery(boolQuery, script);
SearchSourceBuilder builder = new SearchSourceBuilder().query(queryBuilder); SearchSourceBuilder builder = new SearchSourceBuilder().query(queryBuilder);
if (agg) { if (agg) {
......
...@@ -7,6 +7,7 @@ import com.viontech.match.entity.PoolInfo; ...@@ -7,6 +7,7 @@ import com.viontech.match.entity.PoolInfo;
import com.viontech.match.entity.vo.RequestVo; import com.viontech.match.entity.vo.RequestVo;
import com.viontech.match.entity.vo.ResponseVo; import com.viontech.match.entity.vo.ResponseVo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.http.HttpEntity; import org.apache.http.HttpEntity;
import org.elasticsearch.ElasticsearchStatusException; import org.elasticsearch.ElasticsearchStatusException;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
...@@ -56,7 +57,7 @@ public class PoolService { ...@@ -56,7 +57,7 @@ public class PoolService {
/** /**
* 添加特征池 * 添加特征池
* *
* @param requestVo rid,poolId,personPool * @param requestVo rid, poolId, personPool
* *
* @return ResponseVo * @return ResponseVo
* @throws Exception -- * @throws Exception --
...@@ -76,7 +77,7 @@ public class PoolService { ...@@ -76,7 +77,7 @@ public class PoolService {
CreateIndexResponse createIndexResponse = client.indices().create(createIndexRequest, RequestOptions.DEFAULT); CreateIndexResponse createIndexResponse = client.indices().create(createIndexRequest, RequestOptions.DEFAULT);
List<Person> personPool = requestVo.getPersonPool(); List<Person> personPool = requestVo.getPersonPool();
if (personPool != null && personPool.size() > 0) { if (CollectionUtils.isNotEmpty(personPool)) {
BulkResponse bulkItemResponses = personService.addPerson(poolId, personPool); BulkResponse bulkItemResponses = personService.addPerson(poolId, personPool);
if (bulkItemResponses != null) { if (bulkItemResponses != null) {
log.info(bulkItemResponses.buildFailureMessage()); log.info(bulkItemResponses.buildFailureMessage());
...@@ -290,6 +291,12 @@ public class PoolService { ...@@ -290,6 +291,12 @@ public class PoolService {
} }
builder.endObject(); builder.endObject();
// 监控点 ID
builder.startObject("gateId");
{
builder.field("type", "long");
}
builder.endObject();
} }
builder.endObject(); builder.endObject();
......
...@@ -4,6 +4,8 @@ spring.jackson.time-zone=GMT+8 ...@@ -4,6 +4,8 @@ spring.jackson.time-zone=GMT+8
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
# es # es
spring.elasticsearch.rest.uris=http://127.0.0.1:9200 spring.elasticsearch.rest.uris=http://127.0.0.1:9200
spring.elasticsearch.rest.username=elastic
spring.elasticsearch.rest.password=vion2021
#\u5206\u7247\u6570\u91CF #\u5206\u7247\u6570\u91CF
vion.index.number_of_shards=1 vion.index.number_of_shards=1
#\u526F\u672C\u6570\u91CF #\u526F\u672C\u6570\u91CF
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!