123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490 |
- package cn.cslg.pas.service;
- import cn.cslg.pas.common.dto.*;
- import cn.cslg.pas.common.dto.business.EsPatentFamilyDTO;
- import cn.cslg.pas.common.dto.business.ReportTempleDTO;
- import cn.cslg.pas.common.dto.business.SelectClaimDTO;
- import cn.cslg.pas.common.dto.es.EsCustomFieldDTO;
- import cn.cslg.pas.common.dto.es.EsCustomFieldValueDTO;
- import cn.cslg.pas.common.model.cronModel.Records;
- import cn.cslg.pas.common.model.request.*;
- import cn.cslg.pas.common.utils.Response;
- import cn.cslg.pas.common.vo.business.EsCountVO;
- import cn.cslg.pas.common.vo.business.PatentKinVO;
- import cn.cslg.pas.common.vo.business.PatentNoVO;
- import cn.cslg.pas.common.vo.business.TempleByReportTypeVO;
- import cn.cslg.pas.controller.EventController;
- import cn.cslg.pas.controller.PatentController;
- import cn.cslg.pas.domain.es.FamilyPatent;
- import cn.cslg.pas.domain.es.Patent;
- import cn.cslg.pas.domain.es.PatentFamilyMessage;
- import cn.cslg.pas.service.business.MergePersonService;
- import cn.cslg.pas.service.business.ProductMarketDataService;
- import cn.cslg.pas.service.business.ReportTempleService;
- import cn.cslg.pas.service.business.es.EsCountService;
- import cn.cslg.pas.service.business.es.EsCustomFieldService;
- import cn.cslg.pas.service.business.es.EsService;
- import cn.cslg.pas.service.business.es.EsPatentService;
- import com.alibaba.fastjson.JSONObject;
- import org.apache.http.entity.ContentType;
- import org.junit.jupiter.api.Test;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.boot.test.context.SpringBootTest;
- import org.springframework.mock.web.MockMultipartFile;
- import org.springframework.transaction.annotation.Propagation;
- import org.springframework.transaction.annotation.Transactional;
- import org.springframework.web.multipart.MultipartFile;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.IOException;
- import java.util.*;
- import java.util.stream.Collectors;
- /**
- * @author chenyu
- * @date 2023/9/6
- */
- @SpringBootTest
- public class EventServiceTests {
- @Autowired
- private EventController eventController;
- @Autowired
- PatentController patentController;
- @Autowired
- private EsService esService;
- @Autowired
- private EsCountService esCountService;
- @Autowired
- private ReportTempleService templeService;
- @Autowired
- private EsPatentService patentService;
- @Autowired
- private EsCustomFieldService esCustomFieldService;
- @Autowired
- private MergePersonService mergePersonService;
- @Autowired
- private ProductMarketDataService productMarketDataService;
- @Test
- void test() throws Exception {
- StringRequest queryRequest = new StringRequest();
- queryRequest.setSearchQuery("id=52");
- List<OrderDTO> dtos = new ArrayList<>();
- OrderDTO orderDTO1 = new OrderDTO();
- orderDTO1.setOrderBy("name");
- orderDTO1.setOrderType(0);
- OrderDTO orderDTO2 = new OrderDTO();
- orderDTO2.setOrderBy("createName");
- orderDTO2.setOrderType(1);
- dtos.add(orderDTO1);
- dtos.add(orderDTO2);
- queryRequest.setOrderDTOList(dtos);
- queryRequest.setCurrent(Long.parseLong("1"));
- queryRequest.setSize(Long.parseLong("10"));
- Response response = eventController.queryEvent(queryRequest);
- System.out.println(response);
- }
- @Test
- void add() throws Exception {
- JSONObject jsonObj = new JSONObject();
- jsonObj.put("name", "事件4");
- jsonObj.put("description", "描述1");
- jsonObj.put("clientId", 1);
- jsonObj.put("scenarioId", 2);
- jsonObj.put("eventDate", "");
- String json_to_string = JSONObject.toJSONString(jsonObj);
- List<MultipartFile> list = new ArrayList<>();
- File file = new File("C:\\Users\\admin\\Desktop\\test.txt");
- MultipartFile mulFile = new MockMultipartFile(
- "th.jpg", //文件名
- "th.jpg", //originalName 相当于上传文件在客户机上的文件名
- ContentType.APPLICATION_OCTET_STREAM.toString(), //文件类型
- new FileInputStream(file) //文件流
- );
- list.add(mulFile);
- eventController.addEvent(json_to_string, list);
- }
- @Test
- void groupEvent() throws Exception {
- StringGroupRequest queryRequest = new StringGroupRequest();
- queryRequest.setSearchQuery("name~事件 and createName=朱");
- List<OrderDTO> dtos = new ArrayList<>();
- OrderDTO orderDTO1 = new OrderDTO();
- orderDTO1.setOrderBy("name");
- orderDTO1.setOrderType(0);
- OrderDTO orderDTO2 = new OrderDTO();
- orderDTO2.setOrderBy("createName");
- orderDTO2.setOrderType(1);
- dtos.add(orderDTO1);
- dtos.add(orderDTO2);
- queryRequest.setOrderDTOList(dtos);
- queryRequest.setCurrent(Long.parseLong("1"));
- queryRequest.setSize(Long.parseLong("10"));
- queryRequest.setGroupBy("name");
- eventController.groupEvent(queryRequest);
- }
- @Test
- void test1() throws Exception {
- StringGroupRequest groupRequest = new StringGroupRequest();
- groupRequest.setGroupBy("groupMonthTime");
- Records records = (Records) productMarketDataService.getGroup(groupRequest, "productMarketData");
- System.out.println(records);
- }
- @Test
- void test11() throws Exception {
- // List<Patent> list = esService.Search("publicDate=2009-03", 0, 50,null);
- // MapRequest mapRequest = new MapRequest();
- // Map<String, Object> map = new HashMap<>();
- // map.put("titleTextContent", "电子");
- // map.put("patentNo", "CN201199922Y");
- // mapRequest.setSearchQuery(map);
- // mapRequest.setCurrent(0L);
- // mapRequest.setSize(50L);
- // mapRequest.setProjectId(1);
- StringRequest stringRequest = new StringRequest();
- // stringRequest.setSearchQuery("appCity=济南");
- // stringRequest.setSearchQuery("mipcLevel1=H");
- // stringRequest.setSearchQuery("agent=李桂存");
- // stringRequest.setSearchQuery("IN=郝旭东");
- // stringRequest.setSearchQuery("simpleStatus=3");
- // stringRequest.setSearchQuery("publicFullText=本申请涉及直流输电技术领域");
- // stringRequest.setSearchQuery("AB=本申请提供一种储能系统机电暂态建模方法、装置、设备及可读存储介质");
- // stringRequest.setSearchQuery("TI=储能系统机电暂态建模方法、装置、设备及可读存储介质");
- // stringRequest.setSearchQuery("PN=CN114513005B");
- // stringRequest.setSearchQuery("AN=CN201810025278.2");
- // stringRequest.setSearchQuery("patentNo=CN");
- stringRequest.setSearchQuery("PD<=200903");
- // stringRequest.setSearchQuery("patentNo=CN201199922Y and (simpleFamilyNum>1 or simpleFamilyNum=0)");
- stringRequest.setCurrent(1L);
- stringRequest.setSize(5L);
- // stringRequest.setProjectId(1);
- //
- PatentDTO patentDTO = esService.esSearch(stringRequest);
- System.out.println(patentDTO);
- }
- @Test
- void test12() throws IOException {
- Boolean bool = esService.searchPatent("YiQCGowBmB3pRkTj4NNG", 5);
- System.out.println(bool);
- }
- @Test
- void getpagetexst() throws IOException {
- //1.添加一批数据(10)
- //2.调用查询取第一页(5笔一页)
- //3.判断5笔数据是正确的;
- //4.删除测试数据
- List<Integer> list = Arrays.asList(1, 2, 3, 4);
- List<Integer> list1 = Arrays.asList(4, 5);
- // list1.removeAll(list);
- System.out.println(list1);
- }
- @Test
- void add1() throws Exception {
- List<FamilyPatent> list = new ArrayList<>();
- FamilyPatent patent = new FamilyPatent();
- patent.setAppNo("CN147258369");
- patent.setGrantNo("CN258369147");
- patent.setPublicNo("CN369258147");
- FamilyPatent patent1 = new FamilyPatent();
- patent1.setAppNo("US147258369");
- patent1.setGrantNo("US258369147");
- patent1.setPublicNo("US369258147");
- list.add(patent);
- list.add(patent1);
- PatentFamilyMessage patentFamilyMessage = new PatentFamilyMessage();
- patentFamilyMessage.setPatent(list);
- patentFamilyMessage.setFamilyType("test");
- String id = esService.addPatentFamily(patentFamilyMessage);
- System.out.println(id);
- }
- @Test
- void test3() throws IOException {
- List<String> stringList = Arrays.asList("US369258147", "US258369147", "14528");
- EsPatentFamilyDTO test = esService.addEsPatentFamily(stringList, "test");
- System.out.println(test);
- }
- @Test
- void test4() throws IOException {
- List<String> stringList = Arrays.asList("US369258147", "US258369147", "14528");
- EsPatentFamilyDTO test = esService.addEsPatentFamily(stringList, "test");
- System.out.println(test);
- }
- @Test
- void test5() throws IOException {
- SelectClaimDTO dto = esService.selectClaim("CN102324864A");
- System.out.println(dto);
- }
- @Test
- void test8() throws Exception {
- List<EsCountVO> countVOS = new ArrayList<>();
- EsCountVO vo1 = new EsCountVO();
- vo1.setField("childRaw");
- // vo.setField("CO");
- // vo.setField("PT");
- // vo1.setValueOne("国家电网公司");
- // vo.setValueOne("2022");
- // vo.setValueTwo("2024");
- // vo.setField("AD");
- EsCountVO vo2 = new EsCountVO();
- vo2.setField("AD");
- vo2.setValueOne("2022");
- vo2.setValueTwo("2023");
- countVOS.add(vo1);
- // countVOS.add(vo2);
- // EsCountDTO esCountDTO = esCountService.esCountSearch(countVOS);
- // System.out.println(esCountDTO);
- }
- @Test
- void test9() throws IOException {
- PatentNoVO vo = new PatentNoVO();
- vo.setPatentNo("CN201910069334.7");
- PatentColumnDTO columnDTO = patentService.selectPatentDetail(vo);
- System.out.println(columnDTO);
- // String s = "asfassafsafe";
- // Map<Character, Long> map = s.chars().mapToObj(c->(char)c).collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
- // System.out.println(map);
- //
- // List<String> stringList = Arrays.asList("apple", "apple", "balana", "origin", "apple", "balana");
- // Map<String, Long> collect = stringList.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
- // System.out.println("----" + collect);
- }
- @Test
- void test10() throws IOException {
- PatentKinVO vo = new PatentKinVO();
- vo.setPatentNo("CN201910069334.7");
- vo.setPageNum(1);
- vo.setPageSize(10);
- vo.setType("inpadoc");
- List<PatentKinDTO> kinDTOS = patentService.selectKinByPatentNo(vo);
- System.out.println(kinDTOS);
- }
- @Test
- void test14() {
- TempleByReportTypeVO vo = new TempleByReportTypeVO();
- vo.setReportType(1);
- List<ReportTempleDTO> reportTempleDTOS = templeService.queryTempleByType(vo);
- System.out.println(reportTempleDTOS);
- }
- @Test
- void test15() throws Exception {
- EsCustomFieldDTO dto = new EsCustomFieldDTO();
- dto.setProjectId(83);
- dto.setFieldType(5);
- dto.setFieldId("303");
- dto.setFieldValue(Arrays.asList("多选1", "多选2"));
- dto.setOptionType(1);
- dto.setPatentNo("CN201910069334.7");
- esCustomFieldService.addCustomField(dto);
- }
- @Test
- void test16() {
- List<EsCustomFieldValueDTO> customFields = new ArrayList<>();
- EsCustomFieldValueDTO dto1 = new EsCustomFieldValueDTO();
- dto1.setFieldId("1");
- dto1.setFieldValue(Arrays.asList("a"));
- EsCustomFieldValueDTO dto2 = new EsCustomFieldValueDTO();
- dto2.setFieldId("2");
- dto2.setFieldValue(Arrays.asList("a"));
- customFields.add(dto1);
- customFields.add(dto2);
- String s = esService.parseCustomField(customFields);
- System.out.println("结果为:" + s);
- System.out.println("-----------------------------");
- List<EsCustomFieldValueDTO> fields = new ArrayList<>();
- }
- @Test
- void test17() throws IOException {
- List<String> list = new ArrayList<>();
- list.add("CN201910069334.7");
- list.add("CN201110286649.0");
- list.add("CN200820185104.4");
- SelectClaimDTO dto = esService.selectPatentNo(list);
- System.out.println(dto);
- }
- @Test
- void test18() {
- List<String> list = Arrays.asList("AD");
- if (list.contains("AD")) {
- String str = "AD=2008~201009";
- String s = this.get(str);
- if (s.contains("~")) {
- int i = s.indexOf("~");
- // s.substring()
- String s1 = this.get(s);
- System.out.println("-------------");
- System.out.println("s1是:" + s1);
- }
- } else {
- System.out.println("DDDDDDDDDDDDDDDDDD");
- }
- }
- public String get(String str) {
- int i = str.indexOf("AD");
- String s = str.substring(str.indexOf("AD")).toUpperCase(Locale.ROOT);
- int length = s.length();//------
- String key = s.substring(0, s.indexOf("="));
- int i2 = s.indexOf("=");
- String s1 = s.substring(s.indexOf("=") + 1, s.indexOf("~"));
- String s2 = "";
- if (s.contains("AND")) {
- s2 = s.substring(s.indexOf("~") + 1, s.indexOf("AND"));
- } else {
- s2 = s.substring(s.indexOf("~") + 1).trim();
- }
- int index = str.indexOf(key);
- int index1 = str.indexOf(s2) + s2.length();
- int i1 = index + key.length() + 1 + s1.length() + 1 + s2.length();
- String substring = str.substring(index, i1);
- String concat = key.concat(">=").concat(s1).concat(" and ").concat(key).concat("<=").concat(s2);
- System.out.println(concat);
- String replace = str.replace(substring, concat);
- System.out.println(replace);
- return replace;
- }
- @Test
- public void aaaaa() throws Exception {
- List<String> list = Arrays.asList("gh,ji");
- String str = "[";
- if (list.size() >= 1) {
- for (int i = 0; i < list.size(); i++) {
- String s = list.get(i);
- if (i == list.size() - 1) {
- str = str + "\"" +s + "\"" ;
- } else {
- str = str + "\"" +s + "\"" + "," ;
- }
- }
- } else {
- }
- str = str + "]";
- System.out.println(str + "------------");
- String projectId = "ctx._source.custom_field.project_id = " + 1 + ";" + "\n";
- String field = "ctx._source.custom_field.field=" + 1 + ";" + "\n";
- String fieldType = "ctx._source.custom_field.field_type = " + 1 + ";" + "\n";
- String personId = "ctx._source.custom_field.person_id = " + 1 + ";" + "\n";
- String createTime = "ctx._source.custom_field.create_time = " + new Date().getTime() + ";" + "\n";
- String fieldValue = "ctx._source.custom_field.field_value = " + str + ";" + "\n";
- String statsValue = "ctx._source.custom_field.stats_value = " + list;
- String source = "\"" + projectId + field + fieldType + personId + createTime + fieldValue + statsValue + "\"";
- // String source = "\"\"ctx._source.custom_field.project_id = " + 1 + ";" + "\n" +
- // "ctx._source.custom_field.field=" + 2 + ";" + "\n" + "\"\"";
- System.out.println(source);
- Patent patent = new Patent();
- String id = "hy7ayIwB68vilgBjUWBz";
- String name = "士大夫";
- Integer type = 0;
- esService.delMergePerson(patent, id, type, name);
- }
- @Test
- public void test100() {
- List<GetAllPersonDTO> DTOS = new ArrayList<>();
- List<GetAllPersonDTO> applicantDTOS = new ArrayList<>();
- GetAllPersonDTO dto = new GetAllPersonDTO();
- dto.setName("A");
- dto.setType(0);
- dto.setCountry("CN");
- dto.setAddress("efe");
- applicantDTOS.add(dto);
- GetAllPersonDTO dto1 = new GetAllPersonDTO();
- dto1.setName("B");
- dto1.setType(0);
- dto1.setCountry("CN");
- dto1.setAddress("weew");
- applicantDTOS.add(dto1);
- GetAllPersonDTO dto2 = new GetAllPersonDTO();
- dto2.setName("C");
- dto2.setType(0);
- dto2.setCountry("CN");
- dto2.setAddress("fdsyt");
- applicantDTOS.add(dto2);
- List<GetAllPersonDTO> rightDTOS = new ArrayList<>();
- GetAllPersonDTO dto4 = new GetAllPersonDTO();
- dto4.setName("A");
- dto4.setType(0);
- dto4.setCountry("CN");
- dto4.setAddress("efed");
- rightDTOS.add(dto4);
- GetAllPersonDTO dto5 = new GetAllPersonDTO();
- dto5.setName("D");
- dto5.setType(0);
- dto5.setCountry("CN");
- dto5.setAddress("ete");
- rightDTOS.add(dto5);
- GetAllPersonDTO dto6 = new GetAllPersonDTO();
- dto6.setName("E");
- dto6.setType(0);
- rightDTOS.add(dto6);
- applicantDTOS.removeAll(rightDTOS);
- System.out.println(applicantDTOS + "-----------------");
- for (GetAllPersonDTO applicantDTO : applicantDTOS) {
- rightDTOS.removeIf(rightDTO -> applicantDTO.getName().equals(rightDTO.getName()));
- }
- System.out.println(applicantDTOS);
- System.out.println(rightDTOS);
- DTOS.addAll(applicantDTOS);
- DTOS.addAll(rightDTOS);
- System.out.println("DTOS:" + DTOS);
- }
- @Test
- public void test101() {
- // Date date = new Date();
- // Calendar calendar = Calendar.getInstance();
- // calendar.setTime(date);
- // calendar.add(Calendar.DAY_OF_MONTH, 1);
- // Date date1 = calendar.getTime();
- // System.out.println(date1);
- //
- // List<Integer> list = Arrays.asList(1, 2, 3);
- // String result = String.join(",", String.join(",", list.stream().map(Object::toString).collect(Collectors.toList())));
- // System.out.println(result); // 输出: 1,2,3
- String s = "((type='1') AND (type_id='7') ) AND (parent_id='0') ";
- if (s.contains("type='1") || s.contains("type='2'")) {
- System.out.println("Sdggdsgred");
- } else {
- System.out.println("end");
- }
- }
- }
|