|
|
@ -1,9 +1,13 @@
|
|
|
|
package com.baiye.task;
|
|
|
|
package com.baiye.task;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
import com.alibaba.excel.EasyExcelFactory;
|
|
|
|
import com.alibaba.excel.EasyExcelFactory;
|
|
|
|
|
|
|
|
import com.baiye.exception.BadRequestException;
|
|
|
|
|
|
|
|
import com.baiye.feign.TaskClient;
|
|
|
|
import com.baiye.module.constant.FileConstant;
|
|
|
|
import com.baiye.module.constant.FileConstant;
|
|
|
|
import com.baiye.module.dao.ClueJpa;
|
|
|
|
import com.baiye.module.dao.ClueJpa;
|
|
|
|
import com.baiye.module.dao.ClueMiddleRepository;
|
|
|
|
import com.baiye.module.dao.ClueMiddleRepository;
|
|
|
|
|
|
|
|
import com.baiye.module.dao.ClueRecordRepository;
|
|
|
|
import com.baiye.module.dao.ClueRepository;
|
|
|
|
import com.baiye.module.dao.ClueRepository;
|
|
|
|
import com.baiye.module.entity.Clue;
|
|
|
|
import com.baiye.module.entity.Clue;
|
|
|
|
import com.baiye.module.entity.ClueRecord;
|
|
|
|
import com.baiye.module.entity.ClueRecord;
|
|
|
@ -24,7 +28,9 @@ import org.springframework.transaction.annotation.Propagation;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
|
|
|
|
import java.io.FileNotFoundException;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
@ -35,26 +41,25 @@ public class FileAnalysisTask {
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private ClueService clueService;
|
|
|
|
private ClueService clueService;
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private ClueJpa clueJpa;
|
|
|
|
private ClueJpa clueJpa;
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private ClueRepository clueRepository;
|
|
|
|
private ClueRepository clueRepository;
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private ClueMiddleRepository clueMiddleRepository;
|
|
|
|
private ClueMiddleRepository clueMiddleRepository;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private TaskClient taskClient;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 读取文件处理数据
|
|
|
|
* 读取文件处理数据
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param clueRecords
|
|
|
|
* @param clueRecords
|
|
|
|
* @param headerMap
|
|
|
|
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
@Async(value = "SendBigDataTaskExecutor")
|
|
|
|
@Async(value = "SendBigDataTaskExecutor")
|
|
|
|
@SneakyThrows //处理异常try
|
|
|
|
//@SneakyThrows
|
|
|
|
public void runFileAnalysisTask(List<ClueRecord> clueRecords, String oneFileName, Map<String, String> headerMap) {
|
|
|
|
public void runFileAnalysisTask(List<ClueRecord> clueRecords, String oneFileName){
|
|
|
|
|
|
|
|
try {
|
|
|
|
for (ClueRecord clueRecord : clueRecords) {
|
|
|
|
for (ClueRecord clueRecord : clueRecords) {
|
|
|
|
BaseExcelVo baseExcelVo = new BaseExcelVo();
|
|
|
|
BaseExcelVo baseExcelVo = new BaseExcelVo();
|
|
|
|
baseExcelVo.setUserId(clueRecord.getCreateBy());
|
|
|
|
baseExcelVo.setUserId(clueRecord.getCreateBy());
|
|
|
@ -81,6 +86,10 @@ public class FileAnalysisTask {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
taskClient.sendErrMessage("导入资源错误,请检查数据格式后重新导入", clueRecords.get(0).getCreateBy());
|
|
|
|
|
|
|
|
throw new BadRequestException("=========读取资源错误============");
|
|
|
|
|
|
|
|
}
|
|
|
|
//创建任务
|
|
|
|
//创建任务
|
|
|
|
Long taskId = clueRecords.get(0).getTaskId();
|
|
|
|
Long taskId = clueRecords.get(0).getTaskId();
|
|
|
|
Long userId = clueRecords.get(0).getCreateBy();
|
|
|
|
Long userId = clueRecords.get(0).getCreateBy();
|
|
|
@ -92,13 +101,13 @@ public class FileAnalysisTask {
|
|
|
|
baseExcelVo.setUserId(userId);
|
|
|
|
baseExcelVo.setUserId(userId);
|
|
|
|
baseExcelVo.setTaskId(taskId);
|
|
|
|
baseExcelVo.setTaskId(taskId);
|
|
|
|
baseExcelVo.setOneFileName(oneFileName);
|
|
|
|
baseExcelVo.setOneFileName(oneFileName);
|
|
|
|
RequestHeaderHandler.setHeaderMap(headerMap);
|
|
|
|
|
|
|
|
clueService.saveTask(baseExcelVo);
|
|
|
|
clueService.saveTask(baseExcelVo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 同一个任务内去重手机号
|
|
|
|
* 同一个任务内去重手机号
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param taskId
|
|
|
|
* @param taskId
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Transactional(propagation = Propagation.REQUIRED)
|
|
|
|
@Transactional(propagation = Propagation.REQUIRED)
|
|
|
|