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