|
@@ -7,6 +7,7 @@ import cn.cslg.report.common.utils.Response;
|
|
|
import cn.cslg.report.common.utils.SecurityUtils.LoginUtils;
|
|
|
import cn.cslg.report.entity.Features;
|
|
|
import cn.cslg.report.entity.PatentRight;
|
|
|
+import cn.cslg.report.entity.Report;
|
|
|
import cn.cslg.report.mapper.FeatureMapper;
|
|
|
import cn.cslg.report.service.OutInterfaceService;
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
@@ -21,9 +22,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -35,31 +34,44 @@ public class FeatureService extends ServiceImpl<FeatureMapper, Features> {
|
|
|
|
|
|
private final OutInterfaceService outInterfaceService;
|
|
|
private final CacheUtils cacheUtils;
|
|
|
+ private final ReportService reportService;
|
|
|
+ private final LoginUtils loginUtils;
|
|
|
|
|
|
//对权要进行合并操作
|
|
|
- private List<PatentRight> FormatPatentRights(List<PatentRight> patentRights)
|
|
|
- { List<PatentRight> retList= new ArrayList<>();
|
|
|
- for(int i=0;i< patentRights.size();i++)
|
|
|
- {
|
|
|
- String str=patentRights.get(i).getContent();
|
|
|
- str =str.replace(" ","");
|
|
|
- Pattern p = Pattern.compile("^[0-9]+\\..*");
|
|
|
- Matcher m = p.matcher(str);
|
|
|
- if( m.matches()){
|
|
|
- retList.add(patentRights.get(i));
|
|
|
- }
|
|
|
- else {
|
|
|
- if(retList.size()!=0){
|
|
|
- retList.get(retList.size()-1).setContent(retList.get(retList.size()-1).getContent()+patentRights.get(i).getContent());
|
|
|
- retList.get(retList.size()-1).setContentOut(retList.get(retList.size()-1).getContentOut()+patentRights.get(i).getContentOut());}
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
+ private List<PatentRight> FormatPatentRights(List<PatentRight> patentRights) {
|
|
|
+ List<PatentRight> retList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < patentRights.size(); i++) {
|
|
|
+ String str = patentRights.get(i).getContent();
|
|
|
+ str = str.replace(" ", "");
|
|
|
+ Pattern p = Pattern.compile("^[0-9]+\\..*");
|
|
|
+ Matcher m = p.matcher(str);
|
|
|
+ if (m.matches()) {
|
|
|
+ retList.add(patentRights.get(i));
|
|
|
+ } else {
|
|
|
+ if (retList.size() != 0) {
|
|
|
+ retList.get(retList.size() - 1).setContent(retList.get(retList.size() - 1).getContent() + patentRights.get(i).getContent());
|
|
|
+ retList.get(retList.size() - 1).setContentOut(retList.get(retList.size() - 1).getContentOut() + patentRights.get(i).getContentOut());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
return retList;
|
|
|
}
|
|
|
+
|
|
|
//从PAS系统上获得权要并拆分
|
|
|
public String splitPatentRight(String patentNo, Integer splitType, Integer splitBy, Integer reportId) throws IOException {
|
|
|
+ PersonnelVO personnelVO = cacheUtils.getLoginUser(StpUtil.getLoginIdAsInt());
|
|
|
+ LambdaQueryWrapper<Report> queryWrapper = new LambdaQueryWrapper();
|
|
|
+ queryWrapper.eq(Report::getId, reportId);
|
|
|
+ Report report = reportService.list(queryWrapper).get(0);
|
|
|
+ Integer flag = 0;
|
|
|
+ if (report.getSplitBy() == null || report.getSplitType() == null || report.getSplitBy() != splitBy || report.getSplitType() != splitType) {
|
|
|
+ report.setSplitBy(splitBy);
|
|
|
+ report.setSplitType(splitType);
|
|
|
+ report.updateById();
|
|
|
+ flag = 1;
|
|
|
+ }
|
|
|
//权要(带拆分的特征)列表
|
|
|
List<PatentRightVo> patentRightVos = new ArrayList<>();
|
|
|
//从pas获得权要信息
|
|
@@ -83,16 +95,18 @@ public class FeatureService extends ServiceImpl<FeatureMapper, Features> {
|
|
|
//当splitBy=0时仅仅根据“,”拆解
|
|
|
if (splitBy == 0) {
|
|
|
flags.add(",");
|
|
|
-
|
|
|
+ flags.add(",");
|
|
|
}
|
|
|
//当splitBy=1时仅仅根据“;“拆解
|
|
|
else if (splitBy == 1) {
|
|
|
flags.add(";");
|
|
|
+ flags.add(";");
|
|
|
}//当splitBy=2时根据“;“和”,”拆解
|
|
|
else if (splitBy == 2) {
|
|
|
-
|
|
|
- flags.add(",");
|
|
|
flags.add(";");
|
|
|
+ flags.add(";");
|
|
|
+ flags.add(",");
|
|
|
+ flags.add(",");
|
|
|
}
|
|
|
Features featureTO = new Features();
|
|
|
featureTO.setReportId(reportId);
|
|
@@ -108,10 +122,15 @@ public class FeatureService extends ServiceImpl<FeatureMapper, Features> {
|
|
|
|
|
|
if (featureFromDb != null && featureFromDb.size() != 0) {
|
|
|
int rightId = patentRights.get(i).getId();
|
|
|
- featuresList = featureFromDb.stream().filter(item -> item.getRightId() == rightId).collect(Collectors.toList());
|
|
|
+ featuresList = featureFromDb.stream().filter(item -> item.getRightId() == rightId && item.getSplitBy() == splitBy).collect(Collectors.toList());
|
|
|
}
|
|
|
//如果数据库里无拆解记录则手动插入一条
|
|
|
- if (featuresList == null || featuresList.size() == 0) {
|
|
|
+ if (featuresList == null || featuresList.size() == 0 || flag == 1) {
|
|
|
+ LambdaQueryWrapper<Features> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(Features::getReportId, reportId)
|
|
|
+ .eq(Features::getSignPatentNo, patentNo)
|
|
|
+ .eq(Features::getPartnerId, personnelVO.getId());
|
|
|
+ this.remove(wrapper);
|
|
|
featuresList = new ArrayList<>();
|
|
|
//获得权要的译文并且拆解
|
|
|
List<String> contentOuts = this.splitStringByFlags(patentRights.get(i).getContentOut(), flags);
|
|
@@ -127,7 +146,7 @@ public class FeatureService extends ServiceImpl<FeatureMapper, Features> {
|
|
|
String countOut = contentOuts.size() - 1 >= t ? contentOuts.get(t) : "";
|
|
|
features.setContentOut(countOut);
|
|
|
features.setContent(contents.get(t));
|
|
|
- PersonnelVO personnelVO = cacheUtils.getLoginUser(StpUtil.getLoginIdAsInt());
|
|
|
+ features.setSplitBy(splitBy);
|
|
|
features.setPartnerId(personnelVO.getId());
|
|
|
featuresList.add(features);
|
|
|
}
|
|
@@ -137,7 +156,7 @@ public class FeatureService extends ServiceImpl<FeatureMapper, Features> {
|
|
|
|
|
|
//装载到对象PatentRightVo
|
|
|
PatentRightVo patentRightVo = new PatentRightVo();
|
|
|
- String name="权要"+(i+1);
|
|
|
+ String name = "权要" + (i + 1);
|
|
|
patentRightVo.setPatentId(patentRights.get(i).getPatentId());
|
|
|
patentRightVo.setFeatures(featuresList);
|
|
|
patentRightVo.setContent(patentRights.get(i).getContent());
|
|
@@ -149,9 +168,11 @@ public class FeatureService extends ServiceImpl<FeatureMapper, Features> {
|
|
|
patentRightVo.setSignPatentNo(patentNo);
|
|
|
patentRightVos.add(patentRightVo);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- return Response.success(patentRightVos);
|
|
|
+ Map<String, Object> map = new HashMap<String, Object>();
|
|
|
+ map.put("patentRightVos", patentRightVos);
|
|
|
+ map.put("splitBy", report.getSplitBy());
|
|
|
+ map.put("splitType", report.getSplitType());
|
|
|
+ return Response.success(map);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -210,26 +231,42 @@ public class FeatureService extends ServiceImpl<FeatureMapper, Features> {
|
|
|
public String addFeatures(List<PatentRightVo> patentRightVos) {
|
|
|
PersonnelVO personnelVO = cacheUtils.getLoginUser(StpUtil.getLoginIdAsInt());
|
|
|
LambdaQueryWrapper<Features> wrapper = new LambdaQueryWrapper<>();
|
|
|
- if(patentRightVos.get(0).getReportId() != null && patentRightVos.get(0).getSignPatentNo() != null ) {
|
|
|
+ if (patentRightVos.get(0).getReportId() != null && patentRightVos.get(0).getSignPatentNo() != null) {
|
|
|
|
|
|
wrapper.eq(Features::getReportId, patentRightVos.get(0).getReportId())
|
|
|
.eq(Features::getSignPatentNo, patentRightVos.get(0).getSignPatentNo())
|
|
|
- .eq(Features::getPartnerId,personnelVO.getId() );
|
|
|
+ .eq(Features::getPartnerId, personnelVO.getId());
|
|
|
this.remove(wrapper);
|
|
|
}
|
|
|
List<Features> features = new ArrayList<>();
|
|
|
for (int i = 0; i < patentRightVos.size(); i++) {
|
|
|
PatentRightVo patentRightVo = patentRightVos.get(i);
|
|
|
- if (patentRightVo.getFeatures() != null && patentRightVo.getFeatures().size() != 0) {
|
|
|
- features.addAll(patentRightVo.getFeatures());
|
|
|
+ if (patentRightVo.getFeatures() != null && patentRightVo.getFeatures().size() != 0) {
|
|
|
+ features.addAll(patentRightVo.getFeatures());
|
|
|
}
|
|
|
}
|
|
|
- for(int t =0 ;t<features.size();t++){
|
|
|
+ for (int t = 0; t < features.size(); t++) {
|
|
|
features.get(t).setPartnerId(personnelVO.getId());
|
|
|
}
|
|
|
this.saveBatch(features);
|
|
|
return Response.success();
|
|
|
}
|
|
|
|
|
|
+ public String querySimFeaturePatent(Integer reportId, String patentNo) {
|
|
|
+ //获得当前用户信息
|
|
|
+ PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
|
|
|
+ //根据报告Id,拆分人Id,标的专利号获得特征。
|
|
|
+ LambdaQueryWrapper<Features> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(Features::getReportId, reportId)
|
|
|
+ .eq(Features::getSignPatentNo, patentNo)
|
|
|
+ .eq(Features::getPartnerId, personnelVO.getId());
|
|
|
+ List<Features> features = this.list(queryWrapper);
|
|
|
+ //获得特征内容
|
|
|
+ List<String> contents = features.stream().map(Features::getContent).collect(Collectors.toList());
|
|
|
+ return Response.success();
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|