Преглед на файлове

编写查询专题库专利pdf首页图片清单接口(已完成)

chendayu преди 2 години
родител
ревизия
68749689f6

+ 2 - 2
PAS/src/main/java/cn/cslg/pas/controller/PatentInstructionController.java

@@ -106,10 +106,10 @@ public class PatentInstructionController {
         return Response.success();
     }
 
-    @Operation(summary = "查询专题库专利的pdf首页清单")
+    @Operation(summary = "查询专题库专利的pdf首页图片清单")
     @PostMapping("/queryPatentPdfFirstPages")
     public String queryPatentPdfFirstPages(@RequestBody PatentVO params) throws IOException {
-        log.info("开始处理【查询专题库专利的pdf首页清单】的业务,业务参数为:{}", params);
+        log.info("开始处理【查询专题库专利的pdf首页图片清单】的请求,请求参数为:{}", params);
         IPage<PatentDTO> patentDTOs = patentInstructionService.queryPatentPdfFirstPages(params);
         return Response.success(patentDTOs);
     }

+ 1 - 0
PAS/src/main/java/cn/cslg/pas/mapper/PatentMapper.java

@@ -37,6 +37,7 @@ public interface PatentMapper extends BaseMapper<Patent> {
     Map<String, Object> getPatentListByIdAndColumn(Integer id, String column);
 
     IPage<Patent> getPageList(Page<Patent> page, @Param("params") PatentVO params);
+    List<Patent> getPageListNext5(@Param("params") PatentVO params, Integer beforeNum);
     IPage<Patent> getPageListForRMS2(Page<Patent> page, @Param("params") QueryPatentVO params);
     List<String> getListForRMS( @Param("params")QueryPatentVO params);
     List<Patent> getPageList(@Param("params") PatentVO params);

+ 87 - 39
PAS/src/main/java/cn/cslg/pas/service/PatentInstructionService.java

@@ -14,6 +14,7 @@ import cn.cslg.pas.domain.Patent;
 import cn.cslg.pas.domain.PatentInstruction;
 import cn.cslg.pas.domain.Task;
 import cn.cslg.pas.mapper.PatentInstructionMapper;
+import cn.cslg.pas.mapper.PatentMapper;
 import cn.cslg.pas.service.upLoadPatent.MessageService;
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.util.IdUtil;
@@ -37,6 +38,7 @@ import org.apache.pdfbox.pdmodel.font.PDFont;
 import org.apache.pdfbox.pdmodel.font.PDType1Font;
 import org.apache.pdfbox.rendering.ImageType;
 import org.apache.pdfbox.rendering.PDFRenderer;
+import org.springframework.beans.BeanUtils;
 import org.springframework.cache.Cache;
 import org.springframework.cache.CacheManager;
 import org.springframework.context.annotation.Lazy;
@@ -50,7 +52,9 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.imageio.ImageIO;
 import java.awt.*;
 import java.awt.image.RenderedImage;
+import java.io.ByteArrayOutputStream;
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.IOException;
 import java.util.List;
 import java.util.*;
@@ -69,6 +73,7 @@ import java.util.stream.Collectors;
 @RequiredArgsConstructor(onConstructor_ = {@Lazy})
 public class PatentInstructionService extends ServiceImpl<PatentInstructionMapper, PatentInstruction> {
     private final PatentService patentService;
+    private final PatentMapper patentMapper;
     private final TaskService taskService;
     private final MessageService messageService;
     private final FileManagerService fileManagerService;
@@ -324,7 +329,8 @@ public class PatentInstructionService extends ServiceImpl<PatentInstructionMappe
         log.info("开始处理【合并导出专题库专利的pdf首页文件】的业务,业务参数为:{}", params);
 
         //根据筛选条件分页查询专利清单(这一次查询目的只是获得专利总数和总页数)
-        IPage<PatentDTO> pageList0 = patentService.getPageList(params);
+        //IPage<PatentDTO> pageList0 = patentService.getPageList(params);
+        IPage<Patent> pageList0 = patentMapper.getPageList(new Page<>(params.getCurrent(), params.getSize()), params);
         if (pageList0 == null || pageList0.getRecords() == null || pageList0.getRecords().size() == 0) {
             ThrowException.throwXiaoShiException("合并专利pdf首页文档失败,无专利信息!");
         }
@@ -353,9 +359,10 @@ public class PatentInstructionService extends ServiceImpl<PatentInstructionMappe
         //一页一页检索
         for (long i = 1; i <= pages; i++) {
             params.setCurrent(i);
-            IPage<PatentDTO> pageList = patentService.getPageList(params);  //根据筛选条件分页查询专利清单
-            List<PatentDTO> patents = pageList.getRecords();  //取出专利清单
-            List<String> patentNos = patents.stream().map(PatentDTO::getPatentNo).collect(Collectors.toList());  //过滤取出专利号
+            //IPage<PatentDTO> pageList = patentService.getPageList(params);  //根据筛选条件分页查询专利清单
+            IPage<Patent> pageList = patentMapper.getPageList(new Page<>(params.getCurrent(), params.getSize()), params);
+            List<Patent> patents = pageList.getRecords();  //取出专利清单
+            List<String> patentNos = patents.stream().map(Patent::getPatentNo).collect(Collectors.toList());  //过滤取出专利号
 
             //根据专利号patentNos查询出所有pdf文档数据
             List<PatentInstruction> patentInstructions = this.list(new LambdaQueryWrapper<PatentInstruction>().in(PatentInstruction::getPatentNo, patentNos));
@@ -504,6 +511,12 @@ public class PatentInstructionService extends ServiceImpl<PatentInstructionMappe
         messageService.sendWebsocketMessage(task, total, task.getSuccessNum(), percentage);
     }
 
+    /**
+     * pdf转图片方法Demo
+     *
+     * @param inputFile
+     * @param outputFile
+     */
     public void generateBookIamge(File inputFile, File outputFile) {
 
         try {
@@ -531,21 +544,24 @@ public class PatentInstructionService extends ServiceImpl<PatentInstructionMappe
      * @param params 查询条件
      */
     public IPage<PatentDTO> queryPatentPdfFirstPages(PatentVO params) throws IOException {
-        log.info("开始处理【查询专题库专利的pdf首页清单】的业务,业务参数为:{}", params);
+        log.info("开始处理【查询专题库专利的pdf首页图片清单】的业务,业务参数为:{}", params);
 
+        IPage<PatentDTO> pageListResult = new Page<>();
+        ArrayList<PatentDTO> patentDTOs = new ArrayList<>();
         //根据筛选条件分页查询专利清单(这一次查询目的只是获得专利总数和总页数)
-        IPage<PatentDTO> pageList = patentService.getPageList(params);
+        //IPage<PatentDTO> pageList = patentService.getPageList(params);
+        IPage<Patent> pageList = patentMapper.getPageList(new Page<>(params.getCurrent(), params.getSize()), params);
         if (pageList == null || pageList.getRecords() == null || pageList.getRecords().size() == 0) {
-            ThrowException.throwXiaoShiException("查询专题库专利的pdf首页清单失败,未获取到任何专利信息!");
+            ThrowException.throwXiaoShiException("查询专题库专利的pdf首页图片清单失败,未获取到任何专利信息!");
         }
 
-        List<PatentDTO> patents = pageList.getRecords();  //取出专利清单
-        List<String> patentNos = patents.stream().map(PatentDTO::getPatentNo).collect(Collectors.toList());  //过滤取出专利号
-        //根据专利号patentNos查询出所有pdf文档数据
+        List<Patent> patents = pageList.getRecords();  //取出专利清单
+        List<String> patentNos = patents.stream().map(Patent::getPatentNo).collect(Collectors.toList());  //取出专利号
+        //查询出所有pdf文档数据
         List<PatentInstruction> patentInstructions = this.list(new LambdaQueryWrapper<PatentInstruction>().in(PatentInstruction::getPatentNo, patentNos));
 
         //遍历专利,装载数据
-        for (PatentDTO patent : patents) {
+        for (Patent patent : patents) {
             String patentNo = patent.getPatentNo();
             List<PatentInstruction> patentInstructionList = patentInstructions.stream().filter(patentInstruction -> patentInstruction.getPatentNo().equals(patentNo)).collect(Collectors.toList());
             PatentInstruction patentInstruction = new PatentInstruction();
@@ -561,37 +577,33 @@ public class PatentInstructionService extends ServiceImpl<PatentInstructionMappe
                 continue;
             }
 
-
+            //判断缓存中是否有当前专利号的说明书pdf首页图片数据
             Cache.ValueWrapper patentNoImgData = cacheManager.getCache("imgData").get(patentNo);
             String imgData;
-            if (patentNoImgData == null) {  //即当前专利号对应的pdf首页图片数据不在缓存里,则先进行缓存,后返回图片数据
-                imgData = cyCacheUtil.getImgData(patentNo, pdfFile);
-            } else {  //即当前专利号对应的pdf首页图片数据已在缓存里,则先从缓存里取出图片数据并返回后,再删除缓存
+            if (patentNoImgData == null) {  //若没有,则手动转化并返回图片数据
+                //imgData = cyCacheUtil.getImgData(patentNo, pdfFile);  //(此时不能进行缓存,防止缓存过多导致服务器宕机)
+                imgData = this.getImgData(pdfFile);
+            } else {  //若有,则从缓存取出图片数据后,再删除该缓存(防止缓存过多导致服务器宕机)
                 imgData = cyCacheUtil.getImgData(patentNo, pdfFile);
-                cyCacheUtil.deleteImgData(patentNo);
+                cyCacheUtil.deleteImgData(patentNo);  //清除缓存
             }
 
-            patent.setPdfFirstPage(imgData);
+            PatentDTO patentDTO = new PatentDTO();
+            BeanUtils.copyProperties(patent, patentDTO);
+            patentDTO.setPdfFirstPage(imgData);
+            patentDTOs.add(patentDTO);
         }
 
-        //开启一个线程去拿当前专利后面5件专利
+        //开启一个线程去拿后面5件专利的pdf首页图片数据进行缓存
         Thread thread = new Thread() {
             @Override
             public void run() {
-                //根据当前页和每页条数,计算后面5件专利的位置
+                //计算检索分页信息条件前面所有专利数量 beforeNum,作为接下来检索时的起始位置(sql语句:limit beforeNum-1, 5)
                 Long current = params.getCurrent();
                 Long size = params.getSize();
                 long beforeNum = current * size;
-                long page = beforeNum / 5;
-                if (page == 0) {  //即当前检索到第1 - 4个专利,则接下来按照current=1,size=5继续检索并缓存专利pdf首页图片数据
-                    current = 1L;
-                } else {  //即当前检索到超过5个专利,则接下来按照current = page + 1,size=5继续检索并缓存专利pdf首页图片数据
-                    current = page + 1;
-                }
-                params.setCurrent(current);
-                params.setSize(5L);
                 try {
-                    threadRunTask(params);
+                    threadRunTask(params, (int) beforeNum);
                 } catch (IOException e) {
                     e.printStackTrace();
                 }
@@ -599,9 +611,12 @@ public class PatentInstructionService extends ServiceImpl<PatentInstructionMappe
         };
         thread.start();
 
-
-        pageList.setRecords(patents);
-        return pageList;
+        pageListResult.setCurrent(pageList.getCurrent());
+        pageListResult.setSize(pageList.getSize());
+        pageListResult.setPages(pageList.getPages());
+        pageListResult.setTotal(pageList.getTotal());
+        pageListResult.setRecords(patentDTOs);
+        return pageListResult;
     }
 
     /**
@@ -609,18 +624,17 @@ public class PatentInstructionService extends ServiceImpl<PatentInstructionMappe
      *
      * @param params 检索条件
      */
-    public void threadRunTask(PatentVO params) throws IOException {
+    public void threadRunTask(PatentVO params, Integer beforeNum) throws IOException {
         //根据筛选条件分页查询专利清单(这一次查询目的只是获得专利总数和总页数)
-        IPage<PatentDTO> pageList = patentService.getPageList(params);
-        if (pageList == null || pageList.getRecords() == null || pageList.getRecords().size() == 0) {
+        List<Patent> patents = patentMapper.getPageListNext5(params, beforeNum);
+        if (patents == null || patents.size() == 0) {
             return;
         }
-        List<PatentDTO> patents = pageList.getRecords();  //取出专利清单
-        List<String> patentNos = patents.stream().map(PatentDTO::getPatentNo).collect(Collectors.toList());  //过滤取出专利号
-        //根据专利号patentNos查询出所有pdf文档数据
+        List<String> patentNos = patents.stream().map(Patent::getPatentNo).collect(Collectors.toList());  //取出专利号
+        //查询出所有pdf文档数据
         List<PatentInstruction> patentInstructions = this.list(new LambdaQueryWrapper<PatentInstruction>().in(PatentInstruction::getPatentNo, patentNos));
         //遍历专利,装载数据
-        for (PatentDTO patent : patents) {
+        for (Patent patent : patents) {
             String patentNo = patent.getPatentNo();
             List<PatentInstruction> patentInstructionList = patentInstructions.stream().filter(patentInstruction -> patentInstruction.getPatentNo().equals(patentNo)).collect(Collectors.toList());
             PatentInstruction patentInstruction = new PatentInstruction();
@@ -636,10 +650,44 @@ public class PatentInstructionService extends ServiceImpl<PatentInstructionMappe
                 continue;
             }
 
-            //解析当前专利号的pdf文件,将pdf首页转换为图片数据并返回,使用名称为"imgData"的缓存进行处理
+            //调用缓存方法,将当前专利号作为key,专利pdf首页文件图片数据作为value放入名称为"imgData"的缓存(key是唯一值,若缓存中已有当前专利号的key,则不会做任何操作)
             cyCacheUtil.getImgData(patentNo, pdfFile);
         }
     }
 
+    public String getImgData(File pdfFile) throws IOException {
+        //pdf转图片方式二(用依赖pdfbox)
+        PDDocument doc = PDDocument.load(pdfFile);
+        String newFilePath = StringUtils.getUUID() + ".pdf";
+        File outputFile = new File(newFilePath);
+        PDFRenderer pdfRenderer = new PDFRenderer(doc);
+        // 提取的页码
+        int pageNumber = 0;
+        // 以300 dpi 读取存入 BufferedImage 对象
+        int dpi = 300;
+        RenderedImage buffImage = pdfRenderer.renderImageWithDPI(pageNumber, dpi, ImageType.RGB);
+        // 将 BufferedImage 写入到 png
+        ImageIO.write(buffImage, "png", outputFile);
+        doc.close();
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        FileInputStream in = new FileInputStream(outputFile);
+        int bytesRead;
+        byte[] buffer = new byte[8192];
+
+        //读取pdf首页临时文件
+        while ((bytesRead = in.read(buffer)) != -1) {
+            out.write(buffer, 0, bytesRead);
+        }
+        //关闭读取流
+        in.close();
+        byte[] bytes = out.toByteArray();
+        String imgData = org.apache.commons.codec.binary.Base64.encodeBase64String(bytes);
+        //关闭写出流
+        out.close();
+        //最后记得删除pdf首页的临时文件
+        new File(newFilePath).delete();
+        return imgData;
+    }
+
 
 }

+ 61 - 0
PAS/src/main/java/cn/cslg/pas/service/PatentService.java

@@ -515,6 +515,67 @@ public class PatentService extends ServiceImpl<PatentMapper, Patent> {
         return pageList;
     }
 
+    public List<Patent> getPageListNext5(PatentVO params, Integer beforeNum) {
+        //根据同族类型装载需要查询的同族类型
+        this.setQueryFamilyParams(params);
+        //装载需要查询的字段
+        this.setQueryPatentParams(params);
+        //根据装载信息查询专利
+        List<Patent> patents = baseMapper.getPageListNext5(params, beforeNum);
+//        IPage<PatentDTO> pageList = new Page<>();
+//        List<PatentDTO> records = new ArrayList<>();
+//        List<Integer> patentIds = dataPage.getRecords().stream().map(Patent::getId).collect(Collectors.toList());
+//        List<PatentApplicant> patentApplicantList = patentApplicantService.getPatentApplicantByPatentIds(patentIds);
+//        List<PatentInventor> patentInventorList = patentInventorService.getPatentInventorByPatentIds(patentIds);
+//        List<PatentLabel> patentLabelList = patentLabelService.getPatentLabelByPatentIdsAndProjectId(patentIds, params.getProjectId());
+//        List<PatentClassNumberLink> patentClassNumberLinkList = patentClassNumberLinkService.getPatentClassNumberLinkByPatentIds(patentIds);
+//        List<PatentAgent> patentAgentList = patentAgentService.getPatentAgentByPatentIds(patentIds);
+//        List<PatentAgency> patentAgencyList = patentAgencyService.getPatentAgencyByIds(dataPage.getRecords().stream().filter(item -> StringUtils.isNotEmpty(item.getAgencyId())).map(item -> Integer.parseInt(item.getAgencyId())).distinct().collect(Collectors.toList()));
+//        List<PatentSimpleFamilyLink> patentSimpleFamilyLinkList = patentSimpleFamilyLinkService.getPatentSimpleFamilyLinkByFamilyIds(dataPage.getRecords().stream().map(Patent::getSimpleFamily).collect(Collectors.toList()));
+//        List<PatentSimpleFamilyLink> patentInpadocFamilyLinkList = patentSimpleFamilyLinkService.getPatentSimpleFamilyLinkByFamilyIds(dataPage.getRecords().stream().map(Patent::getInpadocFamily).collect(Collectors.toList()));
+//        List<PatentSimpleFamilyLink> patentPatSnapFamilyLinkList = patentSimpleFamilyLinkService.getPatentSimpleFamilyLinkByFamilyIds(dataPage.getRecords().stream().map(Patent::getPatSnapFamily).collect(Collectors.toList()));
+//        List<SystemDict> systemDictList = systemDictService.getSystemDictListByType(Arrays.asList(Constants.PATENT_TYPE, Constants.PATENT_SIMPLE_STATUS));
+//        //获得所有的自定义字段信息
+//        Map<Integer, List<PatentDTO.Field>> map = projectFieldService.getPatentFieldByPatentIdAndProjectId2(params.getProjectId(), patentIds);
+//        dataPage.getRecords().forEach(item -> {
+//            PatentDTO patentDTO = new PatentDTO();
+//            BeanUtils.copyProperties(item, patentDTO);
+//            patentDTO.setApplicationDate(DateUtils.formatDate(item.getApplicationDate(), DateUtils.YYYY_MM_DD));
+//            patentDTO.setPriorityDate(DateUtils.formatDate(item.getPriorityDate(), DateUtils.YYYY_MM_DD));
+//            patentDTO.setPublicDate(DateUtils.formatDate(item.getPublicDate(), DateUtils.YYYY_MM_DD));
+//            patentDTO.setPublicAccreditDate(DateUtils.formatDate(item.getPublicAccreditDate(), DateUtils.YYYY_MM_DD));
+//            patentDTO.setPublicAccreditNo(item.getPublicAccreditNo());
+//            patentDTO.setFirstPublicDate(DateUtils.formatDate(item.getFirstPublicDate(), DateUtils.YYYY_MM_DD));
+//            patentDTO.setSimpleStatus(systemDictList.stream().filter(systemDict -> systemDict.getType().equals(Constants.PATENT_SIMPLE_STATUS) && systemDict.getValue().equals(String.valueOf(item.getSimpleStatus()))).findFirst().orElse(new SystemDict()).getLabel());
+//            patentDTO.setType(systemDictList.stream().filter(systemDict -> systemDict.getType().equals(Constants.PATENT_TYPE) && systemDict.getValue().equals(String.valueOf(item.getType()))).findFirst().orElse(new SystemDict()).getLabel());
+//            patentDTO.setApplicant(patentApplicantList.stream().filter(patentApplicant -> patentApplicant.getPatentId().equals(item.getId())).collect(Collectors.toList()));
+//            patentDTO.setInventor(patentInventorList.stream().filter(patentInventor -> patentInventor.getPatentId().equals(item.getId())).collect(Collectors.toList()));
+//            patentDTO.setLabel(patentLabelList.stream().filter(patentLabel -> patentLabel.getPatentId().equals(item.getId())).collect(Collectors.toList()));
+//            patentDTO.setIpcList(patentClassNumberLinkList.stream().filter(patentClassNumber -> patentClassNumber.getPatentId().equals(item.getId()) && patentClassNumber.getType().equals(Constants.PATENT_CLASS_NUMBER_IPC)).map(PatentClassNumberLink::getCode).distinct().collect(Collectors.toList()));
+//            patentDTO.setCpcList(patentClassNumberLinkList.stream().filter(patentClassNumber -> patentClassNumber.getPatentId().equals(item.getId()) && patentClassNumber.getType().equals(Constants.PATENT_CLASS_NUMBER_CPC)).map(PatentClassNumberLink::getCode).distinct().collect(Collectors.toList()));
+//            patentDTO.setUpcList(patentClassNumberLinkList.stream().filter(patentClassNumber -> patentClassNumber.getPatentId().equals(item.getId()) && patentClassNumber.getType().equals(Constants.PATENT_CLASS_NUMBER_UPC)).map(PatentClassNumberLink::getCode).distinct().collect(Collectors.toList()));
+//            patentDTO.setLocList(patentClassNumberLinkList.stream().filter(patentClassNumber -> patentClassNumber.getPatentId().equals(item.getId()) && patentClassNumber.getType().equals(Constants.PATENT_CLASS_NUMBER_LOC)).map(PatentClassNumberLink::getCode).distinct().collect(Collectors.toList()));
+//            if (StringUtils.isNotEmpty(item.getAgencyId())) {
+//                patentDTO.setAgency(patentAgencyList.stream().filter(patentAgency -> patentAgency.getId().equals(Integer.parseInt(item.getAgencyId()))).findFirst().orElse(null));
+//            }
+//            PatentDTO.PatentFamily patentFamily = new PatentDTO.PatentFamily();
+//            patentFamily.setSimple(patentSimpleFamilyLinkList.stream().filter(patentSimpleFamilyLink -> patentSimpleFamilyLink.getFamilyId().equals(item.getSimpleFamily())).map(PatentSimpleFamilyLink::getPatentNo).collect(Collectors.toList()));
+//            patentFamily.setInpadoc(patentInpadocFamilyLinkList.stream().filter(patentSimpleFamilyLink -> patentSimpleFamilyLink.getFamilyId().equals(item.getInpadocFamily())).map(PatentSimpleFamilyLink::getPatentNo).collect(Collectors.toList()));
+//            patentFamily.setPatSnap(patentPatSnapFamilyLinkList.stream().filter(patentSimpleFamilyLink -> patentSimpleFamilyLink.getFamilyId().equals(item.getPatSnapFamily())).map(PatentSimpleFamilyLink::getPatentNo).collect(Collectors.toList()));
+//            patentDTO.setFamily(patentFamily);
+//            patentDTO.setAgent(patentAgentList.stream().filter(patentAgent -> patentAgent.getPatentId().equals(item.getId())).collect(Collectors.toList()));
+//            // TODO 性能优化
+//            patentDTO.setField(map.get(item.getId()));
+//            records.add(patentDTO);
+//        });
+//        pageList.setTotal(dataPage.getTotal());
+//        pageList.setRecords(records);
+//        pageList.setPages(dataPage.getPages());
+//        pageList.setSize(dataPage.getSize());
+//        pageList.setCurrent(dataPage.getCurrent());
+        return patents;
+    }
+
     public IPage<PatentDTO> getPageListForRMS(QueryPatentVO params) {
         if (params.getObligeeName() != null) {
             String obligeeName = params.getObligeeName().replace("(", "\\(");

+ 363 - 0
PAS/src/main/resources/mapper/PatentMapper.xml

@@ -404,6 +404,369 @@
         <if test="params.sort.prop == 'quotedNum'">a.quotedno</if>
         ${params.sort.order}
     </select>
+
+    <select id="getPageListNext5" parameterType="cn.cslg.pas.common.model.vo.PatentVO"
+            resultType="cn.cslg.pas.domain.Patent">
+        select a.id, a.`name` as name, a.nameout as name_out, a.patentno as patent_no, a.abstract_path, a.abstract as
+        abstract_str, a.abstractout as abstract_out,
+        a.publicno as public_no, a.publicdate as public_date, a.simple_family, a.inpadoc_family, a.applicationno as
+        application_no, a.appdate as application_date,
+        a.`status` as simple_status, a.type, a.publictodate as public_accredit_date, a.fpublicdate as first_public_date,
+        a.prioritydate as priority_date, a.publictono as public_accredit_no,
+        b.look as `read`, a.agencyid as agency_id, a.num2 as right_num, a.quoteno as quote_num, a.quotedno as
+        quoted_num,
+        a.patsnap_family as patSnapFamily, a.patsnapfamilynum as patSnapFamilyNum
+        from os_patent a
+        <if test="params.folder != null and params.folder != ''">
+            left join os_portfolio_link b on b.pid = a.id
+        </if>
+        <if test="params.folder == null or params.folder == ''">
+            left join os_thematic_pid b on b.pid = a.id
+        </if>
+        <if test="params.queryLabel == true">
+            left join os_patent_label d on d.pid = a.id and d.tid = b.zid
+        </if>
+        <if test="params.queryApplicantOriginal == true">
+            left join os_applicant_attr e on e.type = 2 and e.pid = a.id
+        </if>
+        <if test="params.queryApplicantCurrent == true">
+            left join os_applicant_attr f on f.type = 1 and f.pid = a.id
+        </if>
+        <if test="params.queryInventor == true">
+            left join os_patent_inventor_relation g on g.pid = a.id
+            left join os_patent_inventor g1 on g1.id = g.fid
+        </if>
+        <if test="params.queryInventorMerge == true">
+            left join os_patent_inventor_merge g2 on g2.inventor_id = g.fid
+        </if>
+        <if test="params.queryApplicantOriginalStandard == true">
+            left join os_applicant_attr h on h.type = 2 and h.pid = a.id
+            left join os_patent_applicant h1 on h1.id = h.applicantid
+        </if>
+        <if test="params.queryApplicantCurrentStandard == true">
+            left join os_applicant_attr i on i.type = 1 and i.pid = a.id
+            left join os_patent_applicant i1 on i1.id = i.applicantid
+        </if>
+        <if test="params.queryApplicantOriginalMerge == true">
+            left join os_associate_applicant j on e.applicantid = j.applicantid
+        </if>
+        <if test="params.queryApplicantCurrentMerge == true">
+            left join os_associate_applicant k on f.applicantid = k.applicantid
+        </if>
+        <if test="params.queryApplicantAddress == true">
+            left join os_applicant_attr m on m.pid = a.id and m.type = 2
+            left join os_patent_applicant o on o.id = m.applicantid
+        </if>
+        <if test="params.queryAffair == true">
+            left join os_patent_affair p on p.pid = a.id
+        </if>
+        <if test="params.queryClassNumberIpc == true">
+            left join os_patent_typeno q1 on q1.pid = a.id
+        </if>
+        <if test="params.queryClassNumberCpc == true">
+            left join os_patent_typeno q2 on q2.pid = a.id
+        </if>
+        <if test="params.queryClassNumberUpc == true">
+            left join os_patent_typeno q3 on q3.pid = a.id
+        </if>
+        <if test="params.queryClassNumberLoc == true">
+            left join os_patent_typeno q4 on q4.pid = a.id
+        </if>
+        <if test="params.selfField !=null and params.selfField.size()>0">
+            left join os_patent_field_patent_link a2 on a2.pid = a.id
+        </if>
+        <where>
+            <if test="params.read == 'read'">
+                and b.look = 1
+            </if>
+            <if test="params.read == 'unread'">
+                and b.look = 0
+            </if>
+            <if test="params.projectId != null and params.importTaskId == null">
+                and b.zid = #{params.projectId}
+            </if>
+            <if test="params.importTaskId != null and params.projectId == null">
+                and a.patentno in
+                ( select PATENT_NO from ASSO_IMPORTTASK_PATENT where IMPORTTASK_ID in
+                <foreach item="item" collection="params.importTaskId" index="index" open="(" separator=","
+                         close=") ">
+                    #{item}
+                </foreach>
+                )
+            </if>
+            <if test="params.importTaskId != null and params.projectId != null">
+                and (b.zid = #{params.projectId} or
+                a.patentno in
+                ( select PATENT_NO from ASSO_IMPORTTASK_PATENT where IMPORTTASK_ID in
+                <foreach item="item" collection="params.importTaskId" index="index" open="(" separator=","
+                         close=") ">
+                    #{item}
+                </foreach>
+                )
+                )
+            </if>
+            <if test="params.projectId == null and params.projectId == null">
+                and 1 !=1
+            </if>
+            <if test="params.folder != null and params.folder != ''">
+                and b.fid = #{params.folder}
+            </if>
+            <if test="params.nameSql != null and params.nameSql != ''">
+                and (${params.nameSql})
+            </if>
+            <if test="params.abstractStrSql != null and params.abstractStrSql != ''">
+                and (${params.abstractStrSql})
+            </if>
+            <if test="params.publicNoSql != null and params.publicNoSql != ''">
+                and (${params.publicNoSql})
+            </if>
+            <if test="params.applicationNoSql != null and params.applicationNoSql != ''">
+                and (${params.applicationNoSql})
+            </if>
+            <if test="params.rightContentSql != null and params.rightContentSql != ''">
+                and (select count(*) from os_patent_right where a.id = patent_id and (${params.rightContentSql})) > 0
+            </if>
+            <if test="params.querySimpleFamily == true">
+                and (a.simple_family = (select id from os_patent_simplefamily where type = 1 and patent_no = a.patentno)
+                or a.simple_family is null)
+            </if>
+            <if test="params.queryInpadocFamily == true">
+                and (a.inpadoc_family = (select id from os_patent_simplefamily where type = 2 and patent_no =
+                a.patentno) or a.inpadoc_family is null)
+            </if>
+            <if test="params.queryPatSnapFamily == true">
+                and (a.patsnap_family = (select id from os_patent_simplefamily where type = 3 and patent_no =
+                a.patentno) or a.patsnap_family is null)
+            </if>
+            <if test="params.whereClassNumberIpc != null">
+                and q1.type = 1 and
+                <foreach collection="params.whereClassNumberIpc" item="item" separator="or" open="(" close=")">
+                    <if test="params.queryClassNumberIpcMethod == 1">
+                        left(q1.code, 1)
+                    </if>
+                    <if test="params.queryClassNumberIpcMethod == 2">
+                        left(q1.code, 3)
+                    </if>
+                    <if test="params.queryClassNumberIpcMethod == 3">
+                        left(q1.code, 4)
+                    </if>
+                    <if test="params.queryClassNumberIpcMethod == 4">
+                        substring_index(q1.code, '/', 1)
+                    </if>
+                    <if test="params.queryClassNumberIpcMethod == 5">
+                        q1.code
+                    </if>
+                    = #{item}
+                </foreach>
+            </if>
+            <if test="params.whereClassNumberCpc != null">
+                and q2.type = 2 and
+                <foreach collection="params.whereClassNumberCpc" item="item" separator="or" open="(" close=")">
+                    <if test="params.queryClassNumberCpcMethod == 1">
+                        left(q2.code, 1)
+                    </if>
+                    <if test="params.queryClassNumberCpcMethod == 2">
+                        left(q2.code, 3)
+                    </if>
+                    <if test="params.queryClassNumberCpcMethod == 3">
+                        left(q2.code, 4)
+                    </if>
+                    <if test="params.queryClassNumberCpcMethod == 4">
+                        substring_index(q2.code, '/', 1)
+                    </if>
+                    <if test="params.queryClassNumberCpcMethod == 5">
+                        q2.code
+                    </if>
+                    = #{item}
+                </foreach>
+            </if>
+            <if test="params.whereClassNumberUpc != null">
+                and q3.type = 3 and
+                <foreach collection="params.whereClassNumberUpc" item="item" separator="or" open="(" close=")">
+                    <if test="params.queryClassNumberUpcMethod == 1">
+                        q3.code
+                    </if>
+                    <if test="params.queryClassNumberUpcMethod == 2">
+                        substring_index(q3.code, '/', 1)
+                    </if>
+                    <if test="params.queryClassNumberUpcMethod == 3">
+                        substring_index(q3.code, '/', -1)
+                    </if>
+                    = #{item}
+                </foreach>
+            </if>
+            <if test="params.whereClassNumberLoc != null">
+                and q4.type = 4 and
+                <foreach collection="params.whereClassNumberLoc" item="item" separator="or" open="(" close=")">
+                    <if test="params.queryClassNumberLocMethod == 1">
+                        q4.code
+                    </if>
+                    <if test="params.queryClassNumberLocMethod == 2">
+                        substring_index(q4.code, '/', 1)
+                    </if>
+                    <if test="params.queryClassNumberLocMethod == 3">
+                        substring_index(q4.code, '/', -1)
+                    </if>
+                    = #{item}
+                </foreach>
+            </if>
+            <if test="params.whereApplicantOriginal != null">
+                and e.applicantid in
+                <foreach collection="params.whereApplicantOriginal" item="item" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="params.whereApplicantCurrent != null">
+                and f.applicantid in
+                <foreach collection="params.whereApplicantCurrent" item="item" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="params.whereInventor != null">
+                and g1.id in
+                <foreach collection="params.whereInventor" item="item" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="params.whereInventorMerge != null">
+                and (
+                g2.merge_id in
+                <foreach collection="params.whereInventorMerge" item="item" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+                or
+                g.fid in
+                <foreach collection="params.whereInventorMerge" item="item" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+                )
+            </if>
+            <if test="params.whereApplicantOriginalStandard != null">
+                and h1.bname in
+                <foreach collection="params.whereApplicantOriginalStandard" item="item" separator="," open="("
+                         close=")">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="params.whereApplicantCurrentStandard != null">
+                and i1.bname in
+                <foreach collection="params.whereApplicantCurrentStandard" item="item" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="params.whereApplicantOriginalMerge != null">
+                and (
+                j.mergeid in
+                <foreach collection="params.whereApplicantOriginalMerge" item="item" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+                or
+                e.applicantid in
+                <foreach collection="params.whereApplicantOriginalMerge" item="item" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+                )
+            </if>
+            <if test="params.whereApplicantCurrentMerge != null">
+                and (
+                k.mergeid in
+                <foreach collection="params.whereApplicantCurrentMerge" item="item" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+                or
+                f.applicantid in
+                <foreach collection="params.whereApplicantCurrentMerge" item="item" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+                )
+            </if>
+            <if test="params.whereBureau != null">
+                and a.bureau in
+                <foreach collection="params.whereBureau" item="item" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="params.whereType != null">
+                and a.type in
+                <foreach collection="params.whereType" item="item" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="params.whereStatus != null">
+                and a.status in
+                <foreach collection="params.whereStatus" item="item" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="params.whereAppDate != null">
+                and from_unixtime(a.appdate, '%Y') in
+                <foreach collection="params.whereAppDate" item="item" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="params.wherePublicDate != null">
+                and from_unixtime(a.publicdate, '%Y') in
+                <foreach collection="params.wherePublicDate" item="item" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="params.whereCountry != null">
+                and o.country in
+                <foreach collection="params.whereCountry" item="item" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="params.whereApplicantProvince != null">
+                and o.province_id in
+                <foreach collection="params.whereApplicantProvince" item="item" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="params.whereAffair != null">
+                and p.status REGEXP #{params.whereAffair}
+            </if>
+            <if test="params.whereLabel != null">
+                and d.tagname in
+                <foreach collection="params.whereLabel" item="item" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="params.selfField != null and params.selfField.size()>0">
+                and
+                <foreach collection="params.selfField" item="item" separator=" and " open="(" close=")">
+                    a.id in (
+                    select distinct a3.id from os_patent a3 left join os_patent_field_patent_link a4
+                    on a4.pid = a3.id
+                    and a4.cid=#{item.key}
+                    <where>
+                        a4.fid in
+                        <foreach collection="item.value" item="item2" separator="," open="(" close=")">
+                            #{item2}
+                        </foreach>
+                        <if test="item.isnull==true">
+                            or a4.id is null
+                        </if>
+                    </where>
+                    )
+                </foreach>
+            </if>
+        </where>
+        group by a.id
+        order by
+        <if test="params.sort.prop == 'id'">a.id</if>
+        <if test="params.sort.prop == 'name'">a.name</if>
+        <if test="params.sort.prop == 'patentNo'">a.patentno</if>
+        <if test="params.sort.prop == 'applicationNo'">a.applicationno</if>
+        <if test="params.sort.prop == 'applicationDate'">a.appdate</if>
+        <if test="params.sort.prop == 'publicDate'">a.publicdate</if>
+        <if test="params.sort.prop == 'publicAccreditDate'">a.publictodate</if>
+        <if test="params.sort.prop == 'rightNum'">a.num2</if>
+        <if test="params.sort.prop == 'quoteNum'">a.quoteno</if>
+        <if test="params.sort.prop == 'quotedNum'">a.quotedno</if>
+        ${params.sort.order}
+        limit #{beforeNum}, 5
+    </select>
+
     <select id="getPatentQuerySourcePageList" parameterType="cn.cslg.pas.common.model.vo.PatentQueryFieldSourceVO"
             resultType="cn.cslg.pas.common.model.dto.PatentQueryFieldSourceDTO">
         <if test="params.key == '41-1'">