|
@@ -2,14 +2,12 @@ package com.example.demo.service;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.example.demo.domain.PatentCell;
|
|
|
-import com.example.demo.domain.QrtzTask;
|
|
|
-import com.example.demo.domain.UploadFileDTO;
|
|
|
-import com.example.demo.domain.WebConfig;
|
|
|
+import com.example.demo.domain.*;
|
|
|
import com.example.demo.mapper.QrtzTaskMapper;
|
|
|
import com.example.demo.model.dto.QuartzTaskDTO;
|
|
|
import com.example.demo.util.FileUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.openqa.selenium.By;
|
|
|
import org.openqa.selenium.WebDriver;
|
|
|
import org.openqa.selenium.WebElement;
|
|
@@ -28,252 +26,256 @@ import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Set;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
|
|
/**
|
|
|
-* @author admin
|
|
|
-* @description 针对表【qrtz_task(定时任务表)】的数据库操作Service实现
|
|
|
-* @createDate 2023-03-15 13:40:32
|
|
|
-*/
|
|
|
+ * @author admin
|
|
|
+ * @description 针对表【qrtz_task(定时任务表)】的数据库操作Service实现
|
|
|
+ * @createDate 2023-03-15 13:40:32
|
|
|
+ */
|
|
|
@Service
|
|
|
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
|
|
|
-public class UploadFromWebService{
|
|
|
+public class UploadFromWebService {
|
|
|
private final FileUtils fileUtils;
|
|
|
private final OutInterfaceService outInterfaceService;
|
|
|
private final WebConfigService webConfigService;
|
|
|
-// 查询并上传(专利之星)
|
|
|
-public List<PatentCell> getPatentStar(String conditions,Integer id) throws Exception {
|
|
|
- //根据id 获得网站配置
|
|
|
- WebConfig webConfig= webConfigService.getConfigById(id);
|
|
|
- List<PatentCell> patentCells = new ArrayList<>();
|
|
|
- //1.获得驱动
|
|
|
- System.setProperty("webdriver.chrome.driver", "D:\\driver\\chromedriver.exe");
|
|
|
- // 2.页面最大化
|
|
|
- ChromeOptions chromeOptions = new ChromeOptions();
|
|
|
- chromeOptions.addArguments("--start-maximized");
|
|
|
- // 3.创建驱动
|
|
|
- WebDriver driver = new ChromeDriver(chromeOptions);
|
|
|
- // 4.创建动作
|
|
|
- Actions action = new Actions(driver);
|
|
|
- //设置等待时间
|
|
|
- long formSecond1 = 50;
|
|
|
- WebDriverWait wait1 = new WebDriverWait(driver, formSecond1);
|
|
|
- // 打开智慧芽首页
|
|
|
- driver.get(webConfig.getWebAddress());
|
|
|
- wait1.until(ExpectedConditions.presenceOfElementLocated(By.id("loginname")));
|
|
|
- WebElement loginName = driver.findElement(By.id("loginname"));
|
|
|
- WebElement password = driver.findElement(By.id("password"));
|
|
|
- loginName.sendKeys(webConfig.getWebAccount());
|
|
|
- password.sendKeys(webConfig.getWebPassword());
|
|
|
- WebElement loginButton = driver.findElement(By.id("login"));
|
|
|
- loginButton.click();
|
|
|
- //获得表格搜索按钮并点击
|
|
|
- wait1.until(ExpectedConditions.presenceOfElementLocated(By.id("tablepage")));
|
|
|
- WebElement tablePage = driver.findElement(By.id("tablepage"));
|
|
|
- WebElement tablePagea = tablePage.findElement(By.tagName("a"));
|
|
|
- tablePagea.click();
|
|
|
- //获得搜索框并点击
|
|
|
- wait1.until(ExpectedConditions.presenceOfElementLocated(By.id("TxtSearch")));
|
|
|
- WebElement TxtSearch = driver.findElement(By.id("TxtSearch"));
|
|
|
- TxtSearch.sendKeys(conditions);
|
|
|
- WebElement searchBtn = driver.findElement(By.id("searchbtn2"));
|
|
|
- searchBtn.click();
|
|
|
- wait1.until(ExpectedConditions.presenceOfElementLocated(By.className("tcdNumber")));
|
|
|
- List<WebElement> tcdNumbers =driver.findElements(By.className("tcdNumber"));
|
|
|
- String pagesText = tcdNumbers.get(tcdNumbers.size()-1).getText();
|
|
|
- int page =Integer.parseInt(pagesText);
|
|
|
- String Handle = driver.getWindowHandle();
|
|
|
- //创建一个map集合存放浏览器句柄
|
|
|
- HashMap<String, String> handleMap = new HashMap<>();
|
|
|
- //将智慧芽句柄放到map中
|
|
|
- handleMap.put("mainPage", Handle);
|
|
|
- for( int p =0;p<1;p++) {
|
|
|
- //等待数据加载
|
|
|
- wait1.until(ExpectedConditions.presenceOfElementLocated(By.className("patent")));
|
|
|
- TimeUnit.MILLISECONDS.sleep(1000);//毫秒
|
|
|
- //获得列表
|
|
|
- List<WebElement> patentContents = driver.findElements(By.className("patent"));
|
|
|
- // 页面元素标签
|
|
|
- for (int i = 0; i < patentContents.size(); i++) {
|
|
|
- PatentCell patentCell = new PatentCell();
|
|
|
- wait1.until(ExpectedConditions.presenceOfElementLocated(By.className("title-color")));
|
|
|
- WebElement titleA = patentContents.get(i).findElement(By.className("title-color"));
|
|
|
- titleA.click();
|
|
|
- //9、获取到所有的句柄
|
|
|
- Set<String> set = driver.getWindowHandles();
|
|
|
- //10、循环找到详情窗口句柄
|
|
|
- for (String s : set) {
|
|
|
- //10.1、将详情窗口的句柄放到map中
|
|
|
- if (!s.equals(Handle)) {
|
|
|
- handleMap.put("detail", s);
|
|
|
- }
|
|
|
- }
|
|
|
- driver.switchTo().window(handleMap.get("detail"));
|
|
|
- wait1.until(ExpectedConditions.presenceOfElementLocated(By.className("item-content")));
|
|
|
- WebElement itemContent = driver.findElement(By.className("item-content"));
|
|
|
- List<WebElement> divItems = itemContent.findElements(By.tagName("div"));
|
|
|
- for (int t = 0; t < divItems.size(); t++) {
|
|
|
- WebElement temEle = divItems.get(t);
|
|
|
- String text = temEle.getText();
|
|
|
- String value = "";
|
|
|
- String[] strings = text.split(":");
|
|
|
- if (strings.length > 1) {
|
|
|
- value = strings[1];
|
|
|
+
|
|
|
+ // 查询并上传(专利之星)
|
|
|
+ public List<PatentCell> getPatentStar(String conditions, Integer id) throws Exception {
|
|
|
+ conditions=this.formatConditions(conditions);
|
|
|
+ //根据id 获得网站配置
|
|
|
+ WebConfig webConfig = webConfigService.getConfigById(id);
|
|
|
+ List<PatentCell> patentCells = new ArrayList<>();
|
|
|
+ //1.获得驱动
|
|
|
+ System.setProperty("webdriver.chrome.driver", "D:\\driver\\chromedriver.exe");
|
|
|
+ // 2.页面最大化
|
|
|
+ ChromeOptions chromeOptions = new ChromeOptions();
|
|
|
+ chromeOptions.addArguments("--start-maximized");
|
|
|
+ // 3.创建驱动
|
|
|
+ WebDriver driver = new ChromeDriver(chromeOptions);
|
|
|
+ // 4.创建动作
|
|
|
+ Actions action = new Actions(driver);
|
|
|
+ //设置等待时间
|
|
|
+ long formSecond1 = 50;
|
|
|
+ WebDriverWait wait1 = new WebDriverWait(driver, formSecond1);
|
|
|
+ // 打开智慧芽首页
|
|
|
+ driver.get(webConfig.getWebAddress());
|
|
|
+ wait1.until(ExpectedConditions.presenceOfElementLocated(By.id("loginname")));
|
|
|
+ WebElement loginName = driver.findElement(By.id("loginname"));
|
|
|
+ WebElement password = driver.findElement(By.id("password"));
|
|
|
+ loginName.sendKeys(webConfig.getWebAccount());
|
|
|
+ password.sendKeys(webConfig.getWebPassword());
|
|
|
+ WebElement loginButton = driver.findElement(By.id("login"));
|
|
|
+ loginButton.click();
|
|
|
+ //获得表格搜索按钮并点击
|
|
|
+ wait1.until(ExpectedConditions.presenceOfElementLocated(By.id("tablepage")));
|
|
|
+ WebElement tablePage = driver.findElement(By.id("tablepage"));
|
|
|
+ WebElement tablePagea = tablePage.findElement(By.tagName("a"));
|
|
|
+ tablePagea.click();
|
|
|
+ //获得搜索框并点击
|
|
|
+ wait1.until(ExpectedConditions.presenceOfElementLocated(By.id("TxtSearch")));
|
|
|
+ WebElement TxtSearch = driver.findElement(By.id("TxtSearch"));
|
|
|
+ TxtSearch.sendKeys(conditions);
|
|
|
+ WebElement searchBtn = driver.findElement(By.id("searchbtn2"));
|
|
|
+ searchBtn.click();
|
|
|
+ wait1.until(ExpectedConditions.presenceOfElementLocated(By.className("tcdNumber")));
|
|
|
+ List<WebElement> tcdNumbers = driver.findElements(By.className("tcdNumber"));
|
|
|
+ String pagesText = tcdNumbers.get(tcdNumbers.size() - 1).getText();
|
|
|
+ int page = Integer.parseInt(pagesText);
|
|
|
+ String Handle = driver.getWindowHandle();
|
|
|
+ //创建一个map集合存放浏览器句柄
|
|
|
+ HashMap<String, String> handleMap = new HashMap<>();
|
|
|
+ //将智慧芽句柄放到map中
|
|
|
+ handleMap.put("mainPage", Handle);
|
|
|
+ for (int p = 0; p < 1; p++) {
|
|
|
+ //等待数据加载
|
|
|
+ wait1.until(ExpectedConditions.presenceOfElementLocated(By.className("patent")));
|
|
|
+ TimeUnit.MILLISECONDS.sleep(1000);//毫秒
|
|
|
+ //获得列表
|
|
|
+ List<WebElement> patentContents = driver.findElements(By.className("patent"));
|
|
|
+ // 页面元素标签
|
|
|
+ for (int i = 0; i < patentContents.size(); i++) {
|
|
|
+ PatentCell patentCell = new PatentCell();
|
|
|
+ wait1.until(ExpectedConditions.presenceOfElementLocated(By.className("title-color")));
|
|
|
+ WebElement titleA = patentContents.get(i).findElement(By.className("title-color"));
|
|
|
+ titleA.click();
|
|
|
+ //9、获取到所有的句柄
|
|
|
+ Set<String> set = driver.getWindowHandles();
|
|
|
+ //10、循环找到详情窗口句柄
|
|
|
+ for (String s : set) {
|
|
|
+ //10.1、将详情窗口的句柄放到map中
|
|
|
+ if (!s.equals(Handle)) {
|
|
|
+ handleMap.put("detail", s);
|
|
|
+ }
|
|
|
}
|
|
|
- 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;
|
|
|
+ driver.switchTo().window(handleMap.get("detail"));
|
|
|
+ wait1.until(ExpectedConditions.presenceOfElementLocated(By.className("item-content")));
|
|
|
+ WebElement itemContent = driver.findElement(By.className("item-content"));
|
|
|
+ List<WebElement> divItems = itemContent.findElements(By.tagName("div"));
|
|
|
+ for (int t = 0; t < divItems.size(); t++) {
|
|
|
+ WebElement temEle = divItems.get(t);
|
|
|
+ String text = temEle.getText();
|
|
|
+ String value = "";
|
|
|
+ String[] strings = text.split(":");
|
|
|
+ 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;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- //获得摘要
|
|
|
- WebElement abstrElement = driver.findElement(By.className("item-summary"));
|
|
|
- List<WebElement> spans =abstrElement.findElements(By.tagName("span"));
|
|
|
- String abstrText = spans.get(0).getText();
|
|
|
- patentCell.setAbstrText(abstrText);
|
|
|
- //获得主权要
|
|
|
- String mainRight =spans.get(1).getText();
|
|
|
- patentCell.setMainRignt(mainRight);
|
|
|
- //获得图片路径
|
|
|
- wait1.until(ExpectedConditions.presenceOfElementLocated(By.className("item-img")));
|
|
|
- WebElement picElement = driver.findElement(By.className("item-img"));
|
|
|
- WebElement imag =picElement.findElement(By.tagName("img"));
|
|
|
- String url = imag.getAttribute("src");
|
|
|
- url =fileUtils.uploadToLocal(url,".jpg");
|
|
|
- patentCell.setPicUrl(url);
|
|
|
- //获得权要
|
|
|
- WebElement CLElement = driver.findElement(By.id("itemCL"));
|
|
|
- CLElement.click();
|
|
|
- wait1.until(ExpectedConditions.presenceOfElementLocated(By.tagName("claim-text")));
|
|
|
- List<WebElement> rightElements = driver.findElements(By.tagName("claim-text"));
|
|
|
- List<String> rights= new ArrayList<>();
|
|
|
- rightElements.forEach(item->{
|
|
|
- rights.add(item.getText());
|
|
|
- });
|
|
|
- patentCell.setRights(rights);
|
|
|
- //获得说明书
|
|
|
- WebElement DSElement = driver.findElement(By.id("itemDS"));
|
|
|
- DSElement.click();
|
|
|
- wait1.until(ExpectedConditions.presenceOfElementLocated(By.id("title1")));
|
|
|
- WebElement titleElement = driver.findElement(By.id("title1"));
|
|
|
- patentCell.setTitle(titleElement.getText());
|
|
|
- StringBuilder stringBuilder =new StringBuilder();
|
|
|
- int flag =1;
|
|
|
- //技术领域
|
|
|
- WebElement textElement1 = driver.findElement(By.id("technical-field001"));
|
|
|
- List<WebElement> textP1 =textElement1.findElements(By.tagName("p"));
|
|
|
- stringBuilder.append(textP1.get(0).getText());
|
|
|
- stringBuilder.append("\r\n");
|
|
|
- for(int t=1;t<textP1.size();t++){
|
|
|
- String tem= String.format("%04d", flag);
|
|
|
- stringBuilder.append("["+tem+"]"+textP1.get(t).getText());
|
|
|
+ //获得摘要
|
|
|
+ WebElement abstrElement = driver.findElement(By.className("item-summary"));
|
|
|
+ List<WebElement> spans = abstrElement.findElements(By.tagName("span"));
|
|
|
+ String abstrText = spans.get(0).getText();
|
|
|
+ patentCell.setAbstrText(abstrText);
|
|
|
+ //获得主权要
|
|
|
+ String mainRight = spans.get(1).getText();
|
|
|
+ patentCell.setMainRignt(mainRight);
|
|
|
+ //获得图片路径
|
|
|
+ wait1.until(ExpectedConditions.presenceOfElementLocated(By.className("item-img")));
|
|
|
+ WebElement picElement = driver.findElement(By.className("item-img"));
|
|
|
+ WebElement imag = picElement.findElement(By.tagName("img"));
|
|
|
+ String url = imag.getAttribute("src");
|
|
|
+ url = fileUtils.uploadToLocal(url, ".jpg");
|
|
|
+ patentCell.setPicUrl(url);
|
|
|
+ //获得权要
|
|
|
+ WebElement CLElement = driver.findElement(By.id("itemCL"));
|
|
|
+ CLElement.click();
|
|
|
+ wait1.until(ExpectedConditions.presenceOfElementLocated(By.tagName("claim-text")));
|
|
|
+ List<WebElement> rightElements = driver.findElements(By.tagName("claim-text"));
|
|
|
+ List<String> rights = new ArrayList<>();
|
|
|
+ rightElements.forEach(item -> {
|
|
|
+ rights.add(item.getText());
|
|
|
+ });
|
|
|
+ patentCell.setRights(rights);
|
|
|
+ //获得说明书
|
|
|
+ WebElement DSElement = driver.findElement(By.id("itemDS"));
|
|
|
+ DSElement.click();
|
|
|
+ wait1.until(ExpectedConditions.presenceOfElementLocated(By.id("title1")));
|
|
|
+ WebElement titleElement = driver.findElement(By.id("title1"));
|
|
|
+ patentCell.setTitle(titleElement.getText());
|
|
|
+ StringBuilder stringBuilder = new StringBuilder();
|
|
|
+ int flag = 1;
|
|
|
+ //技术领域
|
|
|
+ WebElement textElement1 = driver.findElement(By.id("technical-field001"));
|
|
|
+ List<WebElement> textP1 = textElement1.findElements(By.tagName("p"));
|
|
|
+ stringBuilder.append(textP1.get(0).getText());
|
|
|
stringBuilder.append("\r\n");
|
|
|
- flag+=1;
|
|
|
- }
|
|
|
- //背景技术
|
|
|
- WebElement textElement2 = driver.findElement(By.id("background-art001"));
|
|
|
- List<WebElement> textP2 =textElement2.findElements(By.tagName("p"));
|
|
|
- stringBuilder.append(textP2.get(0).getText());
|
|
|
- stringBuilder.append("\r\n");
|
|
|
- for(int t=1;t<textP2.size();t++){
|
|
|
- String tem= String.format("%04d", flag);
|
|
|
- stringBuilder.append("["+tem+"]"+textP2.get(t).getText());
|
|
|
+ for (int t = 1; t < textP1.size(); t++) {
|
|
|
+ String tem = String.format("%04d", flag);
|
|
|
+ stringBuilder.append("[" + tem + "]" + textP1.get(t).getText());
|
|
|
+ stringBuilder.append("\r\n");
|
|
|
+ flag += 1;
|
|
|
+ }
|
|
|
+ //背景技术
|
|
|
+ WebElement textElement2 = driver.findElement(By.id("background-art001"));
|
|
|
+ List<WebElement> textP2 = textElement2.findElements(By.tagName("p"));
|
|
|
+ stringBuilder.append(textP2.get(0).getText());
|
|
|
stringBuilder.append("\r\n");
|
|
|
- flag+=1;
|
|
|
- }
|
|
|
- //说明文本
|
|
|
- WebElement textElement3 = driver.findElement(By.id("disclosure001"));
|
|
|
- List<WebElement> textP3 =textElement3.findElements(By.tagName("p"));
|
|
|
- stringBuilder.append(textP3.get(0).getText());
|
|
|
- stringBuilder.append("\r\n");
|
|
|
- for(int t=1;t<textP3.size();t++){
|
|
|
- String tem= String.format("%04d", flag);
|
|
|
- stringBuilder.append("["+tem+"]"+textP3.get(t).getText());
|
|
|
+ for (int t = 1; t < textP2.size(); t++) {
|
|
|
+ String tem = String.format("%04d", flag);
|
|
|
+ stringBuilder.append("[" + tem + "]" + textP2.get(t).getText());
|
|
|
+ stringBuilder.append("\r\n");
|
|
|
+ flag += 1;
|
|
|
+ }
|
|
|
+ //说明文本
|
|
|
+ WebElement textElement3 = driver.findElement(By.id("disclosure001"));
|
|
|
+ List<WebElement> textP3 = textElement3.findElements(By.tagName("p"));
|
|
|
+ stringBuilder.append(textP3.get(0).getText());
|
|
|
stringBuilder.append("\r\n");
|
|
|
- flag+=1;
|
|
|
- }
|
|
|
- //发明内容
|
|
|
- WebElement textElement4 = driver.findElement(By.id("disclosure001"));
|
|
|
- List<WebElement> textP4 =textElement4.findElements(By.tagName("p"));
|
|
|
- stringBuilder.append(textP4.get(0).getText());
|
|
|
- stringBuilder.append("\r\n");
|
|
|
- for(int t=1;t<textP4.size();t++){
|
|
|
- String tem= String.format("%04d", flag);
|
|
|
- stringBuilder.append("["+tem+"]"+textP4.get(t).getText());
|
|
|
+ for (int t = 1; t < textP3.size(); t++) {
|
|
|
+ String tem = String.format("%04d", flag);
|
|
|
+ stringBuilder.append("[" + tem + "]" + textP3.get(t).getText());
|
|
|
+ stringBuilder.append("\r\n");
|
|
|
+ flag += 1;
|
|
|
+ }
|
|
|
+ //发明内容
|
|
|
+ WebElement textElement4 = driver.findElement(By.id("disclosure001"));
|
|
|
+ List<WebElement> textP4 = textElement4.findElements(By.tagName("p"));
|
|
|
+ stringBuilder.append(textP4.get(0).getText());
|
|
|
stringBuilder.append("\r\n");
|
|
|
- flag+=1;
|
|
|
- }
|
|
|
- //附图说明
|
|
|
- WebElement textElement5 = driver.findElement(By.id("description-of-drawings001"));
|
|
|
- List<WebElement> textP5 =textElement5.findElements(By.tagName("p"));
|
|
|
- stringBuilder.append(textP5.get(0).getText());
|
|
|
- stringBuilder.append("\r\n");
|
|
|
- for(int t=1;t<textP5.size();t++){
|
|
|
- String tem= String.format("%04d", flag);
|
|
|
- stringBuilder.append("["+tem+"]"+textP5.get(t).getText());
|
|
|
+ for (int t = 1; t < textP4.size(); t++) {
|
|
|
+ String tem = String.format("%04d", flag);
|
|
|
+ stringBuilder.append("[" + tem + "]" + textP4.get(t).getText());
|
|
|
+ stringBuilder.append("\r\n");
|
|
|
+ flag += 1;
|
|
|
+ }
|
|
|
+ //附图说明
|
|
|
+ WebElement textElement5 = driver.findElement(By.id("description-of-drawings001"));
|
|
|
+ List<WebElement> textP5 = textElement5.findElements(By.tagName("p"));
|
|
|
+ stringBuilder.append(textP5.get(0).getText());
|
|
|
stringBuilder.append("\r\n");
|
|
|
- flag+=1;
|
|
|
- }
|
|
|
- patentCell.setPatentInstructionText(stringBuilder.toString());
|
|
|
- //获得pdf文档
|
|
|
- WebElement PDFElement = driver.findElement(By.id("itemPdf"));
|
|
|
- PDFElement.click();
|
|
|
- wait1.until(ExpectedConditions.presenceOfElementLocated(By.tagName("embed")));
|
|
|
- WebElement PDFFile =driver.findElement(By.tagName("embed"));
|
|
|
- String pdfUrl =PDFFile.getAttribute("src");
|
|
|
- pdfUrl =fileUtils.uploadToLocal(pdfUrl,".PDF");
|
|
|
- patentCell.setPDF(pdfUrl);
|
|
|
+ for (int t = 1; t < textP5.size(); t++) {
|
|
|
+ String tem = String.format("%04d", flag);
|
|
|
+ stringBuilder.append("[" + tem + "]" + textP5.get(t).getText());
|
|
|
+ stringBuilder.append("\r\n");
|
|
|
+ flag += 1;
|
|
|
+ }
|
|
|
+ patentCell.setPatentInstructionText(stringBuilder.toString());
|
|
|
+ //获得pdf文档
|
|
|
+ WebElement PDFElement = driver.findElement(By.id("itemPdf"));
|
|
|
+ PDFElement.click();
|
|
|
+ wait1.until(ExpectedConditions.presenceOfElementLocated(By.tagName("embed")));
|
|
|
+ WebElement PDFFile = driver.findElement(By.tagName("embed"));
|
|
|
+ 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;
|
|
|
// }
|
|
|
- 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.switchTo().window(handleMap.get("mainPage"));
|
|
|
- }
|
|
|
- wait1.until(ExpectedConditions.presenceOfElementLocated(By.className("tcdPageCode")));
|
|
|
+ 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.switchTo().window(handleMap.get("mainPage"));
|
|
|
+ }
|
|
|
+ wait1.until(ExpectedConditions.presenceOfElementLocated(By.className("tcdPageCode")));
|
|
|
|
|
|
- List<WebElement> nexts = driver.findElements(By.className("nextPage"));
|
|
|
- if (nexts.size()!=0){
|
|
|
- nexts.get(0).click();
|
|
|
+ List<WebElement> nexts = driver.findElements(By.className("nextPage"));
|
|
|
+ if (nexts.size() != 0) {
|
|
|
+ nexts.get(0).click();
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
// driver.quit();
|
|
|
- return patentCells;
|
|
|
-}
|
|
|
+ return patentCells;
|
|
|
+ }
|
|
|
|
|
|
public List<PatentCell> getPatentya(String patentVO) throws IOException, InterruptedException {
|
|
|
//1.获得驱动
|
|
@@ -361,6 +363,42 @@ public List<PatentCell> getPatentStar(String conditions,Integer id) throws Excep
|
|
|
return patentCells;
|
|
|
}
|
|
|
|
|
|
+ //格式化参数
|
|
|
+ public String formatConditions(String condition) throws IOException {
|
|
|
+
|
|
|
+ String jsons = FileUtils.readerMethod();
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ List<JSONObject> sources = JSONObject.parseArray(jsons, JSONObject.class);
|
|
|
+ for (JSONObject jsonObject1 : sources) {
|
|
|
+ jsonObject = jsonObject1;
|
|
|
+ }
|
|
|
+ condition= condition.replace(" ", "");
|
|
|
+ condition= condition.replace("&&", "*");
|
|
|
+ condition=condition.replace("||", "+");
|
|
|
+ StringBuilder stringBuilder = new StringBuilder("F XX ");
|
|
|
+ String pattern = "\\([^)]*\\)";
|
|
|
+ Pattern p = Pattern.compile(pattern);
|
|
|
+ Matcher m = p.matcher(condition);
|
|
|
+ while (m.find()) { // 当字符串中有匹配到 {} 时
|
|
|
+ String param = m.group(0);
|
|
|
+ String cell = formatParam(param,jsonObject);
|
|
|
+ condition= condition.replace(param,cell);
|
|
|
+
|
|
|
+ }
|
|
|
+ return condition;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String formatParam(String param, JSONObject jsonObject) {
|
|
|
+ param= param.replace("(", "");
|
|
|
+ param= param.replace(")", "");
|
|
|
+ String[] params = param.split("=");// {} 和里面的内容
|
|
|
+ StringBuilder stringBuilder = new StringBuilder("(" + params[1]);
|
|
|
+ stringBuilder.append("/");
|
|
|
+ String cell = jsonObject.get(params[0]).toString();
|
|
|
+ stringBuilder.append(cell +")");
|
|
|
+ return stringBuilder.toString();
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|