Browse Source

fit:审计台帐导出

master
pengwei 5 months ago
parent
commit
284de2dbe3
  1. 53
      src/main/java/com/biutag/supervision/controller/books/NegativeBookController.java
  2. 6
      src/main/java/com/biutag/supervision/pojo/vo/NegativeAuditExportVo.java

53
src/main/java/com/biutag/supervision/controller/books/NegativeBookController.java

@ -3,7 +3,6 @@ package com.biutag.supervision.controller.books;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.io.IoUtil; import cn.hutool.core.io.IoUtil;
import cn.hutool.core.stream.CollectorUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.metadata.data.ImageData; import com.alibaba.excel.metadata.data.ImageData;
@ -20,7 +19,6 @@ import com.biutag.supervision.pojo.vo.*;
import com.biutag.supervision.service.*; import com.biutag.supervision.service.*;
import com.biutag.supervision.util.DownloadAndZip; import com.biutag.supervision.util.DownloadAndZip;
import com.biutag.supervision.util.ImgUtils; import com.biutag.supervision.util.ImgUtils;
import dm.jdbc.util.FileUtil;
import dm.jdbc.util.StringUtil; import dm.jdbc.util.StringUtil;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@ -326,10 +324,12 @@ public class NegativeBookController {
List<NegativeBlame> negativeBlames = emptyFlag ? new ArrayList<>() : blameService.listByNegativeIds(negativeIds); List<NegativeBlame> negativeBlames = emptyFlag ? new ArrayList<>() : blameService.listByNegativeIds(negativeIds);
List<NegativeProblemRelation> problemRelations = emptyFlag ? new ArrayList<>() : negativeProblemRelationService.list(negativeIds); List<NegativeProblemRelation> problemRelations = emptyFlag ? new ArrayList<>() : negativeProblemRelationService.list(negativeIds);
List<NegativeFile> negativeFiles = emptyFlag ? new ArrayList<>() : negativeFileService.listByNegativeIds(negativeIds); List<NegativeFile> negativeFiles = emptyFlag ? new ArrayList<>() : negativeFileService.listByNegativeIds(negativeIds);
AtomicInteger index = new AtomicInteger(1);
List<NegativeAuditExportVo> list = pages.getRecords().stream().map((item) -> { List<NegativeAuditExportVo> list = pages.getRecords().stream().map((item) -> {
NegativeAuditExportVo vo = new NegativeAuditExportVo(); NegativeAuditExportVo vo = new NegativeAuditExportVo();
BeanUtil.copyProperties(item, vo); BeanUtil.copyProperties(item, vo);
int indexNumber = index.getAndIncrement();
vo.setIndexNumber(indexNumber);
vo.setProblems(problemRelations.stream() vo.setProblems(problemRelations.stream()
.filter(problem -> StrUtil.isNotBlank(problem.getOneLevelContent()) && StrUtil.isNotBlank(problem.getTwoLevelContent()) && StrUtil.isNotBlank(problem.getThreeLevelContentOther())) .filter(problem -> StrUtil.isNotBlank(problem.getOneLevelContent()) && StrUtil.isNotBlank(problem.getTwoLevelContent()) && StrUtil.isNotBlank(problem.getThreeLevelContentOther()))
.map(problem -> String.format("%s / %s / %s", problem.getOneLevelContent(), problem.getTwoLevelContent(), problem.getThreeLevelContentOther())) .map(problem -> String.format("%s / %s / %s", problem.getOneLevelContent(), problem.getTwoLevelContent(), problem.getThreeLevelContentOther()))
@ -338,28 +338,28 @@ public class NegativeBookController {
.filter(blame -> StrUtil.isNotBlank(blame.getBlameName()) && StrUtil.isNotBlank(blame.getBlameEmpNo())) .filter(blame -> StrUtil.isNotBlank(blame.getBlameName()) && StrUtil.isNotBlank(blame.getBlameEmpNo()))
.map(blame -> blame.getBlameName() + "-" + blame.getBlameEmpNo()) .map(blame -> blame.getBlameName() + "-" + blame.getBlameEmpNo())
.collect(Collectors.joining("、"))); .collect(Collectors.joining("、")));
AtomicInteger i = new AtomicInteger(0); // AtomicInteger i = new AtomicInteger(0);
List<ImageData> imageDataList = negativeFiles.stream().filter(file -> item.getId().equals(file.getNegtiveId())) // List<ImageData> imageDataList = negativeFiles.stream().filter(file -> item.getId().equals(file.getNegtiveId()))
// 过滤图片 // // 过滤图片
.filter(file -> ImgUtils.isImg(file.getFileName())).map(file -> { // .filter(file -> ImgUtils.isImg(file.getFileName())).map(file -> {
// 下载文件 // // 下载文件
InputStream is = fileService.download(file.getFilePath()); // InputStream is = fileService.download(file.getFilePath());
byte[] bytes = IoUtil.readBytes(is); // byte[] bytes = IoUtil.readBytes(is);
ImageData imageData = new ImageData(); // ImageData imageData = new ImageData();
imageData.setImage(bytes); // imageData.setImage(bytes);
imageData.setTop(0); // imageData.setTop(0);
imageData.setBottom(0); // imageData.setBottom(0);
imageData.setLeft(i.get() * 10 + (i.get() == 0 ? 0 : 5)); // 0 15 25 // imageData.setLeft(i.get() * 10 + (i.get() == 0 ? 0 : 5)); // 0 15 25
System.out.println(i.get() * 10 + (i.get() == 0 ? 0 : 5)); // System.out.println(i.get() * 10 + (i.get() == 0 ? 0 : 5));
imageData.setRight(i.get() * 15 + 10); // 10 25 35 // imageData.setRight(i.get() * 15 + 10); // 10 25 35
System.out.println(i.get() * 15 + 10); // System.out.println(i.get() * 15 + 10);
System.out.println("==================="); // System.out.println("===================");
i.getAndIncrement(); // i.getAndIncrement();
return imageData; // return imageData;
}).toList(); // }).toList();
WriteCellData<Void> writeCellData = new WriteCellData<>(); // WriteCellData<Void> writeCellData = new WriteCellData<>();
writeCellData.setImageDataList(imageDataList); // writeCellData.setImageDataList(imageDataList);
vo.setFiles(writeCellData); // vo.setFiles(writeCellData);
return vo; return vo;
}).toList(); }).toList();
String headerValue = "attachment; filename=\"" + URLEncoder.encode("审计监督数据台账.xlsx", "UTF-8") + "\""; String headerValue = "attachment; filename=\"" + URLEncoder.encode("审计监督数据台账.xlsx", "UTF-8") + "\"";
@ -390,7 +390,6 @@ public class NegativeBookController {
String serialNumber =String.valueOf(negativeIds.indexOf(s) +1); String serialNumber =String.valueOf(negativeIds.indexOf(s) +1);
//问题附件 //问题附件
List<NegativeFile> fileUrls = maps.get(s); List<NegativeFile> fileUrls = maps.get(s);
try { try {
Files.createDirectories(Paths.get(tempDir)); Files.createDirectories(Paths.get(tempDir));
@ -423,7 +422,7 @@ public class NegativeBookController {
log.info("压缩包下载完成---压缩包路径:"+zipFilePath); log.info("压缩包下载完成---压缩包路径:"+zipFilePath);
//删除压缩包 //删除压缩包
if(Files.exists(zipPath)){ if(Files.exists(zipPath)){
Files.delete(zipPath);
} }
} }
} }

6
src/main/java/com/biutag/supervision/pojo/vo/NegativeAuditExportVo.java

@ -47,9 +47,9 @@ public class NegativeAuditExportVo implements Serializable {
@ExcelProperty("整改情况") @ExcelProperty("整改情况")
private String rectifyDesc; private String rectifyDesc;
@ExcelProperty("整改佐证材料") // @ExcelProperty("整改佐证材料")
@ColumnWidth(40) // @ColumnWidth(40)
private WriteCellData<Void> files; // private WriteCellData<Void> files;
@ExcelProperty("涉及单位") @ExcelProperty("涉及单位")
private String involveDepartName; private String involveDepartName;

Loading…
Cancel
Save