|
@@ -9,6 +9,7 @@ import cn.cslg.pas.domain.PatentSimpleFamilyLink;
|
|
|
import cn.cslg.pas.mapper.PatentSimpleFamilyLinkMapper;
|
|
|
import cn.cslg.pas.mapper.PatentSimpleFamilyMapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
@@ -110,67 +111,94 @@ public class PatentSimpleFamilyService extends ServiceImpl<PatentSimpleFamilyMap
|
|
|
else{
|
|
|
temPatentNo= patentNo;
|
|
|
}
|
|
|
+ String familyPatent =temPatentNo;
|
|
|
+ //根据专利号查询同族信息
|
|
|
+ LambdaQueryWrapper<PatentSimpleFamily> wrapper =new LambdaQueryWrapper<>();
|
|
|
+ wrapper.in(PatentSimpleFamily::getPatentNo,familyNo)
|
|
|
+ .eq(PatentSimpleFamily::getType,type);
|
|
|
+ List<PatentSimpleFamily> simpleFamilies = this.list(wrapper);
|
|
|
+ //获得同族专利的同族id
|
|
|
+ List<Integer> familyIds =simpleFamilies.stream().map(PatentSimpleFamily::getId).collect(Collectors.toList());
|
|
|
+ //查询是否有满足条件的
|
|
|
+ PatentSimpleFamily simpleFamily =simpleFamilies.stream().filter(item->item.getPatentNo().equals(familyPatent)&&item.getType().equals(type)).findFirst().orElse(null);
|
|
|
+ if(simpleFamily==null){
|
|
|
+ simpleFamily= this.add(type,familyPatent);
|
|
|
+ }
|
|
|
+ familyIds.remove(simpleFamily.getId());
|
|
|
|
|
|
//3.根据专利号(faimlyNo + patentNo)和同族类型从family关联表中取数据
|
|
|
List<PatentSimpleFamilyLink> patentSimpleFamilyLinkList = patentSimpleFamilyLinkMapper.getPatentFamilyLinkByPatentNo(familyNo,type);
|
|
|
|
|
|
- //4.第3步中如果有数据,则取得一个familID为下一步的插入关联表中的id
|
|
|
- PatentSimpleFamily patentSimpleFamily;
|
|
|
- if(patentSimpleFamilyLinkList !=null && patentSimpleFamilyLinkList.size() >0){
|
|
|
- //4.1 第3步中有数据
|
|
|
- patentSimpleFamily = this.getPatentSimpleFamilyByIdsAndType(patentSimpleFamilyLinkList.stream().map(PatentSimpleFamilyLink::getFamilyId).collect(Collectors.toList()), type);
|
|
|
- }
|
|
|
- else{
|
|
|
- //4.2 第3步中有数据则在Family表中添加一条记录,并
|
|
|
- patentSimpleFamily = this.add(type,temPatentNo);
|
|
|
- }
|
|
|
-
|
|
|
//5.专利号(faimlyNo + patentNo)和第三步获得的记录比较,如果没有则在关联表中添加一条记录
|
|
|
for(String temPN:familyNo) {
|
|
|
PatentSimpleFamilyLink temp = patentSimpleFamilyLinkList.stream().filter(item -> item.getPatentNo().equals(temPN)).findFirst().orElse(null);
|
|
|
if (temp == null) {
|
|
|
//5.1 如果关联表中没有记录,添加一个
|
|
|
PatentSimpleFamilyLink patentSimpleFamilyLink = new PatentSimpleFamilyLink();
|
|
|
- patentSimpleFamilyLink.setFamilyId(patentSimpleFamily.getId());
|
|
|
+ patentSimpleFamilyLink.setFamilyId(simpleFamily.getId());
|
|
|
patentSimpleFamilyLink.setPatentNo(temPN);
|
|
|
patentSimpleFamilyLink.insert();
|
|
|
} else {
|
|
|
//5.2 如果关联表中有记录,判断familyid是否跟temFailyID相同,不相同则更新记录
|
|
|
- if (temp.getFamilyId() != patentSimpleFamily.getId()) {
|
|
|
- temp.setFamilyId(patentSimpleFamily.getId());
|
|
|
+ if (temp.getFamilyId() != simpleFamily.getId()) {
|
|
|
+ temp.setFamilyId(simpleFamily.getId());
|
|
|
temp.updateById();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- //6.如果同族关联表有数据则更新,无数据则插入一条数据
|
|
|
- Patent patent1 = patent1s.stream().filter(item -> item.getPatentNo().equals(temPN)).findFirst().orElse(null);
|
|
|
- if (patent1 != null) {
|
|
|
- switch (type) {
|
|
|
- case 1:
|
|
|
- if(patent1.getSimpleFamily()!=patentSimpleFamily.getId())
|
|
|
- {
|
|
|
- patent1.setSimpleFamily(patentSimpleFamily.getId());
|
|
|
- patent1.updateById();
|
|
|
- }
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- if(patent1.getInpadocFamily()!=patentSimpleFamily.getId())
|
|
|
- {
|
|
|
- patent1.setInpadocFamily(patentSimpleFamily.getId());
|
|
|
- patent1.updateById();
|
|
|
- }
|
|
|
- break;
|
|
|
- case 3:
|
|
|
- if(patent1.getPatSnapFamily()!=patentSimpleFamily.getId())
|
|
|
- {
|
|
|
- patent1.setPatSnapFamily(patentSimpleFamily.getId());
|
|
|
- patent1.updateById();
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+ //6.如果同族关联表有数据则更新,无数据则插入一条数据
|
|
|
+ Patent patent1 = patent1s.stream().filter(item -> item.getPatentNo().equals(familyPatent)).findFirst().orElse(null);
|
|
|
+ if (patent1 != null) {
|
|
|
+ switch (type) {
|
|
|
+ case 1:
|
|
|
+ if(patent1.getSimpleFamily()!=simpleFamily.getId())
|
|
|
+ {
|
|
|
+ patent1.setSimpleFamily(simpleFamily.getId());
|
|
|
+ patent1.updateById();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ if(patent1.getInpadocFamily()!=simpleFamily.getId())
|
|
|
+ {
|
|
|
+ patent1.setInpadocFamily(simpleFamily.getId());
|
|
|
+ patent1.updateById();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ if(patent1.getPatSnapFamily()!=simpleFamily.getId())
|
|
|
+ {
|
|
|
+ patent1.setPatSnapFamily(simpleFamily.getId());
|
|
|
+ patent1.updateById();
|
|
|
+ }
|
|
|
+ break;
|
|
|
}
|
|
|
+
|
|
|
+ }
|
|
|
+ if(familyIds.size()!=0) {
|
|
|
+ //删除同族关联信息
|
|
|
+ LambdaQueryWrapper<PatentSimpleFamilyLink> linkWrapper =new LambdaQueryWrapper<>();
|
|
|
+ linkWrapper.in(PatentSimpleFamilyLink::getId,familyIds);
|
|
|
+ patentSimpleFamilyLinkService.remove(linkWrapper);
|
|
|
+ //删除其他同族信息
|
|
|
+ LambdaUpdateWrapper<PatentSimpleFamily> deleteWrapper= new LambdaUpdateWrapper<>();
|
|
|
+ deleteWrapper.in(PatentSimpleFamily::getId,familyIds);
|
|
|
+ this.remove(deleteWrapper);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+//
|
|
|
+// //4.第3步中如果有数据,则取得一个familID为下一步的插入关联表中的id
|
|
|
+// PatentSimpleFamily patentSimpleFamily;
|
|
|
+// if(patentSimpleFamilyLinkList !=null && patentSimpleFamilyLinkList.size() >0){
|
|
|
+// //4.1 第3步中有数据
|
|
|
+// patentSimpleFamily = this.getPatentSimpleFamilyByIdsAndType(patentSimpleFamilyLinkList.stream().map(PatentSimpleFamilyLink::getFamilyId).collect(Collectors.toList()), type);
|
|
|
+// }
|
|
|
+// else{
|
|
|
+// //4.2 第3步中有数据则在Family表中添加一条记录,并
|
|
|
+// patentSimpleFamily = this.add(type,temPatentNo);
|
|
|
+// }
|
|
|
+//
|
|
|
+
|
|
|
+//
|
|
|
+
|
|
|
}
|