|
|
@ -1,21 +1,24 @@
|
|
|
|
package com.baiye.task;
|
|
|
|
package com.baiye.task;
|
|
|
|
|
|
|
|
|
|
|
|
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.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;
|
|
|
|
|
|
|
|
import com.baiye.module.entity.Task;
|
|
|
|
import com.baiye.module.entity.vo.BaseExcelVo;
|
|
|
|
import com.baiye.module.entity.vo.BaseExcelVo;
|
|
|
|
import com.baiye.module.entity.vo.KsVo;
|
|
|
|
import com.baiye.module.entity.vo.KsVo;
|
|
|
|
|
|
|
|
import com.baiye.module.entity.vo.TaskZdyVo;
|
|
|
|
import com.baiye.module.entity.vo.ZdyVo;
|
|
|
|
import com.baiye.module.entity.vo.ZdyVo;
|
|
|
|
import com.baiye.module.listener.KsExcelListener;
|
|
|
|
import com.baiye.module.listener.KsExcelListener;
|
|
|
|
|
|
|
|
import com.baiye.module.listener.TaskZdyExcelListener;
|
|
|
|
import com.baiye.module.listener.UcCsvListener;
|
|
|
|
import com.baiye.module.listener.UcCsvListener;
|
|
|
|
import com.baiye.module.listener.ZdyExcelListener;
|
|
|
|
import com.baiye.module.listener.ZdyExcelListener;
|
|
|
|
import com.baiye.module.service.ClueService;
|
|
|
|
import com.baiye.module.service.ClueService;
|
|
|
|
import com.baiye.util.RequestHeaderHandler;
|
|
|
|
|
|
|
|
import lombok.SneakyThrows;
|
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
@ -35,26 +38,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());
|
|
|
@ -77,10 +79,30 @@ public class FileAnalysisTask {
|
|
|
|
log.info("==============开始导入快手表单============{}", Thread.currentThread().getName());
|
|
|
|
log.info("==============开始导入快手表单============{}", Thread.currentThread().getName());
|
|
|
|
EasyExcelFactory.read(file, KsVo.class, new KsExcelListener(clueService, baseExcelVo)).build().readAll();
|
|
|
|
EasyExcelFactory.read(file, KsVo.class, new KsExcelListener(clueService, baseExcelVo)).build().readAll();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FileConstant.FIVE_NUMBER:
|
|
|
|
|
|
|
|
log.info("==============开始导入动态任务表单============{}", Thread.currentThread().getName());
|
|
|
|
|
|
|
|
EasyExcelFactory.read(file, TaskZdyVo.class, new TaskZdyExcelListener(clueService, baseExcelVo)).build().readAll();
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
log.info("=========读取资源错误============{}",e);
|
|
|
|
|
|
|
|
taskClient.sendErrMessage("导入资源错误,请检查数据格式后重新导入", clueRecords.get(0).getCreateBy());
|
|
|
|
|
|
|
|
throw new BadRequestException("=========读取资源错误============");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//动态任务不需要创建任务,更新后结束方法
|
|
|
|
|
|
|
|
if (clueRecords.get(0).getUploadType() == FileConstant.FIVE_NUMBER){
|
|
|
|
|
|
|
|
Long taskId = clueRecords.get(0).getTaskId();
|
|
|
|
|
|
|
|
Integer taskNum = clueMiddleRepository.findTaskNum(taskId);
|
|
|
|
|
|
|
|
Task task = new Task();
|
|
|
|
|
|
|
|
task.setId(taskId);
|
|
|
|
|
|
|
|
task.setTotalNumber(taskNum);
|
|
|
|
|
|
|
|
task.setIsDistribution(1);
|
|
|
|
|
|
|
|
taskClient.updateTask(task);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
//创建任务
|
|
|
|
//创建任务
|
|
|
|
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 +114,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)
|
|
|
|