Exemple #1
0
        public void Check(PartUnit pu, IFlatBOMItem item, IPartOwner owner, string station, IFlatBOM bom)
        {
#if DEBUG
            ICheckModule checker = (ICheckModule)GetInstance(_checkModule, typeof(ICheckModule));
#else
            ICheckModule checker = PartSpecialCodeContainer.GetInstance.GetCheckModule(_checkModule);
#endif
            //已經Binded Part 檢查收集CT是否存在 
            if (item.HasBinded)
            {
                if (owner != null)
                {
                    var partNoList = item.AlterParts.Select(x=>x.PN).ToList();
                    bool hasBinded = owner.CheckPartBinded(pu.ValueType, partNoList, pu.Type, pu.ItemType, pu.Sn);
                    if (!hasBinded)
                    {
                        throw new FisException("MAT011", false, new string[] { pu.Sn, pu.Type, pu.ValueType, pu.ItemType });
                    }
                }
                else
                {
                    throw new FisException("MAT012", false, new string[] { pu.Sn, pu.Type, pu.ValueType, pu.ItemType });
                }
            }
            else
            {
                if (checker != null)
                {
                    checker.Check(pu, item, station);
                }

                //if have value then replace _needUniqueCheck 
                if (item.NeedCheckUnique.HasValue)
                {
                    _needUniqueCheck = item.NeedCheckUnique.Value;
                }
                
                if (NeedUniqueCheck)
                {
                    //do unique check                
                    //1.part been used on this product (mem)
                    var checkedParts = bom.GetCheckedPart();
                    if (checkedParts != null)
                    {
                        foreach (PartUnit checkPu in checkedParts)
                        {
                            if (pu.Sn == checkPu.Sn)
                            {
                                throw new FisException("CHK084", new string[] { pu.Sn });
                            }
                        }
                    }

                    //2.part been used on other product (db)
                    if (owner != null)
                    {
                        owner.PartUniqueCheck(pu.Pn, pu.Sn);
                    }

                    //3.part been used on other product (mem)
                }
                
            }

            if (NeedPartForbidCheck)
            {
                IPartRepository partRep = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
                string noticeMsg = "";
                if (partRep.CheckPartForbid(item.PartForbidList, pu.Type, pu.Sn, pu.Pn, out noticeMsg))
                {
                    throw new FisException("CHK1105", new string[] { pu.Type, pu.Pn, pu.Sn, noticeMsg??string.Empty});
                }
            }

            if (_needDefectComponentCheck)
            {
                IMiscRepository miscRep = RepositoryFactory.GetInstance().GetRepository<IMiscRepository>();
                IPartRepository partRep = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
                IList<IMES.DataModel.SysSettingInfo> SysSettingInfoList = partRep.GetSysSettingInfoes(new IMES.DataModel.SysSettingInfo { name = "DefectComponentPassStatus" });
                if (SysSettingInfoList == null || SysSettingInfoList.Count == 0)
                {
                    throw new FisException("PAK095", new string[] { "DefectComponentPassStatus" });
                }
                string[] passStatus = SysSettingInfoList[0].value.Split(new char[] { '~', ',', ';' });
                IList<IMES.DataModel.DefectComponentInfo> DefectComponentInfoList = miscRep.GetData<IMES.Infrastructure.Repository._Metas.DefectComponent, IMES.DataModel.DefectComponentInfo>(new IMES.DataModel.DefectComponentInfo { PartSn = pu.Sn });
                if (DefectComponentInfoList != null && DefectComponentInfoList.Count > 0)
                {
                    if (DefectComponentInfoList.Any(x => !passStatus.Contains(x.Status)))
                    {
                        throw new FisException("CQCHK1097", new string[] { pu.Sn, string.Join(",", DefectComponentInfoList.Select(x => x.Status).Distinct().ToArray()) });
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// 默认的PartCheck实现,只进行唯一性检查
        /// </summary>
        /// <param name="part">需要check的part</param>
        /// <param name="owner">PartOwner</param>
        public virtual void Check(IBOMPart part, IPartOwner owner, string station)
        {
            PartCheck checkSetting = this.GetPartCheckSettingData(part.ValueType);
            if (checkSetting == null)
            {
                string msg = string.Format("PartCheck data of {0} type does not exist.", part.Type);
                Exception ex = new Exception(msg);
                throw ex;
            }

            if (checkSetting.NeedCheck == 1)
            {
                string realSn = ProductPart.PartSpecialDeal(part.Type, part.ValueType, part.MatchedSn);
                owner.PartUniqueCheck(part.PN, realSn);
            }
        }