From 38c060a610e8c27dfc54e064f4fb4fd22b6b4d56 Mon Sep 17 00:00:00 2001 From: linzhijie <19970921lzj> Date: 星期一, 12 四月 2021 15:53:52 +0800 Subject: [PATCH] 最新代码 --- src/main/java/com/ots/project/exam/domain/TLibraryCode.java | 2 src/main/java/com/ots/project/tool/ShellTool.java | 39 --- src/main/java/com/ots/project/tool/report/MAQ/base/MAQConditionVO.java | 9 src/main/java/com/ots/project/tool/email/EmailMessageImpl.java | 10 - src/main/java/com/ots/project/tool/exam/ImageUtil.java | 38 ++++ src/main/java/com/ots/project/tool/report/CAQ/CAQReport.java | 24 -- pom.xml | 52 +---- /dev/null | 44 ---- src/main/java/com/ots/project/tool/report/MAQ/base/BaseCondition.java | 21 -- src/main/java/com/ots/common/utils/poi/WordUtil.java | 246 ++++++++++++++++++++++----- src/main/java/com/ots/common/enums/ReportTypeEnum.java | 2 tai-ots-framework.iml | 5 src/main/java/com/ots/project/tool/email/SimpleMailSender.java | 2 src/main/java/com/ots/project/tool/exam/ExamUtil.java | 5 14 files changed, 272 insertions(+), 227 deletions(-) diff --git a/README.md b/README.md deleted file mode 100644 index a5ffc18..0000000 --- a/README.md +++ /dev/null @@ -1,4 +0,0 @@ -## TAI_OTS_FRAMEWORK - -娴嬭瘎绯荤粺鏍稿績浠g爜 - diff --git a/pom.xml b/pom.xml index 713da3e..393ee3b 100644 --- a/pom.xml +++ b/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> \ No newline at end of file diff --git a/src/main/java/com/ots/common/enums/ReportTitle.java b/src/main/java/com/ots/common/enums/ReportTitle.java deleted file mode 100644 index fccd1ea..0000000 --- a/src/main/java/com/ots/common/enums/ReportTitle.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.ots.common.enums; - -/** - * @author zhijie - * @date 2021/03/19 - * @Description: 鎶ュ憡閭欢鏍囬绫� - */ -public enum ReportTitle { - ZH("濮撳悕","Chinese", "%s鐨�%s娴嬭瘎鎶ュ憡"), - US("Name","English", "%s's %s Report"), - TAI("喔娻阜喙堗腑","Thai", "喔`覆喔⑧竾喔侧笝喔佮覆喔`笡喔`赴喙�喔∴复喔� %s 喔傕腑喔� %s"), - ; - public final String field; - public final String langType; - public final String reportTitle; - - - - ReportTitle(String field,String langType, String reportTitle) { - this.field = field; - this.langType = langType; - this.reportTitle = reportTitle; - } - - public static String getReportTitle(String langType) { - ReportTitle[] types = ReportTitle.values(); - for (ReportTitle type : types) { - if (type.langType.equals(langType)) { - return type.reportTitle; - } - } - return ""; - } - - public static String getField(String langType) { - ReportTitle[] types = ReportTitle.values(); - for (ReportTitle type : types) { - if (type.langType.equals(langType)) { - return type.field; - } - } - return ""; - } -} diff --git a/src/main/java/com/ots/common/enums/ReportTypeEnum.java b/src/main/java/com/ots/common/enums/ReportTypeEnum.java index f78eaba..624b286 100644 --- a/src/main/java/com/ots/common/enums/ReportTypeEnum.java +++ b/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) { diff --git a/src/main/java/com/ots/common/utils/poi/WordUtil.java b/src/main/java/com/ots/common/utils/poi/WordUtil.java index 34a17cc..6de620f 100644 --- a/src/main/java/com/ots/common/utils/poi/WordUtil.java +++ b/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(); diff --git a/src/main/java/com/ots/project/exam/domain/TLibraryCode.java b/src/main/java/com/ots/project/exam/domain/TLibraryCode.java index 312bb3b..87417d6 100644 --- a/src/main/java/com/ots/project/exam/domain/TLibraryCode.java +++ b/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; diff --git a/src/main/java/com/ots/project/tool/ShellTool.java b/src/main/java/com/ots/project/tool/ShellTool.java index 715583b..b93fa55 100644 --- a/src/main/java/com/ots/project/tool/ShellTool.java +++ b/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()杩斿洖褰撳墠搴旂敤绋嬪簭鐨凴untime瀵硅薄 - 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 ")); } } diff --git a/src/main/java/com/ots/project/tool/email/EmailMessageImpl.java b/src/main/java/com/ots/project/tool/email/EmailMessageImpl.java index b697c65..5c05dff 100644 --- a/src/main/java/com/ots/project/tool/email/EmailMessageImpl.java +++ b/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"; diff --git a/src/main/java/com/ots/project/tool/email/SimpleMailSender.java b/src/main/java/com/ots/project/tool/email/SimpleMailSender.java index 257f266..b4cd559 100644 --- a/src/main/java/com/ots/project/tool/email/SimpleMailSender.java +++ b/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("璇勬祴绯荤粺娴嬭瘯閭�璇烽摼鎺ttp://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"}; diff --git a/src/main/java/com/ots/project/tool/exam/ExamUtil.java b/src/main/java/com/ots/project/tool/exam/ExamUtil.java index a29dfff..ccc5170 100644 --- a/src/main/java/com/ots/project/tool/exam/ExamUtil.java +++ b/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"); diff --git a/src/main/java/com/ots/project/tool/exam/ImageUtil.java b/src/main/java/com/ots/project/tool/exam/ImageUtil.java index ff2b699..b0c1724 100644 --- a/src/main/java/com/ots/project/tool/exam/ImageUtil.java +++ b/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); } } diff --git a/src/main/java/com/ots/project/tool/report/CAQ/CAQReport.java b/src/main/java/com/ots/project/tool/report/CAQ/CAQReport.java index 07adf38..37d5129 100644 --- a/src/main/java/com/ots/project/tool/report/CAQ/CAQReport.java +++ b/src/main/java/com/ots/project/tool/report/CAQ/CAQReport.java @@ -23,14 +23,7 @@ private String reportDate; private String testToken; - - /** - * 鑾峰彇鎶ュ憡瀛楀吀鐨刢ode璺焩alue - * @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(); - //閬嶅巻鍒濆鍖朿ode瀛楀吀鍊肩殑value getParamList(type).stream().forEach(p -> { TLibraryCode calculate = p.calculate(thaiCalculationMap, langType); - //淇濆瓨缃崲鍚庢枃鏈瓧鍏� 渚�:LIBCAQ0015 : 璇ュ�欓�変汉鍦ㄦ娊璞℃帹鐞嗚兘鍔涢儴鍒�20棰樹腑鍥炵瓟姝g‘鐨勯鏁帮細<BoldText>14</BoldText> textMap.put(p.getName(), Objects.isNull(calculate) || StringUtils.isBlank(calculate.getLangTypeContext(langType)) ? "N/A NONE" : calculate.getLangTypeContext(langType)); - //淇濆瓨鍥剧墖瀛楀吀 渚嬪瓙锛歅_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" diff --git a/src/main/java/com/ots/project/tool/report/MAQ/base/BaseCondition.java b/src/main/java/com/ots/project/tool/report/MAQ/base/BaseCondition.java index 34cd069..5176400 100644 --- a/src/main/java/com/ots/project/tool/report/MAQ/base/BaseCondition.java +++ b/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 + "%"; diff --git a/src/main/java/com/ots/project/tool/report/MAQ/base/MAQConditionVO.java b/src/main/java/com/ots/project/tool/report/MAQ/base/MAQConditionVO.java index d379165..501f13f 100644 --- a/src/main/java/com/ots/project/tool/report/MAQ/base/MAQConditionVO.java +++ b/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; diff --git a/tai-ots-framework.iml b/tai-ots-framework.iml index 8cdebc4..04ddbce 100644 --- a/tai-ots-framework.iml +++ b/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> \ No newline at end of file -- Gitblit v1.9.1