Commit 5b458050 by 姚冰

Merge remote-tracking branch 'origin/index-merge' into develop_es8.15_merge

# Conflicts:
#	src/main/java/com/viontech/match/service/PersonService.java
#	src/main/java/com/viontech/match/service/PoolService.java
2 parents 3bd562f2 cb16fb78
......@@ -171,18 +171,25 @@ public class PersonService {
if (poolId != null) {
poolIds.add(poolId);
}
// log.info("人员匹配操作开始,PoolIds:[{}],rid:{}", poolIds, rid);
log.info("人员匹配操作开始,PoolIds:[{}],rid:{}", poolIds, rid);
long startTime = System.currentTimeMillis();
try {
for (String id : poolIds) {
Pool pool = new Pool();
pool.setPersonPoolId(id);
if (poolService.existPool(id)) {
pool.setStatus(0);
List<Person> face = matchPerson(rid, id, requestVo.getPerson(), 0, size, agg);
matchFaces.addAll(face);
List<Person> body = matchPerson(rid, id, requestVo.getPerson(), 1, size, agg);
matchBodies.addAll(body);
//根据mallId判断特征池是否存在该mall的数据
boolean hasData = hasData(id, requestVo.getPerson().getMallId());
if (hasData) {
pool.setStatus(0);
List<Person> face = matchPerson(rid, id, requestVo.getPerson(), 0, size, agg);
matchFaces.addAll(face);
List<Person> body = matchPerson(rid, id, requestVo.getPerson(), 1, size, agg);
matchBodies.addAll(body);
} else {
pool.setStatus(2);
}
} else {
pool.setStatus(1);
}
......@@ -364,6 +371,21 @@ public class PersonService {
return client.deleteByQuery(deleteByQueryRequest);
}
public BulkByScrollResponse deletePersonByMallId(String poolId, Long mallId) throws IOException {
DeleteByQueryRequest deleteByQueryRequest = new DeleteByQueryRequest(poolId)
.setQuery(new TermQueryBuilder("mallId", mallId))
.setRefresh(true);
return client.deleteByQuery(deleteByQueryRequest, RequestOptions.DEFAULT);
}
public BulkByScrollResponse deletePersonByFid(String poolId, List<String> fidList) throws IOException {
DeleteByQueryRequest deleteByQueryRequest = new DeleteByQueryRequest(poolId)
.setQuery(new TermsQueryBuilder("fid", fidList))
.setRefresh(true);
return client.deleteByQuery(deleteByQueryRequest, RequestOptions.DEFAULT);
}
/**
* 人员匹配入口
*
......@@ -503,7 +525,10 @@ public class PersonService {
knnQuery.field("body").queryVector(getFeature(feature)).numCandidates(Constant.BODY_MATCH_RESULT_SIZE);
queries.add(new Query.Builder().exists(s -> s.field("body").boost(1.0f)).build());
}
//根据mallId过滤
if (person.getMallId() != null) {
boolQuery.filter().add(QueryBuilders.termQuery("mallId", person.getMallId()));
}
// 根据通道号过滤
List<String> channelSerialNums = person.getChannelSerialNums();
if (CollectionUtils.isNotEmpty(channelSerialNums)) {
......@@ -621,4 +646,22 @@ public class PersonService {
}
public boolean hasData(String poolId, Long mallId) throws IOException {
log.info("判断特征池:{}是否存在mallId:{}的数据", poolId, mallId);
if (mallId == null || mallId == 0L) {
return true;
}
//店员库才需要判断是否有数据,并且重建库
if (!poolId.contains("staff")) {
return true;
}
BoolQueryBuilder builder = new BoolQueryBuilder();
builder.filter(QueryBuilders.termQuery("mallId", mallId));
CountRequest countRequest = new CountRequest(poolId);
countRequest.query(builder);
CountResponse response = client.count(countRequest, RequestOptions.DEFAULT);
log.info("特征池:{}中mallId:{}的数据量为:{}", poolId, mallId, response.getCount());
return response.getCount() > 0;
}
}
......@@ -202,6 +202,46 @@ public class PoolService {
}
public ResponseVo deletePoolData(RequestVo requestVo) throws Exception {
String rid = requestVo.getRid();
Integer flushPool = requestVo.getFlushPool();
String poolId = requestVo.getPoolId();
Long mallId = requestVo.getMallId();
log.info("特征池删除mallId:{}数据操作开始:[{}]", mallId,poolId);
try {
personService.deletePersonByMallId(poolId, mallId);
log.info("特征池删除mallId:{}操作完成:[{}]", mallId, poolId);
return ResponseVo.success(rid);
} catch (ElasticsearchStatusException e) {
if (e.status() == RestStatus.NOT_FOUND) {
return ResponseVo.poolIdNotExists(rid);
} else {
return ResponseVo.error(rid, e.getDetailedMessage());
}
}
}
public ResponseVo deleteStaffPoolData(RequestVo requestVo) throws Exception {
String rid = requestVo.getRid();
Integer flushPool = requestVo.getFlushPool();
String poolId = requestVo.getPoolId();
List<String> fidList = requestVo.getFidList();
log.info("店员特征池删除数据操作开始:[{}]",poolId);
try {
personService.deletePersonByFid(poolId, fidList);
log.info("店员特征池删除操作完成:[{}]",poolId);
return ResponseVo.success(rid);
} catch (ElasticsearchStatusException e) {
if (e.status() == RestStatus.NOT_FOUND) {
return ResponseVo.poolIdNotExists(rid);
} else {
return ResponseVo.error(rid, e.getDetailedMessage());
}
}
}
/**
* 修改特征池(添加人员)
*
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!