| | |
| | | import com.ots.project.tool.exam.ExamUtil; |
| | | import com.ots.project.tool.exam.ImageUtil; |
| | | import com.ots.project.tool.exam.ZipUtil; |
| | | import com.ots.project.tool.libreoffice.LibreOfficeUtil; |
| | | import com.ots.project.tool.report.CIAQ.chart.CIAQChart; |
| | | 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; |
| | |
| | | |
| | | if (checkText(runValue)) { |
| | | runValue = runValue.replaceAll("%.*%", ""); |
| | | runValue = runValue.replaceAll("N/A NONE", ""); |
| | | |
| | | } |
| | | runValue = runValue.replaceAll("N/A NONE", ""); |
| | | |
| | | return runValue; |
| | | } |
| | |
| | | |
| | | //模板文件需要加锁 |
| | | out = getDownLoadFileOutputStream(reportName); |
| | | synchronized (fileName.intern()){ |
| | | //synchronized (fileName.intern()){ |
| | | //String templateType = tReportTemplate.getTemplateType(); |
| | | setChageWord(fileName, out, textMap, tReportTemplate.getReportType(),tReportTemplate.getDataPath(), autoTableMap); |
| | | out.flush(); |
| | | changColorIfJAQ(textMap, out, reportName, tReportTemplate.getReportType()); |
| | | } |
| | | //} |
| | | |
| | | //PAQ、MAQTR采用新的doc转pdf |
| | | if(ReportTypeEnum.PAQ.getCode().equals(reportType) || ReportTypeEnum.MAQTR.getCode().equals(reportType)){ |
| | | //PAQ、MAQTR采用、CIAQ新的doc转pdf |
| | | if(ReportTypeEnum.PAQ.getCode().equals(reportType) || ReportTypeEnum.MAQTR.getCode().equals(reportType) |
| | | || ReportTypeEnum.CIAQ.getCode().equals(reportType)){ |
| | | PdfUtil.convertPDF(EssConfig.getProfile() + "/" + reportName); |
| | | }else if(ReportTypeEnum.LAQ.getCode().equals(reportType)){ |
| | | PdfUtil.dockerConvertPDF(EssConfig.getProfile(),EssConfig.getDocx2pdfPath(),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")); |
| | | 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); |
| | | |
| | |
| | | */ |
| | | 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); |
| | | |
| | | |
| | | |
| | | //插入表格 |
| | | addTableValue(document, autoTableMap); |
| | |
| | | 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 { |
| | |
| | | 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())) { |
| | | LAQChart.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(); |