|
@@ -1,10 +1,131 @@
|
|
|
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.extension.service.impl.ServiceImpl;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
@Service
|
|
|
+@Slf4j
|
|
|
+@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<>();
|
|
|
+ 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<>();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+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;
|
|
|
+
|
|
|
+}
|
|
|
+return sectences;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
}
|