风险矩阵功能,增加日志输出。先判断内容,再加表头
This commit is contained in:
parent
438f217a77
commit
597c5173a3
@ -790,93 +790,89 @@ public class OutputWordUtil {
|
|||||||
JSONObject jsonObject = JSONObject.parseObject(riskMatrixInfo.getPropertyValue());
|
JSONObject jsonObject = JSONObject.parseObject(riskMatrixInfo.getPropertyValue());
|
||||||
if(null != jsonObject){
|
if(null != jsonObject){
|
||||||
JSONArray tableInfo = jsonObject.getJSONArray("table");
|
JSONArray tableInfo = jsonObject.getJSONArray("table");
|
||||||
//添加段落,设置一级序列
|
//看看tableInfo是什么内容,如果没有内容,也不用生成表格
|
||||||
Paragraph paragraph_risk = section.addParagraph();
|
System.out.println(">>>>>>>>>tableInfo.toString() = " + tableInfo.toString());
|
||||||
ParagraphFormat paragraphFormat_risk = paragraph_risk.getFormat();
|
if(!tableInfo.isEmpty()){
|
||||||
paragraphFormat_risk.setHorizontalAlignment(Left);
|
//添加段落,设置一级序列
|
||||||
TextRange tr = paragraph_risk.appendText("关键控制点风险矩阵");
|
Paragraph paragraph_risk = section.addParagraph();
|
||||||
tr.getCharacterFormat().setBold(true);
|
ParagraphFormat paragraphFormat_risk = paragraph_risk.getFormat();
|
||||||
tr.getCharacterFormat().setFontName("宋体");
|
paragraphFormat_risk.setHorizontalAlignment(Left);
|
||||||
tr.getCharacterFormat().setFontSize(12f);
|
TextRange tr = paragraph_risk.appendText("关键控制点风险矩阵");
|
||||||
paragraph_risk.applyStyle(BuiltinStyle.Body_Text); //应用标题1样式
|
tr.getCharacterFormat().setBold(true);
|
||||||
|
tr.getCharacterFormat().setFontName("宋体");
|
||||||
|
tr.getCharacterFormat().setFontSize(12f);
|
||||||
|
paragraph_risk.applyStyle(BuiltinStyle.Body_Text); //应用标题1样式
|
||||||
|
|
||||||
|
|
||||||
//定义表格数据
|
//定义表格数据
|
||||||
String[] header = {"关键控制点", "控制描述","对应风险控制","角色/岗位"};
|
String[] header = {"关键控制点", "控制描述","对应风险控制","角色/岗位"};
|
||||||
//添加表格的表头
|
//添加表格的表头
|
||||||
Table table = section.addTable(true);
|
Table table = section.addTable(true);
|
||||||
table.resetCells(tableInfo.size(),header.length);
|
table.resetCells(tableInfo.size(),header.length);
|
||||||
//table.getTableFormat().isAutoResized(true);
|
//table.getTableFormat().isAutoResized(true);
|
||||||
table.autoFit(AutoFitBehaviorType.Fixed_Column_Widths);
|
table.autoFit(AutoFitBehaviorType.Fixed_Column_Widths);
|
||||||
TableRow row = table.getRows().get(0);
|
TableRow row = table.getRows().get(0);
|
||||||
row.isHeader(true);
|
row.isHeader(true);
|
||||||
row.setHeight(20);
|
row.setHeight(20);
|
||||||
row.setHeightType(TableRowHeightType.Exactly);
|
row.setHeightType(TableRowHeightType.Exactly);
|
||||||
for (int i = 0; i < header.length; i++) {
|
for (int i = 0; i < header.length; i++) {
|
||||||
row.getCells().get(i).getCellFormat().setVerticalAlignment(VerticalAlignment.Middle);
|
row.getCells().get(i).getCellFormat().setVerticalAlignment(VerticalAlignment.Middle);
|
||||||
Paragraph p = row.getCells().get(i).addParagraph();
|
Paragraph p = row.getCells().get(i).addParagraph();
|
||||||
p.getFormat().setHorizontalAlignment(HorizontalAlignment.Center);
|
p.getFormat().setHorizontalAlignment(HorizontalAlignment.Center);
|
||||||
TextRange txtRange = p.appendText(header[i]);
|
TextRange txtRange = p.appendText(header[i]);
|
||||||
txtRange.getCharacterFormat().setBold(true);
|
txtRange.getCharacterFormat().setBold(true);
|
||||||
txtRange.getCharacterFormat().setFontName("宋体");
|
txtRange.getCharacterFormat().setFontName("宋体");
|
||||||
txtRange.getCharacterFormat().setFontSize(10.5f);
|
txtRange.getCharacterFormat().setFontSize(10.5f);
|
||||||
|
|
||||||
//设置固定列宽
|
|
||||||
if(i==0){
|
|
||||||
row.getCells().get(0).setWidth(10);
|
|
||||||
}else if(i==1){
|
|
||||||
row.getCells().get(1).setWidth(10);
|
|
||||||
}else if(i==2){
|
|
||||||
row.getCells().get(2).setWidth(10);
|
|
||||||
}else if(i==3){
|
|
||||||
row.getCells().get(3).setWidth(10);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
//添加数据到表中
|
|
||||||
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.Auto);
|
|
||||||
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);
|
if(i==0){
|
||||||
//dataRow.getCells().get(1).setWidth(150);
|
row.getCells().get(0).setWidth(10);
|
||||||
//dataRow.getCells().get(c).addParagraph().appendText(data[r][c]);
|
}else if(i==1){
|
||||||
|
row.getCells().get(1).setWidth(10);
|
||||||
TextRange text =dataRow.getCells().get(flagNum).addParagraph().appendText(cellInfo.getString(cellKey));
|
}else if(i==2){
|
||||||
text.getCharacterFormat().setFontName("宋体");
|
row.getCells().get(2).setWidth(10);
|
||||||
text.getCharacterFormat().setFontSize(10.5f);
|
}else if(i==3){
|
||||||
dataRow.getRowFormat().setHorizontalAlignment(RowAlignment.Center);
|
row.getCells().get(3).setWidth(10);
|
||||||
dataRow.getCells().get(flagNum).getCellFormat();
|
}
|
||||||
flagNum++;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
//添加数据到表中
|
||||||
|
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.Auto);
|
||||||
|
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));
|
||||||
if(i==0){
|
text.getCharacterFormat().setFontName("宋体");
|
||||||
row.getCells().get(0).setWidth(10);
|
text.getCharacterFormat().setFontSize(10.5f);
|
||||||
}else if(i==1){
|
dataRow.getRowFormat().setHorizontalAlignment(RowAlignment.Center);
|
||||||
row.getCells().get(1).setWidth(10);
|
dataRow.getCells().get(flagNum).getCellFormat();
|
||||||
}else if(i==2){
|
flagNum++;
|
||||||
row.getCells().get(2).setWidth(10);
|
}
|
||||||
}else if(i==3){
|
//设置固定列宽
|
||||||
row.getCells().get(3).setWidth(10);
|
if(i==0){
|
||||||
|
row.getCells().get(0).setWidth(10);
|
||||||
|
}else if(i==1){
|
||||||
|
row.getCells().get(1).setWidth(10);
|
||||||
|
}else if(i==2){
|
||||||
|
row.getCells().get(2).setWidth(10);
|
||||||
|
}else if(i==3){
|
||||||
|
row.getCells().get(3).setWidth(10);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Paragraph paragraph_blank = section.addParagraph();
|
||||||
}
|
}
|
||||||
Paragraph paragraph_blank = section.addParagraph();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//关键控制点风险矩阵 结束
|
//关键控制点风险矩阵 结束
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user