From 316e1c18d0d55b28d64400923721bab2158ff251 Mon Sep 17 00:00:00 2001 From: jinlin <jinlin> Date: 星期五, 13 九月 2024 16:32:35 +0800 Subject: [PATCH] 修改 --- modules/mainPart/src/main/java/com/zt/life/modules/mainPart/taskReliability/service/ModelLineService.java | 851 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 787 insertions(+), 64 deletions(-) diff --git a/modules/mainPart/src/main/java/com/zt/life/modules/mainPart/taskReliability/service/ModelLineService.java b/modules/mainPart/src/main/java/com/zt/life/modules/mainPart/taskReliability/service/ModelLineService.java index 6f04591..7ad020c 100644 --- a/modules/mainPart/src/main/java/com/zt/life/modules/mainPart/taskReliability/service/ModelLineService.java +++ b/modules/mainPart/src/main/java/com/zt/life/modules/mainPart/taskReliability/service/ModelLineService.java @@ -5,10 +5,18 @@ import com.zt.common.service.BaseService; import com.zt.common.utils.JsonUtils2; import com.zt.common.utils.UUIDUtil; +import com.zt.life.modules.mainPart.basicInfo.dao.ParamDataDao; +import com.zt.life.modules.mainPart.basicInfo.dao.XhProductModelDao; +import com.zt.life.modules.mainPart.basicInfo.model.ParamData; +import com.zt.life.modules.mainPart.basicInfo.model.ProductImg; +import com.zt.life.modules.mainPart.basicInfo.model.XhProductModel; import com.zt.life.modules.mainPart.taskReliability.dao.*; -import com.zt.life.modules.mainPart.taskReliability.dto.ModelLinePair; +import com.zt.life.modules.mainPart.taskReliability.dto.ModelLinePairDto; import com.zt.life.modules.mainPart.taskReliability.model.*; import org.apache.commons.lang3.StringUtils; +import org.dom4j.Element; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.zt.common.db.query.QueryFilter; @@ -26,6 +34,42 @@ */ @Service public class ModelLineService extends BaseService<ModelLineDao, ModelLine> { + private static final Logger logger = LoggerFactory.getLogger(ModelLineService.class); + + // 杩愮畻 + public static final String OPE_TYPE_SERIES = "series"; + public static final String OPE_TYPE_PARALLEL = "parallel"; + public static final String OPE_TYPE_SWITCH = "switch"; + public static final String OPE_TYPE_VOTE = "vote"; + public static final String OPE_TYPE_BRIDGE = "bridge"; + + // 鑺傜偣 + /* 鑷姩甯冨眬锛歴tart涓巈nd鐨勫ぇ灏� */ + public static final int LAYOUT_START_END_SIZE_X = 60; + public static final int LAYOUT_START_END_SIZE_Y = 40; + /* 鑷姩甯冨眬锛氳櫄妗嗙殑澶у皬 */ + public static final int LAYOUT_DASHED_BOX_SIZE_X = 60; + public static final int LAYOUT_DASHED_BOX_SIZE_Y = 40; + /* 鑷姩甯冨眬锛氶�昏緫杩愮畻绗︾殑澶у皬 */ + public static final int LAYOUT_OPE_NODE_SIZE_X = 50; + public static final int LAYOUT_OPE_NODE_SIZE_Y = 50; + /* 鑷姩甯冨眬锛氳澶囪妭鐐圭殑澶у皬 */ + public static final int LAYOUT_DEVICE_NODE_SIZE_X = 60; + public static final int LAYOUT_DEVICE_NODE_SIZE_Y = 60; + /* 鑷姩甯冨眬锛歝onnect鐨勫ぇ灏� */ + public static final int LAYOUT_CONNECT_SIZE_X = 10; + public static final int LAYOUT_CONNECT_SIZE_Y = 10; + + // 鍗曞厓鏍硷紙瀛樻斁鑺傜偣锛� + /* 鑷姩甯冨眬锛氬崟鍏冩牸澶у皬 */ + public static final int LAYOUT_CELL_SIZE_X = 120; + public static final int LAYOUT_CELL_SIZE_Y = 120; + /* 鑷姩甯冨眬锛氳妭鐐瑰崰鎹崟鍏冩牸鏁伴噺 */ + public static final int LAYOUT_CELL_NUM_NODE_X = 1; + public static final int LAYOUT_CELL_NUM_NODE_Y = 1; + public static final int LAYOUT_CELL_NUM_CONNECT_X = 1; + public static final int LAYOUT_CELL_NUM_CONNECT_Y = 1; + @Autowired private ModelLineDao modelLineDao; @Autowired @@ -36,6 +80,10 @@ private AlgorithmDao algorithmDao; @Autowired private ModelNodeAlgorithmDao modelNodeAlgorithmDao; + @Autowired + private XhProductModelDao xhProductModelDao; + @Autowired + private ParamDataDao paramDataDao; /** * 鍒嗛〉鏌ヨ @@ -74,6 +122,7 @@ modelRbdDao.insert(modelRbd); } + @Transactional(rollbackFor = Exception.class) public void update(ModelRbd modelRbd) { if (modelRbd==null) return; @@ -86,18 +135,19 @@ modelRbdDao.insert(modelRbd); } + // 鑷姩鎺掔増RBD @Transactional(rollbackFor = Exception.class) - public boolean analyze(ModelRbd modelRbd) { + public boolean layout(ModelRbd modelRbd) { boolean result = true; if (modelRbd==null) return result; Long modelId = modelRbd.getId(); - result = analyzeRbd(modelId, modelRbd.getContent(), true); + result = layoutRbd(modelRbd); return result; } - private boolean analyzeRbd(Long modelId, String content, boolean saveFlag) { + private boolean layoutRbd(ModelRbd modelRbd) { boolean result = true; - String rbdsonStr = content; + String rbdsonStr = modelRbd.getContent(); JSONArray rbdJsonArray = new JSONObject(rbdsonStr).getJSONArray("cells"); if (rbdJsonArray == null) return result; @@ -106,28 +156,519 @@ List<ModelNode> modelNodeList = new ArrayList<>(); List<ModelLine> modelLineList = new ArrayList<>(); List<Algorithm> algorithmList = new ArrayList<>(); + List<ProductImg> productImgList = new ArrayList<>(); // 鏆備笉浣跨敤锛堣�屼娇鐢ㄦ暟鎹簱涓殑鍙潬鎬у弬鏁帮級 // 1. 瑙f瀽鍑鸿妭鐐逛笌杈� - getNodeAndLineFromRbd(modelId, rbdJsonArray, modelNodeList, modelLineList); - // 2. 璁$畻鎵�鏈夎妭鐐圭殑鍏ュ彛绾挎暟鍙婂嚭鍙g嚎鏁� + getNodeAndLineFromRbd(modelRbd.getId(), rbdJsonArray, modelNodeList, modelLineList, productImgList); + // 2. 瀵逛簬鏈夊鏍瑰叆鍙g嚎鐨勪骇鍝佽妭鐐癸紝灏嗗叾涓婄殑琛ㄥ喅銆佹梺鑱斿叧绯诲墺绂绘垚杩愮畻绗﹁妭鐐癸紝娣诲姞鍒拌鑺傜偣鐨勫墠闈紝骞舵坊鍔犵浉搴旂殑杈� + peelOperationFromProductNode(modelRbd.getId(), modelNodeList, modelLineList); + // 3. 璁$畻鎵�鏈夎妭鐐圭殑鍏ュ彛绾挎暟鍙婂嚭鍙g嚎鏁� calcInOutLineNumAllNode(modelNodeList, modelLineList); - // 3. 澶嶅埗浜у搧鑺傜偣(node)鍒發ist + // 4. 澶嶅埗浜у搧鑺傜偣(node)鍒發ist List<ModelNode> modelNodeAndVnodeList = modelNodeList.stream().filter(item -> "node".equals(item.getNodeType())).collect(Collectors.toList()); - // 4. 涓嶆柇灏嗗熀鏈ā鍨嬶紙涓茶仈銆佸苟鑱斻�佹梺鑱斻�佽〃鍐炽�佹ˉ鑱旓級鏇挎崲涓鸿櫄鑺傜偣鑰岀畝鍖栧浘褰紝鐩磋嚦鏃犳硶绠�鍖栦负姝€�� - result = getAlgorithmFromRbd(modelId, modelNodeList, modelLineList, algorithmList, modelNodeAndVnodeList); + // 5. 涓嶆柇灏嗗熀鏈ā鍨嬶紙涓茶仈銆佸苟鑱斻�佹梺鑱斻�佽〃鍐炽�佹ˉ鑱旓級鏇挎崲涓鸿櫄鑺傜偣鑰岀畝鍖栧浘褰紝鐩磋嚦鏃犳硶绠�鍖栦负姝€�� + result = getAlgorithmFromRbd(modelRbd, modelNodeList, modelLineList, algorithmList, modelNodeAndVnodeList); - // 5. 淇濆瓨妯″瀷 - if (saveFlag) saveModel(modelId, modelNodeList, modelLineList, algorithmList, modelNodeAndVnodeList); + // 6. 閫掑綊璁$畻RBD鐨勫竷灞�绌洪棿澶у皬 + calcLayoutSize(modelRbd, algorithmList, modelNodeAndVnodeList); + // 7. 閫掑綊璁$畻RBD鐨勫竷灞�绌洪棿鍙傛暟锛坸銆亂鍧愭爣锛� + calcLayoutPosition(modelRbd, algorithmList, modelNodeAndVnodeList); + + // 8. 淇濆瓨鑷姩甯冨眬妯″瀷 + // 鏇存柊RBD鏁版嵁 +// modelRbd.setAutoLayoutContent("娴嬭瘯鏂囧瓧"); + modelRbdDao.updateById(modelRbd); return result; } - private boolean getAlgorithmFromRbd(Long modelId, - List<ModelNode> modelNodeList, - List<ModelLine> modelLineList, - List<Algorithm> algorithmList, - List<ModelNode> modelNodeAndVnodeList) { + /** + * 鏍规嵁椤跺眰RBD鐨勪綅缃紙x锛寉锛夛紝鑷《鍚戜笅閫掑綊璁$畻鍚勪釜鑺傜偣鐨勪綅缃紙x锛寉锛� + * @param modelRbd + * @param algorithmList + * @param modelNodeAndVnodeList + */ + private void calcLayoutPosition(ModelRbd modelRbd, + List<Algorithm> algorithmList, + List<ModelNode> modelNodeAndVnodeList) { + String rbdsonStr = modelRbd.getContent(); + JSONArray rbdJsonArray = new JSONObject(rbdsonStr).getJSONArray("cells"); + Algorithm endAlgo = algorithmList.stream().filter(item -> + "end".equals(item.getAlgorithmType())).collect(Collectors.toList()).get(0); + ModelNode topNode = modelNodeAndVnodeList.stream().filter(item -> + endAlgo.getComputerList().equals(item.getId().toString())).collect(Collectors.toList()).get(0); + Algorithm topAlgo = algorithmList.stream().filter(item -> + endAlgo.getComputerList().equals(item.getId().toString())).collect(Collectors.toList()).get(0); + // 灏唗oNode鐨勪腑蹇冨潗鏍囧畾涓�(0锛�0)锛屽弽绠楁墍鏈夎妭鐐圭殑鍧愭爣 + // 1. 璁$畻骞惰缃畇tart鐨勪綅缃� + double x = -topNode.getVnodeCellNumX()*LAYOUT_CELL_SIZE_X/2 - LAYOUT_START_END_SIZE_X; + double y = -LAYOUT_START_END_SIZE_Y/2; + setRbdNodePosition(rbdJsonArray, "10000", x, y); + // 2. 璁$畻骞惰缃妭鐐圭殑浣嶇疆 + calcNodeLayoutPosition(rbdJsonArray, algorithmList, modelNodeAndVnodeList, topNode, topAlgo, 0, 0); + // 3. 璁$畻骞惰缃甧nd鐨勪綅缃� + x = topNode.getVnodeCellNumX()*LAYOUT_CELL_SIZE_X/2; + setRbdNodePosition(rbdJsonArray, "20000", x ,y); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("cells", rbdJsonArray); + modelRbd.setContent(jsonObject.toString()); + } + + // 閫掑綊鍑芥暟 + private void calcNodeLayoutPosition(JSONArray rbdJsonArray, + List<Algorithm> algorithmList, + List<ModelNode> modelNodeAndVnodeList, + ModelNode node, + Algorithm algo, + double x, + double y) { + if ("node".equals(node.getNodeType())) { + //璁剧疆node锛堣澶囪妭鐐癸級甯冨眬淇℃伅 + node.setPositionX(x - node.getCellNumX()*LAYOUT_CELL_SIZE_X/2); + node.setPositionY(y - node.getCellNumY()*LAYOUT_CELL_SIZE_Y/2); + setRbdNodePosition(rbdJsonArray, node.getPicId().toString(), node.getPositionX(), node.getPositionY()); + } else if ("vnode".equals(node.getNodeType())) { + String[] computerNodeListStr = algo.getComputerList().split(","); + switch (algo.getAlgorithmType()) { + case OPE_TYPE_SERIES: + int sumCellNumX = 0; + for (String nodeStr : computerNodeListStr) { + ModelNode childNode = modelNodeAndVnodeList.stream().filter(item -> + nodeStr.equals(item.getId().toString())).collect(Collectors.toList()).get(0); + sumCellNumX += childNode.getVnodeCellNumX(); + } + for (int i=0; i<computerNodeListStr.length; i++) { + int idx = i; + ModelNode childNode = modelNodeAndVnodeList.stream().filter(item -> + computerNodeListStr[idx].equals(item.getId().toString())).collect(Collectors.toList()).get(0); + if (0==i) { + double childNodeX = x - sumCellNumX * LAYOUT_CELL_SIZE_X / 2; + double childNodeY = y - childNode.getVnodeCellNumY() * LAYOUT_CELL_SIZE_Y / 2; + if ("node".equals(childNode.getNodeType())) { + childNode.setPositionX(childNodeX); + childNode.setPositionY(childNodeY); + setRbdNodePosition(rbdJsonArray, childNode.getPicId().toString(), childNode.getPositionX(), childNode.getPositionY()); + } else { + Algorithm childAlgo = algorithmList.stream().filter(item -> + childNode.getId().equals(item.getId().toString())).collect(Collectors.toList()).get(0); + calcNodeLayoutPosition(rbdJsonArray, + algorithmList, + modelNodeAndVnodeList, + childNode, + childAlgo, + childNodeX, + childNodeY); + } + } else { + int idxPre = i - 1; + ModelNode childNodePre = modelNodeAndVnodeList.stream().filter(item -> + computerNodeListStr[idxPre].equals(item.getId().toString())).collect(Collectors.toList()).get(0); + int idxMe = i; + double childNodeX = childNodePre.getPositionX() + childNodePre.getVnodeCellNumX()*LAYOUT_CELL_SIZE_X; + double childNodeY = y - childNode.getVnodeCellNumY()*LAYOUT_CELL_SIZE_Y/2; + if ("node".equals(childNode.getNodeType())) { + childNode.setPositionX(childNodeX); + childNode.setPositionY(childNodeY); + setRbdNodePosition(rbdJsonArray, childNode.getPicId().toString(), childNode.getPositionX(), childNode.getPositionY()); + } else { + ModelNode childNodeMe = modelNodeAndVnodeList.stream().filter(item -> + computerNodeListStr[idxMe].equals(item.getId().toString())).collect(Collectors.toList()).get(0); + Algorithm childAlgoMe = algorithmList.stream().filter(item -> + childNodeMe.getId().equals(item.getId().toString())).collect(Collectors.toList()).get(0); + calcNodeLayoutPosition(rbdJsonArray, + algorithmList, + modelNodeAndVnodeList, + childNode, + childAlgoMe, + childNodePre.getPositionX() + childNodePre.getVnodeCellNumX() * LAYOUT_CELL_SIZE_X, + y - childNodeMe.getVnodeCellNumY() * LAYOUT_CELL_SIZE_Y / 2); + } + } + } + break; + case OPE_TYPE_PARALLEL: + case OPE_TYPE_SWITCH: + case OPE_TYPE_VOTE: + int sumCellNumY = 0; + for (String nodeStr : computerNodeListStr) { + ModelNode childNode = modelNodeAndVnodeList.stream().filter(item -> + nodeStr.equals(item.getId().toString())).collect(Collectors.toList()).get(0); + sumCellNumY += childNode.getVnodeCellNumY(); + } + for (int i=0; i<computerNodeListStr.length; i++) { + int idx = i; + ModelNode childNode = modelNodeAndVnodeList.stream().filter(item -> + computerNodeListStr[idx].equals(item.getId().toString())).collect(Collectors.toList()).get(0); + if (0==i) { + double childNodeX = x - childNode.getVnodeCellNumX()*LAYOUT_CELL_SIZE_X/2; + double childNodeY = y - sumCellNumY*LAYOUT_CELL_SIZE_Y/2; + if ("node".equals(childNode.getNodeType())) { + childNode.setPositionX(childNodeX); + childNode.setPositionY(childNodeY); + setRbdNodePosition(rbdJsonArray, childNode.getPicId(), childNode.getPositionX(), childNode.getPositionY()); + } else { + Algorithm childAlgo = algorithmList.stream().filter(item -> + childNode.getId().equals(item.getId().toString())).collect(Collectors.toList()).get(0); + calcNodeLayoutPosition(rbdJsonArray, + algorithmList, + modelNodeAndVnodeList, + childNode, + childAlgo, + childNodeX, + childNodeY); + } + } else { + int idxPre = i - 1; + ModelNode childNodePre = modelNodeAndVnodeList.stream().filter(item -> + computerNodeListStr[idxPre].equals(item.getId().toString())).collect(Collectors.toList()).get(0); + int idxMe = i; + ModelNode childNodeMe = modelNodeAndVnodeList.stream().filter(item -> + computerNodeListStr[idxMe].equals(item.getId().toString())).collect(Collectors.toList()).get(0); + double childNodeX = x - childNodeMe.getVnodeCellNumY() * LAYOUT_CELL_SIZE_Y / 2; + double childNodeY = childNodePre.getPositionY() + childNodePre.getVnodeCellNumY() * LAYOUT_CELL_SIZE_Y; + if ("node".equals(childNodeMe.getNodeType())) { + childNodeMe.setPositionX(childNodeX); + childNodeMe.setPositionY(childNodeY); + setRbdNodePosition(rbdJsonArray, childNodeMe.getPicId(), childNodeMe.getPositionX(), childNodeMe.getPositionY()); + } else { + Algorithm childAlgoMe = algorithmList.stream().filter(item -> + childNodeMe.getId().equals(item.getId().toString())).collect(Collectors.toList()).get(0); + calcNodeLayoutPosition(rbdJsonArray, + algorithmList, + modelNodeAndVnodeList, + childNodeMe, + childAlgoMe, + childNodeX, + childNodeY); + } + } + } + break; + case OPE_TYPE_BRIDGE: + ModelNode node1 = modelNodeAndVnodeList.stream().filter(item -> + computerNodeListStr[0].equals(item.getId().toString())).collect(Collectors.toList()).get(0); + ModelNode node2 = modelNodeAndVnodeList.stream().filter(item -> + computerNodeListStr[1].equals(item.getId().toString())).collect(Collectors.toList()).get(0); + ModelNode node3 = modelNodeAndVnodeList.stream().filter(item -> + computerNodeListStr[2].equals(item.getId().toString())).collect(Collectors.toList()).get(0); + ModelNode node4 = modelNodeAndVnodeList.stream().filter(item -> + computerNodeListStr[3].equals(item.getId().toString())).collect(Collectors.toList()).get(0); + ModelNode node5 = modelNodeAndVnodeList.stream().filter(item -> + computerNodeListStr[4].equals(item.getId().toString())).collect(Collectors.toList()).get(0); + Algorithm algo1 = algorithmList.stream().filter(item -> + node1.getId().equals(item.getId().toString())).collect(Collectors.toList()).get(0); + Algorithm algo2 = algorithmList.stream().filter(item -> + node2.getId().equals(item.getId().toString())).collect(Collectors.toList()).get(0); + Algorithm algo3 = algorithmList.stream().filter(item -> + node3.getId().equals(item.getId().toString())).collect(Collectors.toList()).get(0); + Algorithm algo4 = algorithmList.stream().filter(item -> + node4.getId().equals(item.getId().toString())).collect(Collectors.toList()).get(0); + Algorithm algo5 = algorithmList.stream().filter(item -> + node5.getId().equals(item.getId().toString())).collect(Collectors.toList()).get(0); + // 1锛岃绠椾笁琛岀殑鎬婚珮搴� + // 1.1 璁$畻绗竴琛屼袱涓妭鐐圭殑楂樺害 + int firstRowCellNumY = Math.max(node1.getVnodeCellNumY(), node2.getVnodeCellNumY()); + // 1.2 璁$畻绗簩琛屾ˉ鑱旇妭鐐圭殑楂樺害 + int secondRowCellNumY = node3.getVnodeCellNumY(); + // 1.3 璁$畻绗笁琛屼袱涓妭鐐圭殑楂樺害 + int thirdRowCellNumY = Math.max(node4.getVnodeCellNumY(), node5.getVnodeCellNumY()); + int totalCellNumY = firstRowCellNumY + secondRowCellNumY + thirdRowCellNumY; + // 2. 璁$畻涓夎鍚勮妭鐐圭殑鍧愭爣 + // 2.1 璁$畻绗竴琛屼袱涓妭鐐圭殑鍧愭爣 + calcNodeLayoutPosition(rbdJsonArray, + algorithmList, + modelNodeAndVnodeList, + node1, + algo1, + x - (node1.getVnodeCellNumX() + node2.getVnodeCellNumX())*LAYOUT_CELL_SIZE_X/2, + y - (totalCellNumY-firstRowCellNumY+node1.getVnodeCellNumY())*LAYOUT_CELL_SIZE_Y/2); + calcNodeLayoutPosition(rbdJsonArray, + algorithmList, + modelNodeAndVnodeList, + node2, + algo2, + x + (node1.getVnodeCellNumX() + node2.getVnodeCellNumX())*LAYOUT_CELL_SIZE_X/2, + y - (totalCellNumY-firstRowCellNumY+node2.getVnodeCellNumY())*LAYOUT_CELL_SIZE_Y/2); + // 2.2 璁$畻绗簩琛屾ˉ鑱旇妭鐐圭殑鍧愭爣 + calcNodeLayoutPosition(rbdJsonArray, + algorithmList, + modelNodeAndVnodeList, + node2, + algo2, + x - node3.getVnodeCellNumX()*LAYOUT_CELL_SIZE_X/2, + y - (totalCellNumY/2-firstRowCellNumY)*LAYOUT_CELL_SIZE_Y); + // 2.3 璁$畻绗笁琛屼袱涓妭鐐圭殑鍧愭爣 + calcNodeLayoutPosition(rbdJsonArray, + algorithmList, + modelNodeAndVnodeList, + node1, + algo1, + x - (node1.getVnodeCellNumX() + node2.getVnodeCellNumX())*LAYOUT_CELL_SIZE_X/2, + y - (totalCellNumY-firstRowCellNumY+node1.getVnodeCellNumY())*LAYOUT_CELL_SIZE_Y/2); + calcNodeLayoutPosition(rbdJsonArray, + algorithmList, + modelNodeAndVnodeList, + node2, + algo2, + x + (node1.getVnodeCellNumX() + node2.getVnodeCellNumX())*LAYOUT_CELL_SIZE_X/2, + y - (totalCellNumY-firstRowCellNumY+node2.getVnodeCellNumY())*LAYOUT_CELL_SIZE_Y/2); + // 2.4 璁$畻妗ヨ仈杩愮畻绗︾殑鍧愭爣 + // 2.5 璁$畻宸︿晶閰嶅鐨刢onnect鐨勫潗鏍� + break; + default: + break; + } + } + } + + private void setRbdNodePosition(JSONArray rbdJsonArray, + String id, + double x, + double y) { + for (int i = 0; i < rbdJsonArray.size(); i++) { + JSONObject jsonObject = rbdJsonArray.getJSONObject(i); + if (id.equals(jsonObject.get("id").toString())) { + JsonUtils2.setJsonValueByPath(jsonObject, "position/x".split("/"), x); + JsonUtils2.setJsonValueByPath(jsonObject, "position/y".split("/"), y); + } + } + } + + /** + * 鑷簳鍚戜笂閫掑綊鍚堣鍑烘暣涓猂BD鐨勫ぇ灏忥紙妯悜鍙婄旱鍚戞墍鍗犲崟鍏冩牸鐨勬暟閲忥級 + * @param modelRbd + * @param algorithmList + * @param modelNodeAndVnodeList + */ + private void calcLayoutSize( + ModelRbd modelRbd, + List<Algorithm> algorithmList, + List<ModelNode> modelNodeAndVnodeList) { + Algorithm endAlgo = algorithmList.stream().filter(item -> + "end".equals(item.getAlgorithmType())).collect(Collectors.toList()).get(0); + ModelNode topNode = modelNodeAndVnodeList.stream().filter(item -> + endAlgo.getComputerList().equals(item.getId().toString())).collect(Collectors.toList()).get(0); + Algorithm topAlgo = algorithmList.stream().filter(item -> + endAlgo.getComputerList().equals(item.getId().toString())).collect(Collectors.toList()).get(0); + calcNodeLayoutSize(algorithmList, modelNodeAndVnodeList, topNode, topAlgo); + } + + // 閫掑綊鍑芥暟 + private void calcNodeLayoutSize(List<Algorithm> algorithmList, + List<ModelNode> modelNodeAndVnodeList, + ModelNode node, + Algorithm algo) { + if ("node".equals(node.getNodeType())) { + //璁剧疆node锛堣澶囪妭鐐癸級甯冨眬淇℃伅 + node.setWidth(LAYOUT_DEVICE_NODE_SIZE_X); + node.setHeight(LAYOUT_DEVICE_NODE_SIZE_Y); + node.setCellNumX(LAYOUT_CELL_NUM_NODE_X); + node.setCellNumY(LAYOUT_CELL_NUM_NODE_Y); + node.setVnodeCellNumX(node.getCellNumX()); + node.setVnodeCellNumY(node.getCellNumY()); + } else if ("vnode".equals(node.getNodeType())) { + // 1. 璁剧疆vnode锛堣繍绠楄妭鐐癸級甯冨眬淇℃伅锛堝叾瀹炰覆鑱旀病鏈夎繍绠楃锛屼笉闇�瑕佽缃紝浣嗘槸璁剧疆浜嗕篃娌℃湁鍧忓锛屾墍鏈変笉浣滃尯鍒嗭級 + node.setWidth(LAYOUT_OPE_NODE_SIZE_X); + node.setHeight(LAYOUT_OPE_NODE_SIZE_Y); + node.setCellNumX(LAYOUT_CELL_NUM_NODE_X); + node.setCellNumY(LAYOUT_CELL_NUM_NODE_Y); + + // 2. 璁剧疆铏氳妭鐐瑰竷灞�淇℃伅 + // 2.1 璁剧疆铏氳妭鐐瑰唴鍚勮繍绠楀璞$殑甯冨眬淇℃伅 + String[] computerNodeListStr = algo.getComputerList().split(","); + for (String nodeStr : computerNodeListStr) { + ModelNode childNode = modelNodeAndVnodeList.stream().filter(item -> + nodeStr.equals(item.getId().toString())).collect(Collectors.toList()).get(0); + if ("node".equals(childNode.getNodeType())) { + childNode.setWidth(LAYOUT_DEVICE_NODE_SIZE_X); + childNode.setHeight(LAYOUT_DEVICE_NODE_SIZE_Y); + childNode.setCellNumX(LAYOUT_CELL_NUM_NODE_X); + childNode.setCellNumY(LAYOUT_CELL_NUM_NODE_Y); + childNode.setVnodeCellNumX(node.getCellNumX()); + childNode.setVnodeCellNumY(node.getCellNumY()); + } else { + Algorithm childAlgo = algorithmList.stream().filter(item -> + childNode.getId().equals(item.getId().toString())).collect(Collectors.toList()).get(0); + calcNodeLayoutSize(algorithmList, + modelNodeAndVnodeList, + childNode, + childAlgo); + } + } + // 2.2 璁剧疆铏氳妭鐐规�荤殑甯冨眬淇℃伅鍒拌繍绠楄妭鐐逛腑 + setVnodeLayoutNum(computerNodeListStr, modelNodeAndVnodeList, node, algo); + } + } + + private void setVnodeLayoutNum(String[] computerNodeListStr, + List<ModelNode> modelNodeAndVnodeList, + ModelNode vnode, + Algorithm algo) { + int numX = 0; + int numY = 0; + // 1. 璁$畻涓层�佸苟銆佹梺鑱斻�佽〃鍐� + for (String nodeStr : computerNodeListStr) { + ModelNode childNode = modelNodeAndVnodeList.stream().filter(item -> + nodeStr.equals(item.getId().toString())).collect(Collectors.toList()).get(0); + switch (algo.getAlgorithmType()) { + case OPE_TYPE_SERIES: + numX += childNode.getCellNumX(); + numY = childNode.getCellNumY() > numY ? childNode.getCellNumY() : numY; + break; + case OPE_TYPE_PARALLEL: + case OPE_TYPE_SWITCH: + case OPE_TYPE_VOTE: + numX = childNode.getCellNumX() > numX ? childNode.getCellNumX() : numX; + numY += childNode.getCellNumY(); + break; + default: + break; + } + } + if (OPE_TYPE_PARALLEL.equals(algo.getAlgorithmType()) + || OPE_TYPE_SWITCH.equals(algo.getAlgorithmType()) + || OPE_TYPE_VOTE.equals(algo.getAlgorithmType())) { + // 璁剧疆connect鐨勫ぇ灏� + ModelNode connect = modelNodeAndVnodeList.stream().filter(item -> + vnode.getPairStartNodeId().equals(item.getId().toString())).collect(Collectors.toList()).get(0); + connect.setWidth(LAYOUT_CONNECT_SIZE_X); + connect.setHeight(LAYOUT_CONNECT_SIZE_Y); + connect.setCellNumX(LAYOUT_CELL_NUM_CONNECT_X); + connect.setCellNumY(LAYOUT_CELL_NUM_CONNECT_Y); + numX += connect.getCellNumX(); + numX += vnode.getCellNumX(); + } + // 2. 璁$畻妗ヨ仈 + if (OPE_TYPE_BRIDGE.equals(algo.getAlgorithmType())) { + // 妗ヨ仈鏀矾绠椾竴琛岋紝鏁翠釜妗ヨ仈鍏�3琛� + // 2.1 璁$畻绗竴琛� + ModelNode node1 = modelNodeAndVnodeList.stream().filter(item -> + computerNodeListStr[0].equals(item.getId().toString())).collect(Collectors.toList()).get(0); + ModelNode node2 = modelNodeAndVnodeList.stream().filter(item -> + computerNodeListStr[1].equals(item.getId().toString())).collect(Collectors.toList()).get(0); + ModelNode node3 = modelNodeAndVnodeList.stream().filter(item -> + computerNodeListStr[2].equals(item.getId().toString())).collect(Collectors.toList()).get(0); + ModelNode node4 = modelNodeAndVnodeList.stream().filter(item -> + computerNodeListStr[3].equals(item.getId().toString())).collect(Collectors.toList()).get(0); + ModelNode node5 = modelNodeAndVnodeList.stream().filter(item -> + computerNodeListStr[4].equals(item.getId().toString())).collect(Collectors.toList()).get(0); + int numX1 = node1.getCellNumX() + node2.getCellNumX(); + int numY1 = node1.getCellNumY() > node2.getCellNumY() ? node1.getCellNumY() : node2.getCellNumY(); + // 2.2 璁$畻绗簩琛岋紙妗ヨ仈鏀矾锛屾í鍚戠敾鍥撅級 + int numX2 = node3.getCellNumX(); + int numY2 = node3.getCellNumY(); + // 2.3 璁$畻绗笁琛� + int numX3 = node4.getCellNumX() + node5.getCellNumX(); + int numY3 = node4.getCellNumY() > node5.getCellNumY() ? node4.getCellNumY() : node5.getCellNumY(); + numX = Math.max(Math.max(numX1, numX2), numX3); + numY = numY1 + numY2 + numY3; + // 2.4 璁剧疆connect鐨勫ぇ灏� + ModelNode connect = modelNodeAndVnodeList.stream().filter(item -> + vnode.getPairStartNodeId().equals(item.getId().toString())).collect(Collectors.toList()).get(0); + connect.setWidth(LAYOUT_CONNECT_SIZE_X); + connect.setHeight(LAYOUT_CONNECT_SIZE_Y); + connect.setCellNumX(LAYOUT_CELL_NUM_CONNECT_X); + connect.setCellNumY(LAYOUT_CELL_NUM_CONNECT_Y); + numX += connect.getCellNumX(); + numX += vnode.getCellNumX(); + } + vnode.setVnodeCellNumX(numX); + vnode.setVnodeCellNumY(numY); + } + + @Transactional(rollbackFor = Exception.class) + public boolean analyze(ModelRbd modelRbd) { + boolean result = true; + if (modelRbd==null) return result; + Long modelId = modelRbd.getId(); + result = analyzeRbd(modelRbd, true); + return result; + } + + private boolean analyzeRbd(ModelRbd modelRbd, boolean saveFlag) { + boolean result = true; + String rbdsonStr = modelRbd.getContent(); + + JSONArray rbdJsonArray = new JSONObject(rbdsonStr).getJSONArray("cells"); + if (rbdJsonArray == null) return result; + + // 瑙f瀽缁撴灉瀛樻斁list + List<ModelNode> modelNodeList = new ArrayList<>(); + List<ModelLine> modelLineList = new ArrayList<>(); + List<Algorithm> algorithmList = new ArrayList<>(); + List<ProductImg> productImgList = new ArrayList<>(); // 鏆備笉浣跨敤锛堣�屼娇鐢ㄦ暟鎹簱涓殑鍙潬鎬у弬鏁帮級 + + // 1. 瑙f瀽鍑鸿妭鐐逛笌杈� + getNodeAndLineFromRbd(modelRbd.getId(), rbdJsonArray, modelNodeList, modelLineList, productImgList); + // 2. 瀵逛簬鏈夊鏍瑰叆鍙g嚎鐨勪骇鍝佽妭鐐癸紝灏嗗叾涓婄殑琛ㄥ喅銆佹梺鑱斿叧绯诲墺绂绘垚杩愮畻绗﹁妭鐐癸紝娣诲姞鍒拌鑺傜偣鐨勫墠闈紝骞舵坊鍔犵浉搴旂殑杈� + peelOperationFromProductNode(modelRbd.getId(), modelNodeList, modelLineList); + // 3. 璁$畻鎵�鏈夎妭鐐圭殑鍏ュ彛绾挎暟鍙婂嚭鍙g嚎鏁� + calcInOutLineNumAllNode(modelNodeList, modelLineList); + // 4. 澶嶅埗浜у搧鑺傜偣(node)鍒發ist + List<ModelNode> modelNodeAndVnodeList = modelNodeList.stream().filter(item -> + "node".equals(item.getNodeType())).collect(Collectors.toList()); + // 5. 涓嶆柇灏嗗熀鏈ā鍨嬶紙涓茶仈銆佸苟鑱斻�佹梺鑱斻�佽〃鍐炽�佹ˉ鑱旓級鏇挎崲涓鸿櫄鑺傜偣鑰岀畝鍖栧浘褰紝鐩磋嚦鏃犳硶绠�鍖栦负姝€�� + result = getAlgorithmFromRbd(modelRbd, modelNodeList, modelLineList, algorithmList, modelNodeAndVnodeList); + + // 6. 杞崲涓虹畻娉曞簱鎺ュ彛XML + if (result) { +// result = createIfXmlFromRbd(modelRbd, algorithmList, modelNodeAndVnodeList); + } + + // 7. 淇濆瓨妯″瀷 + if (saveFlag) saveModel(modelRbd, modelNodeList, modelLineList, algorithmList, modelNodeAndVnodeList); + + return result; + } + + private void peelOperationFromProductNode(Long modelId, + List<ModelNode> modelNodeList, + List<ModelLine> modelLineList) { + List<ModelNode> nodesToAdd = new ArrayList<>(); + List<ModelLine> linesToAdd = new ArrayList<>(); + for (ModelNode node: modelNodeList) { + List<ModelLine> inLineList = modelLineList.stream().filter(item -> + item.getEndCell().equals(node.getPicId())).collect(Collectors.toList()); + if ("node".equals(node.getNodeType()) && + StringUtils.isNotBlank(node.getNodeTypeExt()) && + inLineList.size() > 1) { + // 鏃佽仈or琛ㄥ喅 + ModelNode nodeNew = new ModelNode(); + Long nodeNewId = UUIDUtil.generateId(); + nodeNew.setId(nodeNewId); + nodeNew.setPicId(nodeNewId.toString()); + nodeNew.setModelId(modelId); + nodeNew.setNodeType(node.getNodeTypeExt()); + nodeNew.setName(node.getNodeTypeExt()); + nodeNew.setVoteNum(node.getVoteNum()); + nodeNew.setPositionX(node.getPositionX()); + nodeNew.setPositionY(node.getPositionY()); + nodesToAdd.add(nodeNew); + + ModelLine lineNew = new ModelLine(); + Long lineNewId = UUIDUtil.generateId(); + lineNew.setId(lineNewId); + lineNew.setPicId(lineNewId.toString()); + lineNew.setModelId(modelId); + lineNew.setBeginCell(nodeNewId.toString()); + lineNew.setEndCell(node.getPicId()); + linesToAdd.add(lineNew); + + for(ModelLine line: inLineList){ + line.setEndCell(nodeNewId.toString()); + } + } + } + modelNodeList.addAll(nodesToAdd); + modelLineList.addAll(linesToAdd); + } + + private boolean getAlgorithmFromRbd(ModelRbd modelRbd, + List<ModelNode> modelNodeList, + List<ModelLine> modelLineList, + List<Algorithm> algorithmList, + List<ModelNode> modelNodeAndVnodeList) { // 鏍规嵁浠ヤ笅鐨勬瀯鍥捐鍒欐潵杩涜绠楁硶鍒嗚В锛� // 1銆佽妭鐐圭殑瀹氫箟 // 1-1) 杩愮畻鑺傜偣锛氬叡2涓細鏃佽仈銆佽〃鍐筹紝涓旇繍绠楄妭鐐归渶鏀惧湪琚繍绠楄妭鐐圭殑鍙充晶銆� @@ -145,12 +686,13 @@ boolean hasSimplified = false; // 鑷冲皯绠�鍖栦簡涓�澶勫浘褰� do { hasSimplified = false; - hasSimplified = simplifySeries(modelId, modelNodeList, modelLineList, algorithmList, modelNodeAndVnodeList, hasSimplified); - hasSimplified = simplifyParallel(modelId, modelNodeList, modelLineList, algorithmList, modelNodeAndVnodeList, hasSimplified); - hasSimplified = simplifyOperator("switch", modelId, modelNodeList, modelLineList, algorithmList, modelNodeAndVnodeList, hasSimplified); - hasSimplified = simplifyOperator("vote", modelId, modelNodeList, modelLineList, algorithmList, modelNodeAndVnodeList, hasSimplified); - hasSimplified = simplifyBridge(modelId, modelNodeList, modelLineList, algorithmList, modelNodeAndVnodeList, hasSimplified); - isEnd = simplifyEnd(modelId, modelNodeList, modelLineList, algorithmList, modelNodeAndVnodeList); + hasSimplified = simplifySeries(modelRbd.getId(), modelNodeList, modelLineList, algorithmList, modelNodeAndVnodeList, hasSimplified); +// hasSimplified = simplifyParallel(modelRbd.getId(), modelNodeList, modelLineList, algorithmList, modelNodeAndVnodeList, hasSimplified); + hasSimplified = simplifyOperator("parallel", modelRbd.getId(), modelNodeList, modelLineList, algorithmList, modelNodeAndVnodeList, hasSimplified); + hasSimplified = simplifyOperator("switch", modelRbd.getId(), modelNodeList, modelLineList, algorithmList, modelNodeAndVnodeList, hasSimplified); + hasSimplified = simplifyOperator("vote", modelRbd.getId(), modelNodeList, modelLineList, algorithmList, modelNodeAndVnodeList, hasSimplified); + hasSimplified = simplifyBridge(modelRbd.getId(), modelNodeList, modelLineList, algorithmList, modelNodeAndVnodeList, hasSimplified); + isEnd = simplifyEnd(modelRbd.getId(), modelNodeList, modelLineList, algorithmList, modelNodeAndVnodeList); } while (!isEnd && hasSimplified); return isEnd; @@ -229,7 +771,7 @@ if (result.size()<2) continue; ModelNode endNode = result.get(result.size()-1); - if ("start,switch,vote".contains(endNode.getNodeType()) || endNode.getOutLineNum()!=1) { + if ("start,parallel,switch,vote,bridge".contains(endNode.getNodeType()) || endNode.getOutLineNum()!=1) { result.remove(endNode); } List<ModelNode> realSeriesNodes = result.stream().filter(item -> @@ -493,12 +1035,37 @@ List<ModelNode> result) { ModelLine inLine = modelLineList.stream().filter(item -> item.getEndCell().equals(startNode.getPicId())).collect(Collectors.toList()).get(0); - ModelNode pathNode = modelNodeList.stream().filter(item -> - inLine.getBeginCell().equals(item.getPicId())).collect(Collectors.toList()).get(0); + if (isBridgeUpperLine(inLine, modelLineList) || isBridgeLowerLine(inLine, modelLineList)) return; + List<ModelNode> nodes = modelNodeList.stream().filter(item -> + inLine.getBeginCell().equals(item.getPicId())).collect(Collectors.toList()); + if (0==nodes.size()) return; // 鍒版ˉ鑱斾腑闂磋妭鐐圭殑绾跨殑璧风偣涓嶆槸Node锛岃�屾槸Line锛屾墍浠ヨ幏鍙栫殑璧风偣鏁板彲鑳戒负0 + ModelNode pathNode = nodes.get(0); result.add(pathNode); if (pathNode.getOutLineNum()!=1 || pathNode.getInLineNum()!=1) return; - if ("switch,vote".contains(pathNode.getNodeType())) return; + if ("parallel,switch,vote,bridge".contains(pathNode.getNodeType())) return; seekPathSeries(modelNodeList, modelLineList, pathNode, result); + } + + private boolean isBridgeUpperLine(ModelLine line, List<ModelLine> modelLineList) { + boolean result = false; + for (ModelLine ln : modelLineList) { + if (ln.getBeginCell().equals(line.getPicId())) { + result = true; + break; + } + } + return result; + } + + private boolean isBridgeLowerLine(ModelLine line, List<ModelLine> modelLineList) { + boolean result = false; + for (ModelLine ln : modelLineList) { + if (ln.getEndCell().equals(line.getPicId())) { + result = true; + break; + } + } + return result; } private boolean simplifyParallel(Long modelId, @@ -547,6 +1114,7 @@ ModelNode endNode = getBranchNodesOneParallel(pathOneGroup, branchNodeList); if ("connect".equals(startNode.getNodeType()) && pathOneGroup.size()==lines.size()) { // 鏇挎崲鎴愯櫄鑺傜偣 + modelNodeAndVnodeList.add(startNode); replaceToVnode("parallel", modelId, modelNodeList, modelLineList, algorithmList, modelNodeAndVnodeList, startNode, endNode, branchNodeList); } else { @@ -636,15 +1204,15 @@ boolean hasSimplified) { boolean hasSimplifiedMe = false; List<ModelNode> startNodes = modelNodeList.stream().filter(item -> - "node,vnode,connect,end".contains(item.getNodeType())).collect(Collectors.toList()); + "bridge".equals(item.getNodeType())).collect(Collectors.toList()); if (startNodes.size()==0) return hasSimplified; for (ModelNode startNode : startNodes) { List<ModelLine> lines = modelLineList.stream().filter(item -> item.getEndCell().equals(startNode.getPicId())).collect(Collectors.toList()); if (lines.size()<2) continue; - List<ModelLinePair> linePairs = getLinePairs(lines); - for (ModelLinePair linePair : linePairs) { + List<ModelLinePairDto> linePairs = getLinePairs(lines); + for (ModelLinePairDto linePair : linePairs) { hasSimplifiedMe = simplifyBridgeOneLinePair(modelId, modelNodeList, modelLineList, algorithmList, modelNodeAndVnodeList, startNode, linePair); if (hasSimplifiedMe) { @@ -663,12 +1231,15 @@ List<Algorithm> algorithmList, List<ModelNode> modelNodeAndVnodeList, ModelNode startNode, - ModelLinePair linePair) { + ModelLinePairDto linePair) { ModelNode node1 = null; ModelNode node2 = null; ModelNode node3 = null; ModelNode node4 = null; ModelNode node5 = null; + ModelLine line1To2 = null; + ModelLine line4To5 = null; +/* ModelNode nodeTmp1 = modelNodeList.stream().filter(item -> linePair.getLine1().getBeginCell().equals(item.getPicId())).collect(Collectors.toList()).get(0); ModelNode nodeTmp2 = modelNodeList.stream().filter(item -> @@ -733,6 +1304,79 @@ lineTo4.getBeginCell().equals(item.getPicId())).collect(Collectors.toList()).get(0); if (!nodeTmp1.getId().equals(nodeTmp2.getId())) return false; ModelNode endNode = nodeTmp1; +*/ + ModelNode nodeTmp1 = modelNodeList.stream().filter(item -> + linePair.getLine1().getBeginCell().equals(item.getPicId())).collect(Collectors.toList()).get(0); + ModelNode nodeTmp2 = modelNodeList.stream().filter(item -> + linePair.getLine2().getBeginCell().equals(item.getPicId())).collect(Collectors.toList()).get(0); + if (nodeTmp1.getInLineNum()!=1 || nodeTmp1.getOutLineNum()!=1) return false; + if (nodeTmp2.getInLineNum()!=1 || nodeTmp2.getOutLineNum()!=1) return false; + ModelNode finalNode = nodeTmp1; + ModelLine lineToNodeTmp1 = modelLineList.stream().filter(item -> + item.getEndCell().equals(finalNode.getPicId())).collect(Collectors.toList()).get(0); + ModelNode finalNode1 = nodeTmp2; + ModelLine lineToNodeTmp2 = modelLineList.stream().filter(item -> + item.getEndCell().equals(finalNode1.getPicId())).collect(Collectors.toList()).get(0); + ModelNode nodeTmp3 = modelNodeList.stream().filter(item -> + lineToNodeTmp1.getBeginCell().equals(item.getPicId())).collect(Collectors.toList()).get(0); + ModelNode nodeTmp4 = modelNodeList.stream().filter(item -> + lineToNodeTmp2.getBeginCell().equals(item.getPicId())).collect(Collectors.toList()).get(0); + if (nodeTmp3.getId().equals(nodeTmp4.getId())) return false; + boolean isBridgeUpperLine1 = isBridgeUpperLine(lineToNodeTmp1, modelLineList); + boolean isBridgeUpperLine2 = isBridgeUpperLine(lineToNodeTmp2, modelLineList); + if (!isBridgeUpperLine1 && !isBridgeUpperLine2) return false; + if (isBridgeUpperLine1 && isBridgeUpperLine2) return false; + boolean isBridgeLowerLine1 = isBridgeLowerLine(lineToNodeTmp1, modelLineList); + boolean isBridgeLowerLine2 = isBridgeLowerLine(lineToNodeTmp2, modelLineList); + if (!isBridgeLowerLine1 && !isBridgeLowerLine2) return false; + if (isBridgeLowerLine1 && isBridgeLowerLine2) return false; + if (isBridgeUpperLine1) { + line1To2 = lineToNodeTmp1; + line4To5 = lineToNodeTmp2; + node2 = nodeTmp1; + node5 = nodeTmp2; + } else { + line1To2 = lineToNodeTmp2; + line4To5 = lineToNodeTmp1; + node2 = nodeTmp2; + node5 = nodeTmp1; + } + ModelLine finalLine = line1To2; + ModelLine lineTo3 = modelLineList.stream().filter(item -> + item.getBeginCell().equals(finalLine.getPicId())).collect(Collectors.toList()).get(0); + ModelLine finalLine1 = line4To5; + ModelLine lineFrom3 = modelLineList.stream().filter(item -> + item.getEndCell().equals(finalLine1.getPicId())).collect(Collectors.toList()).get(0); + ModelLine finalLine2 = lineTo3; + ModelNode node3Candidate1 = modelNodeList.stream().filter(item -> + finalLine2.getEndCell().equals(item.getPicId())).collect(Collectors.toList()).get(0); + ModelLine finalLine3 = lineFrom3; + ModelNode node3Candidate2 = modelNodeList.stream().filter(item -> + finalLine3.getBeginCell().equals(item.getPicId())).collect(Collectors.toList()).get(0); + if (!node3Candidate1.getId().equals(node3Candidate2.getId())) return false; + node3 = node3Candidate1; + if (node3.getInLineNum()!=1 || node3.getOutLineNum()!=1) return false; + ModelLine finalLine4 = line1To2; + node1 = modelNodeList.stream().filter(item -> + finalLine4.getBeginCell().equals(item.getPicId())).collect(Collectors.toList()).get(0); + if (node1.getInLineNum()!=1 || node1.getOutLineNum()!=1) return false; + ModelLine finalLine5 = line4To5; + node4 = modelNodeList.stream().filter(item -> + finalLine5.getBeginCell().equals(item.getPicId())).collect(Collectors.toList()).get(0); + if (node4.getInLineNum()!=1 || node4.getOutLineNum()!=1) return false; + ModelNode finalNode3 = node1; + ModelLine lineTo1 = modelLineList.stream().filter(item -> + item.getEndCell().equals(finalNode3.getPicId())).collect(Collectors.toList()).get(0); + ModelNode finalNode4 = node4; + ModelLine lineTo4 = modelLineList.stream().filter(item -> + item.getEndCell().equals(finalNode4.getPicId())).collect(Collectors.toList()).get(0); + nodeTmp1 = modelNodeList.stream().filter(item -> + lineTo1.getBeginCell().equals(item.getPicId())).collect(Collectors.toList()).get(0); + nodeTmp2 = modelNodeList.stream().filter(item -> + lineTo4.getBeginCell().equals(item.getPicId())).collect(Collectors.toList()).get(0); + if (!nodeTmp1.getId().equals(nodeTmp2.getId())) return false; + ModelNode endNode = nodeTmp1; + List<ModelNode> branchNodeList = new ArrayList<>(); branchNodeList.add(node1); branchNodeList.add(node2); @@ -740,8 +1384,14 @@ branchNodeList.add(node4); branchNodeList.add(node5); + modelNodeAndVnodeList.add(startNode); + replaceToVnode("bridge", modelId, modelNodeList, modelLineList, + algorithmList, modelNodeAndVnodeList, startNode, endNode, branchNodeList); + +/* if ("connect".equals(startNode.getNodeType()) && startNode.getInLineNum()==2) { // 鏇挎崲鎴愯櫄鑺傜偣 + modelNodeAndVnodeList.add(startNode); replaceToVnode("bridge", modelId, modelNodeList, modelLineList, algorithmList, modelNodeAndVnodeList, startNode, endNode, branchNodeList); } else { @@ -771,6 +1421,7 @@ algorithmList, modelNodeAndVnodeList, vnode, endNode, branchNodeList); calcInOutLineNum(startNode, modelLineList); } +*/ return true; } @@ -791,11 +1442,11 @@ } // 鎵惧嚭鎵�鏈�2鏍圭嚎鐨勭粍鍚� - private List<ModelLinePair> getLinePairs(List<ModelLine> lines) { - List<ModelLinePair> linePairs = new ArrayList<>(); + private List<ModelLinePairDto> getLinePairs(List<ModelLine> lines) { + List<ModelLinePairDto> linePairs = new ArrayList<>(); for (int i=0; i<lines.size()-1; i++) { for (int j=i+1; j<lines.size(); j++) { - ModelLinePair linePair = new ModelLinePair(); + ModelLinePairDto linePair = new ModelLinePairDto(); linePair.setLine1(lines.get(i)); linePair.setLine2(lines.get(j)); linePairs.add(linePair); @@ -837,6 +1488,7 @@ } } if (thisNodeSuccess) { + modelNodeAndVnodeList.add(opNode); replaceToVnode(opNode.getNodeType(), modelId, modelNodeList, modelLineList, algorithmList, modelNodeAndVnodeList, opNode, endNode, branchNodeList); hasSimplified = true; @@ -866,6 +1518,7 @@ algorithm.setAlgorithmType(type); algorithm.setComputerList(computerList.get(0)); algorithm.setObjectList(computerList.get(1)); + if ("vote".equals(type)) algorithm.setVoteNum(startNode.getVoteNum()); algorithm.setStep(algorithmList.size()==0 ? 0 : algorithmList.get(algorithmList.size()-1).getStep()+1); algorithmList.add(algorithm); @@ -918,7 +1571,9 @@ private void getNodeAndLineFromRbd(Long modelId, JSONArray rbdJsonArray, List<ModelNode> modelNodeList, - List<ModelLine> modelLineList) { + List<ModelLine> modelLineList, + List<ProductImg> productImgList) { + Object jsonValue = null; for (int i = 0; i < rbdJsonArray.size(); i++) { JSONObject jsonObject = rbdJsonArray.getJSONObject(i); String shape = jsonObject.get("shape").toString(); @@ -938,11 +1593,73 @@ modelNode.setNodeType(JsonUtils2.getJsonValueByPath(jsonObject, "data/nodeType".split("/")).toString()); modelNode.setPositionX(Double.valueOf(JsonUtils2.getJsonValueByPath(jsonObject, "position/x".split("/")).toString())); modelNode.setPositionY(Double.valueOf(JsonUtils2.getJsonValueByPath(jsonObject, "position/y".split("/")).toString())); + jsonValue = JsonUtils2.getJsonValueByPath(jsonObject, "data/voteNum".split("/")); + if (jsonValue!=null && StringUtils.isNotBlank(jsonValue.toString())) { + modelNode.setVoteNum(Integer.valueOf(jsonValue.toString())); + } + jsonValue = JsonUtils2.getJsonValueByPath(jsonObject, "data/startNodeId".split("/")); + if (jsonValue!=null && StringUtils.isNotBlank(jsonValue.toString())) { + modelNode.setPairStartNodeId(jsonValue.toString()); + } + jsonValue = JsonUtils2.getJsonValueByPath(jsonObject, "data/endNodeId".split("/")); + if (jsonValue!=null && StringUtils.isNotBlank(jsonValue.toString())) { + modelNode.setPairEndNodeId(jsonValue.toString()); + } if ("node".equals(modelNode.getNodeType())) { - modelNode.setDataId(Long.valueOf(JsonUtils2.getJsonValueByPath(jsonObject, "data/dataId".split("/")).toString())); + ProductImg productImg = new ProductImg(); + String dataId = JsonUtils2.getJsonValueByPath(jsonObject, "data/dataId".split("/")).toString(); + modelNode.setDataId(Long.valueOf(dataId)); modelNode.setNodeTypeExt(JsonUtils2.getJsonValueByPath(jsonObject, "data/nodeTypeExt".split("/")).toString()); - Object name = JsonUtils2.getJsonValueByPath(jsonObject, "attrs/text/text".split("/")); - modelNode.setName(name==null ? "" : name.toString()); + jsonValue = JsonUtils2.getJsonValueByPath(jsonObject, "attrs/text/text".split("/")); + modelNode.setName(jsonValue==null ? "" : jsonValue.toString()); + + productImg.setDataId(dataId); + String productType = JsonUtils2.getJsonValueByPath(jsonObject, "data/productType".split("/")).toString(); + productImg.setProductType(productType); + if ("product_sb".equals(productType)) { + jsonValue = JsonUtils2.getJsonValueByPath(jsonObject, "data/reliabDistribType".split("/")); + if (jsonValue != null && StringUtils.isNotBlank(jsonValue.toString())) { + productImg.setReliabDistribType(Integer.valueOf(jsonValue.toString())); + if (3==productImg.getReliabDistribType()) { + // 浜岄」鍒嗗竷 + jsonValue = JsonUtils2.getJsonValueByPath(jsonObject, "data/simulatTimes".split("/")); + if (jsonValue != null && StringUtils.isNotBlank(jsonValue.toString())) { + productImg.setBinomialTotalNum(Integer.valueOf(jsonValue.toString())); + modelNode.setBinomialTotalNum(Integer.valueOf(jsonValue.toString())); + } + jsonValue = JsonUtils2.getJsonValueByPath(jsonObject, "data/successTimes".split("/")); + if (jsonValue != null && StringUtils.isNotBlank(jsonValue.toString())) { + productImg.setBinomialSuccessNum(Integer.valueOf(jsonValue.toString())); + modelNode.setBinomialSuccessNum(Integer.valueOf(jsonValue.toString())); + } + } + } + jsonValue = JsonUtils2.getJsonValueByPath(jsonObject, "data/taskMtbcf".split("/")); + if (null != jsonValue) productImg.setTaskMtbcf(jsonValue.toString()); + jsonValue = JsonUtils2.getJsonValueByPath(jsonObject, "data/taskMtbcfOtherParams2".split("/")); + if (null != jsonValue) productImg.setTaskMtbcfOtherParams2(jsonValue.toString()); + jsonValue = JsonUtils2.getJsonValueByPath(jsonObject, "data/taskMtbcfOtherParams3".split("/")); + if (null != jsonValue) productImg.setTaskMtbcfOtherParams3(jsonValue.toString()); + jsonValue = JsonUtils2.getJsonValueByPath(jsonObject, "data/isRepair".split("/")); + if (jsonValue != null && StringUtils.isNotBlank(jsonValue.toString()) && !"null".equals(jsonValue.toString())) { + productImg.setIsRepair(Integer.valueOf(jsonValue.toString())); + } else { + productImg.setIsRepair(0); + } + if (1 == productImg.getIsRepair()) { + jsonValue = JsonUtils2.getJsonValueByPath(jsonObject, "data/repairDistribType".split("/")); + if (jsonValue != null && StringUtils.isNotBlank(jsonValue.toString())) { + productImg.setRepairDistribType(Integer.valueOf(jsonValue.toString())); + } + jsonValue = JsonUtils2.getJsonValueByPath(jsonObject, "data/repairMttcr".split("/")); + if (null != jsonValue) productImg.setRepairMttcr(jsonValue.toString()); + jsonValue = JsonUtils2.getJsonValueByPath(jsonObject, "data/repairMttcrOtherParams2".split("/")); + if (null != jsonValue) productImg.setRepairMttcrOtherParams2(jsonValue.toString()); + jsonValue = JsonUtils2.getJsonValueByPath(jsonObject, "data/repairMttcrOtherParams3".split("/")); + if (null != jsonValue) productImg.setRepairMttcrOtherParams3(jsonValue.toString()); + } + } + productImgList.add(productImg); } modelNodeList.add(modelNode); } @@ -966,6 +1683,37 @@ } */ + private void saveModel(ModelRbd modelRbd, + List<ModelNode> modelNodeList, + List<ModelLine> modelLineList, + List<Algorithm> algoList, + List<ModelNode> modelNodeAndVnodeList) { + // 鍒犻櫎鏃㈡湁鏁版嵁 + modelNodeDao.deleteByModelId(modelRbd.getId()); + modelLineDao.deleteByModelId(modelRbd.getId()); + algorithmDao.deleteByModelId(modelRbd.getId()); + modelNodeAlgorithmDao.deleteByModelId(modelRbd.getId()); + + // 鎻掑叆鏁版嵁 + for (ModelNode modelNode : modelNodeList) { + modelNodeDao.insert(modelNode); + } + for (ModelLine modelLine : modelLineList) { + modelLineDao.insert(modelLine); + } + for (Algorithm algorithm : algoList) { + algorithmDao.insert(algorithm); + } + for (ModelNode modelNode : modelNodeAndVnodeList) { + modelNodeAlgorithmDao.insert(ModelNodeAlgorithm.from(modelNode)); + } + + // 鏇存柊RBD鏁版嵁 + modelRbd.setPublishedContent(modelRbd.getContent()); + modelRbdDao.updateById(modelRbd); + } + +/* ============瑙f瀽妯″瀷鐨勭1鐗堬紝宸蹭笉浣跨敤============ private void analyzeRbdAndSave(Long modelId, String content, boolean saveFlag) { String diagramJsonStr = content; // String diagramJsonStr = "{\"cells\":[{\"shape\":\"edge\",\"attrs\":{\"line\":{\"stroke\":\"#5F95FF\"}},\"id\":\"26d1a5a6-0be8-4890-86a0-a33d429e6673\",\"labels\":[{\"attrs\":{\"body\":{\"stroke\":\"#5F95FF\"},\"text\":{\"text\":\"\"}},\"position\":{\"distance\":0.5,\"angle\":180,\"options\":{\"keepGradient\":true,\"ensureLegibility\":true}}}],\"zIndex\":0,\"source\":{\"cell\":\"f91765b1-af48-4396-84ba-eb16e3476aa5\",\"port\":\"839cb2d9-59ca-4a39-a63c-26bf60cc6989\"},\"target\":{\"cell\":\"31585e99-58c7-4a98-8824-8000743b364d\",\"port\":\"01eb49d9-4b1c-466f-8263-935542436c7e\"}},{\"shape\":\"edge\",\"attrs\":{\"line\":{\"stroke\":\"#5F95FF\"}},\"id\":\"f2286e46-84c7-4702-8670-d7cda22c34e5\",\"labels\":[{\"attrs\":{\"body\":{\"stroke\":\"#5F95FF\"},\"text\":{\"text\":\"\"}},\"position\":{\"distance\":0.5,\"angle\":180,\"options\":{\"keepGradient\":true,\"ensureLegibility\":true}}}],\"zIndex\":0,\"source\":{\"cell\":\"f91765b1-af48-4396-84ba-eb16e3476aa5\",\"port\":\"839cb2d9-59ca-4a39-a63c-26bf60cc6989\"},\"target\":{\"cell\":\"5123ad82-18bb-46fe-9d93-138b24b54a15\",\"port\":\"01eb49d9-4b1c-466f-8263-935542436c7e\"}},{\"shape\":\"edge\",\"attrs\":{\"line\":{\"stroke\":\"#5F95FF\"}},\"id\":\"2ab8b7f8-7fe2-490f-89c5-4250d4a62a78\",\"labels\":[{\"attrs\":{\"body\":{\"stroke\":\"#5F95FF\"},\"text\":{\"text\":\"\"}},\"position\":{\"distance\":0.5,\"angle\":180,\"options\":{\"keepGradient\":true,\"ensureLegibility\":true}}}],\"zIndex\":0,\"source\":{\"cell\":\"31585e99-58c7-4a98-8824-8000743b364d\",\"port\":\"a977d555-b8c8-4578-9a8b-3097c405c1a8\"},\"target\":{\"cell\":\"6df9adc8-cb83-405c-8482-633db0f3644f\",\"port\":\"f93ccd2f-dedd-47b1-9ad0-9be20c5db8a4\"}},{\"shape\":\"edge\",\"attrs\":{\"line\":{\"stroke\":\"#5F95FF\"}},\"id\":\"700c05a5-f151-4b28-8135-705ccf013522\",\"labels\":[{\"attrs\":{\"body\":{\"stroke\":\"#5F95FF\"},\"text\":{\"text\":\"\"}},\"position\":{\"distance\":0.5,\"angle\":180,\"options\":{\"keepGradient\":true,\"ensureLegibility\":true}}}],\"zIndex\":0,\"source\":{\"cell\":\"5123ad82-18bb-46fe-9d93-138b24b54a15\",\"port\":\"a977d555-b8c8-4578-9a8b-3097c405c1a8\"},\"target\":{\"cell\":\"6df9adc8-cb83-405c-8482-633db0f3644f\",\"port\":\"f93ccd2f-dedd-47b1-9ad0-9be20c5db8a4\"}},{\"shape\":\"edge\",\"attrs\":{\"line\":{\"stroke\":\"#5F95FF\"}},\"id\":\"feef2a57-3c72-4d69-92a6-c828c736b61a\",\"labels\":[{\"attrs\":{\"body\":{\"stroke\":\"#5F95FF\"},\"text\":{\"text\":\"\"}},\"position\":{\"distance\":0.5,\"angle\":180,\"options\":{\"keepGradient\":true,\"ensureLegibility\":true}}}],\"zIndex\":0,\"source\":{\"cell\":\"6df9adc8-cb83-405c-8482-633db0f3644f\",\"port\":\"80d3bd61-1ed3-493a-b4e8-d4576e6fbfda\"},\"target\":{\"cell\":\"da634b2e-5ffc-4e1b-a636-f86ace9eb082\",\"port\":\"01eb49d9-4b1c-466f-8263-935542436c7e\"}},{\"shape\":\"edge\",\"attrs\":{\"line\":{\"stroke\":\"#5F95FF\"}},\"id\":\"49e36d6f-6a94-4edc-9894-6dd825091706\",\"labels\":[{\"attrs\":{\"body\":{\"stroke\":\"#5F95FF\"},\"text\":{\"text\":\"\"}},\"position\":{\"distance\":0.5,\"angle\":180,\"options\":{\"keepGradient\":true,\"ensureLegibility\":true}}}],\"zIndex\":0,\"source\":{\"cell\":\"f91765b1-af48-4396-84ba-eb16e3476aa5\",\"port\":\"839cb2d9-59ca-4a39-a63c-26bf60cc6989\"},\"target\":{\"cell\":\"2b6df966-4e19-4055-bb13-c4c083b18e58\",\"port\":\"01eb49d9-4b1c-466f-8263-935542436c7e\"}},{\"shape\":\"edge\",\"attrs\":{\"line\":{\"stroke\":\"#5F95FF\"}},\"id\":\"ed8c1bfa-c0a6-4e9b-8697-862aef109bcf\",\"labels\":[{\"attrs\":{\"body\":{\"stroke\":\"#5F95FF\"},\"text\":{\"text\":\"\"}},\"position\":{\"distance\":0.5,\"angle\":180,\"options\":{\"keepGradient\":true,\"ensureLegibility\":true}}}],\"zIndex\":0,\"source\":{\"cell\":\"f91765b1-af48-4396-84ba-eb16e3476aa5\",\"port\":\"839cb2d9-59ca-4a39-a63c-26bf60cc6989\"},\"target\":{\"cell\":\"323f5abe-05ed-419d-9d81-d25c7d3b19f3\",\"port\":\"01eb49d9-4b1c-466f-8263-935542436c7e\"}},{\"shape\":\"edge\",\"attrs\":{\"line\":{\"stroke\":\"#5F95FF\"}},\"id\":\"70c6b5fb-1b48-4a2f-bacd-be0284134818\",\"labels\":[{\"attrs\":{\"body\":{\"stroke\":\"#5F95FF\"},\"text\":{\"text\":\"\"}},\"position\":{\"distance\":0.5,\"angle\":180,\"options\":{\"keepGradient\":true,\"ensureLegibility\":true}}}],\"zIndex\":0,\"source\":{\"cell\":\"2b6df966-4e19-4055-bb13-c4c083b18e58\",\"port\":\"a977d555-b8c8-4578-9a8b-3097c405c1a8\"},\"target\":{\"cell\":\"1f378f5e-066d-49bb-a6cc-de24a8882d65\",\"port\":\"01eb49d9-4b1c-466f-8263-935542436c7e\"}},{\"shape\":\"edge\",\"attrs\":{\"line\":{\"stroke\":\"#5F95FF\"}},\"id\":\"6a134969-623b-428e-9b0c-436bae2d6608\",\"labels\":[{\"attrs\":{\"body\":{\"stroke\":\"#5F95FF\"},\"text\":{\"text\":\"\"}},\"position\":{\"distance\":0.5,\"angle\":180,\"options\":{\"keepGradient\":true,\"ensureLegibility\":true}}}],\"zIndex\":0,\"source\":{\"cell\":\"323f5abe-05ed-419d-9d81-d25c7d3b19f3\",\"port\":\"a977d555-b8c8-4578-9a8b-3097c405c1a8\"},\"target\":{\"cell\":\"1f378f5e-066d-49bb-a6cc-de24a8882d65\",\"port\":\"01eb49d9-4b1c-466f-8263-935542436c7e\"}},{\"shape\":\"edge\",\"attrs\":{\"line\":{\"stroke\":\"#5F95FF\"}},\"id\":\"51de5faf-1766-4dd1-abd0-eec2e867a322\",\"labels\":[{\"attrs\":{\"body\":{\"stroke\":\"#5F95FF\"},\"text\":{\"text\":\"\"}},\"position\":{\"distance\":0.5,\"angle\":180,\"options\":{\"keepGradient\":true,\"ensureLegibility\":true}}}],\"zIndex\":0,\"source\":{\"cell\":\"1f378f5e-066d-49bb-a6cc-de24a8882d65\",\"port\":\"a977d555-b8c8-4578-9a8b-3097c405c1a8\"},\"target\":{\"cell\":\"0bb2ba89-a92d-4b32-b3cd-45df2300fa34\",\"port\":\"61eaafd2-095b-41d6-8e34-862fb470b7a6\"}},{\"shape\":\"edge\",\"attrs\":{\"line\":{\"stroke\":\"#A2B1C3\"}},\"id\":\"161f78dc-1f44-4e43-9ced-e39d345aac78\",\"labels\":[{\"attrs\":{\"body\":{\"stroke\":\"#5F95FF\"},\"text\":{\"text\":\"\"}},\"position\":{\"distance\":0.5,\"angle\":180,\"options\":{\"keepGradient\":true,\"ensureLegibility\":true}}}],\"zIndex\":0,\"source\":{\"cell\":\"da634b2e-5ffc-4e1b-a636-f86ace9eb082\",\"port\":\"a977d555-b8c8-4578-9a8b-3097c405c1a8\"},\"target\":{\"cell\":\"0bb2ba89-a92d-4b32-b3cd-45df2300fa34\",\"port\":\"61eaafd2-095b-41d6-8e34-862fb470b7a6\"}},{\"position\":{\"x\":-350,\"y\":-280},\"size\":{\"width\":60,\"height\":60},\"attrs\":{\"text\":{\"refY\":\"100%\",\"textVerticalAnchor\":\"top\",\"text\":\"logo\",\"style\":{\"color\":\"#080808\"},\"refY2\":4},\"image\":{\"xlink:href\":\"dist/img/logo.36cbc06d.png\"},\"body\":{\"stroke\":\"#5F95FF\"},\"line\":{\"stroke\":\"orange\"}},\"visible\":true,\"shape\":\"image\",\"id\":\"31585e99-58c7-4a98-8824-8000743b364d\",\"data\":{\"dataId\":\"123456\",\"nodeType\":\"node\",\"nodeTypeExt\":\"aaa\"},\"ports\":{\"groups\":{\"top\":{\"position\":\"top\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"right\":{\"position\":\"right\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"bottom\":{\"position\":\"bottom\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"left\":{\"position\":\"left\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}}},\"items\":[{\"group\":\"top\",\"id\":\"bc0336ec-7912-4720-aea7-e5869de77692\"},{\"group\":\"right\",\"id\":\"a977d555-b8c8-4578-9a8b-3097c405c1a8\"},{\"group\":\"bottom\",\"id\":\"fef0f533-9581-4831-ba65-427f097a3d17\"},{\"group\":\"left\",\"id\":\"01eb49d9-4b1c-466f-8263-935542436c7e\"}]},\"zIndex\":1,\"labels\":[{\"attrs\":{\"body\":{\"stroke\":\"orange\"}}}]},{\"position\":{\"x\":-350,\"y\":-180},\"size\":{\"width\":60,\"height\":60},\"attrs\":{\"text\":{\"refY\":\"100%\",\"textVerticalAnchor\":\"top\",\"text\":\"logo\",\"style\":{\"color\":\"#080808\"},\"refY2\":4},\"image\":{\"xlink:href\":\"dist/img/logo.36cbc06d.png\"},\"body\":{\"stroke\":\"#5F95FF\"},\"line\":{\"stroke\":\"orange\"}},\"visible\":true,\"shape\":\"image\",\"id\":\"5123ad82-18bb-46fe-9d93-138b24b54a15\",\"data\":{\"dataId\":\"123456\",\"nodeType\":\"node\",\"nodeTypeExt\":\"aaa\"},\"ports\":{\"groups\":{\"top\":{\"position\":\"top\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"right\":{\"position\":\"right\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"bottom\":{\"position\":\"bottom\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"left\":{\"position\":\"left\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}}},\"items\":[{\"group\":\"top\",\"id\":\"bc0336ec-7912-4720-aea7-e5869de77692\"},{\"group\":\"right\",\"id\":\"a977d555-b8c8-4578-9a8b-3097c405c1a8\"},{\"group\":\"bottom\",\"id\":\"fef0f533-9581-4831-ba65-427f097a3d17\"},{\"group\":\"left\",\"id\":\"01eb49d9-4b1c-466f-8263-935542436c7e\"}]},\"zIndex\":2,\"labels\":[{\"attrs\":{\"body\":{\"stroke\":\"orange\"}}}]},{\"position\":{\"x\":-620,\"y\":-200},\"size\":{\"width\":60,\"height\":60},\"attrs\":{\"text\":{\"refY\":\"100%\",\"textVerticalAnchor\":\"top\",\"text\":\"start\",\"style\":{\"color\":\"#080808\"},\"refY2\":4},\"image\":{\"xlink:href\":\"dist/img/start.88f586e1.png\"},\"body\":{\"stroke\":\"#5F95FF\"},\"line\":{\"stroke\":\"orange\"}},\"visible\":true,\"shape\":\"image\",\"id\":\"f91765b1-af48-4396-84ba-eb16e3476aa5\",\"data\":{\"dataId\":\"\",\"nodeType\":\"start\",\"nodeTypeExt\":\"\"},\"ports\":{\"groups\":{\"top\":{\"position\":\"top\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"right\":{\"position\":\"right\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"bottom\":{\"position\":\"bottom\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"left\":{\"position\":\"left\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}}},\"items\":[{\"group\":\"top\",\"id\":\"2ad6a8d5-d86d-49e6-908a-d317b61997c1\"},{\"group\":\"right\",\"id\":\"839cb2d9-59ca-4a39-a63c-26bf60cc6989\"},{\"group\":\"bottom\",\"id\":\"7048578f-94d9-4f75-b653-eb5f43ff55db\"},{\"group\":\"left\",\"id\":\"e7bb1134-4b4c-401d-89ea-e77ae24cbd03\"}]},\"zIndex\":3,\"labels\":[{\"attrs\":{\"body\":{\"stroke\":\"orange\"}}}]},{\"position\":{\"x\":-153,\"y\":-240},\"size\":{\"width\":60,\"height\":60},\"attrs\":{\"text\":{\"refY\":\"100%\",\"textVerticalAnchor\":\"top\",\"text\":\"switchRight\",\"style\":{\"color\":\"#080808\"},\"refY2\":4},\"image\":{\"xlink:href\":\"dist/img/switchRight.74768797.png\"},\"body\":{\"stroke\":\"#5F95FF\"}},\"visible\":true,\"shape\":\"image\",\"id\":\"6df9adc8-cb83-405c-8482-633db0f3644f\",\"data\":{\"dataId\":\"\",\"nodeType\":\"switchRight\",\"nodeTypeExt\":\"\"},\"ports\":{\"groups\":{\"top\":{\"position\":\"top\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"right\":{\"position\":\"right\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"bottom\":{\"position\":\"bottom\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"left\":{\"position\":\"left\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}}},\"items\":[{\"group\":\"top\",\"id\":\"adceedb7-f842-4d1e-be3a-8b3cb0a7e3ce\"},{\"group\":\"right\",\"id\":\"80d3bd61-1ed3-493a-b4e8-d4576e6fbfda\"},{\"group\":\"bottom\",\"id\":\"8fa84779-80b2-4c91-8366-7dd4fa0d93ff\"},{\"group\":\"left\",\"id\":\"f93ccd2f-dedd-47b1-9ad0-9be20c5db8a4\"}]},\"zIndex\":4},{\"position\":{\"x\":-21,\"y\":-240},\"size\":{\"width\":60,\"height\":60},\"attrs\":{\"text\":{\"refY\":\"100%\",\"textVerticalAnchor\":\"top\",\"text\":\"logo\",\"style\":{\"color\":\"#080808\"},\"refY2\":4},\"image\":{\"xlink:href\":\"dist/img/logo.36cbc06d.png\"},\"body\":{\"stroke\":\"#5F95FF\"},\"line\":{\"stroke\":\"orange\"}},\"visible\":true,\"shape\":\"image\",\"id\":\"da634b2e-5ffc-4e1b-a636-f86ace9eb082\",\"data\":{\"dataId\":\"123456\",\"nodeType\":\"node\",\"nodeTypeExt\":\"aaa\"},\"ports\":{\"groups\":{\"top\":{\"position\":\"top\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"right\":{\"position\":\"right\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"bottom\":{\"position\":\"bottom\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"left\":{\"position\":\"left\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}}},\"items\":[{\"group\":\"top\",\"id\":\"bc0336ec-7912-4720-aea7-e5869de77692\"},{\"group\":\"right\",\"id\":\"a977d555-b8c8-4578-9a8b-3097c405c1a8\"},{\"group\":\"bottom\",\"id\":\"fef0f533-9581-4831-ba65-427f097a3d17\"},{\"group\":\"left\",\"id\":\"01eb49d9-4b1c-466f-8263-935542436c7e\"}]},\"zIndex\":5,\"labels\":[{\"attrs\":{\"body\":{\"stroke\":\"orange\"}}}]},{\"position\":{\"x\":170,\"y\":-100},\"size\":{\"width\":60,\"height\":60},\"attrs\":{\"text\":{\"refY\":\"100%\",\"textVerticalAnchor\":\"top\",\"text\":\"end\",\"style\":{\"color\":\"#080808\"},\"refY2\":4},\"image\":{\"xlink:href\":\"dist/img/end.814a7041.png\"},\"body\":{\"stroke\":\"#5F95FF\"}},\"visible\":true,\"shape\":\"image\",\"id\":\"0bb2ba89-a92d-4b32-b3cd-45df2300fa34\",\"data\":{\"dataId\":\"\",\"nodeType\":\"end\",\"nodeTypeExt\":\"\"},\"ports\":{\"groups\":{\"top\":{\"position\":\"top\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"right\":{\"position\":\"right\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"bottom\":{\"position\":\"bottom\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"left\":{\"position\":\"left\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}}},\"items\":[{\"group\":\"top\",\"id\":\"223c9b3a-6baa-4bb8-99ba-c3300db9a942\"},{\"group\":\"right\",\"id\":\"2806bc8a-4e11-4657-9af9-089907985671\"},{\"group\":\"bottom\",\"id\":\"c56eed35-95fa-4e3c-adba-9847ef705e1c\"},{\"group\":\"left\",\"id\":\"61eaafd2-095b-41d6-8e34-862fb470b7a6\"}]},\"zIndex\":6},{\"position\":{\"x\":-350,\"y\":-54},\"size\":{\"width\":60,\"height\":60},\"attrs\":{\"text\":{\"refY\":\"100%\",\"textVerticalAnchor\":\"top\",\"text\":\"logo\",\"style\":{\"color\":\"#080808\"},\"refY2\":4},\"image\":{\"xlink:href\":\"dist/img/logo.36cbc06d.png\"},\"body\":{\"stroke\":\"#5F95FF\"}},\"visible\":true,\"shape\":\"image\",\"id\":\"2b6df966-4e19-4055-bb13-c4c083b18e58\",\"data\":{\"dataId\":\"123456\",\"nodeType\":\"node\",\"nodeTypeExt\":\"aaa\"},\"ports\":{\"groups\":{\"top\":{\"position\":\"top\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"right\":{\"position\":\"right\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"bottom\":{\"position\":\"bottom\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"left\":{\"position\":\"left\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}}},\"items\":[{\"group\":\"top\",\"id\":\"bc0336ec-7912-4720-aea7-e5869de77692\"},{\"group\":\"right\",\"id\":\"a977d555-b8c8-4578-9a8b-3097c405c1a8\"},{\"group\":\"bottom\",\"id\":\"fef0f533-9581-4831-ba65-427f097a3d17\"},{\"group\":\"left\",\"id\":\"01eb49d9-4b1c-466f-8263-935542436c7e\"}]},\"zIndex\":7},{\"position\":{\"x\":-330,\"y\":40},\"size\":{\"width\":60,\"height\":60},\"attrs\":{\"text\":{\"refY\":\"100%\",\"textVerticalAnchor\":\"top\",\"text\":\"logo\",\"style\":{\"color\":\"#080808\"},\"refY2\":4},\"image\":{\"xlink:href\":\"dist/img/logo.36cbc06d.png\"},\"body\":{\"stroke\":\"#5F95FF\"}},\"visible\":true,\"shape\":\"image\",\"id\":\"323f5abe-05ed-419d-9d81-d25c7d3b19f3\",\"data\":{\"dataId\":\"123456\",\"nodeType\":\"node\",\"nodeTypeExt\":\"aaa\"},\"ports\":{\"groups\":{\"top\":{\"position\":\"top\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"right\":{\"position\":\"right\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"bottom\":{\"position\":\"bottom\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"left\":{\"position\":\"left\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}}},\"items\":[{\"group\":\"top\",\"id\":\"bc0336ec-7912-4720-aea7-e5869de77692\"},{\"group\":\"right\",\"id\":\"a977d555-b8c8-4578-9a8b-3097c405c1a8\"},{\"group\":\"bottom\",\"id\":\"fef0f533-9581-4831-ba65-427f097a3d17\"},{\"group\":\"left\",\"id\":\"01eb49d9-4b1c-466f-8263-935542436c7e\"}]},\"zIndex\":8},{\"position\":{\"x\":-153,\"y\":-20},\"size\":{\"width\":60,\"height\":60},\"attrs\":{\"text\":{\"refY\":\"100%\",\"textVerticalAnchor\":\"top\",\"text\":\"logo\",\"style\":{\"color\":\"#080808\"},\"refY2\":4},\"image\":{\"xlink:href\":\"dist/img/logo.36cbc06d.png\"},\"body\":{\"stroke\":\"#5F95FF\"},\"line\":{\"stroke\":\"orange\"}},\"visible\":true,\"shape\":\"image\",\"id\":\"1f378f5e-066d-49bb-a6cc-de24a8882d65\",\"data\":{\"dataId\":\"123456\",\"nodeType\":\"node\",\"nodeTypeExt\":\"aaa\"},\"ports\":{\"groups\":{\"top\":{\"position\":\"top\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"right\":{\"position\":\"right\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"bottom\":{\"position\":\"bottom\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"left\":{\"position\":\"left\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}}},\"items\":[{\"group\":\"top\",\"id\":\"bc0336ec-7912-4720-aea7-e5869de77692\"},{\"group\":\"right\",\"id\":\"a977d555-b8c8-4578-9a8b-3097c405c1a8\"},{\"group\":\"bottom\",\"id\":\"fef0f533-9581-4831-ba65-427f097a3d17\"},{\"group\":\"left\",\"id\":\"01eb49d9-4b1c-466f-8263-935542436c7e\"}]},\"zIndex\":9,\"labels\":[{\"attrs\":{\"body\":{\"stroke\":\"orange\"}}}]}]}"; @@ -1201,31 +1949,6 @@ } return result; } - - private void saveModel(Long modelId, - List<ModelNode> modelNodeList, - List<ModelLine> modelLineList, - List<Algorithm> algoList, - List<ModelNode> modelNodeAndVnodeList) { - // 鍒犻櫎鏃㈡湁鏁版嵁 - modelNodeDao.deleteByModelId(modelId); - modelLineDao.deleteByModelId(modelId); - algorithmDao.deleteByModelId(modelId); - modelNodeAlgorithmDao.deleteByModelId(modelId); - - // 鎻掑叆鏁版嵁 - for (ModelNode modelNode : modelNodeList) { - modelNodeDao.insert(modelNode); - } - for (ModelLine modelLine : modelLineList) { - modelLineDao.insert(modelLine); - } - for (Algorithm algorithm : algoList) { - algorithmDao.insert(algorithm); - } - for (ModelNode modelNode : modelNodeAndVnodeList) { - modelNodeAlgorithmDao.insert(ModelNodeAlgorithm.from(modelNode)); - } - } +============瑙f瀽妯″瀷鐨勭1鐗堬紝宸蹭笉浣跨敤============ */ } -- Gitblit v1.9.1