|
@@ -1,9 +1,7 @@
|
|
|
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;
|
|
@@ -27,105 +25,94 @@ 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());
|
|
|
- if(mainRights==null)
|
|
|
- {
|
|
|
- mainRights=new ArrayList<>();
|
|
|
+ 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;
|
|
|
}
|
|
|
- }
|
|
|
- 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(int i=0;i<mainRights.size();i++) {
|
|
|
- List<String> contentOuts = this.splitStringByFlags(mainRights.get(i).getContentOut(), flags);
|
|
|
- List<String> contents =this.splitStringByFlags(mainRights.get(i).getContent(),flags);
|
|
|
- List<Features> featuresList = new ArrayList<>();
|
|
|
- for (int t = 0; t < contentOuts.size(); t++)
|
|
|
- { Features features =new Features();
|
|
|
- features.setRight(mainRights.get(i).getContentOut());
|
|
|
- features.setRightId(mainRights.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);
|
|
|
- featuresListToDb.add(features);
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ }
|
|
|
}
|
|
|
- PatentRightVo patentRightVo =new PatentRightVo();
|
|
|
- patentRightVo.setPatentId(mainRights.get(i).getPatentId());
|
|
|
- patentRightVo.setFeatures(featuresList);
|
|
|
- patentRightVo.setContent(mainRights.get(i).getContent());
|
|
|
- patentRightVo.setSort(mainRights.get(i).getSort());
|
|
|
- patentRightVo.setType(mainRights.get(i).getType());
|
|
|
- patentRightVo.setContentOut(mainRights.get(i).getContentOut());
|
|
|
- patentRightVos.add(patentRightVo);
|
|
|
- }
|
|
|
- if(splitType==0){
|
|
|
- List<PatentRight> rights =patentRights.stream().filter(item->item.getType()==0).collect(Collectors.toList());
|
|
|
- for(int i=0;i<rights.size();i++) {
|
|
|
- PatentRightVo patentRightVo =new PatentRightVo();
|
|
|
- patentRightVo.setPatentId(rights.get(i).getPatentId());
|
|
|
- patentRightVo.setFeatures(null);
|
|
|
- patentRightVo.setContent(rights.get(i).getContent());
|
|
|
- patentRightVo.setSort(rights.get(i).getSort());
|
|
|
- patentRightVo.setType(rights.get(i).getType());
|
|
|
- patentRightVo.setContentOut(rights.get(i).getContentOut());
|
|
|
- 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<>();
|
|
|
-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;
|
|
|
+ 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 sectences;
|
|
|
+ }
|
|
|
|
|
|
-}
|
|
|
+ return sentenceList;
|
|
|
+ }
|
|
|
|
|
|
}
|