EventServiceTests.java 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. package cn.cslg.pas.service;
  2. import cn.cslg.pas.common.dto.*;
  3. import cn.cslg.pas.common.dto.business.EsPatentFamilyDTO;
  4. import cn.cslg.pas.common.dto.business.ReportTempleDTO;
  5. import cn.cslg.pas.common.dto.business.SelectClaimDTO;
  6. import cn.cslg.pas.common.dto.es.EsCustomFieldDTO;
  7. import cn.cslg.pas.common.dto.es.EsCustomFieldValueDTO;
  8. import cn.cslg.pas.common.model.cronModel.Records;
  9. import cn.cslg.pas.common.model.request.*;
  10. import cn.cslg.pas.common.utils.Response;
  11. import cn.cslg.pas.common.utils.StringUtils;
  12. import cn.cslg.pas.common.utils.parseQueryToTree.expressManager;
  13. import cn.cslg.pas.common.utils.parseQueryToTree.operateNode;
  14. import cn.cslg.pas.common.utils.parseQueryToTree.treeNode;
  15. import cn.cslg.pas.common.vo.EsExplainTextVO;
  16. import cn.cslg.pas.common.vo.business.*;
  17. import cn.cslg.pas.controller.EventController;
  18. import cn.cslg.pas.controller.PatentController;
  19. import cn.cslg.pas.domain.es.FamilyPatent;
  20. import cn.cslg.pas.domain.es.Patent;
  21. import cn.cslg.pas.domain.es.PatentFamilyMessage;
  22. import cn.cslg.pas.mapper.AssoProjectEventMapper;
  23. import cn.cslg.pas.service.business.MergePersonService;
  24. import cn.cslg.pas.service.business.ProductMarketDataService;
  25. import cn.cslg.pas.service.business.ReportTempleService;
  26. import cn.cslg.pas.service.business.es.*;
  27. import cn.cslg.pas.service.common.FileManagerService;
  28. import cn.cslg.pas.service.common.TranslateService;
  29. import cn.cslg.pas.service.query.FormatQueryService;
  30. import co.elastic.clients.elasticsearch.ElasticsearchClient;
  31. import co.elastic.clients.elasticsearch._types.query_dsl.Query;
  32. import co.elastic.clients.elasticsearch.core.SearchRequest;
  33. import co.elastic.clients.elasticsearch.core.SearchResponse;
  34. import co.elastic.clients.elasticsearch.core.search.Hit;
  35. import com.alibaba.fastjson.JSONObject;
  36. import org.apache.http.entity.ContentType;
  37. import org.junit.jupiter.api.Test;
  38. import org.springframework.beans.factory.annotation.Autowired;
  39. import org.springframework.boot.test.context.SpringBootTest;
  40. import org.springframework.mock.web.MockMultipartFile;
  41. import org.springframework.transaction.annotation.Propagation;
  42. import org.springframework.transaction.annotation.Transactional;
  43. import org.springframework.util.CollectionUtils;
  44. import org.springframework.web.multipart.MultipartFile;
  45. import java.io.File;
  46. import java.io.FileInputStream;
  47. import java.io.IOException;
  48. import java.math.BigDecimal;
  49. import java.util.*;
  50. import java.util.function.Function;
  51. import java.util.regex.Matcher;
  52. import java.util.regex.Pattern;
  53. import java.util.stream.Collectors;
  54. /**
  55. * @author chenyu
  56. * @date 2023/9/6
  57. */
  58. @SpringBootTest
  59. public class EventServiceTests {
  60. @Autowired
  61. private EventController eventController;
  62. @Autowired
  63. PatentController patentController;
  64. @Autowired
  65. private EsService esService;
  66. @Autowired
  67. private EsCountService esCountService;
  68. @Autowired
  69. private ReportTempleService templeService;
  70. @Autowired
  71. private EsPatentService patentService;
  72. @Autowired
  73. private EsCustomFieldService esCustomFieldService;
  74. @Autowired
  75. private MergePersonService mergePersonService;
  76. @Autowired
  77. private FileManagerService fileManagerService;
  78. @Autowired
  79. private ProductMarketDataService productMarketDataService;
  80. @Autowired
  81. private AssoProjectEventMapper assoProjectEventMapper;
  82. @Autowired
  83. private TranslateService translateService;
  84. @Test
  85. void test() throws Exception {
  86. StringRequest queryRequest = new StringRequest();
  87. queryRequest.setSearchQuery("id=52");
  88. List<OrderDTO> dtos = new ArrayList<>();
  89. OrderDTO orderDTO1 = new OrderDTO();
  90. orderDTO1.setOrderBy("name");
  91. orderDTO1.setOrderType(0);
  92. OrderDTO orderDTO2 = new OrderDTO();
  93. orderDTO2.setOrderBy("createName");
  94. orderDTO2.setOrderType(1);
  95. dtos.add(orderDTO1);
  96. dtos.add(orderDTO2);
  97. queryRequest.setOrderDTOList(dtos);
  98. queryRequest.setCurrent(Long.parseLong("1"));
  99. queryRequest.setSize(Long.parseLong("10"));
  100. Response response = eventController.queryEvent(queryRequest);
  101. System.out.println(response);
  102. }
  103. @Test
  104. void add() throws Exception {
  105. JSONObject jsonObj = new JSONObject();
  106. jsonObj.put("name", "事件4");
  107. jsonObj.put("description", "描述1");
  108. jsonObj.put("clientId", 1);
  109. jsonObj.put("scenarioId", 2);
  110. jsonObj.put("eventDate", "");
  111. String json_to_string = JSONObject.toJSONString(jsonObj);
  112. List<MultipartFile> list = new ArrayList<>();
  113. File file = new File("C:\\Users\\admin\\Desktop\\test.txt");
  114. MultipartFile mulFile = new MockMultipartFile(
  115. "th.jpg", //文件名
  116. "th.jpg", //originalName 相当于上传文件在客户机上的文件名
  117. ContentType.APPLICATION_OCTET_STREAM.toString(), //文件类型
  118. new FileInputStream(file) //文件流
  119. );
  120. list.add(mulFile);
  121. eventController.addEvent(json_to_string, list);
  122. }
  123. @Test
  124. void groupEvent() throws Exception {
  125. StringGroupRequest queryRequest = new StringGroupRequest();
  126. queryRequest.setSearchQuery("name~事件 and createName=朱");
  127. List<OrderDTO> dtos = new ArrayList<>();
  128. OrderDTO orderDTO1 = new OrderDTO();
  129. orderDTO1.setOrderBy("name");
  130. orderDTO1.setOrderType(0);
  131. OrderDTO orderDTO2 = new OrderDTO();
  132. orderDTO2.setOrderBy("createName");
  133. orderDTO2.setOrderType(1);
  134. dtos.add(orderDTO1);
  135. dtos.add(orderDTO2);
  136. queryRequest.setOrderDTOList(dtos);
  137. queryRequest.setCurrent(Long.parseLong("1"));
  138. queryRequest.setSize(Long.parseLong("10"));
  139. queryRequest.setGroupBy("name");
  140. eventController.groupEvent(queryRequest);
  141. }
  142. @Test
  143. void test1() throws Exception {
  144. StringGroupRequest groupRequest = new StringGroupRequest();
  145. groupRequest.setGroupBy("groupMonthTime");
  146. Records records = (Records) productMarketDataService.getGroup(groupRequest, "productMarketData");
  147. System.out.println(records);
  148. }
  149. @Test
  150. void test11() throws Exception {
  151. // List<Patent> list = esService.Search("publicDate=2009-03", 0, 50,null);
  152. // MapRequest mapRequest = new MapRequest();
  153. // Map<String, Object> map = new HashMap<>();
  154. // map.put("titleTextContent", "电子");
  155. // map.put("patentNo", "CN201199922Y");
  156. // mapRequest.setSearchQuery(map);
  157. // mapRequest.setCurrent(0L);
  158. // mapRequest.setSize(50L);
  159. // mapRequest.setProjectId(1);
  160. StringRequest stringRequest = new StringRequest();
  161. // stringRequest.setSearchQuery("appCity=济南");
  162. // stringRequest.setSearchQuery("mipcLevel1=H");
  163. // stringRequest.setSearchQuery("agent=李桂存");
  164. // stringRequest.setSearchQuery("IN=郝旭东");
  165. // stringRequest.setSearchQuery("simpleStatus=3");
  166. // stringRequest.setSearchQuery("publicFullText=本申请涉及直流输电技术领域");
  167. // stringRequest.setSearchQuery("AB=本申请提供一种储能系统机电暂态建模方法、装置、设备及可读存储介质");
  168. // stringRequest.setSearchQuery("TI=储能系统机电暂态建模方法、装置、设备及可读存储介质");
  169. // stringRequest.setSearchQuery("PN=CN114513005B");
  170. // stringRequest.setSearchQuery("AN=CN201810025278.2");
  171. // stringRequest.setSearchQuery("patentNo=CN");
  172. stringRequest.setSearchQuery("PD<=200903");
  173. // stringRequest.setSearchQuery("patentNo=CN201199922Y and (simpleFamilyNum>1 or simpleFamilyNum=0)");
  174. stringRequest.setCurrent(1L);
  175. stringRequest.setSize(5L);
  176. // stringRequest.setProjectId(1);
  177. //
  178. PatentDTO patentDTO = esService.esSearch(stringRequest);
  179. System.out.println(patentDTO);
  180. }
  181. @Test
  182. void test12() throws IOException {
  183. Boolean bool = esService.searchPatent("YiQCGowBmB3pRkTj4NNG", 5);
  184. System.out.println(bool);
  185. }
  186. @Test
  187. void getpagetexst() throws IOException {
  188. //1.添加一批数据(10)
  189. //2.调用查询取第一页(5笔一页)
  190. //3.判断5笔数据是正确的;
  191. //4.删除测试数据
  192. List<Integer> list = Arrays.asList(1, 2, 3, 4);
  193. List<Integer> list1 = Arrays.asList(4, 5);
  194. // list1.removeAll(list);
  195. System.out.println(list1);
  196. }
  197. @Test
  198. void add1() throws Exception {
  199. List<FamilyPatent> list = new ArrayList<>();
  200. FamilyPatent patent = new FamilyPatent();
  201. patent.setAppNo("CN147258369");
  202. patent.setGrantNo("CN258369147");
  203. patent.setPublicNo("CN369258147");
  204. FamilyPatent patent1 = new FamilyPatent();
  205. patent1.setAppNo("US147258369");
  206. patent1.setGrantNo("US258369147");
  207. patent1.setPublicNo("US369258147");
  208. list.add(patent);
  209. list.add(patent1);
  210. PatentFamilyMessage patentFamilyMessage = new PatentFamilyMessage();
  211. patentFamilyMessage.setPatent(list);
  212. patentFamilyMessage.setFamilyType("test");
  213. String id = esService.addPatentFamily(patentFamilyMessage);
  214. System.out.println(id);
  215. }
  216. @Test
  217. void test3() throws IOException {
  218. List<String> stringList = Arrays.asList("US369258147", "US258369147", "14528");
  219. }
  220. @Test
  221. void test4() throws IOException {
  222. List<String> stringList = Arrays.asList("US369258147", "US258369147", "14528");
  223. }
  224. @Test
  225. void test5() throws IOException {
  226. SelectClaimDTO dto = esService.selectClaim("CN102324864A");
  227. System.out.println(dto);
  228. }
  229. @Test
  230. void test8() throws Exception {
  231. List<EsCountVO> countVOS = new ArrayList<>();
  232. EsCountVO vo1 = new EsCountVO();
  233. vo1.setField("childRaw");
  234. // vo.setField("CO");
  235. // vo.setField("PT");
  236. // vo1.setValueOne("国家电网公司");
  237. // vo.setValueOne("2022");
  238. // vo.setValueTwo("2024");
  239. // vo.setField("AD");
  240. EsCountVO vo2 = new EsCountVO();
  241. vo2.setField("AD");
  242. vo2.setValueOne("2022");
  243. vo2.setValueTwo("2023");
  244. countVOS.add(vo1);
  245. // countVOS.add(vo2);
  246. // EsCountDTO esCountDTO = esCountService.esCountSearch(countVOS);
  247. // System.out.println(esCountDTO);
  248. }
  249. @Test
  250. void test9() throws IOException {
  251. // PatentNoVO vo = new PatentNoVO();
  252. // vo.setPatentNo("CN201910069334.7");
  253. // PatentColumnDTO columnDTO = patentService.selectPatentDetail(vo);
  254. // System.out.println(columnDTO);
  255. String s = "asfassafsafe";
  256. Map<Character, Long> map = s.chars().mapToObj(c -> (char) c).collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
  257. System.out.println(map);
  258. List<String> stringList = Arrays.asList("apple", "apple", "balana", "origin", "apple", "balana");
  259. Map<String, Long> collect = stringList.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
  260. System.out.println("----" + collect);
  261. }
  262. @Test
  263. void test10() throws IOException {
  264. PatentKinVO vo = new PatentKinVO();
  265. vo.setPatentNo("CN201910069334.7");
  266. vo.setPageNum(1);
  267. vo.setPageSize(10);
  268. vo.setType("inpadoc");
  269. Records records = patentService.selectKinByPatentNo(vo);
  270. System.out.println(records);
  271. }
  272. @Test
  273. void test14() {
  274. TempleByReportTypeVO vo = new TempleByReportTypeVO();
  275. vo.setReportType(1);
  276. List<ReportTempleDTO> reportTempleDTOS = templeService.queryTempleByType(vo);
  277. System.out.println(reportTempleDTOS);
  278. }
  279. @Test
  280. void test15() throws Exception {
  281. EsCustomFieldDTO dto = new EsCustomFieldDTO();
  282. dto.setProjectId(83);
  283. dto.setFieldType(5);
  284. dto.setFieldId("303");
  285. dto.setFieldValue(Arrays.asList("多选1", "多选2"));
  286. dto.setOptionType(1);
  287. dto.setPatentNo("CN201910069334.7");
  288. esCustomFieldService.addCustomField(dto);
  289. }
  290. @Test
  291. void test16() throws Exception {
  292. List<EsCustomFieldValueDTO> customFields = new ArrayList<>();
  293. EsCustomFieldValueDTO dto1 = new EsCustomFieldValueDTO();
  294. dto1.setFieldId("1");
  295. dto1.setFieldValue(Arrays.asList("a"));
  296. EsCustomFieldValueDTO dto2 = new EsCustomFieldValueDTO();
  297. dto2.setFieldId("2");
  298. dto2.setFieldValue(Arrays.asList("a"));
  299. customFields.add(dto1);
  300. customFields.add(dto2);
  301. String s = esService.parseCustomField(customFields, null, null);
  302. System.out.println("结果为:" + s);
  303. System.out.println("-----------------------------");
  304. List<EsCustomFieldValueDTO> fields = new ArrayList<>();
  305. }
  306. @Test
  307. void test17() throws IOException {
  308. List<String> list = new ArrayList<>();
  309. list.add("CN201910069334.7");
  310. list.add("CN201110286649.0");
  311. list.add("CN200820185104.4");
  312. SelectClaimDTO dto = esService.selectPatentNo(list);
  313. System.out.println(dto);
  314. }
  315. @Test
  316. void test18() {
  317. List<String> list = Arrays.asList("AD");
  318. if (list.contains("AD")) {
  319. String str = "AD=2008~201009";
  320. String s = this.get(str);
  321. if (s.contains("~")) {
  322. int i = s.indexOf("~");
  323. // s.substring()
  324. String s1 = this.get(s);
  325. System.out.println("-------------");
  326. System.out.println("s1是:" + s1);
  327. }
  328. } else {
  329. System.out.println("DDDDDDDDDDDDDDDDDD");
  330. }
  331. }
  332. public String get(String str) {
  333. int i = str.indexOf("AD");
  334. String s = str.substring(str.indexOf("AD")).toUpperCase(Locale.ROOT);
  335. int length = s.length();//------
  336. String key = s.substring(0, s.indexOf("="));
  337. int i2 = s.indexOf("=");
  338. String s1 = s.substring(s.indexOf("=") + 1, s.indexOf("~"));
  339. String s2 = "";
  340. if (s.contains("AND")) {
  341. s2 = s.substring(s.indexOf("~") + 1, s.indexOf("AND"));
  342. } else {
  343. s2 = s.substring(s.indexOf("~") + 1).trim();
  344. }
  345. int index = str.indexOf(key);
  346. int index1 = str.indexOf(s2) + s2.length();
  347. int i1 = index + key.length() + 1 + s1.length() + 1 + s2.length();
  348. String substring = str.substring(index, i1);
  349. String concat = key.concat(">=").concat(s1).concat(" and ").concat(key).concat("<=").concat(s2);
  350. System.out.println(concat);
  351. String replace = str.replace(substring, concat);
  352. System.out.println(replace);
  353. return replace;
  354. }
  355. @Test
  356. public void aaaaa() throws Exception {
  357. List<String> list = Arrays.asList("gh,ji");
  358. String str = "[";
  359. if (list.size() >= 1) {
  360. for (int i = 0; i < list.size(); i++) {
  361. String s = list.get(i);
  362. if (i == list.size() - 1) {
  363. str = str + "\"" + s + "\"";
  364. } else {
  365. str = str + "\"" + s + "\"" + ",";
  366. }
  367. }
  368. } else {
  369. }
  370. str = str + "]";
  371. System.out.println(str + "------------");
  372. String projectId = "ctx._source.custom_field.project_id = " + 1 + ";" + "\n";
  373. String field = "ctx._source.custom_field.field=" + 1 + ";" + "\n";
  374. String fieldType = "ctx._source.custom_field.field_type = " + 1 + ";" + "\n";
  375. String personId = "ctx._source.custom_field.person_id = " + 1 + ";" + "\n";
  376. String createTime = "ctx._source.custom_field.create_time = " + new Date().getTime() + ";" + "\n";
  377. String fieldValue = "ctx._source.custom_field.field_value = " + str + ";" + "\n";
  378. String statsValue = "ctx._source.custom_field.stats_value = " + list;
  379. String source = "\"" + projectId + field + fieldType + personId + createTime + fieldValue + statsValue + "\"";
  380. // String source = "\"\"ctx._source.custom_field.project_id = " + 1 + ";" + "\n" +
  381. // "ctx._source.custom_field.field=" + 2 + ";" + "\n" + "\"\"";
  382. System.out.println(source);
  383. Patent patent = new Patent();
  384. String id = "hy7ayIwB68vilgBjUWBz";
  385. String name = "士大夫";
  386. Integer type = 0;
  387. esService.delMergePerson(patent, id, type, name);
  388. }
  389. @Test
  390. public void test100() {
  391. List<GetAllPersonDTO> DTOS = new ArrayList<>();
  392. List<GetAllPersonDTO> applicantDTOS = new ArrayList<>();
  393. GetAllPersonDTO dto = new GetAllPersonDTO();
  394. dto.setName("A");
  395. dto.setType(0);
  396. dto.setCountry("CN");
  397. dto.setAddress("efe");
  398. applicantDTOS.add(dto);
  399. GetAllPersonDTO dto1 = new GetAllPersonDTO();
  400. dto1.setName("B");
  401. dto1.setType(0);
  402. dto1.setCountry("CN");
  403. dto1.setAddress("weew");
  404. applicantDTOS.add(dto1);
  405. GetAllPersonDTO dto2 = new GetAllPersonDTO();
  406. dto2.setName("C");
  407. dto2.setType(0);
  408. dto2.setCountry("CN");
  409. dto2.setAddress("fdsyt");
  410. applicantDTOS.add(dto2);
  411. List<GetAllPersonDTO> rightDTOS = new ArrayList<>();
  412. GetAllPersonDTO dto4 = new GetAllPersonDTO();
  413. dto4.setName("A");
  414. dto4.setType(0);
  415. dto4.setCountry("CN");
  416. dto4.setAddress("efed");
  417. rightDTOS.add(dto4);
  418. GetAllPersonDTO dto5 = new GetAllPersonDTO();
  419. dto5.setName("D");
  420. dto5.setType(0);
  421. dto5.setCountry("CN");
  422. dto5.setAddress("ete");
  423. rightDTOS.add(dto5);
  424. GetAllPersonDTO dto6 = new GetAllPersonDTO();
  425. dto6.setName("E");
  426. dto6.setType(0);
  427. rightDTOS.add(dto6);
  428. applicantDTOS.removeAll(rightDTOS);
  429. System.out.println(applicantDTOS + "-----------------");
  430. for (GetAllPersonDTO applicantDTO : applicantDTOS) {
  431. rightDTOS.removeIf(rightDTO -> applicantDTO.getName().equals(rightDTO.getName()));
  432. }
  433. System.out.println(applicantDTOS);
  434. System.out.println(rightDTOS);
  435. DTOS.addAll(applicantDTOS);
  436. DTOS.addAll(rightDTOS);
  437. System.out.println("DTOS:" + DTOS);
  438. }
  439. @Test
  440. public void test101() {
  441. String a = " DESC";
  442. List<Integer> ids = assoProjectEventMapper.getEventProjectNumOrder(0, a);
  443. System.out.println(ids);
  444. }
  445. @Test
  446. public void test102() {
  447. String s = "a47efjerAksu&*s/e";
  448. String s2 = s.replaceAll("[^a-zA-Z]", "").toLowerCase(Locale.ROOT);
  449. String p = s.replace("/", "P");
  450. System.out.println(p);
  451. System.out.println("s2 = " + s2);
  452. List<Character> list1 = Arrays.asList('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n');
  453. String s1 = s.toLowerCase(Locale.ROOT);
  454. int length = s1.length();
  455. List<Character> list = new ArrayList<>();
  456. for (int i = 0; i < length; i++) {
  457. char c = s1.charAt(i);
  458. if (list1.contains(c)) {
  459. list.add(c);
  460. }
  461. }
  462. Collections.sort(list);
  463. System.out.println(list);
  464. String join = StringUtils.join(list, "");
  465. System.out.println("------" + join);
  466. Map<Character, Long> collect = list.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
  467. System.out.println(collect);
  468. }
  469. @Test
  470. public void test103() throws Exception {
  471. GetAllPersonVO personVO = new GetAllPersonVO();
  472. personVO.setProjectId(208);
  473. personVO.setType(0);
  474. personVO.setPageNum(1l);
  475. personVO.setPageSize(10l);
  476. Records mergePerson = mergePersonService.getAllMergePerson(personVO);
  477. Object personData = mergePerson.getData();
  478. System.out.println(personData);
  479. }
  480. @Test
  481. public void test104() throws Exception {
  482. // List<String> parentIds = esCountService.getParentIds(44, null, 290);
  483. // System.out.println(parentIds.size());
  484. // parentIds.forEach(System.out::println);
  485. // List<String> idsList = esService.getIdsList("(field=44 and fieldValue=48)",null);
  486. // System.out.println(idsList);
  487. // Long idsCount = esService.getIdsCount("NCOQKI8Bz9TGU8OYquJE",null,null);
  488. // System.out.println(idsCount);
  489. // String s = "(field=44 and fieldValue=48)";
  490. // String s1 = s.substring(0, s.indexOf("and")-1)+")";
  491. // System.out.println(s1);
  492. // if (s.contains("48")) {
  493. // System.out.println("shduahdi");
  494. // }
  495. // String ids = esService.getIds("t53GZY8BdwlBaY8vOJFq", 319, null, "105");
  496. // System.out.println(ids);
  497. String s = "CN200380003758.0 OR CN200380024517.4 OR CN200380002092.7 \n" +
  498. "OR CN200210053627.0 OR CN199210014159.1 OR JP2024032943A OR CN200310042440.5 OR CN199710090727.9 OR CN199610096572.5 OR CN199410009036.8 \n" +
  499. "OR CN200210043340.X OR CN199710098829.5 OR CN199310003139.9 OR CN198910000939.9 \n" +
  500. "OR CN198820004617.2 OR CN198910000787.2 OR CN198710003233.9";
  501. String[] split = s.split("OR");
  502. List<String> list = Arrays.asList(split);
  503. System.out.println(list.size());
  504. List<String> collect = list.stream().distinct().collect(Collectors.toList());
  505. System.out.println(collect.size());
  506. }
  507. @Test
  508. public void test105() {
  509. String value = "2003800037580";
  510. String sub = value.substring(0, 2);
  511. boolean positiveInteger = StringUtils.isPositiveInteger(sub);
  512. System.out.println(positiveInteger);
  513. if ((StringUtils.isPositiveInteger(sub) || sub.equalsIgnoreCase("CN")) && (value.length() == 13 || value.length() == 15)) {
  514. System.out.println("A");
  515. } else {
  516. System.out.println("B");
  517. }
  518. }
  519. @Test
  520. public void test106() throws Exception {
  521. String s1 = "1. A compound vibration device in a bone conduction speaker, comprising:\r\na vibration conductive plate, and a vibration board; wherein the vibration conductive plate is physically connected with the vibration board, vibrations generated by the vibration conductive plate and the vibration board have two resonance peaks which are among the frequencies catchable with human ears, and sounds are generated by the vibrations transferred through a human bone.\\r\\n2. The compound vibration device according to claim 1, wherein the vibration conductive plate is set as a first torus, and at least two first rods thereof converge to its center.\\r\\n3. The compound vibration device according to claim 2, wherein the vibration board is set as a second torus, and at least two second rods thereof converge to its center.\\r\\n4. The compound vibration according to claim 3, wherein the first torus is fixed on a magnetic system.\\r\\n5. The compound vibration according to claim 4, further comprising a voice coil, wherein the voice coil is driven by the magnetic system and fixed on the second torus.\\r\\n6. The compound vibration device according to claim 5, wherein the vibration conductive plate rods are staggered with the vibration board rods.\\r\\n7. The compound vibration device according to claim 6, wherein the staggered angle between the rods is 60 degrees.\\r\\n8. The compound vibration device according to claim 5, wherein:\\r\\nthe vibration conductive plate is made of stainless steel, with a thickness of 0.1-0.2 mm,\\r\\nthe width of the first rods in the vibration conductive plate is 0.5-1.0 mm, and\\r\\nthe width of the second rods in the vibration board is 1.6-2.6 mm, with a thickness of 0.8-1.2 mm.\\r\\n9. The compound vibration according to claim 5, wherein the number of the vibration conductive plates and the vibration boards is set to be more than one, and the vibration conductive plates and the vibration boards are fixed together through their centers and/or the torus.\\r\\n10. The compound vibration device according to claim 5, wherein the magnetic system comprising:\\r\\na bottom plate,\\r\\nan annular magnet which is set on the bottom plate,\\r\\nan inner magnet which is concentrically disposed inside the annular magnet,\\r\\nan inner magnetic conductive plate which is set on the inner magnet,\\r\\nan annular magnetic conductive plate which is set on the annular magnet,\\r\\na grommet which is set on the annular magnetic conductive plate to be fixed to the first torus, and\\r\\nthe voice coil is set between the inner magnetic conductive plate and the annular magnetic plate.\\r\\n11. The compound vibration device according to claim 5, wherein the numbers of the first rods and the second rods are both set to be three.\\r\\n12. The compound vibration according to claim 5, wherein the first rods and the second rods are both straight rods.\\r\\n13. The compound vibration device according to claim 5, wherein an indentation is set at the center of the vibration board, which adapts to the vibration conductive plate.\\r\\n14. A bone conduction speaker, comprising a compound vibration device having a vibration conductive plate and a vibration board; wherein:\\r\\n the vibration conductive plate is physically connected with the vibration board, and vibrations generated by the vibration conductive plate and the vibration board have two resonance peaks which are among the frequencies catchable with human ears, and sounds are generated by the vibrations transferred through a human bone.\\r\\n15. The bone conduction speaker according to claim 14, wherein the vibration conductive plate is set as a first torus, and at least two first rods thereof converge to its center.\\r\\n16. The bone conduction speaker according to claim 15, wherein the vibration board is set as a second torus, and at least two second rods thereof converge to its center.\\r\\n17. The bone conduction speaker according to claim 16, wherein the first torus is fixed on a magnetic system.\\r\\n18. The bone conduction speaker according to claim 17, further comprising a voice coil, wherein the voice coil is driven by the magnetic system and is fixed on the second torus.\\r\\n19. The bone conduction speaker according to claim 18, wherein the magnetic system comprising:\\r\\na bottom plate,\\r\\nan annular magnet which is set on the bottom plate,\\r\\nan inner magnet which is concentrically disposed inside the annular magnet,\\r\\nan inner magnetic conductive plate which is set on the inner magnet,\\r\\n an annular magnetic conductive plate which is set on the annular magnet,\\r\\n a grommet which is set on the annular magnetic conductive plate to be fixed to the first torus, and\\r\\n the voice coil is set between the inner magnetic conductive plate and the annular magnetic plate.\\r\\n20. The bone conduction speaker according to claim 18, wherein the vibration conductive plate is made of stainless steel, with a thickness of 0.1-0.2 mm; and the width of the first rods in the vibration conductive plate is 0.5-1.0 mm;\\r\\nand the width of the second rods in the vibration board is 1.6-2.6 mm, with a thickness of 0. 8-1.2 mm.";
  522. String regex = "(?<!\\d)\\.(?!\\d)|[;。;]";
  523. String regex1 = "(?<!\\d)\\.(?!\\d)";
  524. Pattern pattern = Pattern.compile(regex);
  525. Pattern pattern1 = Pattern.compile(regex1);
  526. String ss = "";
  527. while (s1.length() > 5000) {
  528. String s2 = s1.substring(0, 5000);
  529. Matcher matcher = pattern.matcher(s2);
  530. Matcher matcher1 = pattern1.matcher(s2);
  531. int lastIndex = -1;
  532. while (matcher.find()) {
  533. lastIndex = matcher.end() - 1; // matcher.end() 返回的是匹配项之后的索引,所以减1得到最后一个字符的索引
  534. }
  535. if (lastIndex == -1) {
  536. while (matcher1.find()) {
  537. lastIndex = matcher1.end() - 1; // matcher.end() 返回的是匹配项之后的索引,所以减1得到最后一个字符的索引
  538. }
  539. }
  540. ss = ss + s1.substring(0, lastIndex + 1);
  541. s1 = s1.substring(lastIndex + 1);
  542. }
  543. System.out.println("s1:" + s1);
  544. ss = ss + s1;
  545. System.out.println(ss);
  546. }
  547. @Autowired
  548. private FormatQueryService formatQueryService;
  549. @Autowired
  550. private ElasticsearchClient client;
  551. @Test
  552. public void test107() throws Exception {
  553. String s = "IFN=3~4"; //条件
  554. SearchRequest.Builder builder = new SearchRequest.Builder();
  555. //设置查询索引
  556. builder.index("patent");
  557. //2、根据条件生成树结构
  558. treeNode tree = expressManager.getInstance().Parse(s, false);
  559. Query query = formatQueryService.EsQueryToQuery((operateNode) tree, "patent", 331);
  560. builder.query(query);
  561. SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
  562. final List<Hit<Patent>> hits = response.hits().hits();
  563. for (Hit<Patent> hit : hits) {
  564. System.out.println(1);
  565. }
  566. }
  567. }