Commit e475d341 by fudahua

feat: 新版本的下载

parent 4c3e5a68
......@@ -47,7 +47,7 @@ public class HDFSUtil {
*/
public boolean downloadFile(String srcPath,String toPath) {
try {
fileSystem.copyToLocalFile(true,new Path(srcPath),new Path(toPath));
fileSystem.copyToLocalFile(false,new Path(srcPath),new Path(toPath));
return true;
} catch (IOException e) {
logger.info("下载失败:{}",e);
......
......@@ -68,7 +68,8 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
private static LogPak log = new LogPak(FlatQueryResultServiceImpl.class);
/** csv / xls 下载目录 */
public static final String SAVE_FOLDER = "/usr/local/data-hook-file";
// public static final String SAVE_FOLDER = "/usr/local/data-hook-file";
public static final String SAVE_FOLDER = "D:\\testorder";
public static final String HDFS_URL = "/data/hook";
......@@ -106,7 +107,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
private FlatQueryResultServiceImpl() {
log.debug("construct", "准备初始化 FlatQuery 查询服务");
runDealHiveFile(3);
// runDealHiveFile(3);
// runDistTask(3);
runDownloadTask(3);
runBalaDownloadTask(3);
......@@ -879,7 +880,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
currentFile.set(xlsxFileInfo);
xlsxFiles.add(currentFile.get().filepath);
}
count.incrementAndGet();
saveXlsSplitNew(currentFile.get().filepath,cells,titles,currentFile.get(),count,false);
});
//结束
......@@ -951,10 +952,10 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
}
}
if (first) {
first=false;
continue;
}
func.deal(cells,titles,first);
first=false;
}while ((cells = csvReader.readNext())!=null);
......@@ -1215,8 +1216,8 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
}
}
Integer limitSize = FileUtil.getLimitSize();
int c = count.incrementAndGet();
if (c>=limitSize||endFlag) {
int c = count.get();
if (c>limitSize||endFlag) {
FileOutputStream fileOut = new FileOutputStream(originalFilePath);
wb.write(fileOut);
//fileOut.flush(); // SXSSFWorkbook 使用 auto-flush 模式
......
......@@ -30,7 +30,8 @@
q.apply_status,
q.real_sql,
q.enterprise_id,
q.report_id
q.report_id,
q.download_condition
</sql>
......
import com.gic.cloud.data.hook.api.dto.DownloadTask;
import com.gic.cloud.data.hook.service.impl.DownloadTaskServiceImpl;
import com.gic.cloud.data.hook.service.impl.FlatQueryResultServiceImpl;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -11,8 +13,17 @@ public class Test {
@Autowired
private FlatQueryResultServiceImpl flatQueryResultService;
@Autowired
private DownloadTaskServiceImpl downloadTaskService;
@org.junit.Test
public void test(){
flatQueryResultService.runDealHiveFile(3);
DownloadTask downloadTask = downloadTaskService.getDownloadTaskById("1680778799753");
flatQueryResultService.takeFileNew(downloadTask);
try {
Thread.sleep(10000000000L);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
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