|
@@ -643,7 +643,7 @@ public class SubInfoExportController extends BaseController {
|
|
|
String subjectId = data.getSubjectId();
|
|
|
String induskind = data.getInduskind();
|
|
|
if (StringUtil.isNotEmpty(induskind)) {
|
|
|
- Optional<TSystable> first = gxjHyfl.stream().filter(item -> item.getCode().equals(induskind)).findFirst();
|
|
|
+ Optional<TSystable> first = gxjHyfl.stream().filter(item -> item.getId().equals(induskind)).findFirst();
|
|
|
first.ifPresent(tSystable -> data.setInduskind(tSystable.getTitle()));
|
|
|
}
|
|
|
if (StringUtil.isNotEmpty(subjectId)) {
|
|
@@ -804,53 +804,24 @@ public class SubInfoExportController extends BaseController {
|
|
|
exportParams.setType(ExcelType.XSSF);
|
|
|
Workbook workbook;
|
|
|
if (SubInfoStatusEnum.CB.getCode().equals(queryVO.getStatus())){
|
|
|
- List<SubInfoCbVO> cbVOList = list.stream().map(e -> {
|
|
|
- SubInfoCbVO subInfoCbVO = new SubInfoCbVO();
|
|
|
- BeanUtil.copyProperties(e, subInfoCbVO);
|
|
|
- return subInfoCbVO;
|
|
|
- }).collect(Collectors.toList());
|
|
|
- exportParams.setTitle("“四个一批”工业项目表(储备项目库)");
|
|
|
- exportParams.setSheetName("储备项目库");
|
|
|
- workbook = ExcelExportUtil.exportExcel(exportParams, SubInfoCbVO.class, cbVOList);
|
|
|
+ workbook = exportExcel(list, SubInfoCbVO.class, "“四个一批”工业项目表(储备项目库)", "储备项目库");
|
|
|
}else if (SubInfoStatusEnum.XJ.getCode().equals(queryVO.getStatus())){
|
|
|
- List<SubInfoXjVO> xjVOList = list.stream().map(e -> {
|
|
|
- SubInfoXjVO subInfoTzVO = new SubInfoXjVO();
|
|
|
- BeanUtil.copyProperties(e, subInfoTzVO);
|
|
|
- return subInfoTzVO;
|
|
|
- }).collect(Collectors.toList());
|
|
|
- exportParams.setTitle("“四个一批”工业项目表(新建项目库)");
|
|
|
- exportParams.setSheetName("新建项目库");
|
|
|
- workbook = ExcelExportUtil.exportExcel(exportParams, SubInfoXjVO.class, xjVOList);
|
|
|
+ workbook = exportExcel(list, SubInfoXjVO.class, "“四个一批”工业项目表(新建项目库)", "新建项目库");
|
|
|
}else if (SubInfoStatusEnum.ZJ.getCode().equals(queryVO.getStatus())){
|
|
|
- List<SubInfoZjVO> zjVoList = list.stream().map(e -> {
|
|
|
- SubInfoZjVO subInfoTzVO = new SubInfoZjVO();
|
|
|
- BeanUtil.copyProperties(e, subInfoTzVO);
|
|
|
- return subInfoTzVO;
|
|
|
- }).collect(Collectors.toList());
|
|
|
- exportParams.setTitle("“四个一批”工业项目表(在建项目库)");
|
|
|
- exportParams.setSheetName("在建项目库");
|
|
|
- workbook = ExcelExportUtil.exportExcel(exportParams, SubInfoZjVO.class, zjVoList);
|
|
|
+ workbook = exportExcel(list, SubInfoZjVO.class, "“四个一批”工业项目表(在建项目库)", "在建项目库");
|
|
|
}else if (SubInfoStatusEnum.TC.getCode().equals(queryVO.getStatus())){
|
|
|
- List<SubInfoTcVO> tcList = list.stream().map(e -> {
|
|
|
- SubInfoTcVO subInfoTzVO = new SubInfoTcVO();
|
|
|
- BeanUtil.copyProperties(e, subInfoTzVO);
|
|
|
- return subInfoTzVO;
|
|
|
- }).collect(Collectors.toList());
|
|
|
- exportParams.setTitle("“四个一批”工业项目表(投产项目库)");
|
|
|
- exportParams.setSheetName("投产项目库");
|
|
|
- workbook = ExcelExportUtil.exportExcel(exportParams, SubInfoTcVO.class, tcList);
|
|
|
+ workbook = exportExcel(list, SubInfoTcVO.class, "“四个一批”工业项目表(投产项目库)", "投产项目库");
|
|
|
}else {
|
|
|
- List<SubInfoZkVO> zkVOList = list.stream().map(e -> {
|
|
|
- SubInfoZkVO subInfoTzVO = new SubInfoZkVO();
|
|
|
- BeanUtil.copyProperties(e, subInfoTzVO);
|
|
|
- return subInfoTzVO;
|
|
|
- }).collect(Collectors.toList());
|
|
|
- exportParams.setTitle("“四个一批”工业项目表(项目总库)");
|
|
|
- exportParams.setSheetName("项目总库");
|
|
|
- workbook = ExcelExportUtil.exportExcel(exportParams, SubInfoZkVO.class, zkVOList);
|
|
|
+ workbook = exportExcel(list, SubInfoZkVO.class, "“四个一批”工业项目表(项目总库)", "项目总库");
|
|
|
}
|
|
|
response.setContentType("application/xlsx;charset=utf-8");
|
|
|
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncodeUtil.encode("项目明细表") + System.currentTimeMillis() + ".xlsx");
|
|
|
+ // workbook.getSheetAt(0).autoSizeColumn(2);
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
+ // 设置自适应行高,i为需要自适应行高的起始行号, 起始行号为3 但是因为下标从0开始3需要减一, i<=20, 因为表格是循环生成,需要一行一行设置自适应高度
|
|
|
+ for (int i = 2; i <= list.size() + 1; i++) {
|
|
|
+ sheet.getRow(i).setHeight((short) -1);
|
|
|
+ }
|
|
|
try (OutputStream outputStream = response.getOutputStream()) {
|
|
|
workbook.write(outputStream);
|
|
|
} catch (IOException e) {
|
|
@@ -858,6 +829,23 @@ public class SubInfoExportController extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private <T> Workbook exportExcel(List<SubInfoGxj> list, Class<T> clazz, String title, String sheetName) {
|
|
|
+ ExportParams exportParams = new ExportParams();
|
|
|
+ exportParams.setTitle(title);
|
|
|
+ exportParams.setSheetName(sheetName);
|
|
|
+ exportParams.setType(ExcelType.XSSF);
|
|
|
+
|
|
|
+ List<T> voList = list.stream()
|
|
|
+ .map(e -> {
|
|
|
+ T vo = BeanUtils.instantiateClass(clazz);
|
|
|
+ BeanUtils.copyProperties(e, vo);
|
|
|
+ return vo;
|
|
|
+ })
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ return ExcelExportUtil.exportExcel(exportParams, clazz, voList);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 4库导出
|
|
|
*
|
|
@@ -882,7 +870,7 @@ public class SubInfoExportController extends BaseController {
|
|
|
String subjectId = data.getSubjectId();
|
|
|
String induskind = data.getInduskind();
|
|
|
if (StringUtil.isNotEmpty(induskind)) {
|
|
|
- Optional<TSystable> first = hyflList.stream().filter(item -> item.getCode().equals(induskind)).findFirst();
|
|
|
+ Optional<TSystable> first = hyflList.stream().filter(item -> item.getId().equals(induskind)).findFirst();
|
|
|
first.ifPresent(tSystable -> data.setInduskind(tSystable.getTitle()));
|
|
|
}
|
|
|
if (StringUtil.isNotEmpty(subjectId)) {
|