Пример #1
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;
 }
Пример #2
0
        public List<string> TryPartMatchCheck(string sessionKey, string checkValue,string partNo)
        {
            Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, SessionType);
            if (currentSession == null)
            {
                FisException ex;
                List<string> erpara = new List<string>();
                erpara.Add(sessionKey);
                ex = new FisException("CHK021", erpara);
                logger.Error(ex.Message, ex);
                throw ex;
            }

            var oriBom = (IFlatBOM)currentSession.GetValue("OriginalBom");

            IFlatBOM tmpbom = new FlatBOM();
            foreach (IFlatBOMItem bi in oriBom.BomItems)
            {
                tmpbom.AddBomItem(bi);
            }

            currentSession.AddValue(Session.SessionKeys.SessionBom, tmpbom);
            var bom = (IFlatBOM)currentSession.GetValue(Session.SessionKeys.SessionBom);
            IList<IFlatBOMItem> lst = bom.BomItems;
            IList<IFlatBOMItem> notMatchPart = new List<IFlatBOMItem>(); 
            foreach(IFlatBOMItem flm in lst)
            {
                if (flm.PartNoItem == partNo)
                {
                    continue;
                }
                else
                {
                    notMatchPart.Add(flm);
                }
            }
            foreach (IFlatBOMItem flm2 in notMatchPart)
            {
                lst.Remove(flm2);
            }
       
          
           MatchedPartOrCheckItem mp= PartCollection.TryPartMatchCheck(sessionKey, SessionType, checkValue);
           int q= bom.BomItems[0].AlterParts.Where(x=>x.Attributes.Where(y=>y.InfoType=="VendorCode").ToList().Count>0).ToList().Count;
           List<PartUnit> lstSessionPart = (List<PartUnit>)currentSession.GetValue("CheckPartUnitForOfflineRCTO");
           if (currentSession.GetValue("CheckPartUnitForOfflineRCTO")== null)
           {
                lstSessionPart = new List<PartUnit>();
                currentSession.AddValue("CheckPartUnitForOfflineRCTO", lstSessionPart);
           }
           lstSessionPart.Add(bom.BomItems[0].CheckedPart[0]);
           bom.BomItems[0].ClearCheckedPart();
           
            List<string> ret = new List<string>();
            ret.Add(mp.PNOrItemName);
            ret.Add(bom.BomItems[0].Tp);
            ret.Add(bom.BomItems[0].Descr);
            ret.Add(mp.CollectionData);
            ret.Add(q.ToString());
            return ret;
        }
Пример #3
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;
        }
Пример #4
0
 private void CopyBom(Session session)
 {
     IFlatBOM obom = new FlatBOM();
     var bom = (IFlatBOM)session.GetValue(Session.SessionKeys.SessionBom);
     foreach (IFlatBOMItem bi in bom.BomItems)
     {
         obom.AddBomItem(bi);
     }
 //    obom = bom;
     session.AddValue("OriginalBom", obom);
 }