EsQueryServiceImpl.java 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package com.winhc.service.impl;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.winhc.pojo.MergePerson;
  4. import com.winhc.service.EsQueryService;
  5. import com.winhc.utils.EsQueryDsl;
  6. import lombok.AllArgsConstructor;
  7. import lombok.extern.slf4j.Slf4j;
  8. import org.frameworkset.elasticsearch.boot.BBossESStarter;
  9. import org.frameworkset.elasticsearch.client.ClientInterface;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.beans.factory.annotation.Qualifier;
  12. import org.springframework.stereotype.Service;
  13. import javax.annotation.PostConstruct;
  14. import java.util.Collection;
  15. import java.util.List;
  16. /**
  17. * @author π
  18. * @Description:
  19. * @date 2022/5/25 19:22
  20. */
  21. @Slf4j
  22. @Service
  23. @AllArgsConstructor
  24. public class EsQueryServiceImpl implements EsQueryService {
  25. @Autowired
  26. @Qualifier("bbossESStarterEs5")
  27. private BBossESStarter bbossESStarterEs5;
  28. private ClientInterface restClient;
  29. @PostConstruct
  30. public void init() {
  31. restClient = bbossESStarterEs5.getRestClient("es5");
  32. }
  33. @Override
  34. public Integer queryByDsl(String human_pid) {
  35. String res = restClient.executeHttp("winhc_company_human_pid_mapping_v9/_count", EsQueryDsl.queryBoss(human_pid), ClientInterface.HTTP_POST);
  36. return JSONObject.parseObject(res).getInteger("count");
  37. }
  38. @Override
  39. public Collection<List<MergePerson>> queryByDsl(Collection<List<MergePerson>> mergePersonList) {
  40. mergePersonList.forEach(p -> p.forEach(m -> {
  41. m.setCnt(queryByDsl(m.getOld_human_pid()));
  42. }));
  43. return mergePersonList;
  44. }
  45. }