소스 검색

字段格式化

lwhhszx 2 년 전
부모
커밋
4cdd4c2d42

+ 6 - 0
src/main/java/com/example/demo/controller/AssoTaskPersonelController.java

@@ -20,6 +20,7 @@ import org.openqa.selenium.chrome.ChromeOptions;
 import org.openqa.selenium.interactions.Actions;
 import org.openqa.selenium.support.ui.ExpectedConditions;
 import org.openqa.selenium.support.ui.WebDriverWait;
+import org.quartz.SchedulerException;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
@@ -42,6 +43,11 @@ public class AssoTaskPersonelController {
         return uploadFromWebService.getPatentStar(conditions,id);
     }
 
+    @GetMapping("/format")
+    public String format(String  condition) throws InterruptedException, SchedulerException, IOException {
+       return uploadFromWebService.formatConditions(condition);
+
+    }
 
     @GetMapping("/getPartClient")
     @Operation(summary = "分页获取对比专利")

+ 17 - 8
src/main/java/com/example/demo/controller/QuartzController.java

@@ -6,10 +6,7 @@ import com.example.demo.service.JobService;
 import lombok.RequiredArgsConstructor;
 import org.quartz.SchedulerException;
 import org.springframework.context.annotation.Lazy;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 
 @RestController
@@ -17,7 +14,7 @@ import org.springframework.web.bind.annotation.RestController;
 @RequiredArgsConstructor(onConstructor_ = {@Lazy})
 public class QuartzController {
     private final JobService jobService;
-@GetMapping("/add")
+@PostMapping("/add")
     public void addJob(@RequestBody QuartzTaskDTO quartzTaskDTO) throws InterruptedException, SchedulerException {
 
     jobService.addJob(quartzTaskDTO);
@@ -29,9 +26,21 @@ public class QuartzController {
         jobService.deleteJob(taskId);
 
     }
-    @GetMapping("/update")
-    public void update(Integer taskId,String cron) throws InterruptedException, SchedulerException {
-        jobService.updateJob(taskId,cron);
+    @PostMapping("/update")
+    public void update(@RequestBody QuartzTaskDTO quartzTaskDTO) throws InterruptedException, SchedulerException {
+        jobService.updateJob(quartzTaskDTO);
+
+    }
+
+    @GetMapping("/pauseJob")
+    public void pauseJob(Integer taskId) throws InterruptedException, SchedulerException {
+        jobService.pauseJob(taskId);
+
+    }
+
+    @GetMapping("/resumeJob")
+    public void resumeJob(Integer taskId) throws InterruptedException, SchedulerException {
+        jobService.resumeJob(taskId);
 
     }
 

+ 25 - 0
src/main/java/com/example/demo/domain/Sources.java

@@ -0,0 +1,25 @@
+package com.example.demo.domain;
+
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 管理员表
+ * </p>
+ *
+ * @author 王岩
+ * @since 2022-03-25
+ */
+@Data
+/*数据库中的表对应的类
+ */
+public class Sources {
+     private Integer sourceId;
+     private String webSiteName;
+     private String patentNo;
+     private String title;
+     private String publicDate;
+}

+ 1 - 0
src/main/java/com/example/demo/model/dto/QuartzTaskDTO.java

@@ -9,4 +9,5 @@ public class QuartzTaskDTO {
     private String cron;
     private String conditions;
     private Integer webConfigId;
+    private Integer taskId;
 }

+ 18 - 10
src/main/java/com/example/demo/service/JobService.java

@@ -10,6 +10,8 @@ import org.quartz.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.RequestBody;
 
 @Service
 @Slf4j
@@ -39,9 +41,10 @@ public class JobService {
      */
     public void pauseJob(Integer taskId) throws SchedulerException {
         QuartzVO quartzVO=this.generateQuartzVO(taskId);
-        TriggerKey triggerKey = TriggerKey.triggerKey(quartzVO.getTriggerName(), quartzVO.getTriggerGroupName());
-        scheduler.pauseTrigger(triggerKey);
-        scheduler.unscheduleJob(triggerKey);
+        qrTaskService.updateState(taskId,0);
+//        TriggerKey triggerKey = TriggerKey.triggerKey(quartzVO.getTriggerName(), quartzVO.getTriggerGroupName());
+//        scheduler.pauseTrigger(triggerKey);
+//        scheduler.unscheduleJob(triggerKey);
         JobKey jobKey = JobKey.jobKey(quartzVO.getJobName(),quartzVO.getJobGroupName());
         scheduler.pauseJob(jobKey);
     }
@@ -53,9 +56,10 @@ public class JobService {
      */
     public void resumeJob(Integer taskId) throws SchedulerException {
         QuartzVO quartzVO=this.generateQuartzVO(taskId);
-        TriggerKey triggerKey = TriggerKey.triggerKey(quartzVO.getTriggerName(), quartzVO.getTriggerGroupName());
-        scheduler.pauseTrigger(triggerKey);
-        scheduler.unscheduleJob(triggerKey);
+         qrTaskService.updateState(taskId,1);
+//        TriggerKey triggerKey = TriggerKey.triggerKey(quartzVO.getTriggerName(), quartzVO.getTriggerGroupName());
+//        scheduler.pauseTrigger(triggerKey);
+//        scheduler.unscheduleJob(triggerKey);
         JobKey jobKey = JobKey.jobKey(quartzVO.getJobName(), quartzVO.getJobGroupName());
         scheduler.resumeJob(jobKey);
     }
@@ -63,13 +67,16 @@ public class JobService {
     /**
      * 修改定时任务
      *
-     * @param cron          新的cron表达式
+     * @param
      */
-    public void updateJob(Integer taskId, String cron) {
-        QuartzVO quartzVO=this.generateQuartzVO(taskId);
+    public void updateJob( QuartzTaskDTO quartzTaskDTO) {
+        //更新任务
+     QrtzTask qrtzTask=   qrTaskService.updateQuartzTask(quartzTaskDTO);
+        QuartzVO quartzVO=this.generateQuartzVO(quartzTaskDTO.getTaskId());
         JobDataMap jobDataMap =new JobDataMap();
+        jobDataMap.put("qrtzTask",qrtzTask);
         TriggerKey oldTriggerKey = TriggerKey.triggerKey(quartzVO.getTriggerName(), quartzVO.getTriggerGroupName());
-        CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(cron);
+        CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(quartzTaskDTO.getCron());
         CronTrigger cronTrigger = TriggerBuilder.newTrigger()
                 .withIdentity(oldTriggerKey).usingJobData(jobDataMap).withSchedule(scheduleBuilder).build();
         try {
@@ -84,6 +91,7 @@ public class JobService {
      *
      * @throws SchedulerException
      */
+    @Transactional
     public void addJob(QuartzTaskDTO quartzTaskDTO) throws SchedulerException {
         //添加一条任务记录
         QrtzTask qrtzTask= qrTaskService.addQuartzTask(quartzTaskDTO);

+ 15 - 1
src/main/java/com/example/demo/service/QrTaskService.java

@@ -24,13 +24,27 @@ public class QrTaskService extends ServiceImpl<QrtzTaskMapper, QrtzTask> {
         QrtzTask qrtzTask = new QrtzTask();
         qrtzTask.setConditions(quartzTaskDTO.getConditions());
         qrtzTask.setProjectId(quartzTaskDTO.getProjectId());
-        qrtzTask.setTaskState(0);
+        qrtzTask.setTaskState(1);
         qrtzTask.setCrons(quartzTaskDTO.getCron());
         qrtzTask.insert();
         return qrtzTask;
     }
 
+    public QrtzTask updateQuartzTask(QuartzTaskDTO quartzTaskDTO) {
+        QrtzTask qrtzTask =this.getById(quartzTaskDTO.getTaskId());
+        qrtzTask.setConditions(quartzTaskDTO.getConditions());
+        qrtzTask.setCrons(quartzTaskDTO.getCron());
+        qrtzTask.updateById();
+        return qrtzTask;
+    }
 
+
+    public QrtzTask updateState(Integer taskId,Integer state) {
+        QrtzTask qrtzTask =this.getById(taskId);
+        qrtzTask.setTaskState(state);
+        qrtzTask.updateById();
+        return qrtzTask;
+    }
 }
 
 

+ 266 - 228
src/main/java/com/example/demo/service/UploadFromWebService.java

@@ -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();
+    }
+
 }
 
 

+ 3 - 2
src/main/java/com/example/demo/service/WebUploadJob.java

@@ -1,5 +1,6 @@
 package com.example.demo.service;
 
+import com.example.demo.domain.QrtzTask;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.quartz.JobDataMap;
@@ -17,7 +18,7 @@ public class WebUploadJob extends QuartzJobBean {
     @Override
     protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
         JobDataMap jobDataMap =   context.getTrigger().getJobDataMap();
-
-        logger.info("信息是");
+        QrtzTask qrtzTask = (QrtzTask) jobDataMap.get("qrtzTask");
+        logger.info("信息是"+qrtzTask);
     }
 }

+ 20 - 0
src/main/java/com/example/demo/util/FileUtils.java

@@ -2,6 +2,7 @@ package com.example.demo.util;
 
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.util.IdUtil;
+import com.alibaba.fastjson.JSON;
 import com.example.demo.domain.UploadFileDTO;
 import org.apache.commons.fileupload.FileItem;
 import org.apache.commons.fileupload.disk.DiskFileItemFactory;
@@ -259,5 +260,24 @@ public class FileUtils {
      return  path;
 
     }
+
+    public static String readerMethod() throws IOException {
+       String ah= FileUtils.getStaticPath("setting.json");
+        File file = new File(ah);
+        FileReader fileReader = new FileReader(file);
+        Reader reader = new InputStreamReader(new FileInputStream(file), "Utf-8");
+        int ch = 0;
+        StringBuffer sb = new StringBuffer();
+        while ((ch = reader.read()) != -1) {
+            sb.append((char) ch);
+        }
+        fileReader.close();
+        reader.close();
+        String jsonStr = sb.toString();
+       return jsonStr;
+    }
+
+
+
 }
 

+ 1 - 1
src/main/resources/application.yml

@@ -28,7 +28,7 @@ spring:
             tablePrefix: QRTZ_
             isClustered: false
             clusterCheckinInterval: 10000
-            useProperties: true
+            useProperties: false
           threadPool:
             class: org.quartz.simpl.SimpleThreadPool
             threadCount: 10