private void RecursivelyConstructHierarchicalBOM(IBOMNode node, ModelBOM modelBom, IList<IBOMNode> allNodes, IList<ModelBOM> allModelBom, int iDeepLimit, int level, IDictionary<int, IList<IPart>> allPartList) { IList<ModelBOM> rootChildren = allModelBom.Where(x => x.Level == level && x.Material == modelBom.Component && x.Flag == 1).ToList(); if (rootChildren != null && rootChildren.Count > 0) { if (iDeepLimit == 0) { throw new FisException("BOML01", new string[] { "", "" }); } IList<IPart> nodePartList = null; if (allPartList.ContainsKey(level)) { nodePartList = allPartList[level]; } else { var partNoList = allModelBom.Where(x => x.Level == level && x.Flag == 1).Select(x => x.Component).Distinct().ToList(); nodePartList = PrtRepository.FindPart(partNoList); allPartList.Add(level, nodePartList); } foreach (ModelBOM childItem in rootChildren) { //IPart nodePart = PrtRepository.Find(childItem.Component); IPart nodePart = nodePartList.Where(x => x != null && x.PN == childItem.Component).FirstOrDefault(); if (nodePart != null) { IBOMNode newNode = new BOMNode(nodePart, int.Parse(childItem.Quantity), childItem.Alternative_item_group); node.AddChild(newNode); allNodes.Add(newNode); RecursivelyConstructHierarchicalBOM(newNode, childItem, allNodes, allModelBom, iDeepLimit - 1, level + 1, allPartList); } } } }
private IHierarchicalBOM GetHierarchicalBOMByModel_DB(string model) { try { IHierarchicalBOM ret = null; //IPart rootPart = PrtRepository.Find(model); IPart rootPart = null; IBOMNode root = new BOMNode(rootPart, 1); ret = new HierarchicalBOM(root); IDictionary<int, IList<IPart>> allPartList = new Dictionary<int, IList<IPart>>(); IList<IBOMNode> allNodes = new List<IBOMNode>(); ret.Nodes = allNodes; ret.Model = model; //IList<MoBOMInfo> rootChildren = GetChildrenInModelBOM(model); IList<ModelBOM> modelBOMList = GetModelBOM(model); var rootChildren = modelBOMList.Where(x => x.Level == 1 && x.Flag == 1).ToList(); if (rootChildren != null && rootChildren.Count > 0) { var partNoList = rootChildren.Select(x => x.Component).Distinct().ToList(); IList<IPart> rootPartList = PrtRepository.FindPart(partNoList); allPartList.Add(1, rootPartList); foreach (ModelBOM childItem in rootChildren) { //IPart nodePart = PrtRepository.Find(childItem.Component); IPart nodePart = rootPartList.Where(x => x != null && x.PN == childItem.Component).FirstOrDefault(); if (nodePart != null) { IBOMNode newNode = new BOMNode(nodePart, int.Parse(childItem.Quantity), childItem.Alternative_item_group); root.AddChild(newNode); allNodes.Add(newNode); int iDeepLimit = 20; try { RecursivelyConstructHierarchicalBOM(newNode, childItem, allNodes, modelBOMList, iDeepLimit - 1, 2, allPartList); } catch (FisException fex) { if (fex.mErrcode == "BOML01") { throw new FisException("BOML01", new string[] { iDeepLimit.ToString(), model }); } } } } } return ret; } catch (Exception) { throw; } }
public IList<IBOMNode> GetParentBomNodeByPnListAndBomNodeType(IList<string> pnList) { try { IList<IBOMNode> ret = null; IDictionary<string, IList<MoBOMInfo>> parents = GetChildrenInModelBOMReverse(pnList); if (parents != null) { ret = new List<IBOMNode>(); foreach (KeyValuePair<string, IList<MoBOMInfo>> kvp in parents) { IPart parentPart = PrtRepository.Find(kvp.Key); if (parentPart != null) { foreach(MoBOMInfo item in kvp.Value) { IBOMNode parentItem = new BOMNode(parentPart, int.Parse(item.quantity), item.alternative_item_group); IPart childPart = PrtRepository.Find(item.component); if (childPart != null) { IBOMNode childItem = new BOMNode(childPart, -1); parentItem.AddChild(childItem); } ret.Add(parentItem); } } } } return ret; } catch (Exception) { throw; } }
private void RecursivelyConstructHierarchicalBOM(IBOMNode node, MoBOMInfo peerInfo, IList<IBOMNode> allNodes, int iDeepLimit) { IList<MoBOMInfo> rootChildren = GetChildrenInModelBOM(peerInfo.component); if (rootChildren != null && rootChildren.Count > 0) { if (iDeepLimit == 0) { throw new FisException("BOML01", new string[] { "", "" }); } foreach (MoBOMInfo childItem in rootChildren) { IPart nodePart = PrtRepository.Find(childItem.component); if (nodePart != null) { IBOMNode newNode = new BOMNode(nodePart, int.Parse(childItem.quantity), childItem.alternative_item_group); node.AddChild(newNode); allNodes.Add(newNode); RecursivelyConstructHierarchicalBOM(newNode, childItem, allNodes, iDeepLimit - 1); } } } }
public IList<IBOMNode> GetParentBomNode(string pn) { try { IList<IBOMNode> ret = null; IList<MoBOMInfo> parents = GetChildrenInModelBOMReverse(pn); if (parents != null) { ret = new List<IBOMNode>(); foreach(MoBOMInfo parent in parents) { IPart parentPart = PrtRepository.Find(parent.material); if (parentPart != null) { IBOMNode parentItem = new BOMNode(parentPart, int.Parse(parent.quantity), parent.alternative_item_group); ret.Add(parentItem); } } } return ret; } catch (Exception) { throw; } }