lwhhszx 1 год назад
Родитель
Сommit
0f09a36c0a

+ 319 - 387
src/main/java/cn/cslg/pas/common/utils/parseQueryToTree/expressManager.java

@@ -6,81 +6,91 @@ import java.util.List;
 import java.util.Stack;
 
 public class expressManager {
-    HashMap<String,Symbol> hSymbols = new HashMap<String, Symbol>();
+    HashMap<String, Symbol> hSymbols = new HashMap<String, Symbol>();
     private static expressManager instance = new expressManager();
-    private expressManager(){
+
+    private expressManager() {
         //#region 添加逻辑符号
-            operate oAnd = new operate();
-            oAnd.Code = "AND";
-            oAnd.ShowName = "AND";
-            oAnd.type = enuType.Logic;
-            oAnd.priorityVale = 11;
-            oAnd.operateValue = 2;
-            hSymbols.put(oAnd.Code, oAnd);
-
-            operate oOR = new operate();
-            oOR.Code = "OR";
-            oOR.ShowName = "OR";
-            oOR.type = enuType.Logic;
-            oOR.priorityVale = 11;
-            oOR.operateValue = 2;
-            hSymbols.put(oOR.Code, oOR);
-
-            oOR = new operate();
-            oOR.Code = "NOT";
-            oOR.ShowName = "NOT";
-            oOR.type = enuType.Logic;
-            oOR.priorityVale = 12;
-            oOR.operateValue = 1;
-            hSymbols.put(oOR.Code, oOR);
-
-            oOR = new operate();
-            oOR.Code = "TO";
-            oOR.ShowName = "TO";
-            oOR.type = enuType.Logic;
-            oOR.priorityVale = 13;
-            oOR.operateValue = 2;
-            hSymbols.put(oOR.Code, oOR);
-
-            oOR = new operate();
-            oOR.Code = "=";
-            oOR.ShowName = "=";
-            oOR.type = enuType.Assignment;
-            oOR.priorityVale = 20;
-            oOR.operateValue = 2;
-            hSymbols.put(oOR.Code, oOR);
-
-            oOR = new operate();
-            oOR.Code = ">";
-            oOR.ShowName = ">";
-            oOR.type = enuType.Assignment;
-            oOR.priorityVale = 20;
-            oOR.operateValue = 2;
-            hSymbols.put(oOR.Code, oOR);
-
-            oOR = new operate();
-            oOR.Code = "<";
-            oOR.ShowName = "<";
-            oOR.type = enuType.Assignment;
-            oOR.priorityVale = 20;
-            oOR.operateValue = 2;
-            hSymbols.put(oOR.Code, oOR);
-
-            oOR = new operate();
-            oOR.Code = ">=";
-            oOR.ShowName = ">=";
-            oOR.type = enuType.Assignment;
-            oOR.priorityVale = 20;
-            oOR.operateValue = 2;
-            hSymbols.put(oOR.Code, oOR);
-
-            oOR = new operate();
-            oOR.Code = "<=";
-            oOR.ShowName = "<=";
-            oOR.type = enuType.Assignment;
-            oOR.priorityVale = 20;
-            oOR.operateValue = 2;
-            hSymbols.put(oOR.Code, oOR);
+        operate oAnd = new operate();
+        oAnd.Code = "AND";
+        oAnd.ShowName = "AND";
+        oAnd.type = enuType.Logic;
+        oAnd.priorityVale = 11;
+        oAnd.operateValue = 2;
+        hSymbols.put(oAnd.Code, oAnd);
+
+        operate oOR = new operate();
+        oOR.Code = "OR";
+        oOR.ShowName = "OR";
+        oOR.type = enuType.Logic;
+        oOR.priorityVale = 11;
+        oOR.operateValue = 2;
+        hSymbols.put(oOR.Code, oOR);
+
+        oOR = new operate();
+        oOR.Code = "NOT";
+        oOR.ShowName = "NOT";
+        oOR.type = enuType.Logic;
+        oOR.priorityVale = 12;
+        oOR.operateValue = 1;
+        hSymbols.put(oOR.Code, oOR);
+
+        oOR = new operate();
+        oOR.Code = "TO";
+        oOR.ShowName = "TO";
+        oOR.type = enuType.Logic;
+        oOR.priorityVale = 13;
+        oOR.operateValue = 2;
+        hSymbols.put(oOR.Code, oOR);
+
+        oOR = new operate();
+        oOR.Code = "~";
+        oOR.ShowName = ">";
+        oOR.type = enuType.Logic;
+        oOR.priorityVale = 13;
+        oOR.operateValue = 2;
+        hSymbols.put(oOR.Code, oOR);
+
+        oOR = new operate();
+        oOR.Code = "=";
+        oOR.ShowName = "=";
+        oOR.type = enuType.Assignment;
+        oOR.priorityVale = 20;
+        oOR.operateValue = 2;
+        hSymbols.put(oOR.Code, oOR);
+
+        oOR = new operate();
+        oOR.Code = ">";
+        oOR.ShowName = ">";
+        oOR.type = enuType.Assignment;
+        oOR.priorityVale = 20;
+        oOR.operateValue = 2;
+        hSymbols.put(oOR.Code, oOR);
+
+        oOR = new operate();
+        oOR.Code = "<";
+        oOR.ShowName = "<";
+        oOR.type = enuType.Assignment;
+        oOR.priorityVale = 20;
+        oOR.operateValue = 2;
+        hSymbols.put(oOR.Code, oOR);
+
+        oOR = new operate();
+        oOR.Code = ">=";
+        oOR.ShowName = ">=";
+        oOR.type = enuType.Assignment;
+        oOR.priorityVale = 20;
+        oOR.operateValue = 2;
+        hSymbols.put(oOR.Code, oOR);
+
+        oOR = new operate();
+        oOR.Code = "<=";
+        oOR.ShowName = "<=";
+        oOR.type = enuType.Assignment;
+        oOR.priorityVale = 20;
+        oOR.operateValue = 2;
+        hSymbols.put(oOR.Code, oOR);
+
 
         oOR = new operate();
         oOR.Code = "CONTAIN";
@@ -89,393 +99,315 @@ public class expressManager {
         oOR.priorityVale = 20;
         oOR.operateValue = 2;
         hSymbols.put(oOR.Code, oOR);
-            //#endregion
+        //#endregion
 
-            //#region 添加成对出现的符号
-            pairSymbol first = new pairSymbol();
-            first.Code = "(";
-            first.isEndSymbol = false;
+        //#region 添加成对出现的符号
+        pairSymbol first = new pairSymbol();
+        first.Code = "(";
+        first.isEndSymbol = false;
 
 
-            pairSymbol end = new pairSymbol();
-            end.Code = ")";
-            end.previewSymbol = first;
-            end.isEndSymbol = true;
+        pairSymbol end = new pairSymbol();
+        end.Code = ")";
+        end.previewSymbol = first;
+        end.isEndSymbol = true;
 
-            hSymbols.put(first.Code, first);
-            hSymbols.put(end.Code, end);
+        hSymbols.put(first.Code, first);
+        hSymbols.put(end.Code, end);
 
-            pairSymbol first1 = new pairSymbol();
-            first1.Code = "[";
-            first1.isEndSymbol = false;
+        pairSymbol first1 = new pairSymbol();
+        first1.Code = "[";
+        first1.isEndSymbol = false;
 
-            pairSymbol end1 = new pairSymbol();
-            end1.Code = "]";
-            end1.previewSymbol = first1;
-            end1.isEndSymbol = true;
+        pairSymbol end1 = new pairSymbol();
+        end1.Code = "]";
+        end1.previewSymbol = first1;
+        end1.isEndSymbol = true;
 
-            hSymbols.put(first1.Code, first1);
-            hSymbols.put(end1.Code, end1);
+        hSymbols.put(first1.Code, first1);
+        hSymbols.put(end1.Code, end1);
 
-            end = new pairSymbol();
-            end.Code = "\"";
-            end.previewSymbol = end;
+        end = new pairSymbol();
+        end.Code = "\"";
+        end.previewSymbol = end;
 
-            hSymbols.put(end.Code, end);
-            //#endregion
+        hSymbols.put(end.Code, end);
+        //#endregion
     }
 
-    public static expressManager getInstance()
-    {
+    public static expressManager getInstance() {
         return instance;
     }
 
-    public Symbol getSymbol(String strSymbol)
-        {
-            String strKey = strSymbol.trim().toUpperCase();
-            if ((strKey!=null && !strKey.trim().equals("")) && hSymbols.containsKey(strKey))
-            {
-                return hSymbols.get(strKey);
-            }
-            else
-            {
-                return null;
-            }
+    public Symbol getSymbol(String strSymbol) {
+        String strKey = strSymbol.trim().toUpperCase();
+        if ((strKey != null && !strKey.trim().equals("")) && hSymbols.containsKey(strKey)) {
+            return hSymbols.get(strKey);
+        } else {
+            return null;
         }
+    }
 
     /// <summary>
-        /// 解析表达式字符串,返回表达式树
-        /// </summary>
-        /// <param name="strExpress">表达式字符串</param>
-        /// <param name="isAnd">如果输入的是多个条件,之间的关系是and还是or,true为and,false为or</param>
-        /// <returns>表达式树节点</returns>
-        public treeNode Parse(String strExpress, boolean isAnd) throws Exception
-        {
-            ArrayList<String> Tokens = GetTokens(strExpress);
-            Stack<Symbol> symbolStack = new Stack<Symbol>();
-            Stack<treeNode> valueStack = new Stack<treeNode>();
-                 for (String strTem : Tokens)
-            {
-                Symbol temSymbol = expressManager.getInstance().getSymbol(strTem);
-                if (temSymbol != null)
-                {
-                    if (temSymbol instanceof operate)
-                    {
-                        //#region 如果是操作符,从操作符堆栈中取出优先级大于等于该操作符的结合值堆栈生成节点后压入值堆栈,然后将该操作符压入堆栈
-                        operate temOperate = (operate)temSymbol;
-                        if (symbolStack.size() > 0)
-                        {
-                            Symbol lastSymbol = symbolStack.peek();
-
-                            while (lastSymbol instanceof operate && ((operate)lastSymbol).priorityVale >= temOperate.priorityVale)
-                            {
-                                operateNode temSymbolNode = new operateNode();
-                                temSymbolNode.operate = (operate)lastSymbol;
-                                if (((operate)lastSymbol).operateValue == 1)
-                                {
-                                    temSymbolNode.Right = valueStack.pop();
-                                }
-                                else
-                                {temSymbolNode.Right = valueStack.pop();
-                                    temSymbolNode.Left = valueStack.pop();
-                                }
+    /// 解析表达式字符串,返回表达式树
+    /// </summary>
+    /// <param name="strExpress">表达式字符串</param>
+    /// <param name="isAnd">如果输入的是多个条件,之间的关系是and还是or,true为and,false为or</param>
+    /// <returns>表达式树节点</returns>
+    public treeNode Parse(String strExpress, boolean isAnd) throws Exception {
+        ArrayList<String> Tokens = GetTokens(strExpress);
+        Stack<Symbol> symbolStack = new Stack<Symbol>();
+        Stack<treeNode> valueStack = new Stack<treeNode>();
+        for (String strTem : Tokens) {
+            Symbol temSymbol = expressManager.getInstance().getSymbol(strTem);
+            if (temSymbol != null) {
+                if (temSymbol instanceof operate) {
+                    //#region 如果是操作符,从操作符堆栈中取出优先级大于等于该操作符的结合值堆栈生成节点后压入值堆栈,然后将该操作符压入堆栈
+                    operate temOperate = (operate) temSymbol;
+                    if (symbolStack.size() > 0) {
+                        Symbol lastSymbol = symbolStack.peek();
+
+                        while (lastSymbol instanceof operate && ((operate) lastSymbol).priorityVale >= temOperate.priorityVale) {
+                            operateNode temSymbolNode = new operateNode();
+                            temSymbolNode.operate = (operate) lastSymbol;
+                            if (((operate) lastSymbol).operateValue == 1) {
+                                temSymbolNode.Right = valueStack.pop();
+                            } else {
+                                temSymbolNode.Right = valueStack.pop();
+                                temSymbolNode.Left = valueStack.pop();
+                            }
 
-                                valueStack.push(temSymbolNode);
+                            valueStack.push(temSymbolNode);
 
-                                symbolStack.pop();
+                            symbolStack.pop();
 
-                                if (symbolStack.size() > 0)
-                                {
-                                    lastSymbol = symbolStack.peek();
-                                }
-                                else
-                                {
-                                    break;
-                                }
+                            if (symbolStack.size() > 0) {
+                                lastSymbol = symbolStack.peek();
+                            } else {
+                                break;
                             }
                         }
-                        symbolStack.push(temSymbol);
-                        //#endregion
                     }
-                    else
-                    {
-                        //#region 括号处理
-                        if (temSymbol instanceof pairSymbol && ((pairSymbol)temSymbol).isEndSymbol)
-                        {
-                            Symbol lastSymbol = symbolStack.peek();
-
-                            if (lastSymbol == null)
-                            {
-                                throw new Exception("无效的括号!");
-                            }
-
-                            while (lastSymbol instanceof operate ||
-                                (lastSymbol instanceof pairSymbol && ((pairSymbol)lastSymbol).Code != ((pairSymbol)temSymbol).previewSymbol.Code))
-                            {
-                                operateNode temSymbolNode = new operateNode();
-                                temSymbolNode.operate = (operate)lastSymbol;
+                    symbolStack.push(temSymbol);
+                    //#endregion
+                } else {
+                    //#region 括号处理
+                    if (temSymbol instanceof pairSymbol && ((pairSymbol) temSymbol).isEndSymbol) {
+                        Symbol lastSymbol = symbolStack.peek();
+
+                        if (lastSymbol == null) {
+                            throw new Exception("无效的括号!");
+                        }
 
-                                if (((operate)lastSymbol).operateValue == 1)
-                                {
-                                    temSymbolNode.Right = valueStack.pop();
-                                }
-                                else
-                                {
-                                    temSymbolNode.Right = valueStack.pop();
-                                    temSymbolNode.Left = valueStack.pop();
-                                }
-                                valueStack.push(temSymbolNode);
+                        while (lastSymbol instanceof operate ||
+                                (lastSymbol instanceof pairSymbol && ((pairSymbol) lastSymbol).Code != ((pairSymbol) temSymbol).previewSymbol.Code)) {
+                            operateNode temSymbolNode = new operateNode();
+                            temSymbolNode.operate = (operate) lastSymbol;
 
-                                symbolStack.pop();
-                                lastSymbol = symbolStack.peek();
-                            }
-
-                            if ((lastSymbol instanceof pairSymbol && ((pairSymbol)temSymbol).previewSymbol.Code == ((pairSymbol)lastSymbol).Code))
-                            {
-                                symbolStack.pop();
-                            }
-                            else
-                            {
-                                throw new Exception("无效的括号");
+                            if (((operate) lastSymbol).operateValue == 1) {
+                                temSymbolNode.Right = valueStack.pop();
+                            } else {
+                                temSymbolNode.Right = valueStack.pop();
+                                temSymbolNode.Left = valueStack.pop();
                             }
+                            valueStack.push(temSymbolNode);
 
+                            symbolStack.pop();
+                            lastSymbol = symbolStack.peek();
                         }
-                        else
-                        {
-                            symbolStack.push(temSymbol);
+
+                        if ((lastSymbol instanceof pairSymbol && ((pairSymbol) temSymbol).previewSymbol.Code == ((pairSymbol) lastSymbol).Code)) {
+                            symbolStack.pop();
+                        } else {
+                            throw new Exception("无效的括号");
                         }
-                        //#endregion
+
+                    } else {
+                        symbolStack.push(temSymbol);
                     }
+                    //#endregion
                 }
-                else
-                {
-                    valueNode temNode = new valueNode();
-                    temNode.value = strTem;
+            } else {
+                valueNode temNode = new valueNode();
+                temNode.value = strTem;
 
-                    valueStack.push(temNode);
-                }
+                valueStack.push(temNode);
             }
+        }
 
-            while (symbolStack.size() > 0)
-            {
-                Symbol temSymbol = symbolStack.pop();
+        while (symbolStack.size() > 0) {
+            Symbol temSymbol = symbolStack.pop();
 
-                if (temSymbol instanceof operate)
-                {
-                    operateNode temNode = new operateNode();
-                    temNode.operate = (operate)temSymbol;
+            if (temSymbol instanceof operate) {
+                operateNode temNode = new operateNode();
+                temNode.operate = (operate) temSymbol;
 
-                    if (((operate)temSymbol).operateValue == 1)
-                    {
-                        temNode.Right = valueStack.pop();
-                    }
-                    else
-                    {
-                        temNode.Right = valueStack.pop();
-                        temNode.Left = valueStack.pop();
-                    }
+                if (((operate) temSymbol).operateValue == 1) {
+                    temNode.Right = valueStack.pop();
+                } else {
+                    temNode.Right = valueStack.pop();
+                    temNode.Left = valueStack.pop();
+                }
 
-                    valueStack.push(temNode);
+                valueStack.push(temNode);
 
-                }
-                else
-                {
-                    throw new Exception("无效的括号!");
-                }
+            } else {
+                throw new Exception("无效的括号!");
             }
+        }
 
-            if (valueStack.size() == 1)
-            {
-                return valueStack.pop();
-            }
-            else
-            {
+        if (valueStack.size() == 1) {
+            return valueStack.pop();
+        } else {
 
-                if (valueStack.size() > 1)
-                {
-                    List<treeNode> lstValues = new ArrayList<treeNode>();
+            if (valueStack.size() > 1) {
+                List<treeNode> lstValues = new ArrayList<treeNode>();
 
-                    while (valueStack.size() > 0)
-                    {
-                        treeNode temNode = valueStack.pop();
+                while (valueStack.size() > 0) {
+                    treeNode temNode = valueStack.pop();
 
-                        if (temNode instanceof valueNode)
-                        {
-                            lstValues.add(temNode);
-                        }
-                        else
-                        {
-                            throw new Exception("无效的检索式!");
-                        }
+                    if (temNode instanceof valueNode) {
+                        lstValues.add(temNode);
+                    } else {
+                        throw new Exception("无效的检索式!");
                     }
+                }
 
-                    treeNode retNode = null;
+                treeNode retNode = null;
 
-                    for (treeNode temNode : lstValues)
-                    {
-                        if (retNode == null)
-                        {
-                            retNode = temNode;
-                        }
-                        else
-                        {
-                            operateNode sNode = new operateNode();
+                for (treeNode temNode : lstValues) {
+                    if (retNode == null) {
+                        retNode = temNode;
+                    } else {
+                        operateNode sNode = new operateNode();
 
-                            if (!isAnd)
-                            {
-                                sNode.operate = (operate)expressManager.getInstance().getSymbol("OR");
-                            }
-                            else
-                            {
-                                sNode.operate = (operate)expressManager.getInstance().getSymbol("AND");
-                            }
-
-                            sNode.Left = retNode;
-                            sNode.Right = temNode;
-                            retNode = sNode;
+                        if (!isAnd) {
+                            sNode.operate = (operate) expressManager.getInstance().getSymbol("OR");
+                        } else {
+                            sNode.operate = (operate) expressManager.getInstance().getSymbol("AND");
                         }
-                    }
 
-                    return retNode;
+                        sNode.Left = retNode;
+                        sNode.Right = temNode;
+                        retNode = sNode;
+                    }
                 }
 
-                throw new Exception("无效的检索式!");
-
+                return retNode;
             }
+
+            throw new Exception("无效的检索式!");
+
         }
+    }
 
 
     /// <summary>
-        /// 语法分析,将表达式字符按照空格分开,
-        /// 且将双引号或者是括号从字符串中拿出来
-        /// </summary>
-        /// <param name="strExpress"></param>
-        /// <returns></returns>
-        public ArrayList<String> GetTokens(String strExpress)
-        {
-            if (strExpress != null)
-            {
-                ArrayList<String> Tokens = new ArrayList<String>();
-                //#region 
-                String strTem = strExpress.trim();
-
-                String strTemToken = "";
-                Boolean isFindingEndYinHao = false;
-                int step = -1;
-                for (int i = 0; i < strTem.length(); i++)
-                {
-                    char c = strTem.charAt(i);
-
-                    switch (c)
-                    {
-                        case '"':
-                            if (!isFindingEndYinHao)
-                            {
-                                isFindingEndYinHao = true;
-                                step = i;
-                            }
-                            else
-                            {
-                                if ((i < strTem.length() - 1 && strTem.charAt(i + 1) == ' ')
+    /// 语法分析,将表达式字符按照空格分开,
+    /// 且将双引号或者是括号从字符串中拿出来
+    /// </summary>
+    /// <param name="strExpress"></param>
+    /// <returns></returns>
+    public ArrayList<String> GetTokens(String strExpress) {
+        if (strExpress != null) {
+            ArrayList<String> Tokens = new ArrayList<String>();
+            //#region
+            String strTem = strExpress.trim();
+
+            String strTemToken = "";
+            Boolean isFindingEndYinHao = false;
+            int step = -1;
+            for (int i = 0; i < strTem.length(); i++) {
+                char c = strTem.charAt(i);
+
+                switch (c) {
+                    case '"':
+                        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;
-                                    isFindingEndYinHao = false;
-                                }
-
+                                    || i == strTem.length() - 1) {
+                                strTemToken = strTem.substring(step + 1, i);
+                                Tokens.add(strTemToken);
+                                step = i;
+                                isFindingEndYinHao = false;
                             }
-                            break;
-                        case ' ':
-                            if (!isFindingEndYinHao)
-                            {
-                                if (step == (i - 1))
-                                {
-                                    step = i;
-                                }
-                                else
-                                {
-                                    strTemToken = strTem.substring(step + 1, i );
-                                    Tokens.add(strTemToken);
-                                    step = i;
 
-                                }
+                        }
+                        break;
+                    case ' ':
+                        if (!isFindingEndYinHao) {
+                            if (step == (i - 1)) {
+                                step = i;
+                            } else {
+                                strTemToken = strTem.substring(step + 1, i);
+                                Tokens.add(strTemToken);
+                                step = i;
+
                             }
-                            break;
-                        case '(':
-                        case '[':
-                        if (i == 0 || strTem.charAt(i - 1) == ' ' || (Tokens.size() > 0 && Tokens.get(Tokens.size() - 1) == String.valueOf(c)) || strTem.charAt(i - 1) == '=')
-                        {
+                        }
+                        break;
+                    case '(':
+                    case '[':
+                        if (i == 0 || strTem.charAt(i - 1) == ' ' || (Tokens.size() > 0 && Tokens.get(Tokens.size() - 1) == String.valueOf(c)) || strTem.charAt(i - 1) == '=') {
                             Tokens.add(String.valueOf(c));
                             step = i;
                         }
                         break;
-                        case ')':
-                        case ']':
-                            if ((i < strTem.length() - 1 && (strTem.charAt(i + 1) == ' ' || strTem.charAt(i + 1) == c)) || i == strTem.length() - 1)
-                            {
-                                Boolean isAdd = false;
-                                for (int index = Tokens.size() - 1; index >= 0; index--)
-                                {
-                                    if ((c == ')' && Tokens.get(index).equals("("))  || (c == ']' && Tokens.get(index).equals("[")))
-                                    {
-                                        isAdd = true;
-                                        break;
-                                    }
-                                }
-                                if (isAdd)
-                                {
-                                    strTemToken = strTem.substring(step + 1, i );
-                                    if (strTemToken != null && !strTemToken.equals(""))
-                                    {
-                                        Tokens.add(strTemToken);
-                                    }
-                                    Tokens.add(String.valueOf(c));
-                                    step = i;
+                    case ')':
+                    case ']':
+                        if ((i < strTem.length() - 1 && (strTem.charAt(i + 1) == ' ' || strTem.charAt(i + 1) == c)) || i == strTem.length() - 1) {
+                            Boolean isAdd = false;
+                            for (int index = Tokens.size() - 1; index >= 0; index--) {
+                                if ((c == ')' && Tokens.get(index).equals("(")) || (c == ']' && Tokens.get(index).equals("["))) {
+                                    isAdd = true;
+                                    break;
                                 }
                             }
-                            break;
-                        case '=':
-                        case '~':
-                        case '>':
-                        case '>':
-                        case '<':
-                        case '<':
-                            strTemToken = strTem.substring(step + 1, i );
-
-                            if (strTemToken !=null && strTemToken !="")
-                            {
-                                Tokens.add(strTemToken);
-                            }
-
-                            if (strTem.charAt(i + 1) == '=')
-                            {
-                                Tokens.add(String.valueOf(c) + "=");
-                                step = i + 1;
-                                i++;
-                            }
-                            else
-                            {
+                            if (isAdd) {
+                                strTemToken = strTem.substring(step + 1, i);
+                                if (strTemToken != null && !strTemToken.equals("")) {
+                                    Tokens.add(strTemToken);
+                                }
                                 Tokens.add(String.valueOf(c));
                                 step = i;
                             }
-                            break;
-                    }
-                }
+                        }
+                        break;
+                    case '=':
+                    case '~':
+                    case '>':
+                    case '>':
+                    case '<':
+                    case '<':
+                        strTemToken = strTem.substring(step + 1, i);
+
+                        if (strTemToken != null && strTemToken != "") {
+                            Tokens.add(strTemToken);
+                        }
 
-                if (step < strTem.length() - 1)
-                {
-                    Tokens.add(strTem.substring(step + 1));
+                        if (strTem.charAt(i + 1) == '=') {
+                            Tokens.add(String.valueOf(c) + "=");
+                            step = i + 1;
+                            i++;
+                        } else {
+                            Tokens.add(String.valueOf(c));
+                            step = i;
+                        }
+                        break;
                 }
-                //#endregion
-                return Tokens;
             }
-            else
-            {
-                return null;
+
+            if (step < strTem.length() - 1) {
+                Tokens.add(strTem.substring(step + 1));
             }
+            //#endregion
+            return Tokens;
+        } else {
+            return null;
         }
+    }
 }

+ 92 - 0
src/main/java/cn/cslg/pas/controller/outApi/PatentStarController.java

@@ -0,0 +1,92 @@
+package cn.cslg.pas.controller.outApi;
+
+import cn.cslg.pas.common.core.base.Constants;
+import cn.cslg.pas.common.dto.PatentStarListDTO;
+import cn.cslg.pas.common.utils.Response;
+import cn.cslg.pas.service.common.PatentStarApiService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.RequiredArgsConstructor;
+import org.springframework.context.annotation.Lazy;
+
+import org.springframework.web.bind.annotation.*;
+
+import java.io.IOException;
+import java.util.Map;
+
+@Tag(name = "专利之星接口服务类")
+@RestController
+@RequestMapping(Constants.API_XiaoSHI + "/patentStar")
+@RequiredArgsConstructor(onConstructor_ = {@Lazy})
+public class PatentStarController {
+    private final PatentStarApiService patentStarApiService;
+
+    @PostMapping("/select")
+    @Operation(summary = "一般检索接口")
+    public Response select(@RequestBody PatentStarListDTO patentStarListDto) throws IOException {
+        Map<String, Object> map = patentStarApiService.patentStarSearchLocal(patentStarListDto);
+        return Response.success(map);
+    }
+
+    @GetMapping("/getCnBib")
+    @Operation(summary = "获得中国专利著录")
+    public String getCnBib(String appNo) {
+        return patentStarApiService.getCnBibApi(appNo);
+    }
+
+    @GetMapping("/getPicture")
+    @Operation(summary = "获得中国专利摘要附图")
+    public String getPicture(String appNo) {
+        return patentStarApiService.getPictureApi(appNo);
+    }
+
+    @GetMapping("/getWGPicture")
+    @Operation(summary = "获得中国专利外观图")
+    public String getWGPicture(String appNo) throws IOException {
+        return patentStarApiService.getWGPictureApi(appNo);
+    }
+
+    @GetMapping("/getCnLegal")
+    @Operation(summary = "获得中国专利法律状态")
+    public String getCnLegal(String appNo) {
+        return patentStarApiService.getCnLegalApi(appNo);
+    }
+
+    @GetMapping("/getCnPdf")
+    @Operation(summary = "获得中国专利pdf全文")
+    public String getCnPdf(String appNo) throws IOException {
+        String picUrl = patentStarApiService.getCnPdfApi(appNo);
+        return picUrl;
+    }
+
+    @GetMapping("/getCnFullXml")
+    @Operation(summary = "获得中国专利全文文本")
+    public String getCnFullXml(String appNo) throws IOException {
+        return patentStarApiService.getCnFullXmlApi(appNo);
+    }
+
+    @GetMapping("/getEnPdf")
+    @Operation(summary = "获得世界专利pdf")
+    public String getEnPdf(String patentNo) throws IOException {
+        return patentStarApiService.getEnPdfApi(patentNo);
+    }
+
+    @GetMapping("/getENBib")
+    @Operation(summary = "获得世界专利著录信息")
+    public String getENBib(String patentNo) throws IOException {
+        String result = patentStarApiService.getENBibApi(patentNo);
+        return result;
+    }
+
+    @GetMapping("/getFamilyByPubNo")
+    @Operation(summary = "获得同族专利")
+    public String getFamilyByPubNo(String patentNo) {
+        return patentStarApiService.getFamilyByPubNoApi(patentNo);
+    }
+
+    @GetMapping("/getCitedNumByPubNo")
+    @Operation(summary = "获得被引用次数")
+    public String getCitedNumByPubNo(String patentNo) throws IOException {
+        return patentStarApiService.getCitedNumByPubNoApi(patentNo);
+    }
+}

+ 4 - 2
src/main/java/cn/cslg/pas/factorys/getSqlFactorys/GetComSql.java

@@ -23,7 +23,7 @@ import java.util.List;
 @Component
 public class GetComSql  implements GetSqlObject{
 
- private SqlObject sqlObject ;
+ private SqlObject sqlObject;
     @Override
     public String getSql(String value) {
       String filed= sqlObject.getSqlField();
@@ -31,9 +31,11 @@ public class GetComSql  implements GetSqlObject{
        return  filed+option+"'"+value+"'";
     }
 
-    public void setSqlObject(SqlObject sqlObject){
+    public void setSqlObject(SqlObject sqlObject)
+    {
         this.sqlObject=sqlObject;
     }
+
     public SqlObject getSqlObject(){
         return sqlObject;
     }

+ 32 - 0
src/main/java/cn/cslg/pas/factorys/getSqlFactorys/GetWebQuerySql.java

@@ -0,0 +1,32 @@
+package cn.cslg.pas.factorys.getSqlFactorys;
+
+import cn.cslg.pas.common.model.cronModel.SqlObject;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+
+@Slf4j
+@Component
+public class GetWebQuerySql implements GetSqlObject {
+
+    private SqlObject sqlObject;
+
+    @Override
+    public String getSql(String value) {
+        String filed = sqlObject.getSqlField();
+        String option = sqlObject.getOption();
+        String trueOption = "";
+        if (option.equals("=")) {
+            option = "/";
+        }
+        return value +option+ filed;
+    }
+
+    public void setSqlObject(SqlObject sqlObject) {
+        this.sqlObject = sqlObject;
+    }
+
+    public SqlObject getSqlObject() {
+        return sqlObject;
+    }
+}

+ 33 - 21
src/main/java/cn/cslg/pas/service/common/PatentStarApiService.java

@@ -12,9 +12,11 @@ import cn.cslg.pas.domain.WebLoginConfig;
 import cn.cslg.pas.domain.business.RetrieveRecord;
 import cn.cslg.pas.service.WebLoginConfigService;
 
+import cn.cslg.pas.service.query.FormatQueryService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import lombok.RequiredArgsConstructor;
+import lombok.experimental.Accessors;
 import lombok.extern.slf4j.Slf4j;
 import okhttp3.FormBody;
 import okhttp3.OkHttpClient;
@@ -24,6 +26,7 @@ import org.joda.time.DateTime;
 import org.joda.time.format.DateTimeFormat;
 import org.joda.time.format.DateTimeFormatter;
 import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.io.IOException;
@@ -43,10 +46,16 @@ import java.util.regex.Pattern;
 @Service
 
 public class PatentStarApiService {
-    private final RetrieveRecordService retrieveRecordService;
-    private final CacheUtils cacheUtils;
-    private final LoginUtils loginUtils;
-    private final WebLoginConfigService webLoginConfigService;
+   @Autowired
+    private  RetrieveRecordService retrieveRecordService;
+    @Autowired
+    private  CacheUtils cacheUtils;
+    @Autowired
+    private LoginUtils loginUtils;
+    @Autowired
+    private WebLoginConfigService webLoginConfigService;
+    @Autowired
+    private FormatQueryService formatQueryService;
 //
 //    //装载专利信息
 //    public void loadStarPatentVOS(List<StarPatentVO> starPatentVOS, JSONObject Data) {
@@ -184,30 +193,33 @@ public class PatentStarApiService {
 //        });
 //    }
 
-    public Map<String, Object> patentStarSearchLocal(PatentStarListDTO PatentStarListDTO) throws IOException {
+    public Map<String, Object> patentStarSearchLocal(PatentStarListDTO patentStarListDTO) throws IOException {
         RetrieveRecord retrieveRecord = new RetrieveRecord();
-        retrieveRecord.setConditions(PatentStarListDTO.getCurrentQuery());
-        if (PatentStarListDTO.getRetrieveRecordId() != null) {
-            //retrieveRecord = retrieveRecordService.getById(PatentStarListDTO.getRetrieveRecordId());
-            //PatentStarListDTO.setCurrentQuery(retrieveRecord.getConditions());
-            //PatentStarListDTO.setDBType(retrieveRecord.getDbType());
+        retrieveRecord.setConditions(patentStarListDTO.getCurrentQuery());
+
+        if (patentStarListDTO.getRetrieveRecordId() != null) {
+            retrieveRecord = retrieveRecordService.getById(patentStarListDTO.getRetrieveRecordId());
+            patentStarListDTO.setCurrentQuery(retrieveRecord.getConditions());
+            patentStarListDTO.setDBType(retrieveRecord.getDbType());
         }
-        Map<String, Object> map = this.patentStarSearchApi(PatentStarListDTO);
+        Map<String, Object> map = this.patentStarSearchApi(patentStarListDTO);
+
         if (map == null) {
             ThrowException.throwXiaoShiException("检索失败,请检查检索式");
         }
+
         //记录检索历史
         retrieveRecord.setRetrieveTime(new Date());
         retrieveRecord.setTotalNum(Integer.parseInt(map.get("total").toString()));
-        retrieveRecord.setDbType(PatentStarListDTO.getDBType());
-        if (PatentStarListDTO.getRetrieveRecordId() == null) {
-            //获取创建人信息
-            PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
-            retrieveRecord.setCreateTime(new Date());
-            retrieveRecord.setCreateId(personnelVO.getId());
-            retrieveRecord.setTenantId(personnelVO.getTenantId());
-            retrieveRecord.insert();
-        }
+        retrieveRecord.setDbType(patentStarListDTO.getDBType());
+//        if (patentStarListDTO.getRetrieveRecordId() == null) {
+//            //获取创建人信息
+//            PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
+//            retrieveRecord.setCreateTime(new Date());
+//            retrieveRecord.setCreateId(personnelVO.getId());
+//            retrieveRecord.setTenantId(personnelVO.getTenantId());
+//            retrieveRecord.insert();
+//        }
 //        else {
 //            retrieveRecord.updateById();
 //        }
@@ -221,7 +233,7 @@ public class PatentStarApiService {
         try {
             if (PatentStarListDTO.getFormed() == null || PatentStarListDTO.getFormed() == false) {
                 String formQuery = PatentStarListDTO.getCurrentQuery();
-//                PatentStarListDTO.setCurrentQuery(PatentStarApiService.formatQuery(formQuery));
+               PatentStarListDTO.setCurrentQuery(formatQueryService.reQuery(formQuery,"webSearchConfig"));
                 if (PatentStarListDTO.getDBType().equals("WD")) {
                     StringBuilder stringBuilder = new StringBuilder(PatentStarListDTO.getCurrentQuery());
                     stringBuilder.insert(PatentStarListDTO.getCurrentQuery().length() - 1, "-CN/GJ");

+ 26 - 2
src/main/java/cn/cslg/pas/service/importPatent/GetPatentFromExcelThread.java

@@ -26,11 +26,11 @@ import java.util.List;
 
 @Configurable
 public class GetPatentFromExcelThread extends Thread {
+
     private ImportTaskAMVO importTaskAMVO;
     private ApplicationContext applicationContext;
     private SavePatentToEsThread savePatentToEsThread;
 
-
     @Override
     public void run() {
         try {
@@ -88,6 +88,7 @@ public class GetPatentFromExcelThread extends Thread {
         Patent patent = uploadParamsVO.getPatent();
         String patentNo =patent.getPatentNo();
         String contry =patentNo.substring(0,2);
+        //装载标题
         if (uploadParamsVO.getTitle() != null) {
             List<Text> texts = new ArrayList<>();
             if (uploadParamsVO.getTitle().getName() != null) {
@@ -109,6 +110,29 @@ 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());
+                text.setIfOrigin(true);
+                text.setLanguage(contry);
+                texts.add(text);
+            }
+            if (uploadParamsVO.getAbstractStr().getNameOut() != null) {
+                Text text = new Text();
+                text.setTextContent(uploadParamsVO.getAbstractStr().getNameOut());
+                text.setIfOrigin(false);
+                text.setLanguage("CN");
+                texts.add(text);
+            }
+            if (texts.size() != 0) {
+                patent.setAbstractStr(texts);
+            }
+        }
+        }
         //如果是中国专利,就将申请号作为专利号
 //        if (patent.getPatentNo().contains("CN")) {
 //            patent.setPatentNo(patent.getAppNo());  //将申请号设为专利号patentNo
@@ -117,5 +141,5 @@ public class GetPatentFromExcelThread extends Thread {
 
         //装载权利要求
 
-    }
+
 }

+ 0 - 4
src/main/java/cn/cslg/pas/service/importPatent/TaskThread.java

@@ -30,8 +30,6 @@ public class TaskThread extends Thread {
     private final List<Integer> importTaskQueue = new ArrayList<>();
     private ImportTaskAMVO importTaskAMVO;
 
-
-
     /**
      * 从任务队列取出并执行任务
      */
@@ -62,7 +60,6 @@ public class TaskThread extends Thread {
 
 
     public void awakeTaskThread() {
-
         if (taskThreadLock.tryLock()) {
             //taskLock.lock();
             taskThreadCondition.signalAll();
@@ -77,6 +74,5 @@ public class TaskThread extends Thread {
     public ApplicationContext getApplicationContext() {
         return this.applicationContext;
     }
-    ;
 
 }

+ 115 - 18
src/main/java/cn/cslg/pas/service/query/FormatQueryService.java

@@ -110,9 +110,9 @@ public class FormatQueryService {
      * @param dtos
      * @return
      */
-    public String orderToString(List<OrderDTO> dtos,String tableName) {
+    public String orderToString(List<OrderDTO> dtos, String tableName) {
         //读取排序配置类
-        String json = CommonService.readJsonFile(tableName+".json");
+        String json = CommonService.readJsonFile(tableName + ".json");
         List<OrderConfig> configs = JSON.parseArray(json, OrderConfig.class);
         String re = "order by ";
         List<String> orders = new ArrayList<>();
@@ -124,8 +124,8 @@ public class FormatQueryService {
                 orders.add(order);
             }
         });
-        if(orders.size()==0){
-            return  "";
+        if (orders.size() == 0) {
+            return "";
         }
 
         String orderStr = StringUtils.join(orders, ",");
@@ -140,7 +140,7 @@ public class FormatQueryService {
      * @param node
      * @return
      */
-    public String ToString2(operateNode node, GetSqlObject getSqlObject,String tableName) {
+    public String ToString2(operateNode node, GetSqlObject getSqlObject, String tableName) {
         operate operate1 = node.getoperate();
         treeNode Left = node.getLeft();
         treeNode Right = node.getRight();
@@ -157,7 +157,7 @@ public class FormatQueryService {
         GetSqlObject getSqlObjectLocal = null;
         if (Left != null) {
             if ((operate1.gettype() == enuType.Logic || operate1.gettype() == enuType.Assignment) && (Left instanceof operateNode)) {
-                strCode = "(" + this.ToString2((operateNode) Left, getSqlObject,tableName) + ") " + strCode + " ";
+                strCode = "(" + this.ToString2((operateNode) Left, getSqlObject, tableName) + ") " + strCode + " ";
             } else {  //获得栏位名称
                 String field = Left.ToString();
 
@@ -166,7 +166,7 @@ public class FormatQueryService {
                 } else {
                     strCode = Left.ToString() + " " + strCode;
                     //判断 参数类型
-                    String json = CommonService.readJsonFile(tableName+".json");
+                    String json = CommonService.readJsonFile(tableName + ".json");
                     List<SqlObject> sqlObjects = JSON.parseArray(json, SqlObject.class);
                     SqlObject sqlObject = sqlObjects.stream().filter(item -> item.getValue().equals(field)).findFirst().orElse(null);
                     if (sqlObject != null) {
@@ -182,7 +182,7 @@ public class FormatQueryService {
         if (Right != null) {
             String rightValue = "";
             if ((operate1.gettype() == enuType.Logic || operate1.gettype() == enuType.Assignment) && (Right instanceof operateNode)) {
-                rightValue = this.ToString2((operateNode) Right, getSqlObject,tableName);
+                rightValue = this.ToString2((operateNode) Right, getSqlObject, tableName);
                 if (getSqlObject != null) {
                     return rightValue;
                 }
@@ -210,25 +210,26 @@ public class FormatQueryService {
      * @param queryRequest
      * @return
      */
-    public List<String> reSqls(QueryRequest queryRequest,String tableName) {
+    public List<String> reSqls(QueryRequest queryRequest, String tableName) {
         List<String> sqls = new ArrayList<>();
         String sql1 = "";
         String sql2 = "";
         String sql3 = "";
         //合成检索式
         StringRequest stringRequest = null;
+
         if (queryRequest instanceof MapRequest) {
 
         } else {
             stringRequest = (StringRequest) queryRequest;
         }
+
         String condition = stringRequest.getSearchQuery();
 
-        if(queryRequest.getGroupField()!=null){
-            if(condition!=null&&condition!="") {
+        if (queryRequest.getGroupField() != null) {
+            if (condition != null && condition != "") {
                 condition += " AND " + queryRequest.getGroupField() + "=" + queryRequest.getGroupFieldValue();
-            }
-            else {
+            } else {
                 condition = queryRequest.getGroupField() + "=" + queryRequest.getGroupFieldValue();
             }
         }
@@ -239,8 +240,7 @@ public class FormatQueryService {
                 //将检索式转换为二叉树
                 treeNode tree = expressManager.getInstance().Parse(condition, false);
                 //格式化检索式
-                sql1 = this.ToString2((operateNode) tree, null,tableName);
-
+                sql1 = this.ToString2((operateNode) tree, null, tableName);
             } catch (Exception e) {
                 throw new ConditionException("检索式错误");
             }
@@ -248,9 +248,8 @@ public class FormatQueryService {
 
         //格式化排序
         if (queryRequest.getOrderDTOList() != null && queryRequest.getOrderDTOList().size() != 0) {
-            String orderSql = this.orderToString(queryRequest.getOrderDTOList(),tableName);
+            String orderSql = this.orderToString(queryRequest.getOrderDTOList(), tableName);
             sql2 = orderSql;
-
         }
 
         //格式化 分页信息
@@ -262,10 +261,108 @@ public class FormatQueryService {
         }
 
         //格式化分组信息
-
         sqls.add(sql1);
         sqls.add(sql2);
         sqls.add(sql3);
         return sqls;
     }
+
+
+    public String webQueryToString(operateNode node, GetSqlObject getSqlObject, String tableName) {
+        operate operate1 = node.getoperate();
+        treeNode Left = node.getLeft();
+        treeNode Right = node.getRight();
+        String strCode = "";
+        String optionName = "";
+        if ((operate1.getShowName() != null)) {
+            if (operate1.getShowName().equals("AND")) {
+                operate1.setShowName("*");
+            } else if (operate1.getShowName().equals("OR")) {
+                operate1.setShowName("+");
+            } else if (operate1.getShowName().equals("NOT")) {
+                operate1.setShowName("-");
+            }
+            strCode = operate1.getShowName();
+            optionName = operate1.getShowName();
+        } else {
+            if (operate1.getCode().equals("AND")) {
+                operate1.setCode("*");
+            } else if (operate1.getCode().equals("OR")) {
+                operate1.setCode("+");
+            } else if (operate1.getCode().equals("NOT")) {
+                operate1.setCode("-");
+            }
+            strCode = operate1.getCode();
+            optionName = operate1.getCode();
+        }
+
+        GetSqlObject getSqlObjectLocal = null;
+        if (Left != null) {
+            if ((operate1.gettype() == enuType.Logic || operate1.gettype() == enuType.Assignment) && (Left instanceof operateNode)) {
+                strCode = "(" + this.webQueryToString((operateNode) Left, getSqlObject, tableName) + ")" + strCode;
+            } else {  //获得栏位名称
+                String field = Left.ToString();
+
+                if (getSqlObject != null) {
+                    strCode = getSqlObject.getSql(field) + strCode;
+                } else {
+                    strCode = Left.ToString() + strCode;
+                    //判断 参数类型
+                    String json = CommonService.readJsonFile(tableName + ".json");
+                    List<SqlObject> sqlObjects = JSON.parseArray(json, SqlObject.class);
+                    SqlObject sqlObject = sqlObjects.stream().filter(item -> item.getValue().equals(field)).findFirst().orElse(null);
+                    if (sqlObject != null) {
+                        getSqlObjectLocal = getSqlFactory.getClass(sqlObject.getSqlClass());
+                        sqlObject.setOption(optionName);
+                        getSqlObjectLocal.setSqlObject(sqlObject);
+                        getSqlObject = getSqlObjectLocal;
+                    }
+                }
+            }
+
+        }
+        if (Right != null) {
+            String rightValue = "";
+            if ((operate1.gettype() == enuType.Logic || operate1.gettype() == enuType.Assignment) && (Right instanceof operateNode)) {
+                if (((operateNode) Right).getoperate().getCode().equals("~")) {
+                    rightValue = this.webQueryToString((operateNode) Right, null, tableName);
+                    strCode = getSqlObject.getSql(rightValue);
+                } else {
+                    rightValue = this.webQueryToString((operateNode) Right, getSqlObject, tableName);
+                    if (getSqlObject != null) {
+                        return rightValue;
+                    }
+                    strCode = strCode + "(" + rightValue + ")";
+                }
+
+            } else {
+                if (getSqlObjectLocal != null) {
+                    rightValue = Right.ToString();
+                    strCode = getSqlObject.getSql(rightValue);
+                } else if (getSqlObject != null) {
+                    rightValue = Right.ToString();
+                    strCode = strCode + getSqlObject.getSql(rightValue);
+                } else if (!(Left instanceof operateNode)) {
+                    rightValue = Right.ToString();
+                    strCode +=rightValue;
+                }
+            }
+        }
+        return strCode;
+    }
+
+    public String reQuery(String query, String configName) {
+
+        //将检索式转换为二叉树
+        treeNode tree = null;
+        try {
+            tree = expressManager.getInstance().Parse(query, false);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        //格式化检索式
+        String reQuery = this.webQueryToString((operateNode) tree, null, configName);
+
+        return reQuery;
+    }
 }

+ 369 - 0
src/main/resources/jsons/webSearchConfig.json

@@ -0,0 +1,369 @@
+[
+  {
+    "name": "TX",
+    "type": "Integer",
+    "value": "TX",
+    "field": "TX",
+    "sqlField": "TX",
+    "sqlClass": "getWebQuerySql",
+    "orderClass": "",
+    "groupClass": "",
+    "ifSearch": "true",
+    "ifGroup": "false",
+    "ifShow": "false"
+  },
+  {
+    "name": "TI",
+    "type": "Integer",
+    "value": "TI",
+    "field": "TI",
+    "sqlField": "TI",
+    "sqlClass": "getWebQuerySql",
+    "orderClass": "",
+    "groupClass": "",
+    "ifSearch": "true",
+    "ifGroup": "false",
+    "ifShow": "false"
+  },
+  {
+    "name": "CL",
+    "type": "Integer",
+    "value": "CL",
+    "field": "CL",
+    "sqlField": "CL",
+    "sqlClass": "getWebQuerySql",
+    "orderClass": "",
+    "groupClass": "",
+    "ifSearch": "true",
+    "ifGroup": "false",
+    "ifShow": "false"
+  },
+  {
+    "name": "AB",
+    "type": "Integer",
+    "value": "AB",
+    "field": "AB",
+    "sqlField": "AB",
+    "sqlClass": "getWebQuerySql",
+    "orderClass": "",
+    "groupClass": "",
+    "ifSearch": "true",
+    "ifGroup": "false",
+    "ifShow": "false"
+  },
+  {
+    "name": "AN",
+    "type": "Integer",
+    "value": "AN",
+    "field": "AN",
+    "sqlField": "AN",
+    "sqlClass": "getWebQuerySql",
+    "orderClass": "",
+    "groupClass": "",
+    "ifSearch": "true",
+    "ifGroup": "false",
+    "ifShow": "false"
+  },
+  {
+    "name": "ANO",
+    "type": "Integer",
+    "value": "ANO",
+    "field": "ANO",
+    "sqlField": "TX",
+    "sqlClass": "getWebQuerySql",
+    "orderClass": "",
+    "groupClass": "",
+    "ifSearch": "true",
+    "ifGroup": "false",
+    "ifShow": "false"
+  },
+  {
+    "name": "GN",
+    "type": "Integer",
+    "value": "GN",
+    "field": "GN",
+    "sqlField": "GN",
+    "sqlClass": "getWebQuerySql",
+    "orderClass": "",
+    "groupClass": "",
+    "ifSearch": "true",
+    "ifGroup": "false",
+    "ifShow": "false"
+  }
+  ,
+  {
+    "name": "PN",
+    "type": "Integer",
+    "value": "PN",
+    "field": "PN",
+    "sqlField": "PN",
+    "sqlClass": "getWebQuerySql",
+    "orderClass": "",
+    "groupClass": "",
+    "ifSearch": "true",
+    "ifGroup": "false",
+    "ifShow": "false"
+  },
+  {
+    "name": "PR",
+    "type": "Integer",
+    "value": "PR",
+    "field": "PR",
+    "sqlField": "PR",
+    "sqlClass": "getWebQuerySql",
+    "orderClass": "",
+    "groupClass": "",
+    "ifSearch": "true",
+    "ifGroup": "false",
+    "ifShow": "false"
+  },
+  {
+    "name": "PT",
+    "type": "Integer",
+    "value": "PT",
+    "field": "PT",
+    "sqlField": "PT",
+    "sqlClass": "getWebQuerySql",
+    "orderClass": "",
+    "groupClass": "",
+    "ifSearch": "true",
+    "ifGroup": "false",
+    "ifShow": "false"
+  },
+  {
+    "name": "LG",
+    "type": "Integer",
+    "value": "LG",
+    "field": "LG",
+    "sqlField": "LG",
+    "sqlClass": "getWebQuerySql",
+    "orderClass": "",
+    "groupClass": "",
+    "ifSearch": "true",
+    "ifGroup": "false",
+    "ifShow": "false"
+  },
+  {
+    "name": "IC",
+    "type": "Integer",
+    "value": "IC",
+    "field": "IC",
+    "sqlField": "IC",
+    "sqlClass": "getWebQuerySql",
+    "orderClass": "",
+    "groupClass": "",
+    "ifSearch": "true",
+    "ifGroup": "false",
+    "ifShow": "false"
+  },
+  {
+    "name": "MC",
+    "type": "Integer",
+    "value": "MC",
+    "field": "MC",
+    "sqlField": "MC",
+    "sqlClass": "getWebQuerySql",
+    "orderClass": "",
+    "groupClass": "",
+    "ifSearch": "true",
+    "ifGroup": "false",
+    "ifShow": "false"
+  },
+  {
+    "name": "CT",
+    "type": "Integer",
+    "value": "CT",
+    "field": "CT",
+    "sqlField": "CT",
+    "sqlClass": "getWebQuerySql",
+    "orderClass": "",
+    "groupClass": "",
+    "ifSearch": "true",
+    "ifGroup": "false",
+    "ifShow": "false"
+  },
+  {
+    "name": "AD",
+    "type": "Integer",
+    "value": "AD",
+    "field": "AD",
+    "sqlField": "AD",
+    "sqlClass": "getWebQuerySql",
+    "orderClass": "",
+    "groupClass": "",
+    "ifSearch": "true",
+    "ifGroup": "false",
+    "ifShow": "false"
+  },
+  {
+    "name": "GD",
+    "type": "Integer",
+    "value": "GD",
+    "field": "GD",
+    "sqlField": "GD",
+    "sqlClass": "getWebQuerySql",
+    "orderClass": "",
+    "groupClass": "",
+    "ifSearch": "true",
+    "ifGroup": "false",
+    "ifShow": "false"
+  },
+  {
+    "name": "PD",
+    "type": "Integer",
+    "value": "PD",
+    "field": "PD",
+    "sqlField": "PD",
+    "sqlClass": "getWebQuerySql",
+    "orderClass": "",
+    "groupClass": "",
+    "ifSearch": "true",
+    "ifGroup": "false",
+    "ifShow": "false"
+  }
+,
+  {
+    "name": "IN",
+    "type": "Integer",
+    "value": "IN",
+    "field": "IN",
+    "sqlField": "IN",
+    "sqlClass": "getWebQuerySql",
+    "orderClass": "",
+    "groupClass": "",
+    "ifSearch": "true",
+    "ifGroup": "false",
+    "ifShow": "false"
+  },
+  {
+    "name": "FI",
+    "type": "Integer",
+    "value": "FI",
+    "field": "FI",
+    "sqlField": "FI",
+    "sqlClass": "getWebQuerySql",
+    "orderClass": "",
+    "groupClass": "",
+    "ifSearch": "true",
+    "ifGroup": "false",
+    "ifShow": "false"
+  },
+  {
+    "name": "PA",
+    "type": "Integer",
+    "value": "PA",
+    "field": "PA",
+    "sqlField": "PA",
+    "sqlClass": "getWebQuerySql",
+    "orderClass": "",
+    "groupClass": "",
+    "ifSearch": "true",
+    "ifGroup": "false",
+    "ifShow": "false"
+  },
+  {
+    "name": "FP",
+    "type": "Integer",
+    "value": "FP",
+    "field": "FP",
+    "sqlField": "FP",
+    "sqlClass": "getWebQuerySql",
+    "orderClass": "",
+    "groupClass": "",
+    "ifSearch": "true",
+    "ifGroup": "false",
+    "ifShow": "false"
+  },
+  {
+    "name": "PE",
+    "type": "Integer",
+    "value": "PE",
+    "field": "PE",
+    "sqlField": "PE",
+    "sqlClass": "getWebQuerySql",
+    "orderClass": "",
+    "groupClass": "",
+    "ifSearch": "true",
+    "ifGroup": "false",
+    "ifShow": "false"
+  },
+  {
+    "name": "AT",
+    "type": "Integer",
+    "value": "AT",
+    "field": "AT",
+    "sqlField": "AT",
+    "sqlClass": "getWebQuerySql",
+    "orderClass": "",
+    "groupClass": "",
+    "ifSearch": "true",
+    "ifGroup": "false",
+    "ifShow": "false"
+  },
+  {
+    "name": "AGN",
+    "type": "Integer",
+    "value": "AGN",
+    "field": "AGN",
+    "sqlField": "AGN",
+    "sqlClass": "getWebQuerySql",
+    "orderClass": "",
+    "groupClass": "",
+    "ifSearch": "true",
+    "ifGroup": "false",
+    "ifShow": "false"
+  },
+  {
+    "name": "DZ",
+    "type": "Integer",
+    "value": "DZ",
+    "field": "DZ",
+    "sqlField": "DZ",
+    "sqlClass": "getWebQuerySql",
+    "orderClass": "",
+    "groupClass": "",
+    "ifSearch": "true",
+    "ifGroup": "false",
+    "ifShow": "false"
+  },
+  {
+    "name": "CO",
+    "type": "Integer",
+    "value": "CO",
+    "field": "CO",
+    "sqlField": "CO",
+    "sqlClass": "getWebQuerySql",
+    "orderClass": "",
+    "groupClass": "",
+    "ifSearch": "true",
+    "ifGroup": "false",
+    "ifShow": "false"
+  }
+,
+  {
+    "name": "CC",
+    "type": "Integer",
+    "value": "CC",
+    "field": "CC",
+    "sqlField": "CC",
+    "sqlClass": "getWebQuerySql",
+    "orderClass": "",
+    "groupClass": "",
+    "ifSearch": "true",
+    "ifGroup": "false",
+    "ifShow": "false"
+  },
+  {
+    "name": "UCC",
+    "type": "Integer",
+    "value": "UCC",
+    "field": "UCC",
+    "sqlField": "UCC",
+    "sqlClass": "getWebQuerySql",
+    "orderClass": "",
+    "groupClass": "",
+    "ifSearch": "true",
+    "ifGroup": "false",
+    "ifShow": "false"
+  }
+]

+ 9 - 1
src/test/java/cn/cslg/pas/service/CommonServiceTests.java

@@ -3,6 +3,7 @@ package cn.cslg.pas.service;
 import cn.cslg.pas.common.model.common.QueryCondition;
 import cn.cslg.pas.common.model.request.QueryRequest;
 import cn.cslg.pas.common.model.request.StringRequest;
+import cn.cslg.pas.common.utils.FormatUtil;
 import cn.cslg.pas.common.utils.MathUtils;
 import cn.cslg.pas.common.utils.Response;
 import cn.cslg.pas.common.vo.DepartmentVO;
@@ -13,6 +14,7 @@ import cn.cslg.pas.domain.business.Matter;
 import cn.cslg.pas.service.business.CommonService;
 import cn.cslg.pas.service.importPatent.SchedulingTaskService;
 import cn.cslg.pas.service.permissions.PermissionService;
+import cn.cslg.pas.service.query.FormatQueryService;
 import com.alibaba.druid.sql.visitor.functions.Char;
 import com.alibaba.fastjson.JSON;
 import org.assertj.core.internal.Arrays;
@@ -37,6 +39,8 @@ public class CommonServiceTests {
     private CommonController commonController;
     @Autowired
     private SchedulingTaskService schedulingTaskService;
+    @Autowired
+    private FormatQueryService formatQueryService;
     @Test
     void test() throws Exception {
      String aa=   permissionService.getPersonIdByNamePCS("朱",false);
@@ -86,6 +90,10 @@ public class CommonServiceTests {
     System.out.println(a);
     System.out.println(ab);
     }
-
+    @Test
+    void reQuerys()  {
+   String re =formatQueryService.reQuery("TX=泳池","webSearchConfig");
+   System.out.println(re);
+    }
 
 }

+ 69 - 0
src/test/java/cn/cslg/pas/service/PatentStarServiceTests.java

@@ -0,0 +1,69 @@
+package cn.cslg.pas.service;
+
+import cn.cslg.pas.common.dto.PatentStarListDTO;
+import cn.cslg.pas.common.utils.FormatUtil;
+import cn.cslg.pas.common.utils.RedisUtil;
+import cn.cslg.pas.common.vo.PatentWithIdVO;
+import cn.cslg.pas.controller.outApi.PatentStarController;
+import cn.cslg.pas.domain.es.Patent;
+import cn.cslg.pas.service.business.es.EsService;
+import cn.cslg.pas.service.common.PatentStarApiService;
+import cn.cslg.pas.service.importPatent.SchedulingTaskService;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author chenyu
+ * @date 2023/9/6
+ */
+@SpringBootTest
+public class PatentStarServiceTests {
+    @Autowired
+    private EsService esService;
+
+    @Autowired
+    private RedisUtil redisUtil;
+
+    @Autowired
+    private SchedulingTaskService importTaskAdd;
+    @Autowired
+    private PatentStarApiService patentStarApiService;
+    @Test
+    void addPatent() throws Exception {
+        PatentStarListDTO patentStarListDTO =new PatentStarListDTO();
+        patentStarListDTO.setCurrentQuery(" GD=(A OR B OR C)");
+        patentStarListDTO.setDBType("CN");
+        patentStarListDTO.setOrderBy("AD");
+        patentStarListDTO.setPageNum(1);
+        patentStarListDTO.setRowCount(10);
+        patentStarListDTO.setOrderByType("DESC");
+     Map<String,Object> map = patentStarApiService.patentStarSearchLocal(patentStarListDTO);
+     System.out.println(map);
+    }
+
+    @Test
+    void getPatentByPatentNo() throws  Exception {
+        //根据专利号获得id
+        PatentWithIdVO patentWithIdVO  = esService.getIdByPatentNo("CN201114765Y");
+        Patent patent =new Patent();
+        patent.setAgency("张三");
+        Patent orgPatent =patentWithIdVO.getPatent();
+        BeanUtils.copyProperties(patent,orgPatent, FormatUtil.getNullPropertyNames(patent));
+          esService.updateDocument(orgPatent,patentWithIdVO.getId());
+    }
+
+    @Test
+    void updatePatent() throws Exception{}
+
+    @Test
+    void addImportTask() throws  Exception {
+        List<Patent> patentList = esService.searchChild("1",1,10);
+        System.out.println(patentList);
+        Thread.sleep(1000000);
+    }
+}