Commit 8ff66409 by fudahua

feat: 新版本的下载

parent 58049861
......@@ -67,8 +67,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 = "D:\\testorder";
// 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 +106,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
private FlatQueryResultServiceImpl() {
log.debug("construct", "准备初始化 FlatQuery 查询服务");
runDealHiveFile(3);
// runDealHiveFile(3);
// runDistTask(3);
runDownloadTask(3);
runBalaDownloadTask(3);
......@@ -932,6 +932,8 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
private class XlsxFileInfo{
String filepath;
SXSSFWorkbook workbook;
CellStyle yyyyMMddhhmmss;
CellStyle yyyyMMdd;
}
......@@ -1207,6 +1209,18 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
cell = row.createCell(j);
cell.setCellValue(titles.get(j).getTitle());
}
//日期
CellStyle yyyyMMddhhmmss = xlsxFileInfo.workbook.createCellStyle();
DataFormat dataFormat = xlsxFileInfo.workbook.createDataFormat();
yyyyMMddhhmmss.setDataFormat(dataFormat.getFormat("yyyy-MM-dd HH:mm:ss"));
xlsxFileInfo.yyyyMMddhhmmss=yyyyMMddhhmmss;
//日期
CellStyle yyyyMMdd = xlsxFileInfo.workbook.createCellStyle();
DataFormat yyyyMMddDataFormat = xlsxFileInfo.workbook.createDataFormat();
yyyyMMdd.setDataFormat(yyyyMMddDataFormat.getFormat("yyyy-MM-dd"));
xlsxFileInfo.yyyyMMdd=yyyyMMdd;
count.incrementAndGet();
}
logger.info("{}-count:{}",originalFilePath,count.get());
......@@ -1214,15 +1228,6 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
SXSSFWorkbook wb = xlsxFileInfo.workbook; // 内存中保留 100 行
if (!endFlag) {
Sheet sheet = wb.getSheetAt(0);
//日期
CellStyle yyyyMMddhhmmss = wb.createCellStyle();
DataFormat dataFormat = wb.createDataFormat();
yyyyMMddhhmmss.setDataFormat(dataFormat.getFormat("yyyy-MM-dd HH:mm:ss"));
//日期
CellStyle yyyyMMdd = wb.createCellStyle();
DataFormat yyyyMMddDataFormat = wb.createDataFormat();
yyyyMMdd.setDataFormat(yyyyMMddDataFormat.getFormat("yyyy-MM-dd"));
Row row = sheet.createRow(count.get());
for (int j = 0; j < cells.length; j++) {
......@@ -1236,10 +1241,10 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
switch (type) {
case FlatQueryFieldType.DATE:
if (columnValue.length() == 10) {
midCell.setCellStyle(yyyyMMdd);
midCell.setCellStyle(xlsxFileInfo.yyyyMMdd);
midCell.setCellValue(DateUtils.parseDate(columnValue, new String[]{"yyyy-MM-dd"}));
} else {
midCell.setCellStyle(yyyyMMddhhmmss);
midCell.setCellStyle(xlsxFileInfo.yyyyMMddhhmmss);
midCell.setCellValue(DateUtils.parseDate(columnValue, new String[]{"yyyy-MM-dd HH:mm:ss"}));
}
break;
......
......@@ -18,7 +18,7 @@ public class Test {
@org.junit.Test
public void test(){
DownloadTask downloadTask = downloadTaskService.getDownloadTaskById("1680832767459");
DownloadTask downloadTask = downloadTaskService.getDownloadTaskById("1680836264864");
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