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 3dd43c87
authored
Jan 24, 2025
by
毛树良
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
<chg>:升级springboot2.5.1至3.4.1
1 parent
97494f0c
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
192 additions
and
163 deletions
pom.xml
src/main/java/com/viontech/match/config/ElasticsearchConfiguration.java
src/main/java/com/viontech/match/controller/MainController.java
src/main/java/com/viontech/match/service/PersonPoolService.java
src/main/java/com/viontech/match/service/PersonService.java
src/main/java/com/viontech/match/service/PoolService.java
src/main/resources/application-option.properties
src/main/resources/logback-spring.xml
pom.xml
View file @
3dd43c8
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
<parent>
<parent>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-parent
</artifactId>
<artifactId>
spring-boot-starter-parent
</artifactId>
<version>
2.5
.1
</version>
<version>
3.4
.1
</version>
<relativePath
/>
<!-- lookup parent from repository -->
<relativePath
/>
<!-- lookup parent from repository -->
</parent>
</parent>
<groupId>
com.viontech
</groupId>
<groupId>
com.viontech
</groupId>
...
@@ -14,7 +14,8 @@
...
@@ -14,7 +14,8 @@
<packaging>
jar
</packaging>
<packaging>
jar
</packaging>
<properties>
<properties>
<java.version>
1.8
</java.version>
<java.version>
21
</java.version>
<logback.version>
1.5.15
</logback.version>
<skipTests>
true
</skipTests>
<skipTests>
true
</skipTests>
</properties>
</properties>
...
@@ -22,7 +23,6 @@
...
@@ -22,7 +23,6 @@
<dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter
</artifactId>
<artifactId>
spring-boot-starter
</artifactId>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
...
@@ -43,12 +43,6 @@
...
@@ -43,12 +43,6 @@
<dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
<artifactId>
spring-boot-starter-web
</artifactId>
<exclusions>
<exclusion>
<groupId>
com.fasterxml.jackson.core
</groupId>
<artifactId>
jackson-databind
</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependency>
<!-- <dependency>-->
<!-- <dependency>-->
...
@@ -92,43 +86,24 @@
...
@@ -92,43 +86,24 @@
<dependency>
<dependency>
<groupId>
co.elastic.clients
</groupId>
<groupId>
co.elastic.clients
</groupId>
<artifactId>
elasticsearch-java
</artifactId>
<artifactId>
elasticsearch-java
</artifactId>
<version>
8.15.
0
</version>
<version>
8.15.
5
</version>
<exclusions>
<exclusions>
<exclusion>
<exclusion>
<groupId>
jakarta.json
</groupId>
<artifactId>
jakarta.json-api
</artifactId>
</exclusion>
<exclusion>
<artifactId>
elasticsearch-rest-client
</artifactId>
<artifactId>
elasticsearch-rest-client
</artifactId>
<groupId>
org.elasticsearch.client
</groupId>
<groupId>
org.elasticsearch.client
</groupId>
</exclusion>
</exclusion>
</exclusions>
</exclusions>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.fasterxml.jackson.core
</groupId>
<artifactId>
jackson-databind
</artifactId>
<version>
2.17.0
</version>
</dependency>
<dependency>
<groupId>
com.fasterxml.jackson.core
</groupId>
<artifactId>
jackson-databind
</artifactId>
<version>
2.12.3
</version>
</dependency>
<dependency>
<artifactId>
elasticsearch-rest-client
</artifactId>
<artifactId>
elasticsearch-rest-client
</artifactId>
<groupId>
org.elasticsearch.client
</groupId>
<groupId>
org.elasticsearch.client
</groupId>
<version>
8.15.0
</version>
<version>
8.15.5
</version>
</dependency>
<dependency>
<groupId>
jakarta.json
</groupId>
<artifactId>
jakarta.json-api
</artifactId>
<version>
2.0.1
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.viontech.keliu
</groupId>
<groupId>
com.viontech.keliu
</groupId>
<artifactId>
AlgApiClient
</artifactId>
<artifactId>
AlgApiClient
</artifactId>
<version>
6.
1
.0-SNAPSHOT
</version>
<version>
6.
2
.0-SNAPSHOT
</version>
<exclusions>
<exclusions>
<exclusion>
<exclusion>
<groupId>
javax
</groupId>
<groupId>
javax
</groupId>
...
@@ -169,6 +144,18 @@
...
@@ -169,6 +144,18 @@
<finalName>
VVAS-Match
</finalName>
<finalName>
VVAS-Match
</finalName>
<plugins>
<plugins>
<plugin>
<plugin>
<groupId>
org.owasp
</groupId>
<artifactId>
dependency-check-maven
</artifactId>
<version>
11.1.1
</version>
<executions>
<execution>
<goals>
<goal>
check
</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
</plugin>
</plugin>
...
@@ -184,8 +171,8 @@
...
@@ -184,8 +171,8 @@
<plugin>
<plugin>
<artifactId>
maven-compiler-plugin
</artifactId>
<artifactId>
maven-compiler-plugin
</artifactId>
<configuration>
<configuration>
<source>
1.8
</source>
<source>
21
</source>
<target>
1.8
</target>
<target>
21
</target>
<encoding>
UTF-8
</encoding>
<encoding>
UTF-8
</encoding>
</configuration>
</configuration>
</plugin>
</plugin>
...
...
src/main/java/com/viontech/match/config/ElasticsearchConfiguration.java
View file @
3dd43c8
...
@@ -35,7 +35,7 @@ import java.security.cert.X509Certificate;
...
@@ -35,7 +35,7 @@ import java.security.cert.X509Certificate;
public
class
ElasticsearchConfiguration
{
public
class
ElasticsearchConfiguration
{
@Bean
@Bean
@ConfigurationProperties
(
prefix
=
"spring.elasticsearch
.rest
"
)
@ConfigurationProperties
(
prefix
=
"spring.elasticsearch"
)
public
CustomElasticsearchProperties
Properties
()
{
public
CustomElasticsearchProperties
Properties
()
{
return
new
CustomElasticsearchProperties
();
return
new
CustomElasticsearchProperties
();
}
}
...
...
src/main/java/com/viontech/match/controller/MainController.java
View file @
3dd43c8
...
@@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestBody;
...
@@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
ja
vax
.annotation.Resource
;
import
ja
karta
.annotation.Resource
;
import
java.io.IOException
;
import
java.io.IOException
;
/**
/**
...
...
src/main/java/com/viontech/match/service/PersonPoolService.java
0 → 100644
View file @
3dd43c8
package
com
.
viontech
.
match
.
service
;
import
co.elastic.clients.elasticsearch.ElasticsearchClient
;
import
co.elastic.clients.elasticsearch._types.FieldValue
;
import
co.elastic.clients.elasticsearch._types.query_dsl.QueryBuilders
;
import
co.elastic.clients.elasticsearch._types.query_dsl.TermsQueryField
;
import
co.elastic.clients.elasticsearch.core.BulkRequest
;
import
co.elastic.clients.elasticsearch.core.BulkResponse
;
import
co.elastic.clients.elasticsearch.core.DeleteByQueryRequest
;
import
co.elastic.clients.elasticsearch.core.DeleteByQueryResponse
;
import
co.elastic.clients.elasticsearch.core.bulk.BulkOperation
;
import
co.elastic.clients.elasticsearch.core.bulk.IndexOperation
;
import
com.viontech.keliu.model.BodyFeature
;
import
com.viontech.keliu.model.FaceFeature
;
import
com.viontech.keliu.model.Person
;
import
com.viontech.match.config.Constant
;
import
com.viontech.match.entity.PersonInfo
;
import
com.viontech.match.util.Utils
;
import
jakarta.annotation.Resource
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.stereotype.Service
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@Service
@Slf4j
public
class
PersonPoolService
{
@Resource
private
ElasticsearchClient
client
;
/**
* 添加人员
*
* @param poolId 特征池Id
* @param personPool 要添加的人员列表
*
* @return 批量添加的结果
* @throws IOException elasticsearch 所产生的异常
*/
public
BulkResponse
addPerson
(
String
poolId
,
List
<
Person
>
personPool
)
throws
IOException
{
// BulkRequest bulkRequest = new BulkRequest.Builder().index(poolId).build();
List
<
BulkOperation
>
operationList
=
new
ArrayList
<>();
for
(
Person
person
:
personPool
)
{
if
(
person
==
null
)
{
continue
;
}
Integer
age
=
person
.
getAge
();
String
gender
=
person
.
getGender
();
String
personId
=
person
.
getPersonId
();
Date
personCountTime
=
person
.
getCounttime
();
String
direction
=
person
.
getDirection
();
Long
mallId
=
person
.
getMallId
();
//Long gateId = person.getGateId();
Integer
bodyType
=
person
.
getBodyType
();
String
personChannelSerialNum
=
person
.
getChannelSerialNum
();
List
<
FaceFeature
>
faceFeatures
=
person
.
getFaceFeatures
();
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
();
operationList
.
add
(
new
BulkOperation
.
Builder
().
index
(
new
IndexOperation
.
Builder
<
PersonInfo
>().
index
(
poolId
).
document
(
new
PersonInfo
(
unid
,
personId
,
null
,
feature
,
age
,
gender
,
bodyType
,
personCountTime
,
fid
,
personChannelSerialNum
,
gateId
,
direction
,
mallId
)).
build
()).
build
());
}
}
}
List
<
BodyFeature
>
bodyFeatures
=
person
.
getBodyFeatures
();
if
(
CollectionUtils
.
isNotEmpty
(
bodyFeatures
))
{
for
(
BodyFeature
bodyFeature
:
bodyFeatures
)
{
Double
[]
feature
=
bodyFeature
.
getFeature
();
if
(
feature
==
null
||
feature
.
length
<
Constant
.
BODY_FEATURE_DIMS_2048
)
{
continue
;
}
else
if
(
feature
.
length
==
Constant
.
BODY_FEATURE_DIMS_2110
)
{
feature
=
Utils
.
transferBodyFeature
(
feature
);
}
if
(
feature
.
length
>
Constant
.
BODY_FEATURE_DIMS_2048
)
{
feature
=
Arrays
.
copyOfRange
(
feature
,
3
,
Constant
.
BODY_FEATURE_DIMS_2048
+
3
);
}
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
();
operationList
.
add
(
new
BulkOperation
.
Builder
().
index
(
new
IndexOperation
.
Builder
<
PersonInfo
>().
index
(
poolId
).
document
(
new
PersonInfo
(
unid
,
personId
,
feature
,
null
,
age
,
gender
,
bodyType
,
counttime
,
fid
,
personChannelSerialNum
,
gateId
,
direction
,
mallId
)).
build
()).
build
());
}
}
}
if
(
operationList
.
size
()
==
0
)
{
return
null
;
}
BulkResponse
bulk
=
client
.
bulk
(
new
BulkRequest
.
Builder
().
index
(
poolId
).
operations
(
operationList
).
build
());
// poolService.refreshPool(poolId);
return
bulk
;
}
/**
* 删除人员
*
* @param poolId 特征池Id
* @param personId 人员Id,对应数据库personUnid
*
* @return 删除结果
* @throws IOException elasticsearch 所产生的异常
*/
public
DeleteByQueryResponse
deletePerson
(
String
poolId
,
String
personId
)
throws
IOException
{
DeleteByQueryRequest
deleteByQueryRequest
=
new
DeleteByQueryRequest
.
Builder
().
index
(
poolId
)
.
query
(
q
->
q
.
match
(
m
->
m
.
field
(
"personId"
).
query
(
personId
)))
.
refresh
(
true
).
build
();
return
client
.
deleteByQuery
(
deleteByQueryRequest
);
}
public
DeleteByQueryResponse
deletePersonByMallId
(
String
poolId
,
Long
mallId
)
throws
IOException
{
DeleteByQueryRequest
deleteByQueryRequest
=
new
DeleteByQueryRequest
.
Builder
().
index
(
poolId
)
.
query
(
q
->
q
.
match
(
m
->
m
.
field
(
"mallId"
).
query
(
mallId
)))
.
refresh
(
true
)
.
build
();
return
client
.
deleteByQuery
(
deleteByQueryRequest
);
}
public
DeleteByQueryResponse
deletePersonByFid
(
String
poolId
,
List
<
String
>
fidList
)
throws
IOException
{
DeleteByQueryRequest
deleteByQueryRequest
=
new
DeleteByQueryRequest
.
Builder
().
index
(
poolId
)
.
query
(
QueryBuilders
.
terms
().
field
(
"fid"
).
terms
(
new
TermsQueryField
.
Builder
().
value
(
fidList
.
stream
().
map
(
FieldValue:
:
of
).
collect
(
Collectors
.
toList
())).
build
()).
build
().
_toQuery
())
.
refresh
(
true
)
.
build
();
return
client
.
deleteByQuery
(
deleteByQueryRequest
);
}
}
src/main/java/com/viontech/match/service/PersonService.java
View file @
3dd43c8
...
@@ -38,7 +38,7 @@ import org.apache.commons.lang3.StringUtils;
...
@@ -38,7 +38,7 @@ import org.apache.commons.lang3.StringUtils;
import
org.elasticsearch.client.RequestOptions
;
import
org.elasticsearch.client.RequestOptions
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
ja
vax
.annotation.Resource
;
import
ja
karta
.annotation.Resource
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.text.ParseException
;
import
java.text.ParseException
;
import
java.util.*
;
import
java.util.*
;
...
@@ -60,6 +60,8 @@ public class PersonService {
...
@@ -60,6 +60,8 @@ public class PersonService {
private
ElasticsearchClient
client
;
private
ElasticsearchClient
client
;
@Resource
@Resource
private
PoolService
poolService
;
private
PoolService
poolService
;
@Resource
private
PersonPoolService
personPoolService
;
/**
/**
* 符合条件的数量
* 符合条件的数量
...
@@ -244,8 +246,8 @@ public class PersonService {
...
@@ -244,8 +246,8 @@ public class PersonService {
if
(!
poolService
.
existPool
(
poolId
))
{
if
(!
poolService
.
existPool
(
poolId
))
{
poolService
.
createPool
(
requestVo
,
false
);
poolService
.
createPool
(
requestVo
,
false
);
}
}
DeleteByQueryResponse
bulkByScrollResponse
=
deletePerson
(
poolId
,
personId
);
DeleteByQueryResponse
bulkByScrollResponse
=
personPoolService
.
deletePerson
(
poolId
,
personId
);
BulkResponse
bulkItemResponses
=
addPerson
(
poolId
,
Collections
.
singletonList
(
person
));
BulkResponse
bulkItemResponses
=
personPoolService
.
addPerson
(
poolId
,
Collections
.
singletonList
(
person
));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"人员修改操作异常"
,
e
);
log
.
error
(
"人员修改操作异常"
,
e
);
return
ResponseVo
.
error
(
rid
,
"update failed"
);
return
ResponseVo
.
error
(
rid
,
"update failed"
);
...
@@ -264,7 +266,7 @@ public class PersonService {
...
@@ -264,7 +266,7 @@ public class PersonService {
if
(!
poolService
.
existPool
(
poolId
))
{
if
(!
poolService
.
existPool
(
poolId
))
{
poolService
.
createPool
(
requestVo
,
false
);
poolService
.
createPool
(
requestVo
,
false
);
}
}
BulkResponse
bulkItemResponses
=
addPerson
(
poolId
,
Collections
.
singletonList
(
person
));
BulkResponse
bulkItemResponses
=
personPoolService
.
addPerson
(
poolId
,
Collections
.
singletonList
(
person
));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"店员修改操作异常"
,
e
);
log
.
error
(
"店员修改操作异常"
,
e
);
return
ResponseVo
.
error
(
rid
,
"update failed"
);
return
ResponseVo
.
error
(
rid
,
"update failed"
);
...
@@ -273,106 +275,13 @@ public class PersonService {
...
@@ -273,106 +275,13 @@ public class PersonService {
return
ResponseVo
.
success
(
rid
);
return
ResponseVo
.
success
(
rid
);
}
}
/**
* 添加人员
*
* @param poolId 特征池Id
* @param personPool 要添加的人员列表
*
* @return 批量添加的结果
* @throws IOException elasticsearch 所产生的异常
*/
public
BulkResponse
addPerson
(
String
poolId
,
List
<
Person
>
personPool
)
throws
IOException
{
// BulkRequest bulkRequest = new BulkRequest.Builder().index(poolId).build();
List
<
BulkOperation
>
operationList
=
new
ArrayList
<>();
for
(
Person
person
:
personPool
)
{
if
(
person
==
null
)
{
continue
;
}
Integer
age
=
person
.
getAge
();
String
gender
=
person
.
getGender
();
String
personId
=
person
.
getPersonId
();
Date
personCountTime
=
person
.
getCounttime
();
String
direction
=
person
.
getDirection
();
Long
mallId
=
person
.
getMallId
();
//Long gateId = person.getGateId();
Integer
bodyType
=
person
.
getBodyType
();
String
personChannelSerialNum
=
person
.
getChannelSerialNum
();
List
<
FaceFeature
>
faceFeatures
=
person
.
getFaceFeatures
();
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
();
operationList
.
add
(
new
BulkOperation
.
Builder
().
index
(
new
IndexOperation
.
Builder
<
PersonInfo
>().
index
(
poolId
).
document
(
new
PersonInfo
(
unid
,
personId
,
null
,
feature
,
age
,
gender
,
bodyType
,
personCountTime
,
fid
,
personChannelSerialNum
,
gateId
,
direction
,
mallId
)).
build
()).
build
());
}
}
}
List
<
BodyFeature
>
bodyFeatures
=
person
.
getBodyFeatures
();
if
(
CollectionUtils
.
isNotEmpty
(
bodyFeatures
))
{
for
(
BodyFeature
bodyFeature
:
bodyFeatures
)
{
Double
[]
feature
=
bodyFeature
.
getFeature
();
if
(
feature
==
null
||
feature
.
length
<
Constant
.
BODY_FEATURE_DIMS_2048
)
{
continue
;
}
else
if
(
feature
.
length
==
Constant
.
BODY_FEATURE_DIMS_2110
)
{
feature
=
Utils
.
transferBodyFeature
(
feature
);
}
if
(
feature
.
length
>
Constant
.
BODY_FEATURE_DIMS_2048
)
{
feature
=
Arrays
.
copyOfRange
(
feature
,
3
,
Constant
.
BODY_FEATURE_DIMS_2048
+
3
);
}
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
();
operationList
.
add
(
new
BulkOperation
.
Builder
().
index
(
new
IndexOperation
.
Builder
<
PersonInfo
>().
index
(
poolId
).
document
(
new
PersonInfo
(
unid
,
personId
,
feature
,
null
,
age
,
gender
,
bodyType
,
counttime
,
fid
,
personChannelSerialNum
,
gateId
,
direction
,
mallId
)).
build
()).
build
());
}
}
}
if
(
operationList
.
size
()
==
0
)
{
return
null
;
}
BulkResponse
bulk
=
client
.
bulk
(
new
BulkRequest
.
Builder
().
index
(
poolId
).
operations
(
operationList
).
build
());
// poolService.refreshPool(poolId);
return
bulk
;
}
/**
* 删除人员
*
* @param poolId 特征池Id
* @param personId 人员Id,对应数据库personUnid
*
* @return 删除结果
* @throws IOException elasticsearch 所产生的异常
*/
public
DeleteByQueryResponse
deletePerson
(
String
poolId
,
String
personId
)
throws
IOException
{
DeleteByQueryRequest
deleteByQueryRequest
=
new
DeleteByQueryRequest
.
Builder
().
index
(
poolId
)
.
query
(
q
->
q
.
match
(
m
->
m
.
field
(
"personId"
).
query
(
personId
)))
.
refresh
(
true
).
build
();
return
client
.
deleteByQuery
(
deleteByQueryRequest
);
}
public
DeleteByQueryResponse
deletePersonByMallId
(
String
poolId
,
Long
mallId
)
throws
IOException
{
DeleteByQueryRequest
deleteByQueryRequest
=
new
DeleteByQueryRequest
.
Builder
().
index
(
poolId
)
.
query
(
q
->
q
.
match
(
m
->
m
.
field
(
"mallId"
).
query
(
mallId
)))
.
refresh
(
true
)
.
build
();
return
client
.
deleteByQuery
(
deleteByQueryRequest
);
}
public
DeleteByQueryResponse
deletePersonByFid
(
String
poolId
,
List
<
String
>
fidList
)
throws
IOException
{
DeleteByQueryRequest
deleteByQueryRequest
=
new
DeleteByQueryRequest
.
Builder
().
index
(
poolId
)
.
query
(
QueryBuilders
.
terms
().
field
(
"fid"
).
terms
(
new
TermsQueryField
.
Builder
().
value
(
fidList
.
stream
().
map
(
FieldValue:
:
of
).
collect
(
Collectors
.
toList
())).
build
()).
build
().
_toQuery
())
.
refresh
(
true
)
.
build
();
return
client
.
deleteByQuery
(
deleteByQueryRequest
);
}
// public DeleteByQueryResponse deletePersonByMallId(String poolId, Long mallId) throws IOException {
// public DeleteByQueryResponse deletePersonByMallId(String poolId, Long mallId) throws IOException {
// DeleteByQueryRequest deleteByQueryRequest = new DeleteByQueryRequest(poolId)
// DeleteByQueryRequest deleteByQueryRequest = new DeleteByQueryRequest(poolId)
...
...
src/main/java/com/viontech/match/service/PoolService.java
View file @
3dd43c8
...
@@ -29,7 +29,7 @@ import org.elasticsearch.client.RestClient;
...
@@ -29,7 +29,7 @@ import org.elasticsearch.client.RestClient;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
ja
vax
.annotation.Resource
;
import
ja
karta
.annotation.Resource
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayInputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
...
@@ -45,7 +45,7 @@ import java.util.*;
...
@@ -45,7 +45,7 @@ import java.util.*;
@Slf4j
@Slf4j
public
class
PoolService
{
public
class
PoolService
{
@Resource
@Resource
private
Person
Service
person
Service
;
private
Person
PoolService
personPool
Service
;
@Resource
@Resource
private
ElasticsearchClient
client
;
private
ElasticsearchClient
client
;
// @Resource
// @Resource
...
@@ -106,7 +106,7 @@ public class PoolService {
...
@@ -106,7 +106,7 @@ public class PoolService {
if
(
addPerson
)
{
if
(
addPerson
)
{
List
<
Person
>
personPool
=
requestVo
.
getPersonPool
();
List
<
Person
>
personPool
=
requestVo
.
getPersonPool
();
if
(
CollectionUtils
.
isNotEmpty
(
personPool
))
{
if
(
CollectionUtils
.
isNotEmpty
(
personPool
))
{
BulkResponse
bulkItemResponses
=
personService
.
addPerson
(
poolId
,
personPool
);
BulkResponse
bulkItemResponses
=
person
Pool
Service
.
addPerson
(
poolId
,
personPool
);
if
(
bulkItemResponses
!=
null
)
{
if
(
bulkItemResponses
!=
null
)
{
log
.
info
(
bulkItemResponses
.
toString
());
log
.
info
(
bulkItemResponses
.
toString
());
}
}
...
@@ -144,7 +144,7 @@ public class PoolService {
...
@@ -144,7 +144,7 @@ public class PoolService {
for
(
HashMap
<
String
,
String
>
item
:
personIds
)
{
for
(
HashMap
<
String
,
String
>
item
:
personIds
)
{
String
personId
=
item
.
get
(
"personId"
);
String
personId
=
item
.
get
(
"personId"
);
if
(
personId
!=
null
)
{
if
(
personId
!=
null
)
{
personService
.
deletePerson
(
poolId
,
personId
);
person
Pool
Service
.
deletePerson
(
poolId
,
personId
);
}
}
}
}
}
else
if
(
flushPool
==
1
)
{
}
else
if
(
flushPool
==
1
)
{
...
@@ -169,7 +169,7 @@ public class PoolService {
...
@@ -169,7 +169,7 @@ public class PoolService {
Long
mallId
=
requestVo
.
getMallId
();
Long
mallId
=
requestVo
.
getMallId
();
log
.
info
(
"特征池删除mallId:{}数据操作开始:[{}]"
,
mallId
,
poolId
);
log
.
info
(
"特征池删除mallId:{}数据操作开始:[{}]"
,
mallId
,
poolId
);
try
{
try
{
personService
.
deletePersonByMallId
(
poolId
,
mallId
);
person
Pool
Service
.
deletePersonByMallId
(
poolId
,
mallId
);
log
.
info
(
"特征池删除mallId:{}操作完成:[{}]"
,
mallId
,
poolId
);
log
.
info
(
"特征池删除mallId:{}操作完成:[{}]"
,
mallId
,
poolId
);
return
ResponseVo
.
success
(
rid
);
return
ResponseVo
.
success
(
rid
);
}
catch
(
ElasticsearchException
e
)
{
}
catch
(
ElasticsearchException
e
)
{
...
@@ -189,7 +189,7 @@ public class PoolService {
...
@@ -189,7 +189,7 @@ public class PoolService {
List
<
String
>
fidList
=
requestVo
.
getFidList
();
List
<
String
>
fidList
=
requestVo
.
getFidList
();
log
.
info
(
"店员特征池删除数据操作开始:[{}]"
,
poolId
);
log
.
info
(
"店员特征池删除数据操作开始:[{}]"
,
poolId
);
try
{
try
{
personService
.
deletePersonByFid
(
poolId
,
fidList
);
person
Pool
Service
.
deletePersonByFid
(
poolId
,
fidList
);
log
.
info
(
"店员特征池删除操作完成:[{}]"
,
poolId
);
log
.
info
(
"店员特征池删除操作完成:[{}]"
,
poolId
);
return
ResponseVo
.
success
(
rid
);
return
ResponseVo
.
success
(
rid
);
}
catch
(
ElasticsearchException
e
)
{
}
catch
(
ElasticsearchException
e
)
{
...
@@ -242,7 +242,7 @@ public class PoolService {
...
@@ -242,7 +242,7 @@ public class PoolService {
return
ResponseVo
.
poolIdNotExists
(
rid
);
return
ResponseVo
.
poolIdNotExists
(
rid
);
}
}
try
{
try
{
BulkResponse
bulkItemResponses
=
personService
.
addPerson
(
poolId
,
personPool
);
BulkResponse
bulkItemResponses
=
person
Pool
Service
.
addPerson
(
poolId
,
personPool
);
if
(
bulkItemResponses
!=
null
&&
bulkItemResponses
.
errors
())
{
if
(
bulkItemResponses
!=
null
&&
bulkItemResponses
.
errors
())
{
log
.
info
(
bulkItemResponses
.
items
().
toString
());
log
.
info
(
bulkItemResponses
.
items
().
toString
());
return
ResponseVo
.
error
(
rid
,
bulkItemResponses
.
items
().
toString
());
return
ResponseVo
.
error
(
rid
,
bulkItemResponses
.
items
().
toString
());
...
...
src/main/resources/application-option.properties
View file @
3dd43c8
...
@@ -4,13 +4,13 @@ spring.jackson.time-zone=GMT+8
...
@@ -4,13 +4,13 @@ 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://182.92.184.40:9200
#spring.elasticsearch.rest.uris=http://182.92.184.40:9200
spring.elasticsearch.
rest.uris
=
http://127.0.0.1:9200
spring.elasticsearch.
uris
=
http://39.155.171.242:9201
spring.elasticsearch.
rest.
username
=
elastic
spring.elasticsearch.username
=
elastic
spring.elasticsearch.
rest.
password
=
vion2021
spring.elasticsearch.password
=
vion2021
spring.elasticsearch.
rest.
socketTimeout
=
5000
spring.elasticsearch.socketTimeout
=
5000
spring.elasticsearch.
rest.
ioThreadCount
=
20
spring.elasticsearch.ioThreadCount
=
20
spring.elasticsearch.
rest.
maxConnTotal
=
100
spring.elasticsearch.maxConnTotal
=
100
spring.elasticsearch.
rest.
maxConnPerRoute
=
20
spring.elasticsearch.maxConnPerRoute
=
20
#\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
...
...
src/main/resources/logback-spring.xml
View file @
3dd43c8
...
@@ -38,14 +38,13 @@
...
@@ -38,14 +38,13 @@
<charset>
UTF-8
</charset>
<!-- 设置字符集 -->
<charset>
UTF-8
</charset>
<!-- 设置字符集 -->
</encoder>
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.
SizeAnd
TimeBasedRollingPolicy"
>
<!-- 日志归档 -->
<!-- 日志归档 -->
<fileNamePattern>
${log.path}/debug/log-debug-%d{yyyy-MM-dd}.%i.log.gz
</fileNamePattern>
<fileNamePattern>
${log.path}/debug/log-debug-%d{yyyy-MM-dd}.%i.log.gz
</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"
>
<maxFileSize>
100MB
</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<!--日志文件保留天数-->
<maxHistory>
15
</maxHistory>
<maxHistory>
15
</maxHistory>
<!-- 日志文件的最大大小 -->
<maxFileSize>
100MB
</maxFileSize>
</rollingPolicy>
</rollingPolicy>
<!-- 此日志文件只记录debug级别的 -->
<!-- 此日志文件只记录debug级别的 -->
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
...
@@ -65,14 +64,13 @@
...
@@ -65,14 +64,13 @@
<charset>
UTF-8
</charset>
<charset>
UTF-8
</charset>
</encoder>
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.
SizeAnd
TimeBasedRollingPolicy"
>
<!-- 每天日志归档路径以及格式 -->
<!-- 每天日志归档路径以及格式 -->
<fileNamePattern>
${log.path}/info/log-info-%d{yyyy-MM-dd}.%i.log.gz
</fileNamePattern>
<fileNamePattern>
${log.path}/info/log-info-%d{yyyy-MM-dd}.%i.log.gz
</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"
>
<maxFileSize>
100MB
</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<!--日志文件保留天数-->
<maxHistory>
15
</maxHistory>
<maxHistory>
15
</maxHistory>
<!-- 日志文件的最大大小 -->
<maxFileSize>
100MB
</maxFileSize>
</rollingPolicy>
</rollingPolicy>
<!-- 此日志文件只记录info级别的 -->
<!-- 此日志文件只记录info级别的 -->
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
...
@@ -97,13 +95,12 @@
...
@@ -97,13 +95,12 @@
<charset>
UTF-8
</charset>
<!-- 此处设置字符集 -->
<charset>
UTF-8
</charset>
<!-- 此处设置字符集 -->
</encoder>
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.
SizeAnd
TimeBasedRollingPolicy"
>
<fileNamePattern>
${log.path}/warn/log-warn-%d{yyyy-MM-dd}.%i.log.gz
</fileNamePattern>
<fileNamePattern>
${log.path}/warn/log-warn-%d{yyyy-MM-dd}.%i.log.gz
</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"
>
<maxFileSize>
100MB
</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<!--日志文件保留天数-->
<maxHistory>
5
</maxHistory>
<maxHistory>
5
</maxHistory>
<!-- 日志文件的最大大小 -->
<maxFileSize>
100MB
</maxFileSize>
</rollingPolicy>
</rollingPolicy>
<!-- 此日志文件只记录warn级别的 -->
<!-- 此日志文件只记录warn级别的 -->
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
...
@@ -124,13 +121,12 @@
...
@@ -124,13 +121,12 @@
<charset>
UTF-8
</charset>
<!-- 此处设置字符集 -->
<charset>
UTF-8
</charset>
<!-- 此处设置字符集 -->
</encoder>
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.
SizeAnd
TimeBasedRollingPolicy"
>
<fileNamePattern>
${log.path}/error/log-error-%d{yyyy-MM-dd}.%i.log.gz
</fileNamePattern>
<fileNamePattern>
${log.path}/error/log-error-%d{yyyy-MM-dd}.%i.log.gz
</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"
>
<maxFileSize>
100MB
</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<!--日志文件保留天数-->
<maxHistory>
15
</maxHistory>
<maxHistory>
15
</maxHistory>
<!-- 日志文件的最大大小 -->
<maxFileSize>
100MB
</maxFileSize>
</rollingPolicy>
</rollingPolicy>
<!-- 此日志文件只记录ERROR级别的 -->
<!-- 此日志文件只记录ERROR级别的 -->
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
...
...
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