diff --git a/com.awspaas.user.apps.coe.pal.output.zd/lib/com.awspaas.user.apps.coe.pal.output.zd.jar b/com.awspaas.user.apps.coe.pal.output.zd/lib/com.awspaas.user.apps.coe.pal.output.zd.jar index 58fdf927..4cef2ff0 100644 Binary files a/com.awspaas.user.apps.coe.pal.output.zd/lib/com.awspaas.user.apps.coe.pal.output.zd.jar and b/com.awspaas.user.apps.coe.pal.output.zd/lib/com.awspaas.user.apps.coe.pal.output.zd.jar differ diff --git a/com.awspaas.user.apps.coe.pal.output.zd/src/com/awspaas/apps/coe/pal/output/zd/InstitutionalTextWeb.java b/com.awspaas.user.apps.coe.pal.output.zd/src/com/awspaas/apps/coe/pal/output/zd/InstitutionalTextWeb.java index f145f5c3..87789fe6 100644 --- a/com.awspaas.user.apps.coe.pal.output.zd/src/com/awspaas/apps/coe/pal/output/zd/InstitutionalTextWeb.java +++ b/com.awspaas.user.apps.coe.pal.output.zd/src/com/awspaas/apps/coe/pal/output/zd/InstitutionalTextWeb.java @@ -34,7 +34,6 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.awspaas.apps.coe.pal.output.zd.util.PrReportComment; import com.awspaas.apps.coe.pal.output.zd.util.ReportRepositoryCompare; -import com.awspaas.apps.coe.pal.output.zd.util.XMLUtil; import com.sini.com.spire.doc.*; import com.sini.com.spire.doc.collections.SectionCollection; import com.sini.com.spire.doc.documents.*; @@ -44,12 +43,9 @@ import com.sini.com.spire.doc.formatting.ParagraphFormat; import freemarker.template.Configuration; import freemarker.template.Template; import org.apache.commons.compress.utils.IOUtils; -import org.dom4j.Document; -import org.dom4j.DocumentException; import java.awt.*; import java.io.*; -import java.nio.charset.StandardCharsets; import java.text.SimpleDateFormat; import java.util.List; import java.util.*; @@ -525,8 +521,6 @@ public class InstitutionalTextWeb extends ActionWeb { PALRepositoryPropertyModel term = PALRepositoryPropertyCache.getPropertyByPropertyId(repositoryModel.getId(), "term"); - - JSONArray termTable = new JSONArray(); //术语定义Table // 属性特征 属性代码KEY String termVal = term.getPropertyValue(); @@ -551,13 +545,12 @@ public class InstitutionalTextWeb extends ActionWeb { //定义表格数据 String[] header = {"术语", "定义"}; - if (termTable != null && !termTable.isEmpty()) { - String[][] strArray2 = new String[termTable.size()][]; + List list = new LinkedList<>(); for (int i = 0; i < termTable.size(); i++) { - JSONObject obj2 = termObj.getJSONArray("table").getJSONObject(i); + JSONObject obj2 = (JSONObject) termTable.get(i); String[] strArray = new String[2]; strArray[0] = obj2.getString("name"); strArray[1] = obj2.getString("desc"); @@ -573,29 +566,37 @@ public class InstitutionalTextWeb extends ActionWeb { TableRow row = table.getRows().get(0); row.isHeader(true); row.setHeight(20); - row.setHeightType(TableRowHeightType.Exactly); + row.setHeightType(TableRowHeightType.Auto); + + for (int i = 0; i < header.length; i++) { row.getCells().get(i).getCellFormat().setVerticalAlignment(VerticalAlignment.Middle); Paragraph p = row.getCells().get(i).addParagraph(); p.getFormat().setHorizontalAlignment(HorizontalAlignment.Center); TextRange txtRange = p.appendText(header[i]); + txtRange.getCharacterFormat().setBold(true); + + } + //将数据添加到其余行 for (int r = 0; r < data.length; r++) { TableRow dataRow = table.getRows().get(r + 1); dataRow.setHeight(25); - dataRow.setHeightType(TableRowHeightType.Exactly); + dataRow.setHeightType(TableRowHeightType.Auto); dataRow.getRowFormat().setBackColor(Color.white); for (int c = 0; c < data[r].length; c++) { dataRow.getCells().get(c).getCellFormat().setVerticalAlignment(VerticalAlignment.Middle); dataRow.getCells().get(c).addParagraph().appendText(data[r][c]); + } + } } else { - Paragraph termparagraph = section.addParagraph(); - termparagraph.appendText("无").applyCharacterFormat(format); + Paragraph orgparagraph = section.addParagraph(); + orgparagraph.appendText("无").applyCharacterFormat(format); } @@ -639,7 +640,6 @@ public class InstitutionalTextWeb extends ActionWeb { //定义表格数据 String[] orgheader = {"组织", "职责"}; - if (organizationTable != null && !organizationTable.isEmpty()) { String[][] strArray2 = new String[organizationTable.size()][]; @@ -657,17 +657,22 @@ public class InstitutionalTextWeb extends ActionWeb { //添加表格 Table table = section.addTable(true); - table.resetCells(data.length + 1, header.length); + + table.resetCells(data.length + 1, orgheader.length); + + + table.autoFit(AutoFitBehaviorType.Auto_Fit_To_Contents); + TableRow row = table.getRows().get(0); row.isHeader(true); row.setHeight(20); row.setHeightType(TableRowHeightType.Exactly); - for (int i = 0; i < header.length; i++) { + for (int i = 0; i < orgheader.length; i++) { row.getCells().get(i).getCellFormat().setVerticalAlignment(VerticalAlignment.Middle); Paragraph p = row.getCells().get(i).addParagraph(); p.getFormat().setHorizontalAlignment(HorizontalAlignment.Center); - TextRange txtRange = p.appendText(header[i]); + TextRange txtRange = p.appendText(orgheader[i]); txtRange.getCharacterFormat().setBold(true); } @@ -675,7 +680,7 @@ public class InstitutionalTextWeb extends ActionWeb { for (int r = 0; r < data.length; r++) { TableRow dataRow = table.getRows().get(r + 1); dataRow.setHeight(25); - dataRow.setHeightType(TableRowHeightType.Exactly); + dataRow.setHeightType(TableRowHeightType.Auto); dataRow.getRowFormat().setBackColor(Color.white); for (int c = 0; c < data[r].length; c++) { dataRow.getCells().get(c).getCellFormat().setVerticalAlignment(VerticalAlignment.Middle); @@ -720,7 +725,6 @@ public class InstitutionalTextWeb extends ActionWeb { String substring = fileName.substring(0, fileName.lastIndexOf(".xml")); appendUrl = docPath + substring + ".docx"; } else { - document.insertTextFromFile(path + fileName, FileFormat.Docx_2013); appendUrl = path + fileName; } @@ -769,7 +773,6 @@ public class InstitutionalTextWeb extends ActionWeb { } else { System.out.println("文档存在纵向页面方向"); - //在第二个文档中循环获取所有节 for (Object sectionObj : (Iterable) document2.getSections()) { Section sec = (Section) sectionObj; @@ -788,7 +791,6 @@ public class InstitutionalTextWeb extends ActionWeb { //保存结果文档 document.saveToFile(outFile.getPath(), FileFormat.Docx_2013); - BO bo = new BO(); bo.set("FILENAME", fileName); bo.set("PALID", repositoryId); @@ -820,7 +822,7 @@ public class InstitutionalTextWeb extends ActionWeb { ParagraphFormat paragraphFormat3 = paragraph3.getFormat(); paragraphFormat3.setHorizontalAlignment(HorizontalAlignment.Left); - TextRange tr3 = paragraph3.appendText("附则"); + TextRange tr3 = paragraph3.appendText("5.附则"); tr3.getCharacterFormat().setBold(true); @@ -924,57 +926,6 @@ public class InstitutionalTextWeb extends ActionWeb { } - public static String getFileContent(File file) { - StringBuilder builder = new StringBuilder(); - - InputStreamReader reader = null; - BufferedReader br = null; - try { - reader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8); - br = new BufferedReader(reader); - String s; - while ((s = br.readLine()) != null) { - builder.append(s); - } - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } finally { - try { - if (reader != null) { - reader.close(); - } - if (br != null) { - br.close(); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - return builder.toString(); - } - - /** - * 解析xml文档 - * - * @param path - * @param b - * @return - */ - private Document analysisXMLFile(String path, boolean b) { - Document d = null; - try { - d = XMLUtil.readXML(path, true); - } catch (DocumentException e) { - e.printStackTrace(); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - return d; - } - - /** * 获取文档数据 * @@ -1032,12 +983,6 @@ public class InstitutionalTextWeb extends ActionWeb { throw new AWSQuotaException("附件格式请以:《附件1:XXXXXX》格式命名"); } }*/ - dataMap.put("file_table", fileTable); - dataMap.put("file_table_count", fileTable.size()); - //dataMap.put("file_table_count", 0);// 暂时置空 - dataMap.put(OutputWordUtil.TABLE_DANGER, dangerTable); - dataMap.put(OutputWordUtil.TABLE_REGULATE, regulateTable); - dataMap.put(OutputWordUtil.TABLE_KPI, KPITable); ReportRepositoryCompare compare = new ReportRepositoryCompare(); JSONArray historyVersionModify = compare.getModifyVersionHistory(repositoryId); dataMap.put("history_table", historyVersionModify); @@ -1046,14 +991,5 @@ public class InstitutionalTextWeb extends ActionWeb { return dataMap; } - public static boolean isNumeric(String str) { - for (int i = str.length(); --i >= 0; ) { - int chr = str.charAt(i); - if (chr < 48 || chr > 57) - return false; - } - return true; - } - }