fix(创建流程图片): 创建流程图时图中存在阶段bar时textBlock为空导致空指针异常

This commit is contained in:
446052889@qq.com 2024-04-23 14:53:27 +08:00
parent 0eaa9e1fd9
commit 05b1aa9120
2 changed files with 24 additions and 22 deletions

View File

@ -1266,29 +1266,31 @@ public class CoeDesignerShapeAPIManager {
int h = props.getInteger("h");
if (shape.containsKey("textBlock")) {
JSONObject textBlock = JSONObject.parseObject(shape.getString("textBlock"));
JSONObject textBlockFinal = new JSONObject();
String textBlockX = textBlock.getString("x").replace("w", w + "").replace("h", h + "").replace("Mat" + h, "Math");
String textBlockY = textBlock.getString("y").replace("w", w + "").replace("h", h + "").replace("Mat" + h, "Math");
String textBlockW = textBlock.getString("w").replace("w", w + "").replace("h", h + "").replace("Mat" + h, "Math");
String textBlockH = textBlock.getString("h").replace("w", w + "").replace("h", h + "").replace("Mat" + h, "Math");
if (textBlockX.equals("0")) {
textBlockX = "0.0";
if (!textBlock.isEmpty()) {
JSONObject textBlockFinal = new JSONObject();
String textBlockX = textBlock.getString("x").replace("w", w + "").replace("h", h + "").replace("Mat" + h, "Math");
String textBlockY = textBlock.getString("y").replace("w", w + "").replace("h", h + "").replace("Mat" + h, "Math");
String textBlockW = textBlock.getString("w").replace("w", w + "").replace("h", h + "").replace("Mat" + h, "Math");
String textBlockH = textBlock.getString("h").replace("w", w + "").replace("h", h + "").replace("Mat" + h, "Math");
if (textBlockX.equals("0")) {
textBlockX = "0.0";
}
if (textBlockY.equals("0")) {
textBlockY = "0.0";
}
if (textBlockW.equals("0")) {
textBlockW = "0.0";
}
if (textBlockH.equals("0")) {
textBlockH = "0.0";
}
textBlockFinal.put("x", Double.parseDouble(runJs(textBlockX).toString()));
textBlockFinal.put("y", Double.parseDouble(runJs(textBlockY).toString()));
textBlockFinal.put("w", Double.parseDouble(runJs(textBlockW).toString()));
textBlockFinal.put("h", Double.parseDouble(runJs(textBlockH).toString()));
shape.put("textBlock", textBlock);
shape.put("textBlockFinal", textBlockFinal);
}
if (textBlockY.equals("0")) {
textBlockY = "0.0";
}
if (textBlockW.equals("0")) {
textBlockW = "0.0";
}
if (textBlockH.equals("0")) {
textBlockH = "0.0";
}
textBlockFinal.put("x", Double.parseDouble(runJs(textBlockX).toString()));
textBlockFinal.put("y", Double.parseDouble(runJs(textBlockY).toString()));
textBlockFinal.put("w", Double.parseDouble(runJs(textBlockW).toString()));
textBlockFinal.put("h", Double.parseDouble(runJs(textBlockH).toString()));
shape.put("textBlock", textBlock);
shape.put("textBlockFinal", textBlockFinal);
}
}
elements.put(shapeId, shape);