EventServiceTests.java 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. package cn.cslg.pas.service;
  2. import cn.cslg.pas.common.dto.PatentDTO;
  3. import cn.cslg.pas.common.dto.PatentDetailDTO;
  4. import cn.cslg.pas.common.dto.PatentKinDTO;
  5. import cn.cslg.pas.common.dto.business.EsCountDTO;
  6. import cn.cslg.pas.common.dto.business.EsPatentFamilyDTO;
  7. import cn.cslg.pas.common.dto.business.ReportTempleDTO;
  8. import cn.cslg.pas.common.dto.business.SelectClaimDTO;
  9. import cn.cslg.pas.common.dto.es.EsCustomFieldDTO;
  10. import cn.cslg.pas.common.model.cronModel.Records;
  11. import cn.cslg.pas.common.model.request.*;
  12. import cn.cslg.pas.common.utils.Response;
  13. import cn.cslg.pas.common.vo.business.EsCountVO;
  14. import cn.cslg.pas.common.vo.business.PatentKinVO;
  15. import cn.cslg.pas.common.vo.business.PatentNoVO;
  16. import cn.cslg.pas.common.vo.business.TempleByReportTypeVO;
  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.PatentFamilyMessage;
  21. import cn.cslg.pas.service.business.ProductMarketDataService;
  22. import cn.cslg.pas.service.business.TempleService;
  23. import cn.cslg.pas.service.business.es.EsCountService;
  24. import cn.cslg.pas.service.business.es.EsCustomFieldService;
  25. import cn.cslg.pas.service.business.es.EsService;
  26. import cn.cslg.pas.service.business.es.EsPatentService;
  27. import com.alibaba.fastjson.JSONObject;
  28. import org.apache.http.entity.ContentType;
  29. import org.junit.jupiter.api.Test;
  30. import org.springframework.beans.factory.annotation.Autowired;
  31. import org.springframework.boot.test.context.SpringBootTest;
  32. import org.springframework.mock.web.MockMultipartFile;
  33. import org.springframework.web.multipart.MultipartFile;
  34. import java.io.File;
  35. import java.io.FileInputStream;
  36. import java.io.IOException;
  37. import java.util.*;
  38. import java.util.function.Function;
  39. import java.util.stream.Collectors;
  40. /**
  41. * @author chenyu
  42. * @date 2023/9/6
  43. */
  44. @SpringBootTest
  45. public class EventServiceTests {
  46. @Autowired
  47. private EventController eventController;
  48. @Autowired
  49. PatentController patentController;
  50. @Autowired
  51. private EsService esService;
  52. @Autowired
  53. private EsCountService esCountService;
  54. @Autowired
  55. private TempleService templeService;
  56. @Autowired
  57. private EsPatentService patentService;
  58. @Autowired
  59. private EsCustomFieldService esCustomFieldService;
  60. @Autowired
  61. private ProductMarketDataService productMarketDataService;
  62. @Test
  63. void test() throws Exception {
  64. StringRequest queryRequest = new StringRequest();
  65. queryRequest.setSearchQuery("id=52");
  66. List<OrderDTO> dtos = new ArrayList<>();
  67. OrderDTO orderDTO1 = new OrderDTO();
  68. orderDTO1.setOrderBy("name");
  69. orderDTO1.setOrderType(0);
  70. OrderDTO orderDTO2 = new OrderDTO();
  71. orderDTO2.setOrderBy("createName");
  72. orderDTO2.setOrderType(1);
  73. dtos.add(orderDTO1);
  74. dtos.add(orderDTO2);
  75. queryRequest.setOrderDTOList(dtos);
  76. queryRequest.setCurrent(Long.parseLong("1"));
  77. queryRequest.setSize(Long.parseLong("10"));
  78. Response response = eventController.queryEvent(queryRequest);
  79. System.out.println(response); }
  80. @Test
  81. void add() throws Exception {
  82. JSONObject jsonObj = new JSONObject();
  83. jsonObj.put("name", "事件4");
  84. jsonObj.put("description", "描述1");
  85. jsonObj.put("clientId", 1);
  86. jsonObj.put("scenarioId", 2);
  87. jsonObj.put("eventDate","");
  88. String json_to_string = JSONObject.toJSONString(jsonObj);
  89. List<MultipartFile> list = new ArrayList<>();
  90. File file = new File("C:\\Users\\admin\\Desktop\\test.txt");
  91. MultipartFile mulFile = new MockMultipartFile(
  92. "th.jpg", //文件名
  93. "th.jpg", //originalName 相当于上传文件在客户机上的文件名
  94. ContentType.APPLICATION_OCTET_STREAM.toString(), //文件类型
  95. new FileInputStream(file) //文件流
  96. );
  97. list.add(mulFile);
  98. eventController.addEvent(json_to_string, list);
  99. }
  100. @Test
  101. void groupEvent() throws Exception {
  102. StringGroupRequest queryRequest = new StringGroupRequest();
  103. queryRequest.setSearchQuery("name~事件 and createName=朱");
  104. List<OrderDTO> dtos = new ArrayList<>();
  105. OrderDTO orderDTO1 = new OrderDTO();
  106. orderDTO1.setOrderBy("name");
  107. orderDTO1.setOrderType(0);
  108. OrderDTO orderDTO2 = new OrderDTO();
  109. orderDTO2.setOrderBy("createName");
  110. orderDTO2.setOrderType(1);
  111. dtos.add(orderDTO1);
  112. dtos.add(orderDTO2);
  113. queryRequest.setOrderDTOList(dtos);
  114. queryRequest.setCurrent(Long.parseLong("1"));
  115. queryRequest.setSize(Long.parseLong("10"));
  116. queryRequest.setGroupBy("name");
  117. eventController.groupEvent(queryRequest);
  118. }
  119. @Test
  120. void test1() throws Exception {
  121. StringGroupRequest groupRequest = new StringGroupRequest();
  122. groupRequest.setGroupBy("groupMonthTime");
  123. Records records=(Records) productMarketDataService.getGroup(groupRequest,"productMarketData");
  124. System.out.println(records);
  125. }
  126. @Test
  127. void test11() throws Exception {
  128. // List<Patent> list = esService.Search("publicDate=2009-03", 0, 50,null);
  129. // MapRequest mapRequest = new MapRequest();
  130. // Map<String, Object> map = new HashMap<>();
  131. // map.put("titleTextContent", "电子");
  132. // map.put("patentNo", "CN201199922Y");
  133. // mapRequest.setSearchQuery(map);
  134. // mapRequest.setCurrent(0L);
  135. // mapRequest.setSize(50L);
  136. // mapRequest.setProjectId(1);
  137. StringRequest stringRequest = new StringRequest();
  138. // stringRequest.setSearchQuery("appCity=济南");
  139. // stringRequest.setSearchQuery("mipcLevel1=H");
  140. // stringRequest.setSearchQuery("agent=李桂存");
  141. // stringRequest.setSearchQuery("IN=郝旭东");
  142. // stringRequest.setSearchQuery("simpleStatus=3");
  143. // stringRequest.setSearchQuery("publicFullText=本申请涉及直流输电技术领域");
  144. // stringRequest.setSearchQuery("AB=本申请提供一种储能系统机电暂态建模方法、装置、设备及可读存储介质");
  145. // stringRequest.setSearchQuery("TI=储能系统机电暂态建模方法、装置、设备及可读存储介质");
  146. // stringRequest.setSearchQuery("PN=CN114513005B");
  147. // stringRequest.setSearchQuery("AN=CN201810025278.2");
  148. // stringRequest.setSearchQuery("patentNo=CN");
  149. stringRequest.setSearchQuery("PD<=200903");
  150. // stringRequest.setSearchQuery("patentNo=CN201199922Y and (simpleFamilyNum>1 or simpleFamilyNum=0)");
  151. stringRequest.setCurrent(1L);
  152. stringRequest.setSize(5L);
  153. // stringRequest.setProjectId(1);
  154. //
  155. PatentDTO patentDTO = esService.esSearch(stringRequest);
  156. System.out.println(patentDTO);
  157. }
  158. @Test
  159. void test12() throws IOException {
  160. Boolean bool = esService.searchPatent("YiQCGowBmB3pRkTj4NNG", 5);
  161. System.out.println(bool);
  162. }
  163. @Test
  164. void getpagetexst() throws IOException{
  165. //1.添加一批数据(10)
  166. //2.调用查询取第一页(5笔一页)
  167. //3.判断5笔数据是正确的;
  168. //4.删除测试数据
  169. List<Integer> list = Arrays.asList(1, 2, 3, 4);
  170. List<Integer> list1 = Arrays.asList(4, 5);
  171. // list1.removeAll(list);
  172. System.out.println(list1);
  173. }
  174. @Test
  175. void add1() throws Exception {
  176. List<FamilyPatent> list = new ArrayList<>();
  177. FamilyPatent patent =new FamilyPatent();
  178. patent.setAppNo("CN147258369");
  179. patent.setGrantNo("CN258369147");
  180. patent.setPublicNo("CN369258147");
  181. FamilyPatent patent1 =new FamilyPatent();
  182. patent1.setAppNo("US147258369");
  183. patent1.setGrantNo("US258369147");
  184. patent1.setPublicNo("US369258147");
  185. list.add(patent);
  186. list.add(patent1);
  187. PatentFamilyMessage patentFamilyMessage =new PatentFamilyMessage();
  188. patentFamilyMessage.setPatent(list);
  189. patentFamilyMessage.setFamilyType("test");
  190. String id = esService.addPatentFamily(patentFamilyMessage);
  191. System.out.println(id);
  192. }
  193. @Test
  194. void test3() throws IOException {
  195. List<String> stringList = Arrays.asList("US369258147", "US258369147", "14528");
  196. EsPatentFamilyDTO test = esService.addEsPatentFamily(stringList, "test");
  197. System.out.println(test);
  198. }
  199. @Test
  200. void test4() throws IOException {
  201. List<String> stringList = Arrays.asList("US369258147", "US258369147", "14528");
  202. EsPatentFamilyDTO test = esService.addEsPatentFamily(stringList, "test");
  203. System.out.println(test);
  204. }
  205. @Test
  206. void test5() throws IOException {
  207. SelectClaimDTO dto = esService.selectClaim("CN102324864A");
  208. System.out.println(dto);
  209. }
  210. @Test
  211. void test8() throws Exception {
  212. List<EsCountVO> countVOS = new ArrayList<>();
  213. EsCountVO vo1 = new EsCountVO();
  214. vo1.setField("childRaw");
  215. // vo.setField("CO");
  216. // vo.setField("PT");
  217. // vo1.setValueOne("国家电网公司");
  218. // vo.setValueOne("2022");
  219. // vo.setValueTwo("2024");
  220. // vo.setField("AD");
  221. EsCountVO vo2 = new EsCountVO();
  222. vo2.setField("AD");
  223. vo2.setValueOne("2022");
  224. vo2.setValueTwo("2023");
  225. countVOS.add(vo1);
  226. // countVOS.add(vo2);
  227. EsCountDTO esCountDTO = esCountService.esCountSearch(countVOS);
  228. System.out.println(esCountDTO);
  229. }
  230. @Test
  231. void test9() throws IOException {
  232. PatentNoVO vo = new PatentNoVO();
  233. vo.setPatentNo("CN201910069334.7");
  234. PatentDetailDTO columnDTO = patentService.selectPatentDetail(vo);
  235. System.out.println(columnDTO);
  236. // String s = "asfassafsafe";
  237. // Map<Character, Long> map = s.chars().mapToObj(c->(char)c).collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
  238. // System.out.println(map);
  239. //
  240. // List<String> stringList = Arrays.asList("apple", "apple", "balana", "origin", "apple", "balana");
  241. // Map<String, Long> collect = stringList.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
  242. // System.out.println("----" + collect);
  243. }
  244. @Test
  245. void test10() throws IOException {
  246. PatentKinVO vo = new PatentKinVO();
  247. vo.setPatentNo("CN201910069334.7");
  248. vo.setPageNum(1);
  249. vo.setPageSize(10);
  250. vo.setType("inpadoc");
  251. List<PatentKinDTO> kinDTOS = patentService.selectKinByPatentNo(vo);
  252. System.out.println(kinDTOS);
  253. }
  254. @Test
  255. void test14() {
  256. TempleByReportTypeVO vo = new TempleByReportTypeVO();
  257. vo.setReportType(1);
  258. List<ReportTempleDTO> reportTempleDTOS = templeService.queryTempleByType(vo);
  259. System.out.println(reportTempleDTOS);
  260. }
  261. @Test
  262. void test15() throws Exception {
  263. EsCustomFieldDTO dto = new EsCustomFieldDTO();
  264. dto.setProjectId(83);
  265. dto.setFieldType(5);
  266. dto.setFieldId("303");
  267. dto.setFieldValue(Arrays.asList("多选1","多选2"));
  268. dto.setOptionType(1);
  269. dto.setPatentNo("CN201910069334.7");
  270. esCustomFieldService.addCustomField(dto);
  271. }
  272. }