Commit e475d341 by fudahua

feat: 新版本的下载

parent 4c3e5a68
...@@ -47,7 +47,7 @@ public class HDFSUtil { ...@@ -47,7 +47,7 @@ public class HDFSUtil {
*/ */
public boolean downloadFile(String srcPath,String toPath) { public boolean downloadFile(String srcPath,String toPath) {
try { try {
fileSystem.copyToLocalFile(true,new Path(srcPath),new Path(toPath)); fileSystem.copyToLocalFile(false,new Path(srcPath),new Path(toPath));
return true; return true;
} catch (IOException e) { } catch (IOException e) {
logger.info("下载失败:{}",e); logger.info("下载失败:{}",e);
......
...@@ -68,7 +68,8 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService { ...@@ -68,7 +68,8 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
private static LogPak log = new LogPak(FlatQueryResultServiceImpl.class); private static LogPak log = new LogPak(FlatQueryResultServiceImpl.class);
/** csv / xls 下载目录 */ /** 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"; public static final String HDFS_URL = "/data/hook";
...@@ -106,7 +107,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService { ...@@ -106,7 +107,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);
...@@ -879,7 +880,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService { ...@@ -879,7 +880,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
currentFile.set(xlsxFileInfo); currentFile.set(xlsxFileInfo);
xlsxFiles.add(currentFile.get().filepath); xlsxFiles.add(currentFile.get().filepath);
} }
count.incrementAndGet();
saveXlsSplitNew(currentFile.get().filepath,cells,titles,currentFile.get(),count,false); saveXlsSplitNew(currentFile.get().filepath,cells,titles,currentFile.get(),count,false);
}); });
//结束 //结束
...@@ -951,10 +952,10 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService { ...@@ -951,10 +952,10 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
} }
} }
if (first) { if (first) {
first=false;
continue; continue;
} }
func.deal(cells,titles,first); func.deal(cells,titles,first);
first=false;
}while ((cells = csvReader.readNext())!=null); }while ((cells = csvReader.readNext())!=null);
...@@ -1215,8 +1216,8 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService { ...@@ -1215,8 +1216,8 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
} }
} }
Integer limitSize = FileUtil.getLimitSize(); Integer limitSize = FileUtil.getLimitSize();
int c = count.incrementAndGet(); int c = count.get();
if (c>=limitSize||endFlag) { if (c>limitSize||endFlag) {
FileOutputStream fileOut = new FileOutputStream(originalFilePath); FileOutputStream fileOut = new FileOutputStream(originalFilePath);
wb.write(fileOut); wb.write(fileOut);
//fileOut.flush(); // SXSSFWorkbook 使用 auto-flush 模式 //fileOut.flush(); // SXSSFWorkbook 使用 auto-flush 模式
......
...@@ -30,7 +30,8 @@ ...@@ -30,7 +30,8 @@
q.apply_status, q.apply_status,
q.real_sql, q.real_sql,
q.enterprise_id, q.enterprise_id,
q.report_id q.report_id,
q.download_condition
</sql> </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 com.gic.cloud.data.hook.service.impl.FlatQueryResultServiceImpl;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -11,8 +13,17 @@ public class Test { ...@@ -11,8 +13,17 @@ public class Test {
@Autowired @Autowired
private FlatQueryResultServiceImpl flatQueryResultService; private FlatQueryResultServiceImpl flatQueryResultService;
@Autowired
private DownloadTaskServiceImpl downloadTaskService;
@org.junit.Test @org.junit.Test
public void 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