Просмотр исходного кода

2/23 修改回避设计相关代码

chendayu 2 лет назад
Родитель
Сommit
7d0c111ed1

+ 52 - 47
RMS/src/main/java/cn/cslg/report/common/model/SystemMO.java

@@ -1,8 +1,13 @@
 package cn.cslg.report.common.model;
 
+import lombok.Data;
+import lombok.experimental.Accessors;
+
 /**
  * 报表系统数据 年月日、专案代码
  */
+@Accessors(chain = true)
+@Data
 public class SystemMO {
     private String year; //年
     private String month; //月
@@ -22,51 +27,51 @@ public class SystemMO {
         this.reportName=report;
     }
 
-    public String getReportName() {
-        return reportName;
-    }
-
-    public void setReportName(String reportName) {
-        this.reportName = reportName;
-    }
-
-    public String getYear() {
-        return year;
-    }
-
-    public void setYear(String year) {
-        this.year = year;
-    }
-
-    public String getMonth() {
-        return month;
-    }
-
-    public void setMonth(String month) {
-        this.month = month;
-    }
-
-    public String getDay() {
-        return day;
-    }
-
-    public void setDay(String day) {
-        this.day = day;
-    }
-
-    public String getDate() {
-        return date;
-    }
-
-    public void setDate(String date) {
-        this.date = date;
-    }
-
-    public String getZadm() {
-        return zadm;
-    }
-
-    public void setZadm(String zadm) {
-        this.zadm = zadm;
-    }
+//    public String getReportName() {
+//        return reportName;
+//    }
+//
+//    public void setReportName(String reportName) {
+//        this.reportName = reportName;
+//    }
+//
+//    public String getYear() {
+//        return year;
+//    }
+//
+//    public void setYear(String year) {
+//        this.year = year;
+//    }
+//
+//    public String getMonth() {
+//        return month;
+//    }
+//
+//    public void setMonth(String month) {
+//        this.month = month;
+//    }
+//
+//    public String getDay() {
+//        return day;
+//    }
+//
+//    public void setDay(String day) {
+//        this.day = day;
+//    }
+//
+//    public String getDate() {
+//        return date;
+//    }
+//
+//    public void setDate(String date) {
+//        this.date = date;
+//    }
+//
+//    public String getZadm() {
+//        return zadm;
+//    }
+//
+//    public void setZadm(String zadm) {
+//        this.zadm = zadm;
+//    }
 }

+ 3 - 6
RMS/src/main/java/cn/cslg/report/controller/ProductController.java

@@ -24,7 +24,7 @@ import java.util.List;
  * 产品的Controller层
  *
  * @Author chenyu
- * @Data 2022/12/20
+ * @Date 2022/12/20
  */
 @Tag(name = "产品管理模块")
 @Slf4j
@@ -69,15 +69,12 @@ public class ProductController {
     @Operation(summary = "根据报告id查询产品数据信息")
     @GetMapping("/getProduct")
     public String getProduct(Integer reportId) {
-        log.info("开始处理【查询产品】的请求,参数为:{}", reportId);
+        log.info("开始处理【查询产品】的请求,请求参数为:{}", reportId);
         if (reportId != null) {
             ProductIncludeFilesVO queryResult = productService.getProduct(reportId);
             return Response.success(queryResult);
-        } else {
-            log.info("前端未传报告reportId");
-            return Response.error("前端未传报告reportId");
         }
-
+        return Response.error("请求参数为null");
     }
 
 }

+ 6 - 5
RMS/src/main/java/cn/cslg/report/controller/ReportDocumentController.java

@@ -23,22 +23,23 @@ import java.io.IOException;
 @SuppressWarnings({"all"})
 public class ReportDocumentController {
     public final ReportDocumentService reportDocumentService;
+
     @RequestMapping(value = "/exportReport", method = RequestMethod.GET)
     @Operation(summary = "导出报告")
-    public  String exportReport(Integer reportId,Integer templeId) throws IOException {
-        return reportDocumentService.exportReport(reportId,templeId);
+    public String exportReport(Integer reportId, Integer templeId) throws IOException {
+        return reportDocumentService.exportReport(reportId, templeId);
     }
 
     @RequestMapping(value = "/getExportList", method = RequestMethod.POST)
     @Operation(summary = "获得导出记录")
-    public  String getExportList(@RequestBody ReportDocument reportDocument) throws IOException {
+    public String getExportList(@RequestBody ReportDocument reportDocument) throws IOException {
         return reportDocumentService.getExportList(reportDocument);
     }
 
     @RequestMapping(value = "/deleteExport", method = RequestMethod.GET)
     @Operation(summary = "删除导出记录")
-    public  String deleteExport(Integer id) throws IOException {
+    public String deleteExport(Integer id) throws IOException {
         return reportDocumentService.deleteExport(id);
     }
-    
+
 }

+ 4 - 0
RMS/src/main/java/cn/cslg/report/entity/AssoProductFile.java

@@ -15,6 +15,10 @@ import java.io.Serializable;
 @Data
 public class AssoProductFile implements Serializable {
     /**
+     * 主键ID
+     */
+    private Integer id;
+    /**
      * 产品ID
      */
     private Integer productId;

+ 25 - 25
RMS/src/main/java/cn/cslg/report/entity/Report.java

@@ -14,7 +14,7 @@ import java.util.List;
 @Accessors(chain = true)
 @EqualsAndHashCode(callSuper = true)
 @TableName(value = "REPORT")
-@Schema(description="报告",required = true)
+@Schema(description = "报告", required = true)
 @NoArgsConstructor
 @AllArgsConstructor
 @Builder(toBuilder = true)
@@ -22,163 +22,163 @@ public class Report extends BaseEntity<Report> {
     /**
      * 标的专利/产品号
      */
-    @Schema(description="标的专利号",required = true)
+    @Schema(description = "标的专利号", required = true)
     @TableField(value = "SIGN_PATENT_NO")
     private String signPatentNo;
 
     /**
      * 报告名称
      */
-    @Schema(description="报告名称",required = true)
+    @Schema(description = "报告名称", required = true)
     @TableField(value = "NAME")
     private String name;
 
     /**
      * 产品/技术
      */
-    @Schema(description="产品/技术")
+    @Schema(description = "产品/技术")
     @TableField(value = "PRO_TEC")
     private String proTec;
 
     /**
      * 报告类别
      */
-    @Schema(description="报告类别(0无效分析1第三方意见2稳定性分析3FTO调查4侵权分析5回避设计6图表分析)")
+    @Schema(description = "报告类别(0无效分析1第三方意见2稳定性分析3FTO调查4侵权分析5回避设计6图表分析)")
     @TableField(value = "TYPE")
     private Integer type;
 
     /**
      * 报告状态
      */
-    @Schema(description="报告状态")
+    @Schema(description = "报告状态")
     @TableField(value = "STATUS")
     private Integer status;
 
     /**
      * 报告生成时间
      */
-    @Schema(description="报告生成时间")
+    @Schema(description = "报告生成时间")
     @TableField(value = "CREATE_TIME")
     private Date createTime;
 
     /**
      * 报告生成文件ID
      */
-    @Schema(description="报告生成文件ID")
+    @Schema(description = "报告生成文件ID")
     @TableField(value = "REPORT_FILE_ID")
     private Integer reportFileId;
 
     /**
      * 负责人ID
      */
-    @Schema(description="负责人ID")
+    @Schema(description = "负责人ID")
     @TableField(value = "PERSON_ID")
     private Integer personId;
     /**
      * 负责人ID
      */
-    @Schema(description="负责人姓名")
+    @Schema(description = "负责人姓名")
     @TableField(value = "PERSON_NAME")
     private String personName;
 
     /**
      * 委托人ID
      */
-    @Schema(description="委托人ID")
+    @Schema(description = "委托人ID")
     @TableField(value = "CLIENT_ID")
     private Integer clientId;
 
     /**
      * 委托人姓名
      */
-    @Schema(description="委托人姓名")
+    @Schema(description = "委托人姓名")
     @TableField(value = "CLIENT_NAME")
     private String clientName;
 
     /**
      * 承担部门ID
      */
-    @Schema(description="承担部门ID")
+    @Schema(description = "承担部门ID")
     @TableField(value = "DEPARTMENT_ID")
     private Integer departmentId;
 
     /**
      * 承担部门名称
      */
-    @Schema(description="承担部门名称")
+    @Schema(description = "承担部门名称")
     @TableField(value = "DEPARTMENT_NAME")
     private String departmentName;
 
     /**
      * 关联报告ID
      */
-    @Schema(description="关联报告ID")
+    @Schema(description = "关联报告ID")
     @TableField(value = "ASSOCIATE_REPORT_ID")
     private Integer associateReportId;
 
     /**
      * 关联报告名称
      */
-    @Schema(description="关联报告名称")
+    @Schema(description = "关联报告名称")
     @TableField(value = "ASSOCIATE_REPORT_NAME")
     private String associateReportName;
 
     /**
      * 应用场景
      */
-    @Schema(description="应用场景")
+    @Schema(description = "应用场景")
 
     @TableField("SCENARIO_ID")
     private String scenarioId;
     /**
      * 调查类型
      */
-    @Schema(description="调查类型")
+    @Schema(description = "调查类型")
     @TableField(value = "IT_FLAG")
     private Integer itFlag;
 
     /**
      * 专题库ID
      */
-    @Schema(description="专题库ID")
+    @Schema(description = "专题库ID")
     @TableField(value = "PROJECT_ID")
     private Integer projectId;
 
     /**
      * 卷号
      */
-    @Schema(description="卷号")
+    @Schema(description = "卷号")
     @TableField(value = "VOLUME_NUMBER")
     private String volumeNumber;
     /**
      * 拆分根据
      */
-    @Schema(description="拆分根据")
+    @Schema(description = "拆分根据")
     @TableField(value = "SPLIT_BY")
     private Integer splitBy;
     /**
      * 拆分类型
      */
-    @Schema(description="拆分类型")
+    @Schema(description = "拆分类型")
     @TableField(value = "SPLIT_TYPE")
     private Integer splitType;
 
     /**
      * 创建人ID
      */
-    @Schema(description="创建人ID")
+    @Schema(description = "创建人ID")
     @TableField(value = "CREATE_PERSON_ID")
     private Integer createPersonId;
     /**
      * 创建人姓名
      */
-    @Schema(description="创建人姓名")
+    @Schema(description = "创建人姓名")
     @TableField(value = "CREATE_PERSON_NAME")
     private String createPersonName;
     /**
      * 备注
      */
-    @Schema(description="REMARK")
+    @Schema(description = "REMARK")
     @TableField(value = "REMARK")
     private String remark;
 

+ 4 - 4
RMS/src/main/java/cn/cslg/report/mapper/AssoProductFileMapper.java

@@ -22,17 +22,17 @@ public interface AssoProductFileMapper {
     int insertBatch(List<AssoProductFile> assoProductFiles);
 
     /**
-     * 根据附件fileId批量删除产品文件关联表数据
+     * 根据附件fileId批量删除数据
      *
-     * @param fileIds 附件id集合
+     * @param fileIds 附件fileId集合
      * @return 返回受影响的行数
      */
     int deleteByFileIds(List<Integer> fileIds);
 
     /**
-     * 根据产品productId删除产品文件关联表数据
+     * 根据产品productId删除数据
      *
-     * @param productId 产品id
+     * @param productId 产品productId
      * @return 返回受影响的行数
      */
     int deleteByProductId(Integer productId);

+ 1 - 1
RMS/src/main/java/cn/cslg/report/service/IAssoProductFileService.java

@@ -18,7 +18,7 @@ public interface IAssoProductFileService {
     void addAsso(Integer productId, List<Integer> fileIds);
 
     /**
-     * 根据附件fileId删除产品文件关联数据
+     * 根据附件fileId删除数据
      *
      * @param fileIds 附件id集合
      */

+ 1 - 1
RMS/src/main/java/cn/cslg/report/service/IProductService.java

@@ -13,7 +13,7 @@ import java.util.List;
  * 产品的Service层接口
  *
  * @Author chenyu
- * @Data 2022/12/20
+ * @Date 2022/12/20
  */
 public interface IProductService {
     /**

+ 184 - 186
RMS/src/main/java/cn/cslg/report/service/business/ReportDocumentService.java

@@ -2,7 +2,6 @@ package cn.cslg.report.service.business;
 
 import cn.cslg.report.common.model.SystemMO;
 import cn.cslg.report.common.model.vo.CompareMessageVO;
-import cn.cslg.report.common.model.vo.PatentRightVo;
 import cn.cslg.report.common.model.vo.PatentVO;
 import cn.cslg.report.common.model.vo.PersonnelVO;
 import cn.cslg.report.common.utils.*;
@@ -10,7 +9,6 @@ import cn.cslg.report.common.utils.SecurityUtils.LoginUtils;
 import cn.cslg.report.entity.*;
 import cn.cslg.report.entity.asso.AssoRecordsFeature;
 import cn.cslg.report.mapper.ReportDocumentMapper;
-
 import cn.cslg.report.service.OutInterfaceService;
 import cn.hutool.core.util.IdUtil;
 import com.alibaba.fastjson.JSON;
@@ -22,22 +20,15 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.deepoove.poi.XWPFTemplate;
 import com.deepoove.poi.config.Configure;
 import com.deepoove.poi.plugin.table.LoopRowTableRenderPolicy;
-import io.swagger.v3.oas.models.security.SecurityScheme;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.poi.poifs.filesystem.DirectoryEntry;
-import org.apache.poi.poifs.filesystem.DocumentEntry;
-import org.apache.poi.poifs.filesystem.POIFSFileSystem;
-import org.apache.poi.ss.formula.functions.T;
 import org.ddr.poi.html.HtmlRenderPolicy;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.io.ByteArrayInputStream;
 import java.io.File;
-import java.io.FileInputStream;
 import java.io.IOException;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -68,6 +59,7 @@ public class ReportDocumentService extends ServiceImpl<ReportDocumentMapper, Rep
     private String rmsFile;
     @Value("${PASFile}")
     private String pasFile;
+
     public String reportDocument(ReportDocument reportDocument) {
 
         return Response.success();
@@ -104,7 +96,7 @@ public class ReportDocumentService extends ServiceImpl<ReportDocumentMapper, Rep
         Template reportTemplate = templateService.getById(templeId);
         //获得模板路径
         String filePath = fileUtils.getPath(reportTemplate.getTemplatePath());
-        // 读取模板后保存生成word的地址
+        //读取模板后保存生成word的地址
         String fileName = IdUtil.simpleUUID() + ".docx";
         String directoryName = fileUtils.createDirectory();
         String outPath = fileUtils.getSavePath(directoryName) + fileName;
@@ -114,9 +106,10 @@ public class ReportDocumentService extends ServiceImpl<ReportDocumentMapper, Rep
             template = this.getstabilityTemplate(report, filePath);
         } else if (report.getType() == 3) {
             template = this.FTOtemplate(reportId, filePath, templeId);
-        }
-        else if(report.getType()==4){
+        } else if (report.getType() == 4) {
             template = this.Torttemplate(reportId, filePath, templeId);
+        } else if (report.getType() == 5) {
+            template = this.avoidDesignTemplate(reportId, filePath, templeId);
         }
         // 读取模板、数据并渲染
 //         文件是否已存在,则删除
@@ -150,7 +143,7 @@ public class ReportDocumentService extends ServiceImpl<ReportDocumentMapper, Rep
      */
     private XWPFTemplate getstabilityTemplate(Report report, String filePath) throws IOException {
         //装载标的专利信息
-        Map<String,Object> signPatent = this.signPantentMess(report.getSignPatentNo());
+        Map<String, Object> signPatent = this.signPantentMess(report.getSignPatentNo());
         //根据报告Id获得报告信息
         // 根据拆分人(报告的创建人)Id和报告ID获得所有特征
         LambdaQueryWrapper<Features> allFeaturesWrapper = new LambdaQueryWrapper<>();
@@ -173,7 +166,7 @@ public class ReportDocumentService extends ServiceImpl<ReportDocumentMapper, Rep
         //获得对比记录-特征关联ID
         List<Integer> recordfeatureRecordIds = scenariosRecords.stream().map(AssoScenarIOS::getFeatureRecordID).collect(Collectors.toList());
         //从关联表里获得是公识的特征Id
-        List<Integer> knowedIds= scenariosRecords.stream().map(AssoScenarIOS::getFeaturesID).collect(Collectors.toList());
+        List<Integer> knowedIds = scenariosRecords.stream().map(AssoScenarIOS::getFeaturesID).collect(Collectors.toList());
         //根据对比记录-特征关联ID查出对比记录-特征关联信息
         List<AssoRecordsFeature> assoRecordsFeatures = new ArrayList<>();
         if (recordfeatureRecordIds != null && recordfeatureRecordIds.size() != 0) {
@@ -206,18 +199,19 @@ public class ReportDocumentService extends ServiceImpl<ReportDocumentMapper, Rep
         PatentVO patentVO = new PatentVO();
         patentVO.setPatentNos(PatentNos);
         //根据专利号查询专利的排序
-        LambdaQueryWrapper<CompareFiles> comWrapper =new LambdaQueryWrapper<>();
+        LambdaQueryWrapper<CompareFiles> comWrapper = new LambdaQueryWrapper<>();
         comWrapper
-                .eq(CompareFiles::getReportId,report.getId())
-                .last("ORDER BY IF(isnull(SYS_ORDER),1,0), SYS_ORDER ASC");;
-        List<CompareFiles> compareFiles =compareFilesService.list(comWrapper);
+                .eq(CompareFiles::getReportId, report.getId())
+                .last("ORDER BY IF(isnull(SYS_ORDER),1,0), SYS_ORDER ASC");
+        ;
+        List<CompareFiles> compareFiles = compareFilesService.list(comWrapper);
         //专利号别名的map
         Map<String, Object> OtherName = new HashMap<>();
-        int flag=1;
-        for(CompareFiles item:compareFiles)
-        { Integer order = item.getSysOrder()==null?flag:item.getSysOrder();
-                OtherName.put(item.getPatentNo(),order);
-        flag++;
+        int flag = 1;
+        for (CompareFiles item : compareFiles) {
+            Integer order = item.getSysOrder() == null ? flag : item.getSysOrder();
+            OtherName.put(item.getPatentNo(), order);
+            flag++;
         }
 
         //根据专利号查询专利详细信息
@@ -255,7 +249,7 @@ public class ReportDocumentService extends ServiceImpl<ReportDocumentMapper, Rep
                 feaListContent.forEach(te -> disclosures.append("(" + te + ")"));
                 disclosures.append("\n");
             }
-          int order=Integer.parseInt(OtherName.get(item.get("publicNo")).toString());
+            int order = Integer.parseInt(OtherName.get(item.get("publicNo")).toString());
 
             patentListMap.put("name", item.get("name"));
             patentListMap.put("fileName", "D" + order);
@@ -265,11 +259,11 @@ public class ReportDocumentService extends ServiceImpl<ReportDocumentMapper, Rep
             patentListMap.put("applicant", applicants);
             patentListMap.put("patentNo", item.get("publicNo"));
             patentListMap.put("abstractStr", item.get("abstractStr"));
-            patentListMap.put("compareFileName", "对比文件" + (order ));
+            patentListMap.put("compareFileName", "对比文件" + (order));
             patentListMap.put("applicationDate", item.get("applicationDate"));
             patentListMap.put("abstractPath", pasFile + item.get("abstractPath"));
             patentListMap.put("disclosures", disclosures);
-            patentListMap.put("order",order);
+            patentListMap.put("order", order);
             patentListMaps.add(patentListMap);
 
         }
@@ -313,71 +307,67 @@ public class ReportDocumentService extends ServiceImpl<ReportDocumentMapper, Rep
             List<Map<String, Object>> maps = new ArrayList<>();
             allRightFeatures.forEach(tem -> {
 
-               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);
-                           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.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);
-               }
+                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);
+                            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.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);
+                }
 
             });
             //方案内容
@@ -398,7 +388,7 @@ public class ReportDocumentService extends ServiceImpl<ReportDocumentMapper, Rep
                         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();
+                            tmName = "D" + OtherName.get(item).toString();
                         }
                         if (temFIds.size() == allRightFeatures.size()) {
                             noveltyFiles.add(tmName);
@@ -412,7 +402,7 @@ public class ReportDocumentService extends ServiceImpl<ReportDocumentMapper, Rep
                     item -> {
                         String tmName = item.getPatentNo();
                         if (OtherName.containsKey(tmName)) {
-                            tmName = "D"+OtherName.get(tmName).toString();
+                            tmName = "D" + OtherName.get(tmName).toString();
                         }
                         if (!creativeFiles.contains(tmName)) {
                             creativeFiles.add(tmName);
@@ -474,20 +464,20 @@ public class ReportDocumentService extends ServiceImpl<ReportDocumentMapper, Rep
         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);
+        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("signPatent", signPatent);
+        map.put("pantentNo", report.getSignPatentNo());
+        map.put("rights", signPatent.get("rights"));
         // 为表格的显示绑定行循环
         LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
         HtmlRenderPolicy htmlRenderPolicy = new HtmlRenderPolicy();
         // 将bz设置为行循环绑定的数据源的key,即key是bz的value会在模板中的{{bz}}处进行解析
-        Configure configure = Configure.builder().bind("patentList", policy).bind("fileDetails", policy).bind("allResults", policy).bind("signPatent.rights",policy).bind("remark", htmlRenderPolicy).build();
+        Configure configure = Configure.builder().bind("patentList", policy).bind("fileDetails", policy).bind("allResults", policy).bind("signPatent.rights", policy).bind("remark", htmlRenderPolicy).build();
         // 读取模板、数据并渲染
         XWPFTemplate template = XWPFTemplate.compile(filePath, configure).render(map);
         return template;
@@ -627,93 +617,100 @@ public class ReportDocumentService extends ServiceImpl<ReportDocumentMapper, Rep
      * @description 装载侵权分析模板
      */
     private XWPFTemplate Torttemplate(Integer reportId, String filePath, Integer templateId) throws IOException {
-            //根据报告Id查询标的专利号
-        Report report =reportService.getById(reportId);
-        String patentNo =report.getSignPatentNo();
-            PatentVO patentVO = new PatentVO();
-            patentVO.setPatentNos(Arrays.asList(patentNo));
-            //根据专利号查询专利详细信息
-            String resBody = outInterfaceService.getPatentDTOListForRMS(patentVO);
-            JSONObject jsonObject = JSONObject.parseObject(resBody);
-            List<JSONObject> patentDTOS = JSON.parseArray(jsonObject.get("data").toString(), JSONObject.class);
+        //根据报告Id查询标的专利号
+        Report report = reportService.getById(reportId);
+        String patentNo = report.getSignPatentNo();
+        PatentVO patentVO = new PatentVO();
+        patentVO.setPatentNos(Arrays.asList(patentNo));
+        //根据专利号查询专利详细信息
+        String resBody = outInterfaceService.getPatentDTOListForRMS(patentVO);
+        JSONObject jsonObject = JSONObject.parseObject(resBody);
+        List<JSONObject> patentDTOS = JSON.parseArray(jsonObject.get("data").toString(), JSONObject.class);
         //装载单个专利的信息
         Map<String, Object> patentMap = new HashMap<>();
-          JSONObject patent = patentDTOS.get(0);
-                List<JSONObject> applicantJSONs = JSON.parseArray(patent.get("applicant").toString(), JSONObject.class);
-                StringBuilder applicants = new StringBuilder();
-                StringBuilder rightPerson = new StringBuilder();
-                applicantJSONs.forEach(tem -> {
-                    if (Integer.parseInt(tem.get("dataType").toString()) == 1) {
-                        applicants.append(tem.get("name") + "\r");
-                    } else {
-                        rightPerson.append(tem.get("name") + "\r");
-                    }
-                });
-                //装载同族信息
-                JSONObject familys = JSONObject.parseObject(patent.get("family").toString());
-                List<String> patSnaps = JSON.parseArray(familys.get("patSnap").toString(), String.class);
-                List<String> simples = JSON.parseArray(familys.get("simple").toString(), String.class);
-                List<String> inpadocs = JSON.parseArray(familys.get("inpadoc").toString(), String.class);
-                patSnaps.addAll(simples);
-                patSnaps.addAll(inpadocs);
-                String familyStr = StringUtils.join(patSnaps, ",");
-                //装载法律状态
-                StringBuilder affair = new StringBuilder();
-                List<JSONObject> affaires = JSON.parseArray(patent.get("affair").toString(), JSONObject.class);
-                affaires.forEach(item -> {
-                            affair.append(item.get("status") + "\r");
-                        }
-                );
-                //同族专利
-                patentMap.put("simpleFamilys", familyStr);
-                //引用专利
-                patentMap.put("quotePatents", patent.get("quote"));
-                //申请日
-                patentMap.put("applicationDate", patent.get("applicationDate"));
-                //公开日
-                patentMap.put("publicDate", patent.get("publicDate"));
-                //专利号
-                patentMap.put("publicNo", patent.get("publicNo"));
-                patentMap.put("firstPublicDate", patent.get("firstPublicDate"));
-                patentMap.put("applicant", applicants);
-                patentMap.put("rightPerson", rightPerson);
-                patentMap.put("affair", affair);
-                patentMap.put("name", patent.get("name"));
-                //图示
-                patentMap.put("abstractPath", "http://139.224.24.90:8081" + patent.get("abstractPath"));
-                //获得专利对比记录的信息
-                Map<String, Object> temMap = compareMessageService.queryforTemplate(patent.get("patentNo").toString(), reportId);
-                List<CompareMessageVO> compareMessageVOS = (List<CompareMessageVO>) temMap.get("compareMessageVOs");
-                //装载对比记录的信息
-                patentMap.put("cM", compareMessageVOS);
-                patentMap.put("rightNum", temMap.get("right"));
-                patentMap.put("mainRightNum", temMap.get("mainRight"));
+        JSONObject patent = patentDTOS.get(0);
+        List<JSONObject> applicantJSONs = JSON.parseArray(patent.get("applicant").toString(), JSONObject.class);
+        StringBuilder applicants = new StringBuilder();
+        StringBuilder rightPerson = new StringBuilder();
+        applicantJSONs.forEach(tem -> {
+            if (Integer.parseInt(tem.get("dataType").toString()) == 1) {
+                applicants.append(tem.get("name") + "\r");
+            } else {
+                rightPerson.append(tem.get("name") + "\r");
+            }
+        });
+        //装载同族信息
+        JSONObject familys = JSONObject.parseObject(patent.get("family").toString());
+        List<String> patSnaps = JSON.parseArray(familys.get("patSnap").toString(), String.class);
+        List<String> simples = JSON.parseArray(familys.get("simple").toString(), String.class);
+        List<String> inpadocs = JSON.parseArray(familys.get("inpadoc").toString(), String.class);
+        patSnaps.addAll(simples);
+        patSnaps.addAll(inpadocs);
+        String familyStr = StringUtils.join(patSnaps, ",");
+        //装载法律状态
+        StringBuilder affair = new StringBuilder();
+        List<JSONObject> affaires = JSON.parseArray(patent.get("affair").toString(), JSONObject.class);
+        affaires.forEach(item -> {
+                    affair.append(item.get("status") + "\r");
+                }
+        );
+        //同族专利
+        patentMap.put("simpleFamilys", familyStr);
+        //引用专利
+        patentMap.put("quotePatents", patent.get("quote"));
+        //申请日
+        patentMap.put("applicationDate", patent.get("applicationDate"));
+        //公开日
+        patentMap.put("publicDate", patent.get("publicDate"));
+        //专利号
+        patentMap.put("publicNo", patent.get("publicNo"));
+        patentMap.put("firstPublicDate", patent.get("firstPublicDate"));
+        patentMap.put("applicant", applicants);
+        patentMap.put("rightPerson", rightPerson);
+        patentMap.put("affair", affair);
+        patentMap.put("name", patent.get("name"));
+        //图示
+        patentMap.put("abstractPath", "http://139.224.24.90:8081" + patent.get("abstractPath"));
+        //获得专利对比记录的信息
+        Map<String, Object> temMap = compareMessageService.queryforTemplate(patent.get("patentNo").toString(), reportId);
+        List<CompareMessageVO> compareMessageVOS = (List<CompareMessageVO>) temMap.get("compareMessageVOs");
+        //装载对比记录的信息
+        patentMap.put("cM", compareMessageVOS);
+        patentMap.put("rightNum", temMap.get("right"));
+        patentMap.put("mainRightNum", temMap.get("mainRight"));
         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"));
         map.put("patentMap", patentMap);
-        map.put("",patentNo);
+        map.put("", patentNo);
         // 为表格的显示绑定行循环
         LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
         HtmlRenderPolicy htmlRenderPolicy = new HtmlRenderPolicy();
         // 将bz设置为行循环绑定的数据源的key,即key是bz的value会在模板中的{{bz}}处进行解析
-        Configure configure = Configure.builder().bind("cM", policy).bind("targetDescription",htmlRenderPolicy).build();
+        Configure configure = Configure.builder().bind("cM", policy).bind("targetDescription", htmlRenderPolicy).build();
         XWPFTemplate template = XWPFTemplate.compile(filePath, configure).render(map);
         return template;
     }
+
+    private XWPFTemplate avoidDesignTemplate(Integer reportId, String filePath, Integer templateId) {
+
+
+        return null;
+    }
+
     /**
      * function:删除报告时删除
      */
     @Transactional(rollbackFor = Exception.class)
-    public String deleteByReportId(Integer id){
+    public String deleteByReportId(Integer id) {
         LambdaQueryWrapper<ReportDocument> wrapper = new LambdaQueryWrapper<>();
         wrapper.eq(ReportDocument::getReportId, id);
         remove(wrapper);
         return Response.success();
     }
 
-    public Map<String,Object> signPantentMess(String patentNo) throws IOException {
+    public Map<String, Object> signPantentMess(String patentNo) throws IOException {
         PatentVO patentVO = new PatentVO();
         patentVO.setPatentNos(Arrays.asList(patentNo));
         //根据专利号查询专利详细信息
@@ -739,7 +736,7 @@ public class ReportDocumentService extends ServiceImpl<ReportDocumentMapper, Rep
         //公开日
         patentMap.put("publicDate", patent.get("publicDate"));
         //公开号
-        patentMap.put("publicNo",patent.get("publicNo"));
+        patentMap.put("publicNo", patent.get("publicNo"));
         //专利号
         patentMap.put("patentNo", patent.get("patentNo"));
         //专利权人
@@ -752,32 +749,33 @@ public class ReportDocumentService extends ServiceImpl<ReportDocumentMapper, Rep
         JSONObject jsonObject2 = JSONObject.parseObject(resBody2);
         //解析jason获得标的专利的权要
         List<PatentRight> patentRightsOrgin = JSON.parseArray(jsonObject2.getString("data"), PatentRight.class);
-        List<Map<String,Object>> rights =new ArrayList<>();
-        patentRightsOrgin.forEach(item->{
-            Map<String,Object> temMap =new HashMap<>();
-            temMap.put("rightName","权"+item.getSort());
-            temMap.put("content",item.getContent());
+        List<Map<String, Object>> rights = new ArrayList<>();
+        patentRightsOrgin.forEach(item -> {
+            Map<String, Object> temMap = new HashMap<>();
+            temMap.put("rightName", "权" + item.getSort());
+            temMap.put("content", item.getContent());
             rights.add(temMap);
         });
-        patentMap.put("rights",rights);
-        return  patentMap;
+        patentMap.put("rights", rights);
+        return patentMap;
+    }
+
+    public List<Map<String, Object>> sortMap(List<Map<String, Object>> maps) {
+
+        for (int i = 0; i < maps.size() - 1; i++) {
+            for (int j = 0; j < maps.size() - i - 1; j++) {
+                Integer order1 = Integer.parseInt(maps.get(j).get("order").toString());
+                Integer order2 = Integer.parseInt(maps.get(j + 1).get("order").toString());
+                if (order1 > order2) {
+                    Map<String, Object> temp = maps.get(j);
+                    maps.set(j, maps.get(j + 1));
+                    maps.set(j + 1, temp);
+                }
+
+            }
+        }
+        return maps;
     }
- public List<Map<String,Object>> sortMap(List<Map<String,Object>> maps){
-
-     for(int i=0;i<maps.size()-1;i++) {
-         for (int j = 0; j < maps.size() - i - 1; j++) {
-             Integer order1 = Integer.parseInt(maps.get(j).get("order").toString());
-             Integer order2 =Integer.parseInt(maps.get(j+1).get("order").toString());
-             if (order1 > order2) {
-                 Map<String,Object> temp = maps.get(j);
-                 maps.set(j,maps.get(j+1));
-                 maps.set(j+1,temp);
-             }
-
-         }
-     }
-     return maps;
- }
 
 }
 

+ 108 - 108
RMS/src/main/java/cn/cslg/report/service/business/ReportFieldPatentLinkService.java

@@ -39,14 +39,14 @@ public class ReportFieldPatentLinkService extends ServiceImpl<ReportFieldPatentL
     private final ReportFieldService reportFieldService;
     private final LoginUtils loginUtils;
     private final ReportFieldOptionService reportFieldOptionService;
-    private final  ReportFieldPatentLinkService reportFieldPatentLinkService;
+    private final ReportFieldPatentLinkService reportFieldPatentLinkService;
 
 
     /**
-     * @function 根据专利号和报告id插叙标引内容关联专利
-     * @param patentNo 专利号
+     * @param patentNo  专利号
      * @param projectId 报告id
      * @return
+     * @function 根据专利号和报告id插叙标引内容关联专利
      */
     public List<ReportFieldPatentLink> getProjectPatentLinkByPatentAndProId(String patentNo, Integer projectId) {
         LambdaQueryWrapper<ReportFieldPatentLink> queryWrapper = new LambdaQueryWrapper<>();
@@ -56,11 +56,11 @@ public class ReportFieldPatentLinkService extends ServiceImpl<ReportFieldPatentL
     }
 
     /**
-     * @function 根据专利号,报告id,自定义字段id 插叙标引内容关联专利
-     * @param patentNo 专利号
+     * @param patentNo  专利号
      * @param projectId 报告id
-     * @param fieldId 自定义字段id
+     * @param fieldId   自定义字段id
      * @return
+     * @function 根据专利号,报告id,自定义字段id 插叙标引内容关联专利
      */
 
     public List<ReportFieldPatentLink> getProjectPatentLinkByPatentAndProjectIdAndFieldId(String patentNo, Integer projectId, Integer fieldId) {
@@ -74,12 +74,12 @@ public class ReportFieldPatentLinkService extends ServiceImpl<ReportFieldPatentL
     }
 
     /**
-     * @function 根据专利号,报告id,自定义字段id 分类标引的id 插叙标引内容关联专利
-     * @param patentId 专利号
+     * @param patentId  专利号
      * @param projectId 报告id
-     * @param fieldId 自定义字段id
-     * @param optionId 分类标引的id
+     * @param fieldId   自定义字段id
+     * @param optionId  分类标引的id
      * @return
+     * @function 根据专利号,报告id,自定义字段id 分类标引的id 插叙标引内容关联专利
      */
 
     public ReportFieldPatentLink getProjectPatentLinkByPatentAndProjectIdAndFieldIdAndOptionId(String patentId, Integer projectId, Integer fieldId, Integer optionId) {
@@ -92,13 +92,13 @@ public class ReportFieldPatentLinkService extends ServiceImpl<ReportFieldPatentL
     }
 
     /**
-     * @function 修改插叙标引内容关联专利
-     * @param patentNo 专利号
-     * @param type 类型
-     * @param fieldId 文件id
-     * @param optionId 分类标引id
-     * @param userId 用户id(当前登录人id)
+     * @param patentNo  专利号
+     * @param type      类型
+     * @param fieldId   文件id
+     * @param optionId  分类标引id
+     * @param userId    用户id(当前登录人id)
      * @param projectId 报告id
+     * @function 修改插叙标引内容关联专利
      */
     public void updateProjectPatentLink(String patentNo, Integer type, Integer fieldId, Integer optionId, Integer userId, Integer projectId) {
         ReportFieldPatentLink reportFieldPatentLink = new ReportFieldPatentLink();
@@ -112,10 +112,10 @@ public class ReportFieldPatentLinkService extends ServiceImpl<ReportFieldPatentL
     }
 
     /**
-     * @function 查询插叙标引内容关联专利
      * @param patentNos 专利号
      * @param projectId 任务id
      * @return
+     * @function 查询插叙标引内容关联专利
      */
 
     public List<ReportFieldPatentLink> getProjectPatentLinkByPatentIdsAndProjectId(List<String> patentNos, Integer projectId) {
@@ -129,24 +129,24 @@ public class ReportFieldPatentLinkService extends ServiceImpl<ReportFieldPatentL
     }
 
     /**
-     * @function 删除ReportFieldPatentLink
      * @param fieldId 自定义字段id
+     * @function 删除ReportFieldPatentLink
      */
     public void deleteByFieldId(Integer fieldId) {
         this.remove(Wrappers.<ReportFieldPatentLink>lambdaQuery().eq(ReportFieldPatentLink::getFieldId, fieldId));
     }
 
     /**
-     * @function 删除ReportFieldPatentLink
      * @param optionId 分类标引的id
+     * @function 删除ReportFieldPatentLink
      */
     public void deleteByOptionId(Integer optionId) {
         this.remove(Wrappers.<ReportFieldPatentLink>lambdaQuery().eq(ReportFieldPatentLink::getOptionId, optionId));
     }
 
     /**
-     * @function 批量删除
      * @param optionIds
+     * @function 批量删除
      */
     public void deleteByOptionIds(List<Integer> optionIds) {
         if (optionIds != null && optionIds.size() != 0) {
@@ -155,10 +155,10 @@ public class ReportFieldPatentLinkService extends ServiceImpl<ReportFieldPatentL
     }
 
     /**
-     * @function  删除
      * @param patentNos 专利号
      * @param projectId 报告id
-     * @param fieldId 自定义字段id
+     * @param fieldId   自定义字段id
+     * @function 删除
      */
     public void deleteByPatentIdsAndProjectIdAndFieldId(List<Integer> patentNos, Integer projectId, Integer fieldId) {
         LambdaQueryWrapper<ReportFieldPatentLink> queryWrapper = new LambdaQueryWrapper<>();
@@ -167,11 +167,12 @@ public class ReportFieldPatentLinkService extends ServiceImpl<ReportFieldPatentL
         queryWrapper.eq(ReportFieldPatentLink::getFieldId, fieldId);
         this.remove(queryWrapper);
     }
+
     /**
-     * @function  删除
      * @param patentNos 专利号
      * @param projectId 报告id
-     * @param fieldId 自定义字段id
+     * @param fieldId   自定义字段id
+     * @function 删除
      */
     public void delete(Integer patentId, String patentNo, Integer fieldId) {
         LambdaQueryWrapper<ReportFieldPatentLink> queryWrapper = new LambdaQueryWrapper<>();
@@ -181,15 +182,13 @@ public class ReportFieldPatentLinkService extends ServiceImpl<ReportFieldPatentL
         this.remove(queryWrapper);
 
 
-
     }
 
     /**
-     *
-     * @function 获取自定义字段
      * @param params
      * @return
      * @throws IOException
+     * @function 获取自定义字段
      */
     public List<LabelDTO> getPatentIndexSetting(PatentIndexSettingVO params) throws IOException {
         //根据专利号报告id自定义字段的id找到ReportFieldPatentLink
@@ -210,7 +209,7 @@ public class ReportFieldPatentLinkService extends ServiceImpl<ReportFieldPatentL
                     mapList.add(map);
                 }
                 break;
-                //选项
+            //选项
             case 3:
             case 4:
             case 5:
@@ -223,7 +222,7 @@ public class ReportFieldPatentLinkService extends ServiceImpl<ReportFieldPatentL
                     mapList.add(map);
                 }
                 break;
-                //树类型
+            //树类型
             case 6:
                 List<ReportFieldTree> projectFieldTreeList = projectFieldTreeService.getProjectFieldTreeOptionByIds(optionIds);
                 for (ReportFieldTree projectFieldTree : projectFieldTreeList) {
@@ -238,15 +237,15 @@ public class ReportFieldPatentLinkService extends ServiceImpl<ReportFieldPatentL
     }
 
     /**
-     * @function
      * @param params
+     * @function
      */
     @Transactional(rollbackFor = Exception.class)
     public void updatePatentIndexSetting(PatentIndexSettingVO params) {
-        LambdaQueryWrapper<ReportFieldPatentLink> lambdaQueryWrapper =new LambdaQueryWrapper<>();
-        lambdaQueryWrapper.eq(ReportFieldPatentLink::getPatentNo,params.getPatentNo())
-                          .eq(ReportFieldPatentLink::getReportId,params.getReportId())
-                           .eq(ReportFieldPatentLink::getFieldId,params.getFieldId());
+        LambdaQueryWrapper<ReportFieldPatentLink> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+        lambdaQueryWrapper.eq(ReportFieldPatentLink::getPatentNo, params.getPatentNo())
+                .eq(ReportFieldPatentLink::getReportId, params.getReportId())
+                .eq(ReportFieldPatentLink::getFieldId, params.getFieldId());
         reportFieldPatentLinkService.remove(lambdaQueryWrapper);
         List<Integer> optionIds = params.getSelected().stream().map(LabelDTO::getValue).distinct().collect(Collectors.toList());
         List<String> texts = params.getSelected().stream().map(LabelDTO::getLabel).distinct().collect(Collectors.toList());
@@ -255,70 +254,69 @@ public class ReportFieldPatentLinkService extends ServiceImpl<ReportFieldPatentL
             case 0:
             case 1:
             case 2:
-                    LambdaQueryWrapper<ReportFieldPatentLink> queryWrapper = new LambdaQueryWrapper<>();
-                    queryWrapper.eq(ReportFieldPatentLink::getPatentNo, params.getPatentNo())
-                            .eq(ReportFieldPatentLink::getReportId, params.getReportId())
-                            .eq(ReportFieldPatentLink::getFieldId, params.getFieldId());
-                    List<ReportFieldPatentLink> list = this.list(queryWrapper);
-                    ReportFieldPatentLink reportFieldPatentLink;
-                    if(list.size()!=0) {
-                        reportFieldPatentLink=list.get(0);
-                        Integer optionId = reportFieldPatentLink.getOptionId();
-                        List<ReportFieldText> reportFieldTexts = reportFieldTextService.get(optionId);
-                        ReportFieldText reportFieldText = reportFieldTexts.get(0);
+                LambdaQueryWrapper<ReportFieldPatentLink> queryWrapper = new LambdaQueryWrapper<>();
+                queryWrapper.eq(ReportFieldPatentLink::getPatentNo, params.getPatentNo())
+                        .eq(ReportFieldPatentLink::getReportId, params.getReportId())
+                        .eq(ReportFieldPatentLink::getFieldId, params.getFieldId());
+                List<ReportFieldPatentLink> list = this.list(queryWrapper);
+                ReportFieldPatentLink reportFieldPatentLink;
+                if (list.size() != 0) {
+                    reportFieldPatentLink = list.get(0);
+                    Integer optionId = reportFieldPatentLink.getOptionId();
+                    List<ReportFieldText> reportFieldTexts = reportFieldTextService.get(optionId);
+                    ReportFieldText reportFieldText = reportFieldTexts.get(0);
+                    reportFieldText.setText(params.getSelected().get(0).getLabel());
+                    reportFieldText.updateById();
+                    reportFieldPatentLink.setFieldId(reportFieldText.getFieldId());
+                    reportFieldPatentLink.setOptionId(reportFieldText.getId());
+                    reportFieldPatentLink.setCreateBy(loginUtils.getId());
+                    reportFieldPatentLink.setPatentNo(params.getPatentNo());
+                    reportFieldPatentLink.setReportId(params.getReportId());
+                    reportFieldPatentLink.updateById();
+                } else {
+                    LambdaQueryWrapper<ReportFieldText> queryWrapper1 = new LambdaQueryWrapper<>();
+                    queryWrapper1.eq(ReportFieldText::getText, params.getSelected().get(0).getLabel())
+                            .eq(ReportFieldText::getFieldId, params.getFieldId());
+                    List<ReportFieldText> reportFieldTexts = reportFieldTextService.list(queryWrapper1);
+                    reportFieldPatentLink = new ReportFieldPatentLink();
+                    ReportFieldText reportFieldText = new ReportFieldText();
+                    if (reportFieldTexts != null && reportFieldTexts.size() != 0) {
+                        reportFieldText = reportFieldTexts.get(0);
+                    } else {
                         reportFieldText.setText(params.getSelected().get(0).getLabel());
-                        reportFieldText.updateById();
-                        reportFieldPatentLink.setFieldId(reportFieldText.getFieldId());
-                        reportFieldPatentLink.setOptionId(reportFieldText.getId());
-                        reportFieldPatentLink.setCreateBy(loginUtils.getId());
-                        reportFieldPatentLink.setPatentNo(params.getPatentNo());
-                        reportFieldPatentLink.setReportId(params.getReportId());
-                        reportFieldPatentLink.updateById();
-                    }else {
-                        LambdaQueryWrapper<ReportFieldText> queryWrapper1 =new LambdaQueryWrapper<>();
-                        queryWrapper1.eq(ReportFieldText::getText,params.getSelected().get(0).getLabel())
-                                      .eq(ReportFieldText::getFieldId,params.getFieldId());
-                         List<ReportFieldText> reportFieldTexts = reportFieldTextService.list(queryWrapper1);
-                        reportFieldPatentLink=new ReportFieldPatentLink();
-                        ReportFieldText reportFieldText=new ReportFieldText();
-                        if(reportFieldTexts!=null&&reportFieldTexts.size()!=0) {
-                            reportFieldText =reportFieldTexts.get(0);
-                        }
-           else {
-                            reportFieldText.setText(params.getSelected().get(0).getLabel());
-                            reportFieldText.setFieldId(params.getFieldId());
-                            reportFieldText.insert();
-                        }
-                        reportFieldPatentLink.setFieldId(reportFieldText.getFieldId());
-                        reportFieldPatentLink.setOptionId(reportFieldText.getId());
-                        reportFieldPatentLink.setCreateBy(loginUtils.getId());
-                        reportFieldPatentLink.setPatentNo(params.getPatentNo());
-                        reportFieldPatentLink.setReportId(params.getReportId());
-                        reportFieldPatentLink.insert();
+                        reportFieldText.setFieldId(params.getFieldId());
+                        reportFieldText.insert();
                     }
-                   //将没有使用到的选项值删除
-                LambdaQueryWrapper<ReportFieldPatentLink> lambdaQueryWrapper1 =new LambdaQueryWrapper<>();
-                lambdaQueryWrapper1.eq(ReportFieldPatentLink::getReportId,params.getReportId())
-                        .eq(ReportFieldPatentLink::getFieldId,params.getFieldId());
-List<ReportFieldPatentLink> links =reportFieldPatentLinkService.list(lambdaQueryWrapper1);
-if(links.size()!=0){
-    List<Integer> opIds =links.stream().map(ReportFieldPatentLink::getOptionId).collect(Collectors.toList());
-    LambdaQueryWrapper<ReportFieldText> removeWrapper= new LambdaQueryWrapper<>();
-    removeWrapper.notIn(ReportFieldText::getId,opIds).eq(ReportFieldText::getFieldId,params.getFieldId());
-    reportFieldTextService.remove(removeWrapper);
+                    reportFieldPatentLink.setFieldId(reportFieldText.getFieldId());
+                    reportFieldPatentLink.setOptionId(reportFieldText.getId());
+                    reportFieldPatentLink.setCreateBy(loginUtils.getId());
+                    reportFieldPatentLink.setPatentNo(params.getPatentNo());
+                    reportFieldPatentLink.setReportId(params.getReportId());
+                    reportFieldPatentLink.insert();
+                }
+                //将没有使用到的选项值删除
+                LambdaQueryWrapper<ReportFieldPatentLink> lambdaQueryWrapper1 = new LambdaQueryWrapper<>();
+                lambdaQueryWrapper1.eq(ReportFieldPatentLink::getReportId, params.getReportId())
+                        .eq(ReportFieldPatentLink::getFieldId, params.getFieldId());
+                List<ReportFieldPatentLink> links = reportFieldPatentLinkService.list(lambdaQueryWrapper1);
+                if (links.size() != 0) {
+                    List<Integer> opIds = links.stream().map(ReportFieldPatentLink::getOptionId).collect(Collectors.toList());
+                    LambdaQueryWrapper<ReportFieldText> removeWrapper = new LambdaQueryWrapper<>();
+                    removeWrapper.notIn(ReportFieldText::getId, opIds).eq(ReportFieldText::getFieldId, params.getFieldId());
+                    reportFieldTextService.remove(removeWrapper);
 
 
-}
+                }
                 break;
             case 3:
             case 4:
             case 5:
             case 6:
-                LambdaQueryWrapper<ReportFieldPatentLink> queryWrapper1 =new LambdaQueryWrapper<>();
-                queryWrapper1.eq(ReportFieldPatentLink::getPatentNo,params.getPatentNo())
-                             .eq(ReportFieldPatentLink::getFieldId,params.getFieldId())
-                             .eq(ReportFieldPatentLink::getReportId,params.getReportId());
-                 this.remove(queryWrapper1);
+                LambdaQueryWrapper<ReportFieldPatentLink> queryWrapper1 = new LambdaQueryWrapper<>();
+                queryWrapper1.eq(ReportFieldPatentLink::getPatentNo, params.getPatentNo())
+                        .eq(ReportFieldPatentLink::getFieldId, params.getFieldId())
+                        .eq(ReportFieldPatentLink::getReportId, params.getReportId());
+                this.remove(queryWrapper1);
                 for (Integer optionId : optionIds) {
                     ReportFieldPatentLink projectFieldPatentLink = new ReportFieldPatentLink();
                     projectFieldPatentLink.setPatentNo(params.getPatentNo());
@@ -336,19 +334,21 @@ if(links.size()!=0){
         }
 
     }
-    public List<ReportFieldPatentLink> get(int id) throws IOException{
-        LambdaQueryWrapper<ReportFieldPatentLink> linkLambdaQueryWrapper=new LambdaQueryWrapper<>();
-        linkLambdaQueryWrapper.eq(ReportFieldPatentLink::getReportId,id);
+
+    public List<ReportFieldPatentLink> get(int id) throws IOException {
+        LambdaQueryWrapper<ReportFieldPatentLink> linkLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        linkLambdaQueryWrapper.eq(ReportFieldPatentLink::getReportId, id);
         return this.list(linkLambdaQueryWrapper);
     }
-    public void updatePatentIndexSetting2(PatentIndexSettingVO params){
-        switch (params.getType()){
+
+    public void updatePatentIndexSetting2(PatentIndexSettingVO params) {
+        switch (params.getType()) {
             case 0:
             case 1:
             case 2:
             case 3:
                 List<LabelDTO> selected = params.getSelected();
-                for(LabelDTO a :selected){
+                for (LabelDTO a : selected) {
                     ReportFieldText reportFieldText = new ReportFieldText();
                     reportFieldText.setText(a.getLabel());
                     reportFieldText.setId(a.getValue());
@@ -358,15 +358,16 @@ if(links.size()!=0){
             case 4:
             case 5:
                 List<LabelDTO> selected2 = params.getSelected();
-                for(LabelDTO a :selected2){
+                for (LabelDTO a : selected2) {
                     ReportFieldOption reportFieldOption = new ReportFieldOption();
                     reportFieldOption.setName(a.getLabel());
                     reportFieldOption.setId(a.getValue());
                     reportFieldOption.updateById();
                 }
                 break;
-            case 6:  List<LabelDTO> selected3 = params.getSelected();
-                for(LabelDTO a :selected3){
+            case 6:
+                List<LabelDTO> selected3 = params.getSelected();
+                for (LabelDTO a : selected3) {
                     ReportFieldTree reportFieldTree = new ReportFieldTree();
                     reportFieldTree.setId(a.getValue());
                     reportFieldTree.setName(a.getLabel());
@@ -378,21 +379,20 @@ if(links.size()!=0){
     }
 
     /**
-     *
      * @param FieldId
      * @param valueId
      * @return
      */
-    public List<String> getPatentNos(Integer FieldId, Integer valueId){
-LambdaQueryWrapper<ReportFieldPatentLink> queryWrapper =new LambdaQueryWrapper<>();
-queryWrapper.select(ReportFieldPatentLink::getPatentNo);
-queryWrapper.eq(ReportFieldPatentLink::getFieldId,FieldId);
-queryWrapper.eq(ReportFieldPatentLink::getOptionId,valueId);
-List<ReportFieldPatentLink> reportFieldPatentLinks =this.list(queryWrapper);
-List<String> patentNos = reportFieldPatentLinks.stream().map(ReportFieldPatentLink::getPatentNo).collect(Collectors.toList());
-return  patentNos;
+    public List<String> getPatentNos(Integer FieldId, Integer valueId) {
+        LambdaQueryWrapper<ReportFieldPatentLink> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.select(ReportFieldPatentLink::getPatentNo);
+        queryWrapper.eq(ReportFieldPatentLink::getFieldId, FieldId);
+        queryWrapper.eq(ReportFieldPatentLink::getOptionId, valueId);
+        List<ReportFieldPatentLink> reportFieldPatentLinks = this.list(queryWrapper);
+        List<String> patentNos = reportFieldPatentLinks.stream().map(ReportFieldPatentLink::getPatentNo).collect(Collectors.toList());
+        return patentNos;
 
-}
+    }
 
     /**
      *

+ 6 - 7
RMS/src/main/java/cn/cslg/report/service/business/TemplateService.java

@@ -15,18 +15,17 @@ import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 
 
-
 @Service
 @Slf4j
 @RequiredArgsConstructor(onConstructor_ = {@Lazy})
 public class TemplateService extends ServiceImpl<TemplateMapper, Template> {
     //根据报告类型获得模板
-     public String getTemplateByType(Template template) {
-         LambdaQueryWrapper<Template> wrapper =new LambdaQueryWrapper<>();
-         wrapper.eq(Template::getReportType,template.getReportType());
-         IPage<Template> templateIPage =this.page(new Page<>(template.getCurrent(), template.getSize()),wrapper);
-       return  Response.success(templateIPage);
+    public String getTemplateByType(Template template) {
+        LambdaQueryWrapper<Template> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(Template::getReportType, template.getReportType());
+        IPage<Template> templateIPage = this.page(new Page<>(template.getCurrent(), template.getSize()), wrapper);
+        return Response.success(templateIPage);
 
-     }
+    }
 
 }

+ 51 - 30
RMS/src/main/java/cn/cslg/report/service/impl/ProductServiceImpl.java

@@ -28,7 +28,7 @@ import java.util.List;
  * 产品的Service层实现类
  *
  * @Author chenyu
- * @Data 2022/12/20
+ * @Date 2022/12/20
  */
 @Slf4j
 @Service
@@ -122,50 +122,75 @@ public class ProductServiceImpl implements IProductService {
         BeanUtils.copyProperties(productIncludeFilesDTO, product);
 
         //1.根据id修改产品表数据
-        log.info("根据id修改产品表数据");
+        log.info("修改产品表数据");
         int rows = productMapper.update(product);
         if (rows != 1) {
             String message = "修改产品失败,服务器忙请稍后再试";
-            log.info("根据id修改产品表数据失败,{}", message);
+            log.info("修改产品表数据失败,{}", message);
             throw new XiaoShiException(message);
         }
 
-        //2.根据reportId(报告id)关联查询出产品关联附件的数据信息
+        //根据报告reportId关联查询产品表、产品文件关联表、报告系统文件表三表,获得产品和原附件数据
         Integer reportId = product.getReportId();
+        log.info("根据报告reportId关联产品表、产品文件关联表、报告系统文件表三表,查询产品和附件的数据");
         ProductIncludeFilesVO queryResult = productMapper.getWholeByReportId(reportId);
 
-        //3.取出对象中的附件集合属性,遍历取出原所有附件fileIds
+        //从产品和原附件数据中获得原附件数据,遍历原附件,取出所有原附件fileId存入集合
         List<ReportFileStandardVO> oldReportFiles = queryResult.getReportFiles();
-        ArrayList<Integer> oldFileIdList = new ArrayList<>();
-        for (ReportFileStandardVO reportFile : oldReportFiles) {
-            Integer fileId = reportFile.getId();
-            oldFileIdList.add(fileId);
+        ArrayList<Integer> oldFileIds = new ArrayList<>();
+        for (ReportFileStandardVO oldReportFile : oldReportFiles) {
+            Integer oldFileId = oldReportFile.getId();
+            oldFileIds.add(oldFileId);
         }
-        //4.取出对象中的附件集合属性,遍历取出现所有附件fileIds
-        List<ReportFileStandardVO> newReportFiles = productIncludeFilesDTO.getReportFiles();
-        ArrayList<Integer> newFileIdList = new ArrayList<>();
-        for (ReportFileStandardVO reportFile : newReportFiles) {
-            Integer fileId = reportFile.getId();
-            newFileIdList.add(fileId);
+        //从DTO中获得新的原附件数据,遍历新的原附件,取出所有新的原附件fileId存入集合
+        List<ReportFileStandardVO> newOldReportFiles = productIncludeFilesDTO.getReportFiles();
+        ArrayList<Integer> newOldFileIds = new ArrayList<>();
+        for (ReportFileStandardVO newOldReportFile : newOldReportFiles) {
+            Integer newOldFileId = newOldReportFile.getId();
+            newOldFileIds.add(newOldFileId);
         }
-        //5.fileId集合去重,去重后剩下的fileId即为被删除的附件fileId
-        oldFileIdList.removeAll(newFileIdList);
-
-        //6.若去重后的原fileId集合仍有长度(即表示剩下了被删除部分的附件),则删除文件表和产品文件关联表中被删除的附件的数据
-        if (oldFileIdList.size() != 0) {
-            reportFileService.deleteFiles(oldFileIdList);  //删除文件表中被删除附件的数据
-            assoProductFileService.deleteAssoByFileIds(oldFileIdList);  //删除产品文件关联表中被删除附件的数据
+        //fileId集合去重,去重后留下的fileId即为被删除的原附件fileId
+        oldFileIds.removeAll(newOldFileIds);
+
+        //如果去重后的oldFileIds仍有长度(即表示集合中留下的被删除的部分原附件fileId),则删除产品文件关联表和报告系统文件表中被删除的部分原附件fileId相关数据
+        if (oldFileIds.size() != 0) {
+            //2.删除产品文件关联表中被删除附件的数据
+            log.info("删除产品文件关联表数据");
+            rows = assoProductFileMapper.deleteByFileIds(oldFileIds);
+            if (rows != oldFileIds.size()) {
+                String message = "修改产品失败,服务器忙请稍后再试";
+                log.info("删除产品文件关联表数据失败,{}", message);
+                throw new XiaoShiException(message);
+            }
+            //2.删除报告系统文件表中被删除附件的数据
+            log.info("删除报告系统文件表数据");
+            reportFileService.deleteFiles(oldFileIds);
         }
 
-        //7.插入新的附件入报告系统文件表中,返回文件id
+        //如果前端传来的files附件不为null(即表示新增了若干附件),则新附件数据入报告系统文件表和产品文件关联表
         if (files != null) {
+            //3.新的附件入报告系统文件表,返回附件fileId
+            log.info("数据入报告系统文件表");
             List<Integer> fileIds = reportFileService.uploadFiles(files);
-            //8.插入新的文件id入产品文件关联表中
+            //3.新的附件fileId入产品文件关联表
             Integer productId = product.getId();
-            assoProductFileService.addAsso(productId, fileIds);
+            ArrayList<AssoProductFile> assoProductFiles = new ArrayList<>();
+            for (Integer fileId : fileIds) {
+                AssoProductFile assoProductFile = new AssoProductFile()
+                        .setProductId(productId)
+                        .setFileId(fileId)
+                        .setFileUseType(0);
+                assoProductFiles.add(assoProductFile);
+            }
+            log.info("数据入产品文件关联表");
+            rows = assoProductFileMapper.insertBatch(assoProductFiles);
+            if (rows != assoProductFiles.size()) {
+                String message = "修改产品失败,服务器忙请稍后再试";
+                log.info("数据入产品文件关联表失败,{}", message);
+                throw new XiaoShiException(message);
+            }
         }
 
-
         log.info("产品修改完成");
 
     }
@@ -180,11 +205,7 @@ public class ProductServiceImpl implements IProductService {
     public ProductIncludeFilesVO getProduct(Integer reportId) {
         log.info("开始处理【查询产品】的业务,参数为:{}", reportId);
         ProductIncludeFilesVO queryResult = productMapper.getWholeByReportId(reportId);
-        if (queryResult == null) {
-            log.info("查询成功,产品不存在");
-        }
         return queryResult;
-
     }
 
     /**