Commit 8ff66409 by fudahua

feat: 新版本的下载

parent 58049861
...@@ -67,8 +67,8 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService { ...@@ -67,8 +67,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 SAVE_FOLDER = "D:\\testorder";
public static final String HDFS_URL = "/data/hook"; public static final String HDFS_URL = "/data/hook";
...@@ -106,7 +106,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService { ...@@ -106,7 +106,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);
...@@ -932,6 +932,8 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService { ...@@ -932,6 +932,8 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
private class XlsxFileInfo{ private class XlsxFileInfo{
String filepath; String filepath;
SXSSFWorkbook workbook; SXSSFWorkbook workbook;
CellStyle yyyyMMddhhmmss;
CellStyle yyyyMMdd;
} }
...@@ -1207,6 +1209,18 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService { ...@@ -1207,6 +1209,18 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
cell = row.createCell(j); cell = row.createCell(j);
cell.setCellValue(titles.get(j).getTitle()); 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(); count.incrementAndGet();
} }
logger.info("{}-count:{}",originalFilePath,count.get()); logger.info("{}-count:{}",originalFilePath,count.get());
...@@ -1214,15 +1228,6 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService { ...@@ -1214,15 +1228,6 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
SXSSFWorkbook wb = xlsxFileInfo.workbook; // 内存中保留 100 行 SXSSFWorkbook wb = xlsxFileInfo.workbook; // 内存中保留 100 行
if (!endFlag) { if (!endFlag) {
Sheet sheet = wb.getSheetAt(0); 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()); Row row = sheet.createRow(count.get());
for (int j = 0; j < cells.length; j++) { for (int j = 0; j < cells.length; j++) {
...@@ -1236,10 +1241,10 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService { ...@@ -1236,10 +1241,10 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
switch (type) { switch (type) {
case FlatQueryFieldType.DATE: case FlatQueryFieldType.DATE:
if (columnValue.length() == 10) { if (columnValue.length() == 10) {
midCell.setCellStyle(yyyyMMdd); midCell.setCellStyle(xlsxFileInfo.yyyyMMdd);
midCell.setCellValue(DateUtils.parseDate(columnValue, new String[]{"yyyy-MM-dd"})); midCell.setCellValue(DateUtils.parseDate(columnValue, new String[]{"yyyy-MM-dd"}));
} else { } else {
midCell.setCellStyle(yyyyMMddhhmmss); midCell.setCellStyle(xlsxFileInfo.yyyyMMddhhmmss);
midCell.setCellValue(DateUtils.parseDate(columnValue, new String[]{"yyyy-MM-dd HH:mm:ss"})); midCell.setCellValue(DateUtils.parseDate(columnValue, new String[]{"yyyy-MM-dd HH:mm:ss"}));
} }
break; break;
......
...@@ -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("1680832767459"); DownloadTask downloadTask = downloadTaskService.getDownloadTaskById("1680836264864");
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