Browse Source

编辑表导出修改

master
CMM 1 year ago
parent
commit
3c35a43175
3 changed files with 33 additions and 2 deletions
  1. +32
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/AnnualPlanLibManage.java
  2. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java
  3. BIN
      pmapi/src/main/resources/template/丽水市2023年数字化项目年度计划编辑表(空).xls

+ 32
- 1
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/AnnualPlanLibManage.java View File

@@ -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();


+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java View File

@@ -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更新到项目库中对应的项目下


BIN
pmapi/src/main/resources/template/丽水市2023年数字化项目年度计划编辑表(空).xls View File


Loading…
Cancel
Save