diff --git a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/web/CoeProcessLevelWeb.java b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/web/CoeProcessLevelWeb.java index 1ceb809f..956fd748 100755 --- a/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/web/CoeProcessLevelWeb.java +++ b/com.actionsoft.apps.coe.pal/src/com/actionsoft/apps/coe/pal/pal/repository/web/CoeProcessLevelWeb.java @@ -8306,6 +8306,8 @@ public class CoeProcessLevelWeb extends ActionWeb { graphTitle="绩效"; } + + //先执行新建操作产生plid PALRepository coeProcessLevel = CoeProcessLevelDaoFacotory.createCoeProcessLevel(); @@ -8319,7 +8321,6 @@ public class CoeProcessLevelWeb extends ActionWeb { null, "admin", "admin", nowTime, null, uuid, null, null, null, null, null, null, null, 1); - System.out.println(model.getId()); coeProcessLevel.insert(model); @@ -8333,6 +8334,9 @@ public class CoeProcessLevelWeb extends ActionWeb { JSONObject definition = JSONObject.parseObject(define); JSONObject elements = definition.getJSONObject("elements"); + + + //新建一个uuid String shapeId = UUIDGener.getObjectId(); @@ -8341,20 +8345,70 @@ public class CoeProcessLevelWeb extends ActionWeb { shape.put("id", shapeId); shape.put("text", graphTitle); - JSONObject props = shape.getJSONObject("props");// 位置大小 - props.put("zindex", 0); - props.put("x", Integer.parseInt("400")); - props.put("y", Integer.parseInt("106")); - props.put("w", Integer.parseInt("110")); - props.put("h", Integer.parseInt("50")); - props.put("zindex", 1); - elements.put(shapeId, shape); + + + JSONArray shapes = new JSONArray(); + /************************************************数据属性*********************************************************/ + + //图形的数据属性配置 + List attributeModels = CoeDesignerShapeAPIManager.getInstance().getAllValidShapeAttributeModels("6f4e292c-1b90-4dd2-8c20-7da159cb20a5", model.getMethodId()); + for (PALMethodAttributeModel attributeModel : attributeModels) { + + //todo:根据importProperty的类型获取具体保存数据值 + + JSONObject arributeObj = new JSONObject(); + arributeObj.put("key", attributeModel.getKey()); + arributeObj.put("isRequired", attributeModel.getIsRequired()); + arributeObj.put("ref", attributeModel.getRef()); + arributeObj.put("readonly", attributeModel.getReadonly()); + arributeObj.put("scope", attributeModel.getScope()); + arributeObj.put("name", attributeModel.getTitle()); + arributeObj.put("id", attributeModel.getKey()); + arributeObj.put("type", attributeModel.getType()); + arributeObj.put("groupPath", attributeModel.getGroupPath()); + arributeObj.put("desc", attributeModel.getDesc()); + arributeObj.put("value", attributeModel.getValue()); + + JSONArray dataAttributes = shape.getJSONArray("dataAttributes"); + if (!dataAttributes.isEmpty() && dataAttributes.size() > 0) { + for (Object attribute : dataAttributes) { + JSONObject obj = (JSONObject) attribute; + if (obj.containsKey("attributesJsonArray")) { + obj.getJSONArray("attributesJsonArray").add(arributeObj); + break; + } + } + } + + } + /************************************************文件属性*********************************************************/ + + //图形的数据属性配置 + List attrLists=PALRepositoryAPIManager.getInstance().getValidAndUseAttributeModels("6f4e292c-1b90-4dd2-8c20-7da159cb20a5", methodId); + + + + + + shapes.add(shape); + + + JSONArray newShapes = this.getMethodElementsJSONArray(shapes, 1); + JSONObject newElements = new JSONObject(); + for (int i = 0; i < newShapes.size(); i++) { + JSONObject shapeObj = newShapes.getJSONObject(i); + newElements.put(shapeObj.getString("id"), shapeObj); + } + + + + definition.put("elements", newElements); // 设置画布大小 - DiagramsUtil.setDiagramHeightWidth(definition, elements); + DiagramsUtil.setDiagramHeightWidth(definition, newElements); defineModel.setDefinition(definition.toString()); // 保存文件 CoeDesignerAPIManager.getInstance().storeDefinition(defineModel);// dao操作 @@ -8372,6 +8426,66 @@ public class CoeProcessLevelWeb extends ActionWeb { } + /** + * 创建具有合理位置的节点数据 + * + * @param elements + * @param shapeRowCount + * @return + */ + private JSONArray getMethodElementsJSONArray(JSONArray elements, int shapeRowCount) { + JSONArray result = new JSONArray(); + int zindex = 0; + int initX = 0; + int initY = 0; + int pageEdge = 100; + int count = 0; + initX += pageEdge; + initY += pageEdge; + for (int i = 0; i < elements.size(); i++) { + JSONObject shape = elements.getJSONObject(i); + count++; + if (count % (shapeRowCount + 1) == 0) { + count = 1; + initY += 130; + // 换行 + initX = 0; + initX = pageEdge + initX; + } + zindex++; + if (shape.containsKey("dataAttributes")) { + JSONArray dataAttributes = JSONArray.parseArray(shape.getString("dataAttributes")); + for (int index = 0; index < dataAttributes.size(); index++) { + dataAttributes.getJSONObject(index).put("id", UUIDGener.getObjectId()); + } + shape.put("dataAttributes", dataAttributes); + } + int totalWidth = 240;// 每个节点总宽度,空白+节点+空白 + int totalHeight = 200;// 每个节点总高度,空白+节点+空白 + int x = 0; + int y = 0; + int w = validateJson(shape.getJSONObject("props").getInteger("w")); + int h = validateJson(shape.getJSONObject("props").getInteger("h")); + int leftBlankWidth = (totalWidth - w) / 2; + int topBlankHeight = (totalHeight - h) / 2; + x = initX + leftBlankWidth; + initX = x + w + leftBlankWidth; + y = initY + topBlankHeight; +// y = pageEdge + initY; +// if (y < 0) { +// y = 100; +// } + JSONObject props = shape.getJSONObject("props"); + props.put("x", x); + props.put("y", y); + props.put("zindex", zindex); + shape.put("props", props); + result.add(shape); + } + return result; + } + + /** * 查找关联角色/绩效数据 * @param uuid @@ -8412,7 +8526,6 @@ public class CoeProcessLevelWeb extends ActionWeb { sortAttrMap.put(attr.getKey(), ++index); } } - PALMethodModel methodModel = PALMethodCache.getPALMethodModelById(m.getMethodId()); PALRepositoryPropertyDao dao = new PALRepositoryPropertyDao(); List propertys = dao.getPropertysByPlid(uuid, null); @@ -8433,7 +8546,6 @@ public class CoeProcessLevelWeb extends ActionWeb { continue; } - String inputValue = property.getPropertyValue(); if ("relation".equals(attributeModel.getType()) || "awsorg".equals(attributeModel.getType())) { List list = DesignerShapeRelationCache.getListByAttrId(uuid, "", attributeModel.getKey()); if (list == null || list.isEmpty()) { @@ -8450,6 +8562,7 @@ public class CoeProcessLevelWeb extends ActionWeb { /***************************************************数据属性校验*************************************************/ + Map methodAttributeModelMap = new HashMap<>(); // 校验形状 List elements = ShapeUtil.getShapeJsonToJsonObject(obj); @@ -8488,8 +8601,7 @@ public class CoeProcessLevelWeb extends ActionWeb { flag2 = UtilString.isNotEmpty(value); } if (!flag2) { - sb.append("''"+shapeName+"''").append(","); - flag2=false; + sb.append("''"+attrModel.getNewTitle()+"''").append(","); } } @@ -8508,6 +8620,7 @@ public class CoeProcessLevelWeb extends ActionWeb { ro.put("result","error"); } + ro.put("sb",sb1); return ro.toString(); diff --git a/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/js/coe.team.pal.designer.js b/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/js/coe.team.pal.designer.js index 887a5396..622a828a 100644 --- a/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/js/coe.team.pal.designer.js +++ b/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/js/coe.team.pal.designer.js @@ -99,7 +99,7 @@ $(function() { define: awsui.encode(obj), }, success: function (msg, textStatus, jqXHR) { - if(msg.result == "ok") { + /*if(msg.result == "ok") {*/ $.ajax({ type: "POST", url: "./jd", @@ -154,7 +154,7 @@ $(function() { $.simpleAlert('保存失败', 'error', 1500); } }); - } else { + /*} else { $.simpleAlert("close"); var result = msg.data; var resultMsg = []; @@ -164,7 +164,7 @@ $(function() { } $.simpleAlert(resultMsg.join('
'), 'error'); // $.simpleAlert(ro.msg, 'error'); - } + }*/ }, error: function (jqXHR, textStatus, errorThrown) { $.simpleAlert("close"); @@ -214,7 +214,9 @@ $(function() { intervalRefresh(); } - + /** + * 质量校验 + */ $("#QualityInspection").off("click").on("click", function () { $.simpleAlert("正在校验", "loading"); debugger;