Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
谢明辉
/
VVAS-Match
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 5f7a0854
authored
Jan 26, 2022
by
xmh
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
添加gateId
1 parent
ed467aee
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
17 deletions
pom.xml
src/main/java/com/viontech/match/service/PersonService.java
src/main/java/com/viontech/match/service/PoolService.java
src/main/resources/application-option.properties
pom.xml
View file @
5f7a085
...
...
@@ -62,7 +62,7 @@
<dependency>
<groupId>
com.viontech.keliu
</groupId>
<artifactId>
AlgApiClient
</artifactId>
<version>
6.0.
8
-SNAPSHOT
</version>
<version>
6.0.
9
-SNAPSHOT
</version>
<exclusions>
<exclusion>
<groupId>
javax
</groupId>
...
...
src/main/java/com/viontech/match/service/PersonService.java
View file @
5f7a085
package
com
.
viontech
.
match
.
service
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.viontech.keliu.model.BodyFeature
;
import
com.viontech.keliu.model.FaceFeature
;
import
com.viontech.keliu.model.Person
;
...
...
@@ -10,6 +9,8 @@ import com.viontech.match.entity.vo.RequestVo;
import
com.viontech.match.entity.vo.ResponseVo
;
import
com.viontech.match.util.Utils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.elasticsearch.ElasticsearchStatusException
;
import
org.elasticsearch.action.bulk.BulkRequest
;
import
org.elasticsearch.action.bulk.BulkResponse
;
...
...
@@ -63,8 +64,6 @@ public class PersonService {
private
RestHighLevelClient
client
;
@Resource
private
PoolService
poolService
;
@Resource
private
ObjectMapper
objectMapper
;
/**
* 人员比对
...
...
@@ -91,7 +90,7 @@ public class PersonService {
if
(
poolId
!=
null
)
{
poolIds
.
add
(
poolId
);
}
log
.
info
(
"人员匹配操作开始,PoolIds:[{}]"
,
poolIds
.
toString
()
);
log
.
info
(
"人员匹配操作开始,PoolIds:[{}]"
,
poolIds
);
try
{
for
(
String
id
:
poolIds
)
{
Pool
pool
=
new
Pool
();
...
...
@@ -116,7 +115,7 @@ public class PersonService {
}
success
.
setMatch
(
1
);
success
.
setPersonPoolStatus
(
poolStatus
);
log
.
info
(
"人员匹配操作完成,PoolIds:[{}}"
,
poolIds
.
toString
()
);
log
.
info
(
"人员匹配操作完成,PoolIds:[{}}"
,
poolIds
);
return
success
;
}
catch
(
ElasticsearchStatusException
e
)
{
if
(
e
.
status
()
==
RestStatus
.
BAD_REQUEST
&&
e
.
getDetailedMessage
().
contains
(
Constant
.
CLASS_CAST_EXCEPTION
))
{
...
...
@@ -182,22 +181,24 @@ public class PersonService {
Integer
bodyType
=
person
.
getBodyType
();
String
personChannelSerialNum
=
person
.
getChannelSerialNum
();
List
<
FaceFeature
>
faceFeatures
=
person
.
getFaceFeatures
();
if
(
faceFeatures
!=
null
&&
faceFeatures
.
size
()
>
0
)
{
if
(
CollectionUtils
.
isNotEmpty
(
faceFeatures
)
)
{
for
(
FaceFeature
faceFeature
:
faceFeatures
)
{
Double
[]
feature
=
faceFeature
.
getFeature
();
if
(
feature
!=
null
&&
feature
.
length
==
Constant
.
FACE_FEATURE_DIMS
)
{
String
fid
=
faceFeature
.
getFid
();
String
unid
=
faceFeature
.
getUnid
();
Long
gateId
=
faceFeature
.
getGateId
();
IndexRequest
indexRequest
=
new
IndexRequest
(
poolId
)
.
source
(
XContentType
.
JSON
,
"personId"
,
personId
,
"unid"
,
unid
,
"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
);
}
}
}
List
<
BodyFeature
>
bodyFeatures
=
person
.
getBodyFeatures
();
if
(
bodyFeatures
!=
null
&&
bodyFeatures
.
size
()
>
0
)
{
if
(
CollectionUtils
.
isNotEmpty
(
bodyFeatures
)
)
{
for
(
BodyFeature
bodyFeature
:
bodyFeatures
)
{
Double
[]
feature
=
bodyFeature
.
getFeature
();
if
(
feature
==
null
||
feature
.
length
<
Constant
.
BODY_FEATURE_DIMS_2048
)
{
...
...
@@ -212,12 +213,14 @@ public class PersonService {
String
fid
=
bodyFeature
.
getBid
();
String
unid
=
bodyFeature
.
getUnid
();
Long
gateId
=
bodyFeature
.
getGateId
();
Date
counttime
=
bodyFeature
.
getCounttime
()
==
null
?
personCountTime
:
bodyFeature
.
getCounttime
();
String
channelSerialNum
=
bodyFeature
.
getChannelSerialNum
()
==
null
?
personChannelSerialNum
:
person
.
getChannelSerialNum
();
IndexRequest
indexRequest
=
new
IndexRequest
(
poolId
)
.
source
(
XContentType
.
JSON
,
"personId"
,
personId
,
"unid"
,
unid
,
"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
);
}
}
...
...
@@ -282,7 +285,7 @@ public class PersonService {
private
void
matchFace
(
String
poolId
,
List
<
Person
>
matchResult
,
Person
person
,
Integer
size
,
Boolean
agg
)
throws
Exception
{
List
<
FaceFeature
>
faceFeatures
=
person
.
getFaceFeatures
();
if
(
faceFeatures
!=
null
&&
faceFeatures
.
size
()
>
0
)
{
if
(
CollectionUtils
.
isNotEmpty
(
faceFeatures
)
)
{
for
(
FaceFeature
faceFeature
:
faceFeatures
)
{
Double
[]
feature
=
faceFeature
.
getFeature
();
if
(
feature
==
null
||
feature
.
length
!=
Constant
.
FACE_FEATURE_DIMS
)
{
...
...
@@ -300,7 +303,7 @@ public class PersonService {
private
void
matchBody
(
String
poolId
,
List
<
Person
>
matchResult
,
Person
person
,
Integer
size
,
Boolean
agg
)
throws
Exception
{
List
<
BodyFeature
>
bodyFeatures
=
person
.
getBodyFeatures
();
if
(
bodyFeatures
!=
null
&&
bodyFeatures
.
size
()
>
0
)
{
if
(
CollectionUtils
.
isNotEmpty
(
bodyFeatures
)
)
{
for
(
BodyFeature
faceFeature
:
bodyFeatures
)
{
Double
[]
feature
=
faceFeature
.
getFeature
();
if
(
feature
==
null
||
feature
.
length
<
Constant
.
BODY_FEATURE_DIMS_2048
)
{
...
...
@@ -338,10 +341,18 @@ public class PersonService {
// 根据通道号过滤
List
<
String
>
channelSerialNums
=
person
.
getChannelSerialNums
();
if
(
channelSerialNums
!=
null
&&
channelSerialNums
.
size
()
>
0
)
{
if
(
CollectionUtils
.
isNotEmpty
(
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
()));
}
...
...
@@ -359,7 +370,6 @@ public class PersonService {
boolQuery
.
filter
(
rangeQueryBuilder
);
}
ScriptScoreQueryBuilder
queryBuilder
=
QueryBuilders
.
scriptScoreQuery
(
boolQuery
,
script
);
SearchSourceBuilder
builder
=
new
SearchSourceBuilder
().
query
(
queryBuilder
);
if
(
agg
)
{
...
...
src/main/java/com/viontech/match/service/PoolService.java
View file @
5f7a085
...
...
@@ -7,6 +7,7 @@ import com.viontech.match.entity.PoolInfo;
import
com.viontech.match.entity.vo.RequestVo
;
import
com.viontech.match.entity.vo.ResponseVo
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.http.HttpEntity
;
import
org.elasticsearch.ElasticsearchStatusException
;
import
org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest
;
...
...
@@ -56,7 +57,7 @@ public class PoolService {
/**
* 添加特征池
*
* @param requestVo rid,
poolId,
personPool
* @param requestVo rid,
poolId,
personPool
*
* @return ResponseVo
* @throws Exception --
...
...
@@ -76,7 +77,7 @@ public class PoolService {
CreateIndexResponse
createIndexResponse
=
client
.
indices
().
create
(
createIndexRequest
,
RequestOptions
.
DEFAULT
);
List
<
Person
>
personPool
=
requestVo
.
getPersonPool
();
if
(
personPool
!=
null
&&
personPool
.
size
()
>
0
)
{
if
(
CollectionUtils
.
isNotEmpty
(
personPool
)
)
{
BulkResponse
bulkItemResponses
=
personService
.
addPerson
(
poolId
,
personPool
);
if
(
bulkItemResponses
!=
null
)
{
log
.
info
(
bulkItemResponses
.
buildFailureMessage
());
...
...
@@ -290,6 +291,12 @@ public class PoolService {
}
builder
.
endObject
();
// 监控点 ID
builder
.
startObject
(
"gateId"
);
{
builder
.
field
(
"type"
,
"long"
);
}
builder
.
endObject
();
}
builder
.
endObject
();
...
...
src/main/resources/application-option.properties
View file @
5f7a085
...
...
@@ -4,6 +4,8 @@ spring.jackson.time-zone=GMT+8
spring.jackson.date-
format
=
yyyy-MM-dd HH:mm:ss
# es
spring.elasticsearch.rest.uris
=
http://127.0.0.1:9200
spring.elasticsearch.rest.username
=
elastic
spring.elasticsearch.rest.password
=
vion2021
#\u5206\u7247\u6570\u91CF
vion.index.number_of_shards
=
1
#\u526F\u672C\u6570\u91CF
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment