Ver código fonte

整改清单报表导出-样式调整

zhuang 1 ano atrás
pai
commit
9c0f7f3d07

+ 0 - 119
business-common/src/main/java/com/rongwei/bscommon/sys/exception/InterfaceRequestErrorAndPerformanceLog.java

@@ -1,119 +0,0 @@
-package com.rongwei.bscommon.sys.exception;
-
-import com.rongwei.bscommon.sys.config.api.ResponseVO;
-import lombok.extern.slf4j.Slf4j;
-import org.aspectj.lang.ProceedingJoinPoint;
-import org.aspectj.lang.Signature;
-import org.aspectj.lang.annotation.Around;
-import org.aspectj.lang.annotation.Aspect;
-import org.aspectj.lang.annotation.Pointcut;
-import org.springframework.stereotype.Component;
-
-import javax.validation.ConstraintViolationException;
-import java.lang.reflect.Method;
-
-/**
- * 切面切在controller上捕获全局异常并处理
- * @author Administrator
- */
-@Component
-@Aspect
-@Slf4j
-public class InterfaceRequestErrorAndPerformanceLog {
-    /**
-     * 切入到controller层的包和所有子包里的任意类的任意方法的执行
-     */
-    @Pointcut("execution(* com.rongwei..*.controller..*.*(..))")
-    public void pointCut() {
-    }
-
-
-    @Around("pointCut()")
-    public Object handleControllerMethod(ProceedingJoinPoint pjp) throws Throwable {
-        long startTm = System.currentTimeMillis();
-        Object res;
-        try {
-            //处理入参特殊字符和sql注入攻击
-            checkRequestParam(pjp);
-            //Signature s = pjp.getSignature();
-            //执行访问接口操作
-            res = pjp.proceed(pjp.getArgs());
-            Long consumeTime = System.currentTimeMillis() - startTm;
-            log.info("耗时:" + consumeTime + "(毫秒).");
-            //当接口请求时间大于3秒时,标记为异常调用时间,并记录入库
-            if (consumeTime > 3000) {
-                log.warn("{" + pjp.getSignature() + "的执行时间超过三秒" + "}");
-            }
-        } catch (Exception throwable) {
-            res = handlerException(pjp, throwable);
-        }
-        return res;
-    }
-
-    /**
-     * 处理接口调用异常
-     *
-     * @param pjp
-     * @param e
-     * @return
-     */
-    private ResponseVO handlerException(ProceedingJoinPoint pjp, Throwable e) {
-        //获取方法签名
-        Signature signature = pjp.getSignature();
-        //获取目标类
-        Object controller = pjp.getTarget();
-        //获取入参数
-        Object[] args = pjp.getArgs();
-        Class<?>[] parameterTypes = new Class<?>[args.length];
-        try {
-            for (int j = 0; j < args.length; j++) {
-                Object arg = args[j];
-                parameterTypes[j] = arg.getClass();
-            }
-
-            Method method = controller.getClass().getDeclaredMethod(signature.getName(), parameterTypes);
-            Class<?> returnType = method.getReturnType();
-            if (!returnType.equals(ResponseVO.class)) {
-                return null;
-            }
-        } catch (Exception ex) {
-            //TODO:出现空指针可能是get入参有问题
-            log.error("异常信息, {}", ex);
-        }
-        ResponseVO apiResponse;
-        if (e.getClass().isAssignableFrom(ServiceException.class)) {
-            apiResponse = ResponseVO.errorInstance(e.getMessage());
-        } else if (e instanceof ConstraintViolationException) {
-            //利用校验框架的验证异常
-            String s = e.getMessage();
-            String msg = s.substring(s.indexOf(":") + 1);
-            apiResponse = ResponseVO.errorInstance(msg);
-        } else if (e instanceof RuntimeException) {
-            log.error("RuntimeException{方法:" + pjp.getSignature() + ", 参数:" + pjp.getArgs() + ",异常:" + e.getMessage() + "}", e);
-            apiResponse = ResponseVO.errorInstance(e.getMessage());
-        } else {
-            log.error("异常{方法:" + pjp.getSignature() + ", 参数:" + pjp.getArgs() + ",异常:" + e.getMessage() + "}", e);
-            apiResponse = ResponseVO.errorInstance(e.getMessage());
-        }
-        log.error("异常信息, {}", e);
-        return apiResponse;
-    }
-
-    /**
-     * @Author: wzd
-     * @Description: 处理入参特殊字符和sql注入攻击
-     */
-    private void checkRequestParam(ProceedingJoinPoint pjp) {
-        String str = String.valueOf(pjp.getArgs());
-       /* if (!IllegalStrFilterUtil.sqlStrFilter(str)) {
-            logger.info("访问接口:" + pjp.getSignature() + ",输入参数存在SQL注入风险!参数为:" + Lists.newArrayList(pjp.getArgs()).toString());
-            DcErrorEntity dcErrorEntity = interfaceErrorService.processDcErrorEntity(pjp.getSignature() + "",Lists.newArrayList(pjp.getArgs()).toString(),"输入参数存在SQL注入风险!");
-            throw new DataCenterException(dcErrorEntity);
-        }
-        if (!IllegalStrFilterUtil.isIllegalStr(str)) {
-            logger.info("访问接口:" + pjp.getSignature() + ",输入参数含有非法字符!,参数为:" + Lists.newArrayList(pjp.getArgs()).toString());
-            DcErrorEntity dcErrorEntity = interfaceErrorService.processDcErrorEntity(pjp.getSignature() + "",Lists.newArrayList(pjp.getArgs()).toString(),"输入参数含有非法字符!");
-            throw new DataCenterException(dcErrorEntity);
-        }*/
-    }
-}

+ 0 - 12
business-common/src/main/java/com/rongwei/bscommon/sys/exception/ServiceException.java

@@ -1,12 +0,0 @@
-package com.rongwei.bscommon.sys.exception;
-
-/**
- * @author Administrator
- */
-public class ServiceException extends RuntimeException {
-
-    public ServiceException(String message) {
-        super(message);
-    }
-
-}

+ 228 - 149
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ZhcxProjectManageServiceImpl.java

@@ -7,14 +7,11 @@ import com.alibaba.fastjson.JSON;
 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.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.rongwei.bscommon.sys.config.api.ResponseVO;
 import com.rongwei.bscommon.sys.dao.LuckysheetDao;
 import com.rongwei.bscommon.sys.feign.LuckySheetService;
 import com.rongwei.bscommon.sys.service.*;
-import com.rongwei.bscommon.sys.utils.JsonUtil;
 import com.rongwei.bscommon.sys.utils.LuckySheet4SummaryHelp;
 import com.rongwei.bscommon.sys.utils.ProjectSummaryExcelHelp;
 import com.rongwei.bscommon.sys.utils.XlsSheetUtil;
@@ -87,7 +84,12 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
     private ZhcxProjectManageDao zhcxProjectManageDao;
     @Autowired
     private LuckySheetService luckySheetFeignService;
-
+    private static final Color[] COLORS = {Color.fromArgb(255, 255, 204),
+            Color.fromArgb(210, 242, 210),
+            Color.fromArgb(255, 252, 213, 180),
+            Color.fromArgb(255, 255, 102, 0),
+            Color.fromArgb(255, 51, 153, 102),
+            Color.fromArgb(255, 255, 0, 0)};
     /**
      * 生成汇总文件
      *
@@ -402,7 +404,17 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
         map.put("projname", dto.getFileName());
 
         //导出
-        int result = exportRectifyReportDataBySheet(workbook, worksheet, map, response);
+        int result = exportRectifyReportDataBySheet(workbook, worksheet, map);
+        try {
+            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("导出失败");
         }
@@ -417,7 +429,7 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
      * @param response
      * @return
      */
-    private int exportRectifyReportDataBySheet(Workbook workbook, Worksheet worksheet, Map<String, Object> map, HttpServletResponse response) {
+    private int exportRectifyReportDataBySheet(Workbook workbook, Worksheet worksheet, Map<String, Object> map) {
         R r = this.getRectifyReportData(map);
         Object depttypeobj = map.getOrDefault("depttype", "施工部门");
         Object projnameobj = map.get("projname");
@@ -428,158 +440,225 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
         String projName = (String) projnameobj;
         RectifyReportDto data = (RectifyReportDto) r.getData();
         if (data != null) {
-            try {
-
-//                Workbook workbook = new Workbook();
-//                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(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);
-
-                // 设置颜色列表
-                Color[] colors = {Color.fromArgb(210, 242, 210), Color.fromArgb(255, 255, 204)};
-
-                int colIndex = 2;
-                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("完成率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("待确认");
-
-                    // 设置颜色
-                    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);
-                        }
-                    }
+            Cells cells = worksheet.getCells();
+
+            // 设置固定列头
+            setFrozenHeader(deptType, projName, cells);
+            //插入图片
+            insertPic(worksheet, cells);
+
+            // 设置颜色列表 //0机号1颜色、1机号2颜色、2汇总部门颜色、3车间颜色,4基地外颜色,5合计颜色
+            List<String> noList = data.getNoList();
+            //设置动态列
+            setTrendsHeader(cells, noList);
+
+            // 填充数据
+            int rowIndex = 3;
+            int colIndex = 2;
+            for (RectifyDto row : data.getData()) {
+                //填充数据组织颜色
+                fillDataOrgColor(cells, rowIndex, row);
+                colIndex = 2;
+                //填充数据颜色 返回索引
+                colIndex = fillDataColor(cells,colIndex, noList, rowIndex, row);
+                rowIndex++;
+            }
 
-                    colIndex += 6;
-                    colorIndex++;
+            // 设置公共样式
+            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 x = 0; x < rowIndex; x++) {
+                    Style cellStyle = cells.get(x, i).getStyle();
+                    commonStyle.setPattern(BackgroundType.SOLID);
+                    commonStyle.setForegroundColor(cellStyle.getForegroundColor());
+                    commonStyle.getFont().setColor(cellStyle.getFont().getColor());
+                    cells.get(x, i).setStyle(commonStyle);
                 }
-                cells.merge(0, 2, 1, noList.size() * 6);
-
-                // 填充数据
-                int rowIndex = 3;
-                for (RectifyDto row : data.getData()) {
-                    cells.get(rowIndex, 0).putValue(row.getFirstdeptname());
-                    cells.get(rowIndex, 1).putValue(row.getDeptname());
-
-                    List<RectifyMachineDto> innerDataList = row.getData();
-                    colIndex = 2;
-                    colorIndex = 0;
-                    for (String no : noList) {
-                        RectifyMachineDto rectifyMachineDto = innerDataList.stream()
-                                .filter(innerRow -> no.equals(innerRow.getNo()))
-                                .findFirst()
-                                .orElse(null);
-                        if (rectifyMachineDto != null) {
-                            cells.get(rowIndex, colIndex).putValue(rectifyMachineDto.getTotalCount());
-                            cells.get(rowIndex, colIndex + 1).putValue(rectifyMachineDto.getFinishRateOne());
-                            cells.get(rowIndex, colIndex + 2).putValue(rectifyMachineDto.getFinishRateTwo());
-                            cells.get(rowIndex, colIndex + 3).putValue(rectifyMachineDto.getClosedCount());
-                            cells.get(rowIndex, colIndex + 4).putValue(rectifyMachineDto.getUnfinishedCount());
-                            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;
-                        colorIndex++;
+            }
+
+            // 一级部门和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);
+        }
+        return 1;
+    }
+
+    private int fillDataColor(Cells cells, int colIndex, List<String> noList, int rowIndex, RectifyDto row) {
+        int colorIndex = 0;
+        List<RectifyMachineDto> innerDataList = row.getData();
+        for (String no : noList) {
+            RectifyMachineDto rectifyMachineDto = innerDataList.stream()
+                    .filter(innerRow -> no.equals(innerRow.getNo()))
+                    .findFirst()
+                    .orElse(null);
+            if (rectifyMachineDto != null) {
+                cells.get(rowIndex, colIndex).putValue(rectifyMachineDto.getTotalCount());
+                cells.get(rowIndex, colIndex + 1).putValue(rectifyMachineDto.getFinishRateOne());
+                cells.get(rowIndex, colIndex + 2).putValue(rectifyMachineDto.getFinishRateTwo());
+                cells.get(rowIndex, colIndex + 3).putValue(rectifyMachineDto.getClosedCount());
+                cells.get(rowIndex, colIndex + 4).putValue(rectifyMachineDto.getUnfinishedCount());
+                cells.get(rowIndex, colIndex + 5).putValue(rectifyMachineDto.getTbcCount());
+                // 设置颜色
+                for (int j = colIndex; j < colIndex + 6; j++) {
+                    Style cellStyle = cells.get(rowIndex, j).getStyle();
+                    if (StringUtils.isNotBlank(row.getDeptid())) {
+                        cellStyle.setForegroundColor(COLORS[colorIndex % 2]);
+                    }else if(StringUtils.isBlank(row.getDeptid())
+                            && StringUtils.isBlank(row.getFirstdeptid())
+                            && StringUtils.isBlank(row.getFirstdeptname())){
+                        //合计颜色
+                        cellStyle.setForegroundColor(COLORS[5]);
+                    }else{
+                        cellStyle.setForegroundColor(COLORS[2]);
                     }
-                    rowIndex++;
+                    cellStyle.setPattern(BackgroundType.SOLID);
+                    cells.get(rowIndex, j).setStyle(cellStyle);
                 }
+            }
+            colIndex += 6;
+            colorIndex++;
+        }
+        return colIndex;
+    }
+
+    /**
+     * 填充数据颜色
+     * @param cells
+     * @param rowIndex
+     * @param row
+     */
+    private void fillDataOrgColor(Cells cells, int rowIndex, RectifyDto row) {
+        cells.get(rowIndex, 0).putValue(row.getFirstdeptname());
+        if (StringUtils.isNotBlank(row.getDeptname())) {
+            cells.get(rowIndex, 1).putValue(row.getDeptname());
+        }else{
+            cells.get(rowIndex, 1).putValue(row.getFirstdeptname());
+        }
+        Style style = cells.get(rowIndex, 1).getStyle();
+        style.setPattern(BackgroundType.SOLID);
+        //车间颜色
+        if(StringUtils.isNotBlank(row.getDeptid()) && StringUtils.isNotBlank(row.getFirstdeptid())){
+            style.setForegroundColor(COLORS[3]);
+        }else if(StringUtils.isNotBlank(row.getDeptid()) && StringUtils.isBlank(row.getFirstdeptid())){
+            //基地外颜色
+            style.setForegroundColor(COLORS[4]);
+        }else if(StringUtils.isBlank(row.getDeptid()) && StringUtils.isBlank(row.getFirstdeptid())
+                && StringUtils.isBlank(row.getFirstdeptname())){
+            //合计颜色
+            style.setForegroundColor(COLORS[5]);
+        }else{
+            //部门汇总颜色
+            style.setForegroundColor(COLORS[2]);
+        }
+        cells.get(rowIndex, 1).setStyle(style);
+    }
 
-                // 设置公共样式
-                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 x = 0; x < rowIndex; x++) {
-                        Style cellStyle = cells.get(x, i).getStyle();
-                        commonStyle.setPattern(BackgroundType.SOLID);
-                        commonStyle.setForegroundColor(cellStyle.getForegroundColor());
-                        cells.get(x, i).setStyle(commonStyle);
+    /**
+     * 设置动态列
+     * @param cells
+     * @param noList
+     * @param colIndex
+     * @param colorIndex
+     */
+    private void setTrendsHeader(Cells cells, List<String> noList) {
+        int colIndex = 2;
+        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();
+                    // "关闭率" 和 "待关闭率"设置字体颜色为红色
+                    if (j == colIndex + 1 || j == colIndex + 2) {
+                        cellStyle.getFont().setColor(COLORS[5]);
                     }
+                    cellStyle.setForegroundColor(COLORS[colorIndex % 2]);
+                    cellStyle.setPattern(BackgroundType.SOLID);
+                    cells.get(i, j).setStyle(cellStyle);
                 }
-
-                // 一级部门和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("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) {
-                log.error("整改清单导出报错", e);
             }
+            colIndex += 6;
+            colorIndex++;
+        }
+        cells.merge(0, 2, 1, noList.size() * 6);
+    }
+
+    /**
+     * 固定列头
+     * @param deptType
+     * @param projName
+     * @param cells
+     */
+    private void setFrozenHeader(String deptType, String projName, Cells cells) {
+        cells.merge(1, 0, 2, 1);
+        cells.merge(1, 1, 2, 1);
+        cells.get(0, 1).putValue("QA");
+        cells.get(0, 2).putValue(projName + "项目整改汇总文字版");
+        cells.get(1, 0).putValue("一级部门");
+        cells.get(1, 1).putValue(deptType);
+    }
+
+    /**
+     * 插入图片
+     * @param worksheet
+     * @param cells
+     */
+    private void insertPic(Worksheet worksheet, Cells cells) {
+        cells.setRowHeight(0, 40);
+        cells.setColumnWidth(0, 20);
+        cells.setColumnWidth(1, 20);
+        Resource resource = new ClassPathResource("/img/zpmc.png");
+        try (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));
+        } catch (Exception e) {
+            log.error("整改清单导出报错", e);
         }
-        return 1;
     }
 
     /**