|
@@ -34,10 +34,14 @@ import com.rongwei.rwcommonentity.commonservers.domain.SysFileItemDo;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
+import org.springframework.core.io.ClassPathResource;
|
|
|
+import org.springframework.core.io.Resource;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
+import java.io.File;
|
|
|
+import java.io.InputStream;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -244,10 +248,12 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
|
|
|
public int exportRectifyReportData(Map<String, Object> map, HttpServletResponse response) {
|
|
|
R r = this.getRectifyReportData(map);
|
|
|
Object depttypeobj = map.getOrDefault("depttype", "施工部门");
|
|
|
- if(ObjectUtil.isEmpty(depttypeobj)){
|
|
|
+ Object projnameobj = map.get("projname");
|
|
|
+ if(ObjectUtil.isEmpty(depttypeobj) || ObjectUtil.isEmpty(projnameobj)){
|
|
|
return 0;
|
|
|
}
|
|
|
String deptType = (String) depttypeobj;
|
|
|
+ String projName = (String) projnameobj;
|
|
|
RectifyReportDto data = (RectifyReportDto) r.getData();
|
|
|
if (data != null) {
|
|
|
try {
|
|
@@ -258,24 +264,54 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
|
|
|
WorksheetCollection worksheets = workbook.getWorksheets();
|
|
|
Worksheet worksheet = worksheets.get(0);
|
|
|
Cells cells = worksheet.getCells();
|
|
|
+ cells.setRowHeight(0,40);
|
|
|
+ cells.setColumnWidth(0, 20);
|
|
|
+ cells.setColumnWidth(1, 20);
|
|
|
List<String> noList = data.getNoList();
|
|
|
// 设置列头
|
|
|
- cells.merge(0, 0, 2, 1);
|
|
|
- cells.merge(0, 1, 2, 1);
|
|
|
- cells.get(0, 0).putValue("一级部门");
|
|
|
- cells.get(0, 1).putValue(deptType);
|
|
|
+ cells.merge(1, 0, 2, 1);
|
|
|
+ cells.merge(1, 1, 2, 1);
|
|
|
+ Resource resource = new ClassPathResource("/img/zpmc.png");
|
|
|
+ InputStream inputStream = resource.getInputStream();
|
|
|
+
|
|
|
+ int pictureIndex = worksheet.getPictures().add(0, 0, inputStream);
|
|
|
+ Picture picture = worksheet.getPictures().get(pictureIndex);
|
|
|
+ double cellWidth = worksheet.getCells().getColumnWidthPixel(0);
|
|
|
+ double cellHeight = worksheet.getCells().getRowHeightPixel(0);
|
|
|
+
|
|
|
+ // 获取图片的宽高
|
|
|
+ int pictureWidth = picture.getWidth();
|
|
|
+ int pictureHeight = picture.getHeight();
|
|
|
+
|
|
|
+ // 计算图片在单元格中的偏移量
|
|
|
+ int offsetX = (int) ((cellWidth - pictureWidth));
|
|
|
+ int offsetY = (int) ((cellHeight - pictureHeight));
|
|
|
+
|
|
|
+ // 确保图片在单元格内居中
|
|
|
+ picture.setLeft(offsetX);
|
|
|
+ picture.setTop(offsetY);
|
|
|
+
|
|
|
+ // 将单元格宽度和高度调整为适合图片的大小
|
|
|
+ worksheet.getCells().setColumnWidthPixel(0, Math.max(pictureWidth, (int) cellWidth));
|
|
|
+ worksheet.getCells().setRowHeightPixel(0, Math.max(pictureHeight, (int) cellHeight));
|
|
|
+
|
|
|
+ cells.get(0, 1).putValue("QA");
|
|
|
+ cells.get(0, 2).putValue(projName + "项目整改汇总文字版");
|
|
|
+ cells.get(1, 0).putValue("一级部门");
|
|
|
+ cells.get(1, 1).putValue(deptType);
|
|
|
int colIndex = 2;
|
|
|
for (String no : noList) {
|
|
|
- cells.merge(0, colIndex, 1, 6);
|
|
|
- cells.get(0, colIndex).putValue(no);
|
|
|
- cells.get(1, colIndex).putValue("整改总数");
|
|
|
- cells.get(1, colIndex + 1).putValue("完成率1");
|
|
|
- cells.get(1, colIndex + 2).putValue("完成率2");
|
|
|
- cells.get(1, colIndex + 3).putValue("关闭");
|
|
|
- cells.get(1, colIndex + 4).putValue("未完成");
|
|
|
- cells.get(1, colIndex + 5).putValue("待确认");
|
|
|
+ cells.merge(1, colIndex, 1, 6);
|
|
|
+ cells.get(1, colIndex).putValue(no);
|
|
|
+ cells.get(2, colIndex).putValue("整改总数");
|
|
|
+ cells.get(2, colIndex + 1).putValue("完成率1");
|
|
|
+ cells.get(2, colIndex + 2).putValue("完成率2");
|
|
|
+ cells.get(2, colIndex + 3).putValue("关闭");
|
|
|
+ cells.get(2, colIndex + 4).putValue("未完成");
|
|
|
+ cells.get(2, colIndex + 5).putValue("待确认");
|
|
|
colIndex += 6;
|
|
|
}
|
|
|
+ cells.merge(0, 2, 1, noList.size() * 6);
|
|
|
// 填充数据
|
|
|
int rowIndex = 2;
|
|
|
for (RectifyDto row : data.getData()) {
|
|
@@ -309,12 +345,20 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
|
|
|
// style.setForegroundColor(Color.getLightGray());
|
|
|
style.setHorizontalAlignment(TextAlignmentType.CENTER);
|
|
|
style.setVerticalAlignment(TextAlignmentType.CENTER);
|
|
|
+ style.setBorder(BorderType.TOP_BORDER, CellBorderType.THIN, Color.getBlack());
|
|
|
+ style.setBorder(BorderType.BOTTOM_BORDER, CellBorderType.THIN, Color.getBlack());
|
|
|
+ style.setBorder(BorderType.LEFT_BORDER, CellBorderType.THIN, Color.getBlack());
|
|
|
+ style.setBorder(BorderType.RIGHT_BORDER, CellBorderType.THIN, Color.getBlack());
|
|
|
for (int i = 0; i < colIndex; i++) {
|
|
|
//cells.get(1, i).setStyle(style);
|
|
|
for (int x = 0; x < rowIndex; x++) {
|
|
|
cells.get(x, i).setStyle(style);
|
|
|
}
|
|
|
}
|
|
|
+ style.getFont().setBold(true);
|
|
|
+ style.getFont().setSize(20);
|
|
|
+ cells.get(0, 1).setStyle(style);
|
|
|
+ cells.get(0, 2).setStyle(style);
|
|
|
response.addHeader("Pargam", "no-cache");
|
|
|
response.addHeader("Cache-Control", "no-cache");
|
|
|
response.setContentType("application/octet-stream;charset=ISO8859-1");
|