|
@@ -1,6 +1,7 @@
|
|
|
package cn.cslg.pas.service.importPatent;
|
|
|
|
|
|
import cn.cslg.pas.common.dto.PatentStarListDTO;
|
|
|
+import cn.cslg.pas.common.dto.UploadPatentWebDTO;
|
|
|
import cn.cslg.pas.common.model.cronModel.Calculate;
|
|
|
import cn.cslg.pas.common.utils.DateUtils;
|
|
|
import cn.cslg.pas.common.utils.MathUtils;
|
|
@@ -24,139 +25,41 @@ import java.util.Map;
|
|
|
@Scope("prototype")
|
|
|
@Service
|
|
|
public class ImportFromWebToEsService implements PatentImportImp {
|
|
|
+
|
|
|
private TaskThread taskThread;
|
|
|
+ @Autowired
|
|
|
private PatentStarApiService patentStarApiService;
|
|
|
|
|
|
@Override
|
|
|
public void startPatentThread() {
|
|
|
ImportTaskAMVO importTaskAMVO = new ImportTaskAMVO();
|
|
|
+ //十进制转二进制
|
|
|
+ String imContents = MathUtils.fun(2, importTaskAMVO.getImportContent());
|
|
|
+ //下载字段
|
|
|
+ char[] importCells = imContents.toCharArray();
|
|
|
+ char ifCataloguing = importCells[0];
|
|
|
+ char ifAddPicture = importCells[1];
|
|
|
+ char ifClaim = importCells[2];
|
|
|
+ char ifFullText =importCells[3];
|
|
|
+ char ifPdf =importCells[4];
|
|
|
//若本次下载任务是超过一万条专利的全部下载任务
|
|
|
int patentNum = 10000;
|
|
|
if (importTaskAMVO.getEndNum() <= patentNum) {
|
|
|
-// excuteLessThan10000(task);
|
|
|
+ excuteLessThan10000(importTaskAMVO);
|
|
|
} else {
|
|
|
- // Integer total = importTaskAMVO.getAllNum(); //任务专利总数量
|
|
|
-// Integer successNum = importTaskAMVO.getSuccessNum();
|
|
|
-// String orderBy = importTaskAMVO.getOrderBy(); //排序字段
|
|
|
-// String orderByType = importTaskAMVO.getOrderByType(); //排序类型
|
|
|
-// String dbType = importTaskAMVO.getDBType(); //检索数据库类型
|
|
|
-// List<String> cells = importTaskAMVO.getConfigCells(); //下载字段
|
|
|
-// Integer startNumber = importTaskAMVO.getStartNumber(); //下载起始条数位置
|
|
|
-// List<String> isDeletePatentNos = task.getIsDeletePatentNos(); //起止条数中不需要下载的专利号
|
|
|
-//
|
|
|
-// //如果完成数量大于0,则当前下载任务为暂停后的继续下载,则开始位置更新
|
|
|
-// if (successNum > 0) {
|
|
|
-// startNumber += successNum;
|
|
|
-// }
|
|
|
-//
|
|
|
-// //获得返回的的多个检索式 patentStarListDtos
|
|
|
-// List<PatentStarListDto> patentStarListDtos = patentStarApiService.getSplitedConditions(new PatentStarListDto()
|
|
|
-// .setCurrentQuery(task.getConditions())
|
|
|
-// .setOrderBy(orderBy)
|
|
|
-// .setOrderByType(orderByType)
|
|
|
-// .setDBType(dbType), patentNum);
|
|
|
-//
|
|
|
-// int produceSuccessNum = 0;
|
|
|
-// int countForStart = 0; //定义变量countForStart,记录检索式的专利总数量(目的是找出下载开始位置专利所属的那个检索式)
|
|
|
-// //第1层:遍历多个检索式
|
|
|
-// for (PatentStarListDto patentStarListDto : patentStarListDtos) {
|
|
|
-// //还没有到开始位置,则跳过,继续判断下一个检索式
|
|
|
-// countForStart += patentStarListDto.getTotal();
|
|
|
-// if (countForStart < startNumber) {
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// //至此,即找到了当前检索式即为要下载的专利开始位置所属的检索式,重新计算开始位置startNumber(即要下载的专利的开始位置,对应了当前检索式中该专利位置)
|
|
|
-// startNumber = startNumber - (countForStart - patentStarListDto.getTotal());
|
|
|
-// //第一个检索式下载完成后,从第二个检索式开始 startNumber都是从1开始下载
|
|
|
-// if (startNumber < 0) {
|
|
|
-// startNumber = 1;
|
|
|
-// }
|
|
|
-// //调用方法,入参为开始位置和结束位置(即当前检索式最后一个专利的位置,即当前检索式的专利总数量total),获得开始页数、结束页数、开始页数的开始位置、结束页数的结束位置
|
|
|
-// Calculate calculate = calculateFromStartAndEndNumber(startNumber, patentStarListDto.getTotal());
|
|
|
-// Integer startPage = calculate.getStartPage();
|
|
|
-// Integer startNum = calculate.getStartNum();
|
|
|
-// Integer endPage = calculate.getEndPage();
|
|
|
-//
|
|
|
-// //第2层:遍历检索页数
|
|
|
-// for (Integer i = startPage; i <= endPage; i++) {
|
|
|
-// //调用一般检索接口,返回一批专利著录相关数据
|
|
|
-// patentStarListDto
|
|
|
-// .setPageNum(i)
|
|
|
-// .setRowCount(50)
|
|
|
-// .setFormed(true);
|
|
|
-// Map<String, Object> resultMap = patentStarApiService.patentStarSearchApi(patentStarListDto);
|
|
|
-// if (resultMap == null || (Integer) resultMap.get("total") == 0) {
|
|
|
-// ThrowException.throwXiaoShiException("未检索到相关专利");
|
|
|
-// }
|
|
|
-//
|
|
|
-// List<StarPatentVO> starPatents = (List<StarPatentVO>) resultMap.get("records");
|
|
|
-// //第3层:遍历专利
|
|
|
-// for (int j = 0; j < starPatents.size(); j++) {
|
|
|
-// //若任务状态为已暂停,则结束本次任务的下载
|
|
|
-// if (pTaskId.equals(task.getId()) && pTaskStatus == 4) {
|
|
|
-// return;
|
|
|
-// }
|
|
|
-// //若生产的数量达到了总数,则结束本次任务的下载
|
|
|
-// if (produceSuccessNum == total) {
|
|
|
-// return;
|
|
|
-// }
|
|
|
-// //如果还没到要下载的专利的开始位置,则跳过,继续判断下一个专利
|
|
|
-// if (i.equals(startPage) && j < startNum - 1) {
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// //如果当前遍历到的专利号是需要删除的专利,则跳过,不下载它
|
|
|
-// if (isDeletePatentNos != null && isDeletePatentNos.size() > 0 && isDeletePatentNos.contains(starPatents.get(j).getApplicationNo())) {
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-//
|
|
|
-// //将专利丢入各生产线程,进行生产和消费
|
|
|
-// UploadParamsVO uploadParamsVO = new UploadParamsVO();
|
|
|
-// uploadParamsVO.setPatent(new Patent());
|
|
|
-// uploadParamsVO.getPatent().setPatentNo(starPatents.get(j).getPatentNo());
|
|
|
-// uploadPatentBatchService.getOneOrInsertOne(uploadParamsVO);
|
|
|
-//
|
|
|
-// PQueueData pQueueData = new PQueueData()
|
|
|
-// .setTask(task)
|
|
|
-// .setStarPatent(starPatents.get(j))
|
|
|
-// .setUploadParamsVO(uploadParamsVO);
|
|
|
-//
|
|
|
-// //专利丢入著录生产者队列,并唤醒著录生产者线程
|
|
|
-// if (cells.contains("1")) {
|
|
|
-// pantentQueueService.zhuluToPQueue(pQueueData);
|
|
|
-// }
|
|
|
-// //专利丢入权要生产者队列,并唤醒权要生产者线程
|
|
|
-// if (cells.contains("2")) {
|
|
|
-// pantentQueueService.rightToPQueue(pQueueData);
|
|
|
-// }
|
|
|
-// //专利丢入说明书文本生产者队列,并唤醒说明书文本生产者线程
|
|
|
-// if (cells.contains("3")) {
|
|
|
-// pantentQueueService.instructionTextToPQueue(pQueueData);
|
|
|
-// }
|
|
|
-// //专利丢入说明书pdf生产者队列,并唤醒说明书pdf生产者线程
|
|
|
-// if (cells.contains("4")) {
|
|
|
-// pantentQueueService.instructionPDFToPQueue(pQueueData);
|
|
|
-// }
|
|
|
-// //专利丢入摘要附图生产者队列,并唤醒摘要附图生产者线程
|
|
|
-// if (cells.contains("6")) {
|
|
|
-// pantentQueueService.imageToPQueue(pQueueData);
|
|
|
-// }
|
|
|
-//
|
|
|
-// produceSuccessNum++; //计数,每生产完一个,生产完成数量++
|
|
|
-//
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
-
|
|
|
}
|
|
|
SavePatentToEsThread savePatentToEsThread = new SavePatentToEsThread(taskThread, taskThread.getApplicationContext());
|
|
|
+ if(ifCataloguing==1){
|
|
|
+ GetCataloguingFromWebThread getCataloguingFromWebThread =new GetCataloguingFromWebThread(taskThread,savePatentToEsThread);
|
|
|
+ getCataloguingFromWebThread.start();
|
|
|
+ }
|
|
|
+
|
|
|
GetPatentFromExcelThread getPatentFromExcelThread = new GetPatentFromExcelThread(taskThread.getImportTaskAMVO(), savePatentToEsThread, taskThread.getApplicationContext());
|
|
|
savePatentToEsThread.start();
|
|
|
getPatentFromExcelThread.start();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
private void excuteLessThan10000(ImportTaskAMVO importTaskAMVO) {
|
|
|
try {
|
|
|
Integer successNum = importTaskAMVO.getSuccessNum(); //成功条数(即上一次下载到的位置)
|
|
@@ -165,42 +68,44 @@ public class ImportFromWebToEsService implements PatentImportImp {
|
|
|
String orderByType = importTaskAMVO.getOrderByType(); //排序类型
|
|
|
String dbType = importTaskAMVO.getDBType(); //检索数据库类型
|
|
|
Integer importContent = importTaskAMVO.getImportContent(); //下载字段
|
|
|
- Integer doneNum =importTaskAMVO.getDoneNum();
|
|
|
+ Integer doneNum = importTaskAMVO.getDoneNum();
|
|
|
//十进制转二进制
|
|
|
String imContents = MathUtils.fun(2, importContent);
|
|
|
//下载字段
|
|
|
char[] importCells = imContents.toCharArray();
|
|
|
- Calculate calculate = DateUtils.calculateFromStartAndEndNumber(doneNum, importTaskAMVO.getAllNum(),50);
|
|
|
+ Calculate calculate = DateUtils.calculateFromStartAndEndNumber(doneNum, importTaskAMVO.getAllNum(), 50);
|
|
|
Integer startPage = calculate.getStartPage();
|
|
|
Integer startNum = calculate.getStartNum();
|
|
|
Integer endPage = calculate.getEndPage();
|
|
|
|
|
|
|
|
|
- //根据计算出的起止页数,一页一页检索
|
|
|
- for (int i = startPage; i <= endPage; i++) {
|
|
|
- PatentStarListDTO patentStarListDto = new PatentStarListDTO()
|
|
|
- .setCurrentQuery(conditions)
|
|
|
- .setOrderBy(orderBy)
|
|
|
- .setOrderByType(orderByType)
|
|
|
- .setPageNum(i)
|
|
|
- .setRowCount(50)
|
|
|
- .setDBType(dbType);
|
|
|
- //调用一般接口返回一批专利著录相关数据
|
|
|
- Map<String, Object> resultMap = patentStarApiService.patentStarSearchApi(patentStarListDto);
|
|
|
- if (resultMap == null || (Integer) resultMap.get("total") == 0) {
|
|
|
- ThrowException.throwXiaoShiException("未检索到相关专利");
|
|
|
- }
|
|
|
-
|
|
|
- List<StarPatentVO> starPatents = (List<StarPatentVO>) resultMap.get("records");
|
|
|
- //遍历这一页的专利
|
|
|
- for (int j = 0; j < starPatents.size(); j++) {
|
|
|
-
|
|
|
+ //根据计算出的起止页数,一页一页检索
|
|
|
+ for (int i = startPage; i <= endPage; i++) {
|
|
|
+ PatentStarListDTO patentStarListDto = new PatentStarListDTO()
|
|
|
+ .setCurrentQuery(conditions)
|
|
|
+ .setOrderBy(orderBy)
|
|
|
+ .setOrderByType(orderByType)
|
|
|
+ .setPageNum(i)
|
|
|
+ .setRowCount(50)
|
|
|
+ .setDBType(dbType);
|
|
|
+ //调用一般接口返回一批专利著录相关数据
|
|
|
+ Map<String, Object> resultMap = patentStarApiService.patentStarSearchApi(patentStarListDto);
|
|
|
+ if (resultMap == null || (Integer) resultMap.get("total") == 0) {
|
|
|
+ ThrowException.throwXiaoShiException("未检索到相关专利");
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
+ List<StarPatentVO> starPatents = (List<StarPatentVO>) resultMap.get("records");
|
|
|
+ //遍历这一页的专利
|
|
|
+ for (int j = 0; j < starPatents.size(); j++) {
|
|
|
+ UploadPatentWebDTO uploadPatentWebDTO = new UploadPatentWebDTO();
|
|
|
+ uploadPatentWebDTO.setStarPatentVO(starPatents.get(0));
|
|
|
+ Patent patent = new Patent();
|
|
|
+ uploadPatentWebDTO.setPatent(patent);
|
|
|
+ uploadPatentWebDTO.setCounter(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ }
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|