[测评系统]--测评系统核心代码库
wzp
2024-02-01 bf90c55358e0bbbbf5091133e45f887fd7f1734c
图文段落居中显示
2个文件已修改
69 ■■■■■ 已修改文件
src/main/java/com/ots/project/tool/report/APIFan/APIFanReport.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ots/project/tool/report/APIFan/chart/APIFanChart.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ots/project/tool/report/APIFan/APIFanReport.java
@@ -2,15 +2,19 @@
import com.ots.common.enums.LangTypeEnum;
import com.ots.common.enums.ReportTypeEnum;
import com.ots.common.utils.StringUtils;
import com.ots.project.exam.domain.TLibraryCode;
import com.ots.project.tool.report.MAQNEW.base.BaseCondition_V2;
import com.ots.project.tool.report.MAQNEW.condition.ScoreCharacteristics_V2;
import com.ots.project.tool.report.MAQNEW.condition.SimpleMessage_V2;
import com.ots.project.tool.report.ReportResultData;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
@Data
@Slf4j
public class APIFanReport {
    private String questionnaireTaker;
    private String questionnaireID;
@@ -21,6 +25,7 @@
    private String questionnaireEndTime;
    private ReportTypeEnum reportTypeEnum;
    private LangTypeEnum langType;
    private String applyToPosition;
    /**
     * 根据报告类型初始化数据
@@ -73,4 +78,31 @@
        return new ArrayList<>();
    }
    /**
     * 获取报告字典替换值
     * @param thaiCalculationMap
     * @param type
     * @param langType
     * @return
     */
    public ReportResultData getTemplateParameters(Map<String, String> thaiCalculationMap, ReportTypeEnum type, LangTypeEnum langType) {
        this.reportTypeEnum = type;
        this.langType = langType;
        Map textMap = new HashMap();
        //基本信息字段
        textMap.put("questionnaireTaker", getQuestionnaireTaker());
        textMap.put("questionnaireID", getQuestionnaireID());
        textMap.put("reportGenerationDate", getReportGenerationDate());
        textMap.put("userName", getUserName());
        textMap.put("questionnaireEmail", getQuestionnaireEmail());
        textMap.put("questionnaireStartTime", getQuestionnaireStartTime());
        textMap.put("questionnaireEndTime", getQuestionnaireEndTime());
        textMap.put("applyToPosition",getApplyToPosition());
        textMap.putAll(thaiCalculationMap);
        ReportResultData reportResultData = new ReportResultData();
        reportResultData.setTextMap(textMap);
        return reportResultData;
    }
}
src/main/java/com/ots/project/tool/report/APIFan/chart/APIFanChart.java
@@ -13,11 +13,13 @@
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.poi.xwpf.usermodel.*;
import org.openxmlformats.schemas.drawingml.x2006.chart.*;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.math.BigInteger;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -106,6 +108,11 @@
            String selectedPic = EssConfig.getReportTemplates()+"apifanSelected.png";
            String defaultPic =EssConfig.getReportTemplates()+"apifanDefalut.png";
            //测试用的
//            String selectedPic = "C:\\测评系统\\home\\reportTemplates\\apifanSelected.png";
//            String defaultPic ="C:\\测评系统\\home\\reportTemplates\\apifanDefalut.png";
            // 遍历段落进行替换操作
            synchronized (paragraphs) {
                for (XWPFParagraph paragraph : paragraphs) {
@@ -142,6 +149,14 @@
                        int width = Units.toEMU(20); // 图片宽度
                        int height = Units.toEMU(20); // 图片高度
                        run.addPicture(new FileInputStream(picturePath), pictureType, "image.png", width, height);
                        // 添加空格或制表符,使文本居中对齐
                        int numberOfSpaces = 3;
                        for (int i = 0; i < numberOfSpaces; i++) {
                            run.setText(" ");
                        }
                        // 设置字符间距为居中对齐
                        paragraph.setVerticalAlignment(TextAlignment.CENTER);
                        run.setText("结果可信,可以直接解读(测试中未发现明显的“伪装好”倾向)");
                    }
@@ -175,6 +190,13 @@
                        int width = Units.toEMU(20); // 图片宽度
                        int height = Units.toEMU(20); // 图片高度
                        run.addPicture(new FileInputStream(picturePath), pictureType, "image.png", width, height);
                        // 添加空格或制表符,使文本居中对齐
                        int numberOfSpaces = 3;
                        for (int i = 0; i < numberOfSpaces; i++) {
                            run.setText(" ");
                        }
                        // 设置字符间距为居中对齐
                        paragraph.setVerticalAlignment(TextAlignment.CENTER);
                        run.setText("结果不可信(测试中有明显的“伪装好”倾向)");
                    }
@@ -208,6 +230,13 @@
                        int width = Units.toEMU(20); // 图片宽度
                        int height = Units.toEMU(20); // 图片高度
                        run.addPicture(new FileInputStream(picturePath), pictureType, "image.png", width, height);
                        // 添加空格或制表符,使文本居中对齐
                        int numberOfSpaces = 3;
                        for (int i = 0; i < numberOfSpaces; i++) {
                            run.setText(" ");
                        }
                        // 设置字符间距为居中对齐
                        paragraph.setVerticalAlignment(TextAlignment.CENTER);
                        run.setText("结果可能可信,解读时要谨慎(测试中有一定的“伪装好倾向”)");
                    }