|
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.example.demo.domain.*;
|
|
import com.example.demo.domain.*;
|
|
import com.example.demo.mapper.QrtzTaskMapper;
|
|
import com.example.demo.mapper.QrtzTaskMapper;
|
|
import com.example.demo.model.dto.QuartzTaskDTO;
|
|
import com.example.demo.model.dto.QuartzTaskDTO;
|
|
|
|
+import com.example.demo.model.dto.WebQueryDTO;
|
|
import com.example.demo.util.FileUtils;
|
|
import com.example.demo.util.FileUtils;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -17,14 +18,12 @@ import org.openqa.selenium.interactions.Actions;
|
|
import org.openqa.selenium.support.ui.ExpectedConditions;
|
|
import org.openqa.selenium.support.ui.ExpectedConditions;
|
|
import org.openqa.selenium.support.ui.WebDriverWait;
|
|
import org.openqa.selenium.support.ui.WebDriverWait;
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.HashMap;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Set;
|
|
|
|
|
|
+import java.util.*;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
import java.util.regex.Pattern;
|
|
@@ -42,8 +41,11 @@ public class UploadFromWebService {
|
|
private final WebConfigService webConfigService;
|
|
private final WebConfigService webConfigService;
|
|
|
|
|
|
// 查询并上传(专利之星)
|
|
// 查询并上传(专利之星)
|
|
- public List<PatentCell> getPatentStar(String conditions, Integer id) throws Exception {
|
|
|
|
- conditions=this.formatConditions(conditions);
|
|
|
|
|
|
+ @Async("singleThreadAsyncTaskExecutor")
|
|
|
|
+ public List<PatentCell> getPatentStar(WebQueryDTO webQueryDTO) throws Exception {
|
|
|
|
+ String conditions = webQueryDTO.getConditions();
|
|
|
|
+ Integer id = webQueryDTO.getWebConfigId();
|
|
|
|
+ conditions = this.formatConditions(conditions);
|
|
//根据id 获得网站配置
|
|
//根据id 获得网站配置
|
|
WebConfig webConfig = webConfigService.getConfigById(id);
|
|
WebConfig webConfig = webConfigService.getConfigById(id);
|
|
List<PatentCell> patentCells = new ArrayList<>();
|
|
List<PatentCell> patentCells = new ArrayList<>();
|
|
@@ -97,6 +99,8 @@ public class UploadFromWebService {
|
|
// 页面元素标签
|
|
// 页面元素标签
|
|
for (int i = 0; i < patentContents.size(); i++) {
|
|
for (int i = 0; i < patentContents.size(); i++) {
|
|
PatentCell patentCell = new PatentCell();
|
|
PatentCell patentCell = new PatentCell();
|
|
|
|
+ patentCell.setProjectId(webQueryDTO.getProjectId());
|
|
|
|
+ patentCell.setReportId(webQueryDTO.getReportId());
|
|
wait1.until(ExpectedConditions.presenceOfElementLocated(By.className("title-color")));
|
|
wait1.until(ExpectedConditions.presenceOfElementLocated(By.className("title-color")));
|
|
WebElement titleA = patentContents.get(i).findElement(By.className("title-color"));
|
|
WebElement titleA = patentContents.get(i).findElement(By.className("title-color"));
|
|
titleA.click();
|
|
titleA.click();
|
|
@@ -119,40 +123,62 @@ public class UploadFromWebService {
|
|
String value = "";
|
|
String value = "";
|
|
String[] strings = text.split(":");
|
|
String[] strings = text.split(":");
|
|
if (strings.length > 1) {
|
|
if (strings.length > 1) {
|
|
- value = strings[1];
|
|
|
|
- }
|
|
|
|
- switch (t) {
|
|
|
|
- case 0:
|
|
|
|
- patentCell.setApplicationNo(value);
|
|
|
|
- case 1:
|
|
|
|
- patentCell.setApplicationDate(value);
|
|
|
|
- case 2:
|
|
|
|
- patentCell.setCountry(value);
|
|
|
|
- case 3:
|
|
|
|
- patentCell.setPatentNo(value);
|
|
|
|
- case 4:
|
|
|
|
- patentCell.setPubilcDate(value);
|
|
|
|
- case 5:
|
|
|
|
- patentCell.setPublicAccreditNo(value);
|
|
|
|
- case 6:
|
|
|
|
- patentCell.setPublicAccreditDate(value);
|
|
|
|
- case 7:
|
|
|
|
- patentCell.setMainTypeNo(value);
|
|
|
|
- case 8:
|
|
|
|
- patentCell.setTypeNo(value);
|
|
|
|
- case 9:
|
|
|
|
- patentCell.setApplicationNo(value);
|
|
|
|
- case 10:
|
|
|
|
- patentCell.setApplicationAddress(value);
|
|
|
|
- case 11:
|
|
|
|
- patentCell.setInventor(value);
|
|
|
|
- case 12:
|
|
|
|
- patentCell.setPatentApplication(value);
|
|
|
|
- case 13:
|
|
|
|
- patentCell.setClassical(value);
|
|
|
|
- case 14:
|
|
|
|
- patentCell.setStatue(value);
|
|
|
|
- break;
|
|
|
|
|
|
+ value = strings[1].trim();
|
|
|
|
+ String key = strings[0].trim();
|
|
|
|
+
|
|
|
|
+ switch (key) {
|
|
|
|
+ case "申请号":
|
|
|
|
+ patentCell.setApplicationNo(value);
|
|
|
|
+ break;
|
|
|
|
+ case "申请日":
|
|
|
|
+ patentCell.setApplicationDate(value);
|
|
|
|
+ break;
|
|
|
|
+ case "国家/省市":
|
|
|
|
+ patentCell.setCountry(value);
|
|
|
|
+ break;
|
|
|
|
+ case "公开号":
|
|
|
|
+ patentCell.setPublicNo(value);
|
|
|
|
+ break;
|
|
|
|
+ case "公开日":
|
|
|
|
+ patentCell.setPubilcDate(value);
|
|
|
|
+ break;
|
|
|
|
+ case "授权公告号":
|
|
|
|
+ patentCell.setPublicAccreditNo(value);
|
|
|
|
+ break;
|
|
|
|
+ case "授权公告日":
|
|
|
|
+ patentCell.setPublicAccreditDate(value);
|
|
|
|
+ break;
|
|
|
|
+ case "主分类号":
|
|
|
|
+ patentCell.setMainIpc(value);
|
|
|
|
+ break;
|
|
|
|
+ case "分类号":
|
|
|
|
+ patentCell.setIpc(this.StringToList(value, ";"));
|
|
|
|
+ break;
|
|
|
|
+ case "申请人":
|
|
|
|
+ patentCell.setApplicationPersons(this.StringToList(value, " "));
|
|
|
|
+ break;
|
|
|
|
+ case "申请人地址":
|
|
|
|
+ patentCell.setApplicationAddress(this.StringToList(value, " "));
|
|
|
|
+ break;
|
|
|
|
+ case "发明人":
|
|
|
|
+ patentCell.setInventors(this.StringToList(value, " "));
|
|
|
|
+ break;
|
|
|
|
+ case "当前权利人":
|
|
|
|
+ patentCell.setApplicationCurrents(this.StringToList(value, " "));
|
|
|
|
+ break;
|
|
|
|
+ case "代理人":
|
|
|
|
+ patentCell.setAgencyPersons(this.StringToList(value, " "));
|
|
|
|
+ break;
|
|
|
|
+ case "代理机构":
|
|
|
|
+ patentCell.setAgency(value);
|
|
|
|
+ break;
|
|
|
|
+ case "范畴分类":
|
|
|
|
+ patentCell.setClassical(value);
|
|
|
|
+ break;
|
|
|
|
+ case "当前状态":
|
|
|
|
+ patentCell.setStatue(value);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//获得摘要
|
|
//获得摘要
|
|
@@ -168,7 +194,7 @@ public class UploadFromWebService {
|
|
WebElement picElement = driver.findElement(By.className("item-img"));
|
|
WebElement picElement = driver.findElement(By.className("item-img"));
|
|
WebElement imag = picElement.findElement(By.tagName("img"));
|
|
WebElement imag = picElement.findElement(By.tagName("img"));
|
|
String url = imag.getAttribute("src");
|
|
String url = imag.getAttribute("src");
|
|
- url = fileUtils.uploadToLocal(url, ".jpg");
|
|
|
|
|
|
+ url = fileUtils.uploadToLocal(url, ".jpg").getPath();
|
|
patentCell.setPicUrl(url);
|
|
patentCell.setPicUrl(url);
|
|
//获得权要
|
|
//获得权要
|
|
WebElement CLElement = driver.findElement(By.id("itemCL"));
|
|
WebElement CLElement = driver.findElement(By.id("itemCL"));
|
|
@@ -250,19 +276,45 @@ public class UploadFromWebService {
|
|
wait1.until(ExpectedConditions.presenceOfElementLocated(By.tagName("embed")));
|
|
wait1.until(ExpectedConditions.presenceOfElementLocated(By.tagName("embed")));
|
|
WebElement PDFFile = driver.findElement(By.tagName("embed"));
|
|
WebElement PDFFile = driver.findElement(By.tagName("embed"));
|
|
String pdfUrl = PDFFile.getAttribute("src");
|
|
String pdfUrl = PDFFile.getAttribute("src");
|
|
- pdfUrl = fileUtils.uploadToLocal(pdfUrl, ".PDF");
|
|
|
|
- patentCell.setPDF(pdfUrl);
|
|
|
|
-// String res = outInterfaceService.importPatents(patentCell);
|
|
|
|
-// JSONObject jsonObject =JSONObject.parseObject(res);
|
|
|
|
-// if(jsonObject.get("code").toString().equals("0")){
|
|
|
|
-// return null;
|
|
|
|
-// }
|
|
|
|
|
|
+ UploadFileDTO fileDTO = fileUtils.uploadToLocal(pdfUrl, ".PDF");
|
|
|
|
+ patentCell.setPDFName(fileDTO.getFileName());
|
|
|
|
+ patentCell.setPDFSize(fileDTO.getFileSize());
|
|
|
|
+ patentCell.setPDFUrl(fileDTO.getPath());
|
|
|
|
+ patentCell.setPdf(fileDTO);
|
|
|
|
+ //获得法律状态
|
|
|
|
+ WebElement flztElement = driver.findElement(By.id("flztbtn"));
|
|
|
|
+ flztElement.click();
|
|
|
|
+ wait1.until(ExpectedConditions.presenceOfElementLocated(By.id("legalContainer")));
|
|
|
|
+ WebElement tBody = driver.findElement(By.id("legalContainer"));
|
|
|
|
+ TimeUnit.MILLISECONDS.sleep(1000);//毫秒
|
|
|
|
+ List<WebElement> trs =tBody.findElements(By.tagName("tr"));
|
|
|
|
+
|
|
|
|
+ List<PatentCell.PatentAffair> affairs =new ArrayList<>();
|
|
|
|
+ trs.forEach(item->{
|
|
|
|
+ List<WebElement> tds =item.findElements(By.tagName("td"));
|
|
|
|
+ PatentCell.PatentAffair affair =new PatentCell.PatentAffair();
|
|
|
|
+ affair.setDateTime(tds.get(0).getText());
|
|
|
|
+ affair.setSimpleStatus(tds.get(1).getText());
|
|
|
|
+ affair.setStatus(tds.get(2).getText());
|
|
|
|
+ affairs.add(affair);
|
|
|
|
+ });
|
|
|
|
+ patentCell.setPatentAffairs(affairs);
|
|
|
|
+
|
|
|
|
+ if(patentCell.getPublicNo()!=null){
|
|
|
|
+ patentCell.setPatentNo(patentCell.getPublicNo());
|
|
|
|
+ patentCell.setPublicNo(patentCell.getPublicAccreditNo());
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ patentCell.setPatentNo(patentCell.getPublicAccreditNo());
|
|
|
|
+ }
|
|
|
|
+ if (patentCell.getPatentNo() != null) {
|
|
|
|
+ String res = outInterfaceService.importPatents(patentCell);
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
|
+ if (jsonObject.get("code").toString().equals("500")) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
patentCells.add(patentCell);
|
|
patentCells.add(patentCell);
|
|
- //上传
|
|
|
|
- MultipartFile file = FileUtils.urlToMultipartFile(patentCell.getPDF(), ".PDF");
|
|
|
|
- UploadFileDTO fileDTO = fileUtils.uploadFile(file);
|
|
|
|
- String path = fileUtils.getPath(fileDTO.getPath());
|
|
|
|
- patentCell.setUrl(path);
|
|
|
|
driver.close();
|
|
driver.close();
|
|
driver.switchTo().window(handleMap.get("mainPage"));
|
|
driver.switchTo().window(handleMap.get("mainPage"));
|
|
}
|
|
}
|
|
@@ -372,33 +424,44 @@ public class UploadFromWebService {
|
|
for (JSONObject jsonObject1 : sources) {
|
|
for (JSONObject jsonObject1 : sources) {
|
|
jsonObject = jsonObject1;
|
|
jsonObject = jsonObject1;
|
|
}
|
|
}
|
|
- condition= condition.replace(" ", "");
|
|
|
|
- condition= condition.replace("&&", "*");
|
|
|
|
- condition=condition.replace("||", "+");
|
|
|
|
|
|
+ condition = condition.replace(" ", "");
|
|
|
|
+ condition = condition.replace("&&", "*");
|
|
|
|
+ condition = condition.replace("||", "+");
|
|
StringBuilder stringBuilder = new StringBuilder("F XX ");
|
|
StringBuilder stringBuilder = new StringBuilder("F XX ");
|
|
String pattern = "\\([^)]*\\)";
|
|
String pattern = "\\([^)]*\\)";
|
|
Pattern p = Pattern.compile(pattern);
|
|
Pattern p = Pattern.compile(pattern);
|
|
Matcher m = p.matcher(condition);
|
|
Matcher m = p.matcher(condition);
|
|
while (m.find()) { // 当字符串中有匹配到 {} 时
|
|
while (m.find()) { // 当字符串中有匹配到 {} 时
|
|
String param = m.group(0);
|
|
String param = m.group(0);
|
|
- String cell = formatParam(param,jsonObject);
|
|
|
|
- condition= condition.replace(param,cell);
|
|
|
|
|
|
+ String cell = formatParam(param, jsonObject);
|
|
|
|
+ condition = condition.replace(param, cell);
|
|
|
|
|
|
}
|
|
}
|
|
return condition;
|
|
return condition;
|
|
}
|
|
}
|
|
|
|
|
|
public String formatParam(String param, JSONObject jsonObject) {
|
|
public String formatParam(String param, JSONObject jsonObject) {
|
|
- param= param.replace("(", "");
|
|
|
|
- param= param.replace(")", "");
|
|
|
|
|
|
+ param = param.replace("(", "");
|
|
|
|
+ param = param.replace(")", "");
|
|
String[] params = param.split("=");// {} 和里面的内容
|
|
String[] params = param.split("=");// {} 和里面的内容
|
|
StringBuilder stringBuilder = new StringBuilder("(" + params[1]);
|
|
StringBuilder stringBuilder = new StringBuilder("(" + params[1]);
|
|
stringBuilder.append("/");
|
|
stringBuilder.append("/");
|
|
String cell = jsonObject.get(params[0]).toString();
|
|
String cell = jsonObject.get(params[0]).toString();
|
|
- stringBuilder.append(cell +")");
|
|
|
|
|
|
+ stringBuilder.append(cell + ")");
|
|
return stringBuilder.toString();
|
|
return stringBuilder.toString();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //将值转换为list
|
|
|
|
+ public List<String> StringToList(String value, String split) {
|
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
|
+ if (value != null && value != "") {
|
|
|
|
+ String[] temValue = value.split(split);
|
|
|
|
+ list = new ArrayList<>(Arrays.asList(temValue));
|
|
|
|
+ }
|
|
|
|
+ return list;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|