Browse Source

7/30 外部检索逻辑更改

lwhhszx 1 year ago
parent
commit
743720ab8c

+ 0 - 25
src/main/java/cn/cslg/pas/common/utils/esDataForm/AddressSplitter.java

@@ -14,7 +14,6 @@ import java.util.regex.Pattern;
 public class AddressSplitter {
 
     public static PersonAddress splitAddress(String address, String provinceStr) {
-//        List<String> addresses = new ArrayList<>();
         PersonAddress personAddress =null;
         // 初始化省、市、区
         String province = "";
@@ -38,30 +37,6 @@ public class AddressSplitter {
             }
         }
 
-//        // 匹配省份
-//        String[] provinceArray = StringUtils.splitByWholeSeparatorPreserveAllTokens(address, "省");
-//        if (provinceArray.length > 1) {
-//            province = provinceArray[0] + "省";
-//            address = provinceArray[1];
-//        }
-//
-//        // 匹配城市
-//        String[] cityArray = StringUtils.splitByWholeSeparatorPreserveAllTokens(address, "市");
-//        if (cityArray.length > 1) {
-//            city = cityArray[0] + "市";
-//            address = cityArray[1];
-//        }
-//
-//        // 匹配区县
-//        String[] districtArray = StringUtils.splitByWholeSeparatorPreserveAllTokens(address, "区");
-//        if (districtArray.length > 1) {
-//            district = districtArray[0] + "区";
-//        }
-
-        // 输出结果
-//        addresses.add(province);
-//        addresses.add(city);
-//        addresses.add(district);
         return personAddress;
 
     }

+ 33 - 36
src/main/java/cn/cslg/pas/common/utils/parseQueryToTree/expressManager.java

@@ -1,7 +1,7 @@
 package cn.cslg.pas.common.utils.parseQueryToTree;
 
 import cn.cslg.pas.common.utils.StringUtils;
-import org.springframework.util.CollectionUtils;
+
 
 import java.util.*;
 
@@ -158,17 +158,16 @@ public class expressManager {
         ArrayList<String> Tokens = GetTokens(strExpress);
         Stack<Symbol> symbolStack = new Stack<Symbol>();
         Stack<treeNode> valueStack = new Stack<treeNode>();
-        List<String> middleKuoHaoStrs =new ArrayList<>();
-     if(!isAnd){
-         return     ExpressTreeNode.Tokens2Node(Tokens,isAnd);
-     }
-        Boolean ifFindEndingMiddleKuoHaoStrs =false;
+        List<String> middleKuoHaoStrs = new ArrayList<>();
+        if (!isAnd) {
+            return ExpressTreeNode.Tokens2Node(Tokens, isAnd);
+        }
+        Boolean ifFindEndingMiddleKuoHaoStrs = false;
         for (String strTem : Tokens) {
             Symbol temSymbol = expressManager.getInstance().getSymbol(strTem);
-            if(ifFindEndingMiddleKuoHaoStrs&&(temSymbol == null||!(temSymbol instanceof pairSymbol&&((pairSymbol) temSymbol).Code.equals("]")))){
+            if (ifFindEndingMiddleKuoHaoStrs && (temSymbol == null || !(temSymbol instanceof pairSymbol && ((pairSymbol) temSymbol).Code.equals("]")))) {
                 middleKuoHaoStrs.add(strTem);
-            }
-            else if (temSymbol != null) {
+            } else if (temSymbol != null) {
                 if (temSymbol instanceof operate) {
                     //#region 如果是操作符,从操作符堆栈中取出优先级大于等于该操作符的结合值堆栈生成节点后压入值堆栈,然后将该操作符压入堆栈
                     operate temOperate = (operate) temSymbol;
@@ -199,18 +198,15 @@ public class expressManager {
                     symbolStack.push(temSymbol);
                     //#endregion
                 } else {
-                    if(temSymbol instanceof pairSymbol&&((pairSymbol) temSymbol).Code.equals("["))
-                    {
-                        ifFindEndingMiddleKuoHaoStrs=true;
-                    }
-                    else if(temSymbol instanceof pairSymbol&&((pairSymbol) temSymbol).Code.equals("]"))
-                    {
-                        ifFindEndingMiddleKuoHaoStrs=false;
-                     String temp=   StringUtils.join(middleKuoHaoStrs,",");
+                    if (temSymbol instanceof pairSymbol && ((pairSymbol) temSymbol).Code.equals("[")) {
+                        ifFindEndingMiddleKuoHaoStrs = true;
+                    } else if (temSymbol instanceof pairSymbol && ((pairSymbol) temSymbol).Code.equals("]")) {
+                        ifFindEndingMiddleKuoHaoStrs = false;
+                        String temp = StringUtils.join(middleKuoHaoStrs, ",");
                         valueNode temNode = new valueNode();
                         temNode.value = temp;
                         valueStack.push(temNode);
-                        middleKuoHaoStrs=new ArrayList<>();
+                        middleKuoHaoStrs = new ArrayList<>();
                     }
 
                     //#region 括号处理
@@ -250,13 +246,12 @@ public class expressManager {
                     //#endregion
                 }
             } else {
-                if(!ifFindEndingMiddleKuoHaoStrs) {
+                if (!ifFindEndingMiddleKuoHaoStrs) {
                     valueNode temNode = new valueNode();
                     temNode.value = strTem;
 
                     valueStack.push(temNode);
-                }
-                else {
+                } else {
                     middleKuoHaoStrs.add(strTem);
                 }
             }
@@ -296,7 +291,7 @@ public class expressManager {
                     if (temNode instanceof valueNode) {
                         lstValues.add(temNode);
                     } else {
-                        throw  new Exception("无效的检索式!");
+                        throw new Exception("无效的检索式!");
                     }
                 }
 
@@ -343,29 +338,31 @@ public class expressManager {
 
             String strTemToken = "";
             Boolean isFindingEndYinHao = false;
-            Boolean ifFindingEndMiddleKuoHao=false;
+            Boolean ifFindingEndMiddleKuoHao = false;
             int step = -1;
             for (int i = 0; i < strTem.length(); i++) {
                 char c = strTem.charAt(i);
 
                 switch (c) {
+                    case '“':
+                    case '”':
                     case '"':
-                            if (!isFindingEndYinHao) {
-                                isFindingEndYinHao = true;
+                        if (!isFindingEndYinHao) {
+                            isFindingEndYinHao = true;
+                            step = i;
+                        } else {
+                            if ((i < strTem.length() - 1 && strTem.charAt(i + 1) == ' ')
+                                    || (i < strTem.length() - 1 && strTem.charAt(i + 1) == ')')
+                                    || (i < strTem.length() - 1 && strTem.charAt(i + 1) == ']')
+                                    || i == strTem.length() - 1) {
+                                strTemToken = strTem.substring(step + 1, i);
+                                Tokens.add(strTemToken);
                                 step = i;
-                            } else {
-                                if ((i < strTem.length() - 1 && strTem.charAt(i + 1) == ' ')
-                                        || (i < strTem.length() - 1 && strTem.charAt(i + 1) == ')')
-                                        || (i < strTem.length() - 1 && strTem.charAt(i + 1) == ']')
-                                        || i == strTem.length() - 1) {
-                                    strTemToken = strTem.substring(step + 1, i);
-                                    Tokens.add(strTemToken);
-                                    step = i;
-                                    isFindingEndYinHao = false;
-                                }
-
+                                isFindingEndYinHao = false;
                             }
 
+                        }
+
                         break;
                     case ' ':
                         if (!isFindingEndYinHao) {

+ 8 - 1
src/main/java/cn/cslg/pas/service/common/PatentStarApiService.java

@@ -88,8 +88,10 @@ public class PatentStarApiService {
             patentStarListDTO.setCurrentQuery(retrieveRecord.getConditions());
             patentStarListDTO.setDBType(retrieveRecord.getDbType());
         }
+    long start =    System.currentTimeMillis();
         Map<String, Object> map = this.patentStarSearchApi(patentStarListDTO);
-
+long end =System.currentTimeMillis();
+System.out.println("search time:"+(end-start));
         if (map == null) {
             ThrowException.throwXiaoShiException("检索失败,请检查检索式");
         }
@@ -166,7 +168,12 @@ public class PatentStarApiService {
         Request request = new Request.Builder().url(url).post(requestBody).build();
         // 发送请求获取响应
         try {
+            long start =    System.currentTimeMillis();
+
             Response response = okHttpClient.newCall(request).execute();
+
+            long end =System.currentTimeMillis();
+            System.out.println("search11time:"+(end-start));
             // 判断请求是否成功
             if (response.isSuccessful()) {
                 JSONObject jsonObject = JSONObject.parseObject(Objects.requireNonNull(response.body()).string());

+ 0 - 1
src/main/java/cn/cslg/pas/service/importPatent/GetCataloguingFromWebThread.java

@@ -49,7 +49,6 @@ public class GetCataloguingFromWebThread extends Thread {
     public void run() {
 
         while ((!ifProductAll || uploadPatentWebDTOs.size() > 0) && importTaskAMVO.getState().equals(1)) {
-
             try {
                 //判断任务队列是否有任务,若没有则线程等待唤醒
                 if (uploadPatentWebDTOs.size() == 0) {

+ 8 - 1
src/main/java/cn/cslg/pas/service/importPatent/GetPatentFromExcelThread.java

@@ -126,7 +126,9 @@ public class GetPatentFromExcelThread extends Thread {
         } else if (grantNo != null) {
             usedNo = grantNo;
         }
+        //获取专利前缀
         String contry = usedNo.substring(0, 2);
+        //根据前缀判断如何设置专利号,中国专利为申请号,外国专利为公开号,若公开号不存在则为公告号
         if (contry.equals("CN")) {
             patentNo = appNo;
         } else {
@@ -139,7 +141,7 @@ public class GetPatentFromExcelThread extends Thread {
         patent.setPatentNo(patentNo);
         //装载国家
         patent.setAppCountry(contry);
-        //装载标题
+        //装载标题原文
         if (uploadParamsVO.getTitle() != null) {
             List<Text> texts = new ArrayList<>();
             if (uploadParamsVO.getTitle().getName() != null) {
@@ -149,6 +151,7 @@ public class GetPatentFromExcelThread extends Thread {
                 text.setLanguage(contry);
                 texts.add(text);
             }
+            //装载标题译文
             if (uploadParamsVO.getTitle().getNameOut() != null) {
                 Text text = new Text();
                 text.setTextContent(uploadParamsVO.getTitle().getNameOut());
@@ -165,6 +168,7 @@ public class GetPatentFromExcelThread extends Thread {
         //装载摘要
         if (uploadParamsVO.getAbstractStr() != null) {
             List<Text> texts = new ArrayList<>();
+            //装载摘要原文
             if (uploadParamsVO.getAbstractStr().getName() != null) {
                 Text text = new Text();
                 text.setTextContent(uploadParamsVO.getAbstractStr().getName());
@@ -172,6 +176,7 @@ public class GetPatentFromExcelThread extends Thread {
                 text.setLanguage(contry);
                 texts.add(text);
             }
+            //装载摘要译文
             if (uploadParamsVO.getAbstractStr().getNameOut() != null) {
                 Text text = new Text();
                 text.setTextContent(uploadParamsVO.getAbstractStr().getNameOut());
@@ -187,6 +192,7 @@ public class GetPatentFromExcelThread extends Thread {
         //装载权利要求
         if (uploadParamsVO.getPatentRight() != null) {
             List<Text> texts = new ArrayList<>();
+            //装载权利要求原文
             if (uploadParamsVO.getPatentRight().getName() != null) {
                 Text text = new Text();
                 text.setTextContent(uploadParamsVO.getPatentRight().getName());
@@ -194,6 +200,7 @@ public class GetPatentFromExcelThread extends Thread {
                 text.setLanguage(contry);
                 texts.add(text);
             }
+            //装载权利要求译文
             if (uploadParamsVO.getPatentRight().getNameOut() != null) {
                 Text text = new Text();
                 text.setTextContent(uploadParamsVO.getPatentRight().getNameOut());