From 7df8a8bea313a270014a1de4ae0de4c69172c5bf Mon Sep 17 00:00:00 2001 From: wzp <2040239371@qq.com> Date: 星期三, 31 七月 2024 11:15:43 +0800 Subject: [PATCH] 优化图表里的标签显示,设置一定的偏移量,确保标签都在图表内 --- src/main/java/com/ots/common/utils/poi/WordUtil.java | 435 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 387 insertions(+), 48 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 4363b87..53c83c4 100644 --- a/src/main/java/com/ots/common/utils/poi/WordUtil.java +++ b/src/main/java/com/ots/common/utils/poi/WordUtil.java @@ -16,12 +16,20 @@ import com.ots.project.tool.ShellTool; import com.ots.project.tool.exam.ExamUtil; import com.ots.project.tool.exam.ImageUtil; +import com.ots.project.tool.exam.JsonUtil; import com.ots.project.tool.exam.ZipUtil; +import com.ots.project.tool.libreoffice.LibreOfficeUtil; +import com.ots.project.tool.report.APIFan.chart.APIFanChart; +import com.ots.project.tool.report.CIAQ.chart.CIAQChart; +import com.ots.project.tool.report.JAQ.condition.JAQTeam; +import com.ots.project.tool.report.LAQ.chart.LAQAllChart; +import com.ots.project.tool.report.LAQ.chart.LAQChart; import com.ots.project.tool.report.MAQTR.chart.MAQTRChart; import com.ots.project.tool.report.PAQ.chart.PAQChart; import org.apache.commons.collections.map.HashedMap; import org.apache.poi.ooxml.POIXMLDocument; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; +import org.apache.poi.openxml4j.util.ZipSecureFile; import org.apache.poi.util.Units; import org.apache.poi.xwpf.usermodel.*; import org.apache.xmlbeans.XmlCursor; @@ -37,9 +45,15 @@ import org.slf4j.LoggerFactory; import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import springfox.documentation.spring.web.json.Json; + import java.awt.image.BufferedImage; import java.io.*; +import java.time.LocalDate; import java.util.*; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -309,6 +323,7 @@ log.info("琛ㄦ牸鏁版嵁锛�" + table.getText()); //澧炲姞琛ㄦ牸鎴栬�呮笡灏戣〃鏍� if (Objects.equals(textMap.get("sendEmailFileName"), ReportTypeEnum.JAQ.getCode())) { + log.info("琛細{}",i); addOrDelTableRow(table,i,textMap); } if (checkText(table.getText())) { @@ -336,12 +351,15 @@ Integer tableNum = Integer.valueOf(textMap.get(tableEnum.getName()).toString()); Integer rows = table.getRows().size(); + log.info("[娴嬭瘯]-tableEnum锛�"+tableEnum.toString()); + //琛�1-琛�3 闇�鍓旈櫎琛ㄥご Integer contentRows = rows - 1; //琛�4 闇�鍓旈櫎琛ㄥご璺熷熬閮ㄩ鐣欒鏁� if(tableEnum == TableEnum.table4){ - contentRows -= 5; - rows -= 5; + //濡傛灉琛�4锛岃澧炲姞鏄剧ず琛岋紝杩欓噷瑕佹敼鍔� + contentRows -= 3; + rows -= 3; //琛�4 琛屼负琛ㄧ幇涓句緥澶勭悊 Integer table4ChildrenNum = Integer.valueOf(textMap.get(TableEnum.table4Children.getName()).toString()); @@ -383,39 +401,75 @@ } } - //闄愬埗琛屾暟涓嶄负绌� 鍜� 闄愬埗琛屾暟璺熸姤鍛婄幇鏈変笉涓�鑷撮渶杩涜澶勭悊 - if(tableNum != null && !tableNum.equals(contentRows)){ - if(tableNum > contentRows){ - //澧炲姞琛屾暟 - Integer addRow = tableNum - contentRows; - log.info("{}澧炲姞{}琛�",tableEnum.getName(),addRow); - for (int i = rows; i < rows+addRow; i++) { - addJAQTable(table,tableEnum,i,textMap); - } + //table5涓嶉渶瑕佽拷鍔狅紝鍗曠嫭澶勭悊 + if(tableEnum != TableEnum.table5) { + //闄愬埗琛屾暟涓嶄负绌� 鍜� 闄愬埗琛屾暟璺熸姤鍛婄幇鏈変笉涓�鑷撮渶杩涜澶勭悊 + if (tableNum != null && !tableNum.equals(contentRows)) { + if (tableNum > contentRows) { + //澧炲姞琛屾暟 + Integer addRow = tableNum - contentRows; + log.info("{}澧炲姞{}琛�", tableEnum.getName(), addRow); + for (int i = rows; i < rows + addRow; i++) { + addJAQTable(table, tableEnum, i, textMap); + } - }else{ - //鍑忓皯琛屾暟 - Integer delRow = rows - tableNum; - for (int i = contentRows; i > rows-delRow; i--) { - delJAQTable(table,i); + } else { + //鍑忓皯琛屾暟 + Integer delRow = rows - tableNum; + for (int i = contentRows; i > rows - delRow; i--) { + delJAQTable(table, i); + } + log.info("{}鍑忓皯{}琛屾暟", TableEnum.codeOf(index).getName(), delRow - 1); } - log.info("{}鍑忓皯{}琛屾暟",TableEnum.codeOf(index).getName(),delRow-1); } } + //濡傛灉琛�4锛岃澧炲姞鏄剧ず琛岋紝杩欓噷瑕佹敼鍔� //琛�4 鑳滀换鍔涢鐣欎綅缃簭鍙峰鐞� if(tableEnum == TableEnum.table4){ - if(tableNum != null && tableNum != 8){ - for (int i = tableNum; i <= tableNum + 4; i++) { + if(tableNum != null && tableNum != 12){ + for (int i = tableNum; i <= tableNum + 2; i++) { + if(i+2 > table.getRows().size()){ + continue; + } XWPFTableRow row = table.getRows().get(i+2); List<XWPFTableCell> cells = row.getTableCells(); changeText(cells.get(0).getParagraphs().get(0),"#"+(i+1)+"."); } } } + + + //琛�6锛屾樉绀篔AQ鎶ュ憡鍙備笌浜� + if(tableEnum == TableEnum.table5) + { + log.info("銆愯〃5銆戝紑濮嬪鐞�...{}",tableNum); +// if(tableNum != null && !tableNum.equals(contentRows)) { +// if (tableNum > contentRows) { +// //澧炲姞琛屾暟 +// Integer addRow = tableNum - contentRows; +// log.info("{}澧炲姞{}琛�", tableEnum.getName(), addRow); +// for (int i = rows; i < rows + addRow; i++) { +// addJAQTable(table, tableEnum, i, textMap); +// } +// } +// } + if(tableNum>0) + { + for(int i=rows;i<rows+tableNum;i++) + { + addJAQTable(table, tableEnum, i, textMap); + } + + delJAQTable(table,1); + } + log.info("銆愯〃5銆戝鐞嗗畬鎴�..."); + } + }catch (Exception e){ e.printStackTrace(); log.info("琛▄}澧炲姞琛ㄦ牸鎴栬�呮笡灏戣〃鏍煎紓甯�",index+1); + log.info("寮傚父锛歿}",e.getMessage()); } } @@ -467,6 +521,7 @@ XWPFTableRow row = table.getRows().get(index); List<XWPFTableCell> cells = row.getTableCells(); + switch (tableEnum){ case table1: cells.get(0).getParagraphs().get(0).getRuns().get(0).setText(textMap.get("T1rank"+index)+""); @@ -537,6 +592,48 @@ cell.getParagraphs().get(cell.getParagraphs().size()-1).getRuns().get(0).setText(null); } } + break; + case table5: + log.info("[add] table5,澧炲姞琛屻�俰ndex={}",index); + String teamUsers = textMap.get("teamUserList").toString(); + List<JAQTeam> teamUserList = JsonUtil.toJsonListObject(teamUsers,JAQTeam.class); + + int keyIndex = index-2; + if(keyIndex>=0) + { + log.info("褰撳墠keyIndex:{}",keyIndex); + for(int k =0;k<3;k++) + { + XWPFParagraph p =cells.get(k).getParagraphs().get(0); + List<XWPFRun> runs = p.getRuns(); + if(runs.isEmpty()) + { + p.createRun(); + } + for (int i = runs.size()-1;i>0;i--) + { + p.removeRun(i); + } + XWPFRun run = runs.get(0); + + switch (k){ + case 0:run.setText(String.valueOf(keyIndex+1),0); break; + case 1:run.setText(teamUserList.get(keyIndex).getTeamName(),0);break; + case 2:run.setText(teamUserList.get(keyIndex).getTeamDepart(),0);break; + case 3:run.setText(teamUserList.get(keyIndex).getTeamName(),0);break; + default:break; + } + } + } + + + + + +// cells.get(0).getParagraphs().get(0).getRuns().get(0).setText(index.toString()); +// cells.get(1).getParagraphs().get(0).getRuns().get(0).setText(teamUserList.get(index).getTeamName()); +// cells.get(2).getParagraphs().get(0).getRuns().get(0).setText(teamUserList.get(index).getTeamDepart()); +// cells.get(3).getParagraphs().get(0).getRuns().get(0).setText(teamUserList.get(index).getTeamName()); break; } } @@ -899,9 +996,8 @@ if (checkText(runValue)) { runValue = runValue.replaceAll("%.*%", ""); - runValue = runValue.replaceAll("N/A NONE", ""); - } + runValue = runValue.replaceAll("N/A NONE", ""); return runValue; } @@ -1119,7 +1215,7 @@ if(StringUtils.contains(keyValue, "%table-line-feed%")){ String[] keyValues = keyValue.split("%table-line-feed%"); runValue = delDynList(keyTemp, Arrays.asList(keyValues), paragraph, document,1); - }else{ + }else if(StringUtils.contains(keyValue, "%line-feed%")){ String[] keyValues = keyValue.split("%line-feed%"); runValue = delDynList(keyTemp, Arrays.asList(keyValues), paragraph, document,0); } @@ -1164,21 +1260,46 @@ reportType = getTypeIfIsSAQ(tReportTemplate, reportType); reportType = getPositionIfJAQ(textMap, reportType); reportName = textMap.get("sendEmailFileName") + "_" + reportType + "_" + ReportTypeNameEnum.valueOf(tReportTemplate.getTemplateType()).getCode() + "_" + ReportTypeNameEnum.valueOf(tReportTemplate.getLangType()).getCode() + ".docx"; - reportName = reportName.replaceAll(" ", "_"); - out = getDownLoadFileOutputStream(reportName); - log.info("reportTemplate:" + fileName); - //String templateType = tReportTemplate.getTemplateType(); - setChageWord(fileName, out, textMap, tReportTemplate.getReportType(),tReportTemplate.getDataPath(), autoTableMap); + //妯℃澘鏂囦欢闇�瑕佸姞閿� + out = getDownLoadFileOutputStream(reportName); + //synchronized (fileName.intern()){ + //String templateType = tReportTemplate.getTemplateType(); + long startTime1 = System.currentTimeMillis(); + setChageWord(fileName, out, textMap, tReportTemplate.getReportType(), tReportTemplate.getDataPath(), autoTableMap); + // 鑾峰彇缁撴潫鏃堕棿 + long endTime1 = System.currentTimeMillis(); + // 璁$畻鑰楁椂锛堝崟浣嶏細姣锛� + long duration1 = endTime1 - startTime1; + log.info("setChageWord 绋嬪簭鎵ц鑰楁椂锛�" + duration1 + " 姣锛岀敓鎴愭姤鍛婏細"+reportName); + out.flush(); changColorIfJAQ(textMap, out, reportName, tReportTemplate.getReportType()); - //PAQ銆丮AQTR閲囩敤鏂扮殑doc杞琾df - if(ReportTypeEnum.PAQ.getCode().equals(reportType) || ReportTypeEnum.MAQTR.getCode().equals(reportType)){ + //} + + //PAQ銆丮AQTR閲囩敤銆丆IAQ銆丄PIFan鏂扮殑doc杞琾df + if(ReportTypeEnum.PAQ.getCode().equals(reportType) || ReportTypeEnum.MAQTR.getCode().equals(reportType) + || ReportTypeEnum.CIAQ.getCode().equals(reportType) ||ReportTypeEnum.API_Fan.getCode().equals(reportType)){ PdfUtil.convertPDF(EssConfig.getProfile() + "/" + reportName); + }else if(ReportTypeEnum.LAQ.getCode().equals(reportType)){ + // 鑾峰彇寮�濮嬫椂闂� + long startTime = System.currentTimeMillis(); + + PdfUtil.dockerConvertPDF(EssConfig.getProfile(),EssConfig.getDocx2pdfPath(),reportName); + // 鑾峰彇缁撴潫鏃堕棿 + long endTime = System.currentTimeMillis(); + // 璁$畻鑰楁椂锛堝崟浣嶏細姣锛� + long duration = endTime - startTime; + log.info("dockerConvertPDF 绋嬪簭鎵ц鑰楁椂锛�" + duration + " 姣锛岀敓鎴愭姤鍛婏細"+reportName); + }else{ ShellTool.execLibreofficeCommand("pdf", EssConfig.getProfile() + "/" + reportName, EssConfig.getProfile() + "/"); + // ShellTool shellTool = ShellTool.builder(); + // shellTool.execNewLibreofficeCommand("pdf", EssConfig.getProfile() + "/" + reportName, EssConfig.getProfile() + "/" + reportName.replace("docx","pdf")); + //鏂版柟娉曟祴璇� + //LibreOfficeUtil.convertOffice2PDFSyncIsSuccess(new File(EssConfig.getProfile() + "/" + reportName),new File(EssConfig.getProfile() + "/" + reportName.replace("docx","pdf"))); } zipFilePath = getPdfPath(reportName); @@ -1193,6 +1314,128 @@ } return zipFilePath; } + + + /** + * LAQ浣跨敤-----澶參浜嗐�傚お鎱簡 + * @param fileName + * @param tReportTemplate + * @param textMap + * @param autoTableMap + * @param deleteFileStrList + * @return + */ + private static List<String> reportNameList = new ArrayList<>(); + public static String makeReportFileForLAQ(String fileName, TReportTemplate tReportTemplate, Map<String, Object> textMap, Map<Integer, Map<Integer, List<String[]>>> autoTableMap, List<String> deleteFileStrList,Integer index,Integer totalNum,Boolean cleanFlag) { + String returnMessage = "瀵煎嚭妯℃澘杞Щ閿欒:"; + InputStream in = null; + FileOutputStream out = null; + String zipFilePath = ""; + String reportName = ""; + + if(cleanFlag) + { + reportNameList = new ArrayList<>(); + } + + try { + + String reportType = tReportTemplate.getReportType(); + reportName = textMap.get("sendEmailFileName") + "_" + reportType + "_" + ReportTypeNameEnum.valueOf(tReportTemplate.getTemplateType()).getCode() + "_" + ReportTypeNameEnum.valueOf(tReportTemplate.getLangType()).getCode() + ".docx"; + reportName = reportName.replaceAll(" ", "_"); + + reportNameList.add(reportName); + + //妯℃澘鏂囦欢闇�瑕佸姞閿� + out = getDownLoadFileOutputStream(reportName); + + long startTime1 = System.currentTimeMillis(); + setChageWord(fileName, out, textMap, tReportTemplate.getReportType(), tReportTemplate.getDataPath(), autoTableMap); + // 鑾峰彇缁撴潫鏃堕棿 + long endTime1 = System.currentTimeMillis(); + // 璁$畻鑰楁椂锛堝崟浣嶏細姣锛� + long duration1 = endTime1 - startTime1; + log.info("setChageWord 绋嬪簭鎵ц鑰楁椂锛�" + duration1 + " 姣锛岀敓鎴愭姤鍛婏細"+reportName); + + out.flush(); + +// if(ReportTypeEnum.LAQ.getCode().equals(reportType)){ +// // 鑾峰彇寮�濮嬫椂闂� +// long startTime = System.currentTimeMillis(); +// +// PdfUtil.dockerConvertPDF(EssConfig.getProfile(),EssConfig.getDocx2pdfPath(),reportName); +// // 鑾峰彇缁撴潫鏃堕棿 +// long endTime = System.currentTimeMillis(); +// // 璁$畻鑰楁椂锛堝崟浣嶏細姣锛� +// long duration = endTime - startTime; +// log.info("dockerConvertPDF 绋嬪簭鎵ц鑰楁椂锛�" + duration + " 姣锛岀敓鎴愭姤鍛婏細"+reportName); +// } + if(Objects.equals(index, totalNum)) + { + //骞惰杞崲 + execLAQ2PDF(reportNameList); + } + + zipFilePath = getPdfPath(reportName); + + deleteFileStrList.add(EssConfig.getProfile() + "/" + reportName); + } catch (Exception ex) { + returnMessage = returnMessage + ex.getMessage(); + deleteFileStrList.add(EssConfig.getProfile() + "/" + reportName); + log.error("瀵煎嚭妯℃澘杞Щ閿欒锛歿}\n妫�鏌ユ枃浠讹細" + fileName, returnMessage, ex); + } finally { + closeChannel(out); + closeChannel(in); + } + return zipFilePath; + } + + + private static void execLAQ2PDF(List<String> reportNames) + { + // 鑾峰彇寮�濮嬫椂闂� + long startTime = System.currentTimeMillis(); + // 鎺у埗骞惰鎵ц鐨勬渶澶х嚎绋嬫暟 + int parallelism = 2; // 璁剧疆涓轰綘甯屾湜鐨勫苟琛屾暟閲� + + // 鍒涘缓涓�涓浐瀹氬ぇ灏忕殑绾跨▼姹� + ExecutorService executor = Executors.newFixedThreadPool(parallelism); + + // 鍒涘缓涓�涓� CompletableFuture 鍒楄〃锛屾瘡涓� CompletableFuture 琛ㄧず涓�涓紓姝ヤ换鍔� + List<CompletableFuture<Void>> futures = new ArrayList<>(); + + // 鏋勫缓寮傛浠诲姟鍒楄〃 + for (String reportName : reportNames) { + CompletableFuture<Void> future = CompletableFuture.runAsync(() -> { + try { + long oneTime = System.currentTimeMillis(); + PdfUtil.dockerConvertPDF(EssConfig.getProfile(), EssConfig.getDocx2pdfPath(), reportName); + long twoTime = System.currentTimeMillis(); + long dura = twoTime - oneTime; + log.info("杞崲鎴愬姛锛� " + reportName + " successfully.鑰楁椂锛�"+dura); + } catch (Exception e) { + log.info("杞崲澶辫触锛� " + reportName + ": " + e.getMessage()); + } + }, executor); // 浣跨敤鎸囧畾鐨勭嚎绋嬫睜鎵ц浠诲姟 + futures.add(future); + } + + // 绛夊緟鎵�鏈夊紓姝ヤ换鍔″畬鎴� + CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join(); + + // 鍏抽棴绾跨▼姹� + executor.shutdown(); + // 鑾峰彇缁撴潫鏃堕棿 + long endTime = System.currentTimeMillis(); + // 璁$畻鑰楁椂锛堝崟浣嶏細姣锛� + long duration = endTime - startTime; + log.info("execLAQ2PDF 绋嬪簭鎵ц鑰楁椂锛�" + duration + " 姣"); + log.info("鎵�鏈夌嚎绋嬮兘鎵ц瀹屾垚锛�"); + } + + + + @Nullable private static String getPositionIfJAQ(Map<String, Object> textMap, String reportType) { if (Objects.equals(reportType, "JAQ")) { @@ -1214,10 +1457,14 @@ private static String getPdfPath(String reportName) { return reportName.substring(0, reportName.lastIndexOf(".")) + ".pdf"; } + + + //鍒犻櫎鏂囦欢 public static void deleteFileByStr(List<String> deleteFileStrList) { for (String deleteStr : deleteFileStrList) { File file = new File(deleteStr); + log.info("鍒犻櫎鏂囦欢锛�"+deleteStr); file.delete(); } } @@ -1271,14 +1518,32 @@ */ private static void setChageWord(String fileName, OutputStream out, Map<String, Object> textMap, String reportType,String dataPath, Map<Integer, Map<Integer, List<String[]>>> autoTableMap) throws IOException, InvalidFormatException, DocumentException { //String filePath = getTemplateDownLoadPathByUpLoad(fileName); + ZipSecureFile.setMinInflateRatio(0.001); XWPFDocument document = new XWPFDocument(POIXMLDocument.openPackage(getTemplateDownLoadPathByUpLoad(fileName))); - //璁剧疆鏂囨湰 - changeText(document, textMap); + if (StringUtils.equals(reportType, ReportTypeEnum.JAQ.getCode())) { + //璁剧疆鏂囨湰妗� + changeTextBox(document, textMap); - //璁剧疆鏂囨湰妗� - changeTextBox(document, textMap); + //璁剧疆鏂囨湰 + changeText(document, textMap); + }else { + //璁剧疆鏂囨湰 + changeText(document, textMap); + + //璁剧疆鏂囨湰妗� + changeTextBox(document, textMap); + } + +// //璁剧疆鏂囨湰妗� +// changeTextBox(document, textMap); +// +// //璁剧疆鏂囨湰 +// changeText(document, textMap); + + //淇敼椤佃剼 + changeFootNotes(document,textMap); //鎻掑叆琛ㄦ牸 addTableValue(document, autoTableMap); @@ -1290,6 +1555,49 @@ changChart(textMap, document, reportType,dataPath); document.write(out); } + + /** + * 淇敼椤佃剼锛堜富瑕佹槸鎶婂勾闄愮粰鎹簡锛� + * @param document + * @param textMap + * @throws DocumentException + */ + private static void changeFootNotes(XWPFDocument document,Map<String,Object> textMap) throws DocumentException{ + + LocalDate currentDate = LocalDate.now(); + int year = currentDate.getYear(); + + // 鑾峰彇鎵�鏈夐〉 + List<XWPFFooter> footers = document.getFooterList(); + + for (XWPFFooter footer : footers) { + // 鑾峰彇姣忎釜椤佃剼鐨勬钀� + List<XWPFParagraph> paragraphs = footer.getParagraphs(); + + // 鎵撳嵃姣忎釜娈佃惤鐨勬枃鏈� + for (XWPFParagraph paragraph : paragraphs) { + System.out.println(paragraph.getText()); + + log.info("銆愰〉鑴氥�戯細{}",paragraph.getText()); + if(paragraph.getText().contains("%year%")) + { + // 鑾峰彇娈佃惤涓殑鎵�鏈塺un + List<XWPFRun> runs = paragraph.getRuns(); + + // 鏇挎崲鏂囨湰 + for (XWPFRun run : runs) { + String text = run.getText(0); + if (text != null && text.contains("%year%")) { + text = text.replace("%year%", String.valueOf(year)); + run.setText(text, 0); + } + } + } + } + } + + } + private static void changeTextBox(XWPFDocument document, Map<String, Object> textMap) throws DocumentException { List<XWPFParagraph> paragraphs = document.getParagraphs(); @@ -1325,7 +1633,7 @@ String key = "%" + textSet.getKey() + "%"; if (text.indexOf(key) != -1) { - text = text.replaceAll(key, (String) textMap.get(textSet.getKey())); + text = text.replaceAll(key, String.valueOf(textMap.get(textSet.getKey()))); repText = text; if (checkText(text)) { continue; @@ -1338,9 +1646,9 @@ repText = repText.replaceAll("<BoldText>", ""); repText = repText.replaceAll("</BoldText>", ""); } - if (repText.indexOf("N/A NONE") != -1) { +/* 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 { @@ -1387,19 +1695,42 @@ if (ExamUtil.isListEmpty(charts)) { return; } - if (StringUtils.equals(reportType, ReportTypeEnum.MAQ.getCode())) { - setMAQCompleteChars(textMap, charts); - } 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); - } else if (StringUtils.equals(reportType, ReportTypeEnum.PAQ.getCode())) { - PAQChart.changeChart(document, textMap); - } else if (StringUtils.equals(reportType, ReportTypeEnum.MAQTR.getCode())) { - MAQTRChart.changeMAQTRChart(document, dataPath); - } else { - return; + try{ + if (StringUtils.equals(reportType, ReportTypeEnum.MAQ.getCode())) { + setMAQCompleteChars(textMap, charts); + } 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); + } else if (StringUtils.equals(reportType, ReportTypeEnum.PAQ.getCode())) { + PAQChart.changeChart(document, textMap); + } else if (StringUtils.equals(reportType, ReportTypeEnum.MAQTR.getCode())) { + MAQTRChart.changeMAQTRChart(document, dataPath); + } else if (StringUtils.equals(reportType, ReportTypeEnum.CIAQ.getCode())) { + CIAQChart.changeChart(document, textMap); + } else if (StringUtils.equals(reportType, ReportTypeEnum.LAQ.getCode())) { + if(!textMap.containsKey("allList")) + { + System.out.println("涓汉鐢ㄦ埛鎶ュ憡"); + LAQChart.changeChart(document, textMap); + } + else + { + System.out.println("鍏ㄦ櫙鍥炬姤鍛�"); + //濡傛灉鍖呭惈allList锛屽垯娓叉煋鍏ㄦ櫙鍥惧浘琛� + LAQAllChart.changeChart(document,textMap); + } + } else if(StringUtils.equals(reportType, ReportTypeEnum.API_Fan.getCode())) + { + APIFanChart.changeChart(document,textMap); + } + else { + return; + } + }catch (Exception e){ + e.printStackTrace(); } + } private static void setMAQ_V2CompleteChars(Map<String, Object> textMap, List<XWPFChart> charts) { String p_Task31 = textMap.get("P_Task31").toString(); @@ -1773,7 +2104,15 @@ //鏇存敼琛ㄦ牸鐨勫�� textMap.put("sendEmailFileName", "JAQ"); + textMap.put("SelectUsers",8); + //changeTable(document, textMap); + + + changeText(document, textMap); + changeTextBox(document, textMap); + addTableValue(document, null); changeTable(document, textMap); + //changChart(textMap, document, reportType, dataPath); //寤虹珛鏂囦欢瀵硅薄 File file = new File("C:\\Users\\Administrator\\Desktop\\JAQ涓枃鐗�1.docx"); -- Gitblit v1.9.1