示例#1
0
文件: Filter.cs 项目: wra222/testgit
 /// <summary>
 ///bom节点Part的Descr描述为Descr为( 'JGS')
 ///bom节点Part的PartInfo中的Descr描述为( 'TPCB')
 ///bom节点Part的PartInfo中的Upper(VCDescr)包含('VIRTUAL')
 /// </summary>
 /// <param name="bomNode"></param>
 /// <returns></returns>
 private bool IsVirtualTPCB(IBOMNode bomNode)
 {
     if (bomNode == null)
     {
         return false;
     }
     IPart part = bomNode.Part;
     if (part == null)
     {
         return false;
     }
     if (string.Compare(part.Descr, "JGS") != 0)
     {
         return false;
     }
     string descrAttribute = part.GetAttribute("Descr");
     if (string.Compare(descrAttribute, "TPCB") != 0 && descrAttribute.IndexOf("KITK")!=0)
     {
         return false;
     }
     string vcdescrAttribute = part.GetAttribute("VCDescr");
     if (string.IsNullOrEmpty(vcdescrAttribute) 
         || !vcdescrAttribute.ToUpper().Contains("VIRTUAL"))
     {
         return false;
     }
     return true;
 }
示例#2
0
文件: Filter.cs 项目: wra222/testgit
 public bool VendorCodeExists(IBOMNode node)
 {
     if (((BOMNode)node).Part != null)
     {
         string vendorCode = ((BOMNode)node).Part.GetAttribute(VendorCodeAttributeName);
         if (!string.IsNullOrEmpty(vendorCode))
         {
             return true;
         }
     }
     return false;
 }
示例#3
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="nodes"></param>
 /// <param name="e_node"></param>
 private void remove(IList<IBOMNode> nodes,IBOMNode e_node)
 {
     if (nodes != null && e_node.Part != null && nodes.Count > 0)
     {
         foreach (var node in nodes)
         {
             if (node.Part != null && node.Part.PN.Trim().Equals(e_node.Part.PN))
             {
                 nodes.Remove(node);
                 break;
             }
         }
     }
 }
示例#4
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="nodes"></param>
 /// <param name="e_node"></param>
 /// <returns></returns>
 private Boolean contains(IList<IBOMNode> nodes,IBOMNode e_node)
 {
     if (nodes != null && e_node.Part != null && nodes.Count > 0)
     {
         foreach (var node in nodes)
         {
             if (node.Part != null && node.Part.PN.Trim().Equals(e_node.Part.PN))
             {
                 return true;
             }
         }
     }
     return false;
 }
示例#5
0
        /// <summary>
        /// BOMNode树的遍历,得到所需的BOMNode列表。
        /// </summary>
        /// <param name="node">遍历的开始节点</param>
        /// <param name="search_path">遍历的指定路径。以BOMNodeType为路径节点,用“->”将它们彼此隔开。</param>
        /// <param name="search_node_type">以给定的BOMNodeType收集BOMNode。</param>
        /// <param name="check_condition"></param>
        /// <param name="check_type"></param>
        /// <returns></returns>
        public IList<QtyParts> BreadthFirstTraversalForHD(IBOMNode node, string search_path, string search_node_type, ITreeTraversal check_condition, string check_type)
        {
            List<IBOMNode> collect_gather_node = new List<IBOMNode>();
            List<QtyParts> ret = new List<QtyParts>();
            Queue<IBOMNode> bom_node_queue = new Queue<IBOMNode>(30);
            try
            {
                if (string.IsNullOrEmpty(search_path))
                {
                    throw new FisException("CHK169", new string[] { "IMES.CheckItemModule.Utility.TreeTraversal.BreadthFirstTraversal" });
                }
                else
                {
                    if (!string.IsNullOrEmpty(search_node_type.Trim()) && search_path.Contains(search_node_type.Trim()))
                    {
                        IBOMNode bom_node = node;
                        string[] trave_path = parse_paths(search_path);
                        //if (bom_node.Part.BOMNodeType.Trim().Equals(trave_path[bom_node.Level].Trim()))//由于Root.part为空,所以暂时去掉该句。
                        if (bom_node != null)
                        {
                            bom_node_queue.Enqueue(node);
                            IBOMNode queue_node;
                            //int obtain_depth = toDepth(trave_path, search_node_type);
                            int search_depth = trave_path.Length;

                            while (bom_node_queue.Count > 0)
                            {
                                queue_node = bom_node_queue.Dequeue();
 
                                if (queue_node.Children != null && queue_node.Children.Count > 0)
                                {
                                    int offset = 1;

                                    for (int i = 0; i < queue_node.Children.Count; i++)
                                    {
                                        bom_node = queue_node.Children.ElementAt(i);
                                        if (bom_node.Part.BOMNodeType.Trim().Equals(trave_path[bom_node.Level - offset].Trim()) && bom_node.Level <= search_depth)
                                        {
                                            if (string.IsNullOrEmpty(check_type))
                                            {
                                                bom_node_queue.Enqueue(bom_node);
                                                if (bom_node.Part != null && bom_node.Part.BOMNodeType.Trim().Equals(search_node_type.Trim()))
                                                {
                                                    if (check_condition.CheckCondition(bom_node))
                                                    {
                                                        collect_gather_node.Add(bom_node);
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                int check_level = toDepth(trave_path, check_type);
                                                if (bom_node.Level == check_level && bom_node.Part.BOMNodeType.Trim().Equals(check_type))
                                                {
                                                    if (check_condition.CheckCondition(bom_node))
                                                    {
                                                        bom_node_queue.Enqueue(bom_node);
                                                    }
                                                }
                                                else
                                                {
                                                    bom_node_queue.Enqueue(bom_node);

                                                }
                                                if (bom_node.Part != null && bom_node.Part.BOMNodeType.Trim().Equals(search_node_type.Trim()))
                                                {
                                                    if (bom_node.Level == 1)
                                                    {
                                                        if (bom_node.Part.BOMNodeType.Trim().Equals(check_type))
                                                        {
                                                            if (check_condition.CheckCondition(bom_node))
                                                            {
                                                                collect_gather_node.Add(bom_node);
                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        collect_gather_node.Add(bom_node);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    if (queue_node.Level == search_depth)
                                    {
                                        int check_level = toDepth(trave_path, check_type);
                                        if (queue_node.Part != null && queue_node.Level == check_level && queue_node.Part.BOMNodeType.Trim().Equals(check_type))
                                        {
                                            if (check_condition.CheckCondition(queue_node))
                                            {
                                                if (queue_node.Part.BOMNodeType.Trim().Equals(search_node_type.Trim()))
                                                {
                                                    if (!collect_gather_node.Contains(queue_node))
                                                    {
                                                        collect_gather_node.Add(queue_node);
                                                    }
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (queue_node.Part != null && queue_node.Part.BOMNodeType.Trim().Equals(search_node_type.Trim()))
                                            {
                                                if (!collect_gather_node.Contains(queue_node))
                                                {
                                                    collect_gather_node.Add(queue_node);
                                                }
                                            }
                                        }
                                    }
                                    if (queue_node.Level < search_depth)
                                    {
                                        IBOMNode parent_node = queue_node;
                                        while (parent_node != null)
                                        {
                                            if (contains(collect_gather_node, parent_node))
                                            {
                                                remove(collect_gather_node, parent_node);
                                            }
                                            parent_node = parent_node.Parent;
                                        }
                                    }
                                }
                            }
                            Hashtable identical_vendor_code = new Hashtable();
                            for (int j = 0; j < collect_gather_node.Count(); j++)
                            {
                                bom_node = collect_gather_node.ElementAt(j);
                                bom_node_queue.Enqueue(bom_node);
                                BOMNode tmp = (BOMNode)bom_node;
                                int qty = 0;
                                string parent_descr = "";
                                string current_descr = "";
                                string vendor_code = "";
                                if (bom_node.Part.BOMNodeType.Trim().Equals(search_node_type))
                                {
//                                    qty = bom_node.Qty;
                                    qty = 1;
                                    current_descr = bom_node.Part.Descr;
                                    IList<PartInfo> part_infos = bom_node.Part.Attributes;
                                    if (part_infos != null)
                                    {
                                        foreach (PartInfo part_info in part_infos)
                                        {
                                            if (part_info.InfoType.Equals("VendorCode"))
                                            {
                                                vendor_code = part_info.InfoValue;
                                                break;
                                            }
                                        }
                                    }
                                }
                                do
                                {
                                    if (tmp.Parent != null)
                                    {
                                        int search_node_level = toDepth(trave_path, search_node_type);

                                        tmp = (BOMNode)tmp.Parent;
                                        
                                        if (tmp.Part != null && tmp.Part.BOMNodeType.Trim().Equals(search_node_type))
                                        {
                                            qty = tmp.Qty;
                                            parent_descr = tmp.Part.Descr;
                                        }
                                        else
                                        {
                                            if (tmp.Level < search_node_level)
                                            {
                                                qty *= tmp.Qty;
                                                parent_descr = tmp.Part.Descr;
                                            }
                                        }

                                    }
                                } while (tmp.Level != 1);
//                                string identical_vendor_code_key = parent_descr + current_descr + vendor_code;
                                string identical_vendor_code_key = current_descr + vendor_code;
                                if (identical_vendor_code.ContainsKey(identical_vendor_code_key))
                                {
                                    ((QtyParts) identical_vendor_code[identical_vendor_code_key]).Qty += qty;
                                }
                                else
                                {
                                    List<IPart> parts = new List<IPart>();
                                    parts.Add(bom_node.Part);
                                    QtyParts qty_parts = new QtyParts(qty, parts);
                                    identical_vendor_code.Add(identical_vendor_code_key, qty_parts);
                                }
//                                List<IPart> parts = new List<IPart>();
//                                parts.Add(bom_node.Part);
//                                QtyParts bom_item = new QtyParts(qty, parts);
//                                ret.Add(bom_item);
                            }
                            if (identical_vendor_code.Count > 0)
                            {
                                foreach (DictionaryEntry de in identical_vendor_code)
                                {
                                    ret.Add((QtyParts)de.Value);
                                }
                            }
                        }
                    }
                    else
                    {
                        string[] param = {
                                    "IMES.CheckItemModule.Utility.BreadthFirstTraversal",
                                    "search_node"
                                 };
                        throw new FisException("CHK156", param);
                    }

                }
            }
            catch (Exception e)
            {
                throw;
            }
            if (collect_gather_node.Count > 0)
                return ret;
            else
                return null;
        }
示例#6
0
        /// <summary>
        /// BOMNode树的遍历,得到所需的BOMNode列表。
        /// </summary>
        /// <param name="node">遍历的开始节点</param>
        /// <param name="search_path">遍历的指定路径。以BOMNodeType为路径节点,用“->”将它们彼此隔开。</param>
        /// <param name="search_node_type">以给定的BOMNodeType收集BOMNode。</param>
        /// <param name="check_condition"></param>
        /// <param name="check_type"></param>
        /// <returns></returns>
        public IList<QtyParts> BreadthFirstTraversal(IBOMNode node, string search_path, string search_node_type, ITreeTraversal check_condition,string check_type)
        {
            List<IBOMNode> collect_gather_node = new List<IBOMNode>();
            List<QtyParts> ret = new List<QtyParts>();
            Queue<IBOMNode> bom_node_queue = new Queue<IBOMNode>(30);
            try
            {
                if (string.IsNullOrEmpty(search_path))
                {
                    throw new FisException("CHK169", new string[] { "IMES.CheckItemModule.Utility.TreeTraversal.BreadthFirstTraversal" });
                }
                else
                {
                    if (!string.IsNullOrEmpty(search_node_type.Trim()) && search_path.Contains(search_node_type.Trim()))
                    {
                        IBOMNode bom_node = node;
                        string[] trave_path = parse_paths(search_path);
                        //if (bom_node.Part.BOMNodeType.Trim().Equals(trave_path[bom_node.Level].Trim()))//由于Root.part为空,所以暂时去掉该句。
                        if (bom_node != null)
                        {
                            bom_node_queue.Enqueue(node);
                            IBOMNode queue_node;
                            //int obtain_depth = toDepth(trave_path, search_node_type);
                            int search_depth = trave_path.Length;

                            while (bom_node_queue.Count > 0)
                            {
                                queue_node = bom_node_queue.Dequeue();
                                //if (queue_node.IsRoot && queue_node.Level == 0)
                                //{
                                //    if (queue_node.Part == null)    //Root 为Model
                                //    {
                                //        if (queue_node.Children != null)
                                //        {
                                //            for (int i = 0; i < queue_node.Children.Count; i++)
                                //            {
                                //                bom_node = queue_node.Children.ElementAt(i);
                                //                if (bom_node.Part.BOMNodeType.Trim().Equals(trave_path[bom_node.Level - 1].Trim()) && bom_node.Level <= search_depth)
                                //                {
                                //                    if (string.IsNullOrEmpty(check_type))
                                //                    {
                                //                        bom_node_queue.Enqueue(bom_node);
                                //                        if (bom_node.Part != null && bom_node.Part.BOMNodeType.Trim().Equals(search_node_type.Trim()))
                                //                        {
                                //                            if (check_condition.CheckCondition(bom_node))
                                //                            {
                                //                                collect_gather_node.Add(bom_node);
                                //                            }
                                //                        }
                                //                    }
                                //                    else
                                //                    {
                                //                        if (b)
                                //                        {
                                                            
                                //                        }
                                //                        bom_node_queue.Enqueue(bom_node);
                                //                        if (bom_node.Part != null && bom_node.Part.BOMNodeType.Trim().Equals(search_node_type.Trim()))
                                //                        {
                                //                            if (check_condition.CheckCondition(bom_node))
                                //                            {
                                //                                collect_gather_node.Add(bom_node);
                                //                            }
                                //                        }
                                //                    }

                                //                }
                                //            }
                                //        }
                                //    }

                                //}
                                //else
                                //{
                                    if (queue_node.Children != null && queue_node.Children.Count > 0)
                                    {
                                        int offset = 1;
                                        //if (node.IsRoot && node.Part != null)
                                        //{
                                        //    offset = 0;
                                        //    search_depth -= 1;
                                        //}
                                        for (int i = 0; i < queue_node.Children.Count; i++)
                                        {
                                            bom_node = queue_node.Children.ElementAt(i);
                                            if (bom_node.Part.BOMNodeType.Trim().Equals(trave_path[bom_node.Level - offset].Trim()) && bom_node.Level <= search_depth)
                                            {
                                                if (string.IsNullOrEmpty(check_type))
                                                {
                                                    bom_node_queue.Enqueue(bom_node);
                                                    if (bom_node.Part != null && bom_node.Part.BOMNodeType.Trim().Equals(search_node_type.Trim()))
                                                    {
                                                        if (check_condition.CheckCondition(bom_node))
                                                        {
                                                            collect_gather_node.Add(bom_node);
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    int check_level = toDepth(trave_path, check_type);
                                                    if (bom_node.Level == check_level && bom_node.Part.BOMNodeType.Trim().Equals(check_type))
                                                    {
                                                        if (check_condition.CheckCondition(bom_node))
                                                        {
                                                            bom_node_queue.Enqueue(bom_node);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        bom_node_queue.Enqueue(bom_node);

                                                    }
                                                    if (bom_node.Part != null && bom_node.Part.BOMNodeType.Trim().Equals(search_node_type.Trim()))
                                                    {
                                                        if (bom_node.Level == 1)
                                                        {
                                                            if(bom_node.Part.BOMNodeType.Trim().Equals(check_type))
                                                            {
                                                                if (check_condition.CheckCondition(bom_node))
                                                                {
                                                                    collect_gather_node.Add(bom_node);
                                                                }
                                                            }
                                                        }
                                                        else
                                                        {
                                                            collect_gather_node.Add(bom_node);
                                                        }
                                                    }
                                                }
                                            }
                                            //else
                                            //{
                                            //    if (contains(collect_gather_node,queue_node))   //不满足路径要求的,当阶删除。
                                            //    {
                                            //        remove(collect_gather_node,queue_node);
                                            //    }
                                            //    else
                                            //    {
                                            //        if (queue_node.Level > 0 && queue_node.Parent != null)  //不满足路径要求的,父阶删除。
                                            //        {
                                            //            IBOMNode parent_node = queue_node.Parent;
                                            //            while(parent_node != null)
                                            //            {
                                            //                if (contains(collect_gather_node,parent_node))
                                            //                {
                                            //                    remove( collect_gather_node,parent_node);
                                            //                }
                                            //                parent_node = parent_node.Parent;
                                            //            }
                                            //        }
                                                    
                                            //    }
                                            //}
                                        }
                                    }
                                    else
                                    {
                                        if (queue_node.Level == search_depth)
                                        {
                                            int check_level = toDepth(trave_path, check_type);
                                            if (queue_node.Part != null && queue_node.Level == check_level && queue_node.Part.BOMNodeType.Trim().Equals(check_type))
                                            {
                                                if (check_condition.CheckCondition(queue_node))
                                                {
                                                    if (queue_node.Part.BOMNodeType.Trim().Equals(search_node_type.Trim()))
                                                    {
                                                        if (!collect_gather_node.Contains(queue_node))
                                                        {
                                                            collect_gather_node.Add(queue_node);
                                                        }
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                if (queue_node.Part != null && queue_node.Part.BOMNodeType.Trim().Equals(search_node_type.Trim()))
                                                {
                                                    if (!collect_gather_node.Contains(queue_node))
                                                    {
                                                        collect_gather_node.Add(queue_node);
                                                    }
                                                }
                                            }
                                        }
                                        if (queue_node.Level < search_depth)
                                        {
                                            IBOMNode parent_node = queue_node;
                                            while(parent_node != null)
                                            {
                                                if (contains(collect_gather_node, parent_node))
                                                {
                                                    remove(collect_gather_node, parent_node);
                                                }
                                                parent_node = parent_node.Parent;
                                            }
                                        }
                                    }
                                //}
 
                                //remove the first node from queue
                                //queue_node = 
                                //bom_node_queue.Dequeue();

                                //if (queue_node.Part != null && queue_node.Part.BOMNodeType.Trim().Equals(search_node_type.Trim()))
                                //{
                                //    if (check_condition.CheckCondition(queue_node))
                                //    {
                                //        collect_gather_node.Add(queue_node);
                                //    }
                                //}
                            }

                            //if (bom_node.Part != null && bom_node.Part.BOMNodeType.Trim().Equals(search_node_type.Trim()))
                            //{
                            //List<IBOMNode> collect_gather_node_temp = new List<IBOMNode>();
                            //foreach (IBOMNode collect_node in collect_gather_node)
                            //{
                            //    if (!collect_node.Part.BOMNodeType.Trim().Equals(search_node_type.Trim()) || !check_condition.CheckCondition(collect_node))
                            //    {
                            //        //collect_gather_node.Add(bom_node);
                            //        collect_gather_node_temp.Add(collect_node);
                            //    }
                            //}
                            //foreach (IBOMNode bom_node_temp in collect_gather_node_temp)
                            //{
                            //    collect_gather_node.Remove(bom_node_temp);
                            //}
                            //}


                            for (int j = 0; j < collect_gather_node.Count(); j++)
                            {
                                bom_node = collect_gather_node.ElementAt(j);
                                //Part part = new Part(bom_node.Part.PN,bom_node.Part.BOMNodeType,bom_node.Part.Type,bom_node.Part.CustPn,bom_node.Part.Descr,
                                //    bom_node.Part.Remark,bom_node.Part.AutoDL,bom_node.Part.Editor,bom_node.Part.Cdt,bom_node.Part.Udt,bom_node.Part.Descr2);
                                //foreach (PartInfo info in bom_node.Part.Attributes)
                                //{
                                //    part.AddAttribute(info);
                                //}

                                bom_node_queue.Enqueue(bom_node);
                                BOMNode tmp = (BOMNode)bom_node;
                                int qty = 0;
                                if (bom_node.Part.BOMNodeType.Trim().Equals(search_node_type))
                                {
                                    qty = bom_node.Qty;
                                }
                                do
                                {
                                    if (tmp.Parent != null)
                                    {
                                        int search_node_level = toDepth(trave_path, search_node_type);

                                        tmp = (BOMNode)tmp.Parent;
                                        if (tmp.Part.BOMNodeType.Trim().Equals(search_node_type))
                                        {
                                            qty = tmp.Qty;
                                        }
                                        else
                                        {
                                            if (tmp.Level < search_node_level )
                                            {
                                                qty *= tmp.Qty;
                                            }
                                        }
                                        
                                    }
                                } while (tmp.Level != 1);

                                //if (bom_node.Children.Count > 0)
                                //{
                                //    qty *= ((BOMNode)bom_node.Children.ElementAt(0)).Qty;
                                //}

                                //while (bom_node_queue.Count > 0)
                                //{
                                //    queue_node = bom_node_queue.Peek();
                                //    for (int i = 0; i < queue_node.Children.Count; i++)
                                //    {
                                //        bom_node = queue_node.Children.ElementAt(i);
                                //        if (((BOMNode)node).Part == null)
                                //        {
                                //            if (bom_node.Part.BOMNodeType.Trim().Equals(trave_path[bom_node.Level - 1].Trim()))
                                //            {
                                //                bom_node_queue.Enqueue(bom_node);
                                //            }
                                //        }
                                //        else
                                //        {
                                //            if (bom_node.Part.BOMNodeType.Trim().Equals(trave_path[bom_node.Level].Trim()))
                                //            {
                                //                bom_node_queue.Enqueue(bom_node);
                                //            }
                                //        }
                                //    }
                                //    queue_node = bom_node_queue.Dequeue();
                                //    if (queue_node.Part.BOMNodeType.Trim().Equals(search_node_type.Trim()))
                                //    {
                                //        if (check_condition.CheckCondition(queue_node))
                                //        {
                                //            foreach (PartInfo attr in queue_node.Part.Attributes)
                                //                part.AddAttribute(attr);
                                //        }
                                //    }
                                ////}
                                List<IPart> parts = new List<IPart>();
                                parts.Add(bom_node.Part);
                                QtyParts bom_item = new QtyParts(qty, parts);
                                ret.Add(bom_item);
                            }
                        }
                    }
                    else
                    {
                        string[] param = {
                                    "IMES.CheckItemModule.Utility.BreadthFirstTraversal",
                                    "search_node"
                                 };
                        throw new FisException("CHK156", param);
                    }

                }
            }
            catch (Exception e)
            {
                throw;
            }
            if (collect_gather_node.Count > 0)
                return ret;
            else
                return null;
        }
示例#7
0
        /// <summary>
 /// BOMNode树的遍历,得到所需的BOMNode列表。
 /// </summary>
 /// <param name="node">遍历的开始节点</param>
 /// <param name="search_path">遍历的指定路径。以BOMNodeType为路径节点,用“->”将它们彼此隔开。</param>
 /// <param name="search_node_type">以给定的BOMNodeType收集BOMNode。</param>
 /// <param name="check_condition"></param>
 /// <param name="check_type"></param>
 /// <returns></returns>
 public IList<QtyParts> BreadthFirstTraversal(IBOMNode node, string search_path, string search_node_type, ITreeTraversal check_condition)
 {
    return BreadthFirstTraversal(node, search_path, search_node_type, check_condition, string.Empty);
 }
示例#8
0
        //FA代码已经稳定,所以加此函数供PAK使用。等PAK稳定后,再考虑代码合并。
        public IList<QtyParts> BreadthFirstTraversal(String part_no_filter_str,IBOMNode node, string search_path, string search_node_type, ITreeTraversal check_condition,string check_type)
        {
            List<IBOMNode> collect_gather_node = new List<IBOMNode>();
            List<QtyParts> ret = new List<QtyParts>();
            Queue<IBOMNode> bom_node_queue = new Queue<IBOMNode>(30);
            try
            {
                if (string.IsNullOrEmpty(search_path))
                {
                    throw new FisException("CHK169", new string[] { "IMES.CheckItemModule.Utility.TreeTraversal.BreadthFirstTraversal" });
                }
                else
                {
                    if (!string.IsNullOrEmpty(search_node_type.Trim()) && search_path.Contains(search_node_type.Trim()))
                    {
                        IBOMNode bom_node = node;
                        string[] trave_path = parse_paths(search_path);
                        if (bom_node != null)
                        {
                            bom_node_queue.Enqueue(node);
                            IBOMNode queue_node;
                            int search_depth = trave_path.Length;

                            while (bom_node_queue.Count > 0)
                            {
                                queue_node = bom_node_queue.Dequeue();
                                if (queue_node.Children != null && queue_node.Children.Count > 0)
                                {
                                    int offset = 1;
                                    for (int i = 0; i < queue_node.Children.Count; i++)
                                    {
                                        bom_node = queue_node.Children.ElementAt(i);
                                        if (bom_node.Part.BOMNodeType.Trim().Equals(trave_path[bom_node.Level - offset].Trim()) && bom_node.Level <= search_depth)
                                        {
                                            if (string.IsNullOrEmpty(check_type))
                                            {
                                                bom_node_queue.Enqueue(bom_node);
                                                if (bom_node.Part != null && bom_node.Part.BOMNodeType.Trim().Equals(search_node_type.Trim()))
                                                {
                                                    if (!string.IsNullOrEmpty(part_no_filter_str))
                                                    {
                                                        if (!bom_node.Part.PN.Trim().Substring(0, 3).Equals(part_no_filter_str.Trim()))
                                                        {
                                                            if (check_condition.CheckCondition(bom_node))
                                                            {
                                                                collect_gather_node.Add(bom_node);
                                                            }
                                                        }
                                                    }
                                                    else     //使用不需要PartNo过滤的情况
                                                    {
                                                        if (check_condition.CheckCondition(bom_node))
                                                        {
                                                            collect_gather_node.Add(bom_node);
                                                        }
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                int check_level = toDepth(trave_path, check_type);
                                                if (bom_node.Level == check_level && bom_node.Part.BOMNodeType.Trim().Equals(check_type))
                                                {
                                                    if (!string.IsNullOrEmpty(part_no_filter_str))
                                                    {
                                                        if (!bom_node.Part.PN.Trim().Substring(0, 3).Equals(part_no_filter_str.Trim()))
                                                        {
                                                            if (check_condition.CheckCondition(bom_node))
                                                            {
                                                                bom_node_queue.Enqueue(bom_node);
                                                            }
                                                        }
                                                    }
                                                    else   //使用不需要PartNo过滤的情况
                                                    {
                                                        if (check_condition.CheckCondition(bom_node))
                                                        {
                                                            bom_node_queue.Enqueue(bom_node);
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    bom_node_queue.Enqueue(bom_node);

                                                }
                                                if (bom_node.Part != null && bom_node.Part.BOMNodeType.Trim().Equals(search_node_type.Trim()))
                                                {
                                                    collect_gather_node.Add(bom_node);
                                                }

                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    if (queue_node.Level == search_depth)
                                    {
                                        String check_type_str = "";
                                        if (string.IsNullOrEmpty(check_type))
                                        {
                                            check_type_str =search_node_type.Trim();
                                        }
                                        else
                                        {
                                            check_type_str = check_type;
                                        }
                                        int check_level = toDepth(trave_path, check_type_str);
                                        if (queue_node.Part != null && queue_node.Level == check_level && queue_node.Part.BOMNodeType.Trim().Equals(check_type_str))
                                        {
                                            if (check_condition.CheckCondition(queue_node))
                                            {
                                                if (queue_node.Part.BOMNodeType.Trim().Equals(search_node_type.Trim()))
                                                {
                                                    if (!string.IsNullOrEmpty(part_no_filter_str))
                                                    {
                                                        if (!queue_node.Part.PN.Trim().Substring(0, 3).Equals(part_no_filter_str.Trim()))
                                                        {
                                                            if (!collect_gather_node.Contains(queue_node))
                                                            {
                                                                collect_gather_node.Add(queue_node);
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (queue_node.Part != null && queue_node.Part.BOMNodeType.Trim().Equals(search_node_type.Trim()))
                                            {
                                                if (!string.IsNullOrEmpty(part_no_filter_str))
                                                {
                                                    if (!queue_node.Part.PN.Trim().Substring(0, 3).Equals(part_no_filter_str.Trim()))
                                                    {
                                                        if (!collect_gather_node.Contains(queue_node))
                                                        {
                                                            collect_gather_node.Add(queue_node);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    if (queue_node.Level < search_depth)
                                    {
                                        IBOMNode parent_node = queue_node;
                                        while (parent_node != null)
                                        {
                                            if (contains(collect_gather_node, parent_node))
                                            {
                                                remove(collect_gather_node, parent_node);
                                            }
                                            parent_node = parent_node.Parent;
                                        }
                                    }
                                }
                            }

                            for (int j = 0; j < collect_gather_node.Count(); j++)
                            {
                                bom_node = collect_gather_node.ElementAt(j);

                                bom_node_queue.Enqueue(bom_node);
                                BOMNode tmp = (BOMNode)bom_node;

                                int qty = bom_node.Qty;
                                do
                                {
                                    if (tmp.Parent != null)
                                    {
                                        tmp = (BOMNode)tmp.Parent;
                                        qty *= tmp.Qty;
                                    }

                                } while (tmp.Level != node.Level);
                                //Packing Pizza 特例

                                if (bom_node.Children != null && bom_node.Children.Count > 0)
                                {
                                    qty *= ((BOMNode)bom_node.Children.ElementAt(0)).Qty;
                                }

//                                int qty = 0;
//                                if (bom_node.Part.BOMNodeType.Trim().Equals(search_node_type))
//                                {
//                                    qty = bom_node.Qty;
//                                }
//                                tmp = (BOMNode)bom_node;
//                                do
//                                {
//                                    if (tmp.Parent != null)
//                                    {
//                                        int search_node_level = toDepth(trave_path, search_node_type);
//
//                                        tmp = (BOMNode)tmp.Parent;
//                                        if (tmp.Part.BOMNodeType.Trim().Equals(search_node_type))
//                                        {
//                                            qty = tmp.Qty;
//                                        }
//                                        else
//                                        {
//                                            if (tmp.Level < search_node_level)
//                                            {
//                                                qty *= tmp.Qty;
//                                            }
//                                        }
//
//                                    }
//                                } while (tmp.Level != 1);

                                List<IPart> parts = new List<IPart>();
                                parts.Add(bom_node.Part);
                                QtyParts bom_item = new QtyParts(qty, parts);
                                ret.Add(bom_item);
                            }
                        }
                    }
                    else
                    {
                        string[] param = {
                                    "IMES.CheckItemModule.Utility.BreadthFirstTraversal",
                                    "search_node"
                                 };
                        throw new FisException("CHK156", param);
                    }

                }
            }
            catch (Exception e)
            {
                throw;
            }
            if (collect_gather_node.Count > 0)
                return ret;
            else
                return null;

        }
示例#9
0
 public IList<QtyParts> BreadthFirstTraversal(String part_no_filter_str,IBOMNode node, string search_path, string search_node_type, ITreeTraversal check_condition)
 {
     return BreadthFirstTraversal(part_no_filter_str,node,search_path,search_node_type,check_condition,null);
 }
示例#10
0
 public HierarchicalBOM(IBOMNode root)
 {
     _root = root;
 }
示例#11
0
 /// <summary>
  /// 展下階BOM規則根據輸入參數
 /// </summary>
 /// <param name="bomNodeTypeRule">PL->KP</param>
 /// <param name="partType">最後階PartType條件</param>
  /// <param name="partDescr">最後階PartDescr條件</param>
  /// <param name="partNo">最後階PartNo條件</param>
 /// <param name="parentBomNode">上階BomNode</param>
 /// <returns></returns>
  public static IList<IBOMNode> GetNextBom(string bomNodeTypeRule,
                                                                      string partType,
                                                                      string partDescr,
                                                                      string partNo,                            
                                                                      IBOMNode parentBomNode)
  {
      int index = bomNodeTypeRule.IndexOf(GlobalConstName.ArrowStr);
      string bomNodeType= index < 0 ? bomNodeTypeRule : bomNodeTypeRule.Substring(0, index);
      string nextFilterBomNodeTypeRule = index <= 0 ? null : bomNodeTypeRule.Substring(index + 2);
      if (string.IsNullOrEmpty(nextFilterBomNodeTypeRule))
      {
          return parentBomNode.FilterChildNode(bomNodeType, partType, partDescr, partNo);               
      }
      else  // have next bomNode
      {
          IList<IBOMNode> ret = new List<IBOMNode>();
          var bomNodeList = parentBomNode.FilterChildNode(bomNodeType, null, null,null);
          if (bomNodeList != null && bomNodeList.Count > 0)
          {
              foreach (IBOMNode node in bomNodeList)
              {
                  ret = ret.Concat(GetNextBom(nextFilterBomNodeTypeRule, partType, partDescr, partNo, node)).ToList();
              }
          }               
          return ret;
      }
  }
示例#12
0
        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);
                    }

                }
            }
        }
示例#13
0
        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);
                    }
                }
            }
        }
示例#14
0
文件: Filter.cs 项目: wra222/testgit
        string GetVendorCode(IBOMNode p1Node)
        {
            string vcString = string.Empty;
            if (p1Node == null || p1Node.Children == null)
            {
                return null;
            }

            foreach (IBOMNode node in p1Node.Children)
            {
                if (node.Part == null)
                {
                }
                else
                {
                    if (string.Compare(node.Part.BOMNodeType, "KP" ) == 0)
                    {
                        string vc = node.Part.GetAttribute("VendorCode");
                        if (!string.IsNullOrEmpty(vc))
                        {
                            if (vcString == string.Empty)
                            {
                                vcString = vc;
                            }
                            else
                            {
                                if (!vcString.Contains(vc))
                                {
                                    vcString = vcString + "," + vc;
                                }
                            }
                        }
                    }                                        
                }
            }
            return vcString;
        }
示例#15
0
文件: BOMNode.cs 项目: wra222/testgit
 public void RemoveChild(IBOMNode child)
 {
     if (Children.Contains(child))
     {
         child.Parent = null;
         Children.Remove(child);
     }
 }
示例#16
0
文件: BOMNode.cs 项目: wra222/testgit
 public void AddChild(IBOMNode child)
 {
     if (!_children.Contains(child))
     {
         _children.Add(child);
         child.Parent = this;
     }
 }