README.md
File was deleted pom.xml
@@ -355,47 +355,17 @@ <scope>compile</scope> </dependency> <dependency> <groupId>dom4j</groupId> <artifactId>dom4j</artifactId> <version>1.6.1</version> </dependency> <dependency> <groupId>jaxen</groupId> <artifactId>jaxen</artifactId> <version>1.1.6</version> </dependency> </dependencies> <build> <finalName>${project.artifactId}</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> <encoding>utf-8</encoding> </configuration> </plugin> </plugins> </build> <repositories> <repository> <id>public</id> <name>aliyun nexus</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>public</id> <name>aliyun nexus</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> </pluginRepositories> </project> src/main/java/com/ots/common/enums/ReportTitle.java
File was deleted src/main/java/com/ots/common/enums/ReportTypeEnum.java
@@ -4,7 +4,7 @@ @Getter public enum ReportTypeEnum { Brief("Brief", "简易版"), Complete("Complete", "完整版"), SAQ("SAQ", "SAQ报告"), RuiLin("RuiLin", "睿邻报告"), CAQ("CAQ", "CAQ报告"), JAQ("JAQ","JAQ报告"),MAQ("MAQ", "MAQ报告"); JAQ("JAQ","JAQ报告"),MAQ("MAQ", "MAQ报告"),MAQV2("MAQV2", "MAQV2报告"); private final String code; private final String message; ReportTypeEnum(String code, String message) { src/main/java/com/ots/common/utils/poi/WordUtil.java
@@ -1,5 +1,6 @@ package com.ots.common.utils.poi; import cn.hutool.core.collection.CollUtil; import com.ots.common.enums.ReportTypeEnum; import com.ots.common.enums.ReportTypeNameEnum; import com.ots.common.enums.TemplateTypeEnum; import com.ots.common.utils.StringUtils; @@ -20,57 +21,36 @@ import org.apache.poi.ooxml.POIXMLDocument; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.util.Units; import org.apache.poi.xwpf.usermodel.Document; import org.apache.poi.xwpf.usermodel.IBodyElement; import org.apache.poi.xwpf.usermodel.IRunElement; import org.apache.poi.xwpf.usermodel.XWPFChart; import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.apache.poi.xwpf.usermodel.XWPFHeader; import org.apache.poi.xwpf.usermodel.XWPFParagraph; import org.apache.poi.xwpf.usermodel.XWPFRun; import org.apache.poi.xwpf.usermodel.XWPFTable; import org.apache.poi.xwpf.usermodel.XWPFTableCell; import org.apache.poi.xwpf.usermodel.XWPFTableRow; import org.apache.poi.xwpf.usermodel.*; import org.apache.xmlbeans.XmlCursor; import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlObject; import org.dom4j.DocumentException; import org.jetbrains.annotations.Nullable; import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource; import org.openxmlformats.schemas.drawingml.x2006.chart.CTBarChart; import org.openxmlformats.schemas.drawingml.x2006.chart.CTBarSer; import org.openxmlformats.schemas.drawingml.x2006.chart.CTChart; import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource; import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumVal; import org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea; import org.openxmlformats.schemas.drawingml.x2006.chart.CTScatterChart; import org.openxmlformats.schemas.drawingml.x2006.chart.CTScatterSer; import org.openxmlformats.schemas.drawingml.x2006.chart.*; import org.openxmlformats.schemas.drawingml.x2006.main.CTGraphicalObject; import org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTAnchor; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDrawing; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPPr; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import java.awt.image.BufferedImage; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.Set; import java.io.*; import java.util.*; public class WordUtil { private static final Logger log = LoggerFactory.getLogger(WordUtil.class); public static String tempFilePath = "/Users/shawnli/Downloads/"; private static String noRunChange = ""; private static Map<String, String> colorLabel = new HashMap<String, String>() {{ put("<YellowText>", "</YellowText>"); }}; private static Map<String, String> fontSize = new HashMap<String, String>() {{ put("<FontSize_11>", "</FontSize_11>"); }}; public static final int DEFAULT_FONT_SIZE = 10; public static boolean changWord(String inputUrl, String outputUrl, @@ -256,7 +236,7 @@ int width = (int) Math.round(bufferedImage.getWidth()); int height = (int) Math.round(bufferedImage.getHeight()); int emuSelf = 3000; run.addPicture(in, Document.PICTURE_TYPE_PNG, "TEST", width * emuSelf, height * emuSelf); run.addPicture(in, Document.PICTURE_TYPE_PNG, "TEST", width * emuSelf, height * emuSelf); in.close(); if (wordParam.isMove()) { @@ -314,7 +294,7 @@ XWPFTable table = tables.get(i); if (table.getRows().size() > 0) { log.info("表格数据:"+ table.getText()); log.info("表格数据:" + table.getText()); if (checkText(table.getText())) { List<XWPFTableRow> rows = table.getRows(); @@ -497,6 +477,7 @@ insertRun.setText(originalRunStr); insertRun.setBold(oldRun.isBold()); insertRun.setColor(oldRun.getColor()); insertRun.setFontFamily(oldRun.getFontFamily()); int fontSize = oldRun.getFontSize(); insertRun.setFontSize((fontSize == -1) ? DEFAULT_FONT_SIZE : fontSize); } @@ -507,12 +488,24 @@ if (StringUtils.isNotEmpty(newRunStr)) { newRunStr = newRunStr.replaceAll("<BoldText>", ""); newRunStr = newRunStr.replaceAll("</BoldText>", ""); String rgbStr = getRGBStr(newRunStr, oldRun); if (rgbStr == null) { rgbStr = oldRun.getColor(); } int fontSize = getFontSize(newRunStr, oldRun); if (fontSize == -1) { fontSize = oldRun.getFontSize(); } newRunStr = getfinalStr(newRunStr); stringList.add(newRunStr); XWPFRun insertRun = paragraph.insertNewRun(runPosition++); insertRun.setText(newRunStr); insertRun.setBold(true); insertRun.setColor(oldRun.getColor()); int fontSize = oldRun.getFontSize(); insertRun.setColor(rgbStr); String fontFamily = oldRun.getFontFamily(); insertRun.setFontFamily(fontFamily); insertRun.setFontSize((fontSize == -1) ? DEFAULT_FONT_SIZE : fontSize); } pointer = position; @@ -522,6 +515,7 @@ insertRun.setText(runValue.substring(pointer, end)); insertRun.setBold(oldRun.isBold()); insertRun.setColor(oldRun.getColor()); insertRun.setFontFamily(oldRun.getFontFamily()); int fontSize = oldRun.getFontSize(); insertRun.setFontSize((fontSize == -1) ? DEFAULT_FONT_SIZE : fontSize); pointer = end; @@ -530,6 +524,71 @@ paragraph.removeRun(runPosition); return "NoChangValue"; } private static int getFontSize(String newRunStr, XWPFRun oldRun) { int font = -1; for (String lab : fontSize.keySet()) { if (newRunStr.contains(lab)) { int fontSize = getFontSize(lab); if (fontSize != -1) { font = fontSize; break; } } } return font; } private static int getFontSize(String lab) { int font = -1; int index = lab.indexOf("_"); String size = lab.substring(index + 1, lab.length() - 1); try{ font = Integer.parseInt(size); }catch (Exception e){} return font; } private static String getfinalStr(String newRunStr) { String result = newRunStr; for (String lab : colorLabel.keySet()) { if (newRunStr.contains(lab)) { newRunStr = newRunStr.replaceAll(lab, ""); newRunStr = newRunStr.replaceAll(colorLabel.get(lab), ""); result = newRunStr; } } for (String lab : fontSize.keySet()) { if (newRunStr.contains(lab)) { newRunStr = newRunStr.replaceAll(lab, ""); newRunStr = newRunStr.replaceAll(fontSize.get(lab), ""); result = newRunStr; } } return result; } private static String getRGBStr(String newRunStr, XWPFRun oldRun) { String rgbStr = null; for (String lab : colorLabel.keySet()) { if (newRunStr.contains(lab)) { String colorByLab = getColorByLab(lab); if (colorByLab != null) { rgbStr = colorByLab; break; } } } return rgbStr; } private static String getColorByLab(String lab) { String rgbStr = null; switch (lab) { case "<YellowText>": rgbStr = "ff9900"; break; default: rgbStr = "000000"; break; } return rgbStr; } @@ -697,7 +756,7 @@ ShellTool.execLibreofficeCommand("pdf", EssConfig.getProfile() + "/" + reportName, EssConfig.getProfile() + "/"); zipFilePath = getPdfPath(reportName); deleteFileStrList.add(EssConfig.getProfile() + "/" + reportName); deleteFileStrList.add(EssConfig.getProfile() + "/" + reportName); } catch (Exception ex) { returnMessage = returnMessage + ex.getMessage(); deleteFileStrList.add(EssConfig.getProfile() + "/" + reportName); @@ -717,7 +776,7 @@ } private static void changColorIfJAQ(Map<String, Object> textMap, FileOutputStream out, String reportName, String reportType) throws IOException { if (Objects.equals(reportType, "JAQ")) { changTableColor(reportName, out, (List<JAQTableStyle>)textMap.get("JAQTableStyle")); changTableColor(reportName, out, (List<JAQTableStyle>) textMap.get("JAQTableStyle")); } } private static String getTypeIfIsSAQ(TReportTemplate tReportTemplate, String reportType) { @@ -727,7 +786,7 @@ return reportType; } private static String getPdfPath(String reportName) { return reportName.substring(0,reportName.lastIndexOf(".")) + ".pdf"; return reportName.substring(0, reportName.lastIndexOf(".")) + ".pdf"; } public static void deleteFileByStr(List<String> deleteFileStrList) { @@ -772,12 +831,14 @@ } return new FileOutputStream(outFile); } private static void setChageWord(String fileName, OutputStream out, Map<String, Object> textMap, String reportType, String templateType, Map<Integer, Map<Integer, List<String[]>>> autoTableMap) throws IOException, org.apache.poi.openxml4j.exceptions.InvalidFormatException { private static void setChageWord(String fileName, OutputStream out, Map<String, Object> textMap, String reportType, String templateType, Map<Integer, Map<Integer, List<String[]>>> autoTableMap) throws IOException, org.apache.poi.openxml4j.exceptions.InvalidFormatException, DocumentException { String filePath = getTemplateDownLoadPathByUpLoad(fileName); XWPFDocument document = new XWPFDocument(POIXMLDocument.openPackage(getTemplateDownLoadPathByUpLoad(fileName))); changeText(document, textMap); changeTextBox(document, textMap); addTableValue(document, autoTableMap); @@ -785,6 +846,58 @@ changChar(textMap, document, reportType, templateType); document.write(out); } private static void changeTextBox(XWPFDocument document, Map<String, Object> textMap) throws DocumentException { List<XWPFParagraph> paragraphs = document.getParagraphs(); for (XWPFParagraph paragraph : paragraphs) { CTR[] rArray = paragraph.getCTP().getRArray(); for (XmlObject ctr : rArray) { Node domNode = ctr.getDomNode(); setTextVal(domNode, textMap); } } } private static void setTextVal(Node node, Map<String, Object> textMap) { if ("w:t".equalsIgnoreCase(node.getNodeName())) { Node wtItem = node.getChildNodes().item(0); if (wtItem != null) { wtItem.setNodeValue(getValByKey(wtItem.getNodeValue(), textMap)); } return; } NodeList childNodes = node.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { setTextVal(childNodes.item(i), textMap); } } private static String getValByKey(String text, Map<String, Object> textMap) { if (!checkText(text)) { return text; } String repText = ""; Set<Map.Entry<String, Object>> textSets = textMap.entrySet(); for (Map.Entry<String, Object> textSet : textSets) { String key = "%" + textSet.getKey() + "%"; if (text.indexOf(key) != -1) { text = text.replaceAll(key, (String) textMap.get(textSet.getKey())); repText = text; if (checkText(text)) { continue; } else { break; } } } if (repText.indexOf("<BoldText>") != -1) { repText = repText.replaceAll("<BoldText>", ""); repText = repText.replaceAll("</BoldText>", ""); } if (repText.indexOf("N/A NONE") != -1) { repText = repText.replaceAll("N/A NONE", ""); } return repText; } public static void changTableColor(String fileName, OutputStream out, List<JAQTableStyle> jaqTableStyleList) throws IOException { if (StringUtils.isEmpty(fileName) || CollUtil.isEmpty(jaqTableStyleList)) { @@ -825,12 +938,55 @@ if (StringUtils.equals(reportType, "MAQ")) { setMAQCompleteChars(textMap, charts); } else if (StringUtils.equals(reportType, "RuiLin")){ } else if (StringUtils.equals(reportType, ReportTypeEnum.MAQV2.getCode())) { setMAQ_V2CompleteChars(textMap, charts); } else if (StringUtils.equals(reportType, "RuiLin")) { setRuiLinChar(textMap, charts); } else { return; } } private static void setMAQ_V2CompleteChars(Map<String, Object> textMap, List<XWPFChart> charts) { String p_People32 = textMap.get("P_Task31").toString(); String p_Task31 = textMap.get("P_People32").toString(); String P_INCON25 = textMap.get("P_INCON25").toString(); String P_IM24 = textMap.get("P_IM24").toString(); String P_SDE23 = textMap.get("P_SDE23").toString(); for (XWPFChart xwpfChart : charts) { try { CTChart ctChart = xwpfChart.getCTChart(); CTPlotArea ctPlotArea = ctChart.getPlotArea(); List<CTScatterChart> scatterChartList = ctPlotArea.getScatterChartList(); List<CTBarChart> barChartList = ctPlotArea.getBarChartList(); if (scatterChartList.size() != 0 && barChartList.size() != 0) { CTScatterChart ctScatterChart = scatterChartList.get(0); CTScatterSer ctScatterSer = ctScatterChart.getSerList().get(0); CTAxDataSource xVal = ctScatterSer.getXVal(); List<CTNumVal> ptList = xVal.getNumRef().getNumCache().getPtList(); ptList.get(0).setV(P_INCON25); ptList.get(1).setV(P_IM24); ptList.get(2).setV(P_SDE23); } else if (scatterChartList.size() != 0 && barChartList.size() == 0) { CTScatterChart ctScatterChart = scatterChartList.get(0); CTScatterSer ctScatterSer = ctScatterChart.getSerList().get(0); CTAxDataSource xVal = ctScatterSer.getXVal(); CTNumDataSource yVal = ctScatterSer.getYVal(); xVal.getNumRef().getNumCache().getPtList().get(0).setV(p_Task31); yVal.getNumRef().getNumCache().getPtList().get(0).setV(p_People32); } else if (barChartList.size() != 0) { CTBarChart ctBarChart = barChartList.get(0); List<CTBarSer> serList = ctBarChart.getSerList(); CTBarSer ctBarSer = serList.get(0); CTNumDataSource val = ctBarSer.getVal(); val.getNumRef().getNumCache().getPtList().get(0).setV(p_Task31); val.getNumRef().getNumCache().getPtList().get(1).setV(p_People32); } } catch (Exception e) { e.printStackTrace(); } } } private static void setRuiLinChar(Map<String, Object> textMap, List<XWPFChart> charts) { try { int char0Size = charts.get(0).getCTChart().getPlotArea().getBarChartList().get(0).getSerList().get(0).getVal().getNumRef().getNumCache().getPtList().size(); src/main/java/com/ots/project/exam/domain/TLibraryCode.java
@@ -34,6 +34,8 @@ private String dictType; private MultipartFile iconFile; private String score; public String getLangTypeContext(LangTypeEnum langType) { if (Objects.equals("2",dictType)) { return icon; src/main/java/com/ots/project/tool/ShellTool.java
@@ -10,13 +10,12 @@ StringBuilder builder = new StringBuilder(); if (os.toLowerCase().startsWith("mac")) { builder.append("/Applications/LibreOffice.app/Contents/MacOS/soffice --headless --convert-to "); } else if(os.contains("Windows")){ builder.append("cmd /c start soffice --headless --convert-to "); } else if(os.toLowerCase().startsWith("windows")){ builder.append("soffice.exe --headless --invisible --convert-to "); } else { builder.append("libreoffice6.4 --headless --convert-to "); } builder.append(type).append(" "); builder.append(type).append(":impress_pdf_Export "); builder.append("--outdir " + targetPath).append(" "); builder.append(sourcePath).append(" "); @@ -27,36 +26,8 @@ } } catch (Exception e) { } return run_cmd(builder.toString()); return exec(builder.toString()); } public static String run_cmd(String strcmd) { // Runtime rt = Runtime.getRuntime(); //Runtime.getRuntime()返回当前应用程序的Runtime对象 Process ps = null; //Process可以控制该子进程的执行或获取该子进程的信息。 try { ps = rt.exec(strcmd); //该对象的exec()方法指示Java虚拟机创建一个子进程执行指定的可执行程序,并返回与该子进程对应的Process对象实例。 ps.waitFor(); //等待子进程完成再往下执行。 } catch (IOException e1) { e1.printStackTrace(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } int i = ps.exitValue(); //接收执行完毕的返回值 if (i == 0) { System.out.println("执行完成."); } else { System.out.println("执行失败."); } ps.destroy(); //销毁子进程 ps = null; return null; } private static String exec(String command) { String returnString = ""; Runtime runTime = Runtime.getRuntime(); @@ -80,6 +51,6 @@ return returnString; } public static void main(String[] args) { System.out.println(exec("libreoffice6.4 --headless --convert-to /root/小红.docx 小红.pdf ")); System.out.println(exec("soffice.exe --headless --invisible --convert-to D:/ots/uploadPath/upload/2021/02/28/01e01cf7e372ba8b1c5d24b8d69a46f8.docx 01e01cf7e372ba8b1c5d24b8d69a46f8.pdf ")); } } src/main/java/com/ots/project/tool/email/EmailMessageImpl.java
@@ -15,16 +15,6 @@ @Slf4j @Component public class EmailMessageImpl implements EmailMessage { public final static String userName = "2040239371"; public final static String password = "ivaikhcfclvlefbj"; private final static String mailServerHost = "smtp.qq.com"; src/main/java/com/ots/project/tool/email/SimpleMailSender.java
@@ -47,7 +47,7 @@ mailInfo.setUserName("test@tai-online.com"); mailInfo.setPassword("Wlz@2020"); mailInfo.setFromAddress("test@tai-online.com"); mailInfo.setToAddress("guobiao8900@126.com"); mailInfo.setToAddress(""); mailInfo.setSubject("测试发送邮件"); mailInfo.setContent("评测系统测试邀请链接http://139.199.11.114/exam-stu/#/demography/ed860660-95a7-4feb-aab9-f56b1eff1a3c/12/index"); String[] attachFileNames = {"D:\\ots\\uploadPath\\upload\\94a3847d-901a-4063-9d2d-ef3a345f46d0.png", "D:\\ots\\uploadPath\\upload\\94a3847d-901a-4063-9d2d-ef3a345f46d0.png"}; src/main/java/com/ots/project/tool/exam/ExamUtil.java
@@ -22,12 +22,14 @@ productTypeMap.put("job", "JAQ"); productTypeMap.put("RuiLin","RuiLin"); productTypeMap.put("MAQ", "MAQ"); productTypeMap.put("MAQV2", "MAQV2"); productTypeMap.put("SAQ", "SAQ"); productTypeMap.put("JAQ", "JAQ"); } private static void setWaterDropAndBar() { waterDropPictureMap.put("ResponseFidelityDiagnosis", "waterDropDarkBlue.png"); waterDropPictureMap.put("ResponseFidelityDiagnosis_V2", "waterDropDarkBlue_V2.png"); waterDropPictureMap.put("ResponseFidelityDiagnosisSAQ", "waterDropDarkBlue.png"); @@ -55,8 +57,11 @@ waterDropPictureMap.put("PoliteTactful", "waterDropLightBlue.png"); barPictureMap.put("ResponseFidelityDiagnosis_waterDrops1", "Bar1.png"); barPictureMap.put("ResponseFidelityDiagnosis_V2_waterDrops1", "Bar1_V2.png"); barPictureMap.put("ResponseFidelityDiagnosis_waterDrops2", "Bar1.png"); barPictureMap.put("ResponseFidelityDiagnosis_V2_waterDrops2", "Bar1_V2.png"); barPictureMap.put("ResponseFidelityDiagnosis_waterDrops3", "Bar2.png"); barPictureMap.put("ResponseFidelityDiagnosis_V2_waterDrops3", "Bar2_V2.png"); barPictureMap.put("ResponseFidelityDiagnosisSAQ_waterDrops1", "Bar1.png"); barPictureMap.put("ResponseFidelityDiagnosisSAQ_waterDrops2", "Bar1.png"); src/main/java/com/ots/project/tool/exam/ImageUtil.java
@@ -95,10 +95,17 @@ int barImageY = 30; float scorce = scorceF / 100; if (key.indexOf("ResponseFidelityDiagnosis") != -1) { CANVAS_H = 105; CANVAS_H = 105; waterDropImageX = 2; scorce100 = 812; barImageY = 5; } if (key.indexOf("ResponseFidelityDiagnosis_V2") != -1) { CANVAS_H = 400; waterDropImageX = -30; scorce100 = 800; barImageY = 5; waterDropImageY = 0; } if (key.indexOf("RuilinTestResultValidityDiagnosisContext") != -1) { CANVAS_H = 105; @@ -130,6 +137,9 @@ } else { barName = ""; } if(StringUtils.isBlank(barName)){ return; } BufferedImage barImage = getImage(reportTemplates + barName); BufferedImage waterDropImage = getImage(reportTemplates + waterDrop); @@ -153,7 +163,11 @@ int waterDropOffsetX = setWaterDrop(waterDrop, waterDropImageX, waterDropImageY, scorce100, scorce, g2d, waterDropImage); setText(String.valueOf(Math.round(scorceF)), g2d, waterDropOffsetX); if (key.indexOf("ResponseFidelityDiagnosis_V2") != -1) { setTextV2(String.valueOf(Math.round(scorceF)), g2d, waterDropOffsetX); }else{ setText(String.valueOf(Math.round(scorceF)), g2d, waterDropOffsetX); } g2d.dispose(); outputBarWaterImage(key + "_" + member_id + "_" + String.valueOf(scorceF)+"_" + suffixDate, image); @@ -165,6 +179,25 @@ } catch (IOException e) { e.printStackTrace(); } } private static void setTextV2(String value, Graphics2D g2d, int waterDropOffsetX) { g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON); g2d.setColor(Color.BLACK); Font font = new Font("", Font.BOLD, 16); g2d.setFont(font); int numX = 0; int numY = 17; if (value.length() == 2) { numX = 36; } else if (value.length() == 3) { numX = 32; } else if (value.length() == 1) { numX = 42; } g2d.drawString(value, numX + waterDropOffsetX, numY); } private static void setText(String value, Graphics2D g2d, int waterDropOffsetX) { g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON); @@ -207,6 +240,7 @@ return image; } catch (IOException e) { log.info("异常图片:" + path); log.error("{}发生异常:{}",path, e); throw new RuntimeException("获取图片资源异常", e); } } src/main/java/com/ots/project/tool/report/CAQ/CAQReport.java
@@ -23,14 +23,7 @@ private String reportDate; private String testToken; /** * 获取报告字典的code跟value * @param thaiCalculationMap * @param type * @param langType * @return */ public ReportResultData getTemplateParameters(Map<String, String> thaiCalculationMap, ReportTypeEnum type, LangTypeEnum langType) { Map<String, Object> infoMap = new HashMap(); infoMap.put("fullName", fullName); @@ -38,17 +31,13 @@ infoMap.put("testToken", testToken); Map textMap = new HashMap(); Map waterDropsMap = new HashMap(); //遍历初始化code字典值的value getParamList(type).stream().forEach(p -> { TLibraryCode calculate = p.calculate(thaiCalculationMap, langType); //保存置换后文本字典 例:LIBCAQ0015 : 该候选人在抽象推理能力部分20题中回答正确的题数:<BoldText>14</BoldText> textMap.put(p.getName(), Objects.isNull(calculate) || StringUtils.isBlank(calculate.getLangTypeContext(langType)) ? "N/A NONE" : calculate.getLangTypeContext(langType)); //保存图片字典 例子:P_Abstract_context_waterDrops : 26.0 if (Objects.nonNull(p.getMAQwaterDropsImages())) { waterDropsMap.putAll(p.getMAQwaterDropsImages()); } }); //保存之前传进来的题目ID跟一些个人信息 textMap.putAll(thaiCalculationMap); ReportResultData reportResultData = new ReportResultData(); reportResultData.setTextMap(textMap); @@ -58,12 +47,6 @@ public List<BaseCondition> getParamList(ReportTypeEnum reportTypeEnum) { return init(reportTypeEnum); } /** * 初始化字典 * @param reportTypeEnum * @return */ private List<BaseCondition> init(ReportTypeEnum reportTypeEnum) { List<BaseCondition> paramList = new ArrayList<>(); @@ -76,11 +59,6 @@ paramList.add(new WaterDropletContentPNumeric()); return paramList; } /** * 初始化简单的字典code * @return */ private List<String> getSimpleMessageCoreIds() { return Arrays.asList("LIBCAQ0005", "LIBCAQ0006", "LIBCAQ0007", "LIBCAQ0008", "LIBCAQ0010", "LIBCAQ0020" ,"LIBCAQ0030","LIBCAQ0040","LIBCAQ0050","LIBCAQ0060","LIBCAQ0070","LIBCAQ0080" src/main/java/com/ots/project/tool/report/MAQ/base/BaseCondition.java
@@ -34,14 +34,6 @@ } return false; } /** * 获取报告字典 * @param map * @param codeId * @param langType * @return */ public TLibraryCode getMaqReportLibrary(Map<String, String> map, String codeId, LangTypeEnum langType) { if (Objects.isNull(codeId)) { return null; @@ -49,9 +41,6 @@ StringBuilder content = new StringBuilder(); String[] split = codeId.split(","); TLibraryCode result = new TLibraryCode(); /** * 根据字典CODE获取对应的字典详情 */ Arrays.stream(split).forEach(item -> { TLibraryCode maqReportLibrary = CacheServiceFactory.getInstance().getMAQReportLibrary(item); if (Objects.isNull(maqReportLibrary)) { @@ -63,21 +52,11 @@ result.setLibraryCode(maqReportLibrary.getLibraryCode()); } }); //设置对应语言的文字内容 result.setLangTypeContext(content.toString(), langType); //替换报告字典内容的变量 dynamicParameterSubstitution(map, result, langType); return result; } /** * 替换报告字典内容的变量 * @param map * @param maqReportLibrary * @param langType */ public void dynamicParameterSubstitution(Map<String, String> map, TLibraryCode maqReportLibrary, LangTypeEnum langType) { //根据报告字典内容 定位变量名位置 替换结果 map.forEach((key, value) -> { String content = maqReportLibrary.getLangTypeContext(langType); String replaceStr = "%" + key + "%"; src/main/java/com/ots/project/tool/report/MAQ/base/MAQConditionVO.java
@@ -11,13 +11,14 @@ @Setter public class MAQConditionVO { private String name; protected String name; private String title; protected String title; private String conditionKey; protected String conditionKey; private List<String> conditionTarget; protected List<String> conditionTarget; public MAQConditionVO(){} public MAQConditionVO(String name, String conditionKey, String conditionTargetPrefix) { this.name = name; tai-ots-framework.iml
@@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> <module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> <module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" version="4"> <component name="FacetManager"> <facet type="Spring" name="Spring"> <configuration /> @@ -171,5 +171,8 @@ <orderEntry type="library" name="Maven: org.jvnet.hudson:ganymed-ssh2:build210-hudson-1" level="project" /> <orderEntry type="library" name="Maven: io.netty:netty-all:4.1.49.Final" level="project" /> <orderEntry type="library" name="Maven: org.jetbrains:annotations:13.0" level="project" /> <orderEntry type="library" name="Maven: dom4j:dom4j:1.6.1" level="project" /> <orderEntry type="library" name="Maven: xml-apis:xml-apis:1.4.01" level="project" /> <orderEntry type="library" name="Maven: jaxen:jaxen:1.1.6" level="project" /> </component> </module>