|
@@ -875,7 +875,6 @@ public class SubInfoExportController extends BaseController {
|
|
|
/**
|
|
|
* 4库/总库 导出明细
|
|
|
*
|
|
|
- * @param response
|
|
|
*/
|
|
|
@PostMapping("/exportDetailExcel")
|
|
|
public void exportDetailExcel(@RequestBody SubInfoQueryTzVO queryVO) {
|
|
@@ -1003,6 +1002,71 @@ public class SubInfoExportController extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 导出重点项目储备明细表
|
|
|
+ *
|
|
|
+ * @param vo
|
|
|
+ */
|
|
|
+ @Log("页面:【项目四库管理-项目总库】,执行操作:导出明细")
|
|
|
+ @PostMapping("/exportXmzkDetailExcel")
|
|
|
+ public void exportXmzkDetailExcel(@RequestBody SubInfoQueryTzVO vo) throws IOException {
|
|
|
+
|
|
|
+ // 设置响应头
|
|
|
+ response.setContentType("application/vnd.ms-excel;charset=utf-8");
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("项目总库-明细数据.xlsx", "UTF-8"));
|
|
|
+
|
|
|
+ try (cn.hutool.poi.excel.ExcelWriter writer = ExcelUtil.getBigWriter();
|
|
|
+ ServletOutputStream out = response.getOutputStream()) {
|
|
|
+
|
|
|
+ // 获取数据
|
|
|
+ List<String> subjectIds = getSubjectIds();
|
|
|
+ List<SmzkDetailVo> subInfoTotalExcel = subInfoService.exportSmzkDetailExcel(vo,subjectIds);
|
|
|
+
|
|
|
+ // 写入标题行
|
|
|
+ writer.writeHeadRow(CollUtil.newArrayList("“四个一批”工业项目表(项目总库)"));
|
|
|
+ writer.merge(0, 0, 0, 9, "“四个一批”工业项目表(项目总库)", true);
|
|
|
+
|
|
|
+ // 写入子标题行
|
|
|
+// writer.writeHeadRow(CollUtil.newArrayList("序号", "项目id", "项目库", "项目代码", "项目名称", "总金额(亿元)", "计划开始日期", "计划投产日期", "行业名称", "状态"));
|
|
|
+
|
|
|
+ writer.addHeaderAlias("number", "序号");
|
|
|
+ writer.addHeaderAlias("id", "项目id");
|
|
|
+ writer.addHeaderAlias("status", "项目库");
|
|
|
+ writer.addHeaderAlias("subCode", "项目代码");
|
|
|
+ writer.addHeaderAlias("subName", "项目名称");
|
|
|
+ writer.addHeaderAlias("amtTotal", "总金额(亿元)");
|
|
|
+ writer.addHeaderAlias("beginDate", "计划开始日期");
|
|
|
+ writer.addHeaderAlias("endDate", "计划投产日期");
|
|
|
+ writer.addHeaderAlias("indusKind", "行业名称");
|
|
|
+ writer.addHeaderAlias("cbStatus", "状态");
|
|
|
+
|
|
|
+
|
|
|
+ // 设置每列的默认宽度
|
|
|
+ SXSSFSheet sheet = ((SXSSFWorkbook) writer.getWorkbook()).getSheetAt(0);
|
|
|
+ int defaultColumnWidth = 40; // 默认宽度为20个字符
|
|
|
+ for (int i = 0; i < 9; i++) {
|
|
|
+ sheet.setColumnWidth(i, defaultColumnWidth * 256); // 其他列保持默认宽度
|
|
|
+ }
|
|
|
+
|
|
|
+ //根据合并行进行合并
|
|
|
+ for (int i = 0; i < subInfoTotalExcel.size(); i++) {
|
|
|
+ subInfoTotalExcel.get(i).setNumber(i);
|
|
|
+ }
|
|
|
+
|
|
|
+ //写入行业明细行
|
|
|
+ writer.write(subInfoTotalExcel, true);
|
|
|
+ // 输出到客户端
|
|
|
+ writer.flush(out, true);
|
|
|
+
|
|
|
+ } catch (IOException e) {
|
|
|
+ // 处理 IO 异常
|
|
|
+ handleErrorResponse(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "导出 Excel 文件时出现错误:" + e.getMessage());
|
|
|
+ } catch (Exception e) {
|
|
|
+ // 处理其他异常
|
|
|
+ handleErrorResponse(response, HttpServletResponse.SC_BAD_REQUEST, "请求参数错误或发生其他错误:" + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private <K extends SubInfoBaseDetailVo> void exportDetail(HttpServletResponse response,ExportParams exportParams,Class<K> clazz, List<SubInfoGxj> list, Map<String, String> hyDictMap, Map<String, List<SubInfoGxj>> groupMap) {
|
|
|
List<K> exportList = new ArrayList<>();
|
|
|
// 合计行
|