Commit 48d1399f by 李乾广

[chg]更新特征库时,判断是否存在,不存在则新建特征库

1 parent 5f7a0854
......@@ -45,7 +45,14 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.IOException;
import java.text.ParseException;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
......@@ -149,9 +156,12 @@ public class PersonService {
String poolId = requestVo.getPoolId();
log.info("人员修改操作开始,poolId:[{}],personId:[{}]", poolId, personId);
try {
if (!poolService.existPool(poolId)) {
poolService.createPool(requestVo, false);
}
BulkByScrollResponse bulkByScrollResponse = deletePerson(poolId, personId);
BulkResponse bulkItemResponses = addPerson(poolId, Collections.singletonList(person));
} catch (IOException e) {
} catch (Exception e) {
log.error("人员修改操作异常", e);
return ResponseVo.error(rid, "update failed");
}
......
......@@ -15,7 +15,11 @@ import org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
import org.elasticsearch.action.admin.indices.refresh.RefreshResponse;
import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.client.*;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.CreateIndexRequest;
import org.elasticsearch.client.indices.CreateIndexResponse;
import org.elasticsearch.client.indices.GetIndexRequest;
......@@ -63,6 +67,10 @@ public class PoolService {
* @throws Exception --
*/
public ResponseVo createPool(RequestVo requestVo) throws Exception {
return createPool(requestVo, true);
}
public ResponseVo createPool(RequestVo requestVo, boolean addPerson) throws Exception {
String rid = requestVo.getRid();
String poolId = requestVo.getPoolId();
log.info("特征池创建操作开始:[{}}", poolId);
......@@ -76,6 +84,7 @@ public class PoolService {
createIndexRequest.settings(setting);
CreateIndexResponse createIndexResponse = client.indices().create(createIndexRequest, RequestOptions.DEFAULT);
if (addPerson) {
List<Person> personPool = requestVo.getPersonPool();
if (CollectionUtils.isNotEmpty(personPool)) {
BulkResponse bulkItemResponses = personService.addPerson(poolId, personPool);
......@@ -83,6 +92,7 @@ public class PoolService {
log.info(bulkItemResponses.buildFailureMessage());
}
}
}
log.info("特征池创建操作完成:[{}]", poolId);
return ResponseVo.success(rid);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!