zero 11 mēneši atpakaļ
vecāks
revīzija
2ba5968f8f

+ 16 - 1
src/main/java/cn/cslg/pas/controller/NoveltyProjectController.java

@@ -81,7 +81,12 @@ public class NoveltyProjectController {
     @PostMapping("/queryNoveltyProject")
     public Response queryNoveltyProject(@RequestBody StringRequest stringRequest) throws Exception {
         Business business = businessFactory.getClass("noveltyProjectService");
-        Records records = (Records) business.queryMessage(stringRequest);
+        Records records = null;
+        try {
+            records = (Records) business.queryMessage(stringRequest);
+        } catch (Exception e) {
+            return Response.error(e.getMessage());
+        }
         return Response.success(records);
     }
 
@@ -215,6 +220,16 @@ public class NoveltyProjectController {
         return Response.success("删除成功");
     }
 
+//    @Operation(summary = "根据文案号从维德系统拉取基本信息")
+//    @PostMapping("/getReportInfoFromWD")
+//    public Response getReportInfoFromWD(@RequestBody CompareFileIdDTO vo) throws Exception {
+//        try {
+//        } catch (Exception e) {
+//            return Response.error(e.getMessage());
+//        }
+//        return Response.success("删除成功");
+//    }
+
     @Operation(summary = "查询查新检索报告模板")
     @PostMapping("/queryTemplate")
     public Response queryTemplate(@RequestBody QueryTemplateDTO queryTemplateDTO) throws IOException {

+ 66 - 0
src/main/java/cn/cslg/pas/factorys/getSqlFactorys/GetEntrustNameSql.java

@@ -0,0 +1,66 @@
+package cn.cslg.pas.factorys.getSqlFactorys;
+
+import cn.cslg.pas.common.model.cronModel.SqlObject;
+import cn.cslg.pas.common.utils.StringUtils;
+import cn.cslg.pas.common.vo.EntrustVO;
+import cn.cslg.pas.service.permissions.PermissionService;
+import com.alibaba.fastjson.JSON;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+@Slf4j
+@Component
+public class GetEntrustNameSql implements GetSqlObject {
+    private SqlObject sqlObject;
+    @Autowired
+    private PermissionService permissionService;
+
+    @Override
+    public String getSql(String value) {
+        if (value.equals("null")) {
+            return "isnull(p.entrust_id)";
+        }
+        List<String> entrustNames = new ArrayList<>();
+        Integer ifEqual = 0;
+        //根据名称查询人员id
+        List<EntrustVO> entrustVOS = null;
+        if (sqlObject.getField().equals("entrustNameTrue")) {
+            ifEqual = 0;
+
+        } else {
+            ifEqual = 1;
+        }
+        //根据名称查询
+        try {
+            String json = permissionService.getEntrustsByName(value, ifEqual);
+            entrustVOS = JSON.parseArray(json, EntrustVO.class);
+        } catch (Exception e) {
+        }
+        if (entrustVOS == null || entrustVOS.size() == 0) {
+            return " 1!=1 ";
+        }
+        entrustVOS.forEach(item -> {
+            String tmp = "(p.entrust_id=" + item.getEntrustId() + " and p.entrust_type=" + item.getEntrustType() + ")";
+            entrustNames.add(tmp);
+        });
+        String names = StringUtils.join(entrustNames, " or ");
+        String re = "(" + names + ")";
+        return re;
+    }
+
+    @Override
+    public void setSqlObject(SqlObject sqlObject) {
+        this.sqlObject = sqlObject;
+    }
+
+    ;
+
+    public SqlObject getSqlObject() {
+        return sqlObject;
+    }
+}

+ 1 - 1
src/main/java/cn/cslg/pas/service/business/es/EsPatentService.java

@@ -125,7 +125,7 @@ public class EsPatentService {
             }
         }
         dto.setPictureGuid(FormatUtil.getPictureFormat(dto.getAppNo()));
-        List<LegalEvent> legalEvents = this.getLegalEvents(dto.getPatentNo());
+        List<LegalEvent> legalEvents = this.getLegalEvents(vo.getPatentNo());
         dto.setLegalEvents(legalEvents);
         return dto;
     }

+ 143 - 0
src/main/java/cn/cslg/pas/service/novelty/NoveltyCompareLiteratureService.java

@@ -31,16 +31,25 @@ import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.openqa.selenium.chrome.ChromeOptions;
+import org.openqa.selenium.support.ui.ExpectedCondition;
+import org.openqa.selenium.support.ui.WebDriverWait;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
+import java.time.Duration;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
 /**
@@ -231,6 +240,140 @@ public class NoveltyCompareLiteratureService extends ServiceImpl<NoveltyCompareL
         compareLiteratureMapper.deleteById(vo.getCompareLitertureId());
     }
 
+    public Map<String, String> getReportInfoFromWD(String caseNo) {
+        ChromeOptions options = new ChromeOptions();
+//        options.addArguments("user-data-dir=" + strFileSavePath);
+        options.addArguments("--lang=nl");
+        options.addArguments("--disable-popup-blocking");
+        options.addArguments("--disable-images");
+        options.addArguments("--remote-allow-origins=*");
+//        if (isHeadless) {
+//            options.addArguments("headless");
+//        }
+
+        WebDriver driver = null;
+        Map<String, String> retObject = new HashMap<>();
+
+        try {
+//            System.setProperty("webdriver.chrome.driver", chromeDriverPath);
+            driver = new ChromeDriver(options);
+
+            driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
+            driver.manage().timeouts().pageLoadTimeout(100, TimeUnit.SECONDS);
+
+//            driver.get(iPEasyWeb);
+
+            //进入登录界面
+            WebElement userField = driver.findElement(By.id("txtUser"));
+            WebElement pwdField = driver.findElement(By.id("txtPwd"));
+            WebElement loginButton = driver.findElement(By.id("btnLogin"));
+            //输入用户名和密码
+            userField.clear();
+//            userField.sendKeys(account);
+            pwdField.clear();
+//            pwdField.sendKeys(password);
+            //点击登录按钮
+            loginButton.click();
+
+            //关闭提示遮罩层
+            WebElement closeOverlay = null;
+            try {
+                closeOverlay = driver.findElement(By.id("jpwClose"));
+                if (closeOverlay.isDisplayed()) {
+                    closeOverlay.click();
+                }
+            } catch (Exception e) {
+
+            }
+
+            //点击顶部菜单栏中的案件管理菜单
+            WebElement caseManagementMenu = driver.findElement(By.name("71A7CC35-F597-40E1-9FEF-BE622A3A3B63"));
+            caseManagementMenu.click();
+
+            //点击左侧 查询 菜单
+            WebElement searchMenu = driver.findElement(By.name("c3266ab3-521a-4815-8aaf-7dd0bc5a76af"));
+            searchMenu.click();
+
+            //切换到自定义报表Frame
+            driver.switchTo().frame(1);
+
+            WebElement inputSearch = driver.findElement(By.id("case_volume"));
+            inputSearch.sendKeys(caseNo.trim());
+
+            WebElement btnSearch = driver.findElement(By.id("btn_Search"));
+            btnSearch.click();
+
+            WebElement caseLink = driver.findElement(By.xpath("//a[contains(text()," + caseNo + ")]"));
+            caseLink.click();
+
+            driver.switchTo().parentFrame().switchTo().frame(2);
+
+            WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(20));
+            //等待页面上ID属性值为submitButton的元素加载完成
+            WebElement myElement = wait.until((ExpectedCondition<WebElement>) wd -> {
+                try {
+                    if (wd != null) {
+                        wd.switchTo().parentFrame().switchTo().frame(2);
+                        return wd.findElement(By.id("libase"));
+                    }
+                } catch (Exception e) {
+                    return null;
+                }
+                return null;
+            });
+
+            myElement.click();
+
+            // 案件号
+            retObject.put("CaseNo", caseNo.trim());
+            //案件名称
+            retObject.put("CaseName", driver.findElement(By.id("p_case_info__case_name")).getAttribute("value"));
+            //客户名称
+            retObject.put("CustomerName", driver.findElement(By.id("p_case_info__customer_id")).getAttribute("value"));
+            //业务类型
+            retObject.put("BusinessType", driver.findElement(By.id("p_case_info__business_type_id")).getAttribute("value"));
+            retObject.put("CaseState", getSelectText(driver.findElement(By.id("p_case_info__case_status_id"))));
+            retObject.put("ApplicationType", getSelectText(driver.findElement(By.id("p_case_info__apply_type_id"))));
+
+            //案件类型
+            retObject.put("CaseType", driver.findElement(By.id("p_case_info__case_type_id")).getAttribute("value"));
+            //委案日期
+            retObject.put("EntrustingDate", driver.findElement(By.id("p_case_info__charge_date")).getAttribute("value"));
+            //案件备注
+            retObject.put("CaseMemo", driver.findElement(By.id("p_case_info__remark")).getAttribute("value"));
+
+            WebElement expandInfoButton = driver.findElement(By.xpath("//span[contains(text(),'扩展信息')]"));
+            expandInfoButton.click();
+            retObject.put("CaseCoefficient", getSelectText(driver.findElement(By.id("p_case_info__case_coefficient_id"))));
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new RuntimeException("An error occurred while retrieving case info", e);
+        } finally {
+            if (driver != null) {
+                driver.quit();
+            }
+        }
+
+        return retObject;
+    }
+
+    public static String getSelectText(WebElement element) {
+        String strValue = element.getAttribute("value");
+
+        if (strValue == null || strValue.isEmpty()) {
+            return null;
+        }
+
+        List<WebElement> ops = element.findElements(By.tagName("option"));
+        for (WebElement op : ops) {
+            if (op.getAttribute("value").equals(strValue)) {
+                return op.getText();
+            }
+        }
+        return null;
+    }
+
     public List<Integer> copyCompareFile(List<Integer> ids, Integer toProjectId, Integer fromProjectId) throws Exception {
 
         if (ids == null || ids.size() == 0) {

+ 2 - 2
src/main/resources/jsons/noveltyProject.json

@@ -343,7 +343,7 @@
     "value": "entrustName",
     "field": "entrustName",
     "sqlField": "p.entrust_id",
-    "sqlClass": "getEntrustTrueNameSql",
+    "sqlClass": "getEntrustNameSql",
     "orderClass": "getEntrustOrder",
     "groupClass": "getEntrustGroup",
     "ifSearch": "true",
@@ -358,7 +358,7 @@
     "value": "entrustNameTrue",
     "field": "entrustNameTrue",
     "sqlField": "p.entrust_id",
-    "sqlClass": "getEntrustTrueNameSql",
+    "sqlClass": "getEntrustNameSql",
     "orderClass": "getEntrustOrder",
     "groupClass": "getEntrustGroup",
     "ifSearch": "false",

+ 14 - 22
src/test/java/cn/cslg/pas/novelty/GetReportInfoFromWDTest.java

@@ -1,5 +1,6 @@
 package cn.cslg.pas.novelty;
 
+import cn.cslg.pas.exception.XiaoShiException;
 import org.junit.jupiter.api.Test;
 import org.openqa.selenium.By;
 import org.openqa.selenium.WebDriver;
@@ -14,10 +15,7 @@ import org.springframework.boot.test.context.SpringBootTest;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.time.Duration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
+import java.util.*;
 import java.util.concurrent.TimeUnit;
 
 @SpringBootTest
@@ -31,26 +29,12 @@ public class GetReportInfoFromWDTest {
 
     @Test
     public void test() {
-        Map<String, String> map = dynamicCaseInfo("5");
+        Map<String, String> map = dynamicCaseInfo("-");
+//        Map<String, String> map = dynamicCaseInfo("P");
         System.out.println(map);
     }
 
     public Map<String, String> dynamicCaseInfo(String caseNo) {
-//        Properties properties = new Properties();
-//        try {
-//            properties.load(new FileInputStream("path/to/your/config.properties"));
-//        } catch (IOException e) {
-//            e.printStackTrace();
-//            throw new RuntimeException("Failed to load configuration properties");
-//        }
-//
-//        String strFileSavePath = properties.getProperty("IPEasySetting.DownloadFileSavePath");
-//        boolean isHeadless = Boolean.parseBoolean(properties.getProperty("IPEasySetting.isHeadless"));
-//        String account = properties.getProperty("IPEasySetting.Account");
-//        String password = properties.getProperty("IPEasySetting.Password");
-//        String chromeDriverPath = properties.getProperty("IPEasySetting.ChromeDriverPath");
-//        String iPEasyWeb = properties.getProperty("IPEasySetting.IPEasyWeb");
-
         ChromeOptions options = new ChromeOptions();
         options.addArguments("user-data-dir=" + strFileSavePath);
         options.addArguments("--lang=nl");
@@ -113,11 +97,20 @@ public class GetReportInfoFromWDTest {
             WebElement btnSearch = driver.findElement(By.id("btn_Search"));
             btnSearch.click();
 
-            WebElement caseLink = driver.findElement(By.xpath("//a[contains(text()," + caseNo + ")]"));
+            WebElement caseLink = null;
+            try {
+                caseLink = driver.findElement(By.xpath("//a[contains(text()," + caseNo + ")]"));
+            } catch (Exception e) {
+                throw new XiaoShiException("未查询到案件基本信息");
+            }
             caseLink.click();
 
             driver.switchTo().parentFrame().switchTo().frame(2);
 
+//            IPCE8AE7FA-6F04-4860-B515-0F350F1A4CFB
+//            WebElement libase = driver.findElement(By.id("libase"));
+//            libase.click();
+
             WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(20));
             //等待页面上ID属性值为submitButton的元素加载完成
             WebElement myElement = wait.until((ExpectedCondition<WebElement>) wd -> {
@@ -183,7 +176,6 @@ public class GetReportInfoFromWDTest {
                 return op.getText();
             }
         }
-
         return null;
     }
 //