|
@@ -9,9 +9,7 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.aspose.cells.*;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.rongwei.bscommon.sys.dao.LuckysheetDao;
|
|
|
import com.rongwei.bscommon.sys.feign.LuckySheetService;
|
|
|
import com.rongwei.bscommon.sys.service.*;
|
|
@@ -23,7 +21,6 @@ import com.rongwei.bscommon.sys.dao.ZhcxProjectManageDao;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.rongwei.bsentity.dto.*;
|
|
|
import com.rongwei.bsentity.dto.project.*;
|
|
|
-import com.rongwei.bsentity.vo.RectifySnapTotalVo;
|
|
|
import com.rongwei.bsentity.vo.RectifySnapVo;
|
|
|
import com.rongwei.bsentity.vo.ZhcxProjectRectifyMachineVo;
|
|
|
import com.rongwei.bsentity.vo.ZhcxProjectRectifyVo;
|
|
@@ -101,6 +98,13 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
|
|
|
Color.fromArgb(255, 255, 102, 0),
|
|
|
Color.fromArgb(255, 51, 153, 102),
|
|
|
Color.fromArgb(255, 255, 0, 0)};
|
|
|
+ //整改清单颜色
|
|
|
+ private static final Color[] RECTIFY_LIST_COLORS = {
|
|
|
+ Color.fromArgb(255, 255, 204),
|
|
|
+ Color.fromArgb(255, 217, 255),
|
|
|
+ Color.fromArgb(204, 255, 204),
|
|
|
+ Color.fromArgb(51, 102, 255)
|
|
|
+ };
|
|
|
/**
|
|
|
* 生成汇总文件
|
|
|
*
|
|
@@ -1955,4 +1959,258 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
|
|
|
public void deleteSnap() {
|
|
|
zhcxProjectManageDao.deleteSnap();
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int exportRectifyListData(Map<String, Object> map, HttpServletResponse response) {
|
|
|
+ Object batchIdObj = map.get("batchId");
|
|
|
+ if (ObjectUtil.isEmpty(batchIdObj)) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ R r = this.getRectifyListData(map);
|
|
|
+ Object projnameobj = map.get("projname");
|
|
|
+ if (ObjectUtil.isEmpty(projnameobj)) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ String projname = (String) projnameobj;
|
|
|
+ RectifyListDto data = (RectifyListDto) r.getData();
|
|
|
+ Workbook workbook = new Workbook();
|
|
|
+ WorksheetCollection worksheets = workbook.getWorksheets();
|
|
|
+ Worksheet worksheet = worksheets.get(0);
|
|
|
+ if (data != null) {
|
|
|
+ if(!excelUtils.GetLicense()) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ Cells cells = worksheet.getCells();
|
|
|
+ //设置开始列头
|
|
|
+ setRectifyListFrozenHeader(projname,cells);
|
|
|
+ // 设置颜色列表
|
|
|
+ List<String> noList = data.getNoList();
|
|
|
+ //设置动态列
|
|
|
+ setRectifyListTrendsHeader(cells, noList);
|
|
|
+ //设置结束列头
|
|
|
+ setRectifyListFrozenEndHeader(cells,noList);
|
|
|
+ // 填充数据
|
|
|
+ int rowIndex = 3;
|
|
|
+ int colIndex = 4;
|
|
|
+ for (ZhcxProjectRectifyVo row : data.getData()) {
|
|
|
+ //填充固定列头数据
|
|
|
+ fillFrozenData(cells, rowIndex, row,noList);
|
|
|
+ colIndex = 4;
|
|
|
+ //填充动态数据和颜色 返回索引
|
|
|
+ colIndex = fillRectifyListTrendsData(cells,colIndex, noList, rowIndex, row);
|
|
|
+ rowIndex++;
|
|
|
+ }
|
|
|
+ // 设置公共样式
|
|
|
+ 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 + 6; i++) {
|
|
|
+ for (int x = 0; x < rowIndex; x++) {
|
|
|
+ Style cellStyle = cells.get(x, i).getStyle();
|
|
|
+ if (i == 3) {
|
|
|
+ commonStyle.setTextWrapped(true);
|
|
|
+ } else {
|
|
|
+ commonStyle.setTextWrapped(false);
|
|
|
+ }
|
|
|
+ commonStyle.setPattern(BackgroundType.SOLID);
|
|
|
+ commonStyle.setForegroundColor(cellStyle.getForegroundColor());
|
|
|
+ commonStyle.getFont().setColor(cellStyle.getFont().getColor());
|
|
|
+ cells.get(x, i).setStyle(commonStyle);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 一级部门和deptType列样式
|
|
|
+ Style headerStyle = workbook.createStyle();
|
|
|
+ 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, 0).setStyle(headerStyle);
|
|
|
+ cells.get(0, 1).setStyle(headerStyle);
|
|
|
+ cells.get(0, 2).setStyle(headerStyle);
|
|
|
+ cells.get(0, 3).setStyle(headerStyle);
|
|
|
+ cells.get(0, colIndex).setStyle(headerStyle);
|
|
|
+ cells.get(0, (colIndex+1)).setStyle(headerStyle);
|
|
|
+ cells.get(0, (colIndex+2)).setStyle(headerStyle);
|
|
|
+ cells.get(0, (colIndex+3)).setStyle(headerStyle);
|
|
|
+ cells.get(0, (colIndex+4)).setStyle(headerStyle);
|
|
|
+ cells.get(0, (colIndex+5)).setStyle(headerStyle);
|
|
|
+
|
|
|
+ //this.exportRectifyReportDataInSummary(dto, response);
|
|
|
+ worksheet.setName("整改清单");
|
|
|
+ //Worksheet worksheet1 = worksheets.add("整改统计");
|
|
|
+ cells.merge(0, 0, 1, 10+noList.size()*6);
|
|
|
+ Style cellStyle = cells.get(0, 0).getStyle();
|
|
|
+ cellStyle.setForegroundColor(RECTIFY_LIST_COLORS[3]);
|
|
|
+ cellStyle.setPattern(BackgroundType.SOLID);
|
|
|
+ cellStyle.getFont().setBold(true);
|
|
|
+ cellStyle.getFont().setSize(20);
|
|
|
+ cells.get(0, 0).setStyle(cellStyle);
|
|
|
+ Workbook workbook1 = new Workbook();
|
|
|
+ WorksheetCollection worksheets1 = workbook1.getWorksheets();
|
|
|
+ Worksheet worksheet1 = worksheets1.get(0);
|
|
|
+ //导出
|
|
|
+ int result = exportRectifyReportDataBySheet(workbook1, worksheet1, map);
|
|
|
+ try {
|
|
|
+ // 记录第一列的原始宽度
|
|
|
+ double firstColumnWidth = worksheet1.getCells().getColumnWidth(0);
|
|
|
+ //double fourthColumnWidth = worksheet.getCells().getColumnWidth(0);
|
|
|
+ // 调整所有列的宽度
|
|
|
+ worksheet1.autoFitColumns();
|
|
|
+ worksheet.autoFitColumns();
|
|
|
+ worksheet.getCells().setColumnWidth(3, 45);
|
|
|
+ // 恢复第一列的宽度
|
|
|
+ worksheet1.getCells().setColumnWidth(0, firstColumnWidth);
|
|
|
+// Worksheet sourceWorksheet = worksheet;
|
|
|
+ int newSheetIndex = workbook.getWorksheets().add();
|
|
|
+ Worksheet newSheetInSource = workbook.getWorksheets().get(newSheetIndex);
|
|
|
+ Worksheet targetWorksheet = worksheet1;
|
|
|
+ try {
|
|
|
+ newSheetInSource.copy(targetWorksheet);
|
|
|
+ newSheetInSource.setName("整改统计");
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ response.addHeader("Pargam", "no-cache");
|
|
|
+ response.addHeader("Cache-Control", "no-cache");
|
|
|
+ response.setContentType("application/octet-stream;charset=ISO8859-1");
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=整改清单.xlsx");
|
|
|
+ workbook.save(response.getOutputStream(), SaveFormat.XLSX);
|
|
|
+ workbook.dispose();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if(result == 0){
|
|
|
+ throw new CustomException("导出失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ private int fillRectifyListTrendsData(Cells cells, int colIndex, List<String> noList, int rowIndex, ZhcxProjectRectifyVo row) {
|
|
|
+ int colorIndex = 0;
|
|
|
+ //List<RectifyMachineDto> innerDataList = row.getData();
|
|
|
+ List<ZhcxProjectRectifyMachineVo> innerDataList = row.getData();
|
|
|
+ for (String no : noList) {
|
|
|
+ ZhcxProjectRectifyMachineVo rectifyMachineVo = innerDataList.stream()
|
|
|
+ .filter(innerRow -> no.equals(innerRow.getMachineno()))
|
|
|
+ .findFirst()
|
|
|
+ .orElse(null);
|
|
|
+ if (rectifyMachineVo != null) {
|
|
|
+ cells.get(rowIndex, colIndex).putValue(rectifyMachineVo.getStatus());
|
|
|
+ cells.get(rowIndex, colIndex + 1).putValue(rectifyMachineVo.getDeptname());
|
|
|
+ cells.get(rowIndex, colIndex + 2).putValue(rectifyMachineVo.getSubcontractorname());
|
|
|
+ cells.get(rowIndex, colIndex + 3).putValue(rectifyMachineVo.getDutydeptname());
|
|
|
+ cells.get(rowIndex, colIndex + 4).putValue(rectifyMachineVo.getDutysubcontractorname());
|
|
|
+ cells.get(rowIndex, colIndex + 5).putValue(rectifyMachineVo.getFinishdate());
|
|
|
+ // 设置颜色
|
|
|
+ for (int j = colIndex; j < colIndex + 6; j++) {
|
|
|
+ Style cellStyle = cells.get(rowIndex, j).getStyle();
|
|
|
+ cellStyle.setForegroundColor(RECTIFY_LIST_COLORS[colorIndex % 2]);
|
|
|
+ cellStyle.setPattern(BackgroundType.SOLID);
|
|
|
+ cells.get(rowIndex, j).setStyle(cellStyle);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ colorIndex++;
|
|
|
+ colIndex += 6;
|
|
|
+ }
|
|
|
+ return colIndex;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void fillFrozenData(Cells cells, int rowIndex, ZhcxProjectRectifyVo row, List<String> noList) {
|
|
|
+ int i = noList.size() * 6;
|
|
|
+ int colIndex = 4;
|
|
|
+ colIndex += i;
|
|
|
+ cells.get(rowIndex, 0).putValue(row.getSeqsort());
|
|
|
+ cells.get(rowIndex, 1).putValue(row.getSupervisorcode());
|
|
|
+ cells.get(rowIndex, 2).putValue(row.getArcposition());
|
|
|
+ cells.get(rowIndex, 3).putValue(row.getArccontent());
|
|
|
+ Style style = cells.get(rowIndex, 3).getStyle();
|
|
|
+ style.setTextWrapped(true);
|
|
|
+ cells.get(rowIndex, 3).setStyle(style);
|
|
|
+ cells.get(rowIndex, colIndex).putValue(row.getMainstatus());
|
|
|
+ cells.get(rowIndex, (colIndex+1)).putValue(row.getReqdate());
|
|
|
+ cells.get(rowIndex, (colIndex+2)).putValue(row.getRectifydate());
|
|
|
+ cells.get(rowIndex, (colIndex+3)).putValue(row.getRequser());
|
|
|
+ cells.get(rowIndex, (colIndex+4)).putValue(row.getRemark1());
|
|
|
+ cells.get(rowIndex, (colIndex+5)).putValue(row.getRemark2());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setRectifyListFrozenEndHeader(Cells cells, List<String> noList) {
|
|
|
+ int i = noList.size() * 6;
|
|
|
+ int colIndex = 4;
|
|
|
+ colIndex += i;
|
|
|
+ cells.merge(1, colIndex, 2, 1);
|
|
|
+ cells.merge(1, (colIndex+1), 2, 1);
|
|
|
+ cells.merge(1, (colIndex+2), 2, 1);
|
|
|
+ cells.merge(1, (colIndex+3), 2, 1);
|
|
|
+ cells.merge(1, (colIndex+4), 2, 1);
|
|
|
+ cells.merge(1, (colIndex+5), 2, 1);
|
|
|
+ cells.get(1, colIndex).putValue("总状态");
|
|
|
+ cells.get(1, (colIndex+1)).putValue("提出日期");
|
|
|
+ cells.get(1, (colIndex+2)).putValue("整改期限");
|
|
|
+ cells.get(1, (colIndex+3)).putValue("提出者");
|
|
|
+ cells.get(1, (colIndex+4)).putValue("备注1");
|
|
|
+ cells.get(1, (colIndex+5)).putValue("备注2");
|
|
|
+ for (int j = 0; j < 6; j++) {
|
|
|
+ Style cellStyle = cells.get(1, (colIndex+j)).getStyle();
|
|
|
+ cellStyle.setForegroundColor(RECTIFY_LIST_COLORS[2]);
|
|
|
+ cellStyle.setPattern(BackgroundType.SOLID);
|
|
|
+ cells.get(1, (colIndex+j)).setStyle(cellStyle);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void setRectifyListFrozenHeader(String projName, Cells cells) {
|
|
|
+ cells.merge(1, 0, 2, 1);
|
|
|
+ cells.merge(1, 1, 2, 1);
|
|
|
+ cells.merge(1, 2, 2, 1);
|
|
|
+ cells.merge(1, 3, 2, 1);
|
|
|
+ cells.get(0, 1).putValue(projName + "整改清单");
|
|
|
+ cells.get(1, 0).putValue("总序号");
|
|
|
+ cells.get(1, 1).putValue("监理编号");
|
|
|
+ cells.get(1, 2).putValue("部位");
|
|
|
+ cells.get(1, 3).putValue("内容");
|
|
|
+ for (int j = 0; j < 4; j++) {
|
|
|
+ Style cellStyle = cells.get(1, j).getStyle();
|
|
|
+ cellStyle.setForegroundColor(RECTIFY_LIST_COLORS[2]);
|
|
|
+ cellStyle.setPattern(BackgroundType.SOLID);
|
|
|
+ cells.get(1, j).setStyle(cellStyle);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setRectifyListTrendsHeader(Cells cells, List<String> noList) {
|
|
|
+ int colIndex = 4;
|
|
|
+ int colorIndex = 0;
|
|
|
+ for (String no : noList) {
|
|
|
+ cells.merge(1, colIndex, 1, 6);
|
|
|
+ cells.get(1, colIndex).putValue(no);
|
|
|
+ cells.get(2, colIndex).putValue("状态");
|
|
|
+ cells.get(2, colIndex + 1).putValue("施工部门");
|
|
|
+ cells.get(2, colIndex + 2).putValue("施工分包商/班组");
|
|
|
+ cells.get(2, colIndex + 3).putValue("责任部门");
|
|
|
+ cells.get(2, colIndex + 4).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(RECTIFY_LIST_COLORS[colorIndex % 2]);
|
|
|
+ cellStyle.setPattern(BackgroundType.SOLID);
|
|
|
+ cells.get(i, j).setStyle(cellStyle);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ colIndex += 6;
|
|
|
+ colorIndex++;
|
|
|
+ }
|
|
|
+ cells.merge(0, 4, 1, noList.size() * 6);
|
|
|
+ }
|
|
|
}
|