From bf90c55358e0bbbbf5091133e45f887fd7f1734c Mon Sep 17 00:00:00 2001 From: wzp <2040239371@qq.com> Date: 星期四, 01 二月 2024 16:37:12 +0800 Subject: [PATCH] 图文段落居中显示 --- src/main/java/com/ots/project/tool/report/APIFan/chart/APIFanChart.java | 29 ++++++++++++++ src/main/java/com/ots/project/tool/report/APIFan/APIFanReport.java | 40 ++++++++++++++++++-- 2 files changed, 65 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/ots/project/tool/report/APIFan/APIFanReport.java b/src/main/java/com/ots/project/tool/report/APIFan/APIFanReport.java index cf7d361..6faa7aa 100644 --- a/src/main/java/com/ots/project/tool/report/APIFan/APIFanReport.java +++ b/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; + } + } diff --git a/src/main/java/com/ots/project/tool/report/APIFan/chart/APIFanChart.java b/src/main/java/com/ots/project/tool/report/APIFan/chart/APIFanChart.java index afbcdb7..c06168a 100644 --- a/src/main/java/com/ots/project/tool/report/APIFan/chart/APIFanChart.java +++ b/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("缁撴灉鍙兘鍙俊锛岃В璇绘椂瑕佽皑鎱庯紙娴嬭瘯涓湁涓�瀹氱殑鈥滀吉瑁呭ソ鍊惧悜鈥濓級"); } -- Gitblit v1.9.1