Commit 445774e3 authored by 曹盼盼's avatar 曹盼盼

代码格式化

parent c514dc89
...@@ -99,7 +99,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -99,7 +99,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
IdxFeignService idxFeignService; IdxFeignService idxFeignService;
@Autowired @Autowired
private static final String TABLENAME="tableName"; private static final String TABLENAME = "tableName";
@Value("${regulator.unit.code}") @Value("${regulator.unit.code}")
private String code; private String code;
...@@ -133,6 +133,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -133,6 +133,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
@Value("${elasticsearch.password}") @Value("${elasticsearch.password}")
private String esPwd; private String esPwd;
/** /**
* 分页查询 * 分页查询
*/ */
...@@ -177,7 +178,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -177,7 +178,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
List<Map<String, Object>> mapList = resourceJson.get(EquipmentClassifityEnum.BDLS.getCode()); List<Map<String, Object>> mapList = resourceJson.get(EquipmentClassifityEnum.BDLS.getCode());
List<Map<String, Object>> list = new ArrayList<>(); List<Map<String, Object>> list = new ArrayList<>();
ReginParams reginParams = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class); ReginParams reginParams = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
if(ObjectUtils.isEmpty(reginParams)){ if (ObjectUtils.isEmpty(reginParams)) {
return null; return null;
} }
String level = reginParams.getUserModel().getCompanys().get(0).getLevel(); String level = reginParams.getUserModel().getCompanys().get(0).getLevel();
...@@ -285,6 +286,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -285,6 +286,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
/** /**
* 将管辖机构树中children为[]的修改为null * 将管辖机构树中children为[]的修改为null
*
* @param result * @param result
* @return * @return
*/ */
...@@ -293,9 +295,9 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -293,9 +295,9 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
while (it.hasNext()) { while (it.hasNext()) {
LinkedHashMap e = (LinkedHashMap) it.next(); LinkedHashMap e = (LinkedHashMap) it.next();
//将管辖机构树中children为[]的修改为null //将管辖机构树中children为[]的修改为null
if(e.get("children") != null){ if (e.get("children") != null) {
if(((List<LinkedHashMap>) e.get("children")).size() == 0){ if (((List<LinkedHashMap>) e.get("children")).size() == 0) {
e.put("children",null); e.put("children", null);
} }
} }
if (!ObjectUtils.isEmpty(e.get("children"))) { if (!ObjectUtils.isEmpty(e.get("children"))) {
...@@ -319,7 +321,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -319,7 +321,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
if ("company".equals(e.get("level"))) { if ("company".equals(e.get("level"))) {
it.remove(); it.remove();
} }
if(e.get("companyName").toString().contains("行政审批局")){ if (e.get("companyName").toString().contains("行政审批局")) {
it.remove(); it.remove();
} }
if (!ObjectUtils.isEmpty(e.get("children"))) { if (!ObjectUtils.isEmpty(e.get("children"))) {
...@@ -397,12 +399,12 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -397,12 +399,12 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
@Override @Override
public List<CategoryOtherInfo> checkCode(Map<String, Object> obj) { public List<CategoryOtherInfo> checkCode(Map<String, Object> obj) {
List<CategoryOtherInfo> codeList; List<CategoryOtherInfo> codeList;
if("save".equals(obj.get("type"))){ if ("save".equals(obj.get("type"))) {
codeList = categoryOtherInfoMapper.selectList(new QueryWrapper<CategoryOtherInfo>().eq("CODE96333", obj.get("CODE96333"))); codeList = categoryOtherInfoMapper.selectList(new QueryWrapper<CategoryOtherInfo>().eq("CODE96333", obj.get("CODE96333")));
} else { } else {
codeList = categoryOtherInfoMapper.selectList(new QueryWrapper<CategoryOtherInfo>().ne("RECORD",obj.get("id")).eq("CODE96333", obj.get("CODE96333"))); codeList = categoryOtherInfoMapper.selectList(new QueryWrapper<CategoryOtherInfo>().ne("RECORD", obj.get("id")).eq("CODE96333", obj.get("CODE96333")));
} }
return codeList; return codeList;
} }
@Override @Override
...@@ -497,7 +499,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -497,7 +499,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
} }
resultMap.put("superviseCode", ObjectUtils.isEmpty(supervisorCode) ? null : supervisorCode.toString()); resultMap.put("superviseCode", ObjectUtils.isEmpty(supervisorCode) ? null : supervisorCode.toString());
resultMap.put("code96333", ObjectUtils.isEmpty(elevatorCode) ? null : elevatorCode.toString()); resultMap.put("code96333", ObjectUtils.isEmpty(elevatorCode) ? null : elevatorCode.toString());
resultMap.put("qrCode",ObjectUtils.isEmpty(supervisorCode) ? null : supervisorCode.toString()); resultMap.put("qrCode", ObjectUtils.isEmpty(supervisorCode) ? null : supervisorCode.toString());
return resultMap; return resultMap;
} }
...@@ -698,7 +700,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -698,7 +700,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
map.remove("ORG_BRANCH_CODE"); map.remove("ORG_BRANCH_CODE");
} }
total += m.getTotal(); total += m.getTotal();
if (!ValidationUtil.isEmpty(m) && !ValidationUtil.isEmpty(m.getRecords())) { if (!ValidationUtil.isEmpty(m) && !ValidationUtil.isEmpty(m.getRecords())) {
res.addAll(m.getRecords()); res.addAll(m.getRecords());
} }
} }
...@@ -726,7 +728,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -726,7 +728,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
} }
public List<Map<String, Object>> scalp(Map<String, Object> map) { public List<Map<String, Object>> scalp(Map<String, Object> map) {
List<Map<String, Object>> list = new ArrayList<>(); List<Map<String, Object>> list = new ArrayList<>();
if (!ValidationUtil.isEmpty(map.get("orgBranchName"))) { if (!ValidationUtil.isEmpty(map.get("orgBranchName"))) {
...@@ -775,7 +776,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -775,7 +776,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
if (!ObjectUtils.isEmpty(data)) { if (!ObjectUtils.isEmpty(data)) {
esEquipmentCategory.deleteById(id); esEquipmentCategory.deleteById(id);
} }
if (!ObjectUtils.isEmpty(dto)){ if (!ObjectUtils.isEmpty(dto)) {
esEquipmentCategory.save(dto); esEquipmentCategory.save(dto);
} }
} }
...@@ -844,13 +845,13 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -844,13 +845,13 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
public Page<Map<String, Object>> getAll(Map<String, Object> map) { public Page<Map<String, Object>> getAll(Map<String, Object> map) {
String tableName = map.get(TABLENAME).toString(); String tableName = map.get(TABLENAME).toString();
Assert.hasText(tableName, "表名不能为空"); Assert.hasText(tableName, "表名不能为空");
String selectSql = " SELECT * FROM " + tableName ; String selectSql = " SELECT * FROM " + tableName;
Integer number = ValidationUtil.isEmpty(map.get("number")) ? 0 : Integer.valueOf(map.get("number").toString()); Integer number = ValidationUtil.isEmpty(map.get("number")) ? 0 : Integer.valueOf(map.get("number").toString());
Integer size = ValidationUtil.isEmpty(map.get("size")) ? 0 : Integer.valueOf(map.get("size").toString()); Integer size = ValidationUtil.isEmpty(map.get("size")) ? 0 : Integer.valueOf(map.get("size").toString());
Page<Map<String, Object>> page = new Page<>(number, size); Page<Map<String, Object>> page = new Page<>(number, size);
int begin = (number - 1) * size; int begin = (number - 1) * size;
if (size > 0) { if (size > 0) {
selectSql = selectSql+" LIMIT " + begin + "," + size; selectSql = selectSql + " LIMIT " + begin + "," + size;
} }
List<Map<String, Object>> mapList = bizJdbcTemplate.queryForList(selectSql); List<Map<String, Object>> mapList = bizJdbcTemplate.queryForList(selectSql);
page.setRecords(mapList); page.setRecords(mapList);
...@@ -858,39 +859,43 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -858,39 +859,43 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
} }
//查询总条数 //查询总条数
public Long counts(Map<String, Object> map){ public Long counts(Map<String, Object> map) {
String tableName = map.get(TABLENAME).toString(); String tableName = map.get(TABLENAME).toString();
Assert.hasText(tableName, "表名不能为空"); Assert.hasText(tableName, "表名不能为空");
String countSql = " SELECT COUNT(SEQUENCE_NBR) count FROM " + tableName; String countSql = " SELECT COUNT(SEQUENCE_NBR) count FROM " + tableName;
Long count = bizJdbcTemplate.queryForObject(countSql, Long.class); Long count = bizJdbcTemplate.queryForObject(countSql, Long.class);
return count; return count;
} }
/** /**
* es数据同步 * es数据同步
*
* @return * @return
*/ */
public void saveEs() { public void saveEs() {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put(TABLENAME,"idx_biz_view_jg_all"); map.put(TABLENAME, "idx_biz_view_jg_all");
Long counts = counts(map); Long counts = counts(map);
Long times = counts / 1000; Long times = counts / 1000;
Long yushu = counts % 1000; Long yushu = counts % 1000;
if (yushu > 0) { if (yushu > 0) {
times++; times++;
} }
for (int i = 1; i <=times; i++) { for (int i = 1; i <= times; i++) {
map.put("number",i); map.put("number", i);
map.put("size",1000); map.put("size", 1000);
Page<Map<String, Object>> page = getAll(map); Page<Map<String, Object>> page = getAll(map);
for (Map<String, Object> record : page.getRecords()) { for (Map<String, Object> record : page.getRecords()) {
if (ValidationUtil.isEmpty(record.get("IS_NOT_ES")) ) { if (ValidationUtil.isEmpty(record.get("IS_NOT_ES"))) {
saveESEquipmentCategory(record); saveESEquipmentCategory(record);
} }
} }
} }
} }
/**es保存设备数据*/ /**
* es保存设备数据
*/
public ESEquipmentCategoryDto saveESEquipmentCategory(Map<String, Object> map) { public ESEquipmentCategoryDto saveESEquipmentCategory(Map<String, Object> map) {
ESEquipmentCategoryDto dto = JSONObject.parseObject(JSONObject.toJSONString(map), ESEquipmentCategoryDto.class); ESEquipmentCategoryDto dto = JSONObject.parseObject(JSONObject.toJSONString(map), ESEquipmentCategoryDto.class);
ESEquipmentCategoryDto save = esEquipmentCategory.save(dto); ESEquipmentCategoryDto save = esEquipmentCategory.save(dto);
...@@ -903,10 +908,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -903,10 +908,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
return save; return save;
} }
public Page<JSONObject> queryByKeys(JSONObject map) { public Page<JSONObject> queryByKeys(JSONObject map) {
//根据当前登录人查询 //根据当前登录人查询
if (!ValidationUtil.isEmpty(map.get(EQUSTATE))) { if (!ValidationUtil.isEmpty(map.get(EQUSTATE))) {
...@@ -921,7 +922,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -921,7 +922,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
if (LEVEL.equals(level)) { if (LEVEL.equals(level)) {
//企业 //企业
map.put("USE_UNIT_CREDIT_CODE", companyCode); map.put("USE_UNIT_CREDIT_CODE", companyCode);
} else { } else {
//监管单位 //监管单位
map.put("ORG_BRANCH_CODE", code); map.put("ORG_BRANCH_CODE", code);
...@@ -930,125 +930,54 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -930,125 +930,54 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
Page<JSONObject> result = new Page<>(map.getInteger("number"), map.getInteger("size")); Page<JSONObject> result = new Page<>(map.getInteger("number"), map.getInteger("size"));
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY, credentialsProvider.setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials(esUserName, esPwd)); //es账号密码 new UsernamePasswordCredentials(esUserName, esPwd)); //es账号密码
RestHighLevelClient esClient = new RestHighLevelClient( RestHighLevelClient esClient = new RestHighLevelClient(
RestClient.builder( RestClient.builder(
new HttpHost(esAddress, esPort) new HttpHost(esAddress, esPort)
).setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() { ).setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) { public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
httpClientBuilder.disableAuthCaching(); httpClientBuilder.disableAuthCaching();
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider); return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
} }
}) })
); );
SearchRequest request = new SearchRequest(); SearchRequest request = new SearchRequest();
request.indices("idx_biz_view_jg_all"); request.indices("idx_biz_view_jg_all");
SearchSourceBuilder builder = new SearchSourceBuilder(); SearchSourceBuilder builder = new SearchSourceBuilder();
builder.trackTotalHits(true); builder.trackTotalHits(true);
BoolQueryBuilder boolMust = QueryBuilders.boolQuery(); BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
//通用匹配规则,条件构建 //通用匹配规则,条件构建
//SEQUENCE_NBR //SEQUENCE_NBR
if (!ObjectUtils.isEmpty(map.getString("SEQUENCE_NBR"))) { if (!ObjectUtils.isEmpty(map.getString("SEQUENCE_NBR"))) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery(); BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchQuery("SEQUENCE_NBR", map.getString("SEQUENCE_NBR"))); meBuilder.must(QueryBuilders.matchQuery("SEQUENCE_NBR", map.getString("SEQUENCE_NBR")));
boolMust.must(meBuilder); boolMust.must(meBuilder);
} }
if (!ObjectUtils.isEmpty(map.getString("ORG_BRANCH_NAME"))) { if (!ObjectUtils.isEmpty(map.getString("ORG_BRANCH_NAME"))) {
BoolQueryBuilder query = QueryBuilders.boolQuery(); BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("ORG_BRANCH_NAME", "*" + map.getString("ORG_BRANCH_NAME") + "*")); query.must(QueryBuilders.matchQuery("ORG_BRANCH_NAME", "*" + map.getString("ORG_BRANCH_NAME") + "*"));
boolMust.must(query); boolMust.must(query);
} }
if (!ObjectUtils.isEmpty(map.getString("ORG_BRANCH_CODE"))) { if (!ObjectUtils.isEmpty(map.getString("ORG_BRANCH_CODE"))) {
BoolQueryBuilder query = QueryBuilders.boolQuery(); BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("ORG_BRANCH_CODE", "*" + map.getString("ORG_BRANCH_CODE") + "*")); query.must(QueryBuilders.matchQuery("ORG_BRANCH_CODE", "*" + map.getString("ORG_BRANCH_CODE") + "*"));
boolMust.must(query); boolMust.must(query);
} }
if (!ObjectUtils.isEmpty(map.getString("USE_UNIT_NAME"))) { if (!ObjectUtils.isEmpty(map.getString("USE_UNIT_NAME"))) {
BoolQueryBuilder query = QueryBuilders.boolQuery(); BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("USE_UNIT_NAME", "*" + map.getString("USE_UNIT_NAME") + "*")); query.must(QueryBuilders.matchQuery("USE_UNIT_NAME", "*" + map.getString("USE_UNIT_NAME") + "*"));
boolMust.must(query); boolMust.must(query);
} }
if (!ObjectUtils.isEmpty(map.getString("USE_UNIT_CREDIT_CODE"))) { if (!ObjectUtils.isEmpty(map.getString("USE_UNIT_CREDIT_CODE"))) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery(); BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchQuery("USE_UNIT_CREDIT_CODE", map.getString("USE_UNIT_CREDIT_CODE"))); meBuilder.must(QueryBuilders.matchQuery("USE_UNIT_CREDIT_CODE", map.getString("USE_UNIT_CREDIT_CODE")));
boolMust.must(meBuilder); boolMust.must(meBuilder);
} }
if (!ObjectUtils.isEmpty(map.getString("EQU_LIST_CODE"))) { if (!ObjectUtils.isEmpty(map.getString("EQU_LIST_CODE"))) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery(); BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchQuery("EQU_LIST_CODE", "*" + map.getString("EQU_LIST_CODE") + "*"));
meBuilder.must(QueryBuilders.matchQuery("EQU_LIST_CODE", "*"+map.getString("EQU_LIST_CODE")+"*"));
boolMust.must(meBuilder); boolMust.must(meBuilder);
} }
if (!ObjectUtils.isEmpty(map.getString("EQU_LIST"))) { if (!ObjectUtils.isEmpty(map.getString("EQU_LIST"))) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery(); BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchQuery("EQU_LIST", map.getString("EQU_LIST"))); meBuilder.must(QueryBuilders.matchQuery("EQU_LIST", map.getString("EQU_LIST")));
...@@ -1064,18 +993,15 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -1064,18 +993,15 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery(); BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchQuery("USE_ORG_CODE", map.getString("USE_ORG_CODE"))); meBuilder.must(QueryBuilders.matchQuery("USE_ORG_CODE", map.getString("USE_ORG_CODE")));
boolMust.must(meBuilder); boolMust.must(meBuilder);
} }
if (!ObjectUtils.isEmpty(map.getString("CODE96333"))) { if (!ObjectUtils.isEmpty(map.getString("CODE96333"))) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery(); BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchQuery("CODE96333", map.getString("CODE96333"))); meBuilder.must(QueryBuilders.matchQuery("CODE96333", map.getString("CODE96333")));
boolMust.must(meBuilder); boolMust.must(meBuilder);
} }
if (!ObjectUtils.isEmpty(map.getString("EQU_CODE"))) { if (!ObjectUtils.isEmpty(map.getString("EQU_CODE"))) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery(); BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchQuery("EQU_CODE", "*"+map.getString("EQU_CODE")+"*")); meBuilder.must(QueryBuilders.matchQuery("EQU_CODE", "*" + map.getString("EQU_CODE") + "*"));
boolMust.must(meBuilder); boolMust.must(meBuilder);
} }
...@@ -1116,59 +1042,41 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -1116,59 +1042,41 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
System.out.println(hit); System.out.println(hit);
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(hit); JSONObject jsonObject = (JSONObject) JSONObject.toJSON(hit);
JSONObject dto2 = jsonObject.getJSONObject("sourceAsMap"); JSONObject dto2 = jsonObject.getJSONObject("sourceAsMap");
if (!ValidationUtil.isEmpty(dto2.get(EQUSTATE))) {
Integer integer = Integer.valueOf(dto2.get(EQUSTATE).toString());
String status = EquimentEnum.getName.get(integer);
dto2.put(EQUSTATE, status);
}
list.add(dto2); list.add(dto2);
} }
totle = getCount("idx_biz_view_jg_all",esClient); totle = getCount("idx_biz_view_jg_all", esClient);
result.setRecords(list); result.setRecords(list);
result.setTotal(totle); result.setTotal(totle);
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
}finally { } finally {
try { try {
esClient.close(); esClient.close();
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
return result; return result;
} }
//es统计总记录数 //es统计总记录数
public Long getCount(String indexs, RestHighLevelClient esClient) {
public Long getCount(String indexs ,RestHighLevelClient esClient){ Long totle = 0L;
Long totle=0L;
SearchRequest searchRequest = new SearchRequest(indexs); SearchRequest searchRequest = new SearchRequest(indexs);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.query(QueryBuilders.matchAllQuery()); searchSourceBuilder.query(QueryBuilders.matchAllQuery());
searchSourceBuilder.trackTotalHits(true); searchSourceBuilder.trackTotalHits(true);
searchRequest.source(searchSourceBuilder); searchRequest.source(searchSourceBuilder);
try { try {
SearchResponse searchResponse = esClient.search(searchRequest, RequestOptions.DEFAULT); SearchResponse searchResponse = esClient.search(searchRequest, RequestOptions.DEFAULT);
totle = searchResponse.getInternalResponse().hits().getTotalHits().value;
totle=searchResponse.getInternalResponse().hits().getTotalHits().value;
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
return totle; return totle;
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment