ソースを参照

项目初始化

lwhhszx 2 年 前
コミット
d0df2f010f

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

@@ -38,8 +38,8 @@ public class AssoTaskPersonelController {
     private final FileUtils fileUtils;
     private final UploadFromWebService uploadFromWebService;
     @GetMapping("/getStar")
-    public List<PatentCell> getPatentStar(String patentVO) throws Exception {
-        return uploadFromWebService.getPatentStar(patentVO);
+    public List<PatentCell> getPatentStar(String conditions,Integer id) throws Exception {
+        return uploadFromWebService.getPatentStar(conditions,id);
     }
 
 

+ 161 - 0
src/main/java/com/example/demo/domain/WebConfig.java

@@ -0,0 +1,161 @@
+package com.example.demo.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import java.io.Serializable;
+
+/**
+ * 网站配置
+ * @TableName web_config
+ */
+@TableName(value ="web_config")
+public class WebConfig implements Serializable {
+    /**
+     * ID
+     */
+    @TableId(type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 网站名称
+     */
+    private String webName;
+
+    /**
+     * 网站地址
+     */
+    private String webAddress;
+
+    /**
+     * 账号
+     */
+    private String webAccount;
+
+    /**
+     * 网站密码
+     */
+    private String webPassword;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * ID
+     */
+    public Integer getId() {
+        return id;
+    }
+
+    /**
+     * ID
+     */
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    /**
+     * 网站名称
+     */
+    public String getWebName() {
+        return webName;
+    }
+
+    /**
+     * 网站名称
+     */
+    public void setWebName(String webName) {
+        this.webName = webName;
+    }
+
+    /**
+     * 网站地址
+     */
+    public String getWebAddress() {
+        return webAddress;
+    }
+
+    /**
+     * 网站地址
+     */
+    public void setWebAddress(String webAddress) {
+        this.webAddress = webAddress;
+    }
+
+    /**
+     * 账号
+     */
+    public String getWebAccount() {
+        return webAccount;
+    }
+
+    /**
+     * 账号
+     */
+    public void setWebAccount(String webAccount) {
+        this.webAccount = webAccount;
+    }
+
+    /**
+     * 网站密码
+     */
+    public String getWebPassword() {
+        return webPassword;
+    }
+
+    /**
+     * 网站密码
+     */
+    public void setWebPassword(String webPassword) {
+        this.webPassword = webPassword;
+    }
+
+    @Override
+    public boolean equals(Object that) {
+        if (this == that) {
+            return true;
+        }
+        if (that == null) {
+            return false;
+        }
+        if (getClass() != that.getClass()) {
+            return false;
+        }
+        WebConfig other = (WebConfig) that;
+        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
+            && (this.getWebName() == null ? other.getWebName() == null : this.getWebName().equals(other.getWebName()))
+            && (this.getWebAddress() == null ? other.getWebAddress() == null : this.getWebAddress().equals(other.getWebAddress()))
+            && (this.getWebAccount() == null ? other.getWebAccount() == null : this.getWebAccount().equals(other.getWebAccount()))
+            && (this.getWebPassword() == null ? other.getWebPassword() == null : this.getWebPassword().equals(other.getWebPassword()));
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
+        result = prime * result + ((getWebName() == null) ? 0 : getWebName().hashCode());
+        result = prime * result + ((getWebAddress() == null) ? 0 : getWebAddress().hashCode());
+        result = prime * result + ((getWebAccount() == null) ? 0 : getWebAccount().hashCode());
+        result = prime * result + ((getWebPassword() == null) ? 0 : getWebPassword().hashCode());
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getSimpleName());
+        sb.append(" [");
+        sb.append("Hash = ").append(hashCode());
+        sb.append(", id=").append(id);
+        sb.append(", webName=").append(webName);
+        sb.append(", webAddress=").append(webAddress);
+        sb.append(", webAccount=").append(webAccount);
+        sb.append(", webPassword=").append(webPassword);
+        sb.append(", serialVersionUID=").append(serialVersionUID);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 21 - 0
src/main/java/com/example/demo/mapper/WebConfigMapper.java

@@ -0,0 +1,21 @@
+package com.example.demo.mapper;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.example.demo.domain.WebConfig;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+* @author admin
+* @description 针对表【web_config(网站配置)】的数据库操作Mapper
+* @createDate 2023-03-08 18:51:17
+* @Entity cn.cslg.pas.domain.WebConfig
+*/
+@Mapper
+public interface WebConfigMapper extends BaseMapper<WebConfig> {
+
+}
+
+
+
+

+ 8 - 4
src/main/java/com/example/demo/service/UploadFromWebService.java

@@ -5,6 +5,7 @@ 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.mapper.QrtzTaskMapper;
 import com.example.demo.model.dto.QuartzTaskDTO;
 import com.example.demo.util.FileUtils;
@@ -38,8 +39,11 @@ import java.util.concurrent.TimeUnit;
 public class UploadFromWebService{
     private final FileUtils fileUtils;
     private final OutInterfaceService outInterfaceService;
+    private final WebConfigService webConfigService;
 // 查询并上传(智慧芽)
-public List<PatentCell> getPatentStar(String patentVO) throws Exception {
+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");
@@ -54,12 +58,12 @@ public List<PatentCell> getPatentStar(String patentVO) throws Exception {
     long formSecond1 = 50;
     WebDriverWait wait1 = new WebDriverWait(driver, formSecond1);
     // 打开智慧芽首页
-    driver.get("https://cprs.patentstar.com.cn/Account/LoginOut");
+    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("lrj20000506");
-    password.sendKeys("20000506sz");
+    loginName.sendKeys(webConfig.getWebAccount());
+    password.sendKeys(webConfig.getWebPassword());
     WebElement loginButton = driver.findElement(By.id("login"));
     loginButton.click();
     //获得表格搜索按钮并点击

+ 28 - 0
src/main/java/com/example/demo/service/WebConfigService.java

@@ -0,0 +1,28 @@
+package com.example.demo.service;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+import com.example.demo.domain.WebConfig;
+import com.example.demo.mapper.WebConfigMapper;
+import lombok.RequiredArgsConstructor;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Service;
+
+/**
+* @author admin
+* @description 针对表【web_config(网站配置)】的数据库操作Service实现
+* @createDate 2023-03-08 18:51:17
+*/
+@Service
+@RequiredArgsConstructor(onConstructor_ = {@Lazy})
+public class WebConfigService extends ServiceImpl<WebConfigMapper, WebConfig>
+  {
+     public WebConfig getConfigById(Integer id){
+       WebConfig webConfig = this.getById(id);
+       if(webConfig !=null){
+         return webConfig;
+       }
+       return new WebConfig();
+  }
+
+}