|
@@ -3,6 +3,7 @@ package com.rtrh.projects.web.controller.subject;
|
|
|
import java.io.IOException;
|
|
|
import java.io.OutputStream;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
@@ -30,9 +31,11 @@ import com.rtrh.core.vo.ListMessage;
|
|
|
import com.rtrh.projects.modules.projects.dao.SubSourceDao;
|
|
|
import com.rtrh.projects.modules.projects.enums.ProjectStatusEnum;
|
|
|
import com.rtrh.projects.modules.projects.enums.SubInfoStatusEnum;
|
|
|
+import com.rtrh.projects.modules.projects.po.SubIndu;
|
|
|
import com.rtrh.projects.modules.projects.po.SubInfoGxj;
|
|
|
import com.rtrh.projects.modules.projects.vo.SubInfoTotalExcel;
|
|
|
import com.rtrh.projects.modules.projects.vo.export.*;
|
|
|
+import com.rtrh.projects.modules.system.service.ISubInduService;
|
|
|
import com.rtrh.projects.modules.utils.CustomCellWriteWidthStrategy;
|
|
|
import com.rtrh.projects.modules.utils.DateUtils;
|
|
|
import com.rtrh.projects.modules.utils.QualificationsDeclareCellWriteHandler;
|
|
@@ -40,6 +43,7 @@ import com.rtrh.projects.outapi.result.JsonResult;
|
|
|
import com.rtrh.projects.web.util.SheetData;
|
|
|
import com.rtrh.projects.web.util.SheetHead;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
+import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
import org.apache.poi.xssf.streaming.SXSSFSheet;
|
|
|
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
@@ -90,6 +94,8 @@ public class SubInfoExportController extends BaseController {
|
|
|
private TSysTableService tSysTableService;
|
|
|
@Autowired
|
|
|
private SubSourceDao subSourceDao;
|
|
|
+ @Autowired
|
|
|
+ private ISubInduService subInduService;
|
|
|
|
|
|
/**
|
|
|
* 导出汇总表
|
|
@@ -622,6 +628,7 @@ public class SubInfoExportController extends BaseController {
|
|
|
|
|
|
/**
|
|
|
* 导出总表
|
|
|
+ *
|
|
|
* @param response
|
|
|
* @param vo
|
|
|
*/
|
|
@@ -637,7 +644,7 @@ public class SubInfoExportController extends BaseController {
|
|
|
List<TSystable> gxjHyfl = tSysTableService.getGxjHyfl(SysTableKind.HYFL);
|
|
|
//遍历subInfoTotalExcel,将subjectId替换为jsddList中code=subjectId的title
|
|
|
for (SubInfoTotalExcel data : subInfoTotalExcel) {
|
|
|
- if (data == null){
|
|
|
+ if (data == null) {
|
|
|
continue;
|
|
|
}
|
|
|
String subjectId = data.getSubjectId();
|
|
@@ -662,7 +669,7 @@ public class SubInfoExportController extends BaseController {
|
|
|
// 合并标题行的所有单元格
|
|
|
writer.merge(0, 0, 0, 3, null, true);
|
|
|
|
|
|
- List<String> rowHead2 = CollUtil.newArrayList("项目分类","项目分类","项目个数","计划总投资(亿元)");
|
|
|
+ List<String> rowHead2 = CollUtil.newArrayList("项目分类", "项目分类", "项目个数", "计划总投资(亿元)");
|
|
|
writer.writeHeadRow(rowHead2);
|
|
|
writer.merge(1, 1, 0, 1, null, true);
|
|
|
|
|
@@ -742,9 +749,9 @@ public class SubInfoExportController extends BaseController {
|
|
|
for (Map.Entry<String, List<List<String>>> dataListEntry : finalDataMap.entrySet()) {
|
|
|
List<List<String>> dataList = dataListEntry.getValue();
|
|
|
int dataSize = dataList.size();
|
|
|
- if (dataSize == 1){
|
|
|
+ if (dataSize == 1) {
|
|
|
indexStart += dataSize;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
writer.merge(indexStart, indexStart + dataSize - 1, 0, 0, null, true);
|
|
|
indexStart += dataSize;
|
|
|
}
|
|
@@ -766,7 +773,7 @@ public class SubInfoExportController extends BaseController {
|
|
|
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("重点项目调度-项目数据.xlsx", "UTF-8"));
|
|
|
out = response.getOutputStream();
|
|
|
writer.flush(out, true);
|
|
|
- }finally {
|
|
|
+ } finally {
|
|
|
//关闭输出Servlet流
|
|
|
IoUtil.close(out);
|
|
|
//关闭writer,释放内存
|
|
@@ -792,6 +799,7 @@ public class SubInfoExportController extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 导出明细
|
|
|
*
|
|
@@ -800,25 +808,23 @@ public class SubInfoExportController extends BaseController {
|
|
|
@PostMapping("/exportDetailExcel")
|
|
|
public void exportDetailExcel(HttpServletResponse response, @RequestBody SubInfoQueryTzVO queryVO) {
|
|
|
List<SubInfoGxj> list = subInfoQueryService.queryAll(getCurUser().getLoginUser(), queryVO);
|
|
|
- ExportParams exportParams = new ExportParams();
|
|
|
- exportParams.setType(ExcelType.XSSF);
|
|
|
Workbook workbook;
|
|
|
- if (SubInfoStatusEnum.CB.getCode().equals(queryVO.getStatus())){
|
|
|
+ if (SubInfoStatusEnum.CB.getCode().equals(queryVO.getStatus())) {
|
|
|
workbook = exportExcel(list, SubInfoCbVO.class, "“四个一批”工业项目表(储备项目库)", "储备项目库");
|
|
|
- }else if (SubInfoStatusEnum.XJ.getCode().equals(queryVO.getStatus())){
|
|
|
+ } else if (SubInfoStatusEnum.XJ.getCode().equals(queryVO.getStatus())) {
|
|
|
workbook = exportExcel(list, SubInfoXjVO.class, "“四个一批”工业项目表(新建项目库)", "新建项目库");
|
|
|
- }else if (SubInfoStatusEnum.ZJ.getCode().equals(queryVO.getStatus())){
|
|
|
+ } else if (SubInfoStatusEnum.ZJ.getCode().equals(queryVO.getStatus())) {
|
|
|
workbook = exportExcel(list, SubInfoZjVO.class, "“四个一批”工业项目表(在建项目库)", "在建项目库");
|
|
|
- }else if (SubInfoStatusEnum.TC.getCode().equals(queryVO.getStatus())){
|
|
|
+ } else if (SubInfoStatusEnum.TC.getCode().equals(queryVO.getStatus())) {
|
|
|
workbook = exportExcel(list, SubInfoTcVO.class, "“四个一批”工业项目表(投产项目库)", "投产项目库");
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
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, 因为表格是循环生成,需要一行一行设置自适应高度
|
|
|
+ // 设置自适应行高,i为需要自适应行高的起始行号, 起始行号为3 但是因为下标从0开始3需要减一,因为表格是循环生成,需要一行一行设置自适应高度
|
|
|
for (int i = 2; i <= list.size() + 1; i++) {
|
|
|
sheet.getRow(i).setHeight((short) -1);
|
|
|
}
|
|
@@ -854,174 +860,112 @@ public class SubInfoExportController extends BaseController {
|
|
|
*/
|
|
|
@PostMapping("/exportTotalExcelByStatus")
|
|
|
public void exportTotalExcelByStatus(HttpServletResponse response, @RequestBody SubInfoQueryTzVO vo) {
|
|
|
+ // 查询数据以及字典
|
|
|
+ List<SubInfoTotalExcel> list = subInfoService.exportTotalExcelByStatus(vo);
|
|
|
+ List<TSystable> jsddDict = tSysTableService.getByKind(SysTableKind.JSDD);
|
|
|
+ Map<String, String> jsddMap = jsddDict.stream().collect(Collectors.toMap(TSystable::getCode, TSystable::getTitle));
|
|
|
+ Map<String, String> hyflMap = subInduService.queryParentAll().stream().collect(Collectors.toMap(SubIndu::getCode, SubIndu::getTitle));
|
|
|
+ // 处理数据
|
|
|
+ List<SubInfoTotalInfoVO> exportData = new ArrayList<>();
|
|
|
+ if (CollectionUtil.isNotEmpty(list)) {
|
|
|
+ // 1.按属地分
|
|
|
+ List<SubInfoTotalInfoVO> ddList = list.stream()
|
|
|
+ .collect(Collectors.groupingBy(SubInfoTotalExcel::getSubjectId))
|
|
|
+ .entrySet().stream()
|
|
|
+ .map(entry -> new SubInfoTotalInfoVO(
|
|
|
+ "按属地分",
|
|
|
+ jsddMap.getOrDefault(entry.getKey(), entry.getKey()),
|
|
|
+ entry.getValue().size(),
|
|
|
+ entry.getValue().stream()
|
|
|
+ .map(SubInfoTotalExcel::getAmtTotal)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add)
|
|
|
+ .divide(new BigDecimal("10000"), 2, RoundingMode.HALF_UP)
|
|
|
+ ))
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
|
- try {
|
|
|
- List<SubInfoTotalExcel> subInfoTotalExcel = subInfoService.exportTotalExcelByStatus(vo);
|
|
|
-
|
|
|
- //获取属地字典
|
|
|
- List<TSystable> jsddList = tSysTableService.getByKind(SysTableKind.JSDD);
|
|
|
- //获取行业字典
|
|
|
- List<TSystable> hyflList = tSysTableService.getByKind(SysTableKind.HYFL);
|
|
|
- //遍历subInfoTotalExcel,将subjectId替换为jsddList中code=subjectId的title
|
|
|
- for (SubInfoTotalExcel data : subInfoTotalExcel) {
|
|
|
- if (data == null) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- String subjectId = data.getSubjectId();
|
|
|
- String induskind = data.getInduskind();
|
|
|
- if (StringUtil.isNotEmpty(induskind)) {
|
|
|
- Optional<TSystable> first = hyflList.stream().filter(item -> item.getId().equals(induskind)).findFirst();
|
|
|
- first.ifPresent(tSystable -> data.setInduskind(tSystable.getTitle()));
|
|
|
- }
|
|
|
- if (StringUtil.isNotEmpty(subjectId)) {
|
|
|
- Optional<TSystable> first = jsddList.stream().filter(item -> item.getCode().equals(subjectId)).findFirst();
|
|
|
- first.ifPresent(tSystable -> data.setSubjectId(tSystable.getTitle()));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //通过ExcelUtil.getBigWriter()创建Writer对象,BigExcelWriter用于大数据量的导出,不会引起溢出;
|
|
|
- cn.hutool.poi.excel.ExcelWriter writer = ExcelUtil.getBigWriter();
|
|
|
-
|
|
|
- //写入标题
|
|
|
- // 写入标题行
|
|
|
- List<String> titleRow = CollUtil.newArrayList("储备项目库基本情况");
|
|
|
- writer.writeHeadRow(titleRow);
|
|
|
- // 合并标题行的所有单元格
|
|
|
- writer.merge(0, 0, 0, 3, null, true);
|
|
|
-
|
|
|
- List<String> rowHead2 = CollUtil.newArrayList("项目分类", "项目分类", "项目个数", "计划总投资(亿元)");
|
|
|
- writer.writeHeadRow(rowHead2);
|
|
|
- writer.merge(1, 1, 0, 1, null, true);
|
|
|
-
|
|
|
- // 获取 SXSSFSheet 对象(确保在写入数据之后)
|
|
|
- SXSSFSheet sheet = ((SXSSFWorkbook) writer.getWorkbook()).getSheetAt(0);
|
|
|
-
|
|
|
- // 设置每列的默认宽度
|
|
|
- int defaultColumnWidth = 40; // 默认宽度为20个字符
|
|
|
- for (int i = 0; i < rowHead2.size(); i++) {
|
|
|
- sheet.setColumnWidth(i, defaultColumnWidth * 256); // 其他列保持默认宽度
|
|
|
- }
|
|
|
-
|
|
|
- //4、对数据按照属地字段进行分组
|
|
|
- LinkedHashMap<String, List<SubInfoTotalExcel>> subjectIdList = subInfoTotalExcel.stream().collect(Collectors.groupingBy(SubInfoTotalExcel::getSubjectId, LinkedHashMap::new, Collectors.toList()));
|
|
|
- //5、对数据按照金额1000-3000,3000-5000,5000-10000进行分组
|
|
|
- LinkedHashMap<String, List<SubInfoTotalExcel>> moneyList = subInfoTotalExcel.stream().collect(Collectors.groupingBy(data -> {
|
|
|
- if (data.getAmtTotal().compareTo(new BigDecimal(1000000)) >= 0) {
|
|
|
- return "100亿元以上";
|
|
|
- } else if (data.getAmtTotal().compareTo(new BigDecimal(500000)) >= 0 && data.getAmtTotal().compareTo(new BigDecimal(1000000)) < 0) {
|
|
|
- return "50-100亿元";
|
|
|
- } else if (data.getAmtTotal().compareTo(new BigDecimal(100000)) >= 0 && data.getAmtTotal().compareTo(new BigDecimal(500000)) < 0) {
|
|
|
- return "10-50亿元";
|
|
|
- } else {
|
|
|
- return "10亿元以下";
|
|
|
- }
|
|
|
- }, LinkedHashMap::new, Collectors.toList()));
|
|
|
- //6、对数据按照行业进行分组
|
|
|
- LinkedHashMap<String, List<SubInfoTotalExcel>> industryList = subInfoTotalExcel.stream().collect(Collectors.groupingBy(SubInfoTotalExcel::getInduskind, LinkedHashMap::new, Collectors.toList()));
|
|
|
-
|
|
|
- //遍历subInfoTotalExcel数据计算总金额
|
|
|
- BigDecimal totalAmt = subInfoTotalExcel.stream().map(SubInfoTotalExcel::getAmtTotal).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- Integer totalNum = subInfoTotalExcel.size();
|
|
|
-
|
|
|
- LinkedHashMap<String, List<List<String>>> finalDataMap = new LinkedHashMap<>();
|
|
|
-
|
|
|
- //7、需要保存的数据
|
|
|
- List<List<String>> areaData = CollUtil.newArrayList();
|
|
|
- for (Map.Entry<String, List<SubInfoTotalExcel>> subInfoListEntry : subjectIdList.entrySet()) {
|
|
|
- List<String> data = CollUtil.newArrayList();
|
|
|
- data.add("按属地分");
|
|
|
- data.add(subInfoListEntry.getKey());
|
|
|
- data.add(String.valueOf(subInfoListEntry.getValue().size()));
|
|
|
- data.add(String.valueOf(subInfoListEntry.getValue().stream().map(SubInfoTotalExcel::getAmtTotal).reduce(BigDecimal.ZERO, BigDecimal::add)));
|
|
|
- areaData.add(data);
|
|
|
- }
|
|
|
- finalDataMap.put("按属地划分", areaData);
|
|
|
-
|
|
|
- List<List<String>> moneyData = CollUtil.newArrayList();
|
|
|
- for (Map.Entry<String, List<SubInfoTotalExcel>> subInfoListEntry : moneyList.entrySet()) {
|
|
|
- List<String> data = CollUtil.newArrayList();
|
|
|
- data.add("按金额分");
|
|
|
- data.add(subInfoListEntry.getKey());
|
|
|
- data.add(String.valueOf(subInfoListEntry.getValue().size()));
|
|
|
- data.add(String.valueOf(subInfoListEntry.getValue().stream().map(SubInfoTotalExcel::getAmtTotal).reduce(BigDecimal.ZERO, BigDecimal::add)));
|
|
|
- moneyData.add(data);
|
|
|
- }
|
|
|
- finalDataMap.put("按金额划分", moneyData);
|
|
|
-
|
|
|
- List<List<String>> industryData = CollUtil.newArrayList();
|
|
|
- for (Map.Entry<String, List<SubInfoTotalExcel>> subInfoListEntry : industryList.entrySet()) {
|
|
|
- List<String> data = CollUtil.newArrayList();
|
|
|
- data.add("按行业分");
|
|
|
- data.add(subInfoListEntry.getKey());
|
|
|
- data.add(String.valueOf(subInfoListEntry.getValue().size()));
|
|
|
- data.add(String.valueOf(subInfoListEntry.getValue().stream().map(SubInfoTotalExcel::getAmtTotal).reduce(BigDecimal.ZERO, BigDecimal::add)));
|
|
|
- industryData.add(data);
|
|
|
- }
|
|
|
- finalDataMap.put("按行业划分", industryData);
|
|
|
-
|
|
|
- ServletOutputStream out = null;
|
|
|
-
|
|
|
- try {
|
|
|
- //6.定义容器保存人物数据
|
|
|
- List<List<String>> finalDataRows = new LinkedList<>();
|
|
|
- int indexStart = 2; //行业分类起始行
|
|
|
-
|
|
|
- for (Map.Entry<String, List<List<String>>> dataListEntry : finalDataMap.entrySet()) {
|
|
|
- List<List<String>> dataList = dataListEntry.getValue();
|
|
|
- int dataSize = dataList.size();
|
|
|
- if (dataSize == 1) {
|
|
|
- indexStart += dataSize;
|
|
|
- } else {
|
|
|
- writer.merge(indexStart, indexStart + dataSize - 1, 0, 0, null, true);
|
|
|
- indexStart += dataSize;
|
|
|
- }
|
|
|
- //18.保存数据
|
|
|
- finalDataRows.addAll(dataList);
|
|
|
- }
|
|
|
- writer.write(finalDataRows, true);
|
|
|
-
|
|
|
- // 创建合计行
|
|
|
- List<String> totalRow = CollUtil.newArrayList("合计", "合计", totalNum.toString(), totalAmt.toString());
|
|
|
- writer.writeHeadRow(totalRow);
|
|
|
- writer.merge(indexStart, indexStart, 0, 1, null, true);
|
|
|
-
|
|
|
+ // 2.按金额分 定义分组边界
|
|
|
+ Map<String, BigDecimal> groupBoundaries = new LinkedHashMap<>();
|
|
|
+ groupBoundaries.put("10亿元以下", new BigDecimal("100000"));
|
|
|
+ groupBoundaries.put("10-50亿元", new BigDecimal("500000"));
|
|
|
+ groupBoundaries.put("50-100亿元", new BigDecimal("1000000"));
|
|
|
+ List<SubInfoTotalInfoVO> amtList = list.stream()
|
|
|
+ .collect(Collectors.groupingBy(transaction -> {
|
|
|
+ for (Map.Entry<String, BigDecimal> entry : groupBoundaries.entrySet()) {
|
|
|
+ if (transaction.getAmtTotal().compareTo(entry.getValue()) < 0) {
|
|
|
+ return entry.getKey();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "100亿元以上"; // 超过最高范围的默认分组
|
|
|
+ }))
|
|
|
+ .entrySet().stream()
|
|
|
+ .map(entry -> new SubInfoTotalInfoVO(
|
|
|
+ "按金额分",
|
|
|
+ entry.getKey(),
|
|
|
+ entry.getValue().size(),
|
|
|
+ entry.getValue().stream()
|
|
|
+ .map(SubInfoTotalExcel::getAmtTotal)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add)
|
|
|
+ .divide(new BigDecimal("10000"), 2, RoundingMode.HALF_UP)
|
|
|
+ ))
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
|
- response.setContentType("application/vnd.ms-excel;charset=utf-8");
|
|
|
- Date currentDate = new Date();
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
|
|
- String date = sdf.format(currentDate);
|
|
|
- response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("重点项目调度-项目数据.xlsx", "UTF-8"));
|
|
|
- out = response.getOutputStream();
|
|
|
- writer.flush(out, true);
|
|
|
- } finally {
|
|
|
- //关闭输出Servlet流
|
|
|
- IoUtil.close(out);
|
|
|
- //关闭writer,释放内存
|
|
|
- writer.close();
|
|
|
- }
|
|
|
- } catch (IOException e) {
|
|
|
- // 设置错误状态码和消息
|
|
|
- response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
|
|
- try {
|
|
|
+ // 3.按行业分
|
|
|
+ List<SubInfoTotalInfoVO> hyList = list.stream()
|
|
|
+ .collect(Collectors.groupingBy(transaction ->{
|
|
|
+ String code = transaction.getInduskind();
|
|
|
+ // 确保code不为空且长度至少为2
|
|
|
+ if (code == null || code.length() < 2) {
|
|
|
+ return "未知行业"; // 默认未知行业
|
|
|
+ }
|
|
|
+ return code.substring(0, 2);
|
|
|
+ }))
|
|
|
+ .entrySet().stream()
|
|
|
+ .map(entry -> new SubInfoTotalInfoVO(
|
|
|
+ "按行业分",
|
|
|
+ hyflMap.getOrDefault(entry.getKey(),entry.getKey()),
|
|
|
+ entry.getValue().size(),
|
|
|
+ entry.getValue().stream()
|
|
|
+ .map(SubInfoTotalExcel::getAmtTotal)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add)
|
|
|
+ .divide(new BigDecimal("10000"), 2, RoundingMode.HALF_UP)
|
|
|
+ )
|
|
|
+ )
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ exportData.addAll(ddList);
|
|
|
+ exportData.addAll(amtList);
|
|
|
+ exportData.addAll(hyList);
|
|
|
+ BigDecimal reduce = list.stream().map(SubInfoTotalExcel::getAmtTotal).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ exportData.add(new SubInfoTotalInfoVO("合计", "合计", list.size(), reduce.divide(new BigDecimal("10000"), 2, RoundingMode.HALF_UP)));
|
|
|
+ // 4.导出
|
|
|
+ ExportParams exportParams = new ExportParams();
|
|
|
+ exportParams.setTitle("项目库基本情况");
|
|
|
+ exportParams.setSheetName("项目库基本情况");
|
|
|
+ exportParams.setType(ExcelType.XSSF);
|
|
|
+ int mergeTotalStartRow = exportData.size() + 1;
|
|
|
+ Workbook workbook = ExcelExportUtil.exportExcel(exportParams, SubInfoTotalInfoVO.class, exportData);
|
|
|
+ response.setContentType("application/xlsx;charset=utf-8");
|
|
|
+ response.setHeader("Content-Disposition", "attachment; filename=" + URLEncodeUtil.encode("项目明细表") + System.currentTimeMillis() + ".xlsx");
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
+ // 合并单元格
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 1));
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(2, ddList.size() + 1, 0, 0));
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(ddList.size() + 2, ddList.size() + amtList.size() + 1, 0, 0));
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(ddList.size() + amtList.size() + 2, ddList.size() + amtList.size() + hyList.size() + 1, 0, 0));
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(mergeTotalStartRow, mergeTotalStartRow, 0, 1));
|
|
|
+
|
|
|
+ try (OutputStream outputStream = response.getOutputStream()) {
|
|
|
+ workbook.write(outputStream);
|
|
|
+ workbook.close();
|
|
|
+ } catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
- response.getWriter().write("导出 Excel 文件时出现错误:" + e.getMessage());
|
|
|
- } catch (IOException ex) {
|
|
|
- ex.printStackTrace();
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- // 处理其他可能的异常
|
|
|
- response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
|
|
|
- e.printStackTrace();
|
|
|
- try {
|
|
|
- response.getWriter().write("请求参数错误或发生其他错误:" + e.getMessage());
|
|
|
- } catch (IOException ex) {
|
|
|
- ex.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 导出重点项目明细表
|
|
|
+ *
|
|
|
* @param response
|
|
|
* @param vo
|
|
|
*/
|
|
@@ -1219,7 +1163,7 @@ public class SubInfoExportController extends BaseController {
|
|
|
listMain.get(i).put("statusSource", "3");
|
|
|
}
|
|
|
for (int j = 0; j < tableList.size(); j++) {
|
|
|
- if (listMain.get(i).get("propKind")!=null&&listMain.get(i).get("propKind").equals(tableList.get(j).getCode())) {
|
|
|
+ if (listMain.get(i).get("propKind") != null && listMain.get(i).get("propKind").equals(tableList.get(j).getCode())) {
|
|
|
listMain.get(i).put("propKindName", tableList.get(j).getTitle());
|
|
|
}
|
|
|
}
|
|
@@ -1324,7 +1268,6 @@ public class SubInfoExportController extends BaseController {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 导出调度表
|
|
|
*
|
|
@@ -1448,9 +1391,4 @@ public class SubInfoExportController extends BaseController {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|