EsServiceTests.java 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. package cn.cslg.pas.service;
  2. import cn.cslg.pas.common.dto.PatentDTO;
  3. import cn.cslg.pas.common.utils.FormatUtil;
  4. import cn.cslg.pas.common.utils.RedisUtil;
  5. import cn.cslg.pas.common.vo.PatentWithIdVO;
  6. import cn.cslg.pas.domain.es.Patent;
  7. import cn.cslg.pas.service.business.es.EsService;
  8. import cn.cslg.pas.service.importPatent.SchedulingTaskService;
  9. import cn.hutool.core.util.XmlUtil;
  10. import org.junit.Test;
  11. import org.springframework.beans.BeanUtils;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.boot.test.context.SpringBootTest;
  14. import javax.swing.text.Document;
  15. import java.io.IOException;
  16. import java.util.List;
  17. /**
  18. * @author chenyu
  19. * @date 2023/9/6
  20. */
  21. @SpringBootTest
  22. public class EsServiceTests {
  23. @Autowired
  24. private EsService esService;
  25. @Autowired
  26. private RedisUtil redisUtil;
  27. @Autowired
  28. private SchedulingTaskService importTaskAdd;
  29. @Test
  30. void addPatent() throws Exception {
  31. Patent patent =new Patent();
  32. patent.setPatentNo("CN202023204739.4");
  33. String id = esService.addPatent(patent);
  34. System.out.println(id);
  35. }
  36. @Test
  37. void getPatentByPatentNo() throws Exception {
  38. //根据专利号获得id
  39. PatentWithIdVO patentWithIdVO = esService.getIdByPatentNo("CN201114765Y");
  40. Patent patent =new Patent();
  41. patent.setAgency("张三");
  42. Patent orgPatent =patentWithIdVO.getPatent();
  43. BeanUtils.copyProperties(patent,orgPatent, FormatUtil.getNullPropertyNames(patent));
  44. esService.updateDocument(orgPatent,patentWithIdVO.getId());
  45. System.out.println();
  46. }
  47. @Test
  48. void updatePatent() throws Exception{
  49. }
  50. @Test
  51. void addImportTask() throws Exception {
  52. List<Patent> patentList = esService.search("1",1,10);
  53. System.out.println(patentList);
  54. Thread.sleep(1000000);
  55. }
  56. @Test
  57. void search() throws Exception {
  58. List<PatentDTO> list = esService.esSearch("patentNo=CN201199922Y and simpleFamilyNum>1 or simpleFamilyNum=0", 0, 50,null);
  59. // List<Patent> list = esService.Search("titleTextContent=电子 or projectId=1", 0, 50,null);
  60. // List<Patent> list = esService.Search("patentNo=CN201199922Y and simpleFamilyNum>1", 0, 50,null);
  61. // List<Patent> list = esService.Search("publicDate=2009-03", 0, 50,null);
  62. // List<Patent> list = esService.Search("simpleFamilyNum>1", 0, 50,null);
  63. // List<Patent> list = esService.Search("titleTextContent=电子", 0, 50,null);
  64. // List<Patent> list = esService.Search("projectId=1", 0, 50,null);
  65. // List<Patent> list = esService.search("patentNo=CN201199922Y", 0, 50);
  66. System.out.println(list);
  67. }
  68. }