package cn.cslg.pas.service; import cn.cslg.pas.common.dto.PatentDTO; import cn.cslg.pas.common.utils.FormatUtil; import cn.cslg.pas.common.utils.RedisUtil; import cn.cslg.pas.common.vo.PatentWithIdVO; import cn.cslg.pas.domain.es.Patent; import cn.cslg.pas.service.business.es.EsService; import cn.cslg.pas.service.importPatent.SchedulingTaskService; import cn.hutool.core.util.XmlUtil; import org.junit.Test; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import javax.swing.text.Document; import java.io.IOException; import java.util.List; /** * @author chenyu * @date 2023/9/6 */ @SpringBootTest public class EsServiceTests { @Autowired private EsService esService; @Autowired private RedisUtil redisUtil; @Autowired private SchedulingTaskService importTaskAdd; @Test void addPatent() throws Exception { Patent patent =new Patent(); patent.setPatentNo("CN202023204739.4"); String id = esService.addPatent(patent); System.out.println(id); } @Test void getPatentByPatentNo() throws Exception { //根据专利号获得id PatentWithIdVO patentWithIdVO = esService.getIdByPatentNo("CN201114765Y"); Patent patent =new Patent(); patent.setAgency("张三"); Patent orgPatent =patentWithIdVO.getPatent(); BeanUtils.copyProperties(patent,orgPatent, FormatUtil.getNullPropertyNames(patent)); esService.updateDocument(orgPatent,patentWithIdVO.getId()); System.out.println(); } @Test void updatePatent() throws Exception{ } @Test void addImportTask() throws Exception { List patentList = esService.search("1",1,10); System.out.println(patentList); Thread.sleep(1000000); } @Test void search() throws Exception { List list = esService.esSearch("patentNo=CN201199922Y and simpleFamilyNum>1 or simpleFamilyNum=0", 0, 50,null); // List list = esService.Search("titleTextContent=电子 or projectId=1", 0, 50,null); // List list = esService.Search("patentNo=CN201199922Y and simpleFamilyNum>1", 0, 50,null); // List list = esService.Search("publicDate=2009-03", 0, 50,null); // List list = esService.Search("simpleFamilyNum>1", 0, 50,null); // List list = esService.Search("titleTextContent=电子", 0, 50,null); // List list = esService.Search("projectId=1", 0, 50,null); // List list = esService.search("patentNo=CN201199922Y", 0, 50); System.out.println(list); } }