AssoTaskPersonelController.java 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. package com.example.demo.controller;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.example.demo.base.Constants;
  4. import com.example.demo.domain.PatentCell;
  5. import com.example.demo.domain.UploadFileDTO;
  6. import com.example.demo.service.OutInterfaceService;
  7. import com.example.demo.service.UploadFromWebService;
  8. import com.example.demo.util.FileUtils;
  9. import com.example.demo.util.Response;
  10. import io.swagger.v3.oas.annotations.Operation;
  11. import io.swagger.v3.oas.annotations.tags.Tag;
  12. import lombok.RequiredArgsConstructor;
  13. import org.openqa.selenium.By;
  14. import org.openqa.selenium.JavascriptExecutor;
  15. import org.openqa.selenium.WebDriver;
  16. import org.openqa.selenium.WebElement;
  17. import org.openqa.selenium.chrome.ChromeDriver;
  18. import org.openqa.selenium.chrome.ChromeOptions;
  19. import org.openqa.selenium.interactions.Actions;
  20. import org.openqa.selenium.support.ui.ExpectedConditions;
  21. import org.openqa.selenium.support.ui.WebDriverWait;
  22. import org.quartz.SchedulerException;
  23. import org.springframework.context.annotation.Lazy;
  24. import org.springframework.web.bind.annotation.*;
  25. import org.springframework.web.multipart.MultipartFile;
  26. import java.io.IOException;
  27. import java.util.ArrayList;
  28. import java.util.HashMap;
  29. import java.util.List;
  30. import java.util.Set;
  31. import java.util.concurrent.TimeUnit;
  32. @Tag(name = "任务人员操作")
  33. @RestController
  34. @RequestMapping(Constants.QUARTZ_API + "/AssoTaskPersonel")
  35. @RequiredArgsConstructor(onConstructor_ = {@Lazy})
  36. public class AssoTaskPersonelController {
  37. private final FileUtils fileUtils;
  38. private final UploadFromWebService uploadFromWebService;
  39. @GetMapping("/getStar")
  40. public List<PatentCell> getPatentStar(String conditions,Integer id) throws Exception {
  41. return uploadFromWebService.getPatentStar(conditions,id);
  42. }
  43. @GetMapping("/format")
  44. public String format(String condition) throws InterruptedException, SchedulerException, IOException {
  45. return uploadFromWebService.formatConditions(condition);
  46. }
  47. @GetMapping("/getPartClient")
  48. @Operation(summary = "分页获取对比专利")
  49. public List<PatentCell> getPatentya(String patentVO) throws IOException, InterruptedException {
  50. return uploadFromWebService.getPatentya(patentVO);
  51. }
  52. @GetMapping("/test")
  53. @Operation(summary = "分页获取对比专利")
  54. public void test(String patentVO) throws IOException, InterruptedException {
  55. System.setProperty("webdriver.chrome.driver", "D:\\driver\\chromedriver.exe");
  56. // 1.创建webdriver驱动
  57. WebDriver driver = new ChromeDriver();
  58. //4、创建一个map集合存放浏览器句柄
  59. HashMap<String, String> handleMap = new HashMap<>();
  60. //5、访问百度
  61. driver.get("https://www.baidu.com/");
  62. //6、获取到打开百度窗口的句柄
  63. String baiDuHandle = driver.getWindowHandle();
  64. //7、将百度句柄放到map中
  65. handleMap.put("baidu", baiDuHandle);
  66. //8、新开一个窗口,用js来完成
  67. String js = "window.open('https://www.sogou.com');";
  68. ((JavascriptExecutor) driver).executeScript(js);
  69. //9、获取到所有的句柄
  70. Set<String> set = driver.getWindowHandles();
  71. //10、循环找到搜狗窗口句柄
  72. for (String s : set) {
  73. //10.1、将搜狗的句柄放到map中
  74. if (!s.equals("baiDuHandle"))
  75. handleMap.put("souGou", s);
  76. }
  77. //11、切换到搜狗的窗口
  78. driver.switchTo().window(handleMap.get("souGou"));
  79. driver.switchTo().window(handleMap.get("baidu"));
  80. driver.close();
  81. }
  82. }