|
@@ -6,6 +6,7 @@ import cn.cslg.pas.common.utils.FileUtils;
|
|
|
import cn.cslg.pas.common.utils.ReadExcelUtils;
|
|
|
import cn.cslg.pas.service.TaskService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import org.apache.poi.ss.formula.functions.T;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -13,6 +14,10 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
+/**
|
|
|
+ * @Author 李仁杰
|
|
|
+ * 导入任务类
|
|
|
+ */
|
|
|
@Service
|
|
|
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
|
|
|
public class UploadTaskService {
|
|
@@ -21,49 +26,21 @@ public class UploadTaskService {
|
|
|
private final TaskService taskService;
|
|
|
private final ReadExcelUtils readExcelUtils;
|
|
|
|
|
|
- public Integer upLoadPatent(MultipartFile file) throws InterruptedException, IOException {
|
|
|
- //1.检查文档合法性
|
|
|
- UploadFileDTO fileDTO = fileUtils.uploadFile(file);
|
|
|
- //获得文件路径
|
|
|
- String filePath = fileUtils.getPath(fileDTO.getPath());
|
|
|
- Integer total = ReadExcelUtils.textExcel(filePath);
|
|
|
- if (total <= 0) {
|
|
|
- return -1;
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 添加导入任务
|
|
|
+ */
|
|
|
+ public void addTask(){
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- //2.解析文档
|
|
|
- //4.建立任务
|
|
|
- Integer projectId = null;
|
|
|
-// Integer taskId = taskService.add(fileDTO, projectId, null, total- 1, 1, 0, file.getOriginalFilename());
|
|
|
- ThreadSafeQueue<UploadParamsVO> threadSafeQueue = new ThreadSafeQueue<>(8);
|
|
|
- for (int i = 0; i < total; i++) {
|
|
|
|
|
|
- //3.装载实体类
|
|
|
- UploadParamsVO uploadParamsVO = new UploadParamsVO();
|
|
|
- uploadParamsVO.setFirstAddress(i + "");
|
|
|
- //5.上传到库
|
|
|
- Thread thread1 = new Thread(() -> {
|
|
|
- try {
|
|
|
- threadSafeQueue.enqueue(uploadParamsVO);
|
|
|
- } catch (InterruptedException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- });
|
|
|
- thread1.start();
|
|
|
- Thread thread2 = new Thread(() -> {
|
|
|
- try {
|
|
|
- threadSafeQueue.dequeue();
|
|
|
- } catch (InterruptedException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- });
|
|
|
- thread2.start();
|
|
|
- }
|
|
|
- return 1;
|
|
|
- }
|
|
|
|
|
|
|
|
|
- public static void main(String[] args) throws InterruptedException {
|
|
|
-// UploadTaskService.upLoadPatent();
|
|
|
}
|
|
|
+
|
|
|
+ public void pauseTask(){}
|
|
|
+
|
|
|
+ public void deleteTask(){}
|
|
|
+
|
|
|
+
|
|
|
}
|