|
@@ -1,18 +1,22 @@
|
|
|
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.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 com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
@@ -25,94 +29,177 @@ import java.util.stream.Collectors;
|
|
|
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
|
|
|
public class FeatureService extends ServiceImpl<FeatureMapper, Features> {
|
|
|
|
|
|
- private final OutInterfaceService outInterfaceService;
|
|
|
-
|
|
|
+ private final OutInterfaceService outInterfaceService;
|
|
|
//从PAS系统上获得权要并拆分
|
|
|
- public String splitPatentRight(String patentNo, Integer splitType, Integer splitBy, Integer reportId) throws IOException {
|
|
|
- //权要(带拆分的特征)列表
|
|
|
- List<PatentRightVo> patentRightVos = new ArrayList<>();
|
|
|
- String resBody = outInterfaceService.getPatentRightFromPAS(patentNo);
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(resBody);
|
|
|
- List<PatentRight> patentRights = JSON.parseArray(jsonObject.getString("data"), PatentRight.class);
|
|
|
- List<String> flags = new ArrayList<>();
|
|
|
- List<PatentRight> mainRights = new ArrayList<>();
|
|
|
- if (splitType == 0) {
|
|
|
- mainRights = patentRights.stream().filter(item -> item.getType() == 1).collect(Collectors.toList());
|
|
|
- // TODO: 2022/11/9 这个地方的判断条件应该是 mainRights.size() == 0 吧 如果是为null的话 这个地方一直都是 false的
|
|
|
- if (mainRights == null) {
|
|
|
- mainRights = new ArrayList<>();
|
|
|
- }
|
|
|
- } else if (splitType == 1) {
|
|
|
- mainRights = patentRights;
|
|
|
- }
|
|
|
- if (splitBy == 0) {
|
|
|
- flags.add(",");
|
|
|
- } else if (splitBy == 1) {
|
|
|
- flags.add(";");
|
|
|
- } else if (splitBy == 2) {
|
|
|
- flags.add(",");
|
|
|
- flags.add(";");
|
|
|
- }
|
|
|
- List<Features> featuresListToDb = new ArrayList<>();
|
|
|
- for (PatentRight mainRight : mainRights) {
|
|
|
- List<String> contentOuts = this.splitStringByFlags(mainRight.getContentOut(), flags);
|
|
|
- List<String> contents = this.splitStringByFlags(mainRight.getContent(), flags);
|
|
|
- List<Features> featuresList = new ArrayList<>();
|
|
|
- for (int t = 0; t < contentOuts.size(); t++) {
|
|
|
- Features features = new Features();
|
|
|
- features.setRight(mainRight.getContentOut());
|
|
|
- features.setRightId(mainRight.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);
|
|
|
- // TODO: 2022/11/9 这段添加代码是做什么的? featuresListToDb 这个List在装填完数据后没有调用啊
|
|
|
- featuresListToDb.add(features);
|
|
|
- }
|
|
|
- PatentRightVo patentRightVo = new PatentRightVo();
|
|
|
- patentRightVo.setPatentId(mainRight.getPatentId());
|
|
|
- patentRightVo.setFeatures(featuresList);
|
|
|
- patentRightVo.setContent(mainRight.getContent());
|
|
|
- patentRightVo.setSort(mainRight.getSort());
|
|
|
- patentRightVo.setType(mainRight.getType());
|
|
|
- patentRightVo.setContentOut(mainRight.getContentOut());
|
|
|
- patentRightVos.add(patentRightVo);
|
|
|
+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(",");
|
|
|
+
|
|
|
+ }
|
|
|
+ //当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 (splitType == 0) {
|
|
|
- List<PatentRight> rights = patentRights.stream().filter(item -> item.getType() == 0).collect(Collectors.toList());
|
|
|
- for (PatentRight right : rights) {
|
|
|
- PatentRightVo patentRightVo = new PatentRightVo();
|
|
|
- patentRightVo.setPatentId(right.getPatentId());
|
|
|
- patentRightVo.setFeatures(null);
|
|
|
- patentRightVo.setContent(right.getContent());
|
|
|
- patentRightVo.setSort(right.getSort());
|
|
|
- patentRightVo.setType(right.getType());
|
|
|
- patentRightVo.setContentOut(right.getContentOut());
|
|
|
- patentRightVos.add(patentRightVo);
|
|
|
+ //如果数据库里无拆解记录则手动插入一条
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return Response.success(patentRightVos);
|
|
|
+ //装载到对象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);
|
|
|
}
|
|
|
|
|
|
|
|
|
- public List<String> splitStringByFlags(String sentence, List<String> flags) {
|
|
|
- List<String> sentenceList = new ArrayList<>();
|
|
|
- sentenceList.add(sentence);
|
|
|
- for (String flag : flags) {
|
|
|
- List<String> tem = new ArrayList<>();
|
|
|
- for (int t = 0; t < sentenceList.size(); t++) {
|
|
|
- tem.addAll(Arrays.asList(sentence.split(flag)));
|
|
|
- }
|
|
|
- sentenceList = tem;
|
|
|
+ return Response.success(patentRightVos);
|
|
|
|
|
|
- }
|
|
|
+}
|
|
|
+
|
|
|
+//根据符号拆分字符串
|
|
|
+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;
|
|
|
+
|
|
|
+}
|
|
|
+return sectences;
|
|
|
+
|
|
|
+}
|
|
|
|
|
|
- return sentenceList;
|
|
|
+ /**
|
|
|
+ * @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());
|
|
|
}
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return Response.success();
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|