| | |
| | | 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.DocumentHelper; |
| | | import org.dom4j.Document; |
| | | import org.dom4j.Element; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.zt.common.db.query.QueryFilter; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | modelRbdDao.insert(modelRbd); |
| | | } |
| | | |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void update(ModelRbd modelRbd) { |
| | | if (modelRbd==null) return; |
| | |
| | | |
| | | // 1. 解析出节点与边 |
| | | getNodeAndLineFromRbd(modelRbd.getId(), rbdJsonArray, modelNodeList, modelLineList, productImgList); |
| | | // 2. 计算所有节点的入口线数及出口线数 |
| | | // 2. 对于有多根入口线的产品节点,将其上的表决、旁联关系剥离成运算符节点,添加到该节点的前面,并添加相应的边 |
| | | peelOperationFromProductNode(modelRbd.getId(), modelNodeList, modelLineList); |
| | | // 3. 计算所有节点的入口线数及出口线数 |
| | | calcInOutLineNumAllNode(modelNodeList, modelLineList); |
| | | // 3. 复制产品节点(node)到list |
| | | // 4. 复制产品节点(node)到list |
| | | List<ModelNode> modelNodeAndVnodeList = modelNodeList.stream().filter(item -> |
| | | "node".equals(item.getNodeType())).collect(Collectors.toList()); |
| | | // 4. 不断将基本模型(串联、并联、旁联、表决、桥联)替换为虚节点而简化图形,直至无法简化为止。 |
| | | // 5. 不断将基本模型(串联、并联、旁联、表决、桥联)替换为虚节点而简化图形,直至无法简化为止。 |
| | | result = getAlgorithmFromRbd(modelRbd, modelNodeList, modelLineList, algorithmList, modelNodeAndVnodeList); |
| | | |
| | | // 5. 转换为算法库接口XML |
| | | // 6. 转换为算法库接口XML |
| | | if (result) { |
| | | result = createIfXmlFromRbd(modelRbd, algorithmList, modelNodeAndVnodeList); |
| | | // result = createIfXmlFromRbd(modelRbd, algorithmList, modelNodeAndVnodeList); |
| | | } |
| | | |
| | | // 6. 保存模型 |
| | | // 7. 保存模型 |
| | | if (saveFlag) saveModel(modelRbd, modelNodeList, modelLineList, algorithmList, modelNodeAndVnodeList); |
| | | |
| | | return result; |
| | | } |
| | | |
| | | private boolean createIfXmlFromRbd(ModelRbd modelRbd, |
| | | List<Algorithm> algorithmList, |
| | | List<ModelNode> modelNodeAndVnodeList) { |
| | | boolean result = true; |
| | | 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); |
| | | |
| | | try { |
| | | Document document = DocumentHelper.createDocument(); |
| | | // 添加root节点 |
| | | Element root = document.addElement("DES"); |
| | | root.addAttribute("Name", "A System"); |
| | | // 添加terminal节点到root1 |
| | | Element terminal = root.addElement("Node"); |
| | | terminal.addAttribute("Name", "Terminal"); |
| | | terminal.addAttribute("Type", "NODE"); |
| | | 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); |
| | | |
| | | // 将模型转换为DOM,添加到root |
| | | Algorithm endAlgo = algorithmList.stream().filter(item -> |
| | | "end".equals(item.getAlgorithmType())).collect(Collectors.toList()).get(0); |
| | | ModelNode computerNode = modelNodeAndVnodeList.stream().filter(item -> |
| | | endAlgo.getComputerList().equals(item.getId().toString())).collect(Collectors.toList()).get(0); |
| | | node2DOM(algorithmList, modelNodeAndVnodeList, computerNode, root); |
| | | |
| | | // 添加start节点到root |
| | | Element start = root.addElement("Node"); |
| | | start.addAttribute("Name", "Start"); |
| | | start.addAttribute("Type", "NODE"); |
| | | // 添加link(路径)到root |
| | | Element link = root.addElement("Link"); |
| | | Element block = link.addElement("Block"); |
| | | block.addAttribute("Name", "Terminal"); |
| | | block = link.addElement("Block"); |
| | | block.addAttribute("Name", computerNode.getId().toString()); |
| | | block = link.addElement("Block"); |
| | | block.addAttribute("Name", "Start"); |
| | | |
| | | document.setXMLEncoding("UTF-8"); |
| | | String xmlString = document.asXML(); |
| | | modelRbd.setIfXml(xmlString); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | result = false; |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | // 递归函数 |
| | | private void node2DOM(List<Algorithm> algorithmList, |
| | | List<ModelNode> modelNodeAndVnodeList, |
| | | ModelNode node, |
| | | Element parent) { |
| | | if ("node".equals(node.getNodeType())) { |
| | | Long dataId = node.getDataId(); |
| | | XhProductModel xhProductModel = xhProductModelDao.getById(dataId); |
| | | if (xhProductModel == null) return; |
| | | if ("1".equals(xhProductModel.getProductType())) { |
| | | // 设备 |
| | | ParamData paramData = paramDataDao.getParamData(dataId, "expect"); |
| | | if (paramData == null) return; |
| | | Element element = parent.addElement("Node"); |
| | | element.addAttribute("Name", dataId.toString()); |
| | | element.addAttribute("Type", "NODE"); |
| | | Element failureTag = element.addElement("Failure"); |
| | | failureTag.addAttribute("Dist", "EXP"); // TODO:需设为具体的分布 |
| | | Element argsTag = failureTag.addElement("Args"); |
| | | Double value = new Double(paramData.getTaskMtbcfRegulate()); |
| | | value = 1.0/value; |
| | | argsTag.addAttribute("value", value.toString()); |
| | | if (1==paramData.getRepairable()) { |
| | | Element repairTag = element.addElement("Repair"); |
| | | repairTag.addAttribute("Dist", "EXP"); // TODO:需设为具体的分布 |
| | | argsTag = repairTag.addElement("Args"); |
| | | value = new Double(paramData.getRepairMttcr()); |
| | | value = 1.0/value; |
| | | argsTag.addAttribute("value", value.toString()); |
| | | Element repairTimeLimitTag = element.addElement("RepairTimeLimit"); |
| | | repairTimeLimitTag.setText(paramData.getRepairMttcr()); |
| | | for(ModelLine line: inLineList){ |
| | | line.setEndCell(nodeNewId.toString()); |
| | | } |
| | | } else if ("10".equals(xhProductModel.getProductType())) { |
| | | // 虚单位 |
| | | ModelRbd rbdXDY = modelRbdDao.getDiagramOfXDY(dataId); |
| | | if (rbdXDY == null) return; |
| | | List<Algorithm> algorithmListXDY = algorithmDao.getListByModelId(rbdXDY.getId()); |
| | | List<ModelNode> modelNodeAndVnodeListXDY =modelNodeAlgorithmDao.getListByModelId(rbdXDY.getId()); |
| | | Algorithm endAlgo = algorithmListXDY.stream().filter(item -> |
| | | "end".equals(item.getAlgorithmType())).collect(Collectors.toList()).get(0); |
| | | ModelNode computerNode = modelNodeAndVnodeListXDY.stream().filter(item -> |
| | | endAlgo.getComputerList().equals(item.getId().toString())).collect(Collectors.toList()).get(0); |
| | | node2DOM(algorithmListXDY, modelNodeAndVnodeListXDY, computerNode, parent); |
| | | } |
| | | } else { |
| | | // vnode(运算节点) |
| | | Algorithm algo = algorithmList.stream().filter(item -> |
| | | node.getId().equals(item.getId())).collect(Collectors.toList()).get(0); |
| | | Element element = parent.addElement("Logic"); |
| | | element.addAttribute("Name", algo.getId().toString()); |
| | | if ("series".equals(algo.getAlgorithmType())) { |
| | | element.addAttribute("Type", "SERIES"); |
| | | } else if ("parallel".equals(algo.getAlgorithmType())) { |
| | | element.addAttribute("Type", "PARALLEL"); |
| | | } else if ("vote".equals(algo.getAlgorithmType())) { |
| | | element.addAttribute("Type", "VOTE"); |
| | | element.addAttribute("VoteValue", algo.getVoteNum().toString()); |
| | | } else if ("switch".equals(algo.getAlgorithmType())) { |
| | | element.addAttribute("Type", "STANDBY"); |
| | | } else if ("bridge".equals(algo.getAlgorithmType())) { |
| | | element.addAttribute("Type", "BRIDGE"); |
| | | } |
| | | String[] computerNodeListStr = algo.getComputerList().split(","); |
| | | for (String nodeStr : computerNodeListStr) { |
| | | ModelNode nd = modelNodeAndVnodeList.stream().filter(item -> |
| | | nodeStr.equals(item.getId().toString())).collect(Collectors.toList()).get(0); |
| | | node2DOM(algorithmList, modelNodeAndVnodeList, nd, element); |
| | | } |
| | | } |
| | | modelNodeList.addAll(nodesToAdd); |
| | | modelLineList.addAll(linesToAdd); |
| | | } |
| | | |
| | | private boolean getAlgorithmFromRbd(ModelRbd modelRbd, |
| | |
| | | do { |
| | | hasSimplified = false; |
| | | hasSimplified = simplifySeries(modelRbd.getId(), modelNodeList, modelLineList, algorithmList, modelNodeAndVnodeList, hasSimplified); |
| | | hasSimplified = simplifyParallel(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); |
| | |
| | | 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 -> |
| | |
| | | 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, |
| | |
| | | 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) { |
| | |
| | | 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 -> |
| | |
| | | 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); |
| | |
| | | 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); |
| | |
| | | algorithmList, modelNodeAndVnodeList, vnode, endNode, branchNodeList); |
| | | calcInOutLineNum(startNode, modelLineList); |
| | | } |
| | | */ |
| | | |
| | | return true; |
| | | } |
| | |
| | | } |
| | | |
| | | // 找出所有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); |
| | |
| | | List<ModelNode> modelNodeList, |
| | | 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(); |
| | |
| | | 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())); |
| | | Object voteNum = JsonUtils2.getJsonValueByPath(jsonObject, "data/voteNum".split("/")); |
| | | if (voteNum!=null && StringUtils.isNotBlank(voteNum.toString())) { |
| | | modelNode.setVoteNum(Integer.valueOf(voteNum.toString())); |
| | | jsonValue = JsonUtils2.getJsonValueByPath(jsonObject, "data/voteNum".split("/")); |
| | | if (jsonValue!=null && StringUtils.isNotBlank(jsonValue.toString())) { |
| | | modelNode.setVoteNum(Integer.valueOf(jsonValue.toString())); |
| | | } |
| | | if ("node".equals(modelNode.getNodeType())) { |
| | | 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)) { |
| | | Object obj = JsonUtils2.getJsonValueByPath(jsonObject, "data/reliabDistribType".split("/")); |
| | | if (obj != null && StringUtils.isNotBlank(obj.toString())) { |
| | | productImg.setReliabDistribType(Integer.valueOf(obj.toString())); |
| | | jsonValue = JsonUtils2.getJsonValueByPath(jsonObject, "data/reliabDistribType".split("/")); |
| | | if (jsonValue != null && StringUtils.isNotBlank(jsonValue.toString())) { |
| | | productImg.setReliabDistribType(Integer.valueOf(jsonValue.toString())); |
| | | } |
| | | productImg.setTaskMtbcf(JsonUtils2.getJsonValueByPath(jsonObject, "data/taskMtbcf".split("/")).toString()); |
| | | productImg.setTaskMtbcfOther(JsonUtils2.getJsonValueByPath(jsonObject, "data/taskMtbcfOther".split("/")).toString()); |
| | | obj = JsonUtils2.getJsonValueByPath(jsonObject, "data/isRepair".split("/")); |
| | | if (obj != null && StringUtils.isNotBlank(obj.toString())) { |
| | | productImg.setIsRepair(Integer.valueOf(obj.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()) { |
| | | obj = JsonUtils2.getJsonValueByPath(jsonObject, "data/repairDistribType".split("/")); |
| | | if (obj != null && StringUtils.isNotBlank(obj.toString())) { |
| | | productImg.setRepairDistribType(Integer.valueOf(obj.toString())); |
| | | jsonValue = JsonUtils2.getJsonValueByPath(jsonObject, "data/repairDistribType".split("/")); |
| | | if (jsonValue != null && StringUtils.isNotBlank(jsonValue.toString())) { |
| | | productImg.setRepairDistribType(Integer.valueOf(jsonValue.toString())); |
| | | } |
| | | productImg.setRepairMttcr(JsonUtils2.getJsonValueByPath(jsonObject, "data/repairMttcr".split("/")).toString()); |
| | | productImg.setRepairMttcrOther(JsonUtils2.getJsonValueByPath(jsonObject, "data/repairMttcrOther".split("/")).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); |
| | |
| | | } |
| | | |
| | | // 更新RBD数据 |
| | | modelRbd.setPublishedContent(modelRbd.getContent()); |
| | | modelRbdDao.updateById(modelRbd); |
| | | } |
| | | |