123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- package cn.cslg.pas.service;
- import cn.cslg.pas.domain.Patent;
- import cn.cslg.pas.domain.PatentApplicant;
- import cn.cslg.pas.domain.PatentSimpleFamilyLink;
- import cn.cslg.pas.common.model.vo.PatentSimpleFamilyVO;
- import cn.cslg.pas.common.utils.StringUtils;
- import cn.cslg.pas.mapper.PatentSimpleFamilyLinkMapper;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- import lombok.RequiredArgsConstructor;
- import org.springframework.context.annotation.Lazy;
- import org.springframework.stereotype.Service;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.stream.Collectors;
- /**
- * <p>
- * 同族关联专利表 服务类
- * </p>
- *
- * @author 王岩
- * @since 2022-02-24
- */
- @Service
- @RequiredArgsConstructor(onConstructor_ = {@Lazy})
- public class PatentSimpleFamilyLinkService extends ServiceImpl<PatentSimpleFamilyLinkMapper, PatentSimpleFamilyLink> {
- private final PatentService patentService;
- private final PatentApplicantService patentApplicantService;
- public IPage<PatentSimpleFamilyLink> getPageList(PatentSimpleFamilyVO params) {
- LambdaQueryWrapper<PatentSimpleFamilyLink> queryWrapper = new LambdaQueryWrapper<>();
- if (StringUtils.isNotEmpty(params.getPatentNo())) {
- queryWrapper.like(PatentSimpleFamilyLink::getPatentNo, params.getPatentNo());
- }
- queryWrapper.eq(PatentSimpleFamilyLink::getFamilyId, params.getFamilyId());
- IPage<PatentSimpleFamilyLink> pageList = this.page(new Page<>(params.getCurrent(), params.getSize()), queryWrapper);
- List<Patent> patentList = patentService.getPatentListByPatentNo(pageList.getRecords().stream().map(PatentSimpleFamilyLink::getPatentNo).collect(Collectors.toList()));
- List<PatentApplicant> patentApplicantList = patentApplicantService.getPatentApplicantByPatentIds(patentList.stream().map(Patent::getId).collect(Collectors.toList()));
- pageList.getRecords().forEach(patentSimpleFamily -> {
- Patent patent = patentList.stream().filter(item -> item.getPatentNo().equals(patentSimpleFamily.getPatentNo())).findFirst().orElse(null);
- if (patent == null) {
- patentSimpleFamily.setPatentId(-1);
- patentSimpleFamily.setName("暂未收录");
- } else {
- patentSimpleFamily.setPatentId(patent.getId());
- patentSimpleFamily.setName(patent.getName());
- patentSimpleFamily.setAbstractPath(patent.getAbstractPath());
- patentSimpleFamily.setApplicant(patentApplicantList.stream().filter(item -> item.getPatentId().equals(patentSimpleFamily.getPatentId())).collect(Collectors.toList()));
- }
- });
- return pageList;
- }
- public List<PatentSimpleFamilyLink> getPatentSimpleFamilyLinkByPatentNo(List<String> patentNos) {
- LambdaQueryWrapper<PatentSimpleFamilyLink> queryWrapper = new LambdaQueryWrapper<>();
- queryWrapper.in(PatentSimpleFamilyLink::getPatentNo, patentNos);
- return this.list(queryWrapper);
- }
- public List<PatentSimpleFamilyLink> getPatentSimpleFamilyLinkByPatentNoAndFamilyId(List<String> patentNo, Integer familyId) {
- LambdaQueryWrapper<PatentSimpleFamilyLink> queryWrapper = new LambdaQueryWrapper<>();
- queryWrapper.in(PatentSimpleFamilyLink::getPatentNo, patentNo);
- queryWrapper.eq(PatentSimpleFamilyLink::getFamilyId, familyId);
- return this.list(queryWrapper);
- }
- public List<PatentSimpleFamilyLink> getPatentSimpleFamilyLinkByFamilyIds(List<Integer> familyIds) {
- if (familyIds == null || familyIds.size() == 0) {
- return new ArrayList<>();
- }
- LambdaQueryWrapper<PatentSimpleFamilyLink> queryWrapper = new LambdaQueryWrapper<>();
- queryWrapper.in(PatentSimpleFamilyLink::getFamilyId, familyIds);
- return this.list(queryWrapper);
- }
- }
|