diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/AnnualPlanLibManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/AnnualPlanLibManage.java index 05ecd4c..6dbe71e 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/AnnualPlanLibManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/AnnualPlanLibManage.java @@ -6,6 +6,7 @@ import cn.afterturn.easypoi.excel.entity.ImportParams; import cn.afterturn.easypoi.excel.entity.TemplateExportParams; import cn.hutool.core.bean.BeanUtil; import cn.hutool.poi.excel.ExcelUtil; +import com.alibaba.excel.EasyExcel; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -22,6 +23,7 @@ import com.ningdatech.pmapi.common.helper.UserInfoHelper; import com.ningdatech.pmapi.common.model.entity.ExcelExportWriter; import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils; import com.ningdatech.pmapi.common.util.ExcelDownUtil; +import com.ningdatech.pmapi.common.util.ExcelExportStyle; import com.ningdatech.pmapi.datascope.model.DataScopeDTO; import com.ningdatech.pmapi.datascope.utils.DataScopeUtil; import com.ningdatech.pmapi.expert.constant.ExpertUserInfoSensitiveFieldEnum; @@ -54,9 +56,14 @@ import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; +import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import java.io.*; import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; @@ -399,7 +406,31 @@ public class AnnualPlanLibManage { map.put("mapList1", null); Workbook workbook = ExcelExportUtil.exportExcel(temp, map); if (workbook == null) { - throw new BizException("读取模板失败!"); + // 输出空模板 + // 获取本地目录的年度计划编辑表空Excel模板 + String emptyTemplate = "丽水市" + year + "年数字化项目年度计划编辑表(空)"; + try { + InputStream templateInputStream = + this.getClass().getClassLoader().getResourceAsStream("template" + File.separator + emptyTemplate + ".xls"); + + OutputStream outputStream = response.getOutputStream(); + // 设置要下载的文件的名称 + response.setHeader("Content-disposition", "attachment;fileName=" + new String(templateName.getBytes("UTF-8"),"ISO8859-1")); + // 设置文件的MIME类型 + response.setContentType("application/vnd.ms-excel;charset=UTF-8"); + + byte[] b = new byte[2048]; + int len; + while ((len = templateInputStream.read(b)) != -1) { + outputStream.write(b, 0, len); + } + templateInputStream.close(); + outputStream.flush(); + outputStream.close(); + } catch (IOException e) { + throw new BizException("读取模板失败!"); + } + return; } // 重置响应对象 response.reset(); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java index 0b1767f..27e3e55 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java @@ -431,7 +431,7 @@ public class TodoCenterManage { // 调用盖章接口,获取盖章后返回的pdf文件字符数组 byte[] signPdf = IRSAPIRequest.createSignPdf(signReq); // 转换成MultipartFile - MultipartFile multipartFile = new MockMultipartFile("file", originalFileName + ".pdf", "application/pdf", signPdf); + MultipartFile multipartFile = new MockMultipartFile("file", originalFileName, "application/pdf", signPdf); // 上传OSS FileResultVO resultVo = fileService.upload(multipartFile, "default"); // 将返回的文件ID更新到项目库中对应的项目下 diff --git a/pmapi/src/main/resources/template/丽水市2023年数字化项目年度计划编辑表(空).xls b/pmapi/src/main/resources/template/丽水市2023年数字化项目年度计划编辑表(空).xls new file mode 100644 index 0000000..7317bac Binary files /dev/null and b/pmapi/src/main/resources/template/丽水市2023年数字化项目年度计划编辑表(空).xls differ