Compare commits

...

2 Commits

Author SHA1 Message Date
862efcfabd Merge remote-tracking branch 'origin/0.8.X' into 0.8.X 2026-03-28 09:27:38 +08:00
d51b555fa2 fix(excel): 修复排产表导出功能中的日期格式和表格合并问题
- 添加SimpleDateFormat用于日期格式化处理
- 将计划日期格式化为yyyy-MM-dd格式避免显示异常
- 修正表格合并区域从38列扩展到40列
- 为整个合并区域的所有单元格应用标题样式
- 确保合并单元格后样式的一致性显示
2026-03-28 09:27:30 +08:00

View File

@@ -30,6 +30,7 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Map;
import java.util.Collection;
@@ -142,12 +143,17 @@ public class ApsPlanSheetServiceImpl implements IApsPlanSheetService {
Long planSheetId = req.getPlanSheetId();
if (planSheetId != null) {
ApsPlanSheetVo planSheet = queryById(planSheetId);
t0.setCellValue(planSheet.getPlanDate().toString() + "————" + planSheet.getLineName() + "————" + planSheet.getPlanCode());
// 格式化日期
String dateStr = "";
if (planSheet.getPlanDate() != null) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
dateStr = sdf.format(planSheet.getPlanDate());
}
t0.setCellValue(dateStr + "————" + planSheet.getLineName() + "————" + planSheet.getPlanCode());
} else {
t0.setCellValue("快速排产表");
}
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 38));
// 1. 先创建标题样式
CellStyle titleStyle = wb.createCellStyle();
titleStyle.setAlignment(HorizontalAlignment.CENTER);
titleStyle.setVerticalAlignment(VerticalAlignment.CENTER);
@@ -155,7 +161,19 @@ public class ApsPlanSheetServiceImpl implements IApsPlanSheetService {
titleFont.setBold(true);
titleFont.setFontHeightInPoints((short) 15);
titleStyle.setFont(titleFont);
t0.setCellStyle(titleStyle);
// 2. 合并区域
CellRangeAddress titleRegion = new CellRangeAddress(0, 0, 0, 40);
sheet.addMergedRegion(titleRegion);
// 3. 给【整个合并区域】设置样式
for (int i = titleRegion.getFirstColumn(); i <= titleRegion.getLastColumn(); i++) {
Cell cell = title.getCell(i);
if (cell == null) {
cell = title.createCell(i);
}
cell.setCellStyle(titleStyle);
}
String[] headers = new String[]{
"产线", "排产日期", "排产单号", "排产类型", "排产人", "修改人", "计划备注",