Explorar el Código

3/21 权要解析

lwhhszx hace 1 año
padre
commit
053f8c4f12

+ 359 - 204
src/main/java/cn/cslg/pas/common/utils/PatentRightUtils.java

@@ -44,6 +44,7 @@ public class PatentRightUtils {
             if (content.contains("\r\n")) {
                 content = content.replaceAll("\r\n", "@");
             }
+
             if (content.contains("\n")) {
                 content = content.replaceAll("\n", "@");
             }
@@ -51,212 +52,15 @@ public class PatentRightUtils {
 
             //中日韩权要↓
             if (country.equals("CN") || country.equals("JP") || country.equals("KR") || content.contains("权利要求")) {
-                String regex;
-                if (content.contains("@2")) {
-                    regex = "@[0-9]+";
-                } else if (content.contains("@[00")) {
-                    regex = "@\\[[0-9]+]";
-                } else if (content.contains("@請求項")) {
-                    regex = "@【請求項[0-9]+】";
-                } else if (content.contains("@청구항")) {
-                    regex = "@청구항 [0-9]+";
-                } else {
-                    regex = "";
-                }
-                String[] strs;  //原文数组
-                //若以上没有匹配到,则权要直接以句号 "。" 拆分
-                if (regex.equals("")) {
-                    content = content.replaceAll("@", "");
-                    strs = content.split("(?<=。)");
-                    //若匹配到,则根据不同情形拆分
-                } else {
-                    Matcher matcher = Pattern.compile(regex).matcher(content);
-                    while (matcher.find()) {
-                        content = content.replaceFirst(matcher.group(), "\n" + matcher.group().substring(matcher.group().indexOf("@") + 1));
-                    }
-
-                    content = content.replaceAll("@", "");
-                    strs = content.split("\n");
-                }
-                //定义父权要排序号
-                String regex1 = "权利要求[0-9]+";
-                String regex2 = "权利要求[0-9]+[至或~-]+[0-9]+";
-                for (int i = 0; i < strs.length; i++) {
-                    //之前:if (strs[i].contains("权利要求")) {
-                    //现在:if(该权要有逗号,并且它第一句话中有"权利要求"4个字 || 该权要没有逗号,并且它有"权利要求"4个字) {
-                    if ((strs[i].contains(",") && strs[i].substring(0, strs[i].indexOf(",")).contains("权利要求")) || (!strs[i].contains(",") && strs[i].contains("权利要求"))) {
-                        Matcher matcher1 = Pattern.compile(regex1).matcher(strs[i]);
-                        Matcher matcher2 = Pattern.compile(regex2).matcher(strs[i]);
-                        if (matcher2.find()) {
-                            String parentNum = matcher2.group().substring(matcher2.group().indexOf("求") + 1);
-                            String[] parentNums;
-                            if (parentNum.contains("~")) {
-                                parentNums = parentNum.split("~");
-                            } else if (parentNum.contains("-")) {
-                                parentNums = parentNum.split("-");
-                            } else if (parentNum.contains("至")) {
-                                parentNums = parentNum.split("至");
-                            } else if (parentNum.contains("或")) {
-                                parentNums = parentNum.split("或");
-                            } else {
-                                parentNums = new String[0];
-                            }
-                            StringBuilder builder = new StringBuilder();
-                            for (int j = Integer.parseInt(parentNums[0]) - 1; j < Integer.parseInt(parentNums[parentNums.length - 1]); j++) {
-                                if ((builder + "").equals("")) {
-                                    builder.append(j);
-                                } else {
-                                    builder.append(",").append(j);
-                                }
-                            }
-                            RePatentClaim patentRight = new RePatentClaim()
-                                    .setPatentNo(params.getPatentNo())
-                                    .setType(0)
-                                    .setContent(strs[i])
-                                    .setSort(i)
-                                    .setParentSort(builder + "");
-
-                            patentRights.add(patentRight);
-                        } else if (matcher1.find()) {
-                            String parentNum = matcher1.group().substring(matcher1.group().indexOf("求") + 1);
-                            RePatentClaim patentRight = new RePatentClaim()
-                                    .setPatentNo(params.getPatentNo())
-                                    .setType(0)
-                                    .setContent(strs[i])
-                                    .setSort(i)
-                                    .setParentSort((Integer.parseInt(parentNum) - 1) + "");
-                            patentRights.add(patentRight);
-                        }
-
-                    } else {
-                        RePatentClaim patentRight = new RePatentClaim()
-                                .setPatentNo(params.getPatentNo())
-                                .setType(1)
-                                .setContent(strs[i])
-                                .setSort(i)
-                                .setParentSort("-1");
-
-                        patentRights.add(patentRight);
-                    }
-                }
+                getChinaRights(content, params.getPatentNo(), patentRights);
                 //英文专利的权要拆分 ↓
-            } else {
-                if (!content.equals("") && content.contains("[1]")) {
-                    content = content.substring(content.indexOf("["));
-                } else if (!content.equals("") && content.contains("1")) {
-                    content = content.substring(content.indexOf("1"));
-                }
-
-                String regex;
-                if (content.contains("@2")) {
-                    regex = "\\.@[0-9]+";
-                } else if (content.contains("[001]") || content.contains("[1]")) {
-                    regex = "\\[[0-9]+]";
-                } else {
-                    regex = "";
-                }
-
-                Matcher matcher = Pattern.compile(regex).matcher(content);
-
-                while (matcher.find()) {
-                    String splitMe = matcher.group();
-                    if (splitMe.contains("[")) {
-                        splitMe = "\\" + splitMe;
-                    }
-                    String p = "\n" + splitMe;
-                    if (splitMe.contains(".")) {
-                        String t = splitMe.replace(".", "");
-                        p = "." + "\n" + t;
-                    }
-                    content = content.replaceFirst(splitMe, p);
-                }
+            }
+            else if(country.equals("FR")){
+                getFRRight(content, params.getPatentNo(), patentRights);
+            }
 
-                content = content.replaceAll("@", "");
-                if (content.startsWith("\n")) {
-                    content = content.replaceFirst("\n", "");
-                }
-                String[] strs = content.split("\n");
-
-                //定义父权要排序号
-                String regex1 = "claim [0-9]+";
-                String regex2 = "claims [0-9]+ or [0-9]+";
-                String regex3 = "any preceding claim";
-                String regex5 = "(Anspruch [0-9]+ oder [0-9]+)|(Ansprüche [0-9]+ bis [0-9]+)";
-                String regex4 = "Anspruch [0-9]+";
-                for (int i = 0; i < strs.length; i++) {
-
-                    Matcher matcher1 = Pattern.compile(regex1).matcher(strs[i]);
-                    Matcher matcher2 = Pattern.compile(regex2).matcher(strs[i]);
-                    Matcher matcher3 = Pattern.compile(regex3).matcher(strs[i]);
-                    Matcher matcher4 = Pattern.compile(regex4).matcher(strs[i]);
-                    Matcher matcher5 = Pattern.compile(regex5).matcher(strs[i]);
-                    Boolean flag1 = matcher1.find();
-                    Boolean flag2 = matcher2.find();
-                    Boolean flag3 = matcher3.find();
-                    Boolean flag4 = matcher4.find();
-                    Boolean flag5 = matcher5.find();
-
-                    if (flag2 || flag5) {
-                        List<String> parentNums = new ArrayList<>();
-                        if (flag2) {
-                            parentNums = getNums(matcher2.group());
-                        } else if (flag5) {
-                            parentNums = getNums(matcher5.group());
-                        }
-                        StringBuilder builder = new StringBuilder();
-                        for (int j = Integer.parseInt(parentNums.get(0)) - 1; j < Integer.parseInt(parentNums.get(parentNums.size() - 1)); j++) {
-                            if ((builder + "").equals("")) {
-                                builder.append(j);
-                            } else {
-                                builder.append(",").append(j);
-                            }
-                        }
-                        RePatentClaim patentRight = new RePatentClaim()
-                                .setPatentNo(params.getPatentNo())
-                                .setType(0)
-                                .setContent(strs[i])
-                                .setSort(i)
-                                .setParentSort(builder + "");
-                        patentRights.add(patentRight);
-                    } else if (flag1 || flag4) {
-                        String parentNum = null;
-                        if (flag1) {
-                            parentNum = getNums(matcher1.group()).get(0);
-                        } else if (flag4) {
-                            parentNum = getNums(matcher4.group()).get(0);
-                        }
-                        RePatentClaim patentRight = new RePatentClaim()
-                                .setPatentNo(params.getPatentNo())
-                                .setType(0)
-                                .setContent(strs[i])
-                                .setSort(i)
-                                .setParentSort((Integer.parseInt(parentNum) - 1) + "");
-                        patentRights.add(patentRight);
-                    } else if (flag3) {
-                        StringBuilder builder = new StringBuilder();
-                        for (int sort = 0; sort < strs.length; sort++) {
-                            if (sort == i) {
-                                continue;
-                            }
-                            builder.append(i).append(",");
-                        }
-                        RePatentClaim patentRight = new RePatentClaim()
-                                .setPatentNo(params.getPatentNo())
-                                .setType(0)
-                                .setContent(strs[i])
-                                .setSort(i)
-                                .setParentSort(builder.substring(0, builder.lastIndexOf(",")));
-                        patentRights.add(patentRight);
-                    } else {
-                        RePatentClaim patentRight = new RePatentClaim()
-                                .setPatentNo(params.getPatentNo())
-                                .setType(1)
-                                .setContent(strs[i])
-                                .setSort(i)
-                                .setParentSort("-1");
-                        patentRights.add(patentRight);
-                    }
-                }
+            else {
+                getForeignRights(content, params.getPatentNo(), patentRights);
             }
 
             return patentRights;
@@ -295,4 +99,355 @@ public class PatentRightUtils {
         }
         return nums;
     }
+
+    private static void getChinaRights(String content, String patentNo, ArrayList<RePatentClaim> patentRights) {
+        String regex;
+        if (content.contains("@2")) {
+            regex = "@[0-9]+";
+        } else if (content.contains("@[00")) {
+            regex = "@\\[[0-9]+]";
+        } else if (content.contains("@請求項")) {
+            regex = "@【請求項[0-9]+】";
+        } else if (content.contains("@청구항")) {
+            regex = "@청구항 [0-9]+";
+        } else {
+            regex = "";
+        }
+        String[] strs;  //原文数组
+        //若以上没有匹配到,则权要直接以句号 "。" 拆分
+        if (regex.equals("")) {
+            content = content.replaceAll("@", "");
+            strs = content.split("(?<=。)");
+            //若匹配到,则根据不同情形拆分
+        } else {
+            Matcher matcher = Pattern.compile(regex).matcher(content);
+            while (matcher.find()) {
+                content = content.replaceFirst(matcher.group(), "\n" + matcher.group().substring(matcher.group().indexOf("@") + 1));
+            }
+
+            content = content.replaceAll("@", "");
+            strs = content.split("\n");
+        }
+        //定义父权要排序号
+        String regex1 = "权利要求[0-9]+";
+        String regex2 = "权利要求[0-9]+[至或~-]+[0-9]+";
+        for (int i = 0; i < strs.length; i++) {
+            //之前:if (strs[i].contains("权利要求")) {
+            //现在:if(该权要有逗号,并且它第一句话中有"权利要求"4个字 || 该权要没有逗号,并且它有"权利要求"4个字) {
+            if ((strs[i].contains(",") && strs[i].substring(0, strs[i].indexOf(",")).contains("权利要求")) || (!strs[i].contains(",") && strs[i].contains("权利要求"))) {
+                Matcher matcher1 = Pattern.compile(regex1).matcher(strs[i]);
+                Matcher matcher2 = Pattern.compile(regex2).matcher(strs[i]);
+                if (matcher2.find()) {
+                    String parentNum = matcher2.group().substring(matcher2.group().indexOf("求") + 1);
+                    String[] parentNums;
+                    if (parentNum.contains("~")) {
+                        parentNums = parentNum.split("~");
+                    } else if (parentNum.contains("-")) {
+                        parentNums = parentNum.split("-");
+                    } else if (parentNum.contains("至")) {
+                        parentNums = parentNum.split("至");
+                    } else if (parentNum.contains("或")) {
+                        parentNums = parentNum.split("或");
+                    } else {
+                        parentNums = new String[0];
+                    }
+                    StringBuilder builder = new StringBuilder();
+                    for (int j = Integer.parseInt(parentNums[0]) - 1; j < Integer.parseInt(parentNums[parentNums.length - 1]); j++) {
+                        if ((builder + "").equals("")) {
+                            builder.append(j);
+                        } else {
+                            builder.append(",").append(j);
+                        }
+                    }
+                    RePatentClaim patentRight = new RePatentClaim()
+                            .setPatentNo(patentNo)
+                            .setType(0)
+                            .setContent(strs[i])
+                            .setSort(i)
+                            .setParentSort(builder + "");
+
+                    patentRights.add(patentRight);
+                } else if (matcher1.find()) {
+                    String parentNum = matcher1.group().substring(matcher1.group().indexOf("求") + 1);
+                    RePatentClaim patentRight = new RePatentClaim()
+                            .setPatentNo(patentNo)
+                            .setType(0)
+                            .setContent(strs[i])
+                            .setSort(i)
+                            .setParentSort((Integer.parseInt(parentNum) - 1) + "");
+                    patentRights.add(patentRight);
+                }
+
+            } else {
+                RePatentClaim patentRight = new RePatentClaim()
+                        .setPatentNo(patentNo)
+                        .setType(1)
+                        .setContent(strs[i])
+                        .setSort(i)
+                        .setParentSort("-1");
+
+                patentRights.add(patentRight);
+            }
+        }
+
+    }
+
+    private static void getForeignRights(String content, String patentNo, ArrayList<RePatentClaim> patentRights) {
+
+        if (!content.equals("") && content.contains("[1]")) {
+            content = content.substring(content.indexOf("["));
+        } else if (!content.equals("") && content.contains("1")) {
+            content = content.substring(content.indexOf("1"));
+        }
+
+        String regex;
+        if (content.contains("@2")) {
+            regex = "\\.@[0-9]+";
+        } else if (content.contains("[001]") || content.contains("[1]")) {
+            regex = "\\[[0-9]+]";
+        } else {
+            regex = "";
+        }
+
+        Matcher matcher = Pattern.compile(regex).matcher(content);
+
+        while (matcher.find()) {
+            String splitMe = matcher.group();
+            if (splitMe.contains("[")) {
+                splitMe = "\\" + splitMe;
+            }
+            String p = "\n" + splitMe;
+            if (splitMe.contains(".")) {
+                String t = splitMe.replace(".", "");
+                p = "." + "\n" + t;
+            }
+            content = content.replaceFirst(splitMe, p);
+        }
+
+        content = content.replaceAll("@", "");
+        if (content.startsWith("\n")) {
+            content = content.replaceFirst("\n", "");
+        }
+        String[] strs = content.split("\n");
+
+        //定义父权要排序号
+        String regex1 = "claim [0-9]+";
+        String regex2 = "claims [0-9]+ or [0-9]+";
+        String regex3 = "any preceding claim";
+        String regex5 = "(Anspruch [0-9]+ oder [0-9]+)|(Ansprüche [0-9]+ bis [0-9]+)";
+        String regex4 = "Anspruch [0-9]+";
+        for (int i = 0; i < strs.length; i++) {
+
+            Matcher matcher1 = Pattern.compile(regex1).matcher(strs[i]);
+            Matcher matcher2 = Pattern.compile(regex2).matcher(strs[i]);
+            Matcher matcher3 = Pattern.compile(regex3).matcher(strs[i]);
+            Matcher matcher4 = Pattern.compile(regex4).matcher(strs[i]);
+            Matcher matcher5 = Pattern.compile(regex5).matcher(strs[i]);
+            Boolean flag1 = matcher1.find();
+            Boolean flag2 = matcher2.find();
+            Boolean flag3 = matcher3.find();
+            Boolean flag4 = matcher4.find();
+            Boolean flag5 = matcher5.find();
+
+            if (flag2 || flag5) {
+                List<String> parentNums = new ArrayList<>();
+                if (flag2) {
+                    parentNums = getNums(matcher2.group());
+                } else if (flag5) {
+                    parentNums = getNums(matcher5.group());
+                }
+                StringBuilder builder = new StringBuilder();
+                for (int j = Integer.parseInt(parentNums.get(0)) - 1; j < Integer.parseInt(parentNums.get(parentNums.size() - 1)); j++) {
+                    if ((builder + "").equals("")) {
+                        builder.append(j);
+                    } else {
+                        builder.append(",").append(j);
+                    }
+                }
+                RePatentClaim patentRight = new RePatentClaim()
+                        .setPatentNo(patentNo)
+                        .setType(0)
+                        .setContent(strs[i])
+                        .setSort(i)
+                        .setParentSort(builder + "");
+                patentRights.add(patentRight);
+            } else if (flag1 || flag4) {
+                String parentNum = null;
+                if (flag1) {
+                    parentNum = getNums(matcher1.group()).get(0);
+                } else if (flag4) {
+                    parentNum = getNums(matcher4.group()).get(0);
+                }
+                RePatentClaim patentRight = new RePatentClaim()
+                        .setPatentNo(patentNo)
+                        .setType(0)
+                        .setContent(strs[i])
+                        .setSort(i)
+                        .setParentSort((Integer.parseInt(parentNum) - 1) + "");
+                patentRights.add(patentRight);
+            } else if (flag3) {
+                StringBuilder builder = new StringBuilder();
+                for (int sort = 0; sort < strs.length; sort++) {
+                    if (sort == i) {
+                        continue;
+                    }
+                    builder.append(i).append(",");
+                }
+                RePatentClaim patentRight = new RePatentClaim()
+                        .setPatentNo(patentNo)
+                        .setType(0)
+                        .setContent(strs[i])
+                        .setSort(i)
+                        .setParentSort(builder.substring(0, builder.lastIndexOf(",")));
+                patentRights.add(patentRight);
+            } else {
+                RePatentClaim patentRight = new RePatentClaim()
+                        .setPatentNo(patentNo)
+                        .setType(1)
+                        .setContent(strs[i])
+                        .setSort(i)
+                        .setParentSort("-1");
+                patentRights.add(patentRight);
+            }
+        }
+
+    }
+
+
+    private static void getFRRight(String content, String patentNo, ArrayList<RePatentClaim> patentRights) {
+
+        if (!content.equals("") && content.contains("[1]")) {
+            content = content.substring(content.indexOf("["));
+        } else if (!content.equals("") && content.contains("1.")) {
+            content = content.substring(content.indexOf("1."));
+        }
+        else if(!content.equals("") && content.contains("[Revendication 1]"))
+        {  content = content.substring(content.indexOf("[Revendication 1]"));
+
+        }
+
+        String regex;
+        if (content.contains("@2")) {
+            regex = "\\.@[0-9]+";
+        } else if (content.contains("[001]") || content.contains("[1]")) {
+            regex = "\\[[0-9]+]";
+        } else if (content.contains("[Revendication 1]")) {
+            regex = "\\[Revendication [0-9]+(]|\\))";
+        } else {
+            regex = "";
+        }
+
+        Matcher matcher = Pattern.compile(regex).matcher(content);
+
+        while (matcher.find()) {
+            String splitMe = matcher.group();
+            if (splitMe.contains("[")) {
+                splitMe = "\\" + splitMe;
+            }
+            if(splitMe.contains(")"))
+            {
+                splitMe=   splitMe.replaceFirst("\\)","\\\\)");
+            }
+            String p = "\n" + splitMe;
+            if (splitMe.contains(".")) {
+                String t = splitMe.replace(".", "");
+                p = "." + "\n" + t;
+            }
+            content = content.replaceFirst(splitMe, p);
+        }
+
+        content = content.replaceAll("@", "");
+        if (content.startsWith("\n")) {
+            content = content.replaceFirst("\n", "");
+        }
+        String[] strs = content.split("\n");
+
+        //定义父权要排序号
+        String regex1 = "revendications là [0-9]+";
+        String regex2 = "(revendication [0-9]+ ou [0-9]+)|(revendication [0-9]+ et [0-9]+)";
+        String regex3 = "des revendications précédentes";
+        String regex4 = "revendication précédente";
+
+        for (int i = 0; i < strs.length; i++) {
+
+            Matcher matcher1 = Pattern.compile(regex1).matcher(strs[i]);
+            Matcher matcher2 = Pattern.compile(regex2).matcher(strs[i]);
+            Matcher matcher3 = Pattern.compile(regex3).matcher(strs[i]);
+            Matcher matcher4 = Pattern.compile(regex4).matcher(strs[i]);
+            Boolean flag1 = matcher1.find();
+            Boolean flag2 = matcher2.find();
+            Boolean flag3 = matcher3.find();
+            Boolean flag4 = matcher4.find();
+
+            if (flag2) {
+                List<String> parentNums = new ArrayList<>();
+                if (flag2) {
+                    parentNums = getNums(matcher2.group());
+                }
+                StringBuilder builder = new StringBuilder();
+                for (int j = Integer.parseInt(parentNums.get(0)) - 1; j < Integer.parseInt(parentNums.get(parentNums.size() - 1)); j++) {
+                    if ((builder + "").equals("")) {
+                        builder.append(j);
+                    } else {
+                        builder.append(",").append(j);
+                    }
+                }
+                RePatentClaim patentRight = new RePatentClaim()
+                        .setPatentNo(patentNo)
+                        .setType(0)
+                        .setContent(strs[i])
+                        .setSort(i)
+                        .setParentSort(builder + "");
+                patentRights.add(patentRight);
+            } else if (flag1 ) {
+                String parentNum = null;
+                if (flag1) {
+                    parentNum = getNums(matcher1.group()).get(0);
+                }
+                RePatentClaim patentRight = new RePatentClaim()
+                        .setPatentNo(patentNo)
+                        .setType(0)
+                        .setContent(strs[i])
+                        .setSort(i)
+                        .setParentSort((Integer.parseInt(parentNum) - 1) + "");
+                patentRights.add(patentRight);
+            } else if (flag3) {
+                StringBuilder builder = new StringBuilder();
+                for (int sort = 0; sort < strs.length; sort++) {
+                    if (sort == i) {
+                        continue;
+                    }
+                    builder.append(i).append(",");
+                }
+                RePatentClaim patentRight = new RePatentClaim()
+                        .setPatentNo(patentNo)
+                        .setType(0)
+                        .setContent(strs[i])
+                        .setSort(i)
+                        .setParentSort(builder.substring(0, builder.lastIndexOf(",")));
+                patentRights.add(patentRight);
+            } else if (flag4) {
+                StringBuilder builder = new StringBuilder();
+
+                builder.append(i - 1);
+
+                RePatentClaim patentRight = new RePatentClaim()
+                        .setPatentNo(patentNo)
+                        .setType(0)
+                        .setContent(strs[i])
+                        .setSort(i)
+                        .setParentSort(builder.toString());
+                patentRights.add(patentRight);
+            } else {
+                RePatentClaim patentRight = new RePatentClaim()
+                        .setPatentNo(patentNo)
+                        .setType(1)
+                        .setContent(strs[i])
+                        .setSort(i)
+                        .setParentSort("-1");
+                patentRights.add(patentRight);
+            }
+        }
+
+    }
 }

+ 21 - 0
src/main/java/cn/cslg/pas/common/vo/exportProject/CustomFiledExportVO.java

@@ -0,0 +1,21 @@
+package cn.cslg.pas.common.vo.exportProject;
+
+import cn.cslg.pas.domain.business.CustomField;
+import cn.cslg.pas.domain.business.CustomOption;
+import cn.cslg.pas.domain.business.TreeNode;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.util.List;
+
+/**
+ * 拆分保存特征的前端传输DTO类
+ */
+@Data
+@Accessors(chain = true)
+public class CustomFiledExportVO {
+    private CustomField customField;
+   private List<CustomOption> customOptions;
+    private List<TreeNode> treeNodes;
+
+}

+ 22 - 0
src/main/java/cn/cslg/pas/common/vo/exportProject/CustomFiledRecord.java

@@ -0,0 +1,22 @@
+package cn.cslg.pas.common.vo.exportProject;
+
+import cn.cslg.pas.domain.business.CustomField;
+import cn.cslg.pas.domain.business.CustomOption;
+import cn.cslg.pas.domain.business.TreeNode;
+import cn.cslg.pas.domain.es.Patent;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.util.List;
+
+/**
+ * 拆分保存特征的前端传输DTO类
+ */
+@Data
+@Accessors(chain = true)
+public class CustomFiledRecord {
+    private Long total;
+   private Long size;
+   private List<Patent> patents;
+
+}

+ 4 - 1
src/main/java/cn/cslg/pas/controller/ExportProjectController.java

@@ -3,6 +3,7 @@ package cn.cslg.pas.controller;
 import cn.cslg.pas.common.core.base.Constants;
 import cn.cslg.pas.common.utils.Response;
 import cn.cslg.pas.service.exportProject.ExportProjectService;
+import cn.cslg.pas.service.exportProject.ImportProjectService;
 import io.swagger.v3.oas.annotations.Operation;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -21,6 +22,8 @@ import org.springframework.web.bind.annotation.RestController;
 public class ExportProjectController {
     @Autowired
     private ExportProjectService exportProjectService;
+    @Autowired
+    private ImportProjectService importProjectService;
     @Operation(summary = "查询无效理由")
     @PostMapping("/writeProjectToFile")
     public Response writeProjectToFile() {
@@ -31,7 +34,7 @@ public class ExportProjectController {
     @Operation(summary = "查询无效理由")
     @PostMapping("/readProjectFromFile")
     public Response readProjectFromFile() {
-        exportProjectService.readProjectFromFile();
+        importProjectService.getFileFromZip();
         return Response.success("");
     }
 }

+ 37 - 2
src/main/java/cn/cslg/pas/service/business/es/EsCustomFieldService.java

@@ -11,6 +11,7 @@ import cn.cslg.pas.common.vo.EsConfigVO;
 import cn.cslg.pas.common.vo.FieldValueVO;
 import cn.cslg.pas.common.vo.PatentWithIdVO;
 import cn.cslg.pas.common.vo.es.*;
+import cn.cslg.pas.common.vo.exportProject.CustomFiledRecord;
 import cn.cslg.pas.domain.business.CustomField;
 import cn.cslg.pas.domain.business.CustomOption;
 import cn.cslg.pas.domain.business.TreeNode;
@@ -855,6 +856,42 @@ public class EsCustomFieldService {
 
     }
 
+    public CustomFiledRecord getEsCustomFields(String filedId, Integer type, Integer projectId, Long current, Long size) {
+       CustomFiledRecord customFiledRecord =new CustomFiledRecord();
+        Query q1 = QueryBuilders.term(t -> t.field("custom_field.project_id").value(projectId));
+        Query q2 = QueryBuilders.term((t -> t.field("custom_field.field").value(filedId)));
+        Query q3 = QueryBuilders.term(t -> t.field("custom_field.field_type").value(type));
+
+        Query fQ = QueryBuilders.bool(i -> i.must(q1, q2, q3));
+        SearchRequest.Builder builder = new SearchRequest.Builder();
+        builder.query(fQ);
+        builder.sort(sortOptionsBuilder -> sortOptionsBuilder
+                .field(fieldSortBuilder -> fieldSortBuilder
+                        .field("custom_field.create_time").order(SortOrder.Desc)));
+
+        if (current != null && size != null && current > 0 && size > 0) {
+            builder.from((current.intValue() - 1) * size.intValue()).size(size.intValue());
+        } else {
+            builder.from(0).size(10000);
+        }
+        try {
+            SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+            long total = response.hits().total().value();
+            customFiledRecord.setTotal(total);
+            if (total > 0) {
+                List<Hit<Patent>> hits = response.hits().hits();
+                for (Hit<Patent> hit : hits) {
+               customFiledRecord.getPatents().add(hit.source());
+                }
+
+            }
+        } catch (Exception e) {
+        }
+
+        return customFiledRecord;
+    }
+
+
     public List<PatentWithIdVO> getEsCustomFields(String filedId, Integer type, Integer projectId) {
         List<PatentWithIdVO> patentWithIdVOS = new ArrayList<>();
         Query q1 = QueryBuilders.term(t -> t.field("custom_field.project_id").value(projectId));
@@ -889,6 +926,4 @@ public class EsCustomFieldService {
 
         return patentWithIdVOS;
     }
-
-
 }

+ 131 - 17
src/main/java/cn/cslg/pas/service/exportProject/ExportProjectService.java

@@ -1,26 +1,29 @@
 package cn.cslg.pas.service.exportProject;
 
 
+import cn.cslg.pas.common.dto.PatentColumnDTO;
 import cn.cslg.pas.common.dto.PatentDTO;
 import cn.cslg.pas.common.model.request.QueryRequest;
 import cn.cslg.pas.common.utils.FileUtils;
 import cn.cslg.pas.common.utils.JsonUtils;
 import cn.cslg.pas.common.utils.UploadPatentBatchUtil;
 import cn.cslg.pas.common.vo.PatentData;
+import cn.cslg.pas.common.vo.PatentWithIdVO;
 import cn.cslg.pas.common.vo.UploadParamsVO;
 import cn.cslg.pas.common.vo.UploadSettingVO;
-import cn.cslg.pas.domain.business.PatentProject;
-import cn.cslg.pas.domain.business.Project;
-import cn.cslg.pas.domain.business.ReportProject;
-import cn.cslg.pas.service.business.PatentProjectService;
-import cn.cslg.pas.service.business.ProjectService;
-import cn.cslg.pas.service.business.ReportProjectService;
+import cn.cslg.pas.common.vo.exportProject.CustomFiledExportVO;
+import cn.cslg.pas.common.vo.exportProject.CustomFiledRecord;
+import cn.cslg.pas.domain.business.*;
+import cn.cslg.pas.domain.es.Patent;
+import cn.cslg.pas.service.business.*;
+import cn.cslg.pas.service.business.es.EsCustomFieldService;
 import cn.cslg.pas.service.business.es.EsService;
 import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.ZipUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.google.gson.JsonObject;
 import org.apache.poi.ss.usermodel.PictureData;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -48,13 +51,23 @@ public class ExportProjectService {
     private ReportProjectService reportProjectService;
     @Autowired
     private EsService esService;
+    @Autowired
+    private CustomFieldService customFieldService;
+    @Autowired
+    private CustomOptionService customOptionService;
+    @Autowired
+    private TreeNodeService treeNodeService;
+    @Autowired
+    private EsCustomFieldService esCustomFieldService;
 
     public void exportProject(Integer projectId) {
         String directoryName = IdUtil.simpleUUID();
         String url = FileUtils.getStaticPath(directoryName);
 
         this.writeProjectToFile(projectId, url);
-        this.getPatentsFromEs(projectId);
+        this.getPatentsFromEs(projectId,url);
+        List<CustomField> customFields = this.getCustomFiled(projectId, url);
+        this.getCustomFiledLabel(customFields, url);
         String outUrl = FileUtils.getStaticPath("");
         String trueOutUrl = outUrl + "\\" + directoryName + ".zip";
         ZipUtil.zip(url, trueOutUrl);
@@ -92,21 +105,19 @@ public class ExportProjectService {
         } catch (Exception e) {
             e.printStackTrace();
         }
-
-
     }
 
     /**
      * 获取专利对象
      */
-    private void getPatentsFromEs(Integer projectId) {
+    private void getPatentsFromEs(Integer projectId,String url) {
         QueryRequest queryRequest = new QueryRequest();
         queryRequest.setProjectId(projectId);
         queryRequest.setCurrent(1L);
         queryRequest.setSize(10L);
         List<QueryRequest> queryRequests = new ArrayList<>();
         queryRequests.add(queryRequest);
-
+        int index = 0;
         try {
             while (queryRequests.size() > 0) {
                 QueryRequest queryRequest2 = queryRequests.remove(0);
@@ -114,6 +125,7 @@ public class ExportProjectService {
                 Long total = patentDTO.getTotal();
                 Long size = patentDTO.getPageSize();
                 Long current = patentDTO.getPageNum();
+                List<PatentColumnDTO> patents =patentDTO.getPatents();
                 if (size * current < total) {
                     QueryRequest queryRequest1 = new QueryRequest();
                     queryRequest1.setCurrent(current + 1);
@@ -122,6 +134,12 @@ public class ExportProjectService {
                     queryRequests.add(queryRequest1);
 
                 }
+                String customFiledUrl = url + "\\patent" + index + ".json";
+                try {
+                    ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(customFiledUrl));
+                    oos.writeObject(patents);
+                } catch (Exception e) {
+                }
             }
         } catch (Exception e) {
             e.printStackTrace();
@@ -131,26 +149,122 @@ public class ExportProjectService {
 
     }
 
+
     /**
-     * 获取专利标引对象
+     * 获取项目附件
      */
-    private void getCustomFieldFromEs() {
+    private void getProjectFile() {
 
 
     }
 
     /**
-     * 获取项目附件
+     * 获取自定义栏位
      */
-    private void getProjectFile() {
+    private List<CustomField> getCustomFiled(Integer projectId, String url) {
+        List<CustomFiledExportVO> customFiledExportVOS = new ArrayList<>();
+        //根据projectId 获得自定义栏位
+        LambdaQueryWrapper<CustomField> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(CustomField::getProjectId, projectId);
+        List<CustomField> customFields = customFieldService.list(queryWrapper);
+        if (customFields.size() != 0) {
+            for (CustomField customField : customFields) {
+
+                CustomFiledExportVO customFiledExportVO = this.getCustomFieldValues(customField);
+                customFiledExportVO.setCustomField(customField);
+                customFiledExportVOS.add(customFiledExportVO);
+            }
+        }
+
+        String customFiledUrl = url + "\\customFiled.json";
+        try {
+            ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(customFiledUrl));
+            oos.writeObject(customFiledExportVOS);
+        } catch (Exception e) {
+        }
+        return customFields;
+    }
+
+
+    private CustomFiledExportVO getCustomFieldValues(CustomField customField) {
+        CustomFiledExportVO customFiledExportVO = new CustomFiledExportVO();
+        Integer type = customField.getType();
+        switch (type) {
+            case 0:
+                ;
+            case 1:
+                ;
+            case 2:
+                ;
+            case 3:
+                break;
+            case 4:
+
 
+            case 5:
+                List<CustomOption> customOptions = this.getOptionValues(customField);
+                customFiledExportVO.setCustomOptions(customOptions);
+                break;
+            case 6:
+                this.getTreeValues(customField);
+                List<TreeNode> treeNodes = this.getTreeValues(customField);
+                customFiledExportVO.setTreeNodes(treeNodes);
+                break;
+
+        }
+        return customFiledExportVO;
+    }
+
+    private List<CustomOption> getOptionValues(CustomField customField) {
+        LambdaQueryWrapper<CustomOption> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(CustomOption::getCustomFieldId, customField.getId());
+        List<CustomOption> customOptions = customOptionService.list(queryWrapper);
+        return customOptions;
+    }
 
+    private List<TreeNode> getTreeValues(CustomField customField) {
+        LambdaQueryWrapper<TreeNode> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(TreeNode::getTypeId, customField.getId())
+                .eq(TreeNode::getType, customField.getType())
+                .orderByAsc(TreeNode::getLevel);
+        List<TreeNode> treeNodes = treeNodeService.list(queryWrapper);
+        return treeNodes;
     }
+
     /**
-     * 获取自定义栏位
+     * @param customFields
      */
-    private void getCustomFiled(Integer projectId){
+    private void getCustomFiledLabel(List<CustomField> customFields, String url) {
+        Integer index = 0;
+        for (CustomField customField : customFields) {
+            List<QueryRequest> queryRequests = new ArrayList<>();
+            QueryRequest queryRequest = new QueryRequest();
+            queryRequest.setCurrent(1L);
+            queryRequest.setSize(10L);
+            queryRequests.add(queryRequest);
+            while (queryRequests.size() > 0) {
+                QueryRequest queryRequest1 = queryRequests.remove(0);
+                Long size = queryRequest1.getSize();
+                Long current = queryRequest1.getCurrent();
+                CustomFiledRecord customFiledRecord = esCustomFieldService.getEsCustomFields(customField.getId().toString(), customField.getType(), customField.getProjectId(), queryRequest1.getCurrent(), queryRequest1.getSize());
+                Long total = customFiledRecord.getTotal();
+                List<Patent> patents = customFiledRecord.getPatents();
+                String customFiledUrl = url + "\\customFiledLabel" + index + ".json";
+                try {
+                    ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(customFiledUrl));
+                    oos.writeObject(patents);
+                } catch (Exception e) {
+                }
+                if (size * current < total) {
+                    QueryRequest queryRequest2 = new QueryRequest();
+                    queryRequest1.setCurrent(current + 1);
+                    queryRequest1.setSize(size);
+                    queryRequests.add(queryRequest2);
 
+                }
+                index++;
+            }
+        }
 
     }
 }

+ 30 - 0
src/main/java/cn/cslg/pas/service/exportProject/ImportProjectService.java

@@ -0,0 +1,30 @@
+package cn.cslg.pas.service.exportProject;
+
+import cn.cslg.pas.common.utils.FileUtils;
+import cn.cslg.pas.domain.business.Project;
+import cn.hutool.core.util.ZipUtil;
+import org.springframework.stereotype.Service;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.util.zip.ZipFile;
+
+@Service
+public class ImportProjectService {
+
+    public void getFileFromZip() {
+        try {
+            File file = new File("D:\\PAS\\target\\2353868e6d06429bbd03fd9b185e6645.zip");
+            ZipFile zipFile = new ZipFile(file);
+            InputStream inputStream = ZipUtil.get(zipFile,"project.json");
+            ObjectInputStream ois = new ObjectInputStream(inputStream);
+            Project project = (Project) ois.readObject();
+            System.out.println(project);
+        } catch (Exception e) {
+        }
+
+
+    }
+}