From 92717109d0ea10ca15f915c8cd4c3804d9d2af93 Mon Sep 17 00:00:00 2001 From: zhijie <1003392067@qq.com> Date: 星期一, 03 一月 2022 18:38:52 +0800 Subject: [PATCH] 最新代码 --- src/main/java/com/ots/common/utils/poi/WordUtil.java | 76 +++++++++++++++++++------------------- 1 files changed, 38 insertions(+), 38 deletions(-) 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 dcd4fac..b859c5f 100644 --- a/src/main/java/com/ots/common/utils/poi/WordUtil.java +++ b/src/main/java/com/ots/common/utils/poi/WordUtil.java @@ -9,6 +9,7 @@ import com.ots.project.exam.domain.TReportTemplate; import com.ots.project.exam.dto.JAQTableStyle; import com.ots.project.exam.dto.WordParam; +import com.ots.project.tool.PdfUtil; import com.ots.project.tool.ShellTool; import com.ots.project.tool.exam.ExamUtil; import com.ots.project.tool.exam.ImageUtil; @@ -17,6 +18,7 @@ import com.ots.project.tool.report.JAQ.condition.Table2; import com.ots.project.tool.report.JAQ.condition.Table3; import com.ots.project.tool.report.JAQ.condition.Table4; +import com.ots.project.tool.report.PAQ.chart.PAQChart; import com.ots.project.tool.report.SAQ.chart.SAQChart; import org.apache.commons.collections.map.HashedMap; import org.apache.poi.ooxml.POIXMLDocument; @@ -427,12 +429,30 @@ } } } - + + //鏍¢獙鏂囨湰鏄惁闇�瑕佹浛鎹� public static boolean checkText(String text) { + //鏇挎崲鏂囨湰鍖呭惈% if (text.indexOf("%") != -1 || StringUtils.equals(text, "N/A NONE")) { - return true; + //鍙湁%澶т簬1 鎵嶉�氳繃 + if(getCount(text) > 1){ + return true; + } + return false; } return false; + } + + //鍒ゆ柇%鍑虹幇鐨勬鏁� + public static int getCount(String text){ + //鏃ч暱搴� + int oldLength = text.length(); + text = text.replace("%", ""); + //鏂伴暱搴� + int newLength = text.length(); + //鍑虹幇娆℃暟 = 鏃ч暱搴� - 鏂伴暱搴� + int count = oldLength - newLength; + return count; } public static String changeValue(String runValue, Map<String, Object> textMap, XWPFRun run, XWPFParagraph paragraph, XWPFDocument document, int runPosition) throws IOException, org.apache.poi.openxml4j.exceptions.InvalidFormatException { @@ -604,38 +624,6 @@ } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - private static void changOtherPicture(XWPFParagraph paragraph) { String paragraphText = paragraph.getText(); @@ -765,7 +753,12 @@ setChageWord(fileName, out, textMap, tReportTemplate.getReportType(), templateType, autoTableMap); out.flush(); changColorIfJAQ(textMap, out, reportName, tReportTemplate.getReportType()); - ShellTool.execLibreofficeCommand("pdf", EssConfig.getProfile() + "/" + reportName, EssConfig.getProfile() + "/"); + //PAQ閲囩敤鏂扮殑doc杞琾df + if(!ReportTypeEnum.PAQ.getCode().equals(reportType)){ + ShellTool.execLibreofficeCommand("pdf", EssConfig.getProfile() + "/" + reportName, EssConfig.getProfile() + "/"); + }else{ + PdfUtil.convertPDF(EssConfig.getProfile() + "/" + reportName); + } zipFilePath = getPdfPath(reportName); deleteFileStrList.add(EssConfig.getProfile() + "/" + reportName); @@ -855,8 +848,8 @@ changeTextBox(document, textMap); //璁剧疆鍥捐〃 - if (Objects.equals(reportType, ReportTypeEnum.SAQ.getCode())) { - SAQChart.changeChart(document, textMap); + if (Objects.equals(reportType, ReportTypeEnum.PAQ.getCode())) { + PAQChart.changeChart(document, textMap); } //鎻掑叆琛ㄦ牸 @@ -968,7 +961,7 @@ } if (StringUtils.equals(reportType, ReportTypeEnum.MAQ.getCode())) { setMAQCompleteChars(textMap, charts); - } else if (StringUtils.equals(reportType, ReportTypeEnum.MAQV2.getCode())) { + } else if (StringUtils.equals(reportType, ReportTypeEnum.MAQV2.getCode()) || StringUtils.equals(reportType, ReportTypeEnum.MAQIAR.getCode())) { setMAQ_V2CompleteChars(textMap, charts); } else if (StringUtils.equals(reportType, ReportTypeEnum.RuiLin.getCode())) { setRuiLinChar(textMap, charts); @@ -1297,4 +1290,11 @@ } return result.size(); } + + + public static void main(String[] args) { + if (!checkText("浜烘墠閫夋嫈鐨勭洰鐨勫氨鏄壘鍒拌兘澶熻儨浠诲伐浣溿�佹効鎰忔壙鎷呭伐浣滐紝涓斾笌缁勭粐鐨勯渶姹傘�佹枃鍖栥�佷环鍊艰鐩稿尮閰嶇殑浜恒�侾AQ鎶ュ憡鏄牴鎹�欓�変汉瀵筆AQ闂嵎涓鐩殑浣滅瓟淇℃伅鑰岀敓鎴愮殑锛屾祴閲忕殑鏄�欓�変汉鍦ㄥ伐浣滀腑鍋忓ソ鐨勮涓洪鏍笺�侾AQ涔熷寘鎷簡瀵逛綔绛旂湡瀹炴�х殑娴嬮噺锛屽悓鏃朵篃瑁呭叆浜員AI涓撴湁鐨勪綔鍋囬槻鑼冪▼搴忥紝鍙互鏈夋晥闄嶄綆鍊欓�変汉鐨勪吉瑁呭ソ鍊惧悜锛堝叏鐞�30%鐨勮嚜璇勯棶鍗蜂腑閮藉嚭鐜颁簡浼濂界幇璞★級銆�")) { + System.out.println("11"); + } + } } -- Gitblit v1.9.1