From b0c88e20d3abfe3addd1eaf4b3faf544133e222b Mon Sep 17 00:00:00 2001 From: yujh Date: Mon, 12 Aug 2024 10:17:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=B6=E5=BA=A6=E5=9B=BE=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E5=B8=A6=E5=87=BA=E5=85=B3=E9=94=AE=E6=8E=A7=E5=88=B6=E7=9F=A9?= =?UTF-8?q?=E9=98=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pal/pal/output/util/OutputWordUtil.java | 70 +++++++++++++++++-- 1 file changed, 65 insertions(+), 5 deletions(-) diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/output/util/OutputWordUtil.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/output/util/OutputWordUtil.java index 1f3dbc5b..64a00282 100755 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/output/util/OutputWordUtil.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/output/util/OutputWordUtil.java @@ -7,11 +7,13 @@ import com.actionsoft.apps.coe.pal.pal.method.model.PALMethodModel; import com.actionsoft.apps.coe.pal.pal.output.extend.GenerLogExd; import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryQueryAPIManager; import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache; +import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryPropertyCache; import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.cache.DesignerShapeRelationCache; import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.dao.DesignerShapeRelationDao; import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.model.DesignerShapeRelationModel; import com.actionsoft.apps.coe.pal.pal.repository.designer.util.CoeDesignerUtil; import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel; +import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryPropertyModel; import com.actionsoft.apps.coe.pal.pal.repository.upfile.constant.CoeFileConstant; import com.actionsoft.apps.coe.pal.pal.repository.upfile.dao.UpFileDao; import com.actionsoft.apps.coe.pal.pal.repository.upfile.model.UpfileModel; @@ -722,11 +724,73 @@ public class OutputWordUtil { //paragraph.appendBreak(BreakType.Page_Break); //Section section2 = doc.addSection(); + //关键控制点风险矩阵 开始 + PALRepositoryPropertyModel riskMatrixInfo = PALRepositoryPropertyCache.getPropertyByPropertyId(repositoryModel.getId(), "riskMatrixInfo"); + if(null!=riskMatrixInfo){ + JSONObject jsonObject = JSONObject.parseObject(riskMatrixInfo.getPropertyValue()); + JSONArray tableInfo = jsonObject.getJSONArray("table"); + //添加段落,设置一级序列 + Paragraph paragraph_risk = section.addParagraph(); + ParagraphFormat paragraphFormat_risk = paragraph_risk.getFormat(); + paragraphFormat_risk.setHorizontalAlignment(Left); + TextRange tr = paragraph_risk.appendText("关键控制点风险矩阵"); + tr.getCharacterFormat().setBold(true); + tr.getCharacterFormat().setFontName("宋体"); + tr.getCharacterFormat().setFontSize(12f); + paragraph_risk.applyStyle(BuiltinStyle.Body_Text); //应用标题1样式 + //定义表格数据 + String[] header = {"关键控制点", "控制描述","对应风险控制","角色/岗位"}; + //添加表格的表头 + Table table = section.addTable(true); + table.resetCells(tableInfo.size(),header.length); + table.getTableFormat().isAutoResized(true); + table.autoFit(AutoFitBehaviorType.Auto_Fit_To_Window); + TableRow row = table.getRows().get(0); + row.isHeader(true); + row.setHeight(20); + row.setHeightType(TableRowHeightType.Exactly); + 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); + txtRange.getCharacterFormat().setFontName("宋体"); + txtRange.getCharacterFormat().setFontSize(10.5f); + } + //添加数据到表中 + for (int i = 1; i < tableInfo.size(); i++) { + JSONObject cellInfo = tableInfo.getJSONObject(i); + TableRow dataRow = table.getRows().get(i); + dataRow.setHeight(25); + dataRow.setHeightType(TableRowHeightType.Exactly); + dataRow.getRowFormat().setBackColor(Color.white); + int flagNum = 0; + for (String cellKey : cellInfo.keySet()) { + if(cellKey.equals("id")){ + continue; + } + dataRow.getCells().get(flagNum).getCellFormat().setVerticalAlignment(VerticalAlignment.Middle); + //设置固定列宽 + //dataRow.getCells().get(0).setWidth(50); + //dataRow.getCells().get(1).setWidth(150); + //dataRow.getCells().get(c).addParagraph().appendText(data[r][c]); + + TextRange text =dataRow.getCells().get(flagNum).addParagraph().appendText(cellInfo.getString(cellKey)); + text.getCharacterFormat().setFontName("宋体"); + text.getCharacterFormat().setFontSize(10.5f); + dataRow.getRowFormat().setHorizontalAlignment(RowAlignment.Center); + dataRow.getCells().get(flagNum).getCellFormat(); + flagNum++; + } + } + Paragraph paragraph_blank = section.addParagraph(); + } + //关键控制点风险矩阵 结束 //相关文件 R_relevant_flies JSONArray relevant_flies = new JSONArray(); //组织职责Table List relationList2 = DesignerShapeRelationCache.getListByAttrId(repositoryModel.getId(), "", "related_files"); - relationList2.sort(Comparator.comparing(DesignerShapeRelationModel::getShapeText)); @@ -810,7 +874,6 @@ public class OutputWordUtil { txtRange.getCharacterFormat().setBold(true); txtRange.getCharacterFormat().setFontName("宋体"); txtRange.getCharacterFormat().setFontSize(10.5f); - } @@ -850,9 +913,6 @@ public class OutputWordUtil { Paragraph paragraph_blank = section.addParagraph(); } - - - int extercount = 0; //外部相关文件 JSONArray ExternalCorrelationFileArray = new JSONArray(); //外部相关文件Table