|
@@ -37,6 +37,7 @@ import org.apache.pdfbox.pdmodel.font.PDFont;
|
|
import org.apache.pdfbox.pdmodel.font.PDType1Font;
|
|
import org.apache.pdfbox.pdmodel.font.PDType1Font;
|
|
import org.apache.pdfbox.rendering.ImageType;
|
|
import org.apache.pdfbox.rendering.ImageType;
|
|
import org.apache.pdfbox.rendering.PDFRenderer;
|
|
import org.apache.pdfbox.rendering.PDFRenderer;
|
|
|
|
+import org.springframework.cache.Cache;
|
|
import org.springframework.cache.CacheManager;
|
|
import org.springframework.cache.CacheManager;
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.data.redis.cache.RedisCacheManager;
|
|
import org.springframework.data.redis.cache.RedisCacheManager;
|
|
@@ -72,7 +73,6 @@ public class PatentInstructionService extends ServiceImpl<PatentInstructionMappe
|
|
private final MessageService messageService;
|
|
private final MessageService messageService;
|
|
private final FileManagerService fileManagerService;
|
|
private final FileManagerService fileManagerService;
|
|
private final CacheManager cacheManager;
|
|
private final CacheManager cacheManager;
|
|
- private final RedisCacheManager redisCacheManager;
|
|
|
|
private final CyCacheUtil cyCacheUtil;
|
|
private final CyCacheUtil cyCacheUtil;
|
|
private final FileUtils fileUtils;
|
|
private final FileUtils fileUtils;
|
|
private final LoginUtils loginUtils;
|
|
private final LoginUtils loginUtils;
|
|
@@ -561,20 +561,35 @@ public class PatentInstructionService extends ServiceImpl<PatentInstructionMappe
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
- //解析当前专利号的pdf文件,将pdf首页转换为图片数据并返回,使用名称为"imgData"的缓存进行处理
|
|
|
|
- String imgData = cyCacheUtil.getImgData(patentNo, pdfFile);
|
|
|
|
- patent.setPdfFirstPage(imgData);
|
|
|
|
|
|
|
|
|
|
+ Cache.ValueWrapper patentNoImgData = cacheManager.getCache("imgData").get(patentNo);
|
|
|
|
+ String imgData;
|
|
|
|
+ if (patentNoImgData == null) { //即当前专利号对应的pdf首页图片数据不在缓存里,则先进行缓存,后返回图片数据
|
|
|
|
+ imgData = cyCacheUtil.getImgData(patentNo, pdfFile);
|
|
|
|
+ } else { //即当前专利号对应的pdf首页图片数据已在缓存里,则先从缓存里取出图片数据并返回后,再删除缓存
|
|
|
|
+ imgData = cyCacheUtil.getImgData(patentNo, pdfFile);
|
|
|
|
+ cyCacheUtil.deleteImgData(patentNo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ patent.setPdfFirstPage(imgData);
|
|
}
|
|
}
|
|
|
|
|
|
- //开启一个线程继续去拿当前专利后面5件专利
|
|
|
|
|
|
+ //开启一个线程去拿当前专利后面5件专利
|
|
Thread thread = new Thread() {
|
|
Thread thread = new Thread() {
|
|
@Override
|
|
@Override
|
|
public void run() {
|
|
public void run() {
|
|
|
|
+ //根据当前页和每页条数,计算后面5件专利的位置
|
|
Long current = params.getCurrent();
|
|
Long current = params.getCurrent();
|
|
- //Long size = params.getSize();
|
|
|
|
- //long beforeNum = current * size;
|
|
|
|
- params.setCurrent(++current);
|
|
|
|
|
|
+ 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 {
|
|
try {
|
|
threadRunTask(params);
|
|
threadRunTask(params);
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
@@ -589,6 +604,11 @@ public class PatentInstructionService extends ServiceImpl<PatentInstructionMappe
|
|
return pageList;
|
|
return pageList;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 根据检索条件,将检索到的专利的pdf首页图片数据缓存到内存中
|
|
|
|
+ *
|
|
|
|
+ * @param params 检索条件
|
|
|
|
+ */
|
|
public void threadRunTask(PatentVO params) throws IOException {
|
|
public void threadRunTask(PatentVO params) throws IOException {
|
|
//根据筛选条件分页查询专利清单(这一次查询目的只是获得专利总数和总页数)
|
|
//根据筛选条件分页查询专利清单(这一次查询目的只是获得专利总数和总页数)
|
|
IPage<PatentDTO> pageList = patentService.getPageList(params);
|
|
IPage<PatentDTO> pageList = patentService.getPageList(params);
|