|
@@ -26,6 +26,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
|
|
|
|
|
import java.io.*;
|
|
|
+import java.net.MalformedURLException;
|
|
|
import java.net.URL;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
@@ -61,7 +62,7 @@ public class ExcutePatentDataStar implements IExcutePatentData {
|
|
|
public void startExcute(Task task) throws IOException {
|
|
|
|
|
|
//若本次下载任务是超过一万条专利的全部下载任务
|
|
|
- int patentNum = 300;
|
|
|
+ int patentNum = 10000;
|
|
|
if (task.getEndNumber() > patentNum) {
|
|
|
try {
|
|
|
Integer total = task.getTotal(); //任务专利总数量
|
|
@@ -91,6 +92,7 @@ public class ExcutePatentDataStar implements IExcutePatentData {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
//至此,即找到了当前检索式即为要下载的专利开始位置所属的检索式,重新计算开始位置startNumber(即要下载的专利的开始位置,对应了当前检索式中该专利位置)
|
|
|
startNumber = startNumber - (countForStart - patentStarListDto.getTotal());
|
|
|
//第一个检索式下载完成后,从第二个检索式开始 startNumber都是从1开始下载
|
|
@@ -470,41 +472,42 @@ public class ExcutePatentDataStar implements IExcutePatentData {
|
|
|
//以下 ↓装载的是调用"获得中国专利法律状态"接口返回的专利相关数据
|
|
|
PatentAffair patentAffair = new PatentAffair();
|
|
|
String cnLegalApiStr = patentStarApiService.getCnLegalApi(appNo);
|
|
|
- List<ChinaLeagalStatus> chinaLeagalStatuses = JSON.parseArray(cnLegalApiStr, ChinaLeagalStatus.class);
|
|
|
- if (chinaLeagalStatuses != null && chinaLeagalStatuses.size() > 0) {
|
|
|
- ArrayList<KeyValueVO> lst = new ArrayList<>();
|
|
|
- HashMap<Integer, String> nameMap = new HashMap<>();
|
|
|
- HashMap<Integer, String> contentMap = new HashMap<>();
|
|
|
- nameMap.put(0, "发生日期");
|
|
|
- nameMap.put(1, "法律状态");
|
|
|
- nameMap.put(2, "详细法律状态");
|
|
|
- nameMap.put(3, "详细信息");
|
|
|
- for (int i = 0; i < chinaLeagalStatuses.size(); i++) {
|
|
|
- if (i == 0) {
|
|
|
- patentAffair.setStatus(chinaLeagalStatuses.get(i).getLegalStatus());
|
|
|
- }
|
|
|
- contentMap.put(0, chinaLeagalStatuses.get(i).getLegalDate());
|
|
|
- contentMap.put(1, chinaLeagalStatuses.get(i).getLegalStatus());
|
|
|
- contentMap.put(2, chinaLeagalStatuses.get(i).getLegalStatusInfo());
|
|
|
- contentMap.put(3, chinaLeagalStatuses.get(i).getDETAIL());
|
|
|
- ArrayList<KeyValueVO.InpadocData> inpadocDatas = new ArrayList<>();
|
|
|
- for (int j = 0; j < 4; j++) {
|
|
|
- KeyValueVO.InpadocData inpadocData = new KeyValueVO.InpadocData();
|
|
|
- inpadocData.setName(nameMap.get(j));
|
|
|
- inpadocData.setContent(contentMap.get(j));
|
|
|
- inpadocDatas.add(inpadocData);
|
|
|
+ if (!cnLegalApiStr.equals("")) {
|
|
|
+ List<ChinaLeagalStatus> chinaLeagalStatuses = JSON.parseArray(cnLegalApiStr, ChinaLeagalStatus.class);
|
|
|
+ if (chinaLeagalStatuses != null && chinaLeagalStatuses.size() > 0) {
|
|
|
+ ArrayList<KeyValueVO> lst = new ArrayList<>();
|
|
|
+ HashMap<Integer, String> nameMap = new HashMap<>();
|
|
|
+ HashMap<Integer, String> contentMap = new HashMap<>();
|
|
|
+ nameMap.put(0, "发生日期");
|
|
|
+ nameMap.put(1, "法律状态");
|
|
|
+ nameMap.put(2, "详细法律状态");
|
|
|
+ nameMap.put(3, "详细信息");
|
|
|
+ for (int i = 0; i < chinaLeagalStatuses.size(); i++) {
|
|
|
+ if (i == 0) {
|
|
|
+ patentAffair.setStatus(chinaLeagalStatuses.get(i).getLegalStatus());
|
|
|
+ }
|
|
|
+ contentMap.put(0, chinaLeagalStatuses.get(i).getLegalDate());
|
|
|
+ contentMap.put(1, chinaLeagalStatuses.get(i).getLegalStatus());
|
|
|
+ contentMap.put(2, chinaLeagalStatuses.get(i).getLegalStatusInfo());
|
|
|
+ contentMap.put(3, chinaLeagalStatuses.get(i).getDETAIL());
|
|
|
+ ArrayList<KeyValueVO.InpadocData> inpadocDatas = new ArrayList<>();
|
|
|
+ for (int j = 0; j < 4; j++) {
|
|
|
+ KeyValueVO.InpadocData inpadocData = new KeyValueVO.InpadocData();
|
|
|
+ inpadocData.setName(nameMap.get(j));
|
|
|
+ inpadocData.setContent(contentMap.get(j));
|
|
|
+ inpadocDatas.add(inpadocData);
|
|
|
+ }
|
|
|
+ KeyValueVO keyValueVO = new KeyValueVO();
|
|
|
+ keyValueVO.setInpadocData(inpadocDatas);
|
|
|
+ lst.add(keyValueVO);
|
|
|
}
|
|
|
- KeyValueVO keyValueVO = new KeyValueVO();
|
|
|
- keyValueVO.setInpadocData(inpadocDatas);
|
|
|
- lst.add(keyValueVO);
|
|
|
+ //装载事务表的status(公开|授权|驳回|权力转移。。。)
|
|
|
+ String content = JSONObject.toJSONString(lst);
|
|
|
+ patentAffair.setContent(content);
|
|
|
+ uploadParamsVO.setPatentAffair(patentAffair);
|
|
|
}
|
|
|
- //装载事务表的status(公开|授权|驳回|权力转移。。。)
|
|
|
- String content = JSONObject.toJSONString(lst);
|
|
|
- patentAffair.setContent(content);
|
|
|
- uploadParamsVO.setPatentAffair(patentAffair);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -513,42 +516,37 @@ public class ExcutePatentDataStar implements IExcutePatentData {
|
|
|
* @param starPatent 专利之星著录对象
|
|
|
* @param uploadParamsVO 专利实体类对象
|
|
|
*/
|
|
|
- public void setPatentClaim(StarPatentVO starPatent, UploadParamsVO uploadParamsVO) {
|
|
|
- try {
|
|
|
- String appNo;
|
|
|
- if (starPatent.getApplicationNo().contains(".")) {
|
|
|
- appNo = starPatent.getApplicationNo().substring(0, starPatent.getApplicationNo().lastIndexOf("."));
|
|
|
- } else {
|
|
|
- appNo = starPatent.getApplicationNo();
|
|
|
- }
|
|
|
- //根据申请号调用"获得中国专利全文文本"接口,获得包含各种xml标签的专利全文内容的长字符串 cnFullXmlStr
|
|
|
- String cnFullXmlStr = patentStarApiService.getCnFullXmlApi(appNo);
|
|
|
-
|
|
|
- //使用正则表达式拼接出权要原文
|
|
|
- String regex = "(?<=<claim id=.{1,110}>)[\\w\\W]+?(?=</claim>)";
|
|
|
- Pattern compile = Pattern.compile(regex);
|
|
|
- Matcher matcher = compile.matcher(cnFullXmlStr);
|
|
|
- StringBuilder builder = new StringBuilder();
|
|
|
- while (matcher.find()) {
|
|
|
- String macherGroup = matcher.group();
|
|
|
- String right = macherGroup.replaceAll("<.*?>", "").trim();
|
|
|
- builder.append(right).append("\r\n");
|
|
|
- }
|
|
|
+ public void setPatentClaim(StarPatentVO starPatent, UploadParamsVO uploadParamsVO) throws IOException {
|
|
|
+ String appNo;
|
|
|
+ if (starPatent.getApplicationNo().contains(".")) {
|
|
|
+ appNo = starPatent.getApplicationNo().substring(0, starPatent.getApplicationNo().lastIndexOf("."));
|
|
|
+ } else {
|
|
|
+ appNo = starPatent.getApplicationNo();
|
|
|
+ }
|
|
|
+ //根据申请号调用"获得中国专利全文文本"接口,获得包含各种xml标签的专利全文内容的长字符串 cnFullXmlStr
|
|
|
+ String cnFullXmlStr = patentStarApiService.getCnFullXmlApi(appNo);
|
|
|
+
|
|
|
+ //使用正则表达式拼接出权要原文
|
|
|
+ String regex = "(?<=<claim id=.{1,110}>)[\\w\\W]+?(?=</claim>)";
|
|
|
+ Pattern compile = Pattern.compile(regex);
|
|
|
+ Matcher matcher = compile.matcher(cnFullXmlStr);
|
|
|
+ StringBuilder builder = new StringBuilder();
|
|
|
+ while (matcher.find()) {
|
|
|
+ String macherGroup = matcher.group();
|
|
|
+ String right = macherGroup.replaceAll("<.*?>", "").trim();
|
|
|
+ builder.append(right).append("\r\n");
|
|
|
+ }
|
|
|
|
|
|
- String patentRightText = builder + "";
|
|
|
+ String patentRightText = builder + "";
|
|
|
|
|
|
- //使用工具类去除字符串文本中的所有HTML格式标签
|
|
|
- patentRightText = RemoveHtmlTagsUtils.removeHtmlTags(patentRightText);
|
|
|
- patentRightText = patentRightText.trim();
|
|
|
+ //使用工具类去除字符串文本中的所有HTML格式标签
|
|
|
+ patentRightText = RemoveHtmlTagsUtils.removeHtmlTags(patentRightText);
|
|
|
+ patentRightText = patentRightText.trim();
|
|
|
|
|
|
- //装载权利要求原文
|
|
|
- PatentRight patentRight = new PatentRight();
|
|
|
- patentRight.setContent(patentRightText);
|
|
|
- uploadParamsVO.setPatentRight(patentRight);
|
|
|
-
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
+ //装载权利要求原文
|
|
|
+ PatentRight patentRight = new PatentRight();
|
|
|
+ patentRight.setContent(patentRightText);
|
|
|
+ uploadParamsVO.setPatentRight(patentRight);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -558,120 +556,64 @@ public class ExcutePatentDataStar implements IExcutePatentData {
|
|
|
* @param starPatent 专利之星著录对象
|
|
|
* @param uploadParamsVO 专利实体类对象
|
|
|
*/
|
|
|
- public void setPatentInstructionText(StarPatentVO starPatent, UploadParamsVO uploadParamsVO) {
|
|
|
- try {
|
|
|
- String appNo;
|
|
|
- if (starPatent.getApplicationNo().contains(".")) {
|
|
|
- appNo = starPatent.getApplicationNo().substring(0, starPatent.getApplicationNo().lastIndexOf("."));
|
|
|
+ public void setPatentInstructionText(StarPatentVO starPatent, UploadParamsVO uploadParamsVO) throws IOException {
|
|
|
+ String appNo;
|
|
|
+ if (starPatent.getApplicationNo().contains(".")) {
|
|
|
+ appNo = starPatent.getApplicationNo().substring(0, starPatent.getApplicationNo().lastIndexOf("."));
|
|
|
+ } else {
|
|
|
+ appNo = starPatent.getApplicationNo();
|
|
|
+ }
|
|
|
+ //根据申请号调用"获得中国专利全文文本"接口,获得包含各种xml标签的专利全文内容的长字符串 cnFullXmlStr
|
|
|
+ String cnFullXmlStr = patentStarApiService.getCnFullXmlApi(appNo);
|
|
|
+
|
|
|
+ //使用正则表达式拼接出说明书文本全文
|
|
|
+ String regex = "(?<=<p id=\"p)[\\w\\W]+?(?=</p>)";
|
|
|
+ Pattern compile = Pattern.compile(regex);
|
|
|
+ Matcher matcher = compile.matcher(cnFullXmlStr);
|
|
|
+ StringBuilder builder = new StringBuilder();
|
|
|
+ while (matcher.find()) {
|
|
|
+ String oldRow = matcher.group();
|
|
|
+ if (oldRow.contains("num=\"n")) {
|
|
|
+ oldRow = oldRow.substring(oldRow.indexOf("num=\"n") + 6);
|
|
|
+ oldRow = "[" + oldRow;
|
|
|
+ oldRow = oldRow.replace("\">", "]");
|
|
|
+ } else if (oldRow.contains("num=")) {
|
|
|
+ oldRow = oldRow.substring(oldRow.indexOf("num=") + 5);
|
|
|
+ oldRow = "[" + oldRow;
|
|
|
+ oldRow = oldRow.replace("\">", "]");
|
|
|
} else {
|
|
|
- appNo = starPatent.getApplicationNo();
|
|
|
+ oldRow = oldRow.substring(oldRow.indexOf("\">") + 2);
|
|
|
}
|
|
|
- //根据申请号调用"获得中国专利全文文本"接口,获得包含各种xml标签的专利全文内容的长字符串 cnFullXmlStr
|
|
|
- String cnFullXmlStr = patentStarApiService.getCnFullXmlApi(appNo);
|
|
|
-
|
|
|
- //使用正则表达式拼接出说明书文本全文
|
|
|
- String regex = "(?<=<p id=\"p)[\\w\\W]+?(?=</p>)";
|
|
|
- Pattern compile = Pattern.compile(regex);
|
|
|
- Matcher matcher = compile.matcher(cnFullXmlStr);
|
|
|
- StringBuilder builder = new StringBuilder();
|
|
|
- while (matcher.find()) {
|
|
|
- String oldRow = matcher.group();
|
|
|
- if (oldRow.contains("num=\"n")) {
|
|
|
- oldRow = oldRow.substring(oldRow.indexOf("num=\"n") + 6);
|
|
|
- oldRow = "[" + oldRow;
|
|
|
- oldRow = oldRow.replace("\">", "]");
|
|
|
- } else if (oldRow.contains("num=")) {
|
|
|
- oldRow = oldRow.substring(oldRow.indexOf("num=") + 5);
|
|
|
- oldRow = "[" + oldRow;
|
|
|
- oldRow = oldRow.replace("\">", "]");
|
|
|
- } else {
|
|
|
- oldRow = oldRow.substring(oldRow.indexOf("\">") + 2);
|
|
|
- }
|
|
|
- builder.append(oldRow).append("\r\n");
|
|
|
- }
|
|
|
-
|
|
|
- String instructionText = builder + "";
|
|
|
-
|
|
|
- //使用工具类去除字符串文本中的所有HTML格式标签
|
|
|
- instructionText = RemoveHtmlTagsUtils.removeHtmlTags(instructionText);
|
|
|
- instructionText = instructionText.trim();
|
|
|
-
|
|
|
- //装载说明书文本全文
|
|
|
- PatentInstructionText patentInstructionText = new PatentInstructionText();
|
|
|
- patentInstructionText.setManual(instructionText);
|
|
|
- uploadParamsVO.setPatentInstructionText(patentInstructionText);
|
|
|
-
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ builder.append(oldRow).append("\r\n");
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
+ String instructionText = builder + "";
|
|
|
|
|
|
- /**
|
|
|
- * 装载说明书pdf
|
|
|
- *
|
|
|
- * @param starPatent 专利之星著录对象
|
|
|
- * @param uploadParamsVO 专利实体类对象
|
|
|
- */
|
|
|
- public void setPatentInstructionPDF(StarPatentVO starPatent, UploadParamsVO uploadParamsVO) {
|
|
|
- try {
|
|
|
- //根据专利号调用"获得世界专利pdf"接口,获得pdf的url地址
|
|
|
- if (starPatent.getPatentNo() != null && !starPatent.getPatentNo().equals("")) {
|
|
|
- String pdfUrl = patentStarApiService.getEnPdfApi(starPatent.getPatentNo());
|
|
|
- URL url = new URL(pdfUrl); //想要读取的url地址
|
|
|
- InputStream in = url.openStream();
|
|
|
-
|
|
|
- File file = File.createTempFile("new_url", ".pdf"); //创建文件
|
|
|
- OutputStream os = new FileOutputStream(file); //创建文件输出流
|
|
|
- int bytesRead;
|
|
|
- byte[] buffer = new byte[8192];
|
|
|
- int len = 8192;
|
|
|
- while ((bytesRead = in.read(buffer, 0, len)) != -1) {
|
|
|
- os.write(buffer, 0, bytesRead);
|
|
|
- }
|
|
|
- //关闭释放流
|
|
|
- os.close();
|
|
|
- in.close();
|
|
|
-
|
|
|
- DiskFileItemFactory diskFileItemFactory = new DiskFileItemFactory(16, null);
|
|
|
- FileItem item = diskFileItemFactory.createItem(file.getName(), "text/plain", true, file.getName());
|
|
|
- buffer = new byte[8192];
|
|
|
- FileInputStream fis = new FileInputStream(file);
|
|
|
- OutputStream fos = item.getOutputStream();
|
|
|
- len = 8192;
|
|
|
- while ((bytesRead = fis.read(buffer, 0, len)) != -1) {
|
|
|
- fos.write(buffer, 0, bytesRead);
|
|
|
- }
|
|
|
- //关闭释放流
|
|
|
- fos.close();
|
|
|
- fis.close();
|
|
|
- MultipartFile multipartFile = new CommonsMultipartFile(item);
|
|
|
- UploadFileDTO fileDTO = fileUtils.uploadFile(multipartFile);
|
|
|
- uploadParamsVO.setFileDTO(fileDTO);
|
|
|
+ //使用工具类去除字符串文本中的所有HTML格式标签
|
|
|
+ instructionText = RemoveHtmlTagsUtils.removeHtmlTags(instructionText);
|
|
|
+ instructionText = instructionText.trim();
|
|
|
|
|
|
- }
|
|
|
-
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
+ //装载说明书文本全文
|
|
|
+ PatentInstructionText patentInstructionText = new PatentInstructionText();
|
|
|
+ patentInstructionText.setManual(instructionText);
|
|
|
+ uploadParamsVO.setPatentInstructionText(patentInstructionText);
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 装载摘要附图
|
|
|
+ * 装载说明书pdf
|
|
|
*
|
|
|
* @param starPatent 专利之星著录对象
|
|
|
* @param uploadParamsVO 专利实体类对象
|
|
|
*/
|
|
|
- public void setPatentPicture(StarPatentVO starPatent, UploadParamsVO uploadParamsVO) {
|
|
|
- //取出一般接口返回的摘要附图路径
|
|
|
- String pictureUrl = starPatent.getAbstractPath();
|
|
|
-
|
|
|
- try {
|
|
|
- URL url = new URL(pictureUrl); //想要读取的url地址
|
|
|
+ public void setPatentInstructionPDF(StarPatentVO starPatent, UploadParamsVO uploadParamsVO) throws IOException {
|
|
|
+ //根据专利号调用"获得世界专利pdf"接口,获得pdf的url地址
|
|
|
+ if (starPatent.getPatentNo() != null && !starPatent.getPatentNo().equals("")) {
|
|
|
+ String pdfUrl = patentStarApiService.getEnPdfApi(starPatent.getPatentNo());
|
|
|
+ URL url = new URL(pdfUrl); //想要读取的url地址
|
|
|
InputStream in = url.openStream();
|
|
|
|
|
|
- File file = File.createTempFile("new_url", ".jpg"); //创建文件
|
|
|
+ File file = File.createTempFile("new_url", ".pdf"); //创建文件
|
|
|
OutputStream os = new FileOutputStream(file); //创建文件输出流
|
|
|
int bytesRead;
|
|
|
byte[] buffer = new byte[8192];
|
|
@@ -699,14 +641,51 @@ public class ExcutePatentDataStar implements IExcutePatentData {
|
|
|
UploadFileDTO fileDTO = fileUtils.uploadFile(multipartFile);
|
|
|
uploadParamsVO.setFileDTO(fileDTO);
|
|
|
|
|
|
-
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 装载摘要附图
|
|
|
+ *
|
|
|
+ * @param starPatent 专利之星著录对象
|
|
|
+ * @param uploadParamsVO 专利实体类对象
|
|
|
+ */
|
|
|
+ public void setPatentPicture(StarPatentVO starPatent, UploadParamsVO uploadParamsVO) throws IOException {
|
|
|
+ //取出一般接口返回的摘要附图路径
|
|
|
+ String pictureUrl = starPatent.getAbstractPath();
|
|
|
+ URL url = new URL(pictureUrl); //想要读取的url地址
|
|
|
+ InputStream in = url.openStream();
|
|
|
+ File file = File.createTempFile("new_url", ".jpg"); //创建文件
|
|
|
+ OutputStream os = new FileOutputStream(file); //创建文件输出流
|
|
|
+ int bytesRead;
|
|
|
+ byte[] buffer = new byte[8192];
|
|
|
+ int len = 8192;
|
|
|
+ while ((bytesRead = in.read(buffer, 0, len)) != -1) {
|
|
|
+ os.write(buffer, 0, bytesRead);
|
|
|
+ }
|
|
|
+ //关闭释放流
|
|
|
+ os.close();
|
|
|
+ in.close();
|
|
|
+
|
|
|
+ DiskFileItemFactory diskFileItemFactory = new DiskFileItemFactory(16, null);
|
|
|
+ FileItem item = diskFileItemFactory.createItem(file.getName(), "text/plain", true, file.getName());
|
|
|
+ buffer = new byte[8192];
|
|
|
+ FileInputStream fis = new FileInputStream(file);
|
|
|
+ OutputStream fos = item.getOutputStream();
|
|
|
+ len = 8192;
|
|
|
+ while ((bytesRead = fis.read(buffer, 0, len)) != -1) {
|
|
|
+ fos.write(buffer, 0, bytesRead);
|
|
|
+ }
|
|
|
+ //关闭释放流
|
|
|
+ fos.close();
|
|
|
+ fis.close();
|
|
|
+ MultipartFile multipartFile = new CommonsMultipartFile(item);
|
|
|
+ UploadFileDTO fileDTO = fileUtils.uploadFile(multipartFile);
|
|
|
+ uploadParamsVO.setFileDTO(fileDTO);
|
|
|
+
|
|
|
+ }
|
|
|
+ /**
|
|
|
* 下载指定多个专利号专利
|
|
|
*
|
|
|
* @param isAddPatentNos 起止条数以外,用户手动勾选的多个专利号
|