|
@@ -0,0 +1,155 @@
|
|
|
+package cn.cslg.report.service.business;
|
|
|
+
|
|
|
+import cn.cslg.report.common.model.vo.CompareMessageVO;
|
|
|
+import cn.cslg.report.common.model.vo.PatentRightVo;
|
|
|
+import cn.cslg.report.common.model.vo.PersonnelVO;
|
|
|
+import cn.cslg.report.common.model.vo.SplitVO;
|
|
|
+import cn.cslg.report.common.utils.CacheUtils;
|
|
|
+import cn.cslg.report.common.utils.Response;
|
|
|
+import cn.cslg.report.entity.*;
|
|
|
+import cn.cslg.report.entity.asso.AssoTaskPatentSplit;
|
|
|
+import cn.cslg.report.entity.asso.AssoTaskPersonel;
|
|
|
+import cn.cslg.report.mapper.AssoTaskPatentSplitMapper;
|
|
|
+import cn.cslg.report.mapper.CompareMessageMapper;
|
|
|
+import cn.cslg.report.service.OutInterfaceService;
|
|
|
+import cn.dev33.satoken.stp.StpUtil;
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+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.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+
|
|
|
+@Service
|
|
|
+@Slf4j
|
|
|
+@RequiredArgsConstructor(onConstructor_ = {@Lazy})
|
|
|
+public class CompareMessageService extends ServiceImpl<CompareMessageMapper, CompareMessage> {
|
|
|
+ private final TaskService taskService;
|
|
|
+ private final FeatureService featureService;
|
|
|
+ private final CacheUtils cacheUtils;
|
|
|
+ private final OutInterfaceService outInterfaceService;
|
|
|
+ private final AssoTaskPatentSplitService assoTaskPatentSplitService;
|
|
|
+ private final AssoTaskPersonelService assoTaskPersonelService;
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Boolean addCompareMessage(List<CompareMessageVO> vos) {
|
|
|
+ /**
|
|
|
+ * @author 李仁杰
|
|
|
+ * @deprecated 保存特征
|
|
|
+ */
|
|
|
+ // 获取登录人信息
|
|
|
+ PersonnelVO personnelVO = cacheUtils.getLoginUser(StpUtil.getLoginIdAsInt());
|
|
|
+ List<CompareMessage> compareMessages = new ArrayList<>();
|
|
|
+ //根据登录人Id,报告Id,标的专利号查询特征
|
|
|
+ LambdaQueryWrapper<Features> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ if (vos.get(0).getTaskId() != null && vos.get(0).getSignPatentNo() != null) {
|
|
|
+ wrapper.eq(Features::getTaskId, vos.get(0).getTaskId())
|
|
|
+ .eq(Features::getSignPatentNo, vos.get(0).getSignPatentNo());
|
|
|
+ Features feature = featureService.list(wrapper).get(0);
|
|
|
+ //根据登录人Id,报告Id,标的专利号删除原有特征
|
|
|
+ featureService.remove(wrapper);
|
|
|
+ for (int i = 0; i < vos.size(); i++) {
|
|
|
+ int order = 1;
|
|
|
+ Features features1 = new Features();
|
|
|
+ features1.setContent(vos.get(i).getContent());
|
|
|
+ features1.setFeaturesOrder(order);
|
|
|
+ features1.setTaskId(vos.get(i).getTaskId());
|
|
|
+ features1.setSplitType(feature.getSplitType());
|
|
|
+ features1.setSplitBy(feature.getSplitBy());
|
|
|
+ features1.setPartnerId(personnelVO.getId());
|
|
|
+ features1.setReportId(feature.getReportId());
|
|
|
+ features1.setRightName(vos.get(i).getRightName());
|
|
|
+ features1.setRightType(vos.get(i).getRightType());
|
|
|
+ features1.setRightId(vos.get(i).getRightId());
|
|
|
+ features1.setSignPatentNo(vos.get(i).getSignPatentNo());
|
|
|
+ features1.setContentOut(vos.get(i).getContentOut());
|
|
|
+ features1.setExplainText(vos.get(i).getExplainText());
|
|
|
+ features1.insert();
|
|
|
+ CompareMessage compareMessage = new CompareMessage();
|
|
|
+ compareMessage.setFeatureId(features1.getId());
|
|
|
+ compareMessage.setCompareResult(vos.get(i).getCompareResult());
|
|
|
+ compareMessage.setTargetDescription(vos.get(i).getTargetDescription());
|
|
|
+ compareMessage.setCompareDescription(vos.get(i).getCompareDescription());
|
|
|
+ compareMessages.add(compareMessage);
|
|
|
+ order += 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return this.saveBatch(compareMessages);
|
|
|
+ }
|
|
|
+
|
|
|
+ public Boolean updateCompareMessage(List<CompareMessage> compareMessageList) {
|
|
|
+ return this.saveOrUpdateBatch(compareMessageList);
|
|
|
+ }
|
|
|
+
|
|
|
+ public Boolean removeCompareMessage(List<Integer> ids) {
|
|
|
+ return this.removeByIds(ids);
|
|
|
+ }
|
|
|
+
|
|
|
+ public Map<String, Object> queryCompareMessage(Integer taskId, String patentNo) throws IOException {
|
|
|
+ List<PatentRightVo> patentRightVos = new ArrayList<>();
|
|
|
+ String resBody = outInterfaceService.getPatentRightFromPAS(patentNo);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(resBody);
|
|
|
+ //解析jason获得标的专利的权要
|
|
|
+ List<PatentRight> patentRightsOrgin = JSON.parseArray(jsonObject.getString("data"), PatentRight.class);
|
|
|
+ //处理权要
|
|
|
+ List<PatentRight> patentRights = featureService.FormatPatentRights(patentRightsOrgin);
|
|
|
+
|
|
|
+ //查询特征
|
|
|
+ LambdaQueryWrapper<Features> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(Features::getTaskId, taskId);
|
|
|
+ queryWrapper.eq(Features::getSignPatentNo, patentNo);
|
|
|
+ List<Features> features = featureService.list(queryWrapper);
|
|
|
+ List<Integer> featureIds = features.stream().map(Features::getId).collect(Collectors.toList());
|
|
|
+ LambdaQueryWrapper<CompareMessage> queryWrapper1 = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper1.in(CompareMessage::getFeatureId, featureIds);
|
|
|
+ List<CompareMessage> compareMessages = this.list(queryWrapper1);
|
|
|
+ List<CompareMessageVO> compareMessageVOS =new ArrayList<>();
|
|
|
+ features.forEach(item->{
|
|
|
+ CompareMessageVO compareMessageVO =new CompareMessageVO();
|
|
|
+ BeanUtil.copyProperties(compareMessageVO,item);
|
|
|
+ CompareMessage compareMessage =new CompareMessage();
|
|
|
+ if( compareMessages.size()!=0){
|
|
|
+ compareMessage = compareMessages.stream().filter(tem->tem.getFeatureId().equals(item.getId())).findFirst().get();
|
|
|
+ }
|
|
|
+ BeanUtil.copyProperties(compareMessageVO,compareMessage);
|
|
|
+ });
|
|
|
+ //将拆解的权要和特征装载到对象PatentRightVo
|
|
|
+ for (int i = 0; i < patentRights.size(); i++) {
|
|
|
+
|
|
|
+ List<CompareMessageVO> featuresList = new ArrayList<>();
|
|
|
+ //对需要拆解的权要进行拆解
|
|
|
+ if (compareMessageVOS != null && compareMessageVOS.size() != 0) {
|
|
|
+ int rightId = patentRights.get(i).getSort();
|
|
|
+ featuresList = compareMessageVOS.stream().filter(item -> item.getRightId().equals(rightId)).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ //装载到对象PatentRightVo
|
|
|
+ PatentRightVo patentRightVo = new PatentRightVo();
|
|
|
+ String name = "权要" + (i + 1);
|
|
|
+ patentRightVo.setPatentId(patentRights.get(i).getPatentId());
|
|
|
+ patentRightVo.setCompareMessageVOS(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.setRightName(name);
|
|
|
+ patentRightVo.setSignPatentNo(patentNo);
|
|
|
+ patentRightVos.add(patentRightVo);
|
|
|
+ }
|
|
|
+ Map<String, Object> map1 = assoTaskPatentSplitService.getSplitMessage(taskId, patentNo);
|
|
|
+ Map<String, Object> map = new HashMap<String, Object>();
|
|
|
+ map.put("patentRightVos", patentRightVos);
|
|
|
+ map.put("splitBy", map1.get("splitBy"));
|
|
|
+ map.put("splitType", map1.get("splitType"));
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|