设计出图bug修改

This commit is contained in:
2025-09-19 18:26:27 +08:00
parent 48a08ac729
commit c7400d25fe
3 changed files with 32 additions and 18 deletions

View File

@ -284,13 +284,11 @@ public class DesCollectServiceImpl extends ServiceImpl<DesCollectMapper, DesColl
public void exportExcelByDeptId(Long deptId, HttpServletResponse response) {
// 1. 从数据库查询下拉选项
Map<Long, String> userIdToNameMapByDept = sysUserService.getUserIdToNameMapByDept(deptId);
if (userIdToNameMapByDept.isEmpty()) {
throw new ServiceException("部门下人员为空!!");
}
// 2. 设置响应头
// 设置响应头指定Excel格式和下载文件名
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
response.setHeader("Content-Disposition", "attachment; filename="+URLEncoder.encode("收资清单模板.xlsx", StandardCharsets.UTF_8));
Workbook workbook = new XSSFWorkbook();
// 创建主 Sheet 和隐藏 Sheet
@ -375,6 +373,11 @@ public class DesCollectServiceImpl extends ServiceImpl<DesCollectMapper, DesColl
mainSheet.setColumnWidth(2, 20 * 200);
mainSheet.setColumnWidth(3, 20 * 200);
// 2. 设置响应头
// 设置响应头指定Excel格式和下载文件名
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
response.setHeader("Content-Disposition", "attachment; filename="+URLEncoder.encode("收资清单模板.xlsx", StandardCharsets.UTF_8));
// 直接写入响应输出流
try {
workbook.write(response.getOutputStream());

View File

@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.FormulaParseException;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddressList;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
@ -436,13 +437,13 @@ public class DesVolumeCatalogServiceImpl extends ServiceImpl<DesVolumeCatalogMap
DesUserBo desUserBo = new DesUserBo();
desUserBo.setProjectId(projectId);
Map<String, String> uniqueMajors = desUserService.getUserMajor(desUserBo);
if (uniqueMajors == null || uniqueMajors.isEmpty()) {
throw new ServiceException("请完成专业配置!!",502);
}
Map<String, String> userList = desUserService.getUserList(desUserBo);
// 2. 设置响应头
// 设置响应头指定Excel格式和下载文件名
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode("卷册目录模板.xlsx", StandardCharsets.UTF_8));
if (userList == null || userList.isEmpty()) {
throw new ServiceException("请完成人员任命!",502);
}
Workbook workbook = new XSSFWorkbook();
// 创建主 Sheet 和隐藏 Sheet
@ -556,7 +557,11 @@ public class DesVolumeCatalogServiceImpl extends ServiceImpl<DesVolumeCatalogMap
mainSheet.setColumnWidth(5, 20 * 200);
mainSheet.setColumnWidth(6, 20 * 200);
mainSheet.setColumnWidth(7, 20 * 200);
// 2. 设置响应头
// 设置响应头指定Excel格式和下载文件名
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode("卷册目录模板.xlsx", StandardCharsets.UTF_8));
// 直接写入响应输出流
try {
workbook.write(response.getOutputStream());

View File

@ -211,19 +211,19 @@ public class PgsConstructionSchedulePlanServiceImpl extends ServiceImpl<PgsConst
DesUserBo desUserBo = new DesUserBo();
desUserBo.setProjectId(projectId);
Map<Long, String> projectStructureMap = projectService.getStructureAsList(projectId);
if (projectStructureMap.isEmpty()) {
throw new ServiceException("获取项目列表失败,项目为空!!!");
}
List<SysDictDataVo> dictDataVos = dictDataService.selectByDictType("project_construction_status");
if (dictDataVos == null || dictDataVos.isEmpty()) {
throw new ServiceException("项目施工状态为空!!");
}
Map<String, String> statusMap = new HashMap<>();
for (SysDictDataVo vo : dictDataVos) {
statusMap.put(vo.getDictValue(), vo.getDictLabel());
}
// 2. 设置响应头
// 设置响应头指定Excel格式和下载文件名
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode("施工里程碑计划模版.xlsx", StandardCharsets.UTF_8));
Workbook workbook = new XSSFWorkbook();
// 创建主 Sheet 和隐藏 Sheet
Sheet mainSheet = workbook.createSheet("施工里程碑计划模版");
@ -345,6 +345,12 @@ public class PgsConstructionSchedulePlanServiceImpl extends ServiceImpl<PgsConst
mainSheet.setColumnWidth(9, 20 * 200);
mainSheet.setColumnWidth(10, 20 * 200);
// 2. 设置响应头
// 设置响应头指定Excel格式和下载文件名
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode("施工里程碑计划模版.xlsx", StandardCharsets.UTF_8));
// 直接写入响应输出流
try {
workbook.write(response.getOutputStream());