Пример #1
0
        public object FilterBOM(object hierarchical_bom, string station, object main_object)
        {
            IList<IFlatBOMItem> flat_bom_items = new List<IFlatBOMItem>(); 
            IFlatBOM ret = null;
            try
            {
                IProduct product = GetProduct(main_object);
                if (!string.IsNullOrEmpty(product.DeliveryNo))
                {
                    string deliveryNo = product.DeliveryNo;
                    IDeliveryRepository dnRep = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>();
                    string flag = dnRep.GetDeliveryInfoValue(deliveryNo, "Flag");
                    if (flag == "N") //自動單
                    {
                        string boxId = (string)product.GetExtendedProperty("BoxId");
                        if (string.IsNullOrEmpty(boxId))
                        {
                            boxId= (string)product.GetExtendedProperty("UCC");
                        }
                        if (string.IsNullOrEmpty(boxId))
                        {
                            throw new FisException("PAK034", new string[] { });   //此机器无BoxId!请返回Ship To Label 确认!;
                        }
                        string virtualPN="BoxID" + "/" + boxId;
                        string descr = "Check BoxID";
                        IPart part = new Part()
                        {
                            PN = virtualPN,      //PN要跟 flat_bom_item.PartNoItem值一樣                  
                            CustPn = "",
                            Remark = "",
                            Descr = descr,
                            Descr2 = "",
                            Type = part_check_type,
                            Udt = DateTime.Now,
                            Cdt = DateTime.Now
                        };
                        var flat_bom_item = new FlatBOMItem(qty, part_check_type, new List<IPart>() { part });
                        flat_bom_item.PartNoItem = virtualPN;
                        flat_bom_item.Tp = part_check_type;
                        flat_bom_item.Descr = descr;
                        flat_bom_item.ValueType = boxId; //存放Part match時檢查的值
                        flat_bom_items.Add(flat_bom_item);

                    }
                }              

              
                if (flat_bom_items.Count > 0)
                {
                    ret = new FlatBOM(flat_bom_items);
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return ret;
        }        
Пример #2
0
        public object FilterBOM(object hierarchical_bom, string station, object main_object)
        {
            IList<IFlatBOMItem> flat_bom_items = new List<IFlatBOMItem>();

            IFlatBOM ret = null;
            if (hierarchical_bom == null)
            {
                throw new ArgumentNullException();
            }
            HierarchicalBOM bom = (HierarchicalBOM)hierarchical_bom;            
            try
            {
                if (bom.FirstLevelNodes != null)
                {

                    IList<IBOMNode> bomNodeList = bom.FirstLevelNodes;

                    var masterLabelPart =( from p in bomNodeList
                                            where p.Part.PN == "60NOMSTLBL01"
                                            select new { Qty = p.Qty, PartNo = p.Part.PN }).FirstOrDefault();
                    if (masterLabelPart != null)
                    {
                        IProduct product=GetProduct(main_object);
                        IModelRepository modelRep = RepositoryFactory.GetInstance().GetRepository<IModelRepository>();
                        IList<IMES.FisObject.Common.Model.ModelInfo> pcid = modelRep.GetModelInfoByModelAndName(product.Model, "PCID");
                        IPart part = new Part()
                        {
                            PN = masterLabelPart.PartNo+"/"+pcid[0].Value,      //PN要跟 flat_bom_item.PartNoItem值一樣                  
                            CustPn = "",
                            Remark = "",
                            Descr = "Master Label",
                            Descr2 = "",
                            Type = "MasterLabel",
                            Udt = DateTime.Now,
                            Cdt = DateTime.Now
                        };

                        var flat_bom_item = new FlatBOMItem(masterLabelPart.Qty, part_check_type, new List<IPart>() { part });
                        flat_bom_item.PartNoItem = masterLabelPart.PartNo + "/" + pcid[0].Value;
                        flat_bom_item.Tp = "MasterLabel";
                        flat_bom_item.Descr = "Check Master Label";
                        flat_bom_item.ValueType = pcid[0].Value; //存放Part match時檢查的值
                        flat_bom_items.Add(flat_bom_item);
                    } 
                }

                if (flat_bom_items.Count > 0)
                {
                    ret = new FlatBOM(flat_bom_items);
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return ret;
        }
Пример #3
0
 public object FilterBOM(object hierarchical_bom, string station, object main_object)
 {
     //根据Model展1阶,得到第一阶是MB的part [BomNodeType=MB]的MBCode[PartInfo.InfoValue(InfoType='MB')],
     IFlatBOM ret = null;
     var parts = new List<IPart>();
     if (hierarchical_bom == null)
     {
         throw new ArgumentNullException();
     }
     var bom = (HierarchicalBOM)hierarchical_bom;
     String mb_info_value_string = "";
     if (bom.FirstLevelNodes != null)
     {
         for (int i = 0; i < bom.FirstLevelNodes.Count; i++)
         {
             if (bom.FirstLevelNodes.ElementAt(i).Part.BOMNodeType.Equals("MB"))
             {
                 if (CheckCondition(bom.FirstLevelNodes.ElementAt(i)))
                 {
                     IList<PartInfo> part_infos = bom.FirstLevelNodes.ElementAt(i).Part.Attributes;
                     if (part_infos != null)
                     {
                         foreach (PartInfo part_info in part_infos)
                         {
                             if (part_info.InfoType.Equals("MB"))
                             {
                                 if (mb_info_value_string.Length == 0)
                                 {
                                     mb_info_value_string = part_info.InfoValue;
                                 }
                                 else
                                 {
                                     if (!mb_info_value_string.Contains(part_info.InfoValue))
                                     {
                                         mb_info_value_string += "," + part_info.InfoValue;
                                     }
                                 }
                             }
                         }
                     }
                     _qty = bom.FirstLevelNodes.ElementAt(i).Qty;
                     IPart part = ((BOMNode)bom.FirstLevelNodes.ElementAt(i)).Part;
                     parts.Add(part);
                 }
             }
         }
     }
     if (parts.Count > 0)
     {
         var flat_bom_item = new FlatBOMItem(_qty, part_check_type, parts);
         flat_bom_item.Descr = bom.FirstLevelNodes.ElementAt(0).Part.Descr;
         flat_bom_item.PartNoItem = mb_info_value_string;
         IList<IFlatBOMItem> flat_bom_items = new List<IFlatBOMItem>();
         flat_bom_items.Add(flat_bom_item);
         ret = new FlatBOM(flat_bom_items);
     }
     return ret;
 }
Пример #4
0
        public object FilterBOM(object hierarchical_bom, string station, object main_object)
        {
            IList<IFlatBOMItem> flat_bom_items = new List<IFlatBOMItem>();
            Hashtable share_parts_set = new Hashtable();
            Hashtable share_part_no_set = new Hashtable();
            Hashtable qty_share_parts_set = new Hashtable();
            Hashtable descr_parts_set = new Hashtable();
            IFlatBOM ret = null;
            if (hierarchical_bom == null)
            {
                throw new ArgumentNullException();
            }
            var bom = (HierarchicalBOM)hierarchical_bom;
            try
            {
                string CountryCode = string.Empty;
                IProduct product = GetProduct(main_object);
                string SN = product.CUSTSN;
                if (product.Model.Length > 11)
                {
                    CountryCode = product.Model.Substring(9, 2);
                }
                if (((CountryCode == "29") || (CountryCode == "39")) && !string.IsNullOrEmpty(SN))
                {
                    string virtualPN = "JapanSN" + "/" + SN;
                    string descr = "Check JapanSN";
                    IPart part = new Part()
                    {
                        PN = virtualPN,      //PN要跟 flat_bom_item.PartNoItem值一樣                  
                        CustPn = "",
                        Remark = "",
                        Descr = descr,
                        Descr2 = "",
                        Type = part_check_type,
                        Udt = DateTime.Now,
                        Cdt = DateTime.Now
                    };
                    var flat_bom_item = new FlatBOMItem(qty, part_check_type, new List<IPart>() { part });
                    flat_bom_item.PartNoItem = virtualPN;
                    flat_bom_item.Tp = part_check_type;
                    flat_bom_item.Descr = descr;
                    flat_bom_item.ValueType = "SN*" + SN; //存放Part match時檢查的值
                    flat_bom_items.Add(flat_bom_item);
                }
                if (flat_bom_items.Count > 0)
                {
                    ret = new FlatBOM(flat_bom_items);
                }

            }
            catch (Exception e)
            {
                throw;
            }

            return ret;
        }
Пример #5
0
        public object FilterBOM(object hierarchical_bom, string station, object main_object)
        {
            IList<IFlatBOMItem> flat_bom_items = new List<IFlatBOMItem>();
            IFlatBOM ret = null;
            try
            {
                   UtilityCommonImpl utl= UtilityCommonImpl.GetInstance();
                   Session session=utl.GetSession(main_object,part_check_type);
                  IList<AstDefineInfo> astDefineInfo =(IList<AstDefineInfo>) session.GetValue(Session.SessionKeys.NeedCombineAstDefineList);
                  if (astDefineInfo==null || astDefineInfo.Count==0)
                  {
                      return ret;
                  }
                  IList<IPart> astPartInfo =(IList<IPart>) session.GetValue(Session.SessionKeys.NeedCombineAstPartList);
                  if (astPartInfo==null || astPartInfo.Count==0)
                  {
                      return ret;
                  }

                  var share_parts_set = astPartInfo.Where(x => astDefineInfo.Any(y => y.AstType == x.BOMNodeType &&
                                                                                                                        y.AstCode == x.Descr &&
                                                                                                                       y.CheckUnique!="N" &&
                                                                                                                        y.NeedScanSN == "Y")).ToList();
                    

                if (share_parts_set.Count > 0)
                {
                    foreach (IPart part in share_parts_set)
                    {
                        var flat_bom_item = new FlatBOMItem(qty, part_check_type, new List<IPart>(){part});
                        flat_bom_item.PartNoItem =part.PN; 
                        flat_bom_item.Tp =  part.BOMNodeType;
                        flat_bom_item.Descr = part.Descr;
                        flat_bom_item.ValueType = ""; //存放Part match時檢查的值
                        flat_bom_items.Add(flat_bom_item);
                    }
                }

                if (flat_bom_items.Count > 0)
                {
                    ret = new FlatBOM(flat_bom_items);
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return ret;
        }        
Пример #6
0
        public object FilterBOM(object hierarchical_bom, string station, object main_object)
        {
            IList<IFlatBOMItem> flat_bom_items = new List<IFlatBOMItem>();
            IFlatBOM ret = null;
            try
            {
                IProduct product = GetProduct(main_object);
                if (!string.IsNullOrEmpty(product.DeliveryNo))
                {
                    string deliveryNo = product.DeliveryNo;
                    IDeliveryRepository dnRep = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>();
                    string configID = dnRep.GetDeliveryInfoValue(deliveryNo, "ConfigID");
                    if (!string.IsNullOrEmpty(configID)) //船務有configID
                    {

                        string virtualPN = "ConfigID" + "/" + configID;
                        string descr = "Check ConfigID";
                        IPart part = new Part()
                        {
                            PN = virtualPN,      //PN要跟 flat_bom_item.PartNoItem值一樣                  
                            CustPn = "",
                            Remark = "",
                            Descr =descr,
                            Descr2 = "",
                            Type = part_check_type,
                            Udt = DateTime.Now,
                            Cdt = DateTime.Now
                        };
                        var flat_bom_item = new FlatBOMItem(qty, part_check_type, new List<IPart>() { part });
                        flat_bom_item.PartNoItem = virtualPN;
                        flat_bom_item.Tp = part_check_type;
                        flat_bom_item.Descr = descr;
                        flat_bom_item.ValueType = configID; //存放Part match時檢查的值
                        flat_bom_items.Add(flat_bom_item);
                    }
                }

                if (flat_bom_items.Count > 0)
                {
                    ret = new FlatBOM(flat_bom_items);
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return ret;
        }        
Пример #7
0
        public object FilterBOM(object hierarchical_bom, string station, object main_object)
        {
            IList<IFlatBOMItem> flat_bom_items = new List<IFlatBOMItem>(); 
            IFlatBOM ret = null;
            try
            {

                IProduct product = Uti.GetProduct(main_object, part_check_type);
                if (string.IsNullOrEmpty(product.CUSTSN))
                {
                     throw new FisException("Product.CustomSN is empty in " + part_check_type + " module");
                }
                string HiddenCode = GetCheckCode(product);
                string virtualPN = "HiddenSN000000-000";
                string descr = "Check PizzaCustomSN";
                IPart part = new Part()
                {
                    PN = virtualPN,      //PN要跟 flat_bom_item.PartNoItem值一樣                  
                    CustPn = "",
                    Remark = "",
                    Descr = descr,
                    Descr2 = "",
                    Type = part_check_type,
                    Udt = DateTime.Now,
                    Cdt = DateTime.Now
                };
                var flat_bom_item = new FlatBOMItem(qty, part_check_type, new List<IPart>() { part });
                flat_bom_item.PartNoItem = virtualPN;
                flat_bom_item.Tp = part_check_type;
                flat_bom_item.Descr = descr;
                flat_bom_item.ValueType = HiddenCode.Trim()+product.CUSTSN; //存放Part match時檢查的值
                flat_bom_items.Add(flat_bom_item);
                 
                if (flat_bom_items.Count > 0)
                {
                    ret = new FlatBOM(flat_bom_items);
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return ret;
        }        
Пример #8
0
        public object FilterBOM(object hierarchical_bom, string station, object main_object)
        {
            IList<IFlatBOMItem> flat_bom_items = new List<IFlatBOMItem>();
            IFlatBOM ret = null;
            try
            {
                IProduct product = GetProduct(main_object);
                string SleeveCT = (string)product.GetExtendedProperty("SleeveCT");
                if (!string.IsNullOrEmpty(SleeveCT))
                {
                    string virtualPN = "SleeveCT" + "/" + SleeveCT;
                    string descr = "Check SleeveCT";
                        IPart part = new Part()
                        {
                            PN = virtualPN,      //PN要跟 flat_bom_item.PartNoItem值一樣                  
                            CustPn = "",
                            Remark = "",
                            Descr = descr,
                            Descr2 = "",
                            Type = part_check_type,
                            Udt = DateTime.Now,
                            Cdt = DateTime.Now
                        };
                        var flat_bom_item = new FlatBOMItem(qty, part_check_type, new List<IPart>() { part });
                        flat_bom_item.PartNoItem = virtualPN;
                        flat_bom_item.Tp = part_check_type;
                        flat_bom_item.Descr = descr;
                        flat_bom_item.ValueType = SleeveCT; //存放Part match時檢查的值
                        flat_bom_items.Add(flat_bom_item);
                    
                }

                if (flat_bom_items.Count > 0)
                {
                    ret = new FlatBOM(flat_bom_items);
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return ret;
        }
Пример #9
0
        public object FilterBOM(object hierarchical_bom, string station, object main_object)
        {
            IList<IFlatBOMItem> flat_bom_items = new List<IFlatBOMItem>();
           
            IFlatBOM ret = null;

            if (hierarchical_bom == null)
            {
                throw new ArgumentNullException();
            }
            var bom = (HierarchicalBOM)hierarchical_bom;
            var bomNodeList = bom.FirstLevelNodes;
            //PB階下所有料號,即為需要收集的數量(無共用料情況).ModelBom.Qty 為每顆料需收集的數量
            try
            {
                if (bomNodeList != null)
                {
                    var partList = bomNodeList.Where(x => x.Part.BOMNodeType == "PB")
                                                            .Select(y => new { Part = y.Part, Qty = y.Qty });
                    if (partList.Count() > 0)
                    {
                        foreach (var item in partList )
                        {
                            var flat_bom_item = new FlatBOMItem(item.Qty, part_check_type, new List<IPart> { item.Part});
                            flat_bom_item.PartNoItem = item.Part.PN;
                            flat_bom_item.Tp = part_check_type;
                            flat_bom_item.Descr =  item.Part.Descr;
                            flat_bom_items.Add(flat_bom_item);
                        }

                    }
                } 
                if (flat_bom_items.Count > 0)
                {
                    ret = new FlatBOM(flat_bom_items);
                }
            }
            catch (Exception e)
            {
                throw;
            }
            return ret;
        }       
Пример #10
0
        public object FilterBOM(object hierarchical_bom, string station, object main_object)
        {
            IList<IFlatBOMItem> flat_bom_items = new List<IFlatBOMItem>(); 
            IFlatBOM ret = null;
            try
            {
                IProduct product = Uti.GetProduct(main_object, part_check_type);
                bool needCheckCRC= Uti.CheckModelByProcReg(product.Model, new List<string>{"SKU"});
                if (needCheckCRC)
                {
                    string virtualPN = "ProductID" + "/" + product.ProId;
                    string descr = "Check ProductID CRC";
                    IPart part = new Part()
                    {
                        PN = virtualPN,      //PN要跟 flat_bom_item.PartNoItem值一樣                  
                        CustPn = "",
                        Remark = "",
                        Descr = descr,
                        Descr2 = "",
                        Type = part_check_type,
                        Udt = DateTime.Now,
                        Cdt = DateTime.Now
                    };
                    var flat_bom_item = new FlatBOMItem(qty, part_check_type, new List<IPart>() { part });
                    flat_bom_item.PartNoItem = virtualPN;
                    flat_bom_item.Tp = part_check_type;
                    flat_bom_item.Descr = descr;
                    flat_bom_item.ValueType = getCRC(product.ProId) + product.ProId; //存放Part match時檢查的值
                    flat_bom_items.Add(flat_bom_item);
                }

                if (flat_bom_items.Count > 0)
                {
                    ret = new FlatBOM(flat_bom_items);
                }
            }
            catch (Exception)
            {
                throw;
            }

            return ret;
        }
Пример #11
0
        public object FilterBOM(object hierarchical_bom, string station, object main_object)
        {
            Hashtable share_parts_set = new Hashtable();
            Hashtable check_typ_set = new Hashtable();
            IFlatBOM ret = null;
            if (station.Trim().Equals("PKOK"))
            {
                //问题:station参数用不上。因为在hierarchicalBOM中,没有与station相关的字段。

                //var parts = new List<IPart>();
                if (hierarchical_bom == null)
                {
                    throw new ArgumentNullException();
                }
                var bom = (HierarchicalBOM) hierarchical_bom;
                try
                {
                    if (bom.FirstLevelNodes != null)
                    {
                        for (int i = 0; i < bom.FirstLevelNodes.Count; i++)
                        {
                            if (CheckCondition(bom.FirstLevelNodes.ElementAt(i)))
                            {
                                IPart part = ((BOMNode) bom.FirstLevelNodes.ElementAt(i)).Part;

                                if (!share_parts_set.ContainsKey(part.PN))
                                {
                                    IList<IPart> parts = new List<IPart>();
                                    parts.Add(part);
                                    share_parts_set.Add(part.PN, parts);
                                    check_typ_set.Add(part.PN, part.BOMNodeType.Trim());
                                }
                                else
                                {
                                    ((IList<IPart>) share_parts_set[part.PN]).Add(part);
                                }
                                break;
                            }
                        }
                    }
                    if (share_parts_set.Count > 0)
                    {
                        IList<IFlatBOMItem> flat_bom_items = new List<IFlatBOMItem>();
                        foreach (DictionaryEntry de in share_parts_set)
                        {
                            var flat_bom_item = new FlatBOMItem(qty, part_check_type, (IList<IPart>)de.Value);
                            flat_bom_item.PartNoItem = bom.Model;
                            flat_bom_item.Tp = (string) check_typ_set[de.Key];
                            flat_bom_item.Descr = "Second Pizza";
                            flat_bom_items.Add(flat_bom_item);
                        }
                        ret = new FlatBOM(flat_bom_items);
                    }
                }
                catch (Exception e)
                {
                    throw;
                }
            }
            return ret;
        }
Пример #12
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="hierarchical_bom"></param>
        /// <param name="station"></param>
        /// <param name="main_object"></param>
        /// <returns></returns>
        public object FilterBOM(object hierarchical_bom, string station, object main_object)
        {
            //根据Model展3阶,得到第一阶是V2的part其下下阶(注意Qty需要相乘) [ V2一定会有VC下阶: V2->P1->KP->VC]
            //界面上显示Part No和Description是P1对应的Part;不同的P1作为多条记录显示在界面上,即相同的P1只显示一条,
            //其VC合并,相同的P1对应的数量认为是一样的,数量只取第一条记录的Qty即可
            //删掉PN前3位是MMI的Part ((GYJ)前三位只是代号,可能有DIB,MMI等)
            IFlatBOM ret = null;
            IList<IFlatBOMItem> flat_bom_items = new List<IFlatBOMItem>();
            //var kp_parts = new List<IPart>();
            if (hierarchical_bom == null)
            {
                throw new ArgumentNullException();
            }
            var bom = (HierarchicalBOM)hierarchical_bom;
            TreeTraversal tree_traversal = new TreeTraversal();
            Hashtable part_group_set = new Hashtable();
            Hashtable descr_part_set = new Hashtable();
            IList<KPVendorCode> kpVCList = new List<KPVendorCode>();
            //Hashtable info_value_string_set = new Hashtable();
            try
            {
                IList<QtyParts> check_conditon_nodes = tree_traversal.BreadthFirstTraversal("MMI",bom.Root, "V2->P1->KP","P1",this);
                IList<PartGroupType> part_group_type = FilterPartGroupType(check_conditon_nodes);
                if (check_conditon_nodes != null && check_conditon_nodes.Count > 0)
                {
                     List<IFlatBOMItem> items = new List<IFlatBOMItem>();
                    foreach (QtyParts check_conditon_node in check_conditon_nodes)
                    {
                        //FlatBOMItem item = new FlatBOMItem(check_conditon_node.Qty,part_check_type,check_conditon_node.Parts);
                        //items.Add(item);
                        if (bom.FirstLevelNodes != null) //当bom.Root.Part不为空时,Root是首阶
                        {
                            IList<IBOMNode> bom_nodes = bom.FirstLevelNodes;
                            foreach (IBOMNode bom_node in bom_nodes)
                            {
                                if (bom_node.Part.BOMNodeType.Equals("V2"))
                                {
                                    IList<IBOMNode> p1_child_nodes = bom_node.Children;
                                    if (p1_child_nodes != null)
                                    {
                                        foreach (IBOMNode p1_child_node in p1_child_nodes)
                                        {
                                            if (p1_child_node.Part != null && p1_child_node.Part.BOMNodeType.Equals("P1"))
                                            {
                                                if (PartCompare(check_conditon_node.Parts, p1_child_node.Part))
                                                {
                                                    if (part_group_type.Count > 0)
                                                    {
                                                        foreach (PartGroupType type in part_group_type)
                                                        {
                                                            if (p1_child_node.Part.PN.Equals(type.PN))
                                                            {
                                                                String part_group_key = type.PN;

                                                                if (!descr_part_set.ContainsKey(part_group_key))
                                                                {
                                                                    descr_part_set.Add(part_group_key, p1_child_node.Part.Descr);
                                                                }
                                                                else
                                                                {
                                                                    if (!((String)descr_part_set[part_group_key]).Contains(p1_child_node.Part.Descr))
                                                                    {
                                                                        descr_part_set[part_group_key] += "," + p1_child_node.Part.Descr;
                                                                    }
                                                                }
                                                                IList<IBOMNode> kp_child_nodes = p1_child_node.Children;
                                                                //String info_value_string = "";
                                                                if (kp_child_nodes != null)
                                                                {
                                                                    foreach (IBOMNode kp_child_node in kp_child_nodes)
                                                                    {
                                                                        if (kp_child_node.Part != null && kp_child_node.Part.BOMNodeType.Equals("KP"))
                                                                        {
                                                                            IList<PartInfo> part_infos = kp_child_node.Part.Attributes;
                                                                            if (part_infos != null && part_infos.Count > 0)
                                                                            {
                                                                                foreach (PartInfo part_info in part_infos)
                                                                                {
                                                                                    if (part_info.InfoType.Equals("VendorCode"))
                                                                                    {
                                                                                        //p1_child_node.Part.AddAttribute(part_info);
                                                                                        kpVCList.Add(new KPVendorCode
                                                                                        {
                                                                                            PartNo = p1_child_node.Part.PN,
                                                                                            VendorCode = part_info.InfoValue
                                                                                        }
                                                                                            );
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                                if (!part_group_set.ContainsKey(part_group_key))
                                                                {
                                                                    IList<IPart> share_parts = new List<IPart>();
                                                                    share_parts.Add(p1_child_node.Part);
                                                                    part_group_set.Add(part_group_key, share_parts);
                                                                }
                                                                else
                                                                {
//                                                                    ((IList<IPart>)part_group_set[part_group_key]).Add(p1_child_node.Part);
                                                                    IList<IBOMNode> identical_p1_child_nodes = p1_child_node.Children;
                                                                    //String info_value_string = "";
                                                                    if (kp_child_nodes != null)
                                                                    {
                                                                        foreach (IBOMNode identical_p1_child_node in identical_p1_child_nodes)
                                                                        {
                                                                            if (identical_p1_child_node.Part != null && identical_p1_child_node.Part.BOMNodeType.Equals("KP"))
                                                                            {
                                                                                IList<PartInfo> part_infos = identical_p1_child_node.Part.Attributes;
                                                                                if (part_infos != null && part_infos.Count > 0)
                                                                                {
                                                                                    foreach (PartInfo part_info in part_infos)
                                                                                    {
                                                                                        if (part_info.InfoType.Equals("VendorCode"))
                                                                                        {
//                                                                                            p1_child_node.Part.AddAttribute(part_info);
                                                                                            // ((IList<IPart>)part_group_set[part_group_key]).ElementAt(0).AddAttribute(part_info);

                                                                                           kpVCList.Add(new KPVendorCode
                                                                                            {
                                                                                                PartNo = ((IList<IPart>)part_group_set[part_group_key]).ElementAt(0).PN,
                                                                                                VendorCode = part_info.InfoValue
                                                                                            });
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (part_group_type.Count > 0)
                    {
                        foreach (PartGroupType type in part_group_type)
                        {
                            String share_material_key = type.PN;
                            var bm_flat_bom_item = new FlatBOMItem(type.Qty, part_check_type, (IList<IPart>)part_group_set[share_material_key]);
                            bm_flat_bom_item.PartNoItem = type.PN;
                            bm_flat_bom_item.Descr = (String)descr_part_set[share_material_key];
                            flat_bom_items.Add(bm_flat_bom_item);
                        }
                    }
                }
 
                if (flat_bom_items.Count > 0)
                {
                    ret = new FlatBOM(flat_bom_items);
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return ret;
        }
Пример #13
0
        public object FilterBOM(object hierarchical_bom, string station, object main_object)
        {
            IList<IFlatBOMItem> flat_bom_items = new List<IFlatBOMItem>();
            Hashtable share_parts_set = new Hashtable();
            //问题:station参数用不上。因为在hierarchicalBOM中,没有与station相关的字段。
            IFlatBOM ret = null;
            //List<IPart> parts = new List<IPart>();
            if (hierarchical_bom == null)
            {
                throw new ArgumentNullException();
            }
            HierarchicalBOM bom = (HierarchicalBOM)hierarchical_bom;

            try
            {
                if (bom.FirstLevelNodes != null)
                {
                    for (int i = 0; i < bom.FirstLevelNodes.Count; i++)
                    {
                        if (CheckCondition(bom.FirstLevelNodes.ElementAt(i)))
                        {
                            IPart part = ((BOMNode) bom.FirstLevelNodes.ElementAt(i)).Part;
                            //parts.Add(part);

                            if (!share_parts_set.ContainsKey(part.PN))
                            {
                                IList<IPart> parts = new List<IPart>();
                                parts.Add(part);
                                share_parts_set.Add(part.PN, parts);
                                //qty_share_parts_set.Add(part.PN, ((BOMNode)bom.FirstLevelNodes.ElementAt(i)).Qty);
                            }
                            else
                            {
                                ((IList<IPart>)share_parts_set[part.PN]).Add(part);
                            }
                        }
                    }

                    //if (parts.Count > 0)
                    //{
                    //    FlatBOMItem flat_bom_item = new FlatBOMItem(qty, part_check_type, parts);
                    //    flat_bom_item.PartNoItem = parts.ElementAt(0).PN;
                    //    flat_bom_item.Descr = parts.ElementAt(0).Descr;
                    //    IList<IFlatBOMItem> flat_bom_items = new List<IFlatBOMItem>();
                    //    flat_bom_items.Add(flat_bom_item);
                    //    ret = new FlatBOM(flat_bom_items);
                    //}
                }
                if (share_parts_set.Count > 0)
                {
                    foreach (DictionaryEntry de in share_parts_set)
                    {
                        var flat_bom_item = new FlatBOMItem(qty, part_check_type, (IList<IPart>)de.Value);
                        flat_bom_item.PartNoItem = (string)de.Key;
                        flat_bom_item.Tp = "PS";
                        flat_bom_item.Descr = "PR/APR" + " Docking Part No";
                        flat_bom_items.Add(flat_bom_item);
                    }
                }
                if (flat_bom_items.Count > 0)
                {
                    ret = new FlatBOM(flat_bom_items);
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return ret;
        }
Пример #14
0
     //   private Session _currentSession;
   //     private IList<CheckItemTypeRuleDef> _lstChkItemRule;
    //    private string _station;
        /// <summary>
        /// 
        /// </summary>
        /// <param name="hierarchical_bom"></param>
        /// <param name="station"></param>
        /// <param name="main_object"></param>
        /// <returns></returns>
        public object FilterBOM(object hierarchical_bom, string station, object main_object)
        {
           // _lstChkItemRule = null;
           // _station = station;
            //IPartRepository partRep = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
            Session session = GetSession(main_object);
            IList<CheckItemTypeRuleDef> lstChkItemRule = GetCheckItemTypeRule(session);
          //  SetCheckItemTypeRule();
            IList<IFlatBOMItem> flat_bom_items = new List<IFlatBOMItem>();
            Hashtable share_parts_set = new Hashtable();
            Hashtable share_part_no_set = new Hashtable();
            Hashtable qty_share_parts_set = new Hashtable();
            Hashtable descr_parts_set = new Hashtable();
            Hashtable check_typ_set = new Hashtable();
            //问题:station参数用不上。因为在hierarchicalBOM中,没有与station相关的字段。
            IFlatBOM ret = null;
            //int qty = 0;
            //var parts = new List<IPart>();
            if (hierarchical_bom == null)
            {
                throw new ArgumentNullException();
            }
            var bom = (HierarchicalBOM)hierarchical_bom;
            try
            {
                /* 
                Product product_model = session.GetValue(Session.SessionKeys.Product) as Product;
                //product.FamilyName
                
                IList<ConstValueInfo> valueList =
                   partRep.GetConstValueListByType("CheckAssemblyVC").Where(x => x.value.Trim() != "" && x.name == "Family" && x.description == lstChkItemRule.Select(y=>y.PartDescr).ElementAt(0).ToString()).ToList();
                bool IsCheckAssemblyVC = false;
                IList<string> lstVC = new List<string>();
                if (valueList != null && valueList.Count > 0)
                {
                    //ret.remark = valueList[0].value;
                    IsCheckAssemblyVC = valueList.Any(x => x.value == product_model.Family);
                    if (IsCheckAssemblyVC)
                    {
                        var product = session.GetValue(Session.SessionKeys.Product) as IProduct;
                        IList<IProductPart> lstPrdPart = product.ProductParts;
                        var partsn = from n in lstPrdPart
                                      where n.CheckItemType == "LCM"
                                      where n.PartSn != ""
                                     select n.PartSn;
                        //var partsn = lstPrdPart.Select(y => y.PartSn).Where(x => x.CheckItemType == "LCM" && x.PartSn != "").ToString();
                        //ProductPart Product_Part = session.GetValue(Session.SessionKeys.ProductPartList) as ProductPart;
                        string sn5 = "";
                        if (null != partsn  &&partsn.ElementAt(0)!="")
                        {
                            sn5 = partsn.ElementAt(0).Substring(0, 5);
                        }
                AssemblyVCInfo ai = new AssemblyVCInfo();
                ai.vc = sn5;
                IList<AssemblyVCInfo> lstAI = partRep.GetAssemblyVC(ai);

                //IList<string> lstVC = new List<string>();
                if (lstAI != null && lstAI.Count > 0)
                {
                    foreach (AssemblyVCInfo a in lstAI)
                    {
                        lstVC.Add(a.combinePartNo);
                    }
                }
                else
                {
                    throw new FisException("CQCHK0004", new string[] { sn5 });
                }
                    }
                }
                 */
                if (bom.FirstLevelNodes != null)
                {
                    for (int i = 0; i < bom.FirstLevelNodes.Count; i++)
                    {
                        IPart part = ((BOMNode)bom.FirstLevelNodes.ElementAt(i)).Part;
                       // if (part != null && (part.BOMNodeType.Trim().Equals("PL") || part.BOMNodeType.Trim().Equals("C2") || part.BOMNodeType.Trim().Equals("VK")))
                        if (part != null && CheckBomNodeType(bom.FirstLevelNodes.ElementAt(i).Part,lstChkItemRule))
                      
                        {

                            if (NewCheckCondition(bom.FirstLevelNodes.ElementAt(i),session,lstChkItemRule))
                            {
                                Boolean exist_share_part = false;
                                IList<PartInfo> part_infos = part.Attributes;
                                if (part_infos != null && part_infos.Count > 0)
                                {
                                    foreach (PartInfo part_info in part_infos)
                                    {
                                        if (part_info.InfoType.Equals("SUB"))
                                        {
                                            exist_share_part = true;

                                            String[] share_parts = part_info.InfoValue.Trim().Split(';');
                                            if (share_parts.Length > 0)
                                            {
                                                string share_part_no = part_info.InfoValue.Trim();
                                                //                                                share_part_no = share_part_no.Replace("DIB", "");
                                                //                                                share_part_no_set.Add(part.PN, share_part_no.Replace(';', ','));
                                                if (share_part_no_set.ContainsKey(part.PN))
                                                {
                                                    share_part_no_set[part.PN] += "," + share_part_no.Replace(';', ',');
                                                }
                                                else
                                                {
                                                    share_part_no_set.Add(part.PN, share_part_no.Replace(';', ','));
                                                }
                                                IPartRepository repository = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
                                                IList<IPart> parts = new List<IPart>();
                                                parts.Add(part);
                                                for (int j = 0; j < share_parts.Length; j++)
                                                {
                                                    //                                                    IPart share_part = repository.GetPartByPartNo(share_parts[j]);
                                                    IPart share_part = null;
                                                    bool isC2WithoutVC = false;
                                                    //part
                                                  //  if (share_parts[j].Substring(0, 3).Equals("DIB") && part.BOMNodeType.Trim().Equals("C2"))
                                                    if (share_parts[j].Substring(0, 3).Equals("DIB") && CheckBomNodeType(part,lstChkItemRule))
                                                    {
                                                        share_part = repository.GetPartByPartNo(share_parts[j].Substring(3, share_parts[j].Length - 3));
                                                        if (share_part == null)
                                                        {
                                                            share_part = repository.GetPartByPartNo(share_parts[j]);
                                                        }
                                                        if (share_part != null)
                                                        {
                                                            IList<PartInfo> c2_dib_share_part_infos = share_part.Attributes;
                                                            if (c2_dib_share_part_infos != null)
                                                            {
                                                                bool have_vendor_code = false;
                                                                foreach (PartInfo c2_dib_share_part_info in c2_dib_share_part_infos)
                                                                {
                                                                    if (c2_dib_share_part_info.InfoType.Equals("VendorCode"))
                                                                    {
                                                                        have_vendor_code = true;
                                                                    }
                                                                }
                                                                if (!have_vendor_code)
                                                                {
                                                                    isC2WithoutVC = true;
                                                                    parts.Add(share_part);
                                                                }
                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        share_part = repository.GetPartByPartNo(share_parts[j]);
                                                    }
                                                    if (share_part != null && !isC2WithoutVC)
                                                    {
                                                        parts.Add(share_part);
                                                    }
                                                }
                                                String share_parts_code = part.PN;
                                                if (!share_parts_set.ContainsKey(share_parts_code))
                                                {
                                                    share_parts_set.Add(share_parts_code, parts);
                                                    qty_share_parts_set.Add(share_parts_code, ((BOMNode)bom.FirstLevelNodes.ElementAt(i)).Qty);
                                                    descr_parts_set.Add(share_parts_code, part.Descr);
                                                    check_typ_set.Add(share_parts_code, part.BOMNodeType.Trim());
                                                }
                                                else
                                                {
                                                    ((IList<IPart>)share_parts_set[share_parts_code]).Add(part);
                                                    if (!((String)descr_parts_set[share_parts_code]).Contains(part.Descr))
                                                    {
                                                        descr_parts_set[share_parts_code] += "," + part.Descr;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }

                                if (!exist_share_part)
                                {
                                    if (!share_parts_set.ContainsKey(part.PN))
                                    {
                                        IList<IPart> parts = new List<IPart>();
                                        parts.Add(part);
                                        //                                        }
                                        share_parts_set.Add(part.PN, parts);
                                        qty_share_parts_set.Add(part.PN, ((BOMNode)bom.FirstLevelNodes.ElementAt(i)).Qty);
                                        descr_parts_set.Add(part.PN, part.Descr);
                                        check_typ_set.Add(part.PN, part.BOMNodeType.Trim());
                                    }
                                    else
                                    {
                                      
                                        ((IList<IPart>)share_parts_set[part.PN]).Add(part);
                                        //                                        }
                                        if (!((String)descr_parts_set[part.PN]).Contains(part.Descr))
                                        {
                                            descr_parts_set[part.PN] += "," + part.Descr;
                                        }
                                    }
                                }
                             }
                        }
                    }

                    if (share_parts_set.Count > 0)
                    {
                        foreach (DictionaryEntry de in share_parts_set)
                        {
                            var flat_bom_item = new FlatBOMItem((int)qty_share_parts_set[de.Key], part_check_type, (IList<IPart>)de.Value);
                            if (share_part_no_set.ContainsKey(de.Key))
                            {
                                if (((string)de.Key).Substring(0, 3).Equals("DIB"))
                                {
                                    flat_bom_item.PartNoItem = ((string)de.Key).Substring(3, ((string)de.Key).Length - 3) + "," + (string)share_part_no_set[de.Key];
                                    flat_bom_item.PartNoItem = flat_bom_item.PartNoItem.Replace("DIB", "");
                                }
                                else
                                {
                                    flat_bom_item.PartNoItem = de.Key + "," + (string)share_part_no_set[de.Key];
                                    flat_bom_item.PartNoItem = flat_bom_item.PartNoItem.Replace("DIB", "");
                                }
                            }
                            else
                            {
                                //                                flat_bom_item.PartNoItem = (string)de.Key;
                                if (((string)de.Key).Substring(0, 3).Equals("DIB"))
                                {
                                    flat_bom_item.PartNoItem = ((string)de.Key).Substring(3, ((string)de.Key).Length - 3);
                                    flat_bom_item.PartNoItem = flat_bom_item.PartNoItem.Replace("DIB", "");
                                }
                                else
                                {
                                    flat_bom_item.PartNoItem = (string)de.Key;
                                    flat_bom_item.PartNoItem = flat_bom_item.PartNoItem.Replace("DIB", "");
                                }
                            }
                            flat_bom_item.Tp = (string)check_typ_set[de.Key];
                            flat_bom_item.Descr = (string)descr_parts_set[de.Key];
                            flat_bom_items.Add(flat_bom_item);
                            //if (IsCheckAssemblyVC)
                            //{
                            //    if (!lstVC.Contains(flat_bom_item.PartNoItem) && flat_bom_item.Descr == lstChkItemRule.Select(y => y.PartDescr).ElementAt(0).ToString())
                            //    {
                            //          //flat_bom_items.Add(flat_bom_item);
                            //        flat_bom_items.Remove(flat_bom_item);
                            //    }                            
                            //}
                           
                        }
                    }
                    if (flat_bom_items.Count > 0)
                    {

                        ret = new FlatBOM(flat_bom_items);
                    }
                }
            }
            catch (Exception e)
            {
                throw;
            }
            return ret;
        }
Пример #15
0
        public object FilterBOM(object hierarchical_bom, string station, object main_object)
        {
            //根据Model展2阶,得到第一阶是PL的part其下阶(注意Qty需要相乘) [ PL->VC],即PL和VC,
            IFlatBOM ret = null;
            var parts = new List<IPart>();
            if (hierarchical_bom == null)
            {
                throw new ArgumentNullException();
            }
            var bom = (HierarchicalBOM)hierarchical_bom;
            String vendor_code_info_value_string = "";
            String descr_info_value_string = "";

            if (bom.FirstLevelNodes != null)
            {
                for (int i = 0; i < bom.FirstLevelNodes.Count; i++)
                {
                    if (bom.FirstLevelNodes.ElementAt(i).Part.BOMNodeType.Equals("PL"))
                    {
                        if (CheckCondition(bom.FirstLevelNodes.ElementAt(i)))
                        {
                            IList<PartInfo> part_infos = bom.FirstLevelNodes.ElementAt(i).Part.Attributes;
                            Boolean is_vc = false;
                            if (part_infos != null)
                            {
                                foreach (PartInfo part_info in part_infos)
                                {
                                    if (part_info.InfoType.Equals("VendorCode"))
                                    {
                                        is_vc = true;
                                        if (vendor_code_info_value_string.Length == 0)
                                        {
                                            vendor_code_info_value_string = part_info.InfoValue;
                                        }
                                        else
                                        {
                                            if (!vendor_code_info_value_string.Contains(part_info.InfoValue))
                                            {
                                                vendor_code_info_value_string += "," + part_info.InfoValue;
                                            }
                                        }
                                    }
                                    if (part_info.InfoType.Equals("Descr"))
                                    {
                                        if (descr_info_value_string.Length == 0)
                                        {
                                            descr_info_value_string = part_info.InfoValue;
                                        }
                                        else
                                        {
                                            if (!descr_info_value_string.Contains(part_info.InfoValue))
                                            {
                                                descr_info_value_string += "," + part_info.InfoValue;
                                            }
                                        }
                                    }
                                }
                            }
                            if (is_vc)
                            {
                                parts.Add(bom.FirstLevelNodes.ElementAt(i).Part);
                                _qty = bom.FirstLevelNodes.ElementAt(i).Qty;
                            }
                        }
                    }
                }
            }
            if (parts.Count > 0)
            {
                if (bom.FirstLevelNodes != null && bom.FirstLevelNodes.Count > 0)
                {
                    //                    _qty = bom.FirstLevelNodes.ElementAt(0).Qty;
                    var flat_bom_item = new FlatBOMItem(_qty, part_check_type, parts);
                    flat_bom_item.PartNoItem = vendor_code_info_value_string;
                    flat_bom_item.Descr = descr_info_value_string;
                    IList<IFlatBOMItem> flat_bom_items = new List<IFlatBOMItem>();
                    flat_bom_items.Add(flat_bom_item);
                    ret = new FlatBOM(flat_bom_items);
                }
            }
            return ret;
        }
Пример #16
0
 public object FilterBOM(object hierarchical_bom, string station, object main_object)
 {
     //根据Model展2阶,得到第一阶是KP的part其下阶(注意Qty需要相乘) [ KP->VC],即KP和VC,
     IFlatBOM flatBom = new FlatBOM();
     var parts = new List<IPart>();
     if (hierarchical_bom == null)
     {
         throw new ArgumentNullException();
     }
     
     var bom = (HierarchicalBOM)hierarchical_bom;
     if (bom.FirstLevelNodes != null)
     {
         for (int i = 0; i < bom.FirstLevelNodes.Count; i++)
         {
             if (bom.FirstLevelNodes.ElementAt(i).Part.BOMNodeType.Equals("KP"))
             {
                 bool bChecked = false;
                 IBOMNode bomNode = bom.FirstLevelNodes.ElementAt(i);
                 bChecked = CheckCondition(bomNode);
                 if (bChecked)
                 {
                     IPart part = bomNode.Part;
                     bool createNew = true;
                     /*if (!string.IsNullOrEmpty(bomNode.AlternativeItemGroup))
                     {
                         foreach (IFlatBOMItem item in flatBom.BomItems)
                         {
                             if (string.Compare(
                                     item.AlternativeItemGroup,
                                     bomNode.AlternativeItemGroup) == 0
                                 )
                             {
                                 item.AddAlterPart(part);
                                 createNew = false;
                                 break;
                             }
                         }
                     }*/
                     if (createNew)
                     {
                         //create new bomitem
                         var flatBOMItem = new FlatBOMItem(1, part_check_type, new List<IPart>());
                         flatBOMItem.AlterParts.Add(part);
                         flatBOMItem.AlternativeItemGroup = bomNode.AlternativeItemGroup;
                         flatBom.AddBomItem(flatBOMItem);
                     }
                 }
             }
         }
     }
     if (flatBom.BomItems.Count > 0)
     {
         foreach (IFlatBOMItem item in flatBom.BomItems)
         {
             item.Tp = item.AlterParts.First().BOMNodeType;
             item.Descr = item.AlterParts.First().Descr;
             string pnString = string.Empty;
             foreach (IPart part in item.AlterParts)
             {
                 if (pnString.Length == 0)
                 {
                     pnString = GetVenderCodeValue(part);
                 }
                 else
                 {
                     pnString += "," + GetVenderCodeValue(part);
                 }
             }
             item.PartNoItem = pnString;
         }
         return flatBom;
     }
     return null;
 }
Пример #17
0
        public object FilterBOM(object hierarchical_bom, string station, object main_object)
        {
            IList<IFlatBOMItem> flat_bom_items = new List<IFlatBOMItem>();
            
            IList<AstRuleInfo> share_parts_set = new List<AstRuleInfo>();
        
            IFlatBOM ret = null;
            if (hierarchical_bom == null)
            {
                throw new ArgumentNullException();
            }
            HierarchicalBOM bom = (HierarchicalBOM)hierarchical_bom;

            try
            {
                if (bom.FirstLevelNodes != null)
                {
                    IList<string> astCategoryList = new List<string> { "AT", "PP" }; 
                    List<astItemRule> astItemRuleList = new List<astItemRule>();
                    var atPartList = (from p in bom.FirstLevelNodes
                                      where astCategoryList.Contains(p.Part.BOMNodeType)
                                      select p.Part);

                    foreach (IPart part in atPartList)
                    {
                        var avPart = (from p in part.Attributes
                                      where p.InfoType == "AV"
                                      select p.InfoValue).FirstOrDefault();
                        if (!string.IsNullOrEmpty(avPart))
                        {
                            astItemRuleList.Add(new astItemRule {  Code =part.Descr,
                                                               AVPartNo = avPart,
                                                               Part = part
                            });
                        }
                    }
                    IProduct product=GetProduct(main_object);
                    IProductRepository prodRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
                    foreach (astItemRule item in astItemRuleList)
                    {
                        IList<AstRuleInfo> astruleList = prodRep.GetAstRuleByCodeAndStationAndCust(item.Code, station, item.AVPartNo);
                        if (astruleList.Count > 0)
                        {
                            foreach (AstRuleInfo rule in astruleList)
                            {
                                AstRuleInfo info = CheckAstRule(rule, product, item.Part);
                                if (info != null)
                                {
                                    share_parts_set.Add(info);
                                }
                            }
                        }
                        else  //料號找不到後再找CustName為空白
                        {
                            astruleList = prodRep.GetAstRuleByCodeAndStationAndCust(item.Code, station, "");
                            foreach (AstRuleInfo rule in astruleList)
                            {
                                AstRuleInfo info = CheckAstRule(rule, product, item.Part);
                                if (info != null)
                                {
                                    share_parts_set.Add(info);
                                }
                            }
                        }
                    }
                  
                }

                if (share_parts_set.Count > 0)
                {
                    foreach (AstRuleInfo ruleInfo in share_parts_set)
                    {
                        IPart part = new Part()
                        {
                            PN = ruleInfo.code + "/" + ruleInfo.custName,      //PN要跟 flat_bom_item.PartNoItem值一樣                  
                            CustPn = ruleInfo.custName,
                             Remark="",
                            Descr = ruleInfo.custName + "/" + ruleInfo.checkItem,
                             Descr2="",
                            Type = ruleInfo.code,
                             Udt= DateTime.Now,
                             Cdt=DateTime.Now
                        };
                        var flat_bom_item = new FlatBOMItem(qty, part_check_type, new List<IPart>(){part});
                        flat_bom_item.PartNoItem = ruleInfo.code + "/" + ruleInfo.custName; 
                        flat_bom_item.Tp =  ruleInfo.code;
                        flat_bom_item.Descr = ruleInfo.custName + "/" + ruleInfo.checkItem;
                        flat_bom_item.ValueType = ruleInfo.remark; //存放Part match時檢查的值
                        flat_bom_items.Add(flat_bom_item);
                    }
                }
                if (flat_bom_items.Count > 0)
                {
                    ret = new FlatBOM(flat_bom_items);
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return ret;
        }        
Пример #18
0
        public object FilterBOM(object hierarchical_bom, string station, object main_object)
        {
            IList<IFlatBOMItem> flat_bom_items = new List<IFlatBOMItem>();
            Hashtable share_parts_set = new Hashtable();
            Hashtable descr_share_parts_set = new Hashtable();
            Hashtable share_part_no_set = new Hashtable();
            IFlatBOM ret = null;
            if (hierarchical_bom == null)
            {
                throw new ArgumentNullException();
            }
            HierarchicalBOM bom = (HierarchicalBOM)hierarchical_bom;
            try
            {
                if (bom.FirstLevelNodes != null)
                {
                    for (int i = 0; i < bom.FirstLevelNodes.Count; i++)
                    {
                        if (CheckCondition(bom.FirstLevelNodes.ElementAt(i)))
                        {
                            IPart part = ((BOMNode) bom.FirstLevelNodes.ElementAt(i)).Part;
                            if (!share_parts_set.ContainsKey(part.Descr))
                            {
                                IList<IPart> parts = new List<IPart>();
                                parts.Add(part);
                                share_parts_set.Add(part.Descr, parts);
                                descr_share_parts_set.Add(part.Descr, part.Descr + "_" + part.PN);
                                if (part.PN.Substring(0, 3).Equals("DIB") )
                                {
                                    share_part_no_set.Add(part.Descr, part.PN.Substring(3,part.PN.Length-3));
                                }
                                else
                                {
                                    share_part_no_set.Add(part.Descr, part.PN);
                                }
                            }
                            else
                            {
                                ((IList<IPart>)share_parts_set[part.Descr]).Add(part);
                                if (!((string)share_part_no_set[part.Descr]).Contains(part.PN))
                                {
                                    if (part.PN.Substring(0, 3).Equals("DIB"))
                                    {
                                        share_part_no_set[part.Descr] += "," + part.PN.Substring(3,part.PN.Length-3);
                                    }
                                    else
                                    {
                                        share_part_no_set[part.Descr] += "," + part.PN;
                                    }
                                }
                            }
                        }
                    }
                }
                if (share_parts_set.Count > 0)
                {
                    foreach (DictionaryEntry de in share_parts_set)
                    {
                        var flat_bom_item = new FlatBOMItem(qty, part_check_type, (IList<IPart>)de.Value);
                        flat_bom_item.PartNoItem = (string) share_part_no_set[de.Key];
                        flat_bom_item.Tp = "C2";
                        flat_bom_item.Descr = (string) descr_share_parts_set[de.Key];
                        flat_bom_items.Add(flat_bom_item);
                    }
                }
                if (flat_bom_items.Count > 0)
                {
                    ret = new FlatBOM(flat_bom_items);
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return ret;
        }
Пример #19
0
        public object FilterBOM(object hierarchical_bom, string station, object main_object)
        {
            
            IFlatBOM ret = null;
            Hashtable share_parts_set = new Hashtable();
            Hashtable qty_set = new Hashtable();
            Hashtable descr_parts_set = new Hashtable();

            if (hierarchical_bom == null)
            {
                throw new ArgumentNullException();
            }
            var bom = (HierarchicalBOM)hierarchical_bom;

            try
            {
                if (bom.FirstLevelNodes != null)
                {
                    for (int i = 0; i < bom.FirstLevelNodes.Count; i++)
                    {
                        if (CheckCondition(bom.FirstLevelNodes.ElementAt(i)))
                        {
                            IPart part = ((BOMNode) bom.FirstLevelNodes.ElementAt(i)).Part;
                            if (part != null)
                            {
                                if (part.PN.Trim().Substring(0, 5).Equals("DUMMY"))
                                {
                                    IList<PartInfo> part_infos = part.Attributes;
                                    if (part_infos != null)
                                    {
                                        foreach (PartInfo part_info in part_infos)
                                        {
                                            if (part_info.InfoType.Trim().Equals("PN"))
                                            {
                                                part.SetKey(part.PN);
                                                part.PN = part_info.InfoValue;
                                                break;
                                            }
                                        }
                                    }
                                }
                                if (!part.PN.Substring(0,3).Equals("MMI"))
                                {
                                    if (share_parts_set.ContainsKey(part.PN))
                                    {
                                        ((IList<IPart>)share_parts_set[part.PN]).Add(part);
                                        qty_set[part.PN] = ((BOMNode)bom.FirstLevelNodes.ElementAt(i)).Qty;
                                        descr_parts_set[part.PN] = "," + part.Descr;
                                    }
                                    else
                                    {
                                        IList<IPart> parts = new List<IPart>();
                                        parts.Add(part);
                                        share_parts_set.Add(part.PN, parts);
                                        qty_set.Add(part.PN, ((BOMNode)bom.FirstLevelNodes.ElementAt(i)).Qty);
                                        descr_parts_set.Add(part.PN,part.Descr);
                                    }
                                }
                            }
                        }
                    }
                }
//                if (parts.Count > 0)
//                {
//                    IList<IFlatBOMItem> flat_bom_items = new List<IFlatBOMItem>();
//                    foreach (IPart part in parts)
//                    {
//                        IList<IPart> bom_item_parts = new List<IPart>();
//                        bom_item_parts.Add(part);
//                        var flat_bom_item = new FlatBOMItem(qty, part_check_type, bom_item_parts);
//                        flat_bom_item.PartNoItem = part.PN;
//                        flat_bom_item.Descr = part.Descr;
//                        flat_bom_item.Model = bom.Model;
//                        flat_bom_items.Add(flat_bom_item);
//                    }
//                    ret = new FlatBOM(flat_bom_items);
//                }
                if (share_parts_set.Count > 0)
                {
                    IList<IFlatBOMItem> flat_bom_items = new List<IFlatBOMItem>();
                    foreach (DictionaryEntry de in share_parts_set)
                    {
                        var flat_bom_item = new FlatBOMItem((int) qty_set[de.Key], part_check_type, (IList<IPart>)de.Value);
                        flat_bom_item.PartNoItem = (string)de.Key;
                        flat_bom_item.Descr = (string)descr_parts_set[de.Key];
                        flat_bom_item.Model = bom.Model;
                        flat_bom_items.Add(flat_bom_item);
                    }
                    if (flat_bom_items.Count > 0)
                    {
                        ret = new FlatBOM(flat_bom_items);
                    }
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return ret;
        }
Пример #20
0
        /// <summary>
        /// light on
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {

            //find current station descr
            var StationRepository = RepositoryFactory.GetInstance().GetRepository<IStationRepository, IStation>();
            IStation currentStation = StationRepository.Find(Station);
            if (currentStation == null || string.IsNullOrEmpty(currentStation.Descr))
            {
                throw new FisException("PKIT01", new string[] { Station });
            }
            string currentStationDescr = currentStation.Descr;
            CurrentSession.AddValue(Session.SessionKeys.StationDescr, currentStationDescr);

            IStation Kit6Station = StationRepository.Find(DDDKitStation6);
            if (Kit6Station == null || string.IsNullOrEmpty(Kit6Station.Descr))
            {
                throw new FisException("PKIT01", new string[] { DDDKitStation6 });
            }

            //Check BSam Kit Station 必須要有PK04 站
            string isBsamModel=CurrentSession.GetValue(ExtendSession.SessionKeys.IsBSamModel) as string;
            IStation Kit4Station = null;
            if (!string.IsNullOrEmpty(isBsamModel) && isBsamModel == "Y")
            {
                Kit4Station = StationRepository.Find(DDDKitStation4);
                if (Kit4Station == null || string.IsNullOrEmpty(Kit4Station.Descr))
                {
                    throw new FisException("PKIT01", new string[] { DDDKitStation4 });
                }
            }
            else
            {
                isBsamModel = "N";
            }
            //////////////////////

            IProduct currentProduct = CurrentSession.GetValue(Session.SessionKeys.Product) as Product;

            //Get all wipbuffer for all station, this line
            var productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            IList<WipBuffer> allWipbufList = productRepository.GetWipBufferByKittingTypeAndCode("PAK Kitting", Line.Substring(0, 1));
            if (allWipbufList == null || allWipbufList.Count == 0)
            {
                if (!string.IsNullOrEmpty(isBsamModel) && isBsamModel == "Y" && DDDKitStation6.Equals(Station)) // BSam Kittig 6
                {
                    IFlatBOM emptyBom = new FlatBOM();
                    CurrentSession.AddValue(Session.SessionKeys.SessionBom, emptyBom);
                    return base.DoExecute(executionContext);
                }
                else
                    throw new FisException("PKIT03", new string[] { });
            }

            // from wipbuffer maintain station list get nextstation should go
            string ShouldGoStation = "";
            int ShouldStationIndex = -1;
            string pkStation = "-PK01-PK02-PK03-PK04-PK05-PKOK-";
            List<string> stationList = (from tempWip in allWipbufList
                                        orderby tempWip.Station
                                        select tempWip.Station).Distinct<string>().ToList<string>();

            // Vincent 2013-01-25 add check Bsam Model & Kitting 4Station case 
            // add Kitting Station 4 Descr and reorder list
            if (isBsamModel=="Y" && !stationList.Contains(Kit4Station.Descr))
            {
                stationList.Add(Kit4Station.Descr);
            }
            /////////////////////////////////

            
            if (!stationList.Contains(Kit6Station.Descr))
            {
                stationList.Add(Kit6Station.Descr);
            }

            if (pkStation.Contains("-" + currentProduct.Status.StationId + "-"))
            {
                IStation preStation = StationRepository.Find(currentProduct.Status.StationId);
                if (preStation == null || string.IsNullOrEmpty(preStation.Descr))
                {
                    throw new FisException("PKIT01", new string[] { currentProduct.Status.StationId });
                }
                string preStationDescr = preStation.Descr;


                for (int i = 0; i < stationList.Count() - 1; i++)
                {
                    if (stationList.ElementAt(i) == preStationDescr)
                    {
                        ShouldStationIndex = i + 1;
                        ShouldGoStation = stationList.ElementAt(i + 1);
                        break;
                    }
                }
            }
            else
            {
                ShouldStationIndex = 0;
                ShouldGoStation = stationList.ElementAt(0);
            }

            // if can't get next station should go,then set next station is kit6
            //Vincent comment: never happen this case, don't care this case
            if (ShouldStationIndex == -1)
            {
                // Vincent 2013-01-25 add check Bsam Model & Kitting 4Station case 
                // Get kittin station 4 first
                ShouldStationIndex = stationList.Count();


                ShouldGoStation = Kit6Station.Descr;
            }

            IFlatBOM totalBom = (IFlatBOM)CurrentSession.GetValue(Session.SessionKeys.SessionBom);

            // if next station doesn't contain any part in wippbuffer, then get next station of this station
            for (int i = ShouldStationIndex; i < stationList.Count() - 1; i++)
            {
                if (ShouldGoStation != currentStationDescr)
                {

                    // Vincent 2013-01-25 add check Bsam Model & Kitting 4 Station case 
                    // 不需要檢查BOM資料,一定要到第四站 show exception code PKIT02
                    if (isBsamModel == "Y" && ShouldGoStation == Kit4Station.Descr)
                    {
                        throw new FisException("PKIT02", new string[] { ShouldGoStation });
                    }

                    var shouldStationWBList = from tempWip in allWipbufList
                                              where tempWip.Station == ShouldGoStation
                                              select tempWip;

                    foreach (IFlatBOMItem bomItem in totalBom.BomItems)
                    {
                        bool match = false;
                        foreach (WipBuffer wipbufobj in shouldStationWBList)
                        {
                            if (PartMatchWipBuffer(wipbufobj.PartNo, bomItem.AlterParts))
                            {
                                match = true;
                                break;
                            }
                        }
                        if (match)
                        {
                            throw new FisException("PKIT02", new string[] { ShouldGoStation });
                        }
                    }                  
                   
                    ShouldStationIndex = ShouldStationIndex + 1;
                    ShouldGoStation = stationList.ElementAt(ShouldStationIndex);

                }
                else
                {
                    break;
                }
            }

            if (ShouldGoStation != currentStationDescr)
            {
                throw new FisException("PKIT02", new string[] { ShouldGoStation });
            }

            // Vincent 2013-01-25 add check Bsam Model & Kitting 4 Station case 
            // BSam Kittig 4 不需要抓BOM資料及WipBuffer 資料
            if (isBsamModel == "Y" && ShouldGoStation == Kit4Station.Descr)
            {
                return base.DoExecute(executionContext);
            }

            //get bom,current station wipbuffer
            IList<IFlatBOMItem> filteredBomItems = new List<IFlatBOMItem>();
            var wipbufObjs = from tempWip in allWipbufList
                             where tempWip.Station == ShouldGoStation
                             select tempWip;
            IList<WipBuffer> wipbufferList = new List<WipBuffer>();

            if (wipbufObjs != null)
            {
                wipbufferList = wipbufObjs.ToList<WipBuffer>();
            }


            IList<string> matchePnList = new List<string>();
            // kit6 get all part by remove kit1-5
            if (Station == DDDKitStation6)
            {
                //IE要在生产过程中随时调整WipBuffer, 这样可能造成已进入PizzaKitting流程的机器漏检料,
                //因此需要修改Kitting6获取待检料规则: 此前系统通过在ModelBOM中排除WipBuffer中定义在
                //Kitting1-5站收集的料得到Kitting6待检料;现在改为在ModelBOM中排除Pizza_Part表中已绑
                //定的Part得到Kitting6待检料
                Pizza pizzaObj = currentProduct.PizzaObj;
                if (pizzaObj != null && pizzaObj.PizzaParts != null)
                {
                    IList<int> removeIndexList = new List<int>();
                    foreach (var part in pizzaObj.PizzaParts)
                    {
                        if (pkStation.Contains(part.Station))
                        {
                            for (int j = 0; j < totalBom.BomItems.Count; j++)
                            {
                                if (PartMatchPizzaPart(part.PartID, totalBom.BomItems[j].AlterParts))
                                {
                                    removeIndexList.Add(j);
                                }
                            }
                        }
                    }
                    var sortedIndexList = (from tempIndex in removeIndexList
                                           orderby tempIndex descending
                                           select tempIndex).Distinct<int>();
                    for (int k = 0; k < sortedIndexList.Count(); k++)
                    {
                        totalBom.BomItems.RemoveAt(sortedIndexList.ElementAt<int>(k));
                    }
                }

                /*
                List<string> station15List = new List<string>();
                for (int i = 0; i < stationList.Count(); i++)
                {
                    if (stationList[i].Trim() == "DDD Kitting 1" || stationList[i].Trim() == "DDD Kitting 2" || stationList[i].Trim() == "DDD Kitting 3" || stationList[i].Trim() == "DDD Kitting 4" || stationList[i].Trim() == "DDD Kitting 5")
                    {
                        station15List.Add(stationList[i]);
                    }
                }
                for (int i = 0; i < station15List.Count(); i++)
                {

                    var wipbufObjtemp = from tempWip in allWipbufList
                                        where tempWip.Station == station15List.ElementAt(i)
                                        select tempWip;
                    if (wipbufObjtemp != null)
                    {
                        IList<int> removeIndexList = new List<int>();

                        foreach (WipBuffer wipbufobj in wipbufObjtemp)
                        {

                            for (int j = 0; j < totalBom.BomItems.Count; j++)
                            {
                                if (PartMatchWipBuffer(wipbufobj.PartNo, totalBom.BomItems[j].AlterParts))
                                {
                                    removeIndexList.Add(j);
                                }
                            }
                        }

                        var sortedIndexList = (from tempIndex in removeIndexList
                                               orderby tempIndex descending
                                               select tempIndex).Distinct<int>();
                        for (int k = 0; k < sortedIndexList.Count(); k++)
                        {
                            totalBom.BomItems.RemoveAt(sortedIndexList.ElementAt<int>(k));
                        }
                    }
                }
                */

                foreach (IFlatBOMItem bomItem in totalBom.BomItems)
                {
                    foreach (WipBuffer wipbufobj in wipbufObjs)
                    {
                        if (PartMatchWipBuffer(wipbufobj.PartNo, bomItem.AlterParts))
                        {
                            matchePnList.Add(wipbufobj.PartNo);
                        }
                    }
                }


                foreach (IFlatBOMItem bomItem in totalBom.BomItems)
                {
                    filteredBomItems.Add(bomItem);
                }
            }
            else
            {
                // kit 1-5,get part by wipbuffer cross bom 
                if (wipbufObjs == null || wipbufObjs.Count() == 0)
                {
                    var ex = new FisException("PKIT03", new string[] { });
                    throw ex;
                }


                foreach (IFlatBOMItem bomItem in totalBom.BomItems)
                {
                    bool match = false;
                    foreach (WipBuffer wipbufobj in wipbufObjs)
                    {
                        if (PartMatchWipBuffer(wipbufobj.PartNo, bomItem.AlterParts))
                        {
                            match = true;
                            matchePnList.Add(wipbufobj.PartNo);
                        }
                    }
                    if (match)
                    {
                        filteredBomItems.Add(bomItem);
                    }
                }
            }


            if (filteredBomItems == null || filteredBomItems.Count == 0)
            {
                if (!string.IsNullOrEmpty(isBsamModel) && isBsamModel == "Y" && DDDKitStation6.Equals(Station)) // BSam Kittig 6
                {
                    IFlatBOM emptyBom = new FlatBOM();
                    CurrentSession.AddValue(Session.SessionKeys.SessionBom, emptyBom);
                    return base.DoExecute(executionContext);
                }
                else
                    throw new FisException("PKIT03", new string[] { });
            }

            for (int i = wipbufferList.Count - 1; i >= 0; i--)
            {
                if (!matchePnList.Contains<string>(wipbufferList[i].PartNo))
                {
                    wipbufferList.RemoveAt(i);
                }
            }

            CurrentSession.AddValue(Session.SessionKeys.PizzaKitWipBuffer, wipbufferList);
            //replace with new bom
            IFlatBOM filteredBom = new FlatBOM(filteredBomItems);
            CurrentSession.AddValue(Session.SessionKeys.SessionBom, filteredBom);

            //light on
            if (wipbufferList != null && wipbufferList.Count() > 0)
            {
                IPalletRepository pltRepository = RepositoryFactory.GetInstance().GetRepository<IPalletRepository, Pallet>();
                List<string> TagIDList = new List<string>();
                foreach (WipBuffer wipbufobj in wipbufferList)
                {
                    IList<KittingLocPLMappingStInfo> kitlocstinfos = pltRepository.GetKitLocPLMapST(Line.Substring(0, 1), currentStationDescr, short.Parse(wipbufobj.LightNo));
                    if (kitlocstinfos != null && kitlocstinfos.Count > 0)
                    {
                        TagIDList.Add(kitlocstinfos[0].tagID);
                    }
                }
                pltRepository.UpdateKitLocationFVOnDefered(CurrentSession.UnitOfWork, TagIDList.ToArray<string>(), true, false, "1");
            }

            return base.DoExecute(executionContext);
        }
Пример #21
0
        public object FilterBOM(object hierarchical_bom, string station, object main_object)
        {
            IFlatBOM ret = null;
            IList<IFlatBOMItem> flat_bom_items = new List<IFlatBOMItem>();
            if (hierarchical_bom == null)
            {
                throw new ArgumentNullException();
            }
            HierarchicalBOM bom = (HierarchicalBOM)hierarchical_bom;
            Hashtable share_parts_set = new Hashtable();
            Hashtable share_part_no_set = new Hashtable();
            Hashtable part_no_set = new Hashtable();
            Hashtable qty_set = new Hashtable();
            Hashtable check_typ_set = new Hashtable();
            Hashtable descr_parts_set = new Hashtable();
            TreeTraversal tree_traversal = new TreeTraversal();
            IList<KPVendorCode> kpVCList = new List<KPVendorCode>();
            try
            {
/*
                IList<QtyParts> check_conditon_nodes_case_one = tree_traversal.BreadthFirstTraversal(bom.Root, "VK->P1->KP", "P1", this,"VK");
                //if (check_conditon_nodes_case_one != null && check_conditon_nodes_case_one.Count > 0)
                //{
                //    foreach (QtyParts check_conditon_node in check_conditon_nodes_case_one)
                //    {
                //        //替代料:
                //        //对于P1 Part 来说,Part.Descr 相同的记录是替代料,替代料的料号以逗号分隔,显示在Part No / Item Name列(包括主料);取替代料中Qty 最大的P1 Part 为主料
                //        //Qty:
                //        //对于Model-> VK-> P1-> KP 这种结构,P1 Part 的数量是VK Part 在ModelBOM 定义的数量乘以P1 Part在ModelBOM 定义的数量
                //        //对于Model -> VK -> KP 这种结构,P1 Part 的数量是VK Part 在ModelBOM 定义的数量乘以KP Part在ModelBOM 定义的数量


                //        FlatBOMItem item = new FlatBOMItem(check_conditon_node.Qty, part_check_type, check_conditon_node.Parts);
                //        flat_bom_items.Add(item);
                //    }  
                //}

                if (check_conditon_nodes_case_one != null && check_conditon_nodes_case_one.Count > 0)
                {
                    foreach (QtyParts bm_check_conditon_node in check_conditon_nodes_case_one)
                    {
                        if (bom.FirstLevelNodes != null) 
                        {
                            IList<IBOMNode> bom_nodes = bom.FirstLevelNodes;
                            foreach (IBOMNode bom_node in bom_nodes)
                            {
                                if (bom_node.Part != null && bom_node.Part.BOMNodeType.Equals("VK"))
                                {
                                    IList<IBOMNode> vk_child_nodes = bom_node.Children;
                                    if (vk_child_nodes != null)
                                    {
                                        foreach (IBOMNode vk_child_node in vk_child_nodes)
                                        {
                                            if (vk_child_node.Part  != null && vk_child_node.Part.BOMNodeType.Equals("P1"))
                                            {
                                                if (PartCompare(bm_check_conditon_node.Parts, vk_child_node.Part))
                                                {
                                                    String share_material_key = vk_child_node.Part.PN;
                                                    if (!string.IsNullOrEmpty(share_material_key))
                                                    {
                                                        if (!check_typ_set.ContainsKey(share_material_key))
                                                        {
                                                            check_typ_set.Add(share_material_key,"P1");
                                                        }

                                                        IList<IBOMNode> p1_child_nodes = vk_child_node.Children;
                                                        if (p1_child_nodes != null)
                                                        {
                                                            foreach (IBOMNode p1_child_node in p1_child_nodes)
                                                            {
                                                                if (p1_child_node.Part != null &&
                                                                    p1_child_node.Part.BOMNodeType.Equals("KP"))
                                                                {
                                                                    IList<PartInfo> part_infos =p1_child_node.Part.Attributes;
                                                                    if (part_infos != null && part_infos.Count > 0)
                                                                    {
                                                                        foreach (PartInfo part_info in part_infos)
                                                                        {
                                                                            if (part_info.InfoType.Equals("VendorCode"))
                                                                            {
                                                                                vk_child_node.Part.AddAttribute(part_info);
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }

                                                        if (share_parts_set.ContainsKey(share_material_key))
                                                        {
                                                            part_no_set[share_material_key] += "," + vk_child_node.Part.PN;
                                                            ((IList<IPart>) share_parts_set[share_material_key]).Add(vk_child_node.Part);
                                                            int qty = getMaxQty(check_conditon_nodes_case_one,vk_child_node.Part);
                                                            if ((int) qty_set[share_material_key] < qty)
                                                            {
                                                                qty_set[share_material_key] = qty;
                                                            }
                                                        }
                                                        else
                                                        {
                                                            part_no_set.Add(share_material_key, vk_child_node.Part.PN);
                                                            IList<IPart> parts = new List<IPart>();
                                                            parts.Add(vk_child_node.Part);
                                                            share_parts_set.Add(share_material_key, parts);
                                                            int qty = getMaxQty(check_conditon_nodes_case_one,vk_child_node.Part);
                                                            qty_set.Add(share_material_key, qty);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }



                IList<QtyParts> check_conditon_nodes_case_two = tree_traversal.BreadthFirstTraversal(bom.Root, "VK->KP", "KP", this,"VK");
                IBOMRepository bom_repository = RepositoryFactory.GetInstance().GetRepository<IBOMRepository>();

                if (check_conditon_nodes_case_two != null)
                {
                    foreach (QtyParts qty_part in check_conditon_nodes_case_two)
                    {
                        IList<IPart> parts = qty_part.Parts;
                        if (parts != null)
                        {
                            foreach (IPart part in parts)
                            {
                                IList<IBOMNode> parent_boms = bom_repository.GetParentBomNode(part.PN);
                                if (parent_boms != null)
                                {
                                    foreach (IBOMNode flat_bom_item in parent_boms)
                                    {
                                        IPart parent_part = flat_bom_item.Part;
                                        if (parent_part != null && parent_part.BOMNodeType.Trim().Equals("P1"))
                                        {
                                            //IList<IPart> p1_parts = new List<IPart>();
                                            //p1_parts.Add(part);
                                            //var item = new FlatBOMItem(qty_part.Qty, part_check_type, p1_parts);
                                            //item.PartNoItem = part.PN;
                                            //item.Descr = part.Descr;
                                            //flat_bom_items.Add(item);
                                            IList<PartInfo> part_infos = part.Attributes;
                                            if (part_infos != null && part_infos.Count > 0)
                                            {
                                                foreach (PartInfo part_info in part_infos)
                                                {
                                                    if (part_info.InfoType.Equals("VendorCode"))
                                                    {
                                                        parent_part.AddAttribute(part_info);
                                                    }
                                                }
                                            }
                                            String share_material_key = parent_part.PN;
                                            if (!string.IsNullOrEmpty(share_material_key))
                                            {
                                                if (!check_typ_set.ContainsKey(share_material_key))
                                                {
                                                    check_typ_set.Add(share_material_key, "P1");
                                                }
                                                if (share_parts_set.ContainsKey(share_material_key))
                                                {
                                                    part_no_set[share_material_key] += "," + parent_part.PN;
                                                    ((IList<IPart>) share_parts_set[share_material_key]).Add(parent_part);
                                                    int qty = getMaxQty(check_conditon_nodes_case_two, parent_part);
                                                    if ((int) qty_set[share_material_key] < qty)
                                                    {
                                                        qty_set[share_material_key] = qty;
                                                    }
                                                }
                                                else
                                                {
                                                    part_no_set.Add(share_material_key, parent_part.PN);
                                                    IList<IPart> sparts = new List<IPart>();
                                                    sparts.Add(parent_part);
                                                    share_parts_set.Add(share_material_key, sparts);
                                                    int qty = getMaxQty(check_conditon_nodes_case_two, parent_part);
                                                    qty_set.Add(share_material_key, qty);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
*/
                List<QtyParts> c2_check_conditon_nodes = new List<QtyParts>();
                if (bom.FirstLevelNodes != null)
                {
                    for (int i = 0; i < bom.FirstLevelNodes.Count; i++)
                    {
                        if (bom.FirstLevelNodes.ElementAt(i).Part != null)
                        {
                            if (bom.FirstLevelNodes.ElementAt(i).Part.BOMNodeType.Equals("C2"))
                            {
                                IList<PartInfo> part_infos = bom.FirstLevelNodes.ElementAt(i).Part.Attributes;
                                Boolean have_vendor_code = false;

                                if (part_infos != null && part_infos.Count > 0)
                                {
                                    foreach (PartInfo part_info in part_infos)
                                    {
                                        if (part_info.InfoType.Equals("VendorCode"))
                                        {
                                            have_vendor_code = true;
                                            break;
                                        }
                                    }
                                }
                                
                                Hashtable dib_share_part_infos = new Hashtable();
                                IPartRepository repository = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
                                if (!have_vendor_code)
                                {
                                    if (bom.FirstLevelNodes.ElementAt(i).Part.PN.Length>=3 &&  bom.FirstLevelNodes.ElementAt(i).Part.PN.Trim().Substring(0, 3).Equals("DIB"))
                                    {
                                        string part_pn = bom.FirstLevelNodes.ElementAt(i).Part.PN.Trim();
                                       // IPartRepository repository = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
                                        IPart dib_part = repository.GetPartByPartNo(part_pn.Substring(3, part_pn.Length-3));
                                        if (dib_part != null)
                                        {
                                            IList<PartInfo> dib_part_infos = dib_part.Attributes;
                                            if (dib_part_infos != null && dib_part_infos.Count > 0)
                                            {
                                                foreach (PartInfo dib_part_info in dib_part_infos)
                                                {
                                                    if (dib_part_info.InfoType.Equals("VendorCode"))
                                                    {
                                                        have_vendor_code = true;
                                                        //bom.FirstLevelNodes.ElementAt(i).Part.AddAttribute(dib_part_info);
                                                        kpVCList.Add(new KPVendorCode
                                                        {
                                                            PartNo = bom.FirstLevelNodes.ElementAt(i).Part.PN,
                                                            VendorCode = dib_part_info.InfoValue
                                                        });
                                                        break;
                                                    }
                                                }
                                            }
                                        }
                                        //IPart part = bom.FirstLevelNodes.ElementAt(i).Part;
//                                        IList<PartInfo> sub_part_infos = bom.FirstLevelNodes.ElementAt(i).Part.Attributes;
//                                        if (sub_part_infos != null && sub_part_infos.Count > 0)
//                                        {
//                                            PartInfo need_vendor_code = null;
//                                            foreach (PartInfo sub_part_info in sub_part_infos)
//                                            {
//                                                if (sub_part_info.InfoType.Equals("SUB"))
//                                                {
//                                                    string[] part_pns = sub_part_info.InfoValue.Trim().Split(';');
//                                                    for (int j = 0; j < part_pns.Length;j++ )
//                                                    {
//                                                        if (part_pns[j].Length > 3 && part_pns[j].Substring(0, 3).Equals("DIB"))
//                                                        {
//                                                            IPart sub_dib_part = repository.GetPartByPartNo(part_pns[j].Substring(3, part_pns[j].Length - 3));
//                                                            if (sub_dib_part != null)
//                                                            {
//                                                                IList<PartInfo> sub2_part_infos = sub_dib_part.Attributes;
//                                                                if (sub2_part_infos != null && sub2_part_infos.Count > 0)
//                                                                {
//                                                                    foreach (PartInfo sub2_part_info in sub2_part_infos)
//                                                                    {
//                                                                        if (sub2_part_info.InfoType.Equals("VendorCode"))
//                                                                        {
//                                                                            have_vendor_code = true;
//                                                                            need_vendor_code = sub2_part_info;
////                                                                            if (dib_share_part_infos.ContainsKey(part_pns[j]))
////                                                                            {
////                                                                                ((IList<PartInfo>)dib_share_part_infos[part_pns[j]]).Add(sub2_part_info);
////                                                                            }
////                                                                            else
////                                                                            {
////                                                                                IList<PartInfo> dib_tmp_part_infos = new List<PartInfo>();
////                                                                                dib_tmp_part_infos.Add(sub2_part_info);
////                                                                                dib_share_part_infos.Add(part_pns[j], dib_tmp_part_infos);
////                                                                            }
//                                                                            break;
//                                                                        }
//                                                                    }
//                                                                }
//                                                            }
//                                                        }
//                                                        else
//                                                        {
//                                                            IPart sub_dib_part = repository.GetPartByPartNo(part_pns[j]);
//                                                            if (sub_dib_part != null)
//                                                            {
//                                                                IList<PartInfo> sub2_part_infos = sub_dib_part.Attributes;
//                                                                if (sub2_part_infos != null && sub2_part_infos.Count > 0)
//                                                                {
//                                                                    foreach (PartInfo sub2_part_info in sub2_part_infos)
//                                                                    {
//                                                                        if (sub2_part_info.InfoType.Equals("VendorCode"))
//                                                                        {
//                                                                            have_vendor_code = true;
//                                                                            need_vendor_code = sub2_part_info;
////                                                                            if (dib_share_part_infos.ContainsKey(part_pns[j]))
////                                                                            {
////                                                                                ((IList<PartInfo>)dib_share_part_infos[part_pns[j]]).Add(sub2_part_info);
////                                                                            }
////                                                                            else
////                                                                            {
////                                                                                dib_share_part_infos.Add(part_pns[j], sub2_part_info);
////                                                                            }
//                                                                            break;
//                                                                        }
//                                                                    }
//                                                                }
//                                                            }
//                                                        }
//                                                    }
//                                                }
//                                            }
//                                            if (need_vendor_code != null)
//                                            {
//                                                bom.FirstLevelNodes.ElementAt(i).Part.AddAttribute(need_vendor_code);
//                                            }
//                                        }
                                    }
                                }
 
                                if (have_vendor_code)
                                {
                                    List<IPart> parts = new List<IPart>();
                                    parts.Add(bom.FirstLevelNodes.ElementAt(i).Part);
//                                    if (dib_share_part_infos.Count > 0)
//                                    {
//                                        foreach (DictionaryEntry de in dib_share_part_infos)
//                                        {
//                                            IPart dib_part = repository.GetPartByPartNo((string)de.Key);
//                                            if (dib_part != null)
//                                            {
//                                                IList<PartInfo> dib_share_part_set = (IList<PartInfo>) dib_share_part_infos[de.Key];
//                                                foreach (PartInfo dib_share_part_info in dib_share_part_set)
//                                                {
//                                                    dib_part.AddAttribute(dib_share_part_info);
//                                                }
//                                                parts.Add(dib_part);
//                                            }
//                                        }
//                                    }
                                    QtyParts bom_item = new QtyParts(bom.FirstLevelNodes.ElementAt(i).Qty, parts);
                                    c2_check_conditon_nodes.Add(bom_item);
                                }
                            }
                        }
                    }
                }


                if (c2_check_conditon_nodes.Count > 0)
                {
                    foreach (QtyParts c2_check_conditon_node in c2_check_conditon_nodes)
                    {
                        if (bom.FirstLevelNodes != null)
                        {
                            IList<IBOMNode> bom_nodes = bom.FirstLevelNodes;
                            foreach (IBOMNode bom_node in bom_nodes)
                            {
                                if (bom_node.Part != null && bom_node.Part.BOMNodeType.Equals("C2"))
                                {
                                    String share_material_key = bom_node.Part.PN;

                                    if (!check_typ_set.ContainsKey(share_material_key))
                                    {
                                        check_typ_set.Add(share_material_key, "C2");
                                    }
                                    if (PartCompare(c2_check_conditon_node.Parts, bom_node.Part))
                                    {
                                        Boolean exist_share_part = false;
                                        //parts.Add(part);
                                        IList<PartInfo> part_infos = bom_node.Part.Attributes;
                                        if (part_infos != null && part_infos.Count > 0)
                                        {
                                            foreach (PartInfo part_info in part_infos)
                                            {
                                                if (part_info.InfoType.Equals("SUB"))
                                                {
//                                                    exist_share_part = true;
                                                    String[] share_parts = part_info.InfoValue.Trim().Split(';');
                                                    if (share_parts.Length > 0)
                                                    {
                                                        string share_part_no = part_info.InfoValue.Trim();
                                                        share_part_no = share_part_no.Replace("DIB", "");
                                                        if (share_part_no_set.ContainsKey(bom_node.Part.PN))
                                                        {
                                                            share_part_no_set[bom_node.Part.PN] += "," + share_part_no.Replace(';',',');
                                                        }
                                                        else
                                                        {
                                                            share_part_no_set.Add(bom_node.Part.PN, share_part_no.Replace(';', ','));
                                                        }
                                                        
                                                        IPartRepository repository = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
                                                        IList<IPart> parts = new List<IPart>();
//                                                            parts.Add(bom_node.Part);
                                                        for (int j = 0; j < share_parts.Length; j++)
                                                        {
                                                            IPart share_part = null;
                                                            if (share_parts[j].Length >=3 && share_parts[j].Substring(0,3).Equals("DIB"))
                                                            {
                                                                share_part = repository.GetPartByPartNo(share_parts[j]);
                                                                IPart real_part = repository.GetPartByPartNo(share_parts[j].Substring(3, share_parts[j].Length - 3));
                                                                if (share_part != null && real_part != null)
                                                                {
                                                                    IList<PartInfo> sub2_part_infos = real_part.Attributes;
                                                                    if (sub2_part_infos != null && sub2_part_infos.Count > 0)
                                                                    {
                                                                        foreach (PartInfo sub2_part_info in sub2_part_infos)
                                                                        {
                                                                            if (sub2_part_info.InfoType.Equals("VendorCode"))
                                                                            {
                                                                                //share_part.AddAttribute(sub2_part_info);
                                                                                kpVCList.Add(new KPVendorCode
                                                                                {
                                                                                    PartNo = share_part.PN,
                                                                                    VendorCode = sub2_part_info.InfoValue
                                                                                }
                                                                                );
                                                                                break;
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                            else
                                                            {
                                                                share_part = repository.GetPartByPartNo(share_parts[j]);
                                                            }
                                                            if (share_part != null)
                                                            {
                                                                parts.Add(share_part);
                                                            }
                                                        }
                                                        String share_parts_code = bom_node.Part.PN;
                                                        if (!share_parts_set.ContainsKey(share_parts_code))
                                                        {
                                                            share_parts_set.Add(share_parts_code, parts);
                                                            qty_set.Add(share_parts_code, bom_node.Qty);
                                                            descr_parts_set.Add(share_parts_code, bom_node.Part.Descr);
                                                        }
                                                        else
                                                        {
//                                                                ((IList<IPart>)share_parts_set[share_parts_code]).Add(bom_node.Part);
                                                            if (parts.Count > 0)
                                                            {
                                                                foreach (IPart part in parts)
                                                                {
                                                                    ((IList<IPart>)share_parts_set[share_parts_code]).Add(part);      
                                                                }
                                                            }
                                                            
                                                            if (!((String)descr_parts_set[share_parts_code]).Contains(bom_node.Part.Descr))
                                                            {
                                                                descr_parts_set[share_parts_code] += "," + bom_node.Part.Descr;
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
//                                        if (!exist_share_part)
//                                        {
                                            if (!share_parts_set.ContainsKey(bom_node.Part.PN))
                                            {
                                                IList<IPart> parts = new List<IPart>();
//												if (bom_node.Part.PN.Substring(0,3).Equals("DIB"))
//												{
//                                                    IPartRepository repository = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
//                                                    IPart part = repository.GetPartByPartNo(bom_node.Part.PN.Substring(3, bom_node.Part.PN.Length - 3));
//                                                    parts.Add(part);
//												}
//												else
//												{
                                                    parts.Add(bom_node.Part);
//												}

                                                share_parts_set.Add(bom_node.Part.PN, parts);
                                                qty_set.Add(bom_node.Part.PN, bom_node.Qty);
                                                descr_parts_set.Add(bom_node.Part.PN, bom_node.Part.Descr);
                                            }
                                            else
                                            {
//                                                if (bom_node.Part.PN.Substring(0, 3).Equals("DIB"))
//                                                {
//                                                    IPartRepository repository = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
//                                                    IPart part = repository.GetPartByPartNo(bom_node.Part.PN.Substring(3, bom_node.Part.PN.Length - 3));
//                                                    ((IList<IPart>)share_parts_set[bom_node.Part.PN]).Add(part);
//                                                }
//                                                else
//                                                {
                                                    ((IList<IPart>)share_parts_set[bom_node.Part.PN]).Insert(0, bom_node.Part);
//                                                }
                                                
                                                if (!((String)descr_parts_set[bom_node.Part.PN]).Contains(bom_node.Part.Descr))
                                                {
                                                    descr_parts_set[bom_node.Part.PN] += "," + bom_node.Part.Descr;
                                                }
                                            }
//                                        }
//                                        else
//                                        {
//                                            //开头不是DIB的Part,要将自身加入到share_parts_set中。
//                                            if (!bom_node.Part.PN.Substring(0, 3).Equals("DIB"))
//                                            {
//                                                ((IList<IPart>)share_parts_set[bom_node.Part.PN]).Add(bom_node.Part);
//                                                if (!((String)descr_parts_set[bom_node.Part.PN]).Contains(bom_node.Part.Descr))
//                                                {
//                                                    descr_parts_set[bom_node.Part.PN] += "," + bom_node.Part.Descr;
//                                                }
//                                            }
//                                        }
                                    }
                                }
                            }
                        }
                    }
                }



                if (share_parts_set.Count > 0)
                {
                    foreach (DictionaryEntry  de in share_parts_set)
                    {
                        var flat_bom_item = new FlatBOMItem((int)qty_set[de.Key],part_check_type , (IList<IPart>)de.Value);
                        flat_bom_item.Tag = kpVCList;
                        if (share_part_no_set.ContainsKey(de.Key))
                        {
//                            if (((String)de.Key).Substring(0,3).Equals("DIB"))
//                            {
//                                flat_bom_item.PartNoItem = ((string)share_part_no_set[de.Key]).Replace("DIB","");
//                            }
//                            else
//                            {
                                flat_bom_item.PartNoItem = (String)de.Key + "," + (string)share_part_no_set[de.Key];
                                flat_bom_item.PartNoItem = flat_bom_item.PartNoItem.Replace("DIB", "");
//                            }
                        }
                        else
                        {
                            if (part_no_set.ContainsKey(de.Key))
                            {
                                flat_bom_item.PartNoItem = ((String)part_no_set[de.Key]).Replace("DIB", "");         
                            }
                            else
                            {
                                flat_bom_item.PartNoItem = ((string)de.Key).Replace("DIB", "");     
                            }
                        }
                        
                        flat_bom_item.Tp = (string) check_typ_set[de.Key];
                        if (descr_parts_set.ContainsKey(de.Key))
                        {
                            flat_bom_item.Descr = (string)descr_parts_set[de.Key];
                        }
                        else
                        {
                            flat_bom_item.Descr = (String)de.Key;    
                        }
                        flat_bom_items.Add(flat_bom_item);
                    }
                }
                if (flat_bom_items.Count > 0)
                {
                    ret = new FlatBOM(flat_bom_items);

                }
            }
            catch (Exception e)
            {
                throw;
            }

            return ret;
        }
Пример #22
0
        public object FilterBOM(object hierarchical_bom, string station, object main_object)
        {
            IList<IFlatBOMItem> flat_bom_items = new List<IFlatBOMItem>();
            Hashtable share_parts_set = new Hashtable();
            Hashtable share_part_no_set = new Hashtable();
            Hashtable qty_share_parts_set = new Hashtable();
            Hashtable descr_parts_set = new Hashtable();
            Hashtable check_typ_set = new Hashtable();
            //问题:station参数用不上。因为在hierarchicalBOM中,没有与station相关的字段。
            IFlatBOM ret = null;
            //int qty = 0;
            //var parts = new List<IPart>();
     
            if (hierarchical_bom == null)
            {
                throw new ArgumentNullException();
            }
            var bom = (HierarchicalBOM)hierarchical_bom;
            try
            {
                if (bom.FirstLevelNodes != null)
                {
                    for (int i = 0; i < bom.FirstLevelNodes.Count; i++)
                    {
                        IPart part = ((BOMNode)bom.FirstLevelNodes.ElementAt(i)).Part;
                        if (part != null &&  part.BOMNodeType.Trim().Equals("C2") )
                        {

                            if (CheckCondition(bom.FirstLevelNodes.ElementAt(i)))
                            {
                                Boolean exist_share_part = false;
                                IList<PartInfo> part_infos = part.Attributes;
                                if (part_infos != null && part_infos.Count > 0)
                                {
                                    foreach (PartInfo part_info in part_infos)
                                    {
                                        if (part_info.InfoType.Equals("SUB") && !string.IsNullOrEmpty(part_info.InfoValue))
                                        {
                                            exist_share_part = true;

                                            String[] share_parts = part_info.InfoValue.Trim().Split(';');
                                            if (share_parts.Length > 0)
                                            {
                                                string share_part_no = part_info.InfoValue.Trim();
                                                //                                                share_part_no = share_part_no.Replace("DIB", "");
                                                //                                                share_part_no_set.Add(part.PN, share_part_no.Replace(';', ','));
                                                if (share_part_no_set.ContainsKey(part.PN))
                                                {
                                                    share_part_no_set[part.PN] += "," + share_part_no.Replace(';', ',');
                                                }
                                                else
                                                {
                                                    share_part_no_set.Add(part.PN, share_part_no.Replace(';', ','));
                                                }
                                                IPartRepository repository = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
                                                IList<IPart> parts = new List<IPart>();
                                                parts.Add(part);
                                                for (int j = 0; j < share_parts.Length; j++)
                                                {
                                                    //                                                    IPart share_part = repository.GetPartByPartNo(share_parts[j]);
                                                    IPart share_part = null;
                                                    bool isC2WithoutVC = false;
                                                    if (share_parts[j].Substring(0, 3).Equals("DIB") && part.BOMNodeType.Trim().Equals("C2"))
                                                    {
                                                        share_part = repository.GetPartByPartNo(share_parts[j].Substring(3, share_parts[j].Length - 3));
                                                        if (share_part == null)
                                                        {
                                                            share_part = repository.GetPartByPartNo(share_parts[j]);
                                                        }
                                                        //if (share_part != null)
                                                        //{
                                                        //    IList<PartInfo> c2_dib_share_part_infos = share_part.Attributes;
                                                        //    if (c2_dib_share_part_infos != null)
                                                        //    {
                                                        //        bool have_vendor_code = false;
                                                        //        foreach (PartInfo c2_dib_share_part_info in c2_dib_share_part_infos)
                                                        //        {
                                                        //            if (c2_dib_share_part_info.InfoType.Equals("VendorCode"))
                                                        //            {
                                                        //                have_vendor_code = true;
                                                        //            }
                                                        //        }
                                                        //        if (!have_vendor_code)
                                                        //        {
                                                        //            isC2WithoutVC = true;
                                                        //            parts.Add(share_part);
                                                        //        }
                                                        //    }
                                                        //}
                                                    }
                                                    else
                                                    {
                                                        share_part = repository.GetPartByPartNo(share_parts[j]);
                                                    }
                                                    parts.Add(share_part);
                                                    //if (share_part != null && !isC2WithoutVC)
                                                    //{
                                                    //    parts.Add(share_part);
                                                    //}
                                                }
                                                String share_parts_code = part.PN;
                                                if (!share_parts_set.ContainsKey(share_parts_code))
                                                {
                                                    share_parts_set.Add(share_parts_code, parts);
                                                    qty_share_parts_set.Add(share_parts_code, ((BOMNode)bom.FirstLevelNodes.ElementAt(i)).Qty);
                                                    descr_parts_set.Add(share_parts_code, part.Descr);
                                                    check_typ_set.Add(share_parts_code, part.BOMNodeType.Trim());
                                                }
                                                else
                                                {
                                                    ((IList<IPart>)share_parts_set[share_parts_code]).Add(part);
                                                    if (!((String)descr_parts_set[share_parts_code]).Contains(part.Descr))
                                                    {
                                                        descr_parts_set[share_parts_code] += "," + part.Descr;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }

                                if (!exist_share_part)
                                {
                                    if (!share_parts_set.ContainsKey(part.PN))
                                    {
                                        IList<IPart> parts = new List<IPart>();
                                       
                                        parts.Add(part);
                                      
                                        share_parts_set.Add(part.PN, parts);
                                        qty_share_parts_set.Add(part.PN, ((BOMNode)bom.FirstLevelNodes.ElementAt(i)).Qty);
                                        descr_parts_set.Add(part.PN, part.Descr);
                                        check_typ_set.Add(part.PN, part.BOMNodeType.Trim());
                                    }
                                    else
                                    {
                                     
                                        ((IList<IPart>)share_parts_set[part.PN]).Add(part);
                            
                                        if (!((String)descr_parts_set[part.PN]).Contains(part.Descr))
                                        {
                                            descr_parts_set[part.PN] += "," + part.Descr;
                                        }
                                    }
                                }
                          
                            }
                        }
                    }

                    if (share_parts_set.Count > 0)
                    {
                        foreach (DictionaryEntry de in share_parts_set)
                        {
                            var flat_bom_item = new FlatBOMItem((int)qty_share_parts_set[de.Key], part_check_type, (IList<IPart>)de.Value);
                            if (share_part_no_set.ContainsKey(de.Key))
                            {
                                if (((string)de.Key).Substring(0, 3).Equals("DIB"))
                                {
                                    flat_bom_item.PartNoItem = ((string)de.Key).Substring(3, ((string)de.Key).Length - 3) + "," + (string)share_part_no_set[de.Key];
                                    flat_bom_item.PartNoItem = flat_bom_item.PartNoItem.Replace("DIB", "");
                                }
                                else
                                {
                                    flat_bom_item.PartNoItem = de.Key + "," + (string)share_part_no_set[de.Key];
                                    flat_bom_item.PartNoItem = flat_bom_item.PartNoItem.Replace("DIB", "");
                                }
                            }
                            else
                            {
                                //                                flat_bom_item.PartNoItem = (string)de.Key;
                                if (((string)de.Key).Substring(0, 3).Equals("DIB"))
                                {
                                    flat_bom_item.PartNoItem = ((string)de.Key).Substring(3, ((string)de.Key).Length - 3);
                                    flat_bom_item.PartNoItem = flat_bom_item.PartNoItem.Replace("DIB", "");
                                }
                                else
                                {
                                    flat_bom_item.PartNoItem = (string)de.Key;
                                    flat_bom_item.PartNoItem = flat_bom_item.PartNoItem.Replace("DIB", "");
                                }
                            }
                            flat_bom_item.Tp = (string)check_typ_set[de.Key];
                            flat_bom_item.Descr = (string)descr_parts_set[de.Key];
                            flat_bom_items.Add(flat_bom_item);
                        }
                    }
                    if (flat_bom_items.Count > 0)
                    {
                        ret = new FlatBOM(flat_bom_items);
                    }
                }
            }
            catch (Exception e)
            {
                throw;
            }

           return ret;
        }
Пример #23
0
        public object FilterBOM(object hierarchical_bom, string station, object main_object)
        {
            IList<IFlatBOMItem> flat_bom_items = new List<IFlatBOMItem>();
            Hashtable share_parts_set = new Hashtable();
            Hashtable share_part_no_set = new Hashtable();
            Hashtable qty_share_parts_set = new Hashtable();
            Hashtable descr_parts_set = new Hashtable();
            IFlatBOM ret = null;
            //var parts = new List<IPart>();
            if (hierarchical_bom == null)
            {
                throw new ArgumentNullException();
            }
            var bom = (HierarchicalBOM)hierarchical_bom;
            try
            {
                if (bom.FirstLevelNodes != null)
                {
                    for (int i = 0; i < bom.FirstLevelNodes.Count; i++)
                    {
                        IPart part = ((BOMNode) bom.FirstLevelNodes.ElementAt(i)).Part;
                        if (part.BOMNodeType.Trim().Equals("P1"))
                        {

                            if (CheckCondition(bom.FirstLevelNodes.ElementAt(i)))
                            {
                                Boolean exist_share_part = false;
                                //parts.Add(part);
                                IList<PartInfo> part_infos = part.Attributes;
                                if (part_infos != null && part_infos.Count > 0)
                                {
                                    foreach (PartInfo part_info in part_infos)
                                    {

                                        if (part_info.InfoType.Equals("SUB"))
                                        {
                                            exist_share_part = true;
                                            String[] share_parts = part_info.InfoValue.Trim().Split(';');
                                            if (share_parts.Length > 0)
                                            {
                                                string share_part_no = part_info.InfoValue.Trim();
                                                share_part_no_set.Add(part.PN, share_part_no.Replace(';', ','));
                                                IPartRepository repository = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
                                                IList<IPart> parts = new List<IPart>();
                                                parts.Add(part);
                                                for (int j = 0; j < share_parts.Length; j++)
                                                {
                                                    IPart share_part = repository.GetPartByPartNo(share_parts[j]);
                                                    if (share_part != null)
                                                    {
                                                        parts.Add(share_part);
                                                    }
                                                }
                                                String share_parts_code = part.PN;
                                                if (!share_parts_set.ContainsKey(share_parts_code))
                                                {
                                                    share_parts_set.Add(share_parts_code, parts);
                                                    qty_share_parts_set.Add(share_parts_code,((BOMNode)bom.FirstLevelNodes.ElementAt(i)).Qty);
                                                    descr_parts_set.Add(share_parts_code, part.Descr);
                                                }
                                                else
                                                {
                                                    ((IList<IPart>)share_parts_set[share_parts_code]).Add(part);
                                                    if (!((String)descr_parts_set[share_parts_code]).Contains(part.Descr))
                                                    {
                                                        descr_parts_set[share_parts_code] += "," + part.Descr;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                if (!exist_share_part)
                                {
                                    if (!share_parts_set.ContainsKey(part.PN))
                                    {
                                        IList<IPart> parts = new List<IPart>();
                                        parts.Add(part);
                                        share_parts_set.Add(part.PN, parts);
                                        qty_share_parts_set.Add(part.PN, ((BOMNode)bom.FirstLevelNodes.ElementAt(i)).Qty);
                                        descr_parts_set.Add(part.PN, part.Descr);
                                    }
                                    else
                                    {
                                        ((IList<IPart>)share_parts_set[part.PN]).Add(part);
                                        if (!((String)descr_parts_set[part.PN]).Contains(part.Descr))
                                        {
                                            descr_parts_set[part.PN] += "," + part.Descr;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                if (share_parts_set.Count > 0)
                {
                    foreach (DictionaryEntry de in share_parts_set)
                    {
                        var flat_bom_item = new FlatBOMItem((int)qty_share_parts_set[de.Key], part_check_type, (IList<IPart>)de.Value);
                        if (share_part_no_set.ContainsKey(de.Key))
                        {
                            flat_bom_item.PartNoItem = de.Key + "," + (string)share_part_no_set[de.Key];
                        }
                        else
                        {
                            flat_bom_item.PartNoItem = (string)de.Key;
                        }
                        flat_bom_item.Tp = "P1";
                        flat_bom_item.Descr = (string) descr_parts_set[de.Key];
                        flat_bom_items.Add(flat_bom_item);
                    }
                }
                if (flat_bom_items.Count > 0)
                {
                    ret = new FlatBOM(flat_bom_items);
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return ret;
        }
Пример #24
0
        public object FilterBOM(object hierarchical_bom, string station, object main_object)
        {
            //描述同上,不同的是(Descr like 'CD%' or  Descr like 'DVD%'or Descr like 'ODD%' or Descr like 'COMBO%'or  Descr like 'VCD%')

            IFlatBOM ret = null;
            IList<IFlatBOMItem> flat_bom_items = new List<IFlatBOMItem>();
            if (hierarchical_bom == null)
            {
                throw new ArgumentNullException();
            }
            var bom = (HierarchicalBOM)hierarchical_bom;
            Hashtable share_parts_set = new Hashtable();
            Hashtable descr_kp_part_set = new Hashtable();
            Hashtable info_value_string_set = new Hashtable();
            var tree_traversal = new TreeTraversal();
            try
            {
                //处理BM->KP情况
                IList<QtyParts> bm_check_conditon_nodes = tree_traversal.BreadthFirstTraversal(bom.Root, "BM->KP", "KP", this,"BM");
                IList<ShareMaterialType> material_type = FilterShareMaterialType(bm_check_conditon_nodes);
                if (bm_check_conditon_nodes != null && bm_check_conditon_nodes.Count > 0)
                {
                    foreach (QtyParts bm_check_conditon_node in bm_check_conditon_nodes)
                    {
                        if (bom.FirstLevelNodes != null) //当bom.Root.Part不为空时,Root是首阶
                        {
                            IList<IBOMNode> bom_nodes = bom.FirstLevelNodes;
                            foreach (IBOMNode bom_node in bom_nodes)
                            {
                                if (bom_node.Part.BOMNodeType.Equals("BM"))
                                {
                                    IList<IBOMNode> child_nodes = bom_node.Children;
                                    if (child_nodes != null)
                                    {
                                        foreach (IBOMNode child_node in child_nodes)
                                        {
                                            if (child_node.Part != null && child_node.Part.BOMNodeType.Equals("KP") && child_node.Part.Attributes != null)
                                            {
                                                if (PartCompare(bm_check_conditon_node.Parts, child_node.Part))
                                                {
                                                    if (material_type.Count > 0)
                                                    {
                                                        foreach (ShareMaterialType type in material_type)
                                                        {
                                                            if (child_node.Part.Descr.Equals(type.Descr) && bm_check_conditon_node.Qty == type.Qty)
                                                            {
                                                                String share_material_key = type.Qty.ToString() + type.Descr;

                                                          
                                                                if (!descr_kp_part_set.ContainsKey(share_material_key))
                                                                {
                                                                    descr_kp_part_set.Add(share_material_key, child_node.Part.Descr);
                                                                }
                                                                else
                                                                {
                                                                    if (!((String)descr_kp_part_set[share_material_key]).Contains(child_node.Part.Descr))
                                                                    {
                                                                        descr_kp_part_set[share_material_key] += "," + child_node.Part.Descr;
                                                                    }
                                                                }

                                                                IList<PartInfo> part_infos = child_node.Part.Attributes;
                                                                if (part_infos != null && part_infos.Count > 0)
                                                                {
                                                                    foreach (PartInfo part_info in part_infos)
                                                                    {
                                                                        if (part_info.InfoType.Equals("VendorCode"))
                                                                        {
                                                                            if (!info_value_string_set.ContainsKey(share_material_key))
                                                                            {
                                                                                info_value_string_set.Add(share_material_key, part_info.InfoValue);
                                                                            }
                                                                            else
                                                                            {
                                                                                if (!((String)info_value_string_set[share_material_key]).Contains(part_info.InfoValue))
                                                                                {
                                                                                    info_value_string_set[share_material_key] += "," + part_info.InfoValue;
                                                                                }
                                                                            }

                                                                            if (!share_parts_set.ContainsKey(share_material_key))
                                                                            {
                                                                                IList<IPart> share_parts = new List<IPart>();
                                                                                share_parts.Add(child_node.Part);
                                                                                share_parts_set.Add(share_material_key, share_parts);
                                                                            }
                                                                            else
                                                                            {
                                                                                ((IList<IPart>)share_parts_set[share_material_key]).Add(child_node.Part);
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    //if (material_type.Count > 0)
                    //{
                    //    foreach (ShareMaterialType type in material_type)
                    //    {
                    //        String share_material_key = type.Qty.ToString() + type.Descr;
                    //        var bm_flat_bom_item = new FlatBOMItem(type.Qty, part_check_type, (IList<IPart>)share_parts_set[share_material_key]);
                    //        bm_flat_bom_item.PartNoItem = (String)info_value_string_set[share_material_key];
                    //        bm_flat_bom_item.Descr = (String)descr_kp_part_set[share_material_key];
                    //        flat_bom_items.Add(bm_flat_bom_item);
                    //    }
                    //}

                }
                //处理P1->KP情况
                //descr_kp_part_set.Clear();
                //info_value_string_set.Clear();
                //share_parts_set.Clear();
                IList<QtyParts> p1_check_conditon_nodes = tree_traversal.BreadthFirstTraversal(bom.Root, "P1->KP", "KP", this,"P1");
                IList<ShareMaterialType> p1_material_type = FilterShareMaterialType(p1_check_conditon_nodes);
                foreach (ShareMaterialType type in p1_material_type)
                {
                    Boolean is_add = true;
                    foreach (ShareMaterialType mtype in material_type)
                    {
                        if (mtype.Descr.Trim().Equals(type.Descr.Trim()) && mtype.Qty == type.Qty)
                        {
                            is_add = false;
                            break;
                        }
                    }
                    if (is_add)
                    {
                        material_type.Add(type);
                    }
                }
                if (p1_check_conditon_nodes != null && p1_check_conditon_nodes.Count > 0)
                {
                    foreach (QtyParts bm_check_conditon_node in p1_check_conditon_nodes)
                    {
                        if (bom.FirstLevelNodes != null)
                        {
                            IList<IBOMNode> bom_nodes = bom.FirstLevelNodes;
                            foreach (IBOMNode bom_node in bom_nodes)
                            {
                                if (bom_node.Part.BOMNodeType.Equals("P1"))
                                {
                                    IList<IBOMNode> child_nodes = bom_node.Children;
                                    if (child_nodes != null)
                                    {
                                        foreach (IBOMNode child_node in child_nodes)
                                        {
                                            if (child_node.Part != null && child_node.Part.BOMNodeType.Equals("KP") && child_node.Part.Attributes != null)
                                            {
                                                if (PartCompare(bm_check_conditon_node.Parts, child_node.Part))
                                                {
                                                    if (material_type.Count > 0)
                                                    {
                                                        foreach (ShareMaterialType type in material_type)
                                                        {
                                                            if (child_node.Part.Descr.Equals(type.Descr) && bm_check_conditon_node.Qty == type.Qty)
                                                            {
                                                                String share_material_key = type.Qty.ToString() + type.Descr;

                                                                //if (!share_parts_set.ContainsKey(share_material_key))
                                                                //{
                                                                //    IList<IPart> share_parts = new List<IPart>();
                                                                //    share_parts.Add(child_node.Part);
                                                                //    share_parts_set.Add(share_material_key, share_parts);
                                                                //}
                                                                //else
                                                                //{
                                                                //    ((IList<IPart>)share_parts_set[share_material_key]).Add(child_node.Part);
                                                                //}
                                                                if (!descr_kp_part_set.ContainsKey(share_material_key))
                                                                {
                                                                    descr_kp_part_set.Add(share_material_key, child_node.Part.Descr);
                                                                }
                                                                else
                                                                {
                                                                    if (!((String)descr_kp_part_set[share_material_key]).Contains(child_node.Part.Descr))
                                                                    {
                                                                        descr_kp_part_set[share_material_key] += "," + child_node.Part.Descr;
                                                                    }
                                                                }

                                                                IList<PartInfo> part_infos = child_node.Part.Attributes;
                                                                if (part_infos != null && part_infos.Count > 0)
                                                                {
                                                                    foreach (PartInfo part_info in part_infos)
                                                                    {
                                                                        if (part_info.InfoType.Equals("VendorCode"))
                                                                        {
                                                                            if (!info_value_string_set.ContainsKey(share_material_key))
                                                                            {
                                                                                info_value_string_set.Add(share_material_key, part_info.InfoValue);
                                                                            }
                                                                            else
                                                                            {
                                                                                if (!((String)info_value_string_set[share_material_key]).Contains(part_info.InfoValue))
                                                                                {
                                                                                    info_value_string_set[share_material_key] += "," + part_info.InfoValue;
                                                                                }
                                                                            }
                                                                            if (!share_parts_set.ContainsKey(share_material_key))
                                                                            {
                                                                                IList<IPart> share_parts = new List<IPart>();
                                                                                share_parts.Add(child_node.Part);
                                                                                share_parts_set.Add(share_material_key, share_parts);
                                                                            }
                                                                            else
                                                                            {
                                                                                ((IList<IPart>)share_parts_set[share_material_key]).Add(child_node.Part);
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    //if (material_type.Count > 0)
                    //{
                    //    foreach (ShareMaterialType type in material_type)
                    //    {
                    //        String share_material_key = type.Qty.ToString() + type.Descr;
                    //        if (share_parts_set.ContainsKey(share_material_key))
                    //        {
                    //            var p1_flat_bom_item = new FlatBOMItem(type.Qty, part_check_type, (IList<IPart>)share_parts_set[share_material_key]);
                    //            p1_flat_bom_item.PartNoItem = (String)info_value_string_set[share_material_key];
                    //            p1_flat_bom_item.Descr = (String)descr_kp_part_set[share_material_key];
                    //            flat_bom_items.Add(p1_flat_bom_item);
                    //        }
                    //    }
                    //}
                }

                //处理首阶为KP情况
                //descr_kp_part_set.Clear();
                //info_value_string_set.Clear();
                //share_parts_set.Clear();
                List<IBOMNode> collect_gather_node = new List<IBOMNode>();
                List<QtyParts> kp_check_conditon_nodes = new List<QtyParts>();
               // IList<QtyParts> kp_check_conditon_nodes = tree_traversal.BreadthFirstTraversal(bom.Root, "KP", "KP", this,"KP");
                if (bom.FirstLevelNodes != null)
                {
                    for (int i = 0; i < bom.FirstLevelNodes.Count; i++)
                    {
                        if (bom.FirstLevelNodes.ElementAt(i).Part != null)
                        {
                            if (bom.FirstLevelNodes.ElementAt(i).Part.BOMNodeType.Equals("KP"))
                            {
                                if (CheckCondition(bom.FirstLevelNodes.ElementAt(i)))
                                {
                                    collect_gather_node.Add(bom.FirstLevelNodes.ElementAt(i));
                                    List<IPart> parts = new List<IPart>();
                                    parts.Add(bom.FirstLevelNodes.ElementAt(i).Part);
                                    QtyParts bom_item = new QtyParts(bom.FirstLevelNodes.ElementAt(i).Qty, parts);
                                    kp_check_conditon_nodes.Add(bom_item);
                                }
                            }
                        }
                    }
                }


                IList<ShareMaterialType> kp_material_type = FilterShareMaterialType(kp_check_conditon_nodes);
                foreach (ShareMaterialType type in kp_material_type)
                {
                    Boolean is_add = true;
                    foreach (ShareMaterialType mtype in material_type)
                    {
                        if (mtype.Descr.Trim().Equals(type.Descr.Trim()) && mtype.Qty == type.Qty)
                        {
                            is_add = false;
                            break;
                        }
                    }
                    if (is_add)
                    {
                        material_type.Add(type);
                    }
                }
                if ( kp_check_conditon_nodes.Count > 0)
                {
                    foreach (QtyParts bm_check_conditon_node in kp_check_conditon_nodes)
                    {
                        if (bom.FirstLevelNodes != null)
                        {
                            for (int i = 0; i < bom.FirstLevelNodes.Count; i++)
                            {
                                if (bom.FirstLevelNodes.ElementAt(i).Part != null)
                                {
                                    if (bom.FirstLevelNodes.ElementAt(i).Part.BOMNodeType.Equals("KP") && bom.FirstLevelNodes.ElementAt(i).Part.Attributes != null)
                                    {
                                        IBOMNode kp_node = bom.FirstLevelNodes.ElementAt(i);
                                        //if (CheckCondition(bom.FirstLevelNodes.ElementAt(i)))
                                        if (PartCompare(bm_check_conditon_node.Parts, kp_node.Part))
                                        {
                                            if (material_type.Count > 0)
                                            {
                                                foreach (ShareMaterialType type in material_type)
                                                {
                                                    if (kp_node.Part.Descr.Equals(type.Descr) && bm_check_conditon_node.Qty == type.Qty)
                                                    {
                                                        String share_material_key = type.Qty.ToString() + type.Descr;

                                                        if (!descr_kp_part_set.ContainsKey(share_material_key))
                                                        {
                                                            descr_kp_part_set.Add(share_material_key, kp_node.Part.Descr);
                                                        }
                                                        else
                                                        {
                                                            if (!((String)descr_kp_part_set[share_material_key]).Contains(kp_node.Part.Descr))
                                                            {
                                                                descr_kp_part_set[share_material_key] += "," + kp_node.Part.Descr;
                                                            }
                                                        }

                                                        IList<PartInfo> part_infos = kp_node.Part.Attributes;
                                                        if (part_infos != null && part_infos.Count > 0)
                                                        {
                                                            foreach (PartInfo part_info in part_infos)
                                                            {
                                                                if (part_info.InfoType.Equals("VendorCode"))
                                                                {
                                                                    if (!info_value_string_set.ContainsKey(share_material_key))
                                                                    {
                                                                        info_value_string_set.Add(share_material_key, part_info.InfoValue);
                                                                    }
                                                                    else
                                                                    {
                                                                        if (!((String)info_value_string_set[share_material_key]).Contains(part_info.InfoValue))
                                                                        {
                                                                            info_value_string_set[share_material_key] += "," + part_info.InfoValue;
                                                                        }
                                                                    }
                                                                    if (!share_parts_set.ContainsKey(share_material_key))
                                                                    {
                                                                        IList<IPart> share_parts = new List<IPart>();
                                                                        share_parts.Add(kp_node.Part);
                                                                        share_parts_set.Add(share_material_key, share_parts);
                                                                    }
                                                                    else
                                                                    {
                                                                        ((IList<IPart>)share_parts_set[share_material_key]).Add(kp_node.Part);
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }

                                            }
                                        }
                                    }
                                }

                            }
                        }
                    }
                    //if (material_type.Count > 0)
                    //{
                    //    foreach (ShareMaterialType type in material_type)
                    //    {
                    //        String share_material_key = type.Qty.ToString() + type.Descr;
                    //        if (share_parts_set.ContainsKey(share_material_key))
                    //        {
                    //            var kp_flat_bom_item = new FlatBOMItem(type.Qty, part_check_type, (IList<IPart>)share_parts_set[share_material_key]);
                    //            kp_flat_bom_item.PartNoItem = (String)info_value_string_set[share_material_key];
                    //            kp_flat_bom_item.Descr = (String)descr_kp_part_set[share_material_key];
                    //            flat_bom_items.Add(kp_flat_bom_item);
                    //        }
                    //    }
                    //}
                }
                if (material_type.Count > 0)
                {
                    foreach (ShareMaterialType type in material_type)
                    {
                        String share_material_key = type.Qty.ToString() + type.Descr;
                        if (share_parts_set.ContainsKey(share_material_key))
                        {
                            var kp_flat_bom_item = new FlatBOMItem(type.Qty, part_check_type, (IList<IPart>)share_parts_set[share_material_key]);
                            kp_flat_bom_item.PartNoItem = (String)info_value_string_set[share_material_key];
                            kp_flat_bom_item.Descr = (String)descr_kp_part_set[share_material_key];
                            flat_bom_items.Add(kp_flat_bom_item);
                        }
                    }
                }
                if (flat_bom_items.Count > 0)
                {
                    ret = new FlatBOM(flat_bom_items);
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return ret;
        }
Пример #25
0
        public object FilterBOM(object hierarchical_bom, string station, object main_object)
        {
            IList<IFlatBOMItem> flat_bom_items = new List<IFlatBOMItem>();
            Hashtable share_parts_set = new Hashtable();
            IFlatBOM ret = null;
            if (hierarchical_bom == null)
            {
                throw new ArgumentNullException();
            }
            var bom = (HierarchicalBOM)hierarchical_bom;
            try
            {
                string[] param = {
                                    "IMES.CheckItemModule.RoyaltyPaper.Filter.FilterBOM",
                                    "mainObject"
                                 };
                if (null == main_object)
                    return ret;
                    //throw new FisException("CHK156", param);
                var product = (Product)main_object;
                IDeliveryRepository delivery_repository = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>();
                Delivery delivery = delivery_repository.GetDelivery(product.DeliveryNo.Trim());
                if (delivery != null)
                {
                    if (delivery.PoNo.IndexOf("BF3") == 0 || delivery.PoNo.IndexOf("BFD") == 0)
                    {
                        if (bom.FirstLevelNodes != null)
                        {
                            for (int i = 0; i < bom.FirstLevelNodes.Count; i++)
                            {
                                if (CheckCondition(bom.FirstLevelNodes.ElementAt(i)))
                                {
                                    IPart part = ((BOMNode) bom.FirstLevelNodes.ElementAt(i)).Part;
                                    if (!share_parts_set.ContainsKey(part.PN))
                                    {
                                        IList<IPart> parts = new List<IPart>();
                                        parts.Add(part);
                                        share_parts_set.Add(part.PN, parts);
                                    }
                                    else
                                    {
                                        ((IList<IPart>)share_parts_set[part.PN]).Add(part);
                                    }
                                }
                            }
                        }
                    }
                }
                if (share_parts_set.Count > 0)
                {
                    foreach (DictionaryEntry de in share_parts_set)
                    {
                        var flat_bom_item = new FlatBOMItem(qty, part_check_type, (IList<IPart>)de.Value);
                        flat_bom_item.PartNoItem = (string)de.Key;
                        flat_bom_item.Tp = "P1";
                        flat_bom_item.Descr = "ROYALTY PAPER " + (string)de.Key;
                        flat_bom_items.Add(flat_bom_item);
                    }
                }
                if (flat_bom_items.Count > 0)
                {
                    ret = new FlatBOM(flat_bom_items);
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return ret;
        }
Пример #26
0
        public object FilterBOM(object hierarchical_bom, string station, object main_object)
        {
            IList<IFlatBOMItem> flat_bom_items = new List<IFlatBOMItem>();
            Hashtable share_parts_set = new Hashtable();
            Hashtable share_part_no_set = new Hashtable();
            Hashtable qty_share_parts_set = new Hashtable();
            Hashtable descr_parts_set = new Hashtable();
            Hashtable check_typ_set = new Hashtable();
            //问题:station参数用不上。因为在hierarchicalBOM中,没有与station相关的字段。
            IFlatBOM ret = null;
            //int qty = 0;
            //var parts = new List<IPart>();
     
            if (hierarchical_bom == null)
            {
                throw new ArgumentNullException();
            }
            var bom = (HierarchicalBOM)hierarchical_bom;
            if (checkCleanRoomModel(bom, station)) //FA 3M Station CleanRoom not check Camera
                {
                    return null;
                }
           
            try
            {
                if (bom.FirstLevelNodes != null)
                {
                    for (int i = 0; i < bom.FirstLevelNodes.Count; i++)
                    {
                        IPart part = ((BOMNode)bom.FirstLevelNodes.ElementAt(i)).Part;
                        if (part != null && part.BOMNodeType.Trim().Equals("PL") && "TPM".Equals(part.Descr) && (0 != part.PN.IndexOf("151")))
                        {

                            if (CheckCondition(bom.FirstLevelNodes.ElementAt(i)))
                            {
                                string vendorcodeValue = "";
								Boolean exist_share_part = false;
                                IList<PartInfo> part_infos = part.Attributes;
                                if (part_infos != null && part_infos.Count > 0)
                                {
                                    foreach (PartInfo part_info in part_infos)
                                    {
                                        if (part_info.InfoType.Equals("VendorCode") && !string.IsNullOrEmpty(part_info.InfoValue)) {
											vendorcodeValue = part_info.InfoValue;
										}
                                        /*else if (part_info.InfoType.Equals("SUB") && !string.IsNullOrEmpty(part_info.InfoValue))
                                        {
                                            exist_share_part = true;

                                            String[] share_parts = part_info.InfoValue.Trim().Split(';');
                                            if (share_parts.Length > 0)
                                            {
                                                string share_part_no = part_info.InfoValue.Trim();
                                                //                                                share_part_no = share_part_no.Replace("DIB", "");
                                                //                                                share_part_no_set.Add(part.PN, share_part_no.Replace(';', ','));
                                                if (share_part_no_set.ContainsKey(part.PN))
                                                {
                                                    share_part_no_set[part.PN] += "," + share_part_no.Replace(';', ',');
                                                }
                                                else
                                                {
                                                    share_part_no_set.Add(part.PN, share_part_no.Replace(';', ','));
                                                }
                                                IPartRepository repository = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
                                                IList<IPart> parts = new List<IPart>();
                                                parts.Add(part);
                                                for (int j = 0; j < share_parts.Length; j++)
                                                {
                                                    IPart share_part = repository.GetPartByPartNo(share_parts[j]);
                                                    if (share_part != null)
                                                    {
                                                        parts.Add(share_part);
                                                    }
                                                }
                                                String share_parts_code = part.PN;
                                                if (!share_parts_set.ContainsKey(share_parts_code))
                                                {
                                                    share_parts_set.Add(share_parts_code, parts);
                                                    qty_share_parts_set.Add(share_parts_code, ((BOMNode)bom.FirstLevelNodes.ElementAt(i)).Qty);
                                                    descr_parts_set.Add(share_parts_code, part.Descr);
                                                    check_typ_set.Add(share_parts_code, part.BOMNodeType.Trim());
                                                }
                                                else
                                                {
                                                    ((IList<IPart>)share_parts_set[share_parts_code]).Add(part);
                                                    if (!((String)descr_parts_set[share_parts_code]).Contains(part.Descr))
                                                    {
                                                        descr_parts_set[share_parts_code] += "," + part.Descr;
                                                    }
                                                }
                                            }
                                        }*/
                                    }
                                }

                                if (string.IsNullOrEmpty(vendorcodeValue))
                                    continue;

                                if (!exist_share_part)
                                {
                                    if (!share_parts_set.ContainsKey(vendorcodeValue))
                                    {
                                        IList<IPart> parts = new List<IPart>();
                                       
                                        parts.Add(part);
                                      
                                        share_parts_set.Add(vendorcodeValue, parts);
                                        qty_share_parts_set.Add(vendorcodeValue, ((BOMNode)bom.FirstLevelNodes.ElementAt(i)).Qty);
                                        descr_parts_set.Add(vendorcodeValue, part.Descr);
                                        check_typ_set.Add(vendorcodeValue, part.BOMNodeType.Trim());
                                    }
                                    else
                                    {
                                     
                                        ((IList<IPart>)share_parts_set[vendorcodeValue]).Add(part);
                            
                                        if (!((String)descr_parts_set[vendorcodeValue]).Contains(part.Descr))
                                        {
                                            descr_parts_set[vendorcodeValue] += "," + part.Descr;
                                        }
                                    }
                                }
                          
                            }
                        }
                    }

                    if (share_parts_set.Count > 0)
                    {
                        FlatBOMItem flat_bom_item = null;
                        string partNoItem = "";

                        foreach (DictionaryEntry de in share_parts_set)
                        {
                            if (flat_bom_item == null)
                            {
                                flat_bom_item = new FlatBOMItem((int)qty_share_parts_set[de.Key], part_check_type, (IList<IPart>)de.Value);
                                flat_bom_item.Tp = (string)check_typ_set[de.Key];
                                flat_bom_item.Descr = (string)descr_parts_set[de.Key];
                            }
                            else
                            {
                                IList<IPart> parts = share_parts_set[de.Key] as IList<IPart>;
                                if (null != parts)
                                {
                                    foreach (IPart part in parts)
                                        flat_bom_item.AddAlterPart(part);
                                }
                            }

                            if (partNoItem == "")
                                partNoItem = (string)de.Key;
                            else
                                partNoItem += "," + de.Key;
                        }

                        flat_bom_item.PartNoItem = partNoItem;
                        flat_bom_items.Add(flat_bom_item);
                    }
                    if (flat_bom_items.Count > 0)
                    {
                        ret = new FlatBOM(flat_bom_items);
                    }
                }
            }
            catch (Exception e)
            {
                throw;
            }

           return ret;
        }
Пример #27
0
        /// <summary>
        ///ModelBOM 中Model 直接下阶中BomNodeType = 'PX' 的Part; 
        /// PartInfo 表中不存在InfoType = 'VendorCode'的记录        
        /// </summary>
        /// <param name="hierarchicalBom"></param>
        /// <param name="station"></param>
        /// <param name="mainObject"></param>
        /// <returns></returns>
        public object FilterBOM(object hierarchicalBom, string station, object mainObject)
        {
            if (hierarchicalBom == null)
            {
                throw new ArgumentNullException();
            }

            var bom = (HierarchicalBOM)hierarchicalBom;
            IList<IBOMNode> pxNodes = bom.GetFirstLevelNodesByNodeType(PXBomNodeType);
            if (pxNodes == null)
            {
                return null;
            }

            IFlatBOM flatBom = new FlatBOM();
            foreach (IBOMNode bomNode in pxNodes)
            {
                if (!this.VendorCodeExists(bomNode))
                {
                    IPart part = bomNode.Part;
                    bool createNew = true;
                    if (!string.IsNullOrEmpty(bomNode.AlternativeItemGroup))
                    {
                        foreach (IFlatBOMItem item in flatBom.BomItems)
                        {
                            if (string.Compare(
                                item.AlternativeItemGroup,
                                bomNode.AlternativeItemGroup) == 0
                                )
                            {
                                item.AddAlterPart(part);
                                createNew = false;
                                break;
                            }
                        }
                    }
                    if (createNew)
                    {
                        //create new bomitem
                        var flatBOMItem = new FlatBOMItem(1, PartCheckType, new List<IPart>());
                        flatBOMItem.AlterParts.Add(part);
                        flatBOMItem.AlternativeItemGroup = bomNode.AlternativeItemGroup;
                        flatBom.AddBomItem(flatBOMItem);
                    }
                }
            }

            if (flatBom.BomItems.Count > 0)
            {
                foreach (IFlatBOMItem item in flatBom.BomItems)
                {
                    item.Tp = item.AlterParts.First().BOMNodeType;
                    item.Descr = item.AlterParts.First().Descr;
                    string pnString = string.Empty;
                    foreach (IPart part in item.AlterParts)
                    {
                        if (pnString.Length == 0)
                        {
                            pnString = part.PN;
                        }
                        else
                        {
                            pnString += "," + part.PN;
                        }
                    }
                    item.PartNoItem = pnString;
                }
                return flatBom;
            }

            return null;
        }
Пример #28
0
        /// <summary>
        /// light on
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {

            //find current station descr
            var StationRepository = RepositoryFactory.GetInstance().GetRepository<IStationRepository, IStation>();
            IStation currentStation = StationRepository.Find(Station);
            if (currentStation == null || string.IsNullOrEmpty(currentStation.Descr))
            {
                throw new FisException("PKIT01", new string[] { Station });
            }
            string currentStationDescr = currentStation.Descr;
            CurrentSession.AddValue(Session.SessionKeys.StationDescr, currentStationDescr);

            IStation Kit6Station = StationRepository.Find(DDDKitStation6);
            if (Kit6Station == null || string.IsNullOrEmpty(Kit6Station.Descr))
            {
                throw new FisException("PKIT01", new string[] { DDDKitStation6 });
            }


            IProduct currentProduct = CurrentSession.GetValue(Session.SessionKeys.Product) as Product;

            //Get all wipbuffer for all station, this line
            var productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            IList<WipBuffer> allWipbufList = productRepository.GetWipBufferByKittingTypeAndCode("PAK Kitting", Line.Substring(0, 1));
            if (allWipbufList == null || allWipbufList.Count == 0)
            {
                throw new FisException("PKIT03", new string[] { });
            }

            // from wipbuffer maintain station list get nextstation should go
            string ShouldGoStation = "";
            int ShouldStationIndex = -1;
            string pkStation = "-PK01-PK02-PK03-PK04-PK05-PKOK-";
            List<string> stationList = (from tempWip in allWipbufList
                                        orderby tempWip.Station
                                        select tempWip.Station).Distinct<string>().ToList<string>();

            if (!stationList.Contains(Kit6Station.Descr))
            {
                stationList.Add(Kit6Station.Descr);
            }

            if (pkStation.Contains("-" + currentProduct.Status.StationId + "-"))
            {
                IStation preStation = StationRepository.Find(currentProduct.Status.StationId);
                if (preStation == null || string.IsNullOrEmpty(preStation.Descr))
                {
                    throw new FisException("PKIT01", new string[] { currentProduct.Status.StationId });
                }
                string preStationDescr = preStation.Descr;


                for (int i = 0; i < stationList.Count() - 1; i++)
                {
                    if (stationList.ElementAt(i) == preStationDescr)
                    {
                        ShouldStationIndex = i + 1;
                        ShouldGoStation = stationList.ElementAt(i + 1);
                        break;
                    }
                }
            }
            else
            {
                ShouldStationIndex = 0;
                ShouldGoStation = stationList.ElementAt(0);
            }

            // if can't get next station should go,then set next station is kit6
            if (ShouldStationIndex == -1)
            {
                ShouldStationIndex = stationList.Count();


                ShouldGoStation = Kit6Station.Descr;
            }

            IFlatBOM totalBom = (IFlatBOM)CurrentSession.GetValue(Session.SessionKeys.SessionBom);

            // if next station doesn't contain any part in wippbuffer, then get next station of this station
            for (int i = ShouldStationIndex; i < stationList.Count() - 1; i++)
            {
                if (ShouldGoStation != currentStationDescr)
                {
                    var shouldStationWBList = from tempWip in allWipbufList
                                              where tempWip.Station == ShouldGoStation
                                              select tempWip;

                    foreach (IFlatBOMItem bomItem in totalBom.BomItems)
                    {
                        bool match = false;
                        foreach (WipBuffer wipbufobj in shouldStationWBList)
                        {
                            if (PartMatchWipBuffer(wipbufobj.PartNo, bomItem.AlterParts))
                            {
                                match = true;
                                break;
                            }
                        }
                        if (match)
                        {
                            throw new FisException("PKIT02", new string[] { ShouldGoStation });
                        }
                    }
                    ShouldStationIndex = ShouldStationIndex + 1;
                    ShouldGoStation = stationList.ElementAt(ShouldStationIndex);

                }
                else
                {
                    break;
                }
            }

            if (ShouldGoStation != currentStationDescr)
            {
                throw new FisException("PKIT02", new string[] { ShouldGoStation });
            }



            //get bom,current station wipbuffer
            IList<IFlatBOMItem> filteredBomItems = new List<IFlatBOMItem>();
            var wipbufObjs = from tempWip in allWipbufList
                             where tempWip.Station == ShouldGoStation
                             select tempWip;
            IList<WipBuffer> wipbufferList = new List<WipBuffer>();

            if (wipbufObjs != null)
            {
                wipbufferList = wipbufObjs.ToList<WipBuffer>();
            }


            IList<string> matchePnList = new List<string>();
            // kit6 get all part by remove kit1-5
            if (Station == DDDKitStation6)
            {

                List<string> station15List = new List<string>();
                for (int i = 0; i < stationList.Count(); i++)
                {
                    if (stationList[i].Trim() == "DDD Kitting 1" || stationList[i].Trim() == "DDD Kitting 2" || stationList[i].Trim() == "DDD Kitting 3" || stationList[i].Trim() == "DDD Kitting 4" || stationList[i].Trim() == "DDD Kitting 5")
                    {
                        station15List.Add(stationList[i]);
                    }
                }
                for (int i = 0; i < station15List.Count(); i++)
                {

                    var wipbufObjtemp = from tempWip in allWipbufList
                                        where tempWip.Station == station15List.ElementAt(i)
                                        select tempWip;
                    if (wipbufObjtemp != null)
                    {
                        IList<int> removeIndexList = new List<int>();

                        foreach (WipBuffer wipbufobj in wipbufObjtemp)
                        {

                            for (int j = 0; j < totalBom.BomItems.Count; j++)
                            {
                                if (PartMatchWipBuffer(wipbufobj.PartNo, totalBom.BomItems[j].AlterParts))
                                {
                                    removeIndexList.Add(j);
                                }
                            }
                        }

                        var sortedIndexList = (from tempIndex in removeIndexList
                                               orderby tempIndex descending
                                               select tempIndex).Distinct<int>();
                        for (int k = 0; k < sortedIndexList.Count(); k++)
                        {
                            totalBom.BomItems.RemoveAt(sortedIndexList.ElementAt<int>(k));
                        }
                    }
                }

                foreach (IFlatBOMItem bomItem in totalBom.BomItems)
                {
                    foreach (WipBuffer wipbufobj in wipbufObjs)
                    {
                        if (PartMatchWipBuffer(wipbufobj.PartNo, bomItem.AlterParts))
                        {
                            matchePnList.Add(wipbufobj.PartNo);
                        }
                    }
                }


                foreach (IFlatBOMItem bomItem in totalBom.BomItems)
                {
                    filteredBomItems.Add(bomItem);
                }
            }
            else
            {
                // kit 1-5,get part by wipbuffer cross bom 
                if (wipbufObjs == null || wipbufObjs.Count() == 0)
                {
                    var ex = new FisException("PKIT03", new string[] { });
                    throw ex;
                }


                foreach (IFlatBOMItem bomItem in totalBom.BomItems)
                {
                    bool match = false;
                    foreach (WipBuffer wipbufobj in wipbufObjs)
                    {
                        if (PartMatchWipBuffer(wipbufobj.PartNo, bomItem.AlterParts))
                        {
                            match = true;
                            matchePnList.Add(wipbufobj.PartNo);
                        }
                    }
                    if (match)
                    {
                        filteredBomItems.Add(bomItem);
                    }
                }
            }


            if (filteredBomItems == null || filteredBomItems.Count == 0)
            {
                throw new FisException("PKIT03", new string[] { });
            }

            for (int i = wipbufferList.Count - 1; i >= 0; i--)
            {
                if (!matchePnList.Contains<string>(wipbufferList[i].PartNo))
                {
                    wipbufferList.RemoveAt(i);
                }
            }

            CurrentSession.AddValue(Session.SessionKeys.PizzaKitWipBuffer, wipbufferList);
            //replace with new bom
            IFlatBOM filteredBom = new FlatBOM(filteredBomItems);
            CurrentSession.AddValue(Session.SessionKeys.SessionBom, filteredBom);

            //light on
            if (wipbufferList != null && wipbufferList.Count() > 0)
            {
                IPalletRepository pltRepository = RepositoryFactory.GetInstance().GetRepository<IPalletRepository, Pallet>();
                List<string> TagIDList = new List<string>();
                foreach (WipBuffer wipbufobj in wipbufferList)
                {
                    IList<KittingLocPLMappingStInfo> kitlocstinfos = pltRepository.GetKitLocPLMapST(Line.Substring(0, 1), currentStationDescr, short.Parse(wipbufobj.LightNo));
                    if (kitlocstinfos != null && kitlocstinfos.Count > 0)
                    {
                        TagIDList.Add(kitlocstinfos[0].tagID);
                    }
                }
                pltRepository.UpdateKitLocationFVOnDefered(CurrentSession.UnitOfWork, TagIDList.ToArray<string>(), true, false, "1");
            }

            return base.DoExecute(executionContext);
        }
Пример #29
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="hierarchical_bom"></param>
        /// <param name="station"></param>
        /// <param name="main_object"></param>
        /// <returns></returns>
        public object FilterBOM(object hierarchical_bom, string station, object main_object)
        {
            //根据Model展3阶,得到第一阶是BM和P1的part其下阶和下下阶(注意Qty需要相乘) [ BM->KP->VC]或者[ P1->KP->VC],即KP和VC,
            //以及第一阶是KP的part的第一阶及其下阶[KP->VC],即KP和VC,第一阶的Descr描述为Descr like 'Fiber%'
            IFlatBOM ret = null;
            IList<IFlatBOMItem> flat_bom_items = new List<IFlatBOMItem>();
            //var kp_parts = new List<IPart>();
            if (hierarchical_bom == null)
            {
                throw new ArgumentNullException();
            }
            var bom = (HierarchicalBOM)hierarchical_bom;
            var tree_traversal = new TreeTraversal();
            Hashtable share_parts_set =  new Hashtable();
            Hashtable descr_kp_part_set = new Hashtable();
            Hashtable info_value_string_set = new Hashtable();
            Hashtable mb_qty_set = new Hashtable();
            try
            {
                //处理BM->KP情况
//                IList<QtyParts> bm_check_conditon_nodes = tree_traversal.BreadthFirstTraversalForHD(bom.Root, "BM->KP", "KP", this,"BM");
                IList<QtyParts> bm_check_conditon_nodes = tree_traversal.BreadthFirstTraversal(bom.Root, "BM->KP", "KP", this, "BM");
                //IList<ShareMaterialType> material_type = FilterShareMaterialType(bm_check_conditon_nodes);
                if (bm_check_conditon_nodes != null && bm_check_conditon_nodes.Count > 0)
                {
                    Hashtable temp_share_parts_set = new Hashtable();
                    foreach (QtyParts bm_check_conditon_node in bm_check_conditon_nodes)
                    {
                        if (bom.FirstLevelNodes != null) //当bom.Root.Part不为空时,Root是首阶
                        {
                            IList<IBOMNode> bom_nodes = bom.FirstLevelNodes;
                            foreach (IBOMNode bom_node in bom_nodes)
                            {
                                if (bom_node.Part.BOMNodeType.Equals("BM"))
                                {
                                    IList<IBOMNode> child_nodes = bom_node.Children;
                                    if (child_nodes != null)
                                    {
                                        foreach (IBOMNode child_node in child_nodes)
                                        {
                                            if (child_node.Part != null && child_node.Part.BOMNodeType.Equals("KP") && child_node.Part.Attributes != null)
                                            {
                                                if (PartCompare(bm_check_conditon_node.Parts, child_node.Part))
                                                {
                                                    String share_material_key = bm_check_conditon_node.Qty.ToString() + child_node.Part.Descr + bom_node.Part.PN;
                                                       
                                                    if (!descr_kp_part_set.ContainsKey(share_material_key))
                                                    {
                                                        descr_kp_part_set.Add(share_material_key, child_node.Part.Descr);
                                                    }
                                                    else
                                                    {
                                                        if(!((String)descr_kp_part_set[share_material_key]).Contains(child_node.Part.Descr))
                                                        {
                                                            descr_kp_part_set[share_material_key] += "," + child_node.Part.Descr;
                                                        }
                                                    }

                                                    IList<PartInfo> part_infos = child_node.Part.Attributes;
                                                    if (part_infos != null && part_infos.Count > 0)
                                                    {
                                                        foreach (PartInfo part_info in part_infos)
                                                        {
                                                            if (part_info.InfoType.Equals("VendorCode"))
                                                            {
                                                                if(!info_value_string_set.ContainsKey(share_material_key))
                                                                {
                                                                    info_value_string_set.Add(share_material_key, part_info.InfoValue);
                                                                    mb_qty_set.Add(share_material_key, bm_check_conditon_node.Qty);

                                                                    IList<IPart> share_parts = new List<IPart>();
                                                                    share_parts.Add(child_node.Part);
                                                                    temp_share_parts_set.Add(share_material_key, share_parts);
                                                                }
                                                                else
                                                                {
                                                                    if (!((String)info_value_string_set[share_material_key]).Contains(part_info.InfoValue))
                                                                    {
                                                                        info_value_string_set[share_material_key] += "," + part_info.InfoValue;
                                                                        ((IList<IPart>)temp_share_parts_set[share_material_key]).Add(child_node.Part);
                                                                    }
                                                                }

                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (temp_share_parts_set.Count > 0)
                    {
                        IList<Object> keys_sort = new List<Object>();
                        foreach (DictionaryEntry dictionary_entry in info_value_string_set)
                        {
                            if (keys_sort.Count == 0)
                            {
                                keys_sort.Add(dictionary_entry.Key);
                            }
                            else
                            {
                                int index = 0;
                                bool is_little = false;
                                foreach (Object entry in keys_sort)
                                {
                                    index++;
                                    int keys_sort_info_value_length = ((string) info_value_string_set[entry]).Length;
                                    int info_value_string_length = ((string)info_value_string_set[dictionary_entry.Key]).Length;
                                    if (info_value_string_length < keys_sort_info_value_length)
                                    {
                                        is_little = true;
                                        break;
                                    }
                                }
                                if (index > 0)
                                {
                                    if (is_little)
                                    {
                                        keys_sort.Insert(index - 1, dictionary_entry.Key); 
                                    }
                                    else
                                    {
                                        keys_sort.Add(dictionary_entry.Key); 
                                    }
                                                                       
                                }
                            }
                        }
                        foreach (Object de in keys_sort)
                        {
                            share_parts_set.Add(de, temp_share_parts_set[de]);
                        }
                    }

                    foreach (DictionaryEntry de in share_parts_set)
                    {
                        var kp_flat_bom_item = new FlatBOMItem((int)mb_qty_set[de.Key], part_check_type, (IList<IPart>)share_parts_set[de.Key]);
                        kp_flat_bom_item.PartNoItem = (String)info_value_string_set[de.Key];
                        kp_flat_bom_item.Descr = (String)descr_kp_part_set[de.Key];
                        flat_bom_items.Add(kp_flat_bom_item);
                    }
                }
                share_parts_set.Clear();
                info_value_string_set.Clear();
                mb_qty_set.Clear();

                //处理P1->KP情况
                //descr_kp_part_set.Clear();
                //info_value_string_set.Clear();
                //share_parts_set.Clear();
                IList<ShareMaterialType> material_type = new List<ShareMaterialType>();
                IList<QtyParts> p1_check_conditon_nodes = tree_traversal.BreadthFirstTraversal(bom.Root, "P1->KP", "KP", this, "P1");
                IList<ShareMaterialType> p1_material_type = FilterShareMaterialType(p1_check_conditon_nodes);
//                foreach (ShareMaterialType type in p1_material_type)
//                {
//                    Boolean is_add = true;
//                    foreach (ShareMaterialType mtype in material_type)
//                    {
//                        if (mtype.Descr.Trim().Equals(type.Descr.Trim()) && mtype.Qty == type.Qty)
//                        {
//                            is_add = false;
//                            break;
//                        }
//                    }
//                    if (is_add)
//                    {
//                        material_type.Add(type);
//                    }
//                }
                if (p1_check_conditon_nodes != null && p1_check_conditon_nodes.Count > 0)
                {
                    Hashtable temp_share_parts_set = new Hashtable();
                    foreach (QtyParts bm_check_conditon_node in p1_check_conditon_nodes)
                    {
                        if (bom.FirstLevelNodes != null)
                        {
                            IList<IBOMNode> bom_nodes = bom.FirstLevelNodes;
                            foreach (IBOMNode bom_node in bom_nodes)
                            {
                                if (bom_node.Part.BOMNodeType.Equals("P1"))
                                {
                                    IList<IBOMNode> child_nodes = bom_node.Children;
                                    if (child_nodes != null)
                                    {
                                        foreach (IBOMNode child_node in child_nodes)
                                        {
                                            if (child_node.Part != null && child_node.Part.BOMNodeType.Equals("KP") && child_node.Part.Attributes != null)
                                            {
                                                if (PartCompare(bm_check_conditon_node.Parts, child_node.Part))
                                                {
//                                                    if (material_type.Count > 0)
//                                                    {
//                                                        foreach (ShareMaterialType type in material_type)
//                                                        {
//                                                            if (child_node.Part.Descr.Equals(type.Descr) && bm_check_conditon_node.Qty == type.Qty)
//                                                            {
//                                                                String share_material_key = type.Qty.ToString() + type.Descr;
//
//                                                                //if (!share_parts_set.ContainsKey(share_material_key))
//                                                                //{
//                                                                //    IList<IPart> share_parts = new List<IPart>();
//                                                                //    share_parts.Add(child_node.Part);
//                                                                //    share_parts_set.Add(share_material_key, share_parts);
//                                                                //}
//                                                                //else
//                                                                //{
//                                                                //    ((IList<IPart>)share_parts_set[share_material_key]).Add(child_node.Part);
//                                                                //}
//                                                                if (!descr_kp_part_set.ContainsKey(share_material_key))
//                                                                {
//                                                                    descr_kp_part_set.Add(share_material_key, child_node.Part.Descr);
//                                                                }
//                                                                else
//                                                                {
//                                                                    if (!((String)descr_kp_part_set[share_material_key]).Contains(child_node.Part.Descr))
//                                                                    {
//                                                                        descr_kp_part_set[share_material_key] += "," + child_node.Part.Descr;
//                                                                    }
//                                                                }
//
//                                                                IList<PartInfo> part_infos = child_node.Part.Attributes;
//                                                                if (part_infos != null && part_infos.Count > 0)
//                                                                {
//                                                                    foreach (PartInfo part_info in part_infos)
//                                                                    {
//                                                                        if (part_info.InfoType.Equals("VendorCode"))
//                                                                        {
//                                                                            if (!info_value_string_set.ContainsKey(share_material_key))
//                                                                            {
//                                                                                info_value_string_set.Add(share_material_key, part_info.InfoValue);
//
//                                                                                IList<IPart> share_parts = new List<IPart>();
//                                                                                share_parts.Add(child_node.Part);
//                                                                                share_parts_set.Add(share_material_key, share_parts);
//                                                                            }
//                                                                            else
//                                                                            {
//                                                                                if (!((String)info_value_string_set[share_material_key]).Contains(part_info.InfoValue))
//                                                                                {
//                                                                                    info_value_string_set[share_material_key] += "," + part_info.InfoValue;
//                                                                                    ((IList<IPart>)share_parts_set[share_material_key]).Add(child_node.Part);
//                                                                                }
//                                                                            }
//                                                                        }
//                                                                    }
//                                                                }
//                                                            }
//                                                        }
//                                                    }
                                                    //------------------------------------------------------------------------------------------
                                                    String share_material_key = bm_check_conditon_node.Qty.ToString() + child_node.Part.Descr + bom_node.Part.PN;

                                                    if (!descr_kp_part_set.ContainsKey(share_material_key))
                                                    {
                                                        descr_kp_part_set.Add(share_material_key, child_node.Part.Descr);
                                                    }
                                                    else
                                                    {
                                                        if (!((String)descr_kp_part_set[share_material_key]).Contains(child_node.Part.Descr))
                                                        {
                                                            descr_kp_part_set[share_material_key] += "," + child_node.Part.Descr;
                                                        }
                                                    }

                                                    IList<PartInfo> part_infos = child_node.Part.Attributes;
                                                    if (part_infos != null && part_infos.Count > 0)
                                                    {
                                                        foreach (PartInfo part_info in part_infos)
                                                        {
                                                            if (part_info.InfoType.Equals("VendorCode"))
                                                            {
                                                                if (!info_value_string_set.ContainsKey(share_material_key))
                                                                {
                                                                    info_value_string_set.Add(share_material_key, part_info.InfoValue);
                                                                    mb_qty_set.Add(share_material_key, bm_check_conditon_node.Qty);

                                                                    IList<IPart> share_parts = new List<IPart>();
                                                                    share_parts.Add(child_node.Part);
                                                                    temp_share_parts_set.Add(share_material_key, share_parts);
                                                                }
                                                                else
                                                                {
                                                                    if (!((String)info_value_string_set[share_material_key]).Contains(part_info.InfoValue))
                                                                    {
                                                                        info_value_string_set[share_material_key] += "," + part_info.InfoValue;
                                                                        ((IList<IPart>)temp_share_parts_set[share_material_key]).Add(child_node.Part);
                                                                    }
                                                                }

                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (temp_share_parts_set.Count > 0)
                    {
                        IList<Object> keys_sort = new List<Object>();
                        foreach (DictionaryEntry dictionary_entry in info_value_string_set)
                        {
                            if (keys_sort.Count == 0)
                            {
                                keys_sort.Add(dictionary_entry.Key);
                            }
                            else
                            {
                                int index = 0;
                                bool is_little = false;
                                foreach (Object entry in keys_sort)
                                {
                                    index++;
                                    int keys_sort_info_value_length = ((string)info_value_string_set[entry]).Length;
                                    int info_value_string_length = ((string)info_value_string_set[dictionary_entry.Key]).Length;
                                    if (info_value_string_length < keys_sort_info_value_length)
                                    {
                                        is_little = true;
                                        break;
                                    }
                                }
                                if (index > 0)
                                {
                                    if (is_little)
                                    {
                                        keys_sort.Insert(index - 1, dictionary_entry.Key);
                                    }
                                    else
                                    {
                                        keys_sort.Add(dictionary_entry.Key);
                                    }

                                }
                            }
                        }
                        foreach (Object de in keys_sort)
                        {
                            share_parts_set.Add(de, temp_share_parts_set[de]);
                        }
                    }

                    foreach (DictionaryEntry de in share_parts_set)
                    {
                        var kp_flat_bom_item = new FlatBOMItem((int)mb_qty_set[de.Key], part_check_type, (IList<IPart>)share_parts_set[de.Key]);
                        kp_flat_bom_item.PartNoItem = (String)info_value_string_set[de.Key];
                        kp_flat_bom_item.Descr = (String)descr_kp_part_set[de.Key];
                        flat_bom_items.Add(kp_flat_bom_item);
                    }
                }

                share_parts_set.Clear();
                info_value_string_set.Clear();
                mb_qty_set.Clear();

                //处理首阶为KP情况
                //descr_kp_part_set.Clear();
                //info_value_string_set.Clear();
                //share_parts_set.Clear();
                List<IBOMNode> collect_gather_node = new List<IBOMNode>();
                List<QtyParts> kp_check_conditon_nodes = new List<QtyParts>();
                //String vendor_code_info_value_string = "";
                //String descr_info_value_string = "";
                //IList<QtyParts> kp_check_conditon_nodes = tree_traversal.BreadthFirstTraversal(bom.Root, "KP", "KP", this, "KP");

                if (bom.FirstLevelNodes != null)
                {
                    for (int i = 0; i < bom.FirstLevelNodes.Count; i++)
                    {
                        if (bom.FirstLevelNodes.ElementAt(i).Part != null)
                        {
                            if (bom.FirstLevelNodes.ElementAt(i).Part.BOMNodeType.Equals("KP"))
                            {
                                if (CheckCondition(bom.FirstLevelNodes.ElementAt(i)))
                                {
                                    collect_gather_node.Add(bom.FirstLevelNodes.ElementAt(i));
                                    List<IPart> parts = new List<IPart>();
                                    parts.Add(bom.FirstLevelNodes.ElementAt(i).Part);
                                    QtyParts bom_item = new QtyParts(bom.FirstLevelNodes.ElementAt(i).Qty, parts);
                                    kp_check_conditon_nodes.Add(bom_item);
                                }
                            }
                        }
                    }
                }



                IList<ShareMaterialType> kp_material_type = FilterShareMaterialType(kp_check_conditon_nodes);
                foreach (ShareMaterialType type in kp_material_type)
                {
                    Boolean is_add = true;
                    foreach (ShareMaterialType mtype in material_type)
                    {
                        if (mtype.Descr.Trim().Equals(type.Descr.Trim()) && mtype.Qty == type.Qty)
                        {
                            is_add = false;
                            break;
                        }
                    }
                    if (is_add)
                    {
                        material_type.Add(type);
                    }
                }
                if ( kp_check_conditon_nodes.Count > 0)
                {
                    foreach (QtyParts bm_check_conditon_node in kp_check_conditon_nodes)
                    {
                        if (bom.FirstLevelNodes != null)
                        {
                            for (int i = 0; i < bom.FirstLevelNodes.Count; i++)
                            {
                                if (bom.FirstLevelNodes.ElementAt(i).Part != null)
                                {
                                    if (bom.FirstLevelNodes.ElementAt(i).Part.BOMNodeType.Equals("KP") && bom.FirstLevelNodes.ElementAt(i).Part.Attributes != null)
                                    {
                                        IBOMNode kp_node = bom.FirstLevelNodes.ElementAt(i);
                                        //if (CheckCondition(bom.FirstLevelNodes.ElementAt(i)))
                                        if (PartCompare(bm_check_conditon_node.Parts, kp_node.Part))
                                        {
                                            if (material_type.Count > 0)
                                            {
                                                foreach (ShareMaterialType type in material_type)
                                                {
                                                    if (kp_node.Part.Descr.Equals(type.Descr) && bm_check_conditon_node.Qty == type.Qty)
                                                    {
                                                        String share_material_key = type.Qty.ToString() + type.Descr;

                                                        if (!descr_kp_part_set.ContainsKey(share_material_key))
                                                        {
                                                            descr_kp_part_set.Add(share_material_key, kp_node.Part.Descr);
                                                        }
                                                        else
                                                        {
                                                            if (!((String)descr_kp_part_set[share_material_key]).Contains(kp_node.Part.Descr))
                                                            {
                                                                descr_kp_part_set[share_material_key] += "," + kp_node.Part.Descr;
                                                            }
                                                        }

                                                        IList<PartInfo> part_infos = kp_node.Part.Attributes;
                                                        if (part_infos != null && part_infos.Count > 0)
                                                        {
                                                            foreach (PartInfo part_info in part_infos)
                                                            {
                                                                if (part_info.InfoType.Equals("VendorCode"))
                                                                {
                                                                    if (!info_value_string_set.ContainsKey(share_material_key))
                                                                    {
                                                                        info_value_string_set.Add(share_material_key, part_info.InfoValue);

                                                                        IList<IPart> share_parts = new List<IPart>();
                                                                        share_parts.Add(kp_node.Part);
                                                                        share_parts_set.Add(share_material_key, share_parts);
                                                                    }
                                                                    else
                                                                    {
                                                                        if (!((String)info_value_string_set[share_material_key]).Contains(part_info.InfoValue))
                                                                        {
                                                                            info_value_string_set[share_material_key] += "," + part_info.InfoValue;

                                                                            ((IList<IPart>)share_parts_set[share_material_key]).Add(kp_node.Part);
                                                                        }
                                                                    }
                                                                    if (!share_parts_set.ContainsKey(share_material_key))
                                                                    {
                                                                        IList<IPart> share_parts = new List<IPart>();
                                                                        share_parts.Add(kp_node.Part);
                                                                        share_parts_set.Add(share_material_key, share_parts);
                                                                    }
                                                                    else
                                                                    {
                                                                        ((IList<IPart>)share_parts_set[share_material_key]).Add(kp_node.Part);
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }

                                            }
                                        }
                                    }
                                }

                            }
                        }
                    }
                    //if (material_type.Count > 0)
                    //{
                    //    foreach (ShareMaterialType type in material_type)
                    //    {
                    //        String share_material_key = type.Qty.ToString() + type.Descr;
                    //        if (share_parts_set.ContainsKey(share_material_key))
                    //        {
                    //            var kp_flat_bom_item = new FlatBOMItem(type.Qty, part_check_type, (IList<IPart>)share_parts_set[share_material_key]);
                    //            kp_flat_bom_item.PartNoItem = (String)info_value_string_set[share_material_key];
                    //            kp_flat_bom_item.Descr = (String)descr_kp_part_set[share_material_key];
                    //            flat_bom_items.Add(kp_flat_bom_item);
                    //        }
                    //    }
                    //}
                }
                if (material_type.Count > 0)
                {
                    foreach (ShareMaterialType type in material_type)
                    {
                        String share_material_key = type.Qty.ToString() + type.Descr;
                        if (share_parts_set.ContainsKey(share_material_key))
                        {
                            var kp_flat_bom_item = new FlatBOMItem(type.Qty, part_check_type, (IList<IPart>)share_parts_set[share_material_key]);
                            kp_flat_bom_item.PartNoItem = (String)info_value_string_set[share_material_key];
                            kp_flat_bom_item.Descr = (String)descr_kp_part_set[share_material_key];
                            flat_bom_items.Add(kp_flat_bom_item);
                        }
                    }
                }
                if (flat_bom_items.Count > 0)
                {
                    ret = new FlatBOM(flat_bom_items);
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return ret;
        }
Пример #30
0
        public object FilterBOM(object hierarchical_bom, string station, object main_object)
        {
            IList<IFlatBOMItem> flat_bom_items = new List<IFlatBOMItem>();
            IPartRepository partRep = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
            IModelRepository modelRep = RepositoryFactory.GetInstance().GetRepository<IModelRepository, Model>();
            IFlatBOM ret = null;
            bool NeedCheckContent = false;
            string mn = "";
            string pn = "";
            string warranty = "";
            try
            {
                IProduct product = GetProduct(main_object);
                IList<ConstValueTypeInfo> lstConstValueType = partRep.GetConstValueTypeList("CheckCarveSN");
                if (null != lstConstValueType && lstConstValueType.Count > 0)
                {
                    foreach (ConstValueTypeInfo cvt in lstConstValueType)
                    {
                        if (cvt.value == product.Family)
                        {
                            NeedCheckContent = true;
                            break;
                        }
                    }
                }

                if (NeedCheckContent)
                {
                    IList<IMES.FisObject.Common.Model.ModelInfo> rmnList = modelRep.GetModelInfoByModelAndName(product.Model, "MN1");
                    if (rmnList != null && rmnList.Count > 0)
                    {
                         mn = rmnList[0].Value.Trim();
                    }
                    IList<IMES.FisObject.Common.Model.ModelInfo> pnList = modelRep.GetModelInfoByModelAndName(product.Model, "PN");
                    if (pnList != null && pnList.Count > 0)
                    {
                        pn = pnList[0].Value.Trim();
                    }
                    IList<IMES.FisObject.Common.Model.ModelInfo> warrantyList = modelRep.GetModelInfoByModelAndName(product.Model, "WARRANTY");
                    if (warrantyList != null && warrantyList.Count > 0)
                    {
                        warranty = warrantyList[0].Value.Trim()+",";
                    }
                    string carveSn = product.CUSTSN+"," + mn+"," + pn+"," + warranty.Replace(",", "y");

                    string virtualPN = product.CUSTSN;
                    //  string virtualPN = product.CUSTSN  + mn  + pn  + warranty.Replace(",", "y");
                    string descr = "Check CarveSN";
                    IPart part = new Part()
                    {
                        PN = virtualPN,      //PN要跟 flat_bom_item.PartNoItem值一樣                  
                        CustPn = "",
                        Remark = "",
                        Descr = descr,
                        Descr2 = "",
                        Type = part_check_type,
                        Udt = DateTime.Now,
                        Cdt = DateTime.Now
                    };
                    var flat_bom_item = new FlatBOMItem(qty, part_check_type, new List<IPart>() { part });
                    flat_bom_item.PartNoItem = virtualPN;
                    flat_bom_item.Tp = part_check_type;
                    flat_bom_item.Descr = descr;
                    flat_bom_item.ValueType = carveSn.ToUpper(); //存放Part match時檢查的值
                    //flat_bom_item.ValueType = "5CG505000BHPDESKTOPMINIDVD-WRITERODDMODULE801433-0021Y1Y0Y"; //存放Part match時檢查的值
                    flat_bom_items.Add(flat_bom_item);
                }


                if (flat_bom_items.Count > 0)
                {
                    ret = new FlatBOM(flat_bom_items);
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return ret;
        }