瀏覽代碼

Merge remote-tracking branch 'origin/master' into test

lrj 6 月之前
父節點
當前提交
361c26f5ff

+ 121 - 0
src/main/java/com/example/xiaoshiweixinback/business/utils/commonUtil/FormatUtil.java

@@ -0,0 +1,121 @@
+package com.example.xiaoshiweixinback.business.utils.commonUtil;
+
+
+import org.springframework.beans.BeanWrapper;
+import org.springframework.beans.BeanWrapperImpl;
+
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+public class FormatUtil {
+
+    private List<String> s;
+    private List<String> strs;
+
+    public static String toString(Object o) {
+        return o == null ? "" : o.toString();
+    }
+
+    public static String MD5(String src) {
+        // 需要加密的字符串
+        try {
+            // 加密对象,指定加密方式
+            MessageDigest md5 = MessageDigest.getInstance("md5");
+            // 准备要加密的数据
+            byte[] b = src.getBytes();
+            // 加密
+            byte[] digest = md5.digest(b);
+            // 十六进制的字符
+            char[] chars = new char[]{'0', '1', '2', '3', '4', '5',
+                    '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
+            StringBuffer sb = new StringBuffer();
+            // 处理成十六进制的字符串(通常)
+            for (byte bb : digest) {
+                sb.append(chars[(bb >> 4) & 15]);
+                sb.append(chars[bb & 15]);
+            }
+            return sb.toString();
+        } catch (NoSuchAlgorithmException e) {
+            e.printStackTrace();
+        }
+        return "";
+    }
+
+    public static String[] getNullPropertyNames(Object source) {
+        final BeanWrapper src = new BeanWrapperImpl(source);
+        java.beans.PropertyDescriptor[] pds = src.getPropertyDescriptors();
+        Set emptyNames = new HashSet();
+        for (java.beans.PropertyDescriptor pd : pds) {
+            //check if value of this property is null then add it to the collection
+            Object srcValue = src.getPropertyValue(pd.getName());
+            if (srcValue == null) {//特定字符写在此处过滤,收集不需要copy的字段列表。此处过滤null为例
+                emptyNames.add(pd.getName());
+            }
+        }
+        String[] result = new String[emptyNames.size()];
+        return (String[]) emptyNames.toArray(result);
+
+
+    }
+
+    public static String getPictureFormat(String appAn) {
+        return appAn + "_p";
+
+    }
+
+    public static String getPDFFormat(String appAn, Integer type) {
+        if (type.equals(0)) {
+            return appAn + "_public";
+        } else {
+            return appAn + "_grant";
+        }
+    }
+
+    public static List<String> getDistinctList(List<String> a, List<String> b) {
+        if (a == null || a.size() == 0 &&(b==null||b.size()==0)) {
+            return null;
+        } else if (b == null || b.size() == 0) {
+            return  new ArrayList<>(a);
+        }
+        else if(a==null||a.size()==0){
+            return new ArrayList<>(b);
+        }
+        a.addAll(b);
+        List<String> newList = new ArrayList<>(new HashSet<>(a));
+        return newList;
+    }
+
+
+    public static List<Integer> StringTOIntegerList(List<String> strs) {
+        List<Integer> integers =new ArrayList<>();
+        strs.forEach(item->{
+            integers.add(Integer.parseInt(item));
+        });
+        return  integers;
+    }
+
+    public static List<String> IntegerTOStringList(List<Integer> integers) {
+        List<String> strs =new ArrayList<>();
+        integers.forEach(item->{
+            strs.add(item.toString());
+        });
+        return  strs;
+    }
+    public static List<Integer> StringTOIntegerList(String str,String regex) {
+        List<Integer> reInteger =new ArrayList<>();
+        if (str==null||str.trim().equals("")){
+             return  reInteger;
+        }
+        String[] strings =str.split(regex);
+
+        for (int i=0;i<strings.length;i++){
+            reInteger.add(Integer.parseInt(strings[i]));
+        }
+
+        return  reInteger;
+    }
+}

+ 447 - 0
src/main/java/com/example/xiaoshiweixinback/business/utils/parseQueryToTree/ExpressTreeNode.java

@@ -0,0 +1,447 @@
+package com.example.xiaoshiweixinback.business.utils.parseQueryToTree;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Stack;
+
+public class ExpressTreeNode {
+
+
+    public static treeNode Tokens2Node(List<String> Tokens, boolean isAnd)throws Exception
+
+    {
+
+        Stack<Symbol> symbolStack = new Stack<Symbol>();
+
+        Stack<treeNode> valueStack = new Stack<treeNode>();
+
+
+
+        boolean preIsValue = false;
+
+        for (int i = 0; i < Tokens.size(); i++)
+
+        {
+
+            String strTem = Tokens.get(i);
+
+
+
+            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);
+
+
+
+                            symbolStack.pop();
+
+
+
+                            if (symbolStack.size() > 0)
+
+                            {
+
+                                lastSymbol = symbolStack.peek();
+
+                            }
+
+                            else
+
+                            {
+
+                                break;
+
+                            }
+
+                        }
+
+                    }
+
+
+
+
+
+                    symbolStack.push(temSymbol);
+                    preIsValue = false;
+                }
+                    else
+
+                {
+
+                    if (temSymbol instanceof pairSymbol && ((pairSymbol)temSymbol).isEndSymbol == false)
+
+                    {
+
+                        List<String> strings = new ArrayList<>();
+
+
+
+                        int zkh = 1;
+
+                        for(int j = i+1; j < Tokens.size(); j++)
+
+                        {
+
+                            String s = Tokens.get(j);
+
+
+
+                            Symbol sysTem = expressManager.getInstance().getSymbol(s);
+
+
+
+                            if(sysTem != null)
+
+                            {
+
+                                if (sysTem instanceof pairSymbol)
+
+                                {
+
+                                    if (((pairSymbol)sysTem).isEndSymbol)
+
+                                    {
+
+                                        zkh--;
+
+                                    }
+
+                                    else
+
+                                    {
+
+                                        zkh++;
+
+                                    }
+
+                                }
+
+
+
+                            }
+
+
+
+                            if(zkh == 0)
+
+                            {
+
+                                break ;
+
+                            }
+
+                            else
+
+                            {
+
+                                strings.add(s);
+
+                            }
+
+
+
+                        }
+
+
+
+                        if(zkh == 0)
+
+                        {
+
+                            valueStack.push(Tokens2Node(strings, isAnd));
+
+                            preIsValue = true;
+
+                            i = i + strings.size() +1;
+
+                        }
+
+                    }
+
+                }
+
+            }
+
+            else
+
+            {
+
+                if(preIsValue && symbolStack.size() > 0)
+
+                {
+
+                    if (symbolStack.size() > 0)
+
+                    {
+
+                        Symbol lastSymbol = symbolStack.pop();
+
+
+
+                        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);
+
+
+
+                    }
+
+
+
+                }
+
+
+
+                valueNode  temNode = new valueNode();
+
+                temNode.value = strTem;
+
+                valueStack.push(temNode);
+
+                preIsValue = true;
+
+            }
+
+
+
+        }
+
+
+
+        while (symbolStack.size() > 0)
+
+        {
+
+            Symbol temSymbol = symbolStack.pop();
+
+
+
+            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();
+
+                }
+
+
+
+                valueStack.push(temNode);
+
+
+
+            }
+
+                else
+
+            {
+
+                throw new Exception("无效的括号!");
+
+            }
+
+        }
+
+
+
+
+
+        if (valueStack.size() ==1)
+
+        {
+
+            return valueStack.pop();
+
+
+
+        }
+
+        else
+
+        {
+
+            if (valueStack.size() > 1)
+
+            {
+
+                List<treeNode> lstValues = new ArrayList<>();
+
+
+
+                while (valueStack.size() > 0)
+
+                {
+
+                    treeNode temNode = valueStack.pop();
+
+
+
+                    lstValues.add(0, temNode);
+
+                }
+
+
+
+                treeNode retNode = null;
+
+
+
+                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;
+
+                    }
+
+                }
+
+
+
+                return retNode;
+
+            }
+
+
+
+            throw new Exception("无效的检索式!");
+
+        }
+
+
+
+    }
+
+}

+ 204 - 182
src/main/java/com/example/xiaoshiweixinback/business/utils/parseQueryToTree/expressManager.java

@@ -1,5 +1,9 @@
 package com.example.xiaoshiweixinback.business.utils.parseQueryToTree;
 
+
+
+import com.example.xiaoshiweixinback.business.utils.StringUtils;
+
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -32,8 +36,8 @@ public class expressManager {
         oOR.Code = "NOT";
         oOR.ShowName = "NOT";
         oOR.type = enuType.Logic;
-        oOR.priorityVale = 11;
-        oOR.operateValue = 2;
+        oOR.priorityVale = 12;
+        oOR.operateValue = 1;
         hSymbols.put(oOR.Code, oOR);
 
         oOR = new operate();
@@ -44,13 +48,6 @@ public class expressManager {
         oOR.operateValue = 2;
         hSymbols.put(oOR.Code, oOR);
 
-        oOR = new operate();
-        oOR.Code = "~";
-        oOR.ShowName = "TO";
-        oOR.type = enuType.Logic;
-        oOR.priorityVale = 21;
-        oOR.operateValue = 2;
-        hSymbols.put(oOR.Code, oOR);
 
         oOR = new operate();
         oOR.Code = "=";
@@ -148,21 +145,8 @@ public class expressManager {
 
     public Symbol getSymbol(String strSymbol) {
         String strKey = strSymbol.trim().toUpperCase();
-        if ((strKey != null && !strKey.trim().equals(""))) {
-            if (hSymbols.containsKey(strKey)) {
-                return hSymbols.get(strKey);
-            } else if (strKey.matches("\\$W[0-9]+")) {
-                operate tem = new operate();
-                tem = new operate();
-                tem.Code = strKey;
-                tem.ShowName = strKey;
-                tem.type = enuType.Assignment;
-                tem.priorityVale = 24;
-                tem.operateValue = 2;
-                return tem;
-            } else {
-                return null;
-            }
+        if ((strKey != null && !strKey.trim().equals("")) && hSymbols.containsKey(strKey)) {
+            return hSymbols.get(strKey);
         } else {
             return null;
         }
@@ -178,147 +162,167 @@ public class expressManager {
         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);
-
-                            symbolStack.pop();
-
-                            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;
-
-                            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();
-                        }
-
-                        if ((lastSymbol instanceof pairSymbol && ((pairSymbol) temSymbol).previewSymbol.Code == ((pairSymbol) lastSymbol).Code)) {
-                            symbolStack.pop();
-                        } else {
-                            throw new Exception("无效的括号");
-                        }
-
-                    } else {
-                        symbolStack.push(temSymbol);
-                    }
-                    //#endregion
-                }
-            } else {
-                valueNode temNode = new valueNode();
-                temNode.value = strTem;
-
-                valueStack.push(temNode);
-            }
-        }
-
-        while (symbolStack.size() > 0) {
-            Symbol temSymbol = symbolStack.pop();
-
-            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();
-                }
-
-                valueStack.push(temNode);
-
-            } else {
-                throw new Exception("无效的括号!");
-            }
-        }
-
-        if (valueStack.size() == 1) {
-            return valueStack.pop();
-        } else {
-
-            if (valueStack.size() > 1) {
-                List<treeNode> lstValues = new ArrayList<treeNode>();
-
-                while (valueStack.size() > 0) {
-                    treeNode temNode = valueStack.pop();
-
-                    if (temNode instanceof valueNode) {
-                        lstValues.add(temNode);
-                    } else {
-                        throw new Exception("无效的检索式!");
-                    }
-                }
-
-                treeNode retNode = null;
-
-                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;
-                    }
-                }
-
-                return retNode;
-            }
-
-            throw new Exception("无效的检索式!");
-
-        }
+        List<String> middleKuoHaoStrs = new ArrayList<>();
+            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("]")))) {
+//                middleKuoHaoStrs.add(strTem);
+//            } else 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);
+//
+//                            symbolStack.pop();
+//
+//                            if (symbolStack.size() > 0) {
+//                                lastSymbol = symbolStack.peek();
+//                            } else {
+//                                break;
+//                            }
+//                        }
+//                    }
+//                    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, ",");
+//                        valueNode temNode = new valueNode();
+//                        temNode.value = temp;
+//                        valueStack.push(temNode);
+//                        middleKuoHaoStrs = new ArrayList<>();
+//                    }
+//
+//                    //#region 括号处理
+//                    else 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;
+//
+//                            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();
+//                        }
+//
+//                        if ((lastSymbol instanceof pairSymbol && ((pairSymbol) temSymbol).previewSymbol.Code == ((pairSymbol) lastSymbol).Code)) {
+//                            symbolStack.pop();
+//                        } else {
+//                            throw new Exception("无效的括号");
+//                        }
+//
+//                    } else {
+//                        symbolStack.push(temSymbol);
+//                    }
+//                    //#endregion
+//                }
+//            } else {
+//                if (!ifFindEndingMiddleKuoHaoStrs) {
+//                    valueNode temNode = new valueNode();
+//                    temNode.value = strTem;
+//
+//                    valueStack.push(temNode);
+//                } else {
+//                    middleKuoHaoStrs.add(strTem);
+//                }
+//            }
+//        }
+//
+//        while (symbolStack.size() > 0) {
+//            Symbol temSymbol = symbolStack.pop();
+//
+//            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();
+//                }
+//
+//                valueStack.push(temNode);
+//
+//            } else {
+//                throw new Exception("无效的括号!");
+//            }
+//        }
+//
+//        if (valueStack.size() == 1) {
+//            return valueStack.pop();
+//        } else {
+//
+//            if (valueStack.size() > 1) {
+//                List<treeNode> lstValues = new ArrayList<treeNode>();
+//
+//                while (valueStack.size() > 0) {
+//                    treeNode temNode = valueStack.pop();
+//
+//                    if (temNode instanceof valueNode) {
+//                        lstValues.add(temNode);
+//                    } else {
+//                        throw new Exception("无效的检索式!");
+//                    }
+//                }
+//
+//                treeNode retNode = null;
+//
+//                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;
+//                    }
+//                }
+//
+//                return retNode;
+//            }
+//
+//            throw new Exception("无效的检索式!");
+//
+//        }
     }
 
 
@@ -336,11 +340,14 @@ public class expressManager {
 
             String strTemToken = "";
             Boolean isFindingEndYinHao = 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;
@@ -357,6 +364,7 @@ public class expressManager {
                             }
 
                         }
+
                         break;
                     case ' ':
                         if (!isFindingEndYinHao) {
@@ -372,33 +380,46 @@ public class expressManager {
                         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;
+                        if (!isFindingEndYinHao) {
+                            if (step == (i - 1)) {
+                                Tokens.add(String.valueOf(c));
+                                step = i;
+                            } else {
+                                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);
-                                }
+                        if (!isFindingEndYinHao) {
+                            if (step == (i - 1)) {
                                 Tokens.add(String.valueOf(c));
                                 step = i;
+                            } else {
+                                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;
+                                    }
+                                }
                             }
                         }
                         break;
                     case '=':
-                    case '~':
                     case '>':
                     case '>':
                     case '<':
@@ -430,4 +451,5 @@ public class expressManager {
             return null;
         }
     }
+
 }

+ 1 - 1
src/main/java/com/example/xiaoshiweixinback/controller/PatentController.java

@@ -114,7 +114,7 @@ public class PatentController {
     @Operation(summary = "根据专利号获取相关图片--zero")
     @PostMapping(value = "/getPictureByNo")
     public Response getPictureByNo(@RequestBody EsPictureNoDTO pictureNoDTO) throws Exception {
-        List<EsPictureNoVo> pictureByNo = esDenseVectorService.getPictureByNo(pictureNoDTO);
+        List<EsPictureNoVo> pictureByNo = esDenseVectorService.getPictureByNo3(pictureNoDTO);
         return Response.success(pictureByNo);
     }
 

+ 1 - 1
src/main/java/com/example/xiaoshiweixinback/controller/TemplateController.java

@@ -29,7 +29,7 @@ public class TemplateController {
 
     @Operation(summary = "导入产品")
     @PostMapping("/getTemplate")
-    private Response importProduct(@RequestBody TemplateDTO templateDTO) throws Exception {
+    public Response importProduct(@RequestBody TemplateDTO templateDTO) throws Exception {
        List<TemplateVO> templateVOList= templateService.getTemplate(templateDTO);
         Records records =new Records();
         records.setData(templateVOList);

+ 17 - 22
src/main/java/com/example/xiaoshiweixinback/service/ProductCategoryService.java

@@ -213,11 +213,8 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
                 level = parentCategory.getLevel();
             }
             category.setLevel(level + 1);
-            if (parentCategory.getParentId() != 0) {
-                category.setPath(this.getPath(parentCategory.getParentId()) + "/" + parentCategory.getId() + "/");
-            } else {
-                category.setPath(parentCategory.getId() + "/");
-            }
+            category.setPath(this.getPath(parentCategory));
+
         } else {
             category.setParentId(0);
             category.setLevel(1);
@@ -272,11 +269,9 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
                 level = parentCategory.getLevel();
             }
             category.setLevel(level + 1);
-            if (parentCategory.getParentId() != 0) {
-                category.setPath(this.getPath(parentCategory.getParentId()) + "/" + parentCategory.getId() + "/");
-            } else {
-                category.setPath(parentCategory.getId() + "/");
-            }
+
+                category.setPath(this.getPath(parentCategory));
+
             this.getParentPath(category.getId(), category.getPath(), category.getLevel());
         } else {
             Integer parentId = category.getParentId();
@@ -496,21 +491,21 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
     /**
      * 获取路径
      *
-     * @param parentId
+     * @param
      * @return
      */
-    public String getPath(Integer parentId) {
-        String s = "";
-        ProductCategory parentCategory = this.getById(parentId);
-        if (ToolUtil.isNotEmpty(parentCategory)) {
-            if (parentCategory.getParentId() != 0) {
-                String pathId = this.getPath(parentCategory.getParentId());
-                s = s + "/" + pathId;
-            } else {
-                s = parentCategory.getId().toString();
+    public String getPath(ProductCategory parentCategory) {
+            String s = "";
+            if (ToolUtil.isNotEmpty(parentCategory)) {
+                if (parentCategory.getParentId() != 0) {
+                    String pathId = parentCategory.getPath()+parentCategory.getId()+"/";
+                    s=pathId;
+                } else {
+                    s = parentCategory.getId().toString()+"/";
+                }
             }
-        }
-        return s;
+            return s;
+
     }
 
     /**

+ 103 - 4
src/main/java/com/example/xiaoshiweixinback/service/importPatent/EsDenseVectorService.java

@@ -96,7 +96,7 @@ public class EsDenseVectorService {
     private EsPatentService esPatentService;
 
     @Autowired
-    private VipService vipService;
+    private PatentStarApiService patentStarApiService;
 
     @Autowired
     private RedisService redisService;
@@ -104,7 +104,8 @@ public class EsDenseVectorService {
     private String patentVectorName;
     @Value("${ES.patent}")
     private String patentMapName;
-
+    @Value("${ImageHttp}")
+    private String imageHttp;
     private final UseFunctionFactory useFunctionFactory;
     private final UseFunctionRecordService useFunctionRecordService;
     private static String FACTORY_CLASS = "checkQueryPatent";
@@ -134,7 +135,7 @@ public class EsDenseVectorService {
         }
 
         if (size != -1L && allNum > size) {
-            if (assoVipFunction==null||assoVipFunction.getVipType()==null||assoVipFunction.getVipType().equals(0)) {
+            if (assoVipFunction == null || assoVipFunction.getVipType() == null || assoVipFunction.getVipType().equals(0)) {
                 throw new BusinessException(ExceptionEnum.PERMISSION_NO_VIP, "未开通vip");
             } else {
                 throw new BusinessException(ExceptionEnum.PERMISSION_BEYOND_USETIME, "超过可查看专利数量");
@@ -247,7 +248,7 @@ public class EsDenseVectorService {
         builder.index(patentVectorName);
         Query query = QueryBuilders.term(i -> i.field("app_no").value(noDTO.getAppNo()));
         builder.query(query);
-        builder.size(30);
+        builder.size(300);
         SearchResponse<PatentVector> response = client.search(builder.build(), PatentVector.class);
         List<Hit<PatentVector>> hits = response.hits().hits();
         for (Hit<PatentVector> hit : hits) {
@@ -462,4 +463,102 @@ public class EsDenseVectorService {
         return records;
     }
 
+    /**
+     * 根据专利号获取相关图片
+     *
+     * @param noDTO
+     * @return
+     * @throws IOException
+     */
+    public List<EsPictureNoVo> getPictureByNo2(EsPictureNoDTO noDTO) throws Exception {
+        List<EsPictureNoVo> pictureNoVos = new ArrayList<>();
+        String no = noDTO.getAppNo();
+        if (no.startsWith("CN")) {
+            no = no.substring(2, 14);
+            System.out.println(no);
+            List<String> list = new ArrayList<>();
+            String wgPictureApi = patentStarApiService.getWGPictureApi(no);
+            if (StringUtils.isNotEmpty(wgPictureApi)) {
+                if (wgPictureApi.contains("|http")) {
+                    String[] urlArr = wgPictureApi.split("\\|");
+                    list.addAll(Arrays.asList(urlArr));
+                } else {
+                    list.add(wgPictureApi);
+                }
+            }
+            for (int i = 0; i < list.size(); i++) {
+                EsPictureNoVo noVo = new EsPictureNoVo();
+                noVo.setGuid(list.get(i));
+                noVo.setImageIndex(i);
+                pictureNoVos.add(noVo);
+            }
+            return pictureNoVos;
+        }
+        SearchRequest.Builder builder = new SearchRequest.Builder();
+        //设置查询索引
+        builder.index(patentVectorName);
+        Query query = QueryBuilders.term(i -> i.field("app_no").value(noDTO.getAppNo()));
+        builder.query(query);
+        builder.size(30);
+        SearchResponse<PatentVector> response = client.search(builder.build(), PatentVector.class);
+        List<Hit<PatentVector>> hits = response.hits().hits();
+        for (Hit<PatentVector> hit : hits) {
+            PatentVector vector = hit.source();
+            EsPictureNoVo noVo = new EsPictureNoVo();
+            noVo.setGuid(vector.getGuid());
+            noVo.setImageIndex(vector.getImageIndex());
+            pictureNoVos.add(noVo);
+        }
+        return pictureNoVos.stream().sorted(Comparator.comparing(EsPictureNoVo::getImageIndex)).collect(Collectors.toList());
+    }
+
+    public List<EsPictureNoVo> getPictureByNo3(EsPictureNoDTO noDTO) throws Exception {
+        List<EsPictureNoVo> esPictureNoVos = new ArrayList<>();
+        String appNo = noDTO.getAppNo();
+        if (appNo == null) {
+            return esPictureNoVos;
+        }
+        if (appNo.startsWith("CN")) {
+            esPictureNoVos = this.getPictureByNoCN(noDTO);
+        } else {
+            esPictureNoVos = this.getPictureByNoWG(noDTO);
+        }
+        return esPictureNoVos;
+    }
+
+    public List<EsPictureNoVo> getPictureByNoWG(EsPictureNoDTO noDTO) throws Exception {
+        List<EsPictureNoVo> pictureNoVos = new ArrayList<>();
+        SearchRequest.Builder builder = new SearchRequest.Builder();
+        //设置查询索引
+        builder.index(patentVectorName);
+        Query query = QueryBuilders.term(i -> i.field("app_no").value(noDTO.getAppNo()));
+        builder.query(query);
+        builder.size(300);
+        SearchResponse<PatentVector> response = client.search(builder.build(), PatentVector.class);
+        List<Hit<PatentVector>> hits = response.hits().hits();
+        for (Hit<PatentVector> hit : hits) {
+            PatentVector vector = hit.source();
+            EsPictureNoVo noVo = new EsPictureNoVo();
+            noVo.setGuid(imageHttp+vector.getGuid());
+            noVo.setImageIndex(vector.getImageIndex());
+            pictureNoVos.add(noVo);
+        }
+        return pictureNoVos.stream().sorted(Comparator.comparing(EsPictureNoVo::getImageIndex)).collect(Collectors.toList());
+    }
+
+    public List<EsPictureNoVo> getPictureByNoCN(EsPictureNoDTO noDTO) throws Exception {
+        String appNo = noDTO.getAppNo();
+        String[] appNoStrs = appNo.split("\\.");
+        String rowAppNo = appNoStrs[0];
+        rowAppNo = rowAppNo.replace("CN", "");
+        List<String> urls = patentStarApiService.getExternalFigure(rowAppNo);
+        List<EsPictureNoVo> pictureNoVos = new ArrayList<>();
+        for (int i = 0; i < urls.size(); i++) {
+            EsPictureNoVo esPictureNoVo = new EsPictureNoVo();
+            esPictureNoVo.setImageIndex(i);
+            esPictureNoVo.setGuid(urls.get(i));
+            pictureNoVos.add(esPictureNoVo);
+        }
+        return pictureNoVos;
+    }
 }

+ 2 - 2
src/main/java/com/example/xiaoshiweixinback/service/importPatent/EsPatentService.java

@@ -354,7 +354,7 @@ public class EsPatentService {
                 //获取专利的多张摘要附图
                 EsPictureNoDTO esPictureNoDTO = new EsPictureNoDTO();
                 esPictureNoDTO.setAppNo(appNo);
-                List<EsPictureNoVo> noVos = esDenseVectorService.getPictureByNo(esPictureNoDTO);
+                List<EsPictureNoVo> noVos = esDenseVectorService.getPictureByNo3(esPictureNoDTO);
                 List<String> guids = noVos.stream().map(EsPictureNoVo::getGuid).collect(Collectors.toList());
 
                 //根据专利申请号appNo获取专利信息
@@ -371,7 +371,7 @@ public class EsPatentService {
                     //获取专利的多张摘要附图
                     EsPictureNoDTO esPictureNoDTO = new EsPictureNoDTO();
                     esPictureNoDTO.setAppNo(appNo);
-                    List<EsPictureNoVo> noVos = esDenseVectorService.getPictureByNo(esPictureNoDTO);
+                    List<EsPictureNoVo> noVos = esDenseVectorService.getPictureByNo3(esPictureNoDTO);
                     List<String> guids = noVos.stream().map(EsPictureNoVo::getGuid).collect(Collectors.toList());
 
                     //根据专利申请号appNo获取专利信息

+ 0 - 1
src/main/java/com/example/xiaoshiweixinback/service/importPatent/PatentStarApiService.java

@@ -738,5 +738,4 @@ public class PatentStarApiService {
     public String getPictureGuid(String appNo) {
         return this.getPictureApi(appNo);
     }
-
 }

+ 2 - 2
src/main/resources/application-dev.yml

@@ -84,8 +84,8 @@ WeChat:
 Keypath: C:\Users\admin\Desktop\小程序证书\1673179188_20240408_cert\apiclient_key.pem
 queueName: emailProd.queue
 ES:
-  patentVector: patent_vector
-  patent: wxpatent
+  patentVector: cn_patent_vector_v5
+  patent: cn_weixin_patent_v4
   config: 192.168.2.24
 activity:
   jar-path:

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

@@ -84,4 +84,6 @@ Keypath: apiclient_key.pem
 ES:
   patentVector: patent_vector
   patent: wxpatent
-  config: es-cn-em93o8856000ho9e7.elasticsearch.aliyuncs.com
+  config: es-cn-em93o8856000ho9e7.elasticsearch.aliyuncs.com
+activity:
+  jar-path:

+ 25 - 4
src/main/resources/application-prodNetOut.yml

@@ -1,6 +1,24 @@
 spring:
+  rabbitmq:
+    host: 172.27.247.174
+    port: 5672
+    username: admin
+    password: 123456
+  data:
+    redis:
+      host: 139.224.34.118
+      port: 6379
+      database: 3
+      password: Xx0GWxdWQJxx6Swe
+      lettuce:
+        pool:
+          max-active: 20
+          max-idle: 20
+          min-idle: 0
+          max-wait: -1ms
+      timeout: 2000ms
   datasource:
-    url: jdbc:mysql://47.101.137.223:3306/ecs?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=GMT%2B8
+    url: jdbc:mysql://139.224.34.118:3306/ecs?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=GMT%2B8
     username: root
     password: TU5x6IeBi7rl
     driver-class-name: com.mysql.cj.jdbc.Driver
@@ -18,8 +36,8 @@ PCSUrl: http://localhost:8871
 OPSUrl: http://139.224.24.90:5001
 PASUrl: http://localhost:8877
 RMSUrl: http://localhost:8872
-FMSUrl: http://localhost:8802
-VectorUrl: http://139.224.24.90:8000
+FMSUrl: https://xsip.cn
+VectorUrl: http://192.168.2.24:8000
 FileSource: 5
 
 ##################  短信 ####################
@@ -38,4 +56,7 @@ queueName: emailProd.queue
 ES:
   patentVector: patent_vector
   patent: wxpatent
-  config: es-cn-em93o8856000ho9e7.public.elasticsearch.aliyuncs.com
+  config: es-cn-em93o8856000ho9e7.public.elasticsearch.aliyuncs.com
+activity:
+  jar-path:
+ImageHttp: https://www.xsip.cn/fileManager/downloadFile?fileId=