|
@@ -334,7 +334,7 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
|
|
R r = this.getRectifyReportData(map);
|
|
R r = this.getRectifyReportData(map);
|
|
Object depttypeobj = map.getOrDefault("depttype", "施工部门");
|
|
Object depttypeobj = map.getOrDefault("depttype", "施工部门");
|
|
Object projnameobj = map.get("projname");
|
|
Object projnameobj = map.get("projname");
|
|
- if(ObjectUtil.isEmpty(depttypeobj) || ObjectUtil.isEmpty(projnameobj)){
|
|
|
|
|
|
+ if (ObjectUtil.isEmpty(depttypeobj) || ObjectUtil.isEmpty(projnameobj)) {
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
String deptType = (String) depttypeobj;
|
|
String deptType = (String) depttypeobj;
|
|
@@ -342,17 +342,18 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
|
|
RectifyReportDto data = (RectifyReportDto) r.getData();
|
|
RectifyReportDto data = (RectifyReportDto) r.getData();
|
|
if (data != null) {
|
|
if (data != null) {
|
|
try {
|
|
try {
|
|
- if(!excelUtils.GetLicense()) {
|
|
|
|
|
|
+ if (!excelUtils.GetLicense()) {
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
Workbook workbook = new Workbook();
|
|
Workbook workbook = new Workbook();
|
|
WorksheetCollection worksheets = workbook.getWorksheets();
|
|
WorksheetCollection worksheets = workbook.getWorksheets();
|
|
Worksheet worksheet = worksheets.get(0);
|
|
Worksheet worksheet = worksheets.get(0);
|
|
Cells cells = worksheet.getCells();
|
|
Cells cells = worksheet.getCells();
|
|
- cells.setRowHeight(0,40);
|
|
|
|
|
|
+ cells.setRowHeight(0, 40);
|
|
cells.setColumnWidth(0, 20);
|
|
cells.setColumnWidth(0, 20);
|
|
cells.setColumnWidth(1, 20);
|
|
cells.setColumnWidth(1, 20);
|
|
List<String> noList = data.getNoList();
|
|
List<String> noList = data.getNoList();
|
|
|
|
+
|
|
// 设置列头
|
|
// 设置列头
|
|
cells.merge(1, 0, 2, 1);
|
|
cells.merge(1, 0, 2, 1);
|
|
cells.merge(1, 1, 2, 1);
|
|
cells.merge(1, 1, 2, 1);
|
|
@@ -384,7 +385,12 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
|
|
cells.get(0, 2).putValue(projName + "项目整改汇总文字版");
|
|
cells.get(0, 2).putValue(projName + "项目整改汇总文字版");
|
|
cells.get(1, 0).putValue("一级部门");
|
|
cells.get(1, 0).putValue("一级部门");
|
|
cells.get(1, 1).putValue(deptType);
|
|
cells.get(1, 1).putValue(deptType);
|
|
|
|
+
|
|
|
|
+ // 设置颜色列表
|
|
|
|
+ Color[] colors = {Color.fromArgb(210, 242, 210), Color.fromArgb(255, 255, 204)};
|
|
|
|
+
|
|
int colIndex = 2;
|
|
int colIndex = 2;
|
|
|
|
+ int colorIndex = 0;
|
|
for (String no : noList) {
|
|
for (String no : noList) {
|
|
cells.merge(1, colIndex, 1, 6);
|
|
cells.merge(1, colIndex, 1, 6);
|
|
cells.get(1, colIndex).putValue(no);
|
|
cells.get(1, colIndex).putValue(no);
|
|
@@ -394,16 +400,28 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
|
|
cells.get(2, colIndex + 3).putValue("关闭");
|
|
cells.get(2, colIndex + 3).putValue("关闭");
|
|
cells.get(2, colIndex + 4).putValue("未完成");
|
|
cells.get(2, colIndex + 4).putValue("未完成");
|
|
cells.get(2, colIndex + 5).putValue("待确认");
|
|
cells.get(2, colIndex + 5).putValue("待确认");
|
|
|
|
+
|
|
|
|
+ // 设置颜色
|
|
|
|
+ for (int i = 1; i <= 2; i++) {
|
|
|
|
+ for (int j = colIndex; j < colIndex + 6; j++) {
|
|
|
|
+ Style cellStyle = cells.get(i, j).getStyle();
|
|
|
|
+ cellStyle.setForegroundColor(colors[colorIndex % 2]);
|
|
|
|
+ cellStyle.setPattern(BackgroundType.SOLID);
|
|
|
|
+ cells.get(i, j).setStyle(cellStyle);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
colIndex += 6;
|
|
colIndex += 6;
|
|
|
|
+ colorIndex++;
|
|
}
|
|
}
|
|
cells.merge(0, 2, 1, noList.size() * 6);
|
|
cells.merge(0, 2, 1, noList.size() * 6);
|
|
|
|
+
|
|
// 填充数据
|
|
// 填充数据
|
|
int rowIndex = 3;
|
|
int rowIndex = 3;
|
|
for (RectifyDto row : data.getData()) {
|
|
for (RectifyDto row : data.getData()) {
|
|
cells.get(rowIndex, 0).putValue(row.getFirstdeptname());
|
|
cells.get(rowIndex, 0).putValue(row.getFirstdeptname());
|
|
cells.get(rowIndex, 1).putValue(row.getDeptname());
|
|
cells.get(rowIndex, 1).putValue(row.getDeptname());
|
|
|
|
|
|
- //List<Map<String, Object>> innerDataList = (List<Map<String, Object>>) row.getData();
|
|
|
|
List<RectifyMachineDto> innerDataList = row.getData();
|
|
List<RectifyMachineDto> innerDataList = row.getData();
|
|
colIndex = 2;
|
|
colIndex = 2;
|
|
for (String no : noList) {
|
|
for (String no : noList) {
|
|
@@ -418,37 +436,57 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
|
|
cells.get(rowIndex, colIndex + 3).putValue(rectifyMachineDto.getClosedCount());
|
|
cells.get(rowIndex, colIndex + 3).putValue(rectifyMachineDto.getClosedCount());
|
|
cells.get(rowIndex, colIndex + 4).putValue(rectifyMachineDto.getUnfinishedCount());
|
|
cells.get(rowIndex, colIndex + 4).putValue(rectifyMachineDto.getUnfinishedCount());
|
|
cells.get(rowIndex, colIndex + 5).putValue(rectifyMachineDto.getTbcCount());
|
|
cells.get(rowIndex, colIndex + 5).putValue(rectifyMachineDto.getTbcCount());
|
|
|
|
+ // 设置颜色
|
|
|
|
+ for (int j = colIndex; j < colIndex + 6; j++) {
|
|
|
|
+ Style cellStyle = workbook.createStyle();
|
|
|
|
+ cellStyle.setForegroundColor(colors[colorIndex % 2]);
|
|
|
|
+ cellStyle.setPattern(BackgroundType.SOLID);
|
|
|
|
+ cells.get(rowIndex, j).setStyle(cellStyle);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
colIndex += 6;
|
|
colIndex += 6;
|
|
|
|
+ colorIndex++;
|
|
}
|
|
}
|
|
rowIndex++;
|
|
rowIndex++;
|
|
}
|
|
}
|
|
- // 设置列头样式
|
|
|
|
- Style style = workbook.createStyle();
|
|
|
|
-// style.getFont().setBold(true);
|
|
|
|
-// style.setPattern(BackgroundType.SOLID);
|
|
|
|
-// 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());
|
|
|
|
- Color color = Color.fromArgb(255, 221, 155);
|
|
|
|
|
|
+
|
|
|
|
+ // 设置公共样式
|
|
|
|
+ Style commonStyle = workbook.createStyle();
|
|
|
|
+ commonStyle.setHorizontalAlignment(TextAlignmentType.CENTER);
|
|
|
|
+ commonStyle.setVerticalAlignment(TextAlignmentType.CENTER);
|
|
|
|
+ commonStyle.setBorder(BorderType.TOP_BORDER, CellBorderType.THIN, Color.getBlack());
|
|
|
|
+ commonStyle.setBorder(BorderType.BOTTOM_BORDER, CellBorderType.THIN, Color.getBlack());
|
|
|
|
+ commonStyle.setBorder(BorderType.LEFT_BORDER, CellBorderType.THIN, Color.getBlack());
|
|
|
|
+ commonStyle.setBorder(BorderType.RIGHT_BORDER, CellBorderType.THIN, Color.getBlack());
|
|
|
|
+
|
|
|
|
+ // 应用公共样式
|
|
for (int i = 0; i < colIndex; i++) {
|
|
for (int i = 0; i < colIndex; i++) {
|
|
- //cells.get(1, i).setStyle(style);
|
|
|
|
for (int x = 0; x < rowIndex; x++) {
|
|
for (int x = 0; x < rowIndex; x++) {
|
|
- cells.get(x, i).setStyle(style);
|
|
|
|
|
|
+ Style cellStyle = cells.get(x, i).getStyle();
|
|
|
|
+ commonStyle.setPattern(BackgroundType.SOLID);
|
|
|
|
+ commonStyle.setForegroundColor(cellStyle.getForegroundColor());
|
|
|
|
+ cells.get(x, i).setStyle(commonStyle);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- style.getFont().setBold(true);
|
|
|
|
- style.getFont().setSize(20);
|
|
|
|
- cells.get(0, 1).setStyle(style);
|
|
|
|
- cells.get(0, 2).setStyle(style);
|
|
|
|
|
|
+
|
|
|
|
+ // 一级部门和deptType列样式
|
|
|
|
+ Style headerStyle = workbook.createStyle();
|
|
|
|
+ headerStyle.getFont().setBold(true);
|
|
|
|
+ headerStyle.getFont().setSize(20);
|
|
|
|
+ headerStyle.setHorizontalAlignment(TextAlignmentType.CENTER);
|
|
|
|
+ headerStyle.setVerticalAlignment(TextAlignmentType.CENTER);
|
|
|
|
+ headerStyle.setBorder(BorderType.TOP_BORDER, CellBorderType.THIN, Color.getBlack());
|
|
|
|
+ headerStyle.setBorder(BorderType.BOTTOM_BORDER, CellBorderType.THIN, Color.getBlack());
|
|
|
|
+ headerStyle.setBorder(BorderType.LEFT_BORDER, CellBorderType.THIN, Color.getBlack());
|
|
|
|
+ headerStyle.setBorder(BorderType.RIGHT_BORDER, CellBorderType.THIN, Color.getBlack());
|
|
|
|
+
|
|
|
|
+ cells.get(0, 1).setStyle(headerStyle);
|
|
|
|
+ cells.get(0, 2).setStyle(headerStyle);
|
|
|
|
+
|
|
response.addHeader("Pargam", "no-cache");
|
|
response.addHeader("Pargam", "no-cache");
|
|
response.addHeader("Cache-Control", "no-cache");
|
|
response.addHeader("Cache-Control", "no-cache");
|
|
response.setContentType("application/octet-stream;charset=ISO8859-1");
|
|
response.setContentType("application/octet-stream;charset=ISO8859-1");
|
|
- response.setHeader("Content-Disposition", "attachment;filename=整改清单");
|
|
|
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=整改清单.xlsx");
|
|
workbook.save(response.getOutputStream(), SaveFormat.XLSX);
|
|
workbook.save(response.getOutputStream(), SaveFormat.XLSX);
|
|
workbook.dispose();
|
|
workbook.dispose();
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|