|
@@ -6,8 +6,10 @@ import cn.cslg.pas.common.model.vo.UploadParamsVO;
|
|
|
import cn.cslg.pas.common.model.vo.outApi.StarPatentVO;
|
|
|
import cn.cslg.pas.common.utils.FileUtils;
|
|
|
import cn.cslg.pas.common.utils.RemoveHtmlTagsUtils;
|
|
|
+import cn.cslg.pas.common.utils.ThrowException;
|
|
|
import cn.cslg.pas.domain.*;
|
|
|
import cn.cslg.pas.domain.asso.AssoOsTaskQrtzTask;
|
|
|
+import cn.cslg.pas.service.TaskService;
|
|
|
import cn.cslg.pas.service.UploadPatentBatchService;
|
|
|
import cn.cslg.pas.service.asso.AssoOsTaskQrtzTaskService;
|
|
|
import cn.cslg.pas.service.outApi.PatentStarApiService;
|
|
@@ -55,23 +57,22 @@ public class ExcutePatentDataStar implements IExcutePatentData {
|
|
|
@Override
|
|
|
public void startExcute(Task task) throws IOException {
|
|
|
//从任务关联网站导入任务表中取出当前任务
|
|
|
- List<AssoOsTaskQrtzTask> assoOsTaskQrtzTasks = assoOsTaskQrtzTaskService.list(new LambdaQueryWrapper<AssoOsTaskQrtzTask>().eq(AssoOsTaskQrtzTask::getTaskId, task.getId()));
|
|
|
- AssoOsTaskQrtzTask assoOsTaskQrtzTask = assoOsTaskQrtzTasks.get(0);
|
|
|
+ //List<AssoOsTaskQrtzTask> assoOsTaskQrtzTasks = assoOsTaskQrtzTaskService.list(new LambdaQueryWrapper<AssoOsTaskQrtzTask>().eq(AssoOsTaskQrtzTask::getTaskId, task.getId()));
|
|
|
+ ///AssoOsTaskQrtzTask assoOsTaskQrtzTask = assoOsTaskQrtzTasks.get(0);
|
|
|
+ AssoOsTaskQrtzTask assoOsTaskQrtzTask = assoOsTaskQrtzTaskService.getById(task.getQrtzTaskId());
|
|
|
|
|
|
- //从任务数据中获取下载字段、检索式
|
|
|
- String cellsStr = assoOsTaskQrtzTask.getConfigCells();
|
|
|
- List<String> cells = Arrays.asList(cellsStr.split(","));
|
|
|
+ //从任务数据中获取专利总数量、检索式、下载字段
|
|
|
+ Integer total = assoOsTaskQrtzTask.getTotal();
|
|
|
String conditions = assoOsTaskQrtzTask.getConditions();
|
|
|
+ List<String> cells = Arrays.asList(assoOsTaskQrtzTask.getConfigCells().split(","));
|
|
|
|
|
|
- //定义每次检索的专利数量(每次检索50件)
|
|
|
+ //定义每次检索的页码
|
|
|
+ int pageNum = 0;
|
|
|
+ //定义每次检索的专利数量(当前定义每次检索50件)
|
|
|
int size = 50;
|
|
|
|
|
|
- //获得专利总数量
|
|
|
- Integer count = task.getTotal();
|
|
|
-
|
|
|
//1.根据专利总数量count遍历检索专利
|
|
|
- int pageNum = 0; //页码
|
|
|
- for (int i = 1; i <= count; i += size) {
|
|
|
+ for (int i = 1; i <= total; i += size) {
|
|
|
pageNum++;
|
|
|
PatentStarListDto patentStarListDto = new PatentStarListDto()
|
|
|
.setCurrentQuery(conditions)
|
|
@@ -80,21 +81,19 @@ public class ExcutePatentDataStar implements IExcutePatentData {
|
|
|
.setPageNum(pageNum)
|
|
|
.setRowCount(size)
|
|
|
.setDBType("CN");
|
|
|
- //调用一般接口
|
|
|
+ //调用一般接口返回一批专利著录相关数据
|
|
|
Map<String, Object> resultMap = patentStarApiService.patentStarSearchApi(patentStarListDto);
|
|
|
if (resultMap == null || (Integer) resultMap.get("total") == 0) {
|
|
|
- continue;
|
|
|
+ ThrowException.throwXiaoShiException("发生未知错误,一般接口未检索出专利");
|
|
|
}
|
|
|
|
|
|
- //调用一般接口返回一批专利著录相关数据
|
|
|
List<StarPatentVO> patents = (List<StarPatentVO>) resultMap.get("records");
|
|
|
-
|
|
|
- //遍历50个专利
|
|
|
+ //遍历这一批专利(50个)
|
|
|
for (StarPatentVO starPatent : patents) {
|
|
|
try {
|
|
|
UploadParamsVO uploadParamsVO = new UploadParamsVO();
|
|
|
setPatentZhuLu(starPatent, uploadParamsVO);
|
|
|
- //保存专利基础数据(专利表"os_patent")
|
|
|
+ //保存专利基础数据(专利表"os_patent"),因为需要先拿到专利id供其他消费者部分使用
|
|
|
uploadPatentBatchService.getOneOrInsertOne(uploadParamsVO);
|
|
|
|
|
|
PQueueData pQueueData = new PQueueData()
|
|
@@ -124,8 +123,7 @@ public class ExcutePatentDataStar implements IExcutePatentData {
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- //exceptionNum++;
|
|
|
- //跳过当前生产出问题的专利,继续生产下一个专利
|
|
|
+ //继续下一个专利
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -176,7 +174,7 @@ public class ExcutePatentDataStar implements IExcutePatentData {
|
|
|
uploadParamsVO.setMainIpc(ipcArr[0]);
|
|
|
uploadParamsVO.setIpcList(Arrays.asList(ipcArr));
|
|
|
}
|
|
|
- //装载法律状态
|
|
|
+ //装载法律状态(os_patent表status字段值)
|
|
|
Integer status = starPatent.getLG();
|
|
|
if (status != null) {
|
|
|
//有效(有权)
|
|
@@ -290,34 +288,39 @@ public class ExcutePatentDataStar implements IExcutePatentData {
|
|
|
* @param starPatent 专利之星著录对象
|
|
|
* @param uploadParamsVO 专利实体类对象
|
|
|
*/
|
|
|
- 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-text>)[\\w\\W]+?(?=</claim-text>)";
|
|
|
- Pattern compile = Pattern.compile(regex);
|
|
|
- Matcher matcher = compile.matcher(cnFullXmlStr);
|
|
|
- StringBuilder builder = new StringBuilder();
|
|
|
- while (matcher.find()) {
|
|
|
- builder.append(matcher.group()).append("\r\n");
|
|
|
- }
|
|
|
+ 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-text>)[\\w\\W]+?(?=</claim-text>)";
|
|
|
+ Pattern compile = Pattern.compile(regex);
|
|
|
+ Matcher matcher = compile.matcher(cnFullXmlStr);
|
|
|
+ StringBuilder builder = new StringBuilder();
|
|
|
+ while (matcher.find()) {
|
|
|
+ builder.append(matcher.group()).append("\r\n");
|
|
|
+ }
|
|
|
|
|
|
- String patentRightText = builder + "";
|
|
|
+ String patentRightText = builder + "";
|
|
|
|
|
|
- //使用工具类去除字符串文本中的所有HTML格式标签
|
|
|
- patentRightText = RemoveHtmlTagsUtils.removeHtmlTags(patentRightText);
|
|
|
+ //使用工具类去除字符串文本中的所有HTML格式标签
|
|
|
+ patentRightText = RemoveHtmlTagsUtils.removeHtmlTags(patentRightText);
|
|
|
|
|
|
- //装载权利要求原文
|
|
|
- PatentRight patentRight = new PatentRight();
|
|
|
- patentRight.setContent(patentRightText);
|
|
|
- uploadParamsVO.setPatentRight(patentRight);
|
|
|
+ //装载权利要求原文
|
|
|
+ PatentRight patentRight = new PatentRight();
|
|
|
+ patentRight.setContent(patentRightText);
|
|
|
+ uploadParamsVO.setPatentRight(patentRight);
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -327,46 +330,51 @@ public class ExcutePatentDataStar implements IExcutePatentData {
|
|
|
* @param starPatent 专利之星著录对象
|
|
|
* @param uploadParamsVO 专利实体类对象
|
|
|
*/
|
|
|
- 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("\">", "]");
|
|
|
+ public void setPatentInstructionText(StarPatentVO starPatent, UploadParamsVO uploadParamsVO) {
|
|
|
+ try {
|
|
|
+ String appNo;
|
|
|
+ if (starPatent.getApplicationNo().contains(".")) {
|
|
|
+ appNo = starPatent.getApplicationNo().substring(0, starPatent.getApplicationNo().lastIndexOf("."));
|
|
|
} else {
|
|
|
- oldRow = oldRow.substring(oldRow.indexOf("\">") + 2);
|
|
|
+ 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 {
|
|
|
+ oldRow = oldRow.substring(oldRow.indexOf("\">") + 2);
|
|
|
+ }
|
|
|
+ builder.append(oldRow).append("\r\n");
|
|
|
}
|
|
|
- builder.append(oldRow).append("\r\n");
|
|
|
- }
|
|
|
|
|
|
- String instructionText = builder + "";
|
|
|
+ String instructionText = builder + "";
|
|
|
|
|
|
- //使用工具类去除字符串文本中的所有HTML格式标签
|
|
|
- instructionText = RemoveHtmlTagsUtils.removeHtmlTags(instructionText);
|
|
|
+ //使用工具类去除字符串文本中的所有HTML格式标签
|
|
|
+ instructionText = RemoveHtmlTagsUtils.removeHtmlTags(instructionText);
|
|
|
|
|
|
- //装载说明书文本全文
|
|
|
- PatentInstructionText patentInstructionText = new PatentInstructionText();
|
|
|
- patentInstructionText.setManual(instructionText);
|
|
|
- uploadParamsVO.setPatentInstructionText(patentInstructionText);
|
|
|
+ //装载说明书文本全文
|
|
|
+ PatentInstructionText patentInstructionText = new PatentInstructionText();
|
|
|
+ patentInstructionText.setManual(instructionText);
|
|
|
+ uploadParamsVO.setPatentInstructionText(patentInstructionText);
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -427,14 +435,17 @@ public class ExcutePatentDataStar implements IExcutePatentData {
|
|
|
* @param uploadParamsVO 专利实体类对象
|
|
|
*/
|
|
|
public void setPatentPicture(StarPatentVO starPatent, UploadParamsVO uploadParamsVO) {
|
|
|
- String appNo = null;
|
|
|
- if (starPatent.getApplicationNo().contains(".")) {
|
|
|
- appNo = starPatent.getApplicationNo().substring(0, starPatent.getApplicationNo().lastIndexOf("."));
|
|
|
- } else {
|
|
|
- appNo = starPatent.getApplicationNo();
|
|
|
- }
|
|
|
- //根据申请号调用"获得中国专利摘要附图"接口,获得摘要附图的url地址
|
|
|
- String pictureUrl = patentStarApiService.getPictureApi(appNo);
|
|
|
+// String appNo;
|
|
|
+// if (starPatent.getApplicationNo().contains(".")) {
|
|
|
+// appNo = starPatent.getApplicationNo().substring(0, starPatent.getApplicationNo().lastIndexOf("."));
|
|
|
+// } else {
|
|
|
+// appNo = starPatent.getApplicationNo();
|
|
|
+// }
|
|
|
+// //以下 ↓调用的是"获得中国专利摘要附图"接口,获得摘要附图的url地址
|
|
|
+// String pictureUrl = patentStarApiService.getPictureApi(appNo);
|
|
|
+
|
|
|
+ //直接取出一般接口返回的摘要附图路径
|
|
|
+ String pictureUrl = starPatent.getAbstractPath();
|
|
|
|
|
|
try {
|
|
|
URL url = new URL(pictureUrl); //想要读取的url地址
|