|
@@ -3,6 +3,7 @@ package cn.cslg.pas.service.business;
|
|
|
import cn.cslg.pas.common.dto.ExportTaskDTO;
|
|
|
import cn.cslg.pas.common.dto.ImportTaskDTO;
|
|
|
import cn.cslg.pas.common.dto.PatentStarListDTO;
|
|
|
+import cn.cslg.pas.common.importTask.QuartzConditionDTO;
|
|
|
import cn.cslg.pas.common.model.cronModel.Personnel;
|
|
|
import cn.cslg.pas.common.model.cronModel.PersonnelVO;
|
|
|
import cn.cslg.pas.common.model.cronModel.Records;
|
|
@@ -12,6 +13,7 @@ import cn.cslg.pas.common.model.request.GroupRequest;
|
|
|
import cn.cslg.pas.common.model.request.QueryRequest;
|
|
|
import cn.cslg.pas.common.utils.*;
|
|
|
import cn.cslg.pas.common.vo.ImportTaskAMVO;
|
|
|
+import cn.cslg.pas.common.vo.StarPatentVO;
|
|
|
import cn.cslg.pas.common.vo.business.ImportTaskVO;
|
|
|
import cn.cslg.pas.domain.business.*;
|
|
|
import cn.cslg.pas.exception.UnLoginException;
|
|
@@ -30,6 +32,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.apache.commons.compress.utils.IOUtils;
|
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
+import org.joda.time.DateTime;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -37,10 +41,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.*;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* 导入任务表业务层
|
|
@@ -88,7 +89,6 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
|
|
|
List<ImportTaskVO> importTaskVOS = importTaskMapper.getImportTask(sqls.get(0), sqls.get(1), sqls.get(2));
|
|
|
//查询总数
|
|
|
Long total = importTaskMapper.getImportTaskCount(sqls.get(0));
|
|
|
-
|
|
|
//装载事件信息
|
|
|
this.loadImportTask(importTaskVOS);
|
|
|
Records records = new Records();
|
|
@@ -122,22 +122,35 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Object addMessage(Object object) {
|
|
|
+
|
|
|
if (object == null) {
|
|
|
throw new XiaoShiException("参数不能为空");
|
|
|
}
|
|
|
+
|
|
|
//TODO 校验参数
|
|
|
ImportTaskDTO importTaskDTO = (ImportTaskDTO) object;
|
|
|
-
|
|
|
+ Boolean ifUpdate = importTaskDTO.getIfUpdate();
|
|
|
PersonnelVO personnelVO = new PersonnelVO();
|
|
|
-
|
|
|
- personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
|
|
|
-
|
|
|
+ personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
|
|
|
|
|
|
if (importTaskDTO.getType() == null) {
|
|
|
importTaskDTO.setType(4);
|
|
|
}
|
|
|
List<String> addPatentNos = importTaskDTO.getPatentNos();
|
|
|
- ImportTaskCondition importTaskCondition = new ImportTaskCondition();
|
|
|
+
|
|
|
+ if (!importTaskDTO.getType().equals(1)) {
|
|
|
+ importTaskDTO.setImportContent(MathUtils.BinaryToDecimal(importTaskDTO.getImportContent()));
|
|
|
+ }
|
|
|
+ ImportTaskCondition importTaskCondition = null;
|
|
|
+
|
|
|
+ if (ifUpdate != null && ifUpdate) {
|
|
|
+ QuartzConditionDTO quartzConditionDTO = new QuartzConditionDTO();
|
|
|
+ BeanUtils.copyProperties(importTaskDTO, quartzConditionDTO);
|
|
|
+ importTaskCondition = importTaskConditionService.addQuartzCondition(quartzConditionDTO);
|
|
|
+ } else {
|
|
|
+ importTaskCondition = importTaskConditionService.addQuartzCondition(importTaskDTO);
|
|
|
+ }
|
|
|
+
|
|
|
if (importTaskDTO.getImportToId() != null) {
|
|
|
if (importTaskDTO.getImportToType().equals(0)) {
|
|
|
importTaskCondition.setProjectType(0);
|
|
@@ -149,32 +162,6 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
|
|
|
importTaskCondition.setProductId(importTaskDTO.getImportToId());
|
|
|
}
|
|
|
}
|
|
|
- if (!importTaskDTO.getType().equals(1)) {
|
|
|
- importTaskDTO.setImportContent(MathUtils.BinaryToDecimal(importTaskDTO.getImportContent()));
|
|
|
- }
|
|
|
- importTaskCondition.setImportContent(importTaskDTO.getImportContent());
|
|
|
- importTaskCondition.setCrons(importTaskDTO.getCrons());
|
|
|
- importTaskCondition.setIfUpdate(importTaskDTO.getIfUpdate());
|
|
|
- importTaskCondition.setSearchCondition(importTaskDTO.getSearchCondition());
|
|
|
- importTaskCondition.setType(importTaskDTO.getType());
|
|
|
- importTaskCondition.setFileGuid(importTaskDTO.getFileGuid());
|
|
|
- importTaskCondition.setSourceId(importTaskDTO.getSourceId());
|
|
|
- importTaskCondition.setDbType(importTaskDTO.getDBType());
|
|
|
- importTaskCondition.setOrderBy(importTaskDTO.getOrderBy());
|
|
|
- importTaskCondition.setOrderByType(importTaskDTO.getOrderByType());
|
|
|
- importTaskCondition.setCreateId(personnelVO.getId());
|
|
|
-
|
|
|
- if (importTaskDTO.getPatentNos() != null && importTaskDTO.getPatentNos().size() > 0) {
|
|
|
- String jsons = JSONObject.toJSON(importTaskDTO.getPatentNos()).toString();
|
|
|
- importTaskCondition.setPatentNos(jsons);
|
|
|
- }
|
|
|
-
|
|
|
- //保存标引信息
|
|
|
- if (importTaskDTO.getFieldDTOS() != null && importTaskDTO.getFieldDTOS().size() > 0) {
|
|
|
- String fieldJson = JsonUtils.objectToJson(importTaskDTO.getFieldDTOS());
|
|
|
- importTaskCondition.setCustomFields(fieldJson);
|
|
|
- }
|
|
|
- importTaskCondition.insert();
|
|
|
|
|
|
//装载任务
|
|
|
ImportTask importTask = new ImportTask();
|
|
@@ -194,7 +181,7 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
|
|
|
File tempFile = File.createTempFile(systemFile.getFileName() + "temp", suffix);
|
|
|
try (
|
|
|
InputStream inputStream = new ByteArrayInputStream(bytes);
|
|
|
- FileOutputStream outputStream = new FileOutputStream(tempFile)
|
|
|
+ FileOutputStream outputStream = new FileOutputStream(tempFile);
|
|
|
) {
|
|
|
IOUtils.copy(inputStream, outputStream); // 将输入流复制到临时文件
|
|
|
}
|
|
@@ -203,7 +190,7 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
|
|
|
//删除临时文件tempFile
|
|
|
new File(tempFile.getPath()).delete();
|
|
|
} catch (Exception e) {
|
|
|
-// e.printStackTrace();
|
|
|
+ e.printStackTrace();
|
|
|
throw new XiaoShiException(e.getMessage());
|
|
|
}
|
|
|
} else if (importTaskCondition.getType().equals(4)) {
|
|
@@ -216,12 +203,16 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
|
|
|
.setPageNum(1)
|
|
|
.setRowCount(50)
|
|
|
.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 {
|
|
@@ -252,10 +243,8 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
|
|
|
}
|
|
|
Sheet sheet = ReadExcelUtils.readExcel(tempFile);
|
|
|
patentNos = ReadExcelUtils.getPatentNoFromExcel(sheet);
|
|
|
-
|
|
|
} catch (Exception e) {
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
importTask.setAllNum(patentNos.size());
|
|
|
}
|
|
@@ -263,10 +252,8 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
|
|
|
String taskName = this.setImportTaskName(importTaskCondition, personnelVO.getName());
|
|
|
importTask.setName(taskName);
|
|
|
importTask.insert();
|
|
|
-
|
|
|
schedulingTaskService.startTask();
|
|
|
return importTask.getId();
|
|
|
-
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -282,15 +269,15 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
|
|
|
List<String> createIds = new ArrayList<>();
|
|
|
|
|
|
List<Integer> projectIds = new ArrayList<>();
|
|
|
- List<Integer> productIds =new ArrayList<>();
|
|
|
+ List<Integer> productIds = new ArrayList<>();
|
|
|
importTaskVOS.forEach(item -> {
|
|
|
if (item.getCreateId() != null) {
|
|
|
createIds.add(item.getCreateId());
|
|
|
}
|
|
|
- if(item.getProductId()!=null){
|
|
|
+ if (item.getProductId() != null) {
|
|
|
productIds.add(item.getProductId());
|
|
|
}
|
|
|
- if(item.getProjectId()!=null){
|
|
|
+ if (item.getProjectId() != null) {
|
|
|
projectIds.add(item.getProjectId());
|
|
|
}
|
|
|
});
|
|
@@ -306,16 +293,16 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
|
|
|
|
|
|
//查询项目名称
|
|
|
if (projectIds.size() != 0) {
|
|
|
- LambdaQueryWrapper<Project> queryWrapper =new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.in(Project::getId,projectIds);
|
|
|
- projects =projectService.list(queryWrapper);
|
|
|
+ LambdaQueryWrapper<Project> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.in(Project::getId, projectIds);
|
|
|
+ projects = projectService.list(queryWrapper);
|
|
|
}
|
|
|
|
|
|
//查询产品名称
|
|
|
if (productIds.size() != 0) {
|
|
|
- LambdaQueryWrapper<Product> queryWrapper =new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.in(Product::getId,productIds);
|
|
|
- products =productService.list(queryWrapper);
|
|
|
+ LambdaQueryWrapper<Product> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.in(Product::getId, productIds);
|
|
|
+ products = productService.list(queryWrapper);
|
|
|
}
|
|
|
|
|
|
LambdaQueryWrapper<SystemDict> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
@@ -352,28 +339,23 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
|
|
|
long percentage = (long) Math.floor((importTaskVO.getDoneNum() + 0D) / importTaskVO.getAllNum() * 100D);
|
|
|
importTaskVO.setPercentage(percentage);
|
|
|
|
|
|
-
|
|
|
//装载目标名称
|
|
|
- if(projects.size()>0&&importTaskVO.getProjectId()!=null){
|
|
|
- Project project =projects.stream().filter(item->item.getId().equals(importTaskVO.getProjectId())).findFirst().orElse(null);
|
|
|
- if(project!=null){
|
|
|
- importTaskVO.setImportToId(project.getId());
|
|
|
- importTaskVO.setImportToType(project.getType()-1);
|
|
|
- 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);
|
|
|
- if(product!=null){
|
|
|
- importTaskVO.setImportToId(product.getId());
|
|
|
- importTaskVO.setImportToType(2);
|
|
|
- importTaskVO.setImportToName(product.getName());
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
+ if (projects.size() > 0 && importTaskVO.getProjectId() != null) {
|
|
|
+ Project project = projects.stream().filter(item -> item.getId().equals(importTaskVO.getProjectId())).findFirst().orElse(null);
|
|
|
+ if (project != null) {
|
|
|
+ importTaskVO.setImportToId(project.getId());
|
|
|
+ importTaskVO.setImportToType(project.getType() - 1);
|
|
|
+ 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);
|
|
|
+ if (product != null) {
|
|
|
+ importTaskVO.setImportToId(product.getId());
|
|
|
+ importTaskVO.setImportToType(2);
|
|
|
+ importTaskVO.setImportToName(product.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|
|
@@ -435,6 +417,7 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
public Integer addExportTask(ExportTaskDTO exportTaskDTO) {
|
|
|
if (exportTaskDTO == null) {
|
|
|
throw new XiaoShiException("入参不能为空");
|
|
@@ -529,24 +512,70 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
- public Integer addPdfTask(AddImportPDFTaskDTO addImportPDFTaskDTO){
|
|
|
- String fileGuid =addImportPDFTaskDTO.getFileGuid();
|
|
|
- Integer pdfType =addImportPDFTaskDTO.getPdfType();
|
|
|
- String remark =addImportPDFTaskDTO.getRemark();
|
|
|
- ImportTaskCondition importTaskCondition =new ImportTaskCondition();
|
|
|
+ public Integer addPdfTask(AddImportPDFTaskDTO addImportPDFTaskDTO) {
|
|
|
+ String fileGuid = addImportPDFTaskDTO.getFileGuid();
|
|
|
+ Integer pdfType = addImportPDFTaskDTO.getPdfType();
|
|
|
+ String remark = addImportPDFTaskDTO.getRemark();
|
|
|
+ ImportTaskCondition importTaskCondition = new ImportTaskCondition();
|
|
|
importTaskCondition.setFileGuid(fileGuid);
|
|
|
importTaskCondition.setType(5);
|
|
|
importTaskCondition.setPdfType(pdfType);
|
|
|
importTaskCondition.setCreateId("1");
|
|
|
importTaskCondition.insert();
|
|
|
- ImportTask importTask =new ImportTask();
|
|
|
+ ImportTask importTask = new ImportTask();
|
|
|
importTask.setImportTaskConditionId(importTaskCondition.getId());
|
|
|
- importTask.setRemark(remark);
|
|
|
- importTask.setCreateId("1");
|
|
|
- importTask.setType(5);
|
|
|
- importTask.insert();
|
|
|
+ importTask.setRemark(remark);
|
|
|
+ importTask.setCreateId("1");
|
|
|
+ importTask.setType(5);
|
|
|
+ importTask.insert();
|
|
|
schedulingTaskService.startTask();
|
|
|
- return importTask.getId();
|
|
|
+ return importTask.getId();
|
|
|
+ }
|
|
|
+ public void addImportTaskByCondition(ImportTaskCondition importTaskCondition){
|
|
|
+ //根据id查询最近更新的任务
|
|
|
+ LambdaQueryWrapper<ImportTask> queryWrapper =new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(ImportTask::getImportTaskConditionId,importTaskCondition.getId())
|
|
|
+ .orderByDesc(ImportTask::getUpdateToDate);
|
|
|
+ ImportTask lastImportTask =this.getOne(queryWrapper);
|
|
|
+
|
|
|
+ String condition =importTaskCondition.getSearchCondition();
|
|
|
+ if(lastImportTask !=null&&lastImportTask.getUpdateToDate()!=null)
|
|
|
+ {
|
|
|
+ String dateStr= DateUtils2.dateTimeToPatentStr(lastImportTask.getUpdateToDate());
|
|
|
+ condition =condition+"and PD="+dateStr;
|
|
|
+ }
|
|
|
+ PatentStarListDTO patentStarListDto = new PatentStarListDTO()
|
|
|
+ .setCurrentQuery(condition )
|
|
|
+ .setPageNum(1)
|
|
|
+ .setRowCount(10)
|
|
|
+ .setDBType(importTaskCondition.getDbType());
|
|
|
+ //调用一般接口返回一批专利著录相关数据
|
|
|
+ ImportTask importTask = new ImportTask();
|
|
|
+ try {
|
|
|
+ Map<String, Object> resultMap = patentStarApiService.patentStarSearchApi(patentStarListDto);
|
|
|
+ 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){
|
|
|
+ e.printStackTrace();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ importTask.setImportTaskConditionId(importTaskCondition.getId());
|
|
|
+ importTask.setType(importTaskCondition.getType());
|
|
|
+ importTask.setSearchCondition(condition);
|
|
|
+ importTask.setCreateId(importTaskCondition.getCreateId());
|
|
|
+ importTask.insert();
|
|
|
+
|
|
|
}
|
|
|
}
|