Commit f198fc81 by xmh

类型转或错误说明人员池有问题需要先删掉

1 parent bf226020
......@@ -17,6 +17,9 @@ public class Constant {
/** poolId不存在时es返回的message所包含的字段 */
public final static String STR_POOL_ID_ALREADY_EXISTS = "already_exists";
/** 类型错误时返回所包含的字段 */
public final static String CLASS_CAST_EXCEPTION = "class_cast_exception";
/** 人脸匹配结果的数量 */
public final static int MATCH_RESULT_SIZE = 5;
}
......@@ -9,6 +9,7 @@ import com.viontech.match.config.Constant;
import com.viontech.match.entity.vo.RequestVo;
import com.viontech.match.entity.vo.ResponseVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.tomcat.util.http.fileupload.FileUtils;
import org.elasticsearch.ElasticsearchStatusException;
import org.elasticsearch.action.bulk.BulkRequest;
import org.elasticsearch.action.bulk.BulkResponse;
......@@ -23,6 +24,7 @@ import org.elasticsearch.index.query.TermQueryBuilder;
import org.elasticsearch.index.query.functionscore.ScriptScoreQueryBuilder;
import org.elasticsearch.index.reindex.BulkByScrollResponse;
import org.elasticsearch.index.reindex.DeleteByQueryRequest;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.script.Script;
import org.elasticsearch.script.ScriptType;
import org.elasticsearch.search.SearchHit;
......@@ -90,6 +92,16 @@ public class PersonService {
log.info("人员匹配操作完成,PoolIds:[{}},结果:[{}]", poolIds.toString(), objectMapper.writeValueAsString(success));
return success;
} catch (ElasticsearchStatusException e) {
if (e.status() == RestStatus.BAD_REQUEST && e.getDetailedMessage().contains(Constant.CLASS_CAST_EXCEPTION)) {
for (String id : poolIds) {
RequestVo requestVo1 = new RequestVo();
requestVo1.setRid("1");
requestVo1.setPoolId(id);
requestVo1.setFlushPool(1);
poolService.deletePool(requestVo1);
}
}
log.error("matchPerson", e);
ResponseVo error = ResponseVo.error(rid, e.getDetailedMessage());
error.setMatch(0);
......
......@@ -3,6 +3,4 @@ server.port=12000
spring.jackson.time-zone=GMT+8
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
# es
#spring.elasticsearch.rest.uris=http://192.168.9.116:9200
#spring.elasticsearch.rest.uris=http://127.0.0.1:9200
spring.elasticsearch.rest.uris=http://139.217.100.35:9200,http://139.217.100.35:9201
\ No newline at end of file
spring.elasticsearch.rest.uris=http://127.0.0.1:9200
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!