Commit b80e16fe by fudahua

feat: 新版本的下载

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