浏览代码

专利拆分修改

lwhhszx 1 年之前
父节点
当前提交
25fedd6684

+ 3 - 1
src/main/java/cn/cslg/pas/common/vo/business/SplitVO.java

@@ -26,7 +26,9 @@ public class SplitVO {
      */
      */
     @Schema(description = "拆分形式")
     @Schema(description = "拆分形式")
     private Integer splitBy;
     private Integer splitBy;
-    @JsonProperty("ReportId")
+
+    @Schema(description = "是否重拆")
+    private Boolean ifReSplit;
     @Schema(description = "报告Id")
     @Schema(description = "报告Id")
     private Integer projectId;
     private Integer projectId;
     @Schema(description = "任务Id")
     @Schema(description = "任务Id")

+ 0 - 4
src/main/java/cn/cslg/pas/domain/business/Feature.java

@@ -73,8 +73,4 @@ public class Feature extends BaseEntity<Feature> {
     @TableField(value = "tenant_id")
     @TableField(value = "tenant_id")
     private Integer tenantId;
     private Integer tenantId;
 
 
-    @TableField(value="split_type")
-    private Integer splitType;
-    @TableField(value = "split_by")
-    private Integer splitBy;
 }
 }

+ 34 - 0
src/main/java/cn/cslg/pas/domain/business/PatentSplitMessage.java

@@ -0,0 +1,34 @@
+package cn.cslg.pas.domain.business;
+
+import cn.cslg.pas.domain.BaseEntity;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import org.joda.time.DateTime;
+
+import java.util.Date;
+
+/**
+ * <p>
+ * 事件表
+ * </p>
+ *
+ * @author 李仁杰
+ * @since 2022-10-20
+ */
+@Data
+@TableName("event")
+/*数据库中的表对应的类
+ */
+public class PatentSplitMessage extends BaseEntity<PatentSplitMessage> {
+    @TableField(value = "patent_no")
+    private String patentNo;
+    @TableField(value = "project_id")
+    private Integer projectId;
+    @TableField(value = "create_id")
+    private String createId;
+    @TableField(value = "create_time")
+    private Date createTime;
+    @TableField(value = "tenant_id")
+    private Integer tenantId;
+}

+ 16 - 0
src/main/java/cn/cslg/pas/mapper/PatentSplitMessageMapper.java

@@ -0,0 +1,16 @@
+package cn.cslg.pas.mapper;
+
+import cn.cslg.pas.domain.business.AssoEventFile;
+import cn.cslg.pas.domain.business.PatentSplitMessage;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.springframework.stereotype.Repository;
+
+/**
+ * 任务可见栏位表
+ *
+ * @author chenyu
+ * @date 2023/10/20
+ */
+@Repository
+public interface PatentSplitMessageMapper extends BaseMapper<PatentSplitMessage> {
+}

+ 135 - 85
src/main/java/cn/cslg/pas/service/business/FeatureService.java

@@ -9,6 +9,7 @@ import cn.cslg.pas.common.utils.PatentRightUtils;
 import cn.cslg.pas.common.vo.*;
 import cn.cslg.pas.common.vo.*;
 import cn.cslg.pas.common.vo.business.SplitVO;
 import cn.cslg.pas.common.vo.business.SplitVO;
 import cn.cslg.pas.domain.business.Feature;
 import cn.cslg.pas.domain.business.Feature;
+import cn.cslg.pas.domain.business.PatentSplitMessage;
 import cn.cslg.pas.domain.business.ReportProject;
 import cn.cslg.pas.domain.business.ReportProject;
 import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.mapper.FeatureMapper;
 import cn.cslg.pas.mapper.FeatureMapper;
@@ -36,6 +37,9 @@ public class FeatureService extends ServiceImpl<FeatureMapper, Feature> {
     @Autowired
     @Autowired
     private ReportProjectService reportProjectService;
     private ReportProjectService reportProjectService;
 
 
+    @Autowired
+    private PatentSplitMessageService patentSplitMessageService;
+
     @Transactional(rollbackFor = Exception.class)
     @Transactional(rollbackFor = Exception.class)
     public List<PatentRightVo> splitPatentFeature(SplitVO splitVO) throws IOException {
     public List<PatentRightVo> splitPatentFeature(SplitVO splitVO) throws IOException {
         String patentNo = splitVO.getPatentNo();
         String patentNo = splitVO.getPatentNo();
@@ -43,7 +47,7 @@ public class FeatureService extends ServiceImpl<FeatureMapper, Feature> {
         Integer splitType = splitVO.getSplitType();
         Integer splitType = splitVO.getSplitType();
         Integer splitBy = splitVO.getSplitBy();
         Integer splitBy = splitVO.getSplitBy();
         Integer taskId = splitVO.getTaskId();
         Integer taskId = splitVO.getTaskId();
-        Boolean ifUpdate = false;
+        Boolean ifReSplit = splitVO.getIfReSplit();
 
 
         //当未传入拆分信息时,设置默认值
         //当未传入拆分信息时,设置默认值
         if (splitBy == null) {
         if (splitBy == null) {
@@ -65,33 +69,24 @@ public class FeatureService extends ServiceImpl<FeatureMapper, Feature> {
         if (reportProjects.size() == 0) {
         if (reportProjects.size() == 0) {
             throw new XiaoShiException("未查询到报告");
             throw new XiaoShiException("未查询到报告");
         }
         }
-        ReportProject report = reportProjectService.list(queryWrapper).get(0);
-        //如果报告未拆分过权要,或者拆分类型不同则更新报告
-        if (report.getSplitBy() == null || report.getSplitType() == null || report.getSplitBy() != splitBy || report.getSplitType() != splitType) {
-            report.setSplitBy(splitBy);
-            report.setSplitType(splitType);
-            report.updateById();
-            ifUpdate = true;
-        }
 
 
         //查询拆分下的权要
         //查询拆分下的权要
         List<RePatentClaim> patentRights = this.getRightListByNo(patentNo);
         List<RePatentClaim> patentRights = this.getRightListByNo(patentNo);
         List<String> flags = new ArrayList<>();
         List<String> flags = new ArrayList<>();
 
 
         List<Integer> partRightSorts = new ArrayList<>();  //权要sorts
         List<Integer> partRightSorts = new ArrayList<>();  //权要sorts
-        if (ifUpdate) {
-            if (splitBy == 0) {  //当splitBy=0时仅仅根据“,”拆解
-                flags.add(",");
-                flags.add(",");
-            } else if (splitBy == 1) {  //当splitBy=1时仅仅根据“;“拆解
-                flags.add(";");
-                flags.add(";");
-            } else if (splitBy == 2) {  //当splitBy=2时根据“;“和”,”拆解
-                flags.add(";");
-                flags.add(";");
-                flags.add(",");
-                flags.add(",");
-            }
+        if (splitBy == 0) {  //当splitBy=0时仅仅根据“,”拆解
+            flags.add(",");
+            flags.add(",");
+        } else if (splitBy == 1) {  //当splitBy=1时仅仅根据“;“拆解
+            flags.add(";");
+            flags.add(";");
+        } else if (splitBy == 2) {  //当splitBy=2时根据“;“和”,”拆解
+            flags.add(";");
+            flags.add(";");
+            flags.add(",");
+            flags.add(",");
+
             if (splitType.equals(0)) {  //当splitType=0仅拆解主权要
             if (splitType.equals(0)) {  //当splitType=0仅拆解主权要
                 partRightSorts = patentRights.stream().filter(item -> item.getType().equals(1)).map(RePatentClaim::getSort).collect(Collectors.toList());
                 partRightSorts = patentRights.stream().filter(item -> item.getType().equals(1)).map(RePatentClaim::getSort).collect(Collectors.toList());
             } else if (splitType.equals(1)) {  //当splitType=1拆解全部权要
             } else if (splitType.equals(1)) {  //当splitType=1拆解全部权要
@@ -99,84 +94,139 @@ public class FeatureService extends ServiceImpl<FeatureMapper, Feature> {
             }
             }
         }
         }
 
 
+        //
+        LambdaQueryWrapper<PatentSplitMessage> splitWrapper = new LambdaQueryWrapper<>();
+        splitWrapper.eq(PatentSplitMessage::getPatentNo, patentNo);
+        splitWrapper.eq(PatentSplitMessage::getProjectId, projectId);
+        PatentSplitMessage patentSplitMessage = patentSplitMessageService.getOne(splitWrapper, false);
+
         LambdaQueryWrapper<Feature> wrapper = new LambdaQueryWrapper<>();
         LambdaQueryWrapper<Feature> wrapper = new LambdaQueryWrapper<>();
         wrapper.eq(Feature::getProjectId, projectId)
         wrapper.eq(Feature::getProjectId, projectId)
                 .eq(Feature::getPatentNo, patentNo);
                 .eq(Feature::getPatentNo, patentNo);
         List<Feature> allFeatures = new ArrayList<>();
         List<Feature> allFeatures = new ArrayList<>();
-        if (!ifUpdate) {
-            allFeatures = this.list(wrapper);
-        } else {
+
+        //如果是不重拆
+        if (!ifReSplit) {
+            //如果拆分过
+            if (patentSplitMessage != null) {
+                allFeatures = this.list(wrapper);
+            }
+            //如果没有拆分过
+            else {
+                LambdaQueryWrapper<PatentSplitMessage> haveSplitWrapper = new LambdaQueryWrapper<>();
+                haveSplitWrapper.eq(PatentSplitMessage::getPatentNo, patentNo)
+                        .eq(PatentSplitMessage::getTenantId, personnelVO.getTenantId());
+                haveSplitWrapper.orderByDesc(PatentSplitMessage::getCreateTime);
+                List<PatentSplitMessage> patentSplitMessages = patentSplitMessageService.list(haveSplitWrapper);
+               //如果查询到原本拆分信息则复制
+                if (patentSplitMessages.size() > 0) {
+                    PatentSplitMessage doneMessage = patentSplitMessages.get(0);
+                    //根据报告id和专利号查询特征
+                    LambdaQueryWrapper<Feature> featureLambdaQueryWrapper = new LambdaQueryWrapper<>();
+                    featureLambdaQueryWrapper.eq(Feature::getPatentNo, doneMessage.getPatentNo())
+                            .eq(Feature::getProjectId, doneMessage.getProjectId());
+                    List<Feature> features = this.list(featureLambdaQueryWrapper);
+                    features.forEach(item -> {
+                                item.setCreateId(personnelVO.getId());
+                                item.setId(null);
+                                item.setProjectId(projectId);
+                            }
+                    );
+                    allFeatures = new ArrayList<>(features);
+                    //保存拆分记录
+                    patentSplitMessage = new PatentSplitMessage();
+                    patentSplitMessage.setPatentNo(patentNo);
+                    patentSplitMessage.setProjectId(projectId);
+                    patentSplitMessage.setTenantId(personnelVO.getTenantId());
+                    patentSplitMessage.setCreateId(personnelVO.getId());
+                    patentSplitMessage.insert();
+                }
+                //查询不到则新建
+                else {
+                    allFeatures = new ArrayList<>();
+                    //遍历权要保存特征
+                    for (int i = 0; i < patentRights.size(); i++) {
+                        List<Feature> featureList = new ArrayList<>();
+                        //根据拆分方式返回特征
+                        List<String> contents = Arrays.asList(patentRights.get(i).getContent());
+
+                        //如果是需要拆解的权要
+                        if (partRightSorts.contains(patentRights.get(i).getSort())) {
+                            //获得权要的原文并且拆解
+                            contents = this.splitStringByFlags(patentRights.get(i).getContent(), flags);
+                        }
+                        for (int t = 0; t < contents.size(); t++) {
+                            Feature feature = new Feature();
+                            feature.setRightSort(patentRights.get(i).getSort());
+                            feature.setPatentNo(patentNo);
+                            feature.setProjectId(projectId);
+                            feature.setContent(contents.get(t));
+                            feature.setCreateId(personnelVO.getId());
+                            feature.setRightType(patentRights.get(i).getType());
+                            feature.setTenantId(personnelVO.getTenantId());
+                            featureList.add(feature);
+                        }
+                        if (featureList.size() > 0) {
+                            this.saveBatch(featureList);
+                            allFeatures.addAll(featureList);
+                        }
+                    }
+                    //更新拆分信息
+                    patentSplitMessage.setCreateTime(new Date());
+                    patentSplitMessage.setCreateId(personnelVO.getId());
+                    patentSplitMessage.updateById();
+                }
+            }
+        }
+        //当重拆时新建
+        else {
+            //清除原本的
             this.remove(wrapper);
             this.remove(wrapper);
-            // 查询出拆分方式和专利号都和此专利一样的专利
-            LambdaQueryWrapper<Feature> featureLambdaQueryWrapper = new LambdaQueryWrapper<>();
-            featureLambdaQueryWrapper.eq(Feature::getSplitBy, splitBy)
-                    .eq(Feature::getSplitType, splitType)
-                    .eq(Feature::getPatentNo, patentNo);
-            Feature feature = this.getOne(featureLambdaQueryWrapper, false);
-            if (feature != null) {
-                LambdaQueryWrapper<Feature> wrapper1 = new LambdaQueryWrapper<>();
-                wrapper1
-                        .eq(Feature::getProjectId, feature.getProjectId())
-                        .eq(Feature::getPatentNo, patentNo);
-                allFeatures = this.list(wrapper1);
+            allFeatures = new ArrayList<>();
+            //遍历权要保存特征
+            for (int i = 0; i < patentRights.size(); i++) {
+                List<Feature> featureList = new ArrayList<>();
+                //根据拆分方式返回特征
+                List<String> contents = Arrays.asList(patentRights.get(i).getContent());
+
+                //如果是需要拆解的权要
+                if (partRightSorts.contains(patentRights.get(i).getSort())) {
+                    //获得权要的原文并且拆解
+                    contents = this.splitStringByFlags(patentRights.get(i).getContent(), flags);
+                }
+                for (int t = 0; t < contents.size(); t++) {
+                    Feature feature = new Feature();
+                    feature.setRightSort(patentRights.get(i).getSort());
+                    feature.setPatentNo(patentNo);
+                    feature.setProjectId(projectId);
+                    feature.setContent(contents.get(t));
+                    feature.setCreateId(personnelVO.getId());
+                    feature.setRightType(patentRights.get(i).getType());
+                    feature.setTenantId(personnelVO.getTenantId());
+                    featureList.add(feature);
+                }
+                if (featureList.size() > 0) {
+                    this.saveBatch(featureList);
+                    allFeatures.addAll(featureList);
+                }
             }
             }
+            //更新拆分信息
+            patentSplitMessage.setCreateTime(new Date());
+            patentSplitMessage.setCreateId(personnelVO.getId());
+            patentSplitMessage.updateById();
+
         }
         }
 
 
+
+        //装载信息并返回
         List<PatentRightVo> patentRightVos = new ArrayList<>();
         List<PatentRightVo> patentRightVos = new ArrayList<>();
         //将拆解的权要和特征装载到对象PatentRightVo
         //将拆解的权要和特征装载到对象PatentRightVo
         for (int i = 0; i < patentRights.size(); i++) {
         for (int i = 0; i < patentRights.size(); i++) {
             List<Feature> featureList = new ArrayList<>();
             List<Feature> featureList = new ArrayList<>();
             Integer sort = patentRights.get(i).getSort();
             Integer sort = patentRights.get(i).getSort();
-            //当更新拆分时
-            if (ifUpdate) {
-                featureList = allFeatures.stream().filter(item -> item.getRightSort().equals(sort)).collect(Collectors.toList());
-                if (featureList.size() > 0) {
-                    for (Feature item : featureList) {
-                        Feature feature = new Feature();
-                        feature.setRightSort(item.getRightSort());
-                        feature.setPatentNo(patentNo);
-                        feature.setProjectId(projectId);
-                        feature.setContent(item.getContent());
-                        feature.setCreateId(personnelVO.getId());
-                        feature.setRightType(item.getRightType());
-                        feature.setTenantId(personnelVO.getTenantId());
-                        feature.setSplitBy(splitBy);
-                        feature.setSplitType(splitType);
-                        featureList.add(feature);
-                    }
-
-                } else {
-                    //根据拆分方式返回特征
-                    List<String> contents = Arrays.asList(patentRights.get(i).getContent());
 
 
-                    //如果是需要拆解的权要
-                    if (partRightSorts.contains(patentRights.get(i).getSort())) {
-                        //获得权要的原文并且拆解
-                        contents = this.splitStringByFlags(patentRights.get(i).getContent(), flags);
-                    }
-                    for (int t = 0; t < contents.size(); t++) {
-                        Feature feature = new Feature();
-                        feature.setRightSort(patentRights.get(i).getSort());
-                        feature.setPatentNo(patentNo);
-                        feature.setProjectId(projectId);
-                        feature.setContent(contents.get(t));
-                        feature.setCreateId(personnelVO.getId());
-                        feature.setRightType(patentRights.get(i).getType());
-                        feature.setTenantId(personnelVO.getTenantId());
-                        feature.setSplitBy(splitBy);
-                        feature.setSplitType(splitType);
-                        featureList.add(feature);
-                    }
-                }
-                if (featureList.size() > 0) {
-                    this.saveBatch(featureList);
-                }
-            }
-            //当不更新时,返回信息
-            else {
-                featureList = allFeatures.stream().filter(item -> item.getRightSort().equals(sort)).collect(Collectors.toList());
+            featureList = allFeatures.stream().filter(item -> item.getRightSort().equals(sort)).collect(Collectors.toList());
 
 
-            }
             PatentRightVo patentRightVo = new PatentRightVo();
             PatentRightVo patentRightVo = new PatentRightVo();
             patentRightVo.setPatentNo(patentRights.get(i).getPatentNo());
             patentRightVo.setPatentNo(patentRights.get(i).getPatentNo());
             patentRightVo.setFeatures(featureList);
             patentRightVo.setFeatures(featureList);

+ 24 - 0
src/main/java/cn/cslg/pas/service/business/PatentSplitMessageService.java

@@ -0,0 +1,24 @@
+package cn.cslg.pas.service.business;
+
+import cn.cslg.pas.common.vo.business.ScenarioVO;
+import cn.cslg.pas.domain.business.PatentSplitMessage;
+import cn.cslg.pas.domain.business.Scenario;
+import cn.cslg.pas.mapper.PatentSplitMessageMapper;
+import cn.cslg.pas.mapper.ScenarioMapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @Author xiexiang
+ * @Date 2023/11/7
+ */
+@Slf4j
+@Service
+public class PatentSplitMessageService extends ServiceImpl<PatentSplitMessageMapper, PatentSplitMessage> {
+
+}

+ 7 - 6
src/main/java/cn/cslg/pas/service/business/es/EsCustomFieldService.java

@@ -359,8 +359,8 @@ public class EsCustomFieldService {
     /**
     /**
      * 查询历史
      * 查询历史
      */
      */
-    public  List<FieldHistoryVO>  getCustomFieldHistory(FieldHistoryDTO fieldHistoryDTO) throws Exception {
-       List<FieldHistoryVO> fieldHistoryVOS =new ArrayList<>();
+    public List<FieldHistoryVO> getCustomFieldHistory(FieldHistoryDTO fieldHistoryDTO) throws Exception {
+        List<FieldHistoryVO> fieldHistoryVOS = new ArrayList<>();
         String customId = this.getEsCustomFieldId(fieldHistoryDTO);
         String customId = this.getEsCustomFieldId(fieldHistoryDTO);
         Query q1 = QueryBuilders.term(t -> t.field("custom_field_id").value(customId));
         Query q1 = QueryBuilders.term(t -> t.field("custom_field_id").value(customId));
         SearchRequest.Builder builder = new SearchRequest.Builder();
         SearchRequest.Builder builder = new SearchRequest.Builder();
@@ -373,8 +373,8 @@ public class EsCustomFieldService {
         if (total > 0) {
         if (total > 0) {
             List<Hit<ESCustomFieldHistory>> hits = response.hits().hits();
             List<Hit<ESCustomFieldHistory>> hits = response.hits().hits();
             hits.forEach(item -> {
             hits.forEach(item -> {
-               FieldHistoryVO fieldHistoryVO = new FieldHistoryVO();
-                BeanUtils.copyProperties(item.source(),fieldHistoryVO);
+                FieldHistoryVO fieldHistoryVO = new FieldHistoryVO();
+                BeanUtils.copyProperties(item.source(), fieldHistoryVO);
                 fieldHistoryVOS.add(fieldHistoryVO);
                 fieldHistoryVOS.add(fieldHistoryVO);
             });
             });
 
 
@@ -385,16 +385,17 @@ public class EsCustomFieldService {
     /**
     /**
      * 回退
      * 回退
      */
      */
-    public void BackTo(String historyId) throws Exception{
+    public void BackTo(String historyId) throws Exception {
         //根据历史id获得历史
         //根据历史id获得历史
         SearchRequest.Builder builder = new SearchRequest.Builder();
         SearchRequest.Builder builder = new SearchRequest.Builder();
         builder.index("patent");
         builder.index("patent");
-        Query q =QueryBuilders.ids(i->i.values(Arrays.asList(historyId)));
+        Query q = QueryBuilders.ids(i -> i.values(Arrays.asList(historyId)));
         builder.query(q);
         builder.query(q);
         SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
         SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
         long total = response.hits().total().value();
         long total = response.hits().total().value();
         System.out.println(total);
         System.out.println(total);
         //根据历史的创建时间,查询出所有创建时间大于当前创建时间的历史
         //根据历史的创建时间,查询出所有创建时间大于当前创建时间的历史
+
         //遍历历史,根据操作类型,反推
         //遍历历史,根据操作类型,反推
         //根据反推内容保存并保存历史为回退;
         //根据反推内容保存并保存历史为回退;
     }
     }