管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-02-11 0fbf875aa0a24fcd6781061e4e85232821d72caf
1
已修改2个文件
242 ■■■■■ 文件已修改
data/ts.sql 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/helper/WordHelper.java 238 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
data/ts.sql
@@ -146,8 +146,8 @@
group by modular1,modular2
order by modular1 desc,modular2;
select * from lf.sys_operate where modular2 = ''
delete from lf.sys_operate where modular2 = ''
select * from lf.sys_operate where modular2 = '' or modular2 = '2' or modular2 is null;
delete from lf.sys_operate where modular2 = '' or modular2 = '2' or modular2 is null;
src/main/java/com/lf/server/helper/WordHelper.java
@@ -119,7 +119,7 @@
     */
    private static void insertData(XWPFTable table, List<String[]> addList) {
        for (int i = 1, c = addList.size(); i < c; i++) {
            XWPFTableRow row = table.createRow();
            table.createRow();
        }
        List<XWPFTableCell> oldCells = table.getRow(1).getTableCells();
@@ -133,10 +133,24 @@
                XWPFTableCell newCell = tableCells.get(j);
                if (0 == i) {
                    newCell.setText(addList.get(i)[j]);
                    // newCell.setText(addList.get(i)[j])
                    setCellText(newCell, addList.get(i)[j]);
                } else {
                    setCellText(oldCell, newCell, addList.get(i)[j]);
                }
            }
        }
    }
    /**
     * 设置单元格文本
     */
    private static void setCellText(XWPFTableCell cell, String text) {
        List<XWPFParagraph> paragraphs = cell.getParagraphs();
        for (XWPFParagraph paragraph : paragraphs) {
            List<XWPFRun> runs = paragraph.getRuns();
            for (XWPFRun run : runs) {
                run.setText(text, 0);
            }
        }
    }
@@ -194,42 +208,7 @@
        cellR.setText(text);
        // 复制字体信息
        if (tmpR != null) {
            if (!cellR.isBold()) {
                cellR.setBold(tmpR.isBold());
            }
            cellR.setItalic(tmpR.isItalic());
            cellR.setUnderline(tmpR.getUnderline());
            cellR.setColor(tmpR.getColor());
            cellR.setTextPosition(tmpR.getTextPosition());
            if (tmpR.getFontSize() != -1) {
                cellR.setFontSize(tmpR.getFontSize());
            }
            if (tmpR.getFontFamily() != null) {
                cellR.setFontFamily(tmpR.getFontFamily());
            }
            if (tmpR.getCTR() != null) {
                if (tmpR.getCTR().isSetRPr()) {
                    CTRPr tmpRpr = tmpR.getCTR().getRPr();
                    if (tmpRpr.isSetRFonts()) {
                        CTFonts tmpFonts = tmpRpr.getRFonts();
                        CTRPr cellRpr = cellR.getCTR().isSetRPr() ? cellR
                                .getCTR().getRPr() : cellR.getCTR().addNewRPr();
                        CTFonts cellFonts = cellRpr.isSetRFonts() ? cellRpr
                                .getRFonts() : cellRpr.addNewRFonts();
                        cellFonts.setAscii(tmpFonts.getAscii());
                        cellFonts.setAsciiTheme(tmpFonts.getAsciiTheme());
                        cellFonts.setCs(tmpFonts.getCs());
                        cellFonts.setCstheme(tmpFonts.getCstheme());
                        cellFonts.setEastAsia(tmpFonts.getEastAsia());
                        cellFonts.setEastAsiaTheme(tmpFonts.getEastAsiaTheme());
                        cellFonts.setHAnsi(tmpFonts.getHAnsi());
                        cellFonts.setHAnsiTheme(tmpFonts.getHAnsiTheme());
                    }
                }
            }
        }
        copyFontInfo(cellR, tmpR);
        // 复制段落信息
        cellP.setAlignment(tmpP.getAlignment());
@@ -240,75 +219,128 @@
        cellP.setBorderRight(tmpP.getBorderRight());
        cellP.setBorderTop(tmpP.getBorderTop());
        cellP.setPageBreak(tmpP.isPageBreak());
        if (tmpP.getCTP() != null) {
            if (tmpP.getCTP().getPPr() != null) {
                CTPPr tmpPpr = tmpP.getCTP().getPPr();
                CTPPr cellPpr = cellP.getCTP().getPPr() != null ? cellP.getCTP().getPPr() : cellP.getCTP().addNewPPr();
                // 复制段落间距信息
                CTSpacing tmpSpacing = tmpPpr.getSpacing();
                if (tmpSpacing != null) {
                    CTSpacing cellSpacing = cellPpr.getSpacing() != null ? cellPpr
                            .getSpacing() : cellPpr.addNewSpacing();
                    if (tmpSpacing.getAfter() != null) {
                        cellSpacing.setAfter(tmpSpacing.getAfter());
                    }
                    if (tmpSpacing.getAfterAutospacing() != null) {
                        cellSpacing.setAfterAutospacing(tmpSpacing
                                .getAfterAutospacing());
                    }
                    if (tmpSpacing.getAfterLines() != null) {
                        cellSpacing.setAfterLines(tmpSpacing.getAfterLines());
                    }
                    if (tmpSpacing.getBefore() != null) {
                        cellSpacing.setBefore(tmpSpacing.getBefore());
                    }
                    if (tmpSpacing.getBeforeAutospacing() != null) {
                        cellSpacing.setBeforeAutospacing(tmpSpacing
                                .getBeforeAutospacing());
                    }
                    if (tmpSpacing.getBeforeLines() != null) {
                        cellSpacing.setBeforeLines(tmpSpacing.getBeforeLines());
                    }
                    if (tmpSpacing.getLine() != null) {
                        cellSpacing.setLine(tmpSpacing.getLine());
                    }
                    if (tmpSpacing.getLineRule() != null) {
                        cellSpacing.setLineRule(tmpSpacing.getLineRule());
                    }
                }
        if (tmpP.getCTP() != null&&tmpP.getCTP().getPPr() != null) {
            CTPPr tmpPpr = tmpP.getCTP().getPPr();
            CTPPr cellPpr = cellP.getCTP().getPPr() != null ? cellP.getCTP().getPPr() : cellP.getCTP().addNewPPr();
                // 复制段落缩进信息
                CTInd tmpInd = tmpPpr.getInd();
                if (tmpInd != null) {
                    CTInd cellInd = cellPpr.getInd() != null ? cellPpr.getInd()
                            : cellPpr.addNewInd();
                    if (tmpInd.getFirstLine() != null) {
                        cellInd.setFirstLine(tmpInd.getFirstLine());
                    }
                    if (tmpInd.getFirstLineChars() != null) {
                        cellInd.setFirstLineChars(tmpInd.getFirstLineChars());
                    }
                    if (tmpInd.getHanging() != null) {
                        cellInd.setHanging(tmpInd.getHanging());
                    }
                    if (tmpInd.getHangingChars() != null) {
                        cellInd.setHangingChars(tmpInd.getHangingChars());
                    }
                    if (tmpInd.getLeft() != null) {
                        cellInd.setLeft(tmpInd.getLeft());
                    }
                    if (tmpInd.getLeftChars() != null) {
                        cellInd.setLeftChars(tmpInd.getLeftChars());
                    }
                    if (tmpInd.getRight() != null) {
                        cellInd.setRight(tmpInd.getRight());
                    }
                    if (tmpInd.getRightChars() != null) {
                        cellInd.setRightChars(tmpInd.getRightChars());
                    }
            // 复制段落间距信息
            copySpacing(tmpPpr, cellPpr);
            // 复制段落缩进信息
            copyParagraph(tmpPpr, cellPpr);
        }
    }
    /**
     * 复制字体信息
     */
    private static void copyFontInfo(XWPFRun cellR, XWPFRun tmpR) {
        if (tmpR == null) {
            return;
        }
        if (!cellR.isBold()) {
            cellR.setBold(tmpR.isBold());
        }
        cellR.setItalic(tmpR.isItalic());
        cellR.setUnderline(tmpR.getUnderline());
        cellR.setColor(tmpR.getColor());
        cellR.setTextPosition(tmpR.getTextPosition());
        if (tmpR.getFontSize() != -1) {
            cellR.setFontSize(tmpR.getFontSize());
        }
        if (tmpR.getFontFamily() != null) {
            cellR.setFontFamily(tmpR.getFontFamily());
        }
        if (tmpR.getCTR() != null) {
            if (tmpR.getCTR().isSetRPr()) {
                CTRPr tmpRpr = tmpR.getCTR().getRPr();
                if (tmpRpr.isSetRFonts()) {
                    CTFonts tmpFonts = tmpRpr.getRFonts();
                    CTRPr cellRpr = cellR.getCTR().isSetRPr() ? cellR
                            .getCTR().getRPr() : cellR.getCTR().addNewRPr();
                    CTFonts cellFonts = cellRpr.isSetRFonts() ? cellRpr
                            .getRFonts() : cellRpr.addNewRFonts();
                    cellFonts.setAscii(tmpFonts.getAscii());
                    cellFonts.setAsciiTheme(tmpFonts.getAsciiTheme());
                    cellFonts.setCs(tmpFonts.getCs());
                    cellFonts.setCstheme(tmpFonts.getCstheme());
                    cellFonts.setEastAsia(tmpFonts.getEastAsia());
                    cellFonts.setEastAsiaTheme(tmpFonts.getEastAsiaTheme());
                    cellFonts.setHAnsi(tmpFonts.getHAnsi());
                    cellFonts.setHAnsiTheme(tmpFonts.getHAnsiTheme());
                }
            }
        }
    }
    /**
     * 复制段落间距信息
     */
    private static void copySpacing(CTPPr tmpPpr, CTPPr cellPpr) {
        CTSpacing tmpSpacing = tmpPpr.getSpacing();
        if (tmpSpacing != null) {
            CTSpacing cellSpacing = cellPpr.getSpacing() != null ? cellPpr.getSpacing() : cellPpr.addNewSpacing();
            if (tmpSpacing.getAfter() != null) {
                cellSpacing.setAfter(tmpSpacing.getAfter());
            }
            if (tmpSpacing.getAfterAutospacing() != null) {
                cellSpacing.setAfterAutospacing(tmpSpacing
                        .getAfterAutospacing());
            }
            if (tmpSpacing.getAfterLines() != null) {
                cellSpacing.setAfterLines(tmpSpacing.getAfterLines());
            }
            if (tmpSpacing.getBefore() != null) {
                cellSpacing.setBefore(tmpSpacing.getBefore());
            }
            if (tmpSpacing.getBeforeAutospacing() != null) {
                cellSpacing.setBeforeAutospacing(tmpSpacing
                        .getBeforeAutospacing());
            }
            if (tmpSpacing.getBeforeLines() != null) {
                cellSpacing.setBeforeLines(tmpSpacing.getBeforeLines());
            }
            if (tmpSpacing.getLine() != null) {
                cellSpacing.setLine(tmpSpacing.getLine());
            }
            if (tmpSpacing.getLineRule() != null) {
                cellSpacing.setLineRule(tmpSpacing.getLineRule());
            }
        }
    }
    /**
     * 复制段落缩进信息
     */
    private static void copyParagraph(CTPPr tmpPpr, CTPPr cellPpr) {
        CTInd tmpInd = tmpPpr.getInd();
        if (tmpInd != null) {
            CTInd cellInd = cellPpr.getInd() != null ? cellPpr.getInd() : cellPpr.addNewInd();
            if (tmpInd.getFirstLine() != null) {
                cellInd.setFirstLine(tmpInd.getFirstLine());
            }
            if (tmpInd.getFirstLineChars() != null) {
                cellInd.setFirstLineChars(tmpInd.getFirstLineChars());
            }
            if (tmpInd.getHanging() != null) {
                cellInd.setHanging(tmpInd.getHanging());
            }
            if (tmpInd.getHangingChars() != null) {
                cellInd.setHangingChars(tmpInd.getHangingChars());
            }
            if (tmpInd.getLeft() != null) {
                cellInd.setLeft(tmpInd.getLeft());
            }
            if (tmpInd.getLeftChars() != null) {
                cellInd.setLeftChars(tmpInd.getLeftChars());
            }
            if (tmpInd.getRight() != null) {
                cellInd.setRight(tmpInd.getRight());
            }
            if (tmpInd.getRightChars() != null) {
                cellInd.setRightChars(tmpInd.getRightChars());
            }
        }
    }
}