Commit b80e16fe by fudahua

feat: 新版本的下载

parent 08bb27ae
......@@ -105,7 +105,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
private FlatQueryResultServiceImpl() {
log.debug("construct", "准备初始化 FlatQuery 查询服务");
// runDealHiveFile(3);
runDealHiveFile(3);
// runDistTask(3);
runDownloadTask(3);
runBalaDownloadTask(3);
......@@ -864,6 +864,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
//下载文件
String dirName="hdfs"+task.getId();
String path=HDFS_URL+"/"+dirName;
try {
boolean downloadFlag = HDFSUtil.getInstance().downloadFile(path, SAVE_FOLDER);
if (!downloadFlag) {
logger.info("下载失败:{}-{}",path,JSONObject.toJSONString(task));
......@@ -888,7 +889,6 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
//是否压缩
boolean zipFlag = (xlsxFiles.size() > 1) ? true : false;
String cloudFileUrl=null;
try {
String taskFileExt = task.getUseCompress().equals(Global.YES) || zipFlag ? ".zip" : task.getFormat().equals(DownloadFileFormat.CSV) ? ".csv" : ".xlsx";
if (zipFlag || task.getUseCompress().equals(Global.YES)) {
logger.info("[ runDownloadTask.run ]: {}", "准备生成自助指标压缩文件 " + task.getId() + ".zip");
......@@ -908,11 +908,13 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
task.setStatus(DownloadTaskStatus.COMPLISHED);
task.setOverTime(new Date());
task.setFilePath(cloudFileUrl);
DownloadTaskServiceImpl.getInstance().updateDownloadTask(task);
}catch (Exception e) {
logger.info("异常:{}",e);
task.setStatus(DownloadTaskStatus.ERROR);
}finally {
DownloadTaskServiceImpl.getInstance().updateDownloadTask(task);
//删除文件
delFileOrDirByTaskId(task.getId());
}
......@@ -928,7 +930,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
File file = new File(SAVE_FOLDER);
File[] files = file.listFiles();
for (File midFile : files) {
if (midFile.getName().equals(taskId)) {
if (midFile.getName().indexOf(taskId)!=-1) {
if (midFile.isDirectory()) {
delDir(midFile);
}else{
......@@ -986,8 +988,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
}
func.deal(cells,titles,first);
}while ((cells = csvReader.readNext())!=null);
csvReader.close();
} catch (Exception e) {
logger.info("读取异常:{}",e);
}
......
......@@ -18,7 +18,7 @@ public class Test {
@org.junit.Test
public void test(){
DownloadTask downloadTask = downloadTaskService.getDownloadTaskById("1680778799753");
DownloadTask downloadTask = downloadTaskService.getDownloadTaskById("1680832767459");
flatQueryResultService.takeFileNew(downloadTask);
try {
Thread.sleep(10000000000L);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment