Browse Source

第三方意见模板

lwhhszx 2 years ago
parent
commit
e4e8ba9f78

+ 5 - 0
RMS/src/main/java/cn/cslg/report/entity/PatentRight.java

@@ -35,4 +35,9 @@ public class PatentRight {
     private Integer sort;
 
     private String rightName;
+    /**
+     * 父权要的排序号
+     */
+    private String parentSort;
+
 }

+ 90 - 216
RMS/src/main/java/cn/cslg/report/service/business/ReportDocumentService.java

@@ -105,7 +105,7 @@ public class ReportDocumentService extends ServiceImpl<ReportDocumentMapper, Rep
         String outPath = fileUtils.getSavePath(directoryName) + fileName;
         Report report = reportService.getById(reportId);
         XWPFTemplate template = null;
-        if (report.getType() == 0 || report.getType() == 2|| report.getType() == 1) {
+        if (report.getType() == 0 || report.getType() == 2) {
             template = this.getstabilityTemplate(report, filePath);
         } else if (report.getType() == 3) {
             template = this.FTOtemplate(reportId, filePath, templeId);
@@ -113,6 +113,8 @@ public class ReportDocumentService extends ServiceImpl<ReportDocumentMapper, Rep
             template = this.Torttemplate(reportId, filePath, templeId);
         } else if (report.getType() == 5) {
             template = this.avoidDesignTemplate(reportId, filePath);
+        } else if (report.getType() == 1) {
+            template = this.getThirdTemplate(report, filePath);
         }
         // 读取模板、数据并渲染
 //         文件是否已存在,则删除
@@ -146,16 +148,7 @@ public class ReportDocumentService extends ServiceImpl<ReportDocumentMapper, Rep
      */
 
     private XWPFTemplate getstabilityTemplate(Report report, String filePath) throws IOException {
-        List<PatentRight> patentRights =new ArrayList<>();
-        if(report.getType()==1) {
-          //权要(带拆分的特征)列表
-          List<PatentRightVo> patentRightVos = new ArrayList<>();
-          //从pas获得权要信息
-          String resBody = outInterfaceService.getPatentRightFromPAS(report.getSignPatentNo());
-          JSONObject jsonObject = JSONObject.parseObject(resBody);
-          //解析jason获得标的专利的权要
-         patentRights = JSON.parseArray(jsonObject.getString("data"), PatentRight.class);
-      }
+        List<PatentRight> patentRights = new ArrayList<>();
         //装载标的专利信息
         Map<String, Object> signPatent = this.signPantentMess(report.getSignPatentNo());
         //根据报告Id获得报告信息
@@ -310,9 +303,9 @@ public class ReportDocumentService extends ServiceImpl<ReportDocumentMapper, Rep
                 temMap.put("rightName", "附属" + a);
             }
             temMap.put("rightId", item1.getRightId());
-            if(report.getType()==1){
-                String rightContent =patentRights.stream().filter(t->t.getSort().equals(item1.getRightId())).map(PatentRight::getContent).findFirst().orElse("");
-                temMap.put("rightContent",rightContent);
+            if (report.getType() == 1) {
+                String rightContent = patentRights.stream().filter(t -> t.getSort().equals(item1.getRightId())).map(PatentRight::getContent).findFirst().orElse("");
+                temMap.put("rightContent", rightContent);
             }
             temMap.put("remark", item1.getContrastResult());
             // 从关联数据里获得特征id
@@ -439,7 +432,7 @@ public class ReportDocumentService extends ServiceImpl<ReportDocumentMapper, Rep
         }
         List<Map<String, Object>> allRightScenarios = new ArrayList<>();
         List<Map<String, Object>> resultMaps = new ArrayList<>();
-       // 存放创造性和新颖性的权要
+        // 存放创造性和新颖性的权要
 
         rightIds.forEach(tem -> {
             Map<String, Object> map = new HashMap<>();
@@ -764,16 +757,9 @@ public class ReportDocumentService extends ServiceImpl<ReportDocumentMapper, Rep
     }
 
     private XWPFTemplate getThirdTemplate(Report report, String filePath) throws IOException {
-        List<PatentRight> patentRights =new ArrayList<>();
-            //权要(带拆分的特征)列表
-            List<PatentRightVo> patentRightVos = new ArrayList<>();
-            //从pas获得权要信息
-            String resBody = outInterfaceService.getPatentRightFromPAS(report.getSignPatentNo());
-            JSONObject jsonObject = JSONObject.parseObject(resBody);
-            //解析jason获得标的专利的权要
-            patentRights = JSON.parseArray(jsonObject.getString("data"), PatentRight.class);
         //装载标的专利信息
         Map<String, Object> signPatent = this.signPantentMess(report.getSignPatentNo());
+        List<Map<String, Object>> rights = (List<Map<String, Object>>) signPatent.get("rights");
         //根据报告Id获得报告信息
         // 根据拆分人(报告的创建人)Id和报告ID获得所有特征
         LambdaQueryWrapper<Features> allFeaturesWrapper = new LambdaQueryWrapper<>();
@@ -827,6 +813,10 @@ public class ReportDocumentService extends ServiceImpl<ReportDocumentMapper, Rep
         List<String> PatentNos = compareRecords.stream().map(CompareRecords::getPatentNo).collect(Collectors.toList());
         PatentVO patentVO = new PatentVO();
         patentVO.setPatentNos(PatentNos);
+        //根据专利号查询专利详细信息
+        String resBody = outInterfaceService.getPatentDTOListForRMS(patentVO);
+        JSONObject jsonObject = JSONObject.parseObject(resBody);
+        List<JSONObject> patentDTOS = JSON.parseArray(jsonObject.get("data").toString(), JSONObject.class);
         //根据专利号查询专利的排序
         LambdaQueryWrapper<CompareFiles> comWrapper = new LambdaQueryWrapper<>();
         comWrapper
@@ -842,10 +832,6 @@ public class ReportDocumentService extends ServiceImpl<ReportDocumentMapper, Rep
             OtherName.put(item.getPatentNo(), order);
             flag++;
         }
-        //根据专利号查询专利详细信息
-//        String resBody = outInterfaceService.getPatentDTOListForRMS(patentVO);
-//        JSONObject jsonObject = JSONObject.parseObject(resBody);
-        List<JSONObject> patentDTOS = JSON.parseArray(jsonObject.get("data").toString(), JSONObject.class);
         //存放专利信息的map集合
         List<Map<String, Object>> patentListMaps = new ArrayList<>();
         //填充专利数据到patentListMap
@@ -895,216 +881,102 @@ public class ReportDocumentService extends ServiceImpl<ReportDocumentMapper, Rep
             patentListMaps.add(patentListMap);
 
         }
-        //存放对比方案信息的map集合
-        List<Map<String, Object>> scenariosMaps = new ArrayList<>(compareFiles.size());
-        //存放所有对比方案所有不重复的rightId
-        List<Integer> rightIds = new ArrayList<>();
-        for (int i = 0; i < compareScenarios.size(); i++) {
-            CompareScenarios item1 = compareScenarios.get(i);
-            //获得单个对比方案的
-            List<AssoScenarIOS> partScenariosRecords = scenariosRecords.stream().filter(item -> item.getScenariosID().equals(item1.getId())).collect(Collectors.toList());
-            List<Integer> featureRecordsIds = partScenariosRecords.stream().map(AssoScenarIOS::getFeatureRecordID).collect(Collectors.toList());
-            List<AssoRecordsFeature> assoRecordsFeatures1 = assoRecordsFeatures.stream().filter(item -> featureRecordsIds.contains(item.getId())).collect(Collectors.toList());
-            List<Integer> partRecordIds = assoRecordsFeatures1.stream().map(AssoRecordsFeature::getRecordsId).collect(Collectors.toList());
-            List<Integer> partFetIds = assoRecordsFeatures1.stream().map(AssoRecordsFeature::getFeatureId).collect(Collectors.toList());
-            //获得公识特征的ID
-            List<Integer> comFetIds = partScenariosRecords.stream().map(AssoScenarIOS::getFeaturesID).collect(Collectors.toList());
-            partFetIds.addAll(comFetIds);
-            //获得单个对比方案的权要的所有特征
-            List<Features> partFeatures = allFeatures.stream().filter(item -> partFetIds.contains(item.getId())).collect(Collectors.toList());
-            List<CompareRecords> records = compareRecords.stream().filter(item -> partRecordIds.contains(item.getId())).collect(Collectors.toList());
-            //获得单条权要所有的特征
-            List<Features> allRightFeatures = allFeatures.stream().filter(item -> item.getRightId().equals(item1.getRightId())).collect(Collectors.toList());
-            //存放单条对比结果的map
-            Map<String, Object> temMap = new HashMap<>();
-            String a = partFeatures.get(0).getRightName().replace("\r", "");
-            if (partFeatures.size() != 0 && partFeatures.get(0).getRightType().equals(1)) {
-                temMap.put("rightName", "独立" + a);
-            } else {
-                temMap.put("rightName", "附属" + a);
-            }
-            temMap.put("rightId", item1.getRightId());
-            if(report.getType()==1){
-                String rightContent =patentRights.stream().filter(t->t.getSort().equals(item1.getRightId())).map(PatentRight::getContent).findFirst().orElse("");
-                temMap.put("rightContent",rightContent);
-            }
-            temMap.put("remark", item1.getContrastResult());
-            // 从关联数据里获得特征id
-            if (!rightIds.contains(item1.getRightId())) {
-                rightIds.add(item1.getRightId());
+        List<Map<String, Object>> rightMaps = new ArrayList<>();
+        List<Integer> noveltyIds = new ArrayList<Integer>();
+        List<Integer> creativeIds = new ArrayList<Integer>();
+        for (Map<String, Object> right : rights) {
+            String text ="";
+            if (!right.get("parentSort").equals("-1")) {
+                String parentSort ="";
+                List<String> sorts =new ArrayList<>(Arrays.asList(right.get("parentSort").toString().split(",")));
+                List<Integer> sortIds =new ArrayList<>();
+                sorts.forEach(item->{
+                    sortIds.add(Integer.parseInt(item)+1);
+                });
+                parentSort =StringUtils.join(sortIds,"、");
+
+                text =right.get("rightNameLong")+"为引用权"+parentSort+"的从属权利要求,";
             }
-            //存放对比方案每一个特征记录
-            List<Map<String, Object>> maps = new ArrayList<>();
-            allRightFeatures.forEach(tem -> {
+            for (int i = 0; i < compareScenarios.size(); i++) {
+                CompareScenarios item1 = compareScenarios.get(i);
+                //判断是该权要的方案
+                if (right.get("sort").equals(item1.getRightId())) {
+                    //根据方案id获得特征和记录关联表的id
+                    List<Integer> temfeatureRecordIds = scenariosRecords.stream().filter(item -> item.getScenariosID().equals(item1.getId())).map(AssoScenarIOS::getFeatureRecordID).collect(Collectors.toList());
+                    //获得记录
+                    List<CompareRecords> compareRecords1 = new ArrayList<>();
+                    if (temfeatureRecordIds != null && temfeatureRecordIds.size() != 0) {
+                        // 根据关联表的id获得关联实体类
+                        List<AssoRecordsFeature> assoRecordsFeatures1 = assoRecordsFeatures.stream().filter(item -> temfeatureRecordIds.contains(item.getId())).collect(Collectors.toList());
+                        //根据实体类获得记录id
+                        List<Integer> temRecordIds = assoRecordsFeatures1.stream().map(AssoRecordsFeature::getRecordsId).collect(Collectors.toList());
+                        //根据记录id获得记录
+                        if (temRecordIds != null && temRecordIds.size() > 0) {
+                            LambdaQueryWrapper<CompareRecords> recordsWrapper = new LambdaQueryWrapper<>();
+                            recordsWrapper.in(CompareRecords::getId, temRecordIds);
+                            compareRecords1 = compareRecords.stream().filter(item -> temRecordIds.contains(item.getId())).collect(Collectors.toList());
+                        }
 
-                List<AssoRecordsFeature> assoRecordsFeatures2 = assoRecordsFeatures1.stream().filter(item -> item.getFeatureId().equals(tem.getId())).collect(Collectors.toList());
-                if (comFetIds.contains(tem.getId())) {
-                    Map<String, Object> map = new LinkedHashMap<>();
-                    map.put("featureContent", tem.getContent());
-                    map.put("compareResult", "公识");
-                    map.put("compareContent", "");
-                    maps.add(map);
-                } else if (assoRecordsFeatures2.size() != 0) {
-                    Map<String, Object> map = new LinkedHashMap<>();
-                    map.put("featureContent", tem.getContent());
-                    List<Map<String, Object>> temMap1 = new ArrayList<>();
-                    AssoRecordsFeature assoRecordsFeature = assoRecordsFeatures2.get(0);
-                    CompareRecords record = records.stream().filter(item -> item.getId().equals(assoRecordsFeature.getRecordsId())).findFirst().orElse(new CompareRecords());
-                    String compareContent = "";
-                    //获取对比内容
-                    String content = record.getContent() != null ? record.getContent() : "";
-                    //获得对比专利号
-                    String patentNo = record.getPatentNo() != null ? record.getPatentNo() : "";
-                    if (OtherName.containsKey(patentNo)) {
-                        patentNo = "D" + OtherName.get(patentNo).toString() + ":";
-                    } else if (!patentNo.equals("")) {
-                        patentNo += ":";
                     }
-                    //获得解析过程
-                    String paresingProcess = record.getParesingProcess() != null ? "(" + record.getParesingProcess() + ")" : "";
-                    compareContent = patentNo + content + paresingProcess;
-                    //获取对比专利号
-                    if (maps.size() > 0) {
-                        Map<String, Object> lastMap = maps.get(maps.size() - 1);
-                        if (lastMap.get("compareContent").toString().equals(compareContent)) {
-                            lastMap.put("featureContent", lastMap.get("featureContent") + tem.getContent());
-                        } else {
-                            map.put("compareResult", assoRecordsFeature.getComResult() != null ? assoRecordsFeature.getComResult() : "不公开");
-                            map.put("compareContent", compareContent);
+
+                    //判断方案是否具有创造性或者新颖性字眼
+                    if (item1.getContrastResult() != null && (item1.getContrastResult().contains("创造性") || item1.getContrastResult().contains("新颖性"))) {
+                       //装载对比记录
+                        List<Map<String,Object>> maps =new ArrayList<>();
+                        compareRecords1.forEach(record->{
+                            Map<String,Object> map =new HashMap<>();
                             map.put("figure", fileUtils.getSystemPath() + record.getFilePath());
                             if (record.getFields() == null && record.getPosition() == null) {
                                 map.put("position", "");
                             } else {
                                 map.put("position", "\r" + "(" + record.getFields() + "[" + record.getPosition() + "]" + ")");
                             }
+                            String compareContent = "";
+                            //获取对比内容
+                            String content = record.getContent() != null ? record.getContent() : "";
+                            //获得对比专利号
+                            String patentNo = record.getPatentNo() != null ? record.getPatentNo() : "";
+                            if (OtherName.containsKey(patentNo)) {
+                                patentNo = "D" + OtherName.get(patentNo).toString() + ":";
+                            } else if (!patentNo.equals("")) {
+                                patentNo += ":";
+                            }
+                            //获得解析过程
+                            String paresingProcess = record.getParesingProcess() != null ? "(" + record.getParesingProcess() + ")" : "";
+                            compareContent = patentNo + content + paresingProcess;
+                            map.put("compareContent", compareContent);
                             maps.add(map);
-                        }
-                    } else {
-                        map.put("compareResult", assoRecordsFeature.getComResult() != null ? assoRecordsFeature.getComResult() : "不公开");
-                        map.put("compareContent", compareContent);
-                        map.put("figure", fileUtils.getSystemPath() + record.getFilePath());
-                        if (record.getFields() == null && record.getPosition() == null) {
-                            map.put("position", "");
-                        } else {
-                            map.put("position", "\r" + "(" + record.getFields() + "[" + record.getPosition() + "]" + ")");
-                        }
-                        maps.add(map);
-                    }
-
-                } else {
-                    Map<String, Object> map = new LinkedHashMap<>();
-                    map.put("featureContent", tem.getContent());
-                    map.put("compareResult", "未公开");
-                    map.put("compareContent", "");
-                    maps.add(map);
-                }
+                        });
 
-            });
-            //方案内容
-            temMap.put("fileDetails", maps);
-            //新颖性模块
-            //获得本方案所有的专利号
-            List<String> patentNOs = new ArrayList<>();
-            records.forEach(item -> {
-                if (!patentNOs.contains(item.getPatentNo())) {
-                    patentNOs.add(item.getPatentNo());
-                }
-            });
-            //比较所有专利号和权要所有权要的大小,如果相等则将该专利加入到新颖性列表中
-            List<String> noveltyFiles = new ArrayList<>();
-            patentNOs.forEach(
-                    item -> {
-                        List<Integer> temRecordIds = records.stream().filter(tm -> tm.getPatentNo().equals(item)).map(CompareRecords::getId).collect(Collectors.toList());
-                        List<Integer> temFIds = finalAsso.stream().filter(tm -> temRecordIds.contains(tm.getRecordsId())).map(AssoRecordsFeature::getFeatureId).collect(Collectors.toList());
-                        String tmName = item;
-                        if (OtherName.containsKey(item)) {
-                            tmName = "D" + OtherName.get(item).toString();
-                        }
-                        if (temFIds.size() == allRightFeatures.size()) {
-                            noveltyFiles.add(tmName);
-                        }
-                    }
-            );
-            //创造性列表
-            List<String> creativeFiles = new ArrayList<>();
-            //当前方案所有的特征Id
-            records.forEach(
-                    item -> {
-                        String tmName = item.getPatentNo();
-                        if (OtherName.containsKey(tmName)) {
-                            tmName = "D" + OtherName.get(tmName).toString();
-                        }
-                        if (!creativeFiles.contains(tmName)) {
-                            creativeFiles.add(tmName);
-                        }
-                    }
-            );
-            List<AssoScenarIOS> andRecords = partScenariosRecords.stream().filter(tm -> tm.getScenariosID().equals(item1.getId()) && tm.getFeaturesID() != 0).collect(Collectors.toList());
-            if (andRecords.size() != 0) {
-                creativeFiles.add("C");
-            }
-            String creative = creativeFiles.size() == 0 ? "" : StringUtils.join(creativeFiles, "+");
-            String novelty = noveltyFiles.size() == 0 ? "" : StringUtils.join(noveltyFiles, "-");
-            //新颖性
-            temMap.put("novelty", novelty);
-            //创造性
-            temMap.put("creative", creative);
-            scenariosMaps.add(temMap);
-        }
-        List<Map<String, Object>> allRightScenarios = new ArrayList<>();
-        List<Map<String, Object>> resultMaps = new ArrayList<>();
-        // 存放创造性和新颖性的权要
+                        if (item1.getContrastResult().contains("创造性")) {
+                            creativeIds.add(Integer.parseInt(right.get("sort").toString()) + 1);
 
-        rightIds.forEach(tem -> {
-            Map<String, Object> map = new HashMap<>();
-            Map<String, Object> resultMap = new HashMap<>();
-            List<Map<String, Object>> rightScenarios = new ArrayList<>();
-            //存放新颖性信息
-            List<String> noveList = new ArrayList<>();
-            List<String> creaList = new ArrayList<>();
-            //存放创造性信息
-            for (int t = 0; t < scenariosMaps.size(); t++) {
-                Map<String, Object> item = scenariosMaps.get(t);
-                if (item.get("rightId").equals(tem)) {
-                    item.put("scenariosName", "对比组合" + (t + 1));
-                    rightScenarios.add(item);
-                    if (item.get("novelty").toString() != "") {
-                        if (!noveList.contains(item.get("novelty").toString())) {
-                            noveList.add(item.get("novelty").toString());
-                        }
-                    }
-                    if (item.get("creative").toString() != "") {
-                        if (!creaList.contains(item.get("creative").toString())) {
-                            creaList.add(item.get("creative").toString());
+                            right.put("records", maps);
+                            right.put("text", "第3款的创造性的规定。\n"+text+right.get("rightNameLong")+"的附加技术特征为:");
+                            rightMaps.add(right);
+                        } else if (item1.getContrastResult().contains("新颖性")) {
+                            noveltyIds.add(Integer.parseInt(right.get("sort").toString()) + 1);
+                            right.put("text", "第2款的新颖性的规定。\n"+text+right.get("rightNameLong")+"保护的主体,具体:");
+                            right.put("records", compareRecords1);
+                            rightMaps.add(right);
                         }
                     }
                 }
             }
-            map.put("rightScenrios", rightScenarios);
-            map.put("rightName", rightScenarios.get(0).get("rightName"));
-            String creative = creaList.size() == 0 ? "" : StringUtils.join(creaList, "、");
-            String novelty = noveList.size() == 0 ? "" : StringUtils.join(noveList, "-");
-            resultMap.put("rightName", rightScenarios.get(0).get("rightName"));
-            resultMap.put("rightNovelty", novelty);
-            resultMap.put("rightCreative", creative);
-            allRightScenarios.add(map);
-            resultMaps.add(resultMap);
-        });
-        //1.系统数据
-        //存放单条对比结果的map
+
+        }
+        String noveltyIdStr = StringUtils.join(noveltyIds, ",");
+        String creativeIdStr = StringUtils.join(creativeIds, ",");
         Map<String, Object> map = new HashMap<>();
         String date = DateUtils.formatDate(new Date(), DateUtils.YYYY_MM_DD);
         String[] ds = date.split("-");
         map.put("sys", new SystemMO(ds[0], ds[1], ds[2], "", "reportName"));
-        if (patentListMaps.size() > 1) {
-            patentListMaps = this.sortMap(patentListMaps);
-        }
-        map.put("patentList", patentListMaps);
-        map.put("combinations", allRightScenarios);
-        map.put("allResults", resultMaps);
         map.put("signPatent", signPatent);
         map.put("pantentNo", report.getSignPatentNo());
-        map.put("rights", signPatent.get("rights"));
+        map.put("rights", rightMaps);
+        map.put("noveltyIdStr", noveltyIdStr);
+        map.put("creativeIdStr", creativeIdStr);
+        map.put("patentList", patentListMaps);
         // 为表格的显示绑定行循环
         LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
         HtmlRenderPolicy htmlRenderPolicy = new HtmlRenderPolicy();
@@ -1178,7 +1050,9 @@ public class ReportDocumentService extends ServiceImpl<ReportDocumentMapper, Rep
             Map<String, Object> temMap = new HashMap<>();
             temMap.put("rightName", "权" + (item.getSort() + 1));
             temMap.put("content", item.getContent());
-            temMap.put("rightName","权利要求"+(item.getSort() + 1));
+            temMap.put("rightNameLong", "权利要求" + (item.getSort() + 1));
+            temMap.put("parentSort", item.getParentSort());
+            temMap.put("sort", item.getSort());
             rights.add(temMap);
         });
         patentMap.put("rights", rights);

+ 1 - 1
RMS/src/main/resources/application-dev.yml

@@ -30,7 +30,7 @@ spring:
         max-wait: -1ms
     timeout: 2000ms
   datasource:
-    url: jdbc:mysql://192.168.1.24:3306/rms_test?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=GMT%2B8
+    url: jdbc:mysql://192.168.1.24:3306/RMS_TEST?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=GMT%2B8
     driver-class-name: com.mysql.cj.jdbc.Driver
     username: root
     password: rrzTwWAYX8Gxh5JH