|
@@ -9,6 +9,7 @@ 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;
|
|
|
|
+import org.openqa.selenium.Alert;
|
|
import org.openqa.selenium.By;
|
|
import org.openqa.selenium.By;
|
|
import org.openqa.selenium.WebDriver;
|
|
import org.openqa.selenium.WebDriver;
|
|
import org.openqa.selenium.WebElement;
|
|
import org.openqa.selenium.WebElement;
|
|
@@ -45,7 +46,7 @@ public class UploadFromWebService {
|
|
public List<PatentCell> getPatentStar(WebQueryDTO webQueryDTO) throws Exception {
|
|
public List<PatentCell> getPatentStar(WebQueryDTO webQueryDTO) throws Exception {
|
|
String conditions = webQueryDTO.getConditions();
|
|
String conditions = webQueryDTO.getConditions();
|
|
Integer id = webQueryDTO.getWebConfigId();
|
|
Integer id = webQueryDTO.getWebConfigId();
|
|
- conditions = this.formatConditions(conditions);
|
|
|
|
|
|
+ //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<>();
|
|
@@ -287,24 +288,23 @@ public class UploadFromWebService {
|
|
wait1.until(ExpectedConditions.presenceOfElementLocated(By.id("legalContainer")));
|
|
wait1.until(ExpectedConditions.presenceOfElementLocated(By.id("legalContainer")));
|
|
WebElement tBody = driver.findElement(By.id("legalContainer"));
|
|
WebElement tBody = driver.findElement(By.id("legalContainer"));
|
|
TimeUnit.MILLISECONDS.sleep(1000);//毫秒
|
|
TimeUnit.MILLISECONDS.sleep(1000);//毫秒
|
|
- List<WebElement> trs =tBody.findElements(By.tagName("tr"));
|
|
|
|
|
|
+ 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);
|
|
|
|
|
|
+ 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);
|
|
patentCell.setPatentAffairs(affairs);
|
|
|
|
|
|
- if(patentCell.getPublicNo()!=null){
|
|
|
|
|
|
+ if (patentCell.getPublicNo() != null) {
|
|
patentCell.setPatentNo(patentCell.getPublicNo());
|
|
patentCell.setPatentNo(patentCell.getPublicNo());
|
|
patentCell.setPublicNo(patentCell.getPublicAccreditNo());
|
|
patentCell.setPublicNo(patentCell.getPublicAccreditNo());
|
|
- }
|
|
|
|
- else{
|
|
|
|
|
|
+ } else {
|
|
patentCell.setPatentNo(patentCell.getPublicAccreditNo());
|
|
patentCell.setPatentNo(patentCell.getPublicAccreditNo());
|
|
}
|
|
}
|
|
if (patentCell.getPatentNo() != null) {
|
|
if (patentCell.getPatentNo() != null) {
|
|
@@ -329,6 +329,65 @@ public class UploadFromWebService {
|
|
return patentCells;
|
|
return patentCells;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 查询并上传(合享)
|
|
|
|
+ public List<PatentCell> getHeXiang(WebQueryDTO webQueryDTO) throws InterruptedException {
|
|
|
|
+ //从DTO中获得代表合享网站的id和检索条件conditions
|
|
|
|
+ Integer id = webQueryDTO.getWebConfigId();
|
|
|
|
+ String conditions = webQueryDTO.getConditions();
|
|
|
|
+
|
|
|
|
+ //通过id从数据库中获得网站地址、账号、密码
|
|
|
|
+ WebConfig webConfig = webConfigService.getConfigById(id);
|
|
|
|
+ String webAddress = webConfig.getWebAddress();
|
|
|
|
+ String webAccount = webConfig.getWebAccount();
|
|
|
|
+ String webPassword = webConfig.getWebPassword();
|
|
|
|
+
|
|
|
|
+ //1.获得驱动
|
|
|
|
+ System.setProperty("webdriver.chrome.driver", "D:\\driver\\chromedriver.exe");
|
|
|
|
+ //2.创建驱动
|
|
|
|
+ ChromeDriver driver = new ChromeDriver();
|
|
|
|
+ //3.创建动作
|
|
|
|
+ Actions action = new Actions(driver);
|
|
|
|
+ //4.页面窗口最大化
|
|
|
|
+ driver.manage().window().maximize();
|
|
|
|
+ //5.设置等待时间
|
|
|
|
+ WebDriverWait wait = new WebDriverWait(driver, 50);
|
|
|
|
+
|
|
|
|
+ //打开合享首页
|
|
|
|
+ driver.get(webAddress);
|
|
|
|
+ //等待直到出现id为"u"的元素,找到id为"u"和"p"的元素,并输入值(即输入账号密码)
|
|
|
|
+ wait.until(ExpectedConditions.presenceOfElementLocated(By.id("u")));
|
|
|
|
+ driver.findElement(By.id("u")).sendKeys(webAccount);
|
|
|
|
+ driver.findElement(By.id("p")).sendKeys(webPassword);
|
|
|
|
+ //找到id为"clauseCheckBox"的元素,并(判断若当前元素没有被点击选择)点击(即点击同意服务条款)
|
|
|
|
+ WebElement accept = driver.findElement(By.id("clauseCheckBox"));
|
|
|
|
+ if (!accept.isSelected()) {
|
|
|
|
+ accept.click();
|
|
|
|
+ }
|
|
|
|
+ //找到id为"loginBtn"的元素,并点击(即点击登录按钮)
|
|
|
|
+ driver.findElement(By.id("loginBtn")).click();
|
|
|
|
+ //线程睡眠1秒等待alert弹窗提示 "账号已被他人登录,是否继续登录?",若此时有该弹窗则点击确定按钮(即确认要挤号)
|
|
|
|
+ Thread.sleep(1000);
|
|
|
|
+ Alert alert = driver.switchTo().alert();
|
|
|
|
+ if (alert != null) {
|
|
|
|
+ alert.accept();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //等待直到出现a标签为"检 索"的元素,找到该元素并将鼠标悬停其上(自动展开二级子菜单),找到a标签为"高级检索"的元素并点击
|
|
|
|
+ wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("#container > div:nth-child(1) > div.top > div.top_con > div.menu > ul > li:nth-child(2) > a")));
|
|
|
|
+ action.moveToElement(driver.findElement(By.linkText("检 索"))).perform();
|
|
|
|
+ driver.findElement(By.linkText("高级检索")).click();
|
|
|
|
+
|
|
|
|
+ //等待直到出现id为"textarea"的元素,找到该元素并输入内容conditions,找到检索按钮的css路径并点击(即检索框中输入内容检索)
|
|
|
|
+ wait.until(ExpectedConditions.presenceOfElementLocated(By.id("textarea")));
|
|
|
|
+ driver.findElement(By.id("textarea")).sendKeys(conditions);
|
|
|
|
+ driver.findElement(By.cssSelector("#instructSearchDiv > div.button.citation_btn > input.retrieval")).click();
|
|
|
|
+
|
|
|
|
+ //
|
|
|
|
+
|
|
|
|
+ return null;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
public List<PatentCell> getPatentya(String patentVO) throws IOException, InterruptedException {
|
|
public List<PatentCell> getPatentya(String patentVO) throws IOException, InterruptedException {
|
|
//1.获得驱动
|
|
//1.获得驱动
|
|
System.setProperty("webdriver.chrome.driver", "D:\\driver\\chromedriver.exe");
|
|
System.setProperty("webdriver.chrome.driver", "D:\\driver\\chromedriver.exe");
|