|
@@ -2,12 +2,14 @@ package cn.cslg.report.service.business;
|
|
|
|
|
|
import cn.cslg.report.common.model.vo.PatentRightVo;
|
|
|
import cn.cslg.report.common.model.vo.PersonnelVO;
|
|
|
+import cn.cslg.report.common.utils.CacheUtils;
|
|
|
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.mapper.FeatureMapper;
|
|
|
import cn.cslg.report.service.OutInterfaceService;
|
|
|
+import cn.dev33.satoken.stp.StpUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
@@ -22,6 +24,8 @@ import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
@@ -29,177 +33,203 @@ import java.util.stream.Collectors;
|
|
|
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
|
|
|
public class FeatureService extends ServiceImpl<FeatureMapper, Features> {
|
|
|
|
|
|
- private final OutInterfaceService outInterfaceService;
|
|
|
- //从PAS系统上获得权要并拆分
|
|
|
-public String splitPatentRight(String patentNo,Integer splitType ,Integer splitBy,Integer reportId) throws IOException {
|
|
|
- //权要(带拆分的特征)列表
|
|
|
- List<PatentRightVo> patentRightVos =new ArrayList<>();
|
|
|
- //从pas获得权要信息
|
|
|
- String resBody= outInterfaceService.getPatentRightFromPAS(patentNo);
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(resBody);
|
|
|
- //解析jason获得标的专利的权要
|
|
|
- List<PatentRight> patentRights = JSON.parseArray(jsonObject.getString("data"),PatentRight.class);
|
|
|
- List<Integer> partRightIds=new ArrayList<>();
|
|
|
- List<String> flags =new ArrayList<>();
|
|
|
- // 当splitType=0仅拆解主权要
|
|
|
- if(splitType==0)
|
|
|
- { partRightIds = patentRights.stream().filter(item->item.getType()==1).map(PatentRight::getId).collect(Collectors.toList());
|
|
|
- }// 当splitType=1拆解全部权要
|
|
|
- else if(splitType==1)
|
|
|
- {
|
|
|
- partRightIds = patentRights.stream().map(PatentRight::getId).collect(Collectors.toList());
|
|
|
- }
|
|
|
- //当splitBy=0时仅仅根据“,”拆解
|
|
|
- if(splitBy==0)
|
|
|
- { flags.add(",");
|
|
|
-
|
|
|
+ private final OutInterfaceService outInterfaceService;
|
|
|
+ private final CacheUtils cacheUtils;
|
|
|
+
|
|
|
+ //对权要进行合并操作
|
|
|
+ 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;
|
|
|
}
|
|
|
- //当splitBy=1时仅仅根据“;“拆解
|
|
|
- else if(splitBy==1)
|
|
|
- {
|
|
|
- flags.add(";");
|
|
|
- }//当splitBy=2时根据“;“和”,”拆解
|
|
|
- else if(splitBy==2){
|
|
|
-
|
|
|
- flags.add(",");
|
|
|
- flags.add(";");
|
|
|
- }
|
|
|
- Features featureTO=new Features();
|
|
|
- featureTO.setReportId(reportId);
|
|
|
- featureTO.setSignPatentNo(patentNo);
|
|
|
- //featureTO.setPartnerId();
|
|
|
- //查询数据库里是否有查询记录
|
|
|
- List<Features> featureFromDb =this.queryFeatures(featureTO);
|
|
|
- //将拆解的权要和特征装载到对象PatentRightVo
|
|
|
- for(int i=0;i<patentRights.size();i++) {
|
|
|
- List<Features> featuresList = new ArrayList<>();
|
|
|
- //对需要拆解的权要进行拆解
|
|
|
- if(partRightIds.contains(patentRights.get(i).getId()))
|
|
|
- {
|
|
|
-
|
|
|
- if(featureFromDb!=null&&featureFromDb.size()!=0)
|
|
|
- { int rightId =patentRights.get(i).getId();
|
|
|
- featuresList = featureFromDb.stream().filter(item->item.getRightId()==rightId).collect(Collectors.toList());
|
|
|
+ //从PAS系统上获得权要并拆分
|
|
|
+ public String splitPatentRight(String patentNo, Integer splitType, Integer splitBy, Integer reportId) throws IOException {
|
|
|
+ //权要(带拆分的特征)列表
|
|
|
+ List<PatentRightVo> patentRightVos = new ArrayList<>();
|
|
|
+ //从pas获得权要信息
|
|
|
+ String resBody = outInterfaceService.getPatentRightFromPAS(patentNo);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(resBody);
|
|
|
+ //解析jason获得标的专利的权要
|
|
|
+ List<PatentRight> patentRightsOrgin = JSON.parseArray(jsonObject.getString("data"), PatentRight.class);
|
|
|
+
|
|
|
+ List<PatentRight> patentRights = FormatPatentRights(patentRightsOrgin);
|
|
|
+
|
|
|
+
|
|
|
+ List<Integer> partRightIds = new ArrayList<>();
|
|
|
+ List<String> flags = new ArrayList<>();
|
|
|
+ // 当splitType=0仅拆解主权要
|
|
|
+ if (splitType == 0) {
|
|
|
+ partRightIds = patentRights.stream().filter(item -> item.getType() == 1).map(PatentRight::getId).collect(Collectors.toList());
|
|
|
+ }// 当splitType=1拆解全部权要
|
|
|
+ else if (splitType == 1) {
|
|
|
+ partRightIds = patentRights.stream().map(PatentRight::getId).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ //当splitBy=0时仅仅根据“,”拆解
|
|
|
+ if (splitBy == 0) {
|
|
|
+ flags.add(",");
|
|
|
|
|
|
}
|
|
|
- //如果数据库里无拆解记录则手动插入一条
|
|
|
- if(featuresList==null||featuresList.size()==0)
|
|
|
- { featuresList=new ArrayList<>();
|
|
|
- //获得权要的译文并且拆解
|
|
|
- List<String> contentOuts = this.splitStringByFlags(patentRights.get(i).getContentOut(), flags);
|
|
|
- //获得权要的原文并且拆解
|
|
|
- List<String> contents =this.splitStringByFlags(patentRights.get(i).getContent(),flags);
|
|
|
- //遍历拆解出来的内容并装载到features最后存入列表
|
|
|
- for (int t = 0; t < contentOuts.size(); t++)
|
|
|
- { Features features =new Features();
|
|
|
- features.setRightId(patentRights.get(i).getId());
|
|
|
- features.setIsFinal(0);
|
|
|
- features.setSignPatentNo(patentNo);
|
|
|
- features.setReportId(reportId);
|
|
|
- features.setContentOut(contentOuts.get(t));
|
|
|
- String content= contents.size()-1>=t ? contents.get(t):"";
|
|
|
- features.setContent(content);
|
|
|
-// features.setPartnerId(LoginUtils.getToken());
|
|
|
- featuresList.add(features);
|
|
|
+ //当splitBy=1时仅仅根据“;“拆解
|
|
|
+ else if (splitBy == 1) {
|
|
|
+ flags.add(";");
|
|
|
+ }//当splitBy=2时根据“;“和”,”拆解
|
|
|
+ else if (splitBy == 2) {
|
|
|
+
|
|
|
+ flags.add(",");
|
|
|
+ flags.add(";");
|
|
|
+ }
|
|
|
+ Features featureTO = new Features();
|
|
|
+ featureTO.setReportId(reportId);
|
|
|
+ featureTO.setSignPatentNo(patentNo);
|
|
|
+ //featureTO.setPartnerId();
|
|
|
+ //查询数据库里是否有查询记录
|
|
|
+ List<Features> featureFromDb = this.queryFeatures(featureTO);
|
|
|
+ //将拆解的权要和特征装载到对象PatentRightVo
|
|
|
+ for (int i = 0; i < patentRights.size(); i++) {
|
|
|
+ List<Features> featuresList = new ArrayList<>();
|
|
|
+ //对需要拆解的权要进行拆解
|
|
|
+ if (partRightIds.contains(patentRights.get(i).getId())) {
|
|
|
+
|
|
|
+ if (featureFromDb != null && featureFromDb.size() != 0) {
|
|
|
+ int rightId = patentRights.get(i).getId();
|
|
|
+ featuresList = featureFromDb.stream().filter(item -> item.getRightId() == rightId).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ //如果数据库里无拆解记录则手动插入一条
|
|
|
+ if (featuresList == null || featuresList.size() == 0) {
|
|
|
+ featuresList = new ArrayList<>();
|
|
|
+ //获得权要的译文并且拆解
|
|
|
+ List<String> contentOuts = this.splitStringByFlags(patentRights.get(i).getContentOut(), flags);
|
|
|
+ //获得权要的原文并且拆解
|
|
|
+ List<String> contents = this.splitStringByFlags(patentRights.get(i).getContent(), flags);
|
|
|
+ //遍历拆解出来的内容并装载到features最后存入列表
|
|
|
+ for (int t = 0; t < contents.size(); t++) {
|
|
|
+ Features features = new Features();
|
|
|
+ features.setRightId(patentRights.get(i).getId());
|
|
|
+ features.setIsFinal(0);
|
|
|
+ features.setSignPatentNo(patentNo);
|
|
|
+ features.setReportId(reportId);
|
|
|
+ String countOut = contentOuts.size() - 1 >= t ? contentOuts.get(t) : "";
|
|
|
+ features.setContentOut(countOut);
|
|
|
+ features.setContent(contents.get(t));
|
|
|
+ PersonnelVO personnelVO = cacheUtils.getLoginUser(StpUtil.getLoginIdAsInt());
|
|
|
+ features.setPartnerId(personnelVO.getId());
|
|
|
+ featuresList.add(features);
|
|
|
+ }
|
|
|
+ this.saveBatch(featuresList);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- //装载到对象PatentRightVo
|
|
|
- PatentRightVo patentRightVo =new PatentRightVo();
|
|
|
- patentRightVo.setPatentId(patentRights.get(i).getPatentId());
|
|
|
- patentRightVo.setFeatures(featuresList);
|
|
|
- patentRightVo.setContent(patentRights.get(i).getContent());
|
|
|
- patentRightVo.setSort(patentRights.get(i).getSort());
|
|
|
- patentRightVo.setType(patentRights.get(i).getType());
|
|
|
- patentRightVo.setContentOut(patentRights.get(i).getContentOut());
|
|
|
- patentRightVo.setReportId(reportId);
|
|
|
-// patentRightVo.setPatentId();
|
|
|
- patentRightVo.setSignPatentNo(patentNo);
|
|
|
- patentRightVos.add(patentRightVo);
|
|
|
- }
|
|
|
+ //装载到对象PatentRightVo
|
|
|
+ PatentRightVo patentRightVo = new PatentRightVo();
|
|
|
+ String name="权要"+(i+1);
|
|
|
+ patentRightVo.setPatentId(patentRights.get(i).getPatentId());
|
|
|
+ patentRightVo.setFeatures(featuresList);
|
|
|
+ patentRightVo.setContent(patentRights.get(i).getContent());
|
|
|
+ patentRightVo.setSort(patentRights.get(i).getSort());
|
|
|
+ patentRightVo.setType(patentRights.get(i).getType());
|
|
|
+ patentRightVo.setContentOut(patentRights.get(i).getContentOut());
|
|
|
+ patentRightVo.setReportId(reportId);
|
|
|
+ patentRightVo.setRightName(name);
|
|
|
+ patentRightVo.setSignPatentNo(patentNo);
|
|
|
+ patentRightVos.add(patentRightVo);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- return Response.success(patentRightVos);
|
|
|
+ return Response.success(patentRightVos);
|
|
|
|
|
|
-}
|
|
|
+ }
|
|
|
|
|
|
-//根据符号拆分字符串
|
|
|
-public List<String> splitStringByFlags(String sentence,List<String> flags){
|
|
|
-List<String> sectences =new ArrayList<>();
|
|
|
+ //根据符号拆分字符串
|
|
|
+ public List<String> splitStringByFlags(String sentence, List<String> flags) {
|
|
|
+ List<String> sectences = new ArrayList<>();
|
|
|
//如果字符串为空则返回一个包含空字符串的list
|
|
|
-if(sentence==null){
|
|
|
- sectences.add("");
|
|
|
- return sectences;
|
|
|
-}
|
|
|
-sectences.add(sentence);
|
|
|
-for(int i=0;i<flags.size();i++)
|
|
|
-{ List<String> tem =new ArrayList<>();
|
|
|
- for(int t=0;t<sectences.size();t++)
|
|
|
- {
|
|
|
- tem.addAll(Arrays.asList(sentence.split(flags.get(i))));
|
|
|
- }
|
|
|
-sectences=tem;
|
|
|
+ if (sentence == null) {
|
|
|
+ sectences.add("");
|
|
|
+ return sectences;
|
|
|
+ }
|
|
|
+ sectences.add(sentence);
|
|
|
+ for (int i = 0; i < flags.size(); i++) {
|
|
|
+ List<String> tem = new ArrayList<>();
|
|
|
+ for (int t = 0; t < sectences.size(); t++) {
|
|
|
+ tem.addAll(Arrays.asList(sectences.get(t).split(flags.get(i))));
|
|
|
+ }
|
|
|
+ sectences = tem;
|
|
|
|
|
|
-}
|
|
|
-return sectences;
|
|
|
+ }
|
|
|
+ return sectences;
|
|
|
|
|
|
-}
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* @author lrj
|
|
|
* @deprecated 查询特征
|
|
|
*/
|
|
|
-public List<Features> queryFeatures(Features features){
|
|
|
- List<Features> featureList =new ArrayList<>();
|
|
|
- LambdaQueryWrapper<Features> lambdaQueryWrapper= new LambdaQueryWrapper();
|
|
|
- if(features.getRightId()!=null)
|
|
|
- {lambdaQueryWrapper.eq(Features::getRightId,features.getRightId());
|
|
|
- }
|
|
|
- if(features.getIsFinal()!=null)
|
|
|
- {
|
|
|
- lambdaQueryWrapper.eq(Features::getIsFinal,features.getIsFinal());
|
|
|
- }
|
|
|
- if(features.getPartnerId()!=null)
|
|
|
- {
|
|
|
- lambdaQueryWrapper.eq(Features::getPartnerId,features.getPartnerId());
|
|
|
- }
|
|
|
- if(features.getSignPatentNo()!=null)
|
|
|
- {
|
|
|
- lambdaQueryWrapper.eq(Features::getSignPatentNo,features.getSignPatentNo());
|
|
|
- }
|
|
|
- if(features.getReportId()!=null)
|
|
|
- {
|
|
|
- lambdaQueryWrapper.eq(Features::getReportId,features.getReportId());
|
|
|
+ public List<Features> queryFeatures(Features features) {
|
|
|
+ List<Features> featureList = new ArrayList<>();
|
|
|
+ LambdaQueryWrapper<Features> lambdaQueryWrapper = new LambdaQueryWrapper();
|
|
|
+ if (features.getRightId() != null) {
|
|
|
+ lambdaQueryWrapper.eq(Features::getRightId, features.getRightId());
|
|
|
+ }
|
|
|
+ if (features.getIsFinal() != null) {
|
|
|
+ lambdaQueryWrapper.eq(Features::getIsFinal, features.getIsFinal());
|
|
|
+ }
|
|
|
+ if (features.getPartnerId() != null) {
|
|
|
+ lambdaQueryWrapper.eq(Features::getPartnerId, features.getPartnerId());
|
|
|
+ }
|
|
|
+ if (features.getSignPatentNo() != null) {
|
|
|
+ lambdaQueryWrapper.eq(Features::getSignPatentNo, features.getSignPatentNo());
|
|
|
+ }
|
|
|
+ if (features.getReportId() != null) {
|
|
|
+ lambdaQueryWrapper.eq(Features::getReportId, features.getReportId());
|
|
|
+ }
|
|
|
+ featureList = this.list(lambdaQueryWrapper);
|
|
|
+ return featureList;
|
|
|
}
|
|
|
- featureList =this.list(lambdaQueryWrapper);
|
|
|
- return featureList;
|
|
|
-}
|
|
|
|
|
|
/**
|
|
|
* @author 沈永艺
|
|
|
* @deprecated 保存特征
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
-public String addFeatures(PatentRightVo patentRightVo){
|
|
|
- if(patentRightVo.getReportId()!=null&&patentRightVo.getSignPatentNo()!=null&&patentRightVo.getPartnerId()!=null)
|
|
|
- {LambdaQueryWrapper<Features> wrapper =new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(Features::getReportId,patentRightVo.getReportId())
|
|
|
- .eq(Features::getSignPatentNo,patentRightVo.getSignPatentNo())
|
|
|
- .eq(Features::getPartnerId,patentRightVo.getPartnerId());
|
|
|
-
|
|
|
- this.remove(wrapper);
|
|
|
- if(patentRightVo.getFeatures()!=null&&patentRightVo.getFeatures().size()!=0)
|
|
|
- {
|
|
|
- this.saveBatch(patentRightVo.getFeatures());
|
|
|
- }
|
|
|
-
|
|
|
+ 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 ) {
|
|
|
+
|
|
|
+ wrapper.eq(Features::getReportId, patentRightVos.get(0).getReportId())
|
|
|
+ .eq(Features::getSignPatentNo, patentRightVos.get(0).getSignPatentNo())
|
|
|
+ .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());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for(int t =0 ;t<features.size();t++){
|
|
|
+ features.get(t).setPartnerId(personnelVO.getId());
|
|
|
+ }
|
|
|
+ this.saveBatch(features);
|
|
|
+ return Response.success();
|
|
|
}
|
|
|
|
|
|
- return Response.success();
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
|
|
|
}
|