| | |
| | | * @param place |
| | | */ |
| | | @Async |
| | | public void addPlace(EsParam esParam, PlaceVO place) { |
| | | public void addPlace(EsParam esParam, PlaceEntity place) { |
| | | if (elasticsearchSync) { |
| | | if (!Strings.isBlank(place.getCommunityCode())) { |
| | | place.setCommunityCode(placeService.getCommunityCode(place.getId())); |
| | | } |
| | | try { |
| | | indexDocument(esParam.getIndexName(), |
| | | "tableId", place.getId().toString(), |
| | |
| | | "phone", place.getPrincipalPhone(), |
| | | "idCard", place.getPrincipalIdCard(), |
| | | "content", place.getLocation(), |
| | | "communityCode", place.getCommunityCode() |
| | | "communityCode", placeService.getCommunityCode(place.getId()) |
| | | ); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | |
| | | * @param house |
| | | */ |
| | | @Async |
| | | public void addHouse(EsParam esParam, HouseVO house) { |
| | | public void addHouse(EsParam esParam, HouseEntity house) { |
| | | if (elasticsearchSync) { |
| | | if (!Strings.isBlank(house.getCommunityCode())) { |
| | | house.setCommunityCode(houseService.getCommunityCode(house.getId())); |
| | | } |
| | | try { |
| | | indexDocument(esParam.getIndexName(), |
| | | "tableId", house.getId().toString(), |
| | |
| | | "phone", null, |
| | | "idCard", null, |
| | | "content", null, |
| | | "communityCode", house.getCommunityCode() |
| | | "communityCode", houseService.getCommunityCode(house.getId()) |
| | | ); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | |
| | | * @param household |
| | | */ |
| | | @Async |
| | | public void addHousehold(EsParam esParam, HouseholdVO household) { |
| | | public void addHousehold(EsParam esParam, HouseholdEntity household) { |
| | | if (elasticsearchSync) { |
| | | if (!Strings.isBlank(household.getCommunityCode())) { |
| | | household.setCommunityCode(householdService.getCommunityCode(household.getId())); |
| | | } |
| | | try { |
| | | indexDocument(esParam.getIndexName(), |
| | | "tableId", household.getId().toString(), |
| | |
| | | "name", household.getName(), |
| | | "phone", household.getPhoneNumber(), |
| | | "idCard", household.getIdCard(), |
| | | "content", household.getAddress(), |
| | | "communityCode", household.getCommunityCode() |
| | | "content", household.getCurrentAddress(), |
| | | "communityCode", householdService.getCommunityCode(household.getId()) |
| | | ); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | |
| | | BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); |
| | | // boolQueryBuilder.should(QueryBuilders.matchQuery("content", esParam.getSearchKey())); |
| | | // boolQueryBuilder.should(QueryBuilders.matchQuery("name", esParam.getSearchKey())); |
| | | boolQueryBuilder.should(QueryBuilders.matchQuery("title", esParam.getSearchKey())); |
| | | boolQueryBuilder.must(QueryBuilders.matchQuery("title", esParam.getSearchKey())); |
| | | // boolQueryBuilder.should(QueryBuilders.matchQuery("location", esParam.getSearchKey())); |
| | | // boolQueryBuilder.should(QueryBuilders.matchQuery("phone", esParam.getSearchKey())); |
| | | // boolQueryBuilder.should(QueryBuilders.matchQuery("idCard", esParam.getSearchKey())); |
| | | if (!Strings.isBlank(esParam.getTableName())) { |
| | | boolQueryBuilder.must(QueryBuilders.matchQuery("tableName", esParam.getTableName())); |
| | | } |
| | | String communityCode = SpringUtils.getRequestParam("communityCode"); |
| | | if (!Strings.isBlank(communityCode)) { |
| | | boolQueryBuilder.must(QueryBuilders.matchQuery("communityCode", communityCode)); |
| | | } |
| | | if (!Strings.isBlank(esParam.getTableName())) { |
| | | boolQueryBuilder.must(QueryBuilders.matchQuery("tableName", esParam.getTableName())); |
| | | String roleName = SpringUtils.getRequestParam("roleName"); |
| | | if (!Strings.isBlank(roleName)){ |
| | | if (roleName.equals("wgy") || roleName.equals("mj")){ |
| | | // 不查公告 |
| | | boolQueryBuilder.mustNot(QueryBuilders.matchQuery("tableName", "jczz_article")); |
| | | } |
| | | if (roleName.equals("inhabitant")){ |
| | | // 只查公告 |
| | | boolQueryBuilder.must(QueryBuilders.matchQuery("tableName", "jczz_article")); |
| | | } |
| | | if (roleName.equals("wzcj")){ |
| | | // 只查场所 |
| | | boolQueryBuilder.must(QueryBuilders.matchQuery("tableName", "jczz_place")); |
| | | } |
| | | } |
| | | |
| | | boolQueryBuilder.minimumShouldMatch(1); |
| | | searchSourceBuilder.query(boolQueryBuilder); |
| | | |