|
@@ -126,21 +126,16 @@ public class TrialContainerController extends BladeController {
|
|
}
|
|
}
|
|
|
|
|
|
@PostMapping("/data/download-template")
|
|
@PostMapping("/data/download-template")
|
|
- @ApiOperationSupport(order = 11)
|
|
|
|
|
|
+ @ApiOperationSupport(order = 10)
|
|
@ApiOperation(value = "下载当前容器的excel模板", notes = "传入容器id")
|
|
@ApiOperation(value = "下载当前容器的excel模板", notes = "传入容器id")
|
|
- public R<Object> downloadExcelTemplate(@RequestParam String id, HttpServletResponse response) throws IOException {
|
|
|
|
|
|
+ public void downloadExcelTemplate(@RequestParam String id, HttpServletResponse response) throws IOException {
|
|
TrialContainerClassification objRoot = trialContainerClassificationMapper.selectById(id);
|
|
TrialContainerClassification objRoot = trialContainerClassificationMapper.selectById(id);
|
|
if (objRoot != null) {
|
|
if (objRoot != null) {
|
|
List<TrialContainerClassification> filedList = trialContainerClassificationMapper.selectList(Wrappers.<TrialContainerClassification>lambdaQuery().eq(TrialContainerClassification::getContainerId, id));
|
|
List<TrialContainerClassification> filedList = trialContainerClassificationMapper.selectList(Wrappers.<TrialContainerClassification>lambdaQuery().eq(TrialContainerClassification::getContainerId, id));
|
|
if (filedList.size() > 0) {
|
|
if (filedList.size() > 0) {
|
|
List<String> fieldNames = filedList.stream().map(TrialContainerClassification::getFieldName).collect(Collectors.toList());
|
|
List<String> fieldNames = filedList.stream().map(TrialContainerClassification::getFieldName).collect(Collectors.toList());
|
|
this.exportToExcelTemplate(objRoot.getContainerName(), fieldNames, response);
|
|
this.exportToExcelTemplate(objRoot.getContainerName(), fieldNames, response);
|
|
- return R.success("导出成功");
|
|
|
|
- } else {
|
|
|
|
- return R.success("当前容器没有字段,请新增容器字段后再下载模板");
|
|
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
- return R.success("请选择一个容器后再下载模板");
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -162,9 +157,9 @@ public class TrialContainerController extends BladeController {
|
|
}
|
|
}
|
|
|
|
|
|
response.reset();
|
|
response.reset();
|
|
- response.setContentType("application/octet-stream");
|
|
|
|
- String fileName = URLEncoder.encode(sheetName + ".xlsx", "UTF-8");
|
|
|
|
- response.setHeader("Content-Disposition", "attachment;filename=\"" + fileName + "\"");
|
|
|
|
|
|
+ response.setContentType("application/vnd.ms-excel");
|
|
|
|
+ response.setCharacterEncoding(org.apache.commons.codec.Charsets.UTF_8.name());
|
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + sheetName + ".xlsx");
|
|
OutputStream outputStream = response.getOutputStream();
|
|
OutputStream outputStream = response.getOutputStream();
|
|
workbook.write(outputStream);
|
|
workbook.write(outputStream);
|
|
outputStream.flush();
|
|
outputStream.flush();
|