|
|
@@ -60,9 +60,10 @@ public class PerformanceVerificationController extends GenericProvider{
|
|
|
|
|
|
@PostMapping("/exportExcelTemplate")
|
|
|
@ApiOperation(value = "导出数据模板", notes = "导出数据模板")
|
|
|
- public void exportExcelTemplate(@RequestParam(value = "name") String name,
|
|
|
+ public APIResult<Void> exportExcelTemplate(@RequestParam(value = "name") String name,
|
|
|
@RequestParam(value = "id") String id) {
|
|
|
ByteArrayOutputStream bos = null;
|
|
|
+ APIResult<Void> apiResult = new APIResult<>();
|
|
|
try {
|
|
|
|
|
|
Workbook workbook = performanceVerificationService.exportExcelTemplateExport(name, id);
|
|
|
@@ -73,9 +74,12 @@ public class PerformanceVerificationController extends GenericProvider{
|
|
|
workbook.write(bos);
|
|
|
byte[] barray = bos.toByteArray();
|
|
|
com.lc.ibps.base.web.util.RequestUtil.downLoadFileByByte(this.getRequest(), this.getResponse(), barray, fileName);// 导出
|
|
|
-
|
|
|
+ apiResult.setMessage("导出成功");
|
|
|
+ apiResult.setState(StateEnum.SUCCESS.getCode());
|
|
|
} catch (Exception e) {
|
|
|
logger.error("/pv/exportExcelTemplate", e);
|
|
|
+ apiResult.setMessage("导出失败");
|
|
|
+ apiResult.setState(StateEnum.ERROR.getCode());
|
|
|
} finally {
|
|
|
if (bos != null) {
|
|
|
try {
|
|
|
@@ -85,25 +89,30 @@ public class PerformanceVerificationController extends GenericProvider{
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ return apiResult;
|
|
|
}
|
|
|
@PostMapping("/exportExcelReport")
|
|
|
@ApiOperation(value = "导出数据报告", notes = "导出数据报告")
|
|
|
- public void exportExcelReport(@RequestParam(value = "name") String name,
|
|
|
+ public APIResult<Void> exportExcelReport(@RequestParam(value = "name") String name,
|
|
|
@RequestParam(value = "id") String id) {
|
|
|
ByteArrayOutputStream bos = null;
|
|
|
+ APIResult<Void> apiResult = new APIResult<>();
|
|
|
try {
|
|
|
|
|
|
Workbook workbook = performanceVerificationService.exportExcelReport(name, id);
|
|
|
// String rootRealPath = AppFileUtil.getRealPath("/" + AppFileUtil.TEMP_PATH); // 操作的根目录
|
|
|
- String fileName = "dataTemplate_" + name + (workbook instanceof HSSFWorkbook ? ".xls" : ".xlsx");
|
|
|
+ String fileName = "dataReport_" + name + (workbook instanceof HSSFWorkbook ? ".xls" : ".xlsx");
|
|
|
// FileUtil.writeFile(rootRealPath + File.separator + fileName + (workbook instanceof HSSFWorkbook ? ".xls" : ".xlsx"), workbook);
|
|
|
bos = new ByteArrayOutputStream();
|
|
|
workbook.write(bos);
|
|
|
byte[] barray = bos.toByteArray();
|
|
|
com.lc.ibps.base.web.util.RequestUtil.downLoadFileByByte(this.getRequest(), this.getResponse(), barray, fileName);// 导出
|
|
|
-
|
|
|
+ apiResult.setMessage("导出成功");
|
|
|
+ apiResult.setState(StateEnum.SUCCESS.getCode());
|
|
|
} catch (Exception e) {
|
|
|
logger.error("/pv/exportExcelReport", e);
|
|
|
+ apiResult.setMessage("导出失败");
|
|
|
+ apiResult.setState(StateEnum.ERROR.getCode());
|
|
|
} finally {
|
|
|
if (bos != null) {
|
|
|
try {
|
|
|
@@ -113,5 +122,6 @@ public class PerformanceVerificationController extends GenericProvider{
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ return apiResult;
|
|
|
}
|
|
|
}
|