|
@@ -42,6 +42,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.*;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 导入任务表业务层
|
|
@@ -147,11 +148,8 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
|
|
|
if (ifUpdate != null && ifUpdate) {
|
|
|
QuartzConditionDTO quartzConditionDTO = new QuartzConditionDTO();
|
|
|
BeanUtils.copyProperties(importTaskDTO, quartzConditionDTO);
|
|
|
-
|
|
|
importTaskCondition = importTaskConditionService.addQuartzCondition(quartzConditionDTO);
|
|
|
} else {
|
|
|
-
|
|
|
-
|
|
|
importTaskCondition = importTaskConditionService.addQuartzCondition(importTaskDTO);
|
|
|
}
|
|
|
|
|
@@ -194,18 +192,13 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
|
|
|
.setOrderBy(importTaskCondition.getOrderBy())
|
|
|
.setOrderByType(importTaskCondition.getOrderByType())
|
|
|
.setPageNum(1)
|
|
|
- .setRowCount(50)
|
|
|
+ .setRowCount(10)
|
|
|
.setDBType(importTaskCondition.getDbType());
|
|
|
//调用一般接口返回一批专利著录相关数据
|
|
|
Map<String, Object> resultMap = patentStarApiService.patentStarSearchApi(patentStarListDto);
|
|
|
if (resultMap == null || (Integer) resultMap.get("total") == 0) {
|
|
|
ThrowException.throwXiaoShiException("未检索到相关专利");
|
|
|
} else {
|
|
|
- List<StarPatentVO> starPatentVOS = (List<StarPatentVO>) resultMap.get("records");
|
|
|
- StarPatentVO starPatentVO = starPatentVOS.get(0);
|
|
|
- String pDStr = starPatentVO.getPD();
|
|
|
- Date publicDate = DateUtils2.formStrToDate(pDStr);
|
|
|
- importTask.setUpdateToDate(publicDate);
|
|
|
importTask.setAllNum((Integer) resultMap.get("total"));
|
|
|
}
|
|
|
} else {
|
|
@@ -263,6 +256,7 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
|
|
|
|
|
|
List<Integer> projectIds = new ArrayList<>();
|
|
|
List<Integer> productIds = new ArrayList<>();
|
|
|
+ List<String> guids = new ArrayList<>();
|
|
|
importTaskVOS.forEach(item -> {
|
|
|
if (item.getCreateId() != null) {
|
|
|
createIds.add(item.getCreateId());
|
|
@@ -273,10 +267,15 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
|
|
|
if (item.getProjectId() != null) {
|
|
|
projectIds.add(item.getProjectId());
|
|
|
}
|
|
|
+ if (item.getFileGuid() != null) {
|
|
|
+ guids.add(item.getFileGuid());
|
|
|
+ }
|
|
|
});
|
|
|
List<Personnel> personnels = new ArrayList<>();
|
|
|
List<Product> products = new ArrayList<>();
|
|
|
List<Project> projects = new ArrayList<>();
|
|
|
+ List<SystemFile> systemFiles = new ArrayList<>();
|
|
|
+
|
|
|
//查询创建人名称
|
|
|
if (createIds.size() != 0) {
|
|
|
String res = permissionService.getPersonnelByIdsFromPCS(createIds);
|
|
@@ -298,6 +297,15 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
|
|
|
products = productService.list(queryWrapper);
|
|
|
}
|
|
|
|
|
|
+ //查询文件
|
|
|
+ if (guids.size() != 0) {
|
|
|
+ String res = fileManagerService.getSystemFileFromFMS(guids);
|
|
|
+ systemFiles = JSONObject.parseArray(res, SystemFile.class);
|
|
|
+ if (systemFiles == null) {
|
|
|
+ systemFiles = new ArrayList<>();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
LambdaQueryWrapper<SystemDict> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
lambdaQueryWrapper.eq(SystemDict::getGroupType, "IMPORT_TASK");
|
|
|
List<SystemDict> systemDictList = systemDictService.list(lambdaQueryWrapper);
|
|
@@ -307,12 +315,10 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
|
|
|
if (personnel != null) {
|
|
|
importTaskVO.setCreateName(personnel.getPersonnelName());
|
|
|
}
|
|
|
-
|
|
|
//装载状态
|
|
|
SystemDict systemDict1 = systemDictList.stream()
|
|
|
.filter(item -> item.getType().equals("IMPORT_TASK_TYPE") && item.getType()
|
|
|
.equals(importTaskVO.getType().toString())).findFirst().orElse(null);
|
|
|
-
|
|
|
SystemDict systemDict2 = systemDictList.stream()
|
|
|
.filter(item -> item.getType().equals("IMPORT_TASk_STATE") && item.getType()
|
|
|
.equals(importTaskVO.getState().toString())).findFirst().orElse(null);
|
|
@@ -338,7 +344,11 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
|
|
|
if (project != null) {
|
|
|
importTaskVO.setImportToId(project.getId());
|
|
|
importTaskVO.setImportToType(project.getType() - 1);
|
|
|
- importTaskVO.setImportToName(project.getName());
|
|
|
+ if (project.getType().equals(1)) {
|
|
|
+ importTaskVO.setImportToName(project.getName() + "-专利数据库");
|
|
|
+ } else {
|
|
|
+ importTaskVO.setImportToName(project.getName() + "-报告");
|
|
|
+ }
|
|
|
}
|
|
|
} else if (products.size() > 0 && importTaskVO.getProductId() != null) {
|
|
|
Product product = products.stream().filter(item -> item.getId().equals(importTaskVO.getProductId())).findFirst().orElse(null);
|
|
@@ -348,6 +358,16 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
|
|
|
importTaskVO.setImportToName(product.getName());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if (importTaskVO.getFileGuid() != null) {
|
|
|
+ SystemFile systemFile = systemFiles.stream().filter(item -> item.getGuid().equals(importTaskVO.getFileGuid())).findFirst().orElse(null);
|
|
|
+ importTaskVO.setSystemFile(systemFile);
|
|
|
+ }
|
|
|
+ if(importTaskVO.getImportContent()!=null){
|
|
|
+ String icn=this.getImportContentStr(importTaskVO.getImportContent(),importTaskVO.getType());
|
|
|
+ importTaskVO.setImportContentName(icn);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -527,11 +547,23 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
|
|
|
LambdaQueryWrapper<ImportTask> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
queryWrapper.eq(ImportTask::getImportTaskConditionId, importTaskCondition.getId())
|
|
|
.orderByDesc(ImportTask::getUpdateToDate);
|
|
|
- ImportTask lastImportTask = this.getOne(queryWrapper);
|
|
|
+ ImportTask lastImportTask = this.getOne(queryWrapper, false);
|
|
|
String condition = importTaskCondition.getSearchCondition();
|
|
|
- if (lastImportTask != null && lastImportTask.getUpdateToDate() != null) {
|
|
|
- String dateStr = DateUtils2.dateTimeToPatentStr(lastImportTask.getUpdateToDate());
|
|
|
- condition = condition + "and PD>" + dateStr;
|
|
|
+ Date date = new Date();
|
|
|
+ Date toDate = DateUtils.getDate(date, -7);
|
|
|
+ if (lastImportTask == null) {
|
|
|
+ String toDateStr = DateUtils2.dateTimeToPatentStr(toDate);
|
|
|
+ condition = condition + " and PD<" + toDateStr;
|
|
|
+ } else if (lastImportTask != null && lastImportTask.getUpdateToDate() != null) {
|
|
|
+ Date fromDate = DateUtils.getDate(lastImportTask.getUpdateToDate(), 1);
|
|
|
+ String fromDateStr = DateUtils2.dateTimeToPatentStr(fromDate);
|
|
|
+ String todateStr = DateUtils2.dateTimeToPatentStr(toDate);
|
|
|
+ condition = condition + " and (PD=" + fromDateStr + "~" + todateStr + " or GD=" + fromDateStr + "~" + todateStr + ")";
|
|
|
+ } else if (lastImportTask != null && lastImportTask.getUpdateToDate() == null) {
|
|
|
+ Date fromDate = DateUtils.getDate(lastImportTask.getCreateTime(), -7);
|
|
|
+ String fromDateStr = DateUtils2.dateTimeToPatentStr(fromDate);
|
|
|
+ String todateStr = DateUtils2.dateTimeToPatentStr(toDate);
|
|
|
+ condition = condition + " and (PD=" + fromDateStr + "~" + todateStr + " or GD=" + fromDateStr + "~" + todateStr + ")";
|
|
|
}
|
|
|
PatentStarListDTO patentStarListDto = new PatentStarListDTO()
|
|
|
.setCurrentQuery(condition)
|
|
@@ -545,11 +577,6 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
|
|
|
if (resultMap == null || (Integer) resultMap.get("total") == 0) {
|
|
|
return;
|
|
|
} else {
|
|
|
- List<StarPatentVO> starPatentVOS = (List<StarPatentVO>) resultMap.get("records");
|
|
|
- StarPatentVO starPatentVO = starPatentVOS.get(0);
|
|
|
- String pDStr = starPatentVO.getPD();
|
|
|
- Date publicDate = DateUtils2.formStrToDate(pDStr);
|
|
|
- importTask.setUpdateToDate(publicDate);
|
|
|
importTask.setAllNum((Integer) resultMap.get("total"));
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
@@ -561,10 +588,48 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
|
|
|
importTask.setType(importTaskCondition.getType());
|
|
|
importTask.setSearchCondition(condition);
|
|
|
importTask.setCreateId(importTaskCondition.getCreateId());
|
|
|
- Date date = new Date();
|
|
|
- Date toDate = DateUtils.getDate(date, -7);
|
|
|
importTask.setUpdateToDate(toDate);
|
|
|
importTask.insert();
|
|
|
+ schedulingTaskService.startTask();
|
|
|
+ }
|
|
|
|
|
|
+ public String getImportContentStr(Integer importContent, Integer taskType) {
|
|
|
+ List<String> contents = new ArrayList<>();
|
|
|
+ String imContents = "0000";
|
|
|
+ //当任务为excel导入
|
|
|
+ if (taskType.equals(1)) {
|
|
|
+ imContents = "1100";
|
|
|
+ }
|
|
|
+ //当任务为pdf导入
|
|
|
+ else if (taskType.equals(5)) {
|
|
|
+ imContents = "0001";
|
|
|
+ } else if (!importContent.equals(0)) {
|
|
|
+ imContents = MathUtils.fun(2, importContent);
|
|
|
+ }
|
|
|
+ //下载字段
|
|
|
+ char[] importCells = imContents.toCharArray();
|
|
|
+ char ifCataloguing = importCells[0];
|
|
|
+ char ifAddPicture = importCells[1];
|
|
|
+ char ifFullText = importCells[2];
|
|
|
+ char ifPdf = importCells[3];
|
|
|
+ if (ifCataloguing == '1') {
|
|
|
+ contents.add("著录信息");
|
|
|
+ }
|
|
|
+ if (ifAddPicture == '1') {
|
|
|
+ contents.add("摘要附图");
|
|
|
+
|
|
|
+ }
|
|
|
+ if (ifFullText == '1') {
|
|
|
+ contents.add("权要或说明书");
|
|
|
+
|
|
|
+ }
|
|
|
+ if (ifPdf == '1') {
|
|
|
+ contents.add("pdf或外观附图");
|
|
|
+ }
|
|
|
+ String contentStr = "";
|
|
|
+ if (contents.size() > 0) {
|
|
|
+ contentStr = StringUtils.join(contents, " ");
|
|
|
+ }
|
|
|
+ return contentStr;
|
|
|
}
|
|
|
}
|