PatentRightService.java 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. package cn.cslg.pas.service;
  2. import cn.cslg.pas.common.model.params.PatentRightParams;
  3. import cn.cslg.pas.common.utils.PatentUtils;
  4. import cn.cslg.pas.common.utils.Response;
  5. import cn.cslg.pas.common.utils.StringUtils;
  6. import cn.cslg.pas.domain.Authority;
  7. import cn.cslg.pas.domain.Patent;
  8. import cn.cslg.pas.domain.PatentRight;
  9. import cn.cslg.pas.mapper.PatentRightMapper;
  10. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  11. import com.baomidou.mybatisplus.core.toolkit.Wrappers;
  12. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  13. import lombok.RequiredArgsConstructor;
  14. import org.springframework.context.annotation.Lazy;
  15. import org.springframework.stereotype.Service;
  16. import java.util.ArrayList;
  17. import java.util.Arrays;
  18. import java.util.List;
  19. import java.util.regex.Matcher;
  20. import java.util.regex.Pattern;
  21. import java.util.stream.Collectors;
  22. /**
  23. * @author Administrator
  24. * @description 针对表【os_patent_right(专利权利要求)】的数据库操作Service
  25. * @createDate 2022-04-16 10:09:24
  26. */
  27. @Service
  28. @RequiredArgsConstructor(onConstructor_ = {@Lazy})
  29. public class PatentRightService extends ServiceImpl<PatentRightMapper, PatentRight> {
  30. private final PatentService patentService;
  31. public List<PatentRight> getPatentRightByPatentNo(String patentNo) {
  32. Patent patent = patentService.getByPatentNo(patentNo);
  33. LambdaQueryWrapper<PatentRight> queryWrapper = new LambdaQueryWrapper<>();
  34. queryWrapper.eq(PatentRight::getPatentId, patent.getId());
  35. queryWrapper.orderByAsc(PatentRight::getSort);
  36. return this.list(queryWrapper);
  37. }
  38. public List<PatentRight> getPatentRightByPatentId(Integer patentId) {
  39. LambdaQueryWrapper<PatentRight> queryWrapper = new LambdaQueryWrapper<>();
  40. queryWrapper.eq(PatentRight::getPatentId, patentId);
  41. queryWrapper.orderByAsc(PatentRight::getSort);
  42. return this.list(queryWrapper);
  43. }
  44. public List<PatentRight> getPatentRightByPatentIds(List<Integer> patentIds) {
  45. if (patentIds == null || patentIds.size() == 0) {
  46. return new ArrayList<>();
  47. }
  48. LambdaQueryWrapper<PatentRight> queryWrapper = new LambdaQueryWrapper<>();
  49. queryWrapper.in(PatentRight::getPatentId, patentIds);
  50. queryWrapper.orderByAsc(PatentRight::getSort);
  51. return this.list(queryWrapper);
  52. }
  53. public void deleteByPatentId(Integer patentId) {
  54. this.remove(Wrappers.<PatentRight>lambdaQuery().eq(PatentRight::getPatentId, patentId));
  55. }
  56. public void importPatentRight(Integer localPatentId, Integer importPatentId, List<PatentRight> importPatentRightList) {
  57. this.deleteByPatentId(localPatentId);
  58. List<PatentRight> patentRightList = importPatentRightList.stream().filter(item -> item.getPatentId().equals(importPatentId)).collect(Collectors.toList());
  59. for (PatentRight patentRight : patentRightList) {
  60. patentRight.setId(null);
  61. patentRight.setPatentId(localPatentId);
  62. }
  63. this.saveOrUpdateBatch(patentRightList);
  64. }
  65. public void importAuthority(PatentRightParams params) {
  66. List<Authority> splits = splits(params);
  67. List<Authority> authorities = relationshipAuthority(splits);
  68. List<Authority> authorities1 = relationshipAuthority3(authorities);
  69. List<Authority> authorities2 = relationshipAuthority2(authorities1);
  70. List<Authority> authorities3 = relationshipAuthority4(authorities2);
  71. for (Authority a : authorities3) {
  72. Authority authority = new Authority();
  73. authority.setContent(a.getContent());
  74. String join = StringUtils.join(a.getFatherID(), ",");
  75. authority.setFID(join);
  76. String join1 = StringUtils.join(a.getSonID(), ",");
  77. authority.setSID(join1);
  78. authority.setPatentID(params.getPatentId());
  79. authority.setType(a.getType());
  80. authority.insert();
  81. }
  82. }
  83. public List<Authority> splits(PatentRightParams params) {
  84. //去掉全要开头的""
  85. List<Authority> list = new ArrayList<>();
  86. String selfContent = params.getContent();
  87. if (selfContent == null) {
  88. selfContent = "";
  89. }
  90. //청구항 2. 삭제(是否删除代办)
  91. // selfContent.replaceAll("청구항(\\s)(^\\d*$+)(\\s)삭제","");
  92. selfContent.replaceAll("''", "");
  93. selfContent.replaceAll("(^\\d*$+)-(^\\d*$+)(\\.)(\\s)(canceled)", "");
  94. // selfContent.replaceAll("(^\\d*$+)(.)(\\s)(canceled)","");
  95. selfContent.replaceAll("\n", " ");
  96. //找到1. 2. ...这种格式的正则表达式
  97. String str1 = "(^\\d*$+)(\\.)";
  98. //找到[001]或者[002]这种格式的
  99. String str2 = "(\\[)(^[1-9]/d*$+)(\\])";
  100. //【請求項 1】
  101. String str3 = "(\\【請求項)(^[1-9]/d*$+)(\\】)";
  102. //청구항 1()
  103. String str4 = "청구항(\\s)(^[1-9]/d*$+)(\\.)";
  104. Pattern p4 = Pattern.compile(str4);
  105. Matcher m4 = p4.matcher(selfContent);
  106. List<Integer> integers1 = new ArrayList<>();
  107. while (m4.find()) {
  108. integers1.add(m4.start());
  109. }
  110. if (integers1.size() != 0) {
  111. for (int i = integers1.size() - 1; i >= 0; i--) {
  112. String str = selfContent.substring(integers1.get(i));
  113. Authority authority = new Authority();
  114. authority.setContent(str);
  115. list.add(authority);
  116. }
  117. Authority authority = new Authority();
  118. authority.setContent(selfContent);
  119. list.add(authority);
  120. return list;
  121. }
  122. Pattern p = Pattern.compile(str1);
  123. Matcher m = p.matcher(selfContent);
  124. //判断找到的数量
  125. List<Integer> integers = new ArrayList<>();
  126. while (m.find()) {
  127. integers.add(m.start());
  128. }
  129. if (integers.size() != 0) {
  130. for (int i = integers.size() - 1; i > 0; i--) {
  131. String str = selfContent.substring(integers.get(i));
  132. Authority authority1 = new Authority();
  133. authority1.setContent(str);
  134. list.add(authority1);
  135. }
  136. Authority authority1 = new Authority();
  137. authority1.setContentOut(selfContent);
  138. list.add(authority1);
  139. return list;
  140. }
  141. Pattern compile = Pattern.compile(str2);
  142. Matcher matcher = compile.matcher(selfContent);
  143. List<Integer> start = new ArrayList<>();
  144. while (matcher.find()) {
  145. start.add(matcher.start());
  146. }
  147. if (start.size() != 0) {
  148. for (int i = start.size() - 1; i > 0; i--) {
  149. String str = selfContent.substring(integers.get(i));
  150. Authority authority2 = new Authority();
  151. authority2.setContent(str);
  152. list.add(authority2);
  153. }
  154. Authority authority2 = new Authority();
  155. authority2.setContent(selfContent);
  156. list.add(authority2);
  157. return list;
  158. }
  159. Pattern compile1 = Pattern.compile(str3);
  160. Matcher matcher1 = compile1.matcher(selfContent);
  161. List<Integer> start1 = new ArrayList<>();
  162. while (matcher1.find()) {
  163. start1.add(matcher1.start());
  164. }
  165. if (start1.size() != 0) {
  166. for (int i = start1.size() - 1; i >= 0; i--) {
  167. String str = selfContent.substring(integers.get(i));
  168. Authority authority3 = new Authority();
  169. authority3.setContent(str);
  170. list.add(authority3);
  171. }
  172. Authority authority3 = new Authority();
  173. authority3.setContent(selfContent);
  174. list.add(authority3);
  175. }
  176. return list;
  177. }
  178. /**
  179. * 英文下的处理方式(草稿)
  180. */
  181. private List<Authority> relationshipAuthority(List<Authority> list) {
  182. List<Authority> authorities = list;
  183. //英文下的claim 1,claim2 的正则表达式
  184. String str1 = "(claim)(\\s)(^\\d*$+)";
  185. Pattern p = Pattern.compile(str1);
  186. for (int i = 0; i < list.size(); i++) {
  187. //去掉空格
  188. authorities.get(i).getContent().replaceAll(" ", "");
  189. Matcher m = p.matcher(authorities.get(i).getContent());
  190. if (!m.find()) {
  191. list.get(i).setFID(null);
  192. list.get(i).setType(0);
  193. return list;
  194. } else {
  195. //找到了
  196. String group = m.group(0);
  197. //把claim去掉只剩下面的数字
  198. String substring = group.substring(5);
  199. int j = Integer.parseInt(substring);
  200. List<Integer> sonID = list.get(j - 1).getSonID();
  201. sonID.add(authorities.get(i).getId());
  202. list.get(j - 1).setSonID(sonID);
  203. List<Integer> fatherID = list.get(i).getFatherID();
  204. fatherID.add(list.get(j - 1).getId());
  205. list.get(i).setFatherID(fatherID);
  206. //设置为
  207. list.get(i).setType(1);
  208. }
  209. }
  210. return list;
  211. }
  212. /**
  213. * 小日子的语言下的处理模式
  214. */
  215. private List<Authority> relationshipAuthority3(List<Authority> list) {
  216. List<Authority> authorities = list;
  217. //英文下的claim 1,claim2 的正则表达式
  218. String str1 = "(前記第)(^\\d*$+)";
  219. Pattern p = Pattern.compile(str1);
  220. for (int i = 0; i < list.size(); i++) {
  221. Matcher m = p.matcher(authorities.get(i).getContent());
  222. if (!m.find()) {
  223. list.get(i).setFID(null);
  224. list.get(i).setType(0);
  225. return list;
  226. } else {
  227. //找到了
  228. String group = m.group(0);
  229. //把claim去掉只剩下面的数字
  230. String substring = group.substring(3);
  231. int j = Integer.parseInt(substring);
  232. List<Integer> sonID = list.get(j - 1).getSonID();
  233. sonID.add(authorities.get(i).getId());
  234. list.get(j - 1).setSonID(sonID);
  235. List<Integer> fatherID = list.get(i).getFatherID();
  236. fatherID.add(list.get(j - 1).getId());
  237. list.get(i).setFatherID(fatherID);
  238. //设置为
  239. list.get(i).setType(1);
  240. }
  241. }
  242. return list;
  243. }
  244. /**
  245. * 中文下的处理方式
  246. */
  247. public List<Authority> relationshipAuthority2(List<Authority> list) {
  248. //中文下权利要求1,权利要求2,权利要求3
  249. String str1 = "(权利要求)(^\\d*$+)";
  250. //中文下权利要求1至
  251. String str2 = "(权利要求)(^\\d*$+)(至)(^\\d*$+)";
  252. //中文下权利要求 或
  253. String str3 = "(权利要求)(^\\d*$+)(或)(^\\d*$+)";
  254. Pattern p = Pattern.compile(str1);
  255. Pattern p1 = Pattern.compile(str2);
  256. Pattern p2 = Pattern.compile(str3);
  257. for (int i = 0; i < list.size(); i++) {
  258. Matcher matcher = p.matcher(list.get(i).getContent());
  259. if (matcher.find()) {
  260. list.get(i).setType(1);
  261. //找到满足第一情况
  262. Matcher matcher1 = p1.matcher(list.get(i).getContent());
  263. if (matcher1.find()) {
  264. //找到满足第一和第二种情况按第二种情况处理
  265. String group = matcher1.group(0);
  266. String str5 = "^\\d*$+";
  267. Pattern p3 = Pattern.compile(str5);
  268. Matcher matcher2 = p3.matcher(group);
  269. if (matcher2.find()) {
  270. String group1 = matcher2.group(0);
  271. String group2 = matcher2.group(1);
  272. Integer j = Integer.parseInt(group1);
  273. Integer k = Integer.parseInt(group2);
  274. for (int l = j - 1; l < k; l++) {
  275. List<Integer> sonID = list.get(l).getSonID();
  276. sonID.add(list.get(i).getId());
  277. list.get(l).setSonID(sonID);
  278. List<Integer> fatherID = list.get(i).getFatherID();
  279. fatherID.add(list.get(l).getId());
  280. list.get(i).setFatherID(fatherID);
  281. }
  282. }
  283. } else {
  284. Matcher matcher2 = p2.matcher(list.get(i).getContent());
  285. if (matcher2.find()) {
  286. //找到满足第三和第一情况按第三中情况处理
  287. String group = matcher1.group(0);
  288. String str6 = "^\\d*$+";
  289. Pattern p3 = Pattern.compile(str6);
  290. Matcher matcher3 = p3.matcher(group);
  291. if (matcher3.find()) {
  292. String group1 = matcher2.group(0);
  293. String group2 = matcher2.group(1);
  294. Integer j = Integer.parseInt(group1);
  295. Integer k = Integer.parseInt(group2);
  296. List<Integer> sonID = list.get(j).getSonID();
  297. sonID.add(list.get(i).getId());
  298. list.get(j).setSonID(sonID);
  299. List<Integer> fatherID = list.get(i).getFatherID();
  300. fatherID.add(list.get(j).getId());
  301. list.get(i).setFatherID(fatherID);
  302. List<Integer> sonID1 = list.get(k).getSonID();
  303. sonID1.add(list.get(i).getId());
  304. list.get(k).setSonID(sonID1);
  305. List<Integer> fatherID1 = list.get(i).getFatherID();
  306. fatherID1.add(list.get(k).getId());
  307. list.get(i).setFatherID(fatherID1);
  308. }
  309. } else {
  310. //只满足第一中情况
  311. String group = matcher.group(0);
  312. String str7 = "^\\d*$+";
  313. Pattern p3 = Pattern.compile(str7);
  314. Matcher matcher3 = p3.matcher(group);
  315. if (matcher3.find()) {
  316. String group1 = matcher2.group(0);
  317. Integer j = Integer.parseInt(group1);
  318. List<Integer> sonID = list.get(j).getSonID();
  319. sonID.add(list.get(i).getId());
  320. list.get(j).setSonID(sonID);
  321. List<Integer> fatherID = list.get(i).getFatherID();
  322. fatherID.add(list.get(j).getId());
  323. list.get(i).setFatherID(fatherID);
  324. }
  325. }
  326. }
  327. } else {
  328. list.get(i).setType(0);
  329. list.get(i).setFID(null);
  330. }
  331. }
  332. return list;
  333. }
  334. /**
  335. * 韩文下的处理
  336. */
  337. public List<Authority> relationshipAuthority4(List<Authority> list) {
  338. //韩文情况下的正则表达式
  339. String str1 = "제(\\s)(^\\d*$+)항"; //"제 1항에" ;
  340. String str3 = "제(\\s)(^\\d*$+)항(\\s)또는(\\s)제(^\\d*$+)항";//제 1항 또는 제 2항에 있어서 这种情况下的正则表达式
  341. Pattern p = Pattern.compile(str1);
  342. for (int i = 0; i < list.size(); i++) {
  343. // list.get(i).getContent().replaceAll(" ", "");
  344. Matcher m = p.matcher(list.get(i).getContent());
  345. if (!m.find()) {
  346. list.get(i).setFID(null);
  347. list.get(i).setType(0);
  348. } else {
  349. //找到了
  350. Pattern compile = Pattern.compile(str3);
  351. Matcher matcher1 = compile.matcher(list.get(i).getContent());
  352. if (matcher1.find()) {
  353. String group = m.group(0);
  354. String str2 = "(^\\d*$+)";
  355. Pattern p1 = Pattern.compile(str1);
  356. Matcher matcher = p1.matcher(group);
  357. String group1 = matcher.group(0);
  358. String group2 = matcher.group(1);
  359. Integer j = Integer.parseInt(group1);
  360. Integer k = Integer.parseInt(group2);
  361. List<Integer> sonID = list.get(j).getSonID();
  362. sonID.add(list.get(i).getId());
  363. list.get(j).setSonID(sonID);
  364. List<Integer> fatherID = list.get(i).getFatherID();
  365. fatherID.add(list.get(j).getId());
  366. list.get(i).setFatherID(fatherID);
  367. List<Integer> sonID1 = list.get(k).getSonID();
  368. sonID1.add(list.get(i).getId());
  369. list.get(k).setSonID(sonID1);
  370. List<Integer> fatherID1 = list.get(i).getFatherID();
  371. fatherID1.add(list.get(k).getId());
  372. list.get(i).setFatherID(fatherID1);
  373. } else {
  374. String group = m.group(0);
  375. String str2 = "(^\\d*$+)";
  376. Pattern p1 = Pattern.compile(str1);
  377. Matcher matcher = p1.matcher(group);
  378. String substring = matcher.group(0);
  379. int j = Integer.parseInt(substring);
  380. List<Integer> sonID = list.get(j - 1).getSonID();
  381. sonID.add(list.get(i).getId());
  382. list.get(j - 1).setSonID(sonID);
  383. List<Integer> fatherID = list.get(i).getFatherID();
  384. fatherID.add(list.get(j - 1).getId());
  385. list.get(i).setFatherID(fatherID);
  386. //设置为
  387. list.get(i).setType(1);
  388. }
  389. }
  390. }
  391. return list;
  392. }
  393. public void updatePatentRight(PatentRightParams params) {
  394. // List<PatentRight> patentRightList = new ArrayList<>();
  395. // 获取国家 公开号前两位
  396. // String country = PatentUtils.getPatentCountry(params.getPatentNo());
  397. // String code;
  398. //权利要求原文
  399. String content = params.getContent();
  400. //权利要求译文
  401. String contentOut = params.getContentOut();
  402. //独立权利要求
  403. String selfContent = params.getSelfContent();
  404. if (StringUtils.isNotEmpty(content)) {
  405. this.deleteByPatentId(params.getPatentId());
  406. // String[] contentArray = null;
  407. // String[] contentOutArray = null;
  408. // String[] selfContentArray = null;
  409. // switch (country) {
  410. // case "JP":
  411. // case "CN":
  412. // code = "。";
  413. // if (StringUtils.isNotEmpty(contentOut)) {
  414. // contentOut = contentOut.replaceAll("\n", "");
  415. // contentOutArray = StringUtils.split(contentOut, code);
  416. // }
  417. // if (StringUtils.isNotEmpty(selfContent)) {
  418. // selfContent = selfContent.replaceAll("\n", "");
  419. // selfContentArray = StringUtils.split(selfContent, code);
  420. // }
  421. // content = content.replaceAll("\n", "");
  422. // contentArray = StringUtils.split(content, code);
  423. // break;
  424. // default:
  425. // code = "\n";
  426. // if (StringUtils.isNotEmpty(contentOut)) {
  427. // contentOutArray = StringUtils.split(contentOut, code);
  428. // }
  429. // if (StringUtils.isNotEmpty(selfContent)) {
  430. // selfContentArray = StringUtils.split(selfContent, code);
  431. // }
  432. // contentArray = StringUtils.split(content, code);
  433. // }
  434. // for (int i = 0; i < contentArray.length; i++) {
  435. // if (StringUtils.isEmpty(contentArray[i])) {
  436. // continue;
  437. // }
  438. // PatentRight patentRight = new PatentRight();
  439. // patentRight.setPatentId(params.getPatentId());
  440. // patentRight.setContent(contentArray[i]);
  441. // patentRight.setType(0);
  442. // patentRight.setSort(i);
  443. // if (contentOutArray != null && i < contentOutArray.length) {
  444. // patentRight.setContentOut(contentOutArray[i]);
  445. // }
  446. // if (selfContentArray != null) {
  447. // String temp = Arrays.stream(selfContentArray).filter(item -> item.equals(patentRight.getContent())).findFirst().orElse(null);
  448. // if (temp != null) {
  449. // patentRight.setType(1);
  450. // }
  451. // }
  452. // patentRightList.add(patentRight);
  453. ArrayList<PatentRight> patentRights = new ArrayList<>();
  454. //先去掉所有换行符,使原文连起来
  455. if (content.contains("\r\n")) {
  456. content = content.replaceAll("\r\n", "");
  457. } else {
  458. content = content.replaceAll("\n", "");
  459. }
  460. if (contentOut == null) {
  461. contentOut = "";
  462. }
  463. if (contentOut.contains("\r\n")) {
  464. contentOut = contentOut.replaceAll("\r\n", "");
  465. } else {
  466. contentOut = contentOut.replaceAll("\n", "");
  467. }
  468. //根据专利所属国家,定义序号规则
  469. String regex;
  470. if (content.contains("1.")) {
  471. regex = "[0-9]+[.]";
  472. } else if (content.contains("1、")) {
  473. regex = "[0-9]+[、]";
  474. } else if (content.contains("[001]")) {
  475. regex = "\\[[0-9]+]";
  476. } else {
  477. regex = "";
  478. }
  479. Pattern compile = Pattern.compile(regex);
  480. Matcher matcher = compile.matcher(content);
  481. Matcher matcherOut = compile.matcher(contentOut);
  482. while (matcher.find()) {
  483. if (!matcher.group().equals("1.") && !matcher.group().equals("1、") && !matcher.group().equals("[001]")) {
  484. content = content.replaceFirst(matcher.group(), "\n" + matcher.group());
  485. }
  486. }
  487. String[] strs = content.split("\n");
  488. while (matcherOut.find()) {
  489. if (!matcherOut.group().equals("1.") && !matcherOut.group().equals("1、") && !matcherOut.group().equals("[001]")) {
  490. contentOut = contentOut.replaceFirst(matcherOut.group(), "\n" + matcherOut.group());
  491. }
  492. }
  493. String[] strsOut = contentOut.split("\n");
  494. //定义父权要排序号
  495. String regex1 = "权利要求[0-9]+";
  496. String regex2 = "权利要求[0-9]+[至或~-]+[0-9]+";
  497. for (int i = 0; i < strs.length; i++) {
  498. if (strs[i].contains("权利要求")) {
  499. Pattern compile1 = Pattern.compile(regex1);
  500. Matcher matcher1 = compile1.matcher(strs[i]);
  501. Pattern compile2 = Pattern.compile(regex2);
  502. Matcher matcher2 = compile2.matcher(strs[i]);
  503. if (matcher2.find()) {
  504. String parentNum = matcher2.group().substring(matcher2.group().indexOf("求") + 1);
  505. String[] parentNums;
  506. if (parentNum.contains("~")) {
  507. parentNums = parentNum.split("~");
  508. } else if (parentNum.contains("-")) {
  509. parentNums = parentNum.split("-");
  510. } else if (parentNum.contains("至")) {
  511. parentNums = parentNum.split("至");
  512. } else if (parentNum.contains("或")) {
  513. parentNums = parentNum.split("或");
  514. } else {
  515. parentNums = new String[0];
  516. }
  517. StringBuilder builder = new StringBuilder();
  518. for (int j = Integer.parseInt(parentNums[0]) - 1; j < Integer.parseInt(parentNums[parentNums.length - 1]); j++) {
  519. if ((builder + "").equals("")) {
  520. builder.append(j);
  521. } else {
  522. builder.append(",").append(j);
  523. }
  524. }
  525. PatentRight patentRight = new PatentRight()
  526. .setPatentId(params.getPatentId())
  527. .setType(1)
  528. .setContent(strs[i])
  529. .setSort(i)
  530. .setParentSort(builder + "");
  531. if (strsOut.length - 1 >= i) {
  532. patentRight.setContentOut(strsOut[i]);
  533. }
  534. patentRights.add(patentRight);
  535. } else if (matcher1.find()) {
  536. String parentNum = matcher1.group().substring(matcher1.group().indexOf("求") + 1);
  537. PatentRight patentRight = new PatentRight()
  538. .setPatentId(params.getPatentId())
  539. .setType(1)
  540. .setContent(strs[i])
  541. .setSort(i)
  542. .setParentSort((Integer.parseInt(parentNum) - 1) + "");
  543. if (strsOut.length - 1 >= i) {
  544. patentRight.setContentOut(strsOut[i]);
  545. }
  546. patentRights.add(patentRight);
  547. }
  548. } else {
  549. PatentRight patentRight = new PatentRight()
  550. .setPatentId(params.getPatentId())
  551. .setType(0)
  552. .setContent(strs[i])
  553. .setSort(i)
  554. .setParentSort("-1");
  555. if (strsOut.length - 1 >= i) {
  556. patentRight.setContentOut(strsOut[i]);
  557. }
  558. patentRights.add(patentRight);
  559. }
  560. }
  561. this.saveOrUpdateBatch(patentRights);
  562. }
  563. }
  564. }