Commit f96ee9d9 authored by yanzg's avatar yanzg

合并空行BUG

parent e5a05a84
...@@ -73,8 +73,8 @@ public class ExcelHttp<T extends Object> extends ExcelConsole<T> { ...@@ -73,8 +73,8 @@ public class ExcelHttp<T extends Object> extends ExcelConsole<T> {
String fileNameRow = this.getFileNameRow(); String fileNameRow = this.getFileNameRow();
File fileRow = new File(fileNameRow); File fileRow = new File(fileNameRow);
boolean isDown = file.exists(); boolean ok = file.exists();
if (isDown) { if (ok && config.getExportType() != ExportData.EXPORT_TYPE_WAIT) {
// 下载文件 // 下载文件
HttpFileHelper.localToDown(this.getFileName(), downFileName, response); HttpFileHelper.localToDown(this.getFileName(), downFileName, response);
} else { } else {
...@@ -84,11 +84,12 @@ public class ExcelHttp<T extends Object> extends ExcelConsole<T> { ...@@ -84,11 +84,12 @@ public class ExcelHttp<T extends Object> extends ExcelConsole<T> {
res.setFileName(config.getFileName()); res.setFileName(config.getFileName());
res.setSize(fileTemp.length()); res.setSize(fileTemp.length());
res.setRow(StringHelper.toLong(FileHelper.readFile(fileRow, "utf-8"))); res.setRow(StringHelper.toLong(FileHelper.readFile(fileRow, "utf-8")));
res.setOk(ok);
// 输出结果 // 输出结果
response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE); response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
response.getWriter().print(JsonHelper.serialize(res)); response.getWriter().print(JsonHelper.serialize(res));
} }
return isDown; return ok;
} }
/** /**
...@@ -116,7 +117,8 @@ public class ExcelHttp<T extends Object> extends ExcelConsole<T> { ...@@ -116,7 +117,8 @@ public class ExcelHttp<T extends Object> extends ExcelConsole<T> {
ExcelHttp<M> excel = new ExcelHttp<>(config); ExcelHttp<M> excel = new ExcelHttp<>(config);
boolean isDown = false; boolean isDown = false;
try { try {
if (config.getExportType() == ExportData.EXPORT_TYPE_COMMON) { int type = StringHelper.toInt(config.getExportType());
if (type == ExportData.EXPORT_TYPE_COMMON) {
// 普通模式生成文件并下载 // 普通模式生成文件并下载
releaseExcel(req, excelDao, excel); releaseExcel(req, excelDao, excel);
} else if (isEmptyFile) { } else if (isEmptyFile) {
......
...@@ -17,8 +17,11 @@ public class ExportData { ...@@ -17,8 +17,11 @@ public class ExportData {
@ApiModelProperty(notes = "普通导出模式") @ApiModelProperty(notes = "普通导出模式")
public static final int EXPORT_TYPE_COMMON = 0; public static final int EXPORT_TYPE_COMMON = 0;
@ApiModelProperty(notes = "等待下载模式") @ApiModelProperty(notes = "等待下载")
public static final int EXPORT_TYPE_WAIT_DOWN = 1; public static final int EXPORT_TYPE_WAIT = 1;
@ApiModelProperty(notes = "下载文件")
public static final int EXPORT_TYPE_DOWN = 2;
@ApiModelProperty(notes = "行默认高度") @ApiModelProperty(notes = "行默认高度")
public static final short ROW_HEIGHT_UNIT = 10; public static final short ROW_HEIGHT_UNIT = 10;
...@@ -42,7 +45,7 @@ public class ExportData { ...@@ -42,7 +45,7 @@ public class ExportData {
* 第一次请求会返回导出路径,后续几次会返回正在生成中,并且返回文件的大小,当生成完成后最后一次会下载文件) * 第一次请求会返回导出路径,后续几次会返回正在生成中,并且返回文件的大小,当生成完成后最后一次会下载文件)
*/ */
@ApiModelProperty(notes = "导出类型,0-实时导出,1-等待生成文件后下载(该类型需要请求多次:" + @ApiModelProperty(notes = "导出类型,0-实时导出,1-等待生成文件后下载(该类型需要请求多次:" +
"第一次请求会返回导出路径,后续几次会返回正在生成中,并且返回文件的大小,当生成完成后最后一次会下载文件)", required = true) "第一次请求会返回导出路径,后续几次会返回正在生成中,并且返回文件的大小,当生成完成后最后一次会下载文件),2-下载文件", required = true)
private int exportType; private int exportType;
/** /**
* 服务器保存路径 * 服务器保存路径
......
...@@ -28,6 +28,12 @@ public class ExportTempRes extends BaseVo { ...@@ -28,6 +28,12 @@ public class ExportTempRes extends BaseVo {
@ApiModelProperty(notes = "已生成文件行数") @ApiModelProperty(notes = "已生成文件行数")
private long row; private long row;
/**
* 是否可以下载文件
*/
@ApiModelProperty(notes = "是否可以下载文件")
private boolean ok;
public String getFileName() { public String getFileName() {
return fileName; return fileName;
} }
...@@ -51,4 +57,12 @@ public class ExportTempRes extends BaseVo { ...@@ -51,4 +57,12 @@ public class ExportTempRes extends BaseVo {
public void setRow(long row) { public void setRow(long row) {
this.row = row; this.row = row;
} }
public boolean isOk() {
return ok;
}
public void setOk(boolean ok) {
this.ok = ok;
}
} }
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