Commit 4192ba8c by 朱海

Revert "[chg]增加店员库操作相关接口"

This reverts commit 1d9180de.
1 parent 1d9180de
...@@ -49,12 +49,6 @@ public class MainController { ...@@ -49,12 +49,6 @@ public class MainController {
return personService.updatePerson(requestVo); return personService.updatePerson(requestVo);
case CountMatchPerson: case CountMatchPerson:
return personService.countMatchPerson(requestVo); return personService.countMatchPerson(requestVo);
case DelPoolData:
return poolService.deletePoolData(requestVo);
case DelStaffPoolData:
return poolService.deleteStaffPoolData(requestVo);
case UpdateStaff:
return personService.updateStaff(requestVo);
default: default:
return ResponseVo.commandNotFound(rid); return ResponseVo.commandNotFound(rid);
} }
......
...@@ -67,10 +67,6 @@ public class RequestVo { ...@@ -67,10 +67,6 @@ public class RequestVo {
//暂时无用 //暂时无用
private FaceFeature newFaceFeature; private FaceFeature newFaceFeature;
private Long mallId;
private List<String> fidList;
public void setPoolId(String poolId) { public void setPoolId(String poolId) {
this.poolId = poolId.toLowerCase(); this.poolId = poolId.toLowerCase();
} }
......
...@@ -14,8 +14,5 @@ public enum CommandEnum { ...@@ -14,8 +14,5 @@ public enum CommandEnum {
QueryPersonPool, QueryPersonPool,
MatchPerson, MatchPerson,
UpdatePerson, UpdatePerson,
CountMatchPerson, CountMatchPerson
DelPoolData,
DelStaffPoolData,
UpdateStaff;
} }
...@@ -21,14 +21,11 @@ import org.elasticsearch.action.search.SearchResponse; ...@@ -21,14 +21,11 @@ import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.core.CountRequest;
import org.elasticsearch.client.core.CountResponse;
import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.query.BoolQueryBuilder; import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.RangeQueryBuilder; import org.elasticsearch.index.query.RangeQueryBuilder;
import org.elasticsearch.index.query.TermQueryBuilder; import org.elasticsearch.index.query.TermQueryBuilder;
import org.elasticsearch.index.query.TermsQueryBuilder;
import org.elasticsearch.index.query.functionscore.ScriptScoreQueryBuilder; import org.elasticsearch.index.query.functionscore.ScriptScoreQueryBuilder;
import org.elasticsearch.index.reindex.BulkByScrollResponse; import org.elasticsearch.index.reindex.BulkByScrollResponse;
import org.elasticsearch.index.reindex.DeleteByQueryRequest; import org.elasticsearch.index.reindex.DeleteByQueryRequest;
...@@ -190,18 +187,11 @@ public class PersonService { ...@@ -190,18 +187,11 @@ public class PersonService {
Pool pool = new Pool(); Pool pool = new Pool();
pool.setPersonPoolId(id); pool.setPersonPoolId(id);
if (poolService.existPool(id)) { if (poolService.existPool(id)) {
//根据mallId判断特征池是否存在该mall的数据 pool.setStatus(0);
boolean hasData = hasData(id, requestVo.getPerson().getMallId()); List<Person> face = matchPerson(rid, id, requestVo.getPerson(), 0, size, agg);
if (hasData) { matchFaces.addAll(face);
pool.setStatus(0); List<Person> body = matchPerson(rid, id, requestVo.getPerson(), 1, size, agg);
List<Person> face = matchPerson(rid, id, requestVo.getPerson(), 0, size, agg); matchBodies.addAll(body);
matchFaces.addAll(face);
List<Person> body = matchPerson(rid, id, requestVo.getPerson(), 1, size, agg);
matchBodies.addAll(body);
} else {
pool.setStatus(2);
}
} else { } else {
pool.setStatus(1); pool.setStatus(1);
} }
...@@ -263,26 +253,6 @@ public class PersonService { ...@@ -263,26 +253,6 @@ public class PersonService {
return ResponseVo.success(rid); return ResponseVo.success(rid);
} }
public ResponseVo updateStaff(RequestVo requestVo) {
String rid = requestVo.getRid();
Person person = requestVo.getPerson();
String personId = person.getPersonId();
String poolId = requestVo.getPoolId();
log.info("店员修改操作开始,poolId:[{}],personId:[{}]", poolId, personId);
try {
if (!poolService.existPool(poolId)) {
poolService.createPool(requestVo, false);
}
BulkResponse bulkItemResponses = addPerson(poolId, Collections.singletonList(person));
} catch (Exception e) {
log.error("店员修改操作异常", e);
return ResponseVo.error(rid, "update failed");
}
log.info("店员修改操作完成,poolId:[{}],personId:[{}]", poolId, personId);
return ResponseVo.success(rid);
}
/** /**
* 添加人员 * 添加人员
* *
...@@ -303,7 +273,6 @@ public class PersonService { ...@@ -303,7 +273,6 @@ public class PersonService {
String personId = person.getPersonId(); String personId = person.getPersonId();
Date personCountTime = person.getCounttime(); Date personCountTime = person.getCounttime();
String direction = person.getDirection(); String direction = person.getDirection();
Long mallId = person.getMallId();
//Long gateId = person.getGateId(); //Long gateId = person.getGateId();
Integer bodyType = person.getBodyType(); Integer bodyType = person.getBodyType();
String personChannelSerialNum = person.getChannelSerialNum(); String personChannelSerialNum = person.getChannelSerialNum();
...@@ -319,7 +288,7 @@ public class PersonService { ...@@ -319,7 +288,7 @@ public class PersonService {
.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), "counttime", personCountTime == null ? null : Constant.DATE_FORMAT.get().format(personCountTime),
"channelSerialNum", personChannelSerialNum, "gateId", gateId, "direction", direction, "mallId", mallId); "channelSerialNum", personChannelSerialNum, "gateId", gateId, "direction", direction);
bulkRequest.add(indexRequest); bulkRequest.add(indexRequest);
} }
} }
...@@ -347,7 +316,7 @@ public class PersonService { ...@@ -347,7 +316,7 @@ public class PersonService {
.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) "counttime", counttime == null ? null : Constant.DATE_FORMAT.get().format(counttime)
, "channelSerialNum", channelSerialNum, "gateId", gateId, "direction", direction, "mallId", mallId); , "channelSerialNum", channelSerialNum, "gateId", gateId, "direction", direction);
bulkRequest.add(indexRequest); bulkRequest.add(indexRequest);
} }
} }
...@@ -376,21 +345,6 @@ public class PersonService { ...@@ -376,21 +345,6 @@ public class PersonService {
return client.deleteByQuery(deleteByQueryRequest, RequestOptions.DEFAULT); return client.deleteByQuery(deleteByQueryRequest, RequestOptions.DEFAULT);
} }
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);
}
/** /**
* 人员匹配入口 * 人员匹配入口
* *
...@@ -488,10 +442,7 @@ public class PersonService { ...@@ -488,10 +442,7 @@ public class PersonService {
"(cosineSimilarity(params.body, 'body') + 1) / 2 * 100", Collections.singletonMap("body", feature)); "(cosineSimilarity(params.body, 'body') + 1) / 2 * 100", Collections.singletonMap("body", feature));
boolQuery.filter(QueryBuilders.existsQuery("body")); boolQuery.filter(QueryBuilders.existsQuery("body"));
} }
//根据mallId过滤
if (person.getMallId() != null) {
boolQuery.filter().add(QueryBuilders.termQuery("mallId", person.getMallId()));
}
// 根据通道号过滤 // 根据通道号过滤
List<String> channelSerialNums = person.getChannelSerialNums(); List<String> channelSerialNums = person.getChannelSerialNums();
if (CollectionUtils.isNotEmpty(channelSerialNums)) { if (CollectionUtils.isNotEmpty(channelSerialNums)) {
...@@ -607,22 +558,4 @@ public class PersonService { ...@@ -607,22 +558,4 @@ 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;
}
} }
...@@ -146,46 +146,6 @@ public class PoolService { ...@@ -146,46 +146,6 @@ 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!