Exemplo n.º 1
0
        /// <summary>
        /// 刷第一个SN时,调用该方法启动工作流,根据输入CustSN获取PalletInfo,成功后调用InputCustSn
        /// 将custSN放到Session.CustSN中(string)
        /// 返回ArrayList
        /// </summary>
        public ArrayList InputFirstCustSn(string firstSn, string line, string editor, string station, string customer, out int index)
        {
            logger.Debug("(PalletVerifyOnlyImpl)InputCustSNOnCooLabel start, custsn:" + firstSn + "pdLine:" + line + "editor:" + editor + "station:" + station + "customer:" + customer);

            FisException ex;
            List<string> erpara = new List<string>();
            ArrayList retLst = new ArrayList();

            try
            {
                //根据输入的Customer S/N, 获得对应的Product
                var currentProduct = CommonImpl.GetProductByInput(firstSn, CommonImpl.InputTypeEnum.CustSN);
                if (string.IsNullOrEmpty(currentProduct.ProId))
                {
                    erpara.Add(firstSn);
                    ex = new FisException("CHK152", erpara);    //您所刷入的Customer S/N 无效 ,请重新刷入!
                    throw ex;

                }
                

                //取得Customer S/N 绑定的Delivery No :IMES_FA..Product.DeliveryNo
                if (string.IsNullOrEmpty(currentProduct.DeliveryNo))
                {
                    erpara.Add(firstSn);
                    ex = new FisException("PAK020", erpara);    //该Customer S/N还未与DN绑定!
                    throw ex;
                }
                string curDn = currentProduct.DeliveryNo;

                //获取Pallet No : IMES_FA..Product.PalletNo
                if (string.IsNullOrEmpty(currentProduct.PalletNo))
                {
                    erpara.Add(firstSn);
                    ex = new FisException("PAK021", erpara);     //该Customer S/N还未与Pallet绑定!
                    throw ex;
                }
                string currentPalletNo = currentProduct.PalletNo;
                
     

                string sessionKey = currentProduct.ProId;
                Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, Session.SessionType.Product);

                if (currentSession == null)
                {
                    currentSession = new Session(sessionKey, Session.SessionType.Product, editor, station, line, customer);

                    Dictionary<string, object> wfArguments = new Dictionary<string, object>();
                    wfArguments.Add("Key", sessionKey);
                    wfArguments.Add("Station", station);
                    wfArguments.Add("CurrentFlowSession", currentSession);
                    wfArguments.Add("Editor", editor);
                    wfArguments.Add("PdLine", line);
                    wfArguments.Add("Customer", customer);
                    wfArguments.Add("SessionType", Session.SessionType.Product);

                    string wfName, rlName;
                    RouteManagementUtils.GetWorkflow(station, "PalletVerifyFDEOnly.xoml", "PalletVerifyFDEOnly.rules", out wfName, out rlName);
                    WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments);

                    currentSession.AddValue(Session.SessionKeys.CustSN, firstSn);
                    currentSession.AddValue(Session.SessionKeys.PalletNo, currentPalletNo);
                    currentSession.AddValue(Session.SessionKeys.Product, currentProduct);
                    currentSession.AddValue(Session.SessionKeys.DeliveryNo, curDn);
                    currentSession.AddValue(Session.SessionKeys.IsComplete, false);

                    //For Check OA3
                    ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(CheckValidationResult);
                    IPartRepository partRepository = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
                    IList<ConstValueInfo> cvInfo = new List<ConstValueInfo>();
           
                    //ConstValueInfo cvCond = new ConstValueInfo();
                    //cvCond.type = "CheckOA3State";
                    //cvCond.name = "OA3UpSAP";
                    //bool bNeedCheckEOA = partRepository.GetConstValueInfoList(cvCond).Any(x => x.value == "Y");
    
                    string fkiPath = "";
                    string fkiUser = "";
                    string fkiPwd = "";
                    bool bNoNeedCheckEOA=false;
                    GetAndCheckOA3Setting(currentProduct.Model, out fkiPath, out fkiUser, out fkiPwd, out bNoNeedCheckEOA);

                    //string fkiPath = System.Configuration.ConfigurationManager.AppSettings["FKIServicePath"].Trim();
                    //string fkiUser = System.Configuration.ConfigurationManager.AppSettings["FKIAuthUser"].Trim();
                    //string fkiPwd = System.Configuration.ConfigurationManager.AppSettings["FKIAuthPassword"].Trim();
                    currentSession.AddValue("FKIServicePath", fkiPath);
                    currentSession.AddValue("FKIAuthUser", fkiUser);
                    currentSession.AddValue("FKIAuthPassword", fkiPwd);
                    CommonImpl2 cmm2 = new CommonImpl2();
                    CredentialCache FKICredentialCache = new CredentialCache();
                    if (fkiUser.Contains("\\"))
                    {
                        string user = fkiUser.Substring(fkiUser.IndexOf('\\') + 1);
                        string domain = fkiUser.Substring(0, fkiUser.IndexOf('\\'));
                        FKICredentialCache.Add(new System.Uri(fkiPath), "NTLM", new System.Net.NetworkCredential(user, fkiPwd, domain));
                    }
                    else
                    {
                        FKICredentialCache.Add(new System.Uri(fkiPath), "NTLM", new System.Net.NetworkCredential(fkiUser, fkiPwd));
                    }
                    IMES.FisObject.FA.Product.IProduct prd = (IMES.FisObject.FA.Product.IProduct)currentProduct;
                    IPartRepository partRep = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
                    IBOMRepository bomRep = RepositoryFactory.GetInstance().GetRepository<IBOMRepository>();
                   // bool bNoNeedCheckEOA = partRepository.GetValueFromSysSettingByName("DisableOA3CheckOnPallet").
                                                             //  Any(x => x == "Y");
                    IList<IMES.DataModel.ConstValueTypeInfo> lstConst = partRep.GetConstValueTypeList("NoCheckOA3SN");
                    if (!lstConst.Any(x => x.value == currentProduct.CUSTSN) && !bNoNeedCheckEOA)
                    {
                         IHierarchicalBOM bom = bomRep.GetHierarchicalBOMByModel(currentProduct.Model);
                        if (!cmm2.CheckOA3Key(bom, prd, fkiPath, FKICredentialCache, editor, (UnitOfWork)currentSession.UnitOfWork))
                        {
                            throw new FisException("PAK158", new string[] { currentProduct.CUSTSN, currentProduct.DeliveryNo });
                        }
                    }

                    //For Check OA3

                    currentSession.SetInstance(instance);

                    if (!SessionManager.GetInstance.AddSession(currentSession))
                    {
                        currentSession.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists.");
                        erpara.Add(sessionKey);
                        ex = new FisException("CHK020", erpara);
                        throw ex;
                    }

                    currentSession.WorkflowInstance.Start();
                    currentSession.SetHostWaitOne();
                }
                else
                {
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK020", erpara);
                    throw ex;
                }


                if (currentSession.Exception != null)
                {
                    if (currentSession.GetValue(Session.SessionKeys.WFTerminated) != null)
                    {
                        currentSession.ResumeWorkFlow();
                    }

                    throw currentSession.Exception;
                }
               

                // 获取该Pallet 上的SKU 列表
                // 该Pallet 上的SKU 列表:IMES_FA..Product.PalletNo = @PalletNo的所有记录
                // SKU 列表显示如下信息:Product ID | Customer S/N | PAQC | POD | WC | Collection Data
                // 按照Customer S/N 升序排序
                IList<string> productNoList = new List<string>();
                IList<string> custSnList = new List<string>();
                
                // retLst[0]-[2]
                string dummyPalletNo = string.Empty;
                dummyPalletNo = (string)currentSession.GetValue(Session.SessionKeys.DummyPalletNo);
                productNoList = (IList<string>) currentSession.GetValue(Session.SessionKeys.ProdNoList);
                custSnList = (IList<string>) currentSession.GetValue(Session.SessionKeys.CustomSnList);
                retLst.Add(dummyPalletNo);
                retLst.Add(productNoList);
                retLst.Add(custSnList);

                IProductRepository iproductRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IMES.FisObject.FA.Product.IProduct>();
                
                // Mantis Bug :http://10.99.183.26/Mantis/view.php?id=627 (改为前台页面收集scanProductNoList)
                // Update IMES_FA..ProductStatus ( 更新Pallet 上已收集的PRODUCT 的状态)
                //IList<string> scanProductNoList = new List<string>();
                //scanProductNoList.Add(currentProduct.ProId);
                //currentSession.AddValue(Session.SessionKeys.NewScanedProductIDList, scanProductNoList);
                
                int i = 0;
                index = 0;
                foreach (string iprod in productNoList)
                {
                  
                  if (iprod== currentProduct.ProId && custSnList[i] == firstSn)
                    {
                        index = i+1;
                        break;
                    }
                  else i++;
                }
               
                // PAQC –retLst[3]: 使用ProductID = @ProductId and Tp = 'PAQC' 查询IMES_FA..QCStatus 表取Udt 最新的记录,如果该记录的Status = '8',则PAQC 栏位显示'PAQC';Status = '9',则PAQC 栏位显示'Pass';Status = 'A',则PAQC 栏位显示'Fail';Status = '1',则PAQC 栏位显示'No Check';
                IDeliveryRepository ideliveryRepository = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>();
                IList<string> PAQCStatusLst = new List<string>();
                foreach (string iprod in productNoList)
                {
                    ProductQCStatus qcsStatus = ideliveryRepository.GetQCStatus(iprod, "PAQC");
                    if (qcsStatus == null || string.IsNullOrEmpty(qcsStatus.Status))
                    {
                        erpara.Add(iprod);
                        erpara.Add("PAQC");
                        ex = new FisException("PAK051", erpara);    //QCStatus 中Product%1 的参数 %2 不存在!
                        throw ex;
                    }
                    switch (qcsStatus.Status)
                    {
                        case "8":
                        case "B":
                        case "C":
                            PAQCStatusLst.Add("PAQC");
                            break;
                        case "9":
                            // ITC-1360-1235 : 小写
                            // PAQCStatusLst.Add("PASS");
                            PAQCStatusLst.Add("Pass");
                            break;
                        case "A":
                            PAQCStatusLst.Add("Fail");
                            break;
                        case "1":
                            PAQCStatusLst.Add("No Check");
                            break;
                        default:
                            PAQCStatusLst.Add("");
                            break;
                    }

                }

                retLst.Add(PAQCStatusLst);      


                // POD –retLst[4]: 检查IMES_FA..ProductLog,如果存在Station = 'PD' 的记录,则POD 栏位显示'PD';如果存在Station = '86' 的记录,则POD 栏位显示'86';
                // WC –retLst[5]: IMES_ProductStatus.Station
                // UC Revision: 7422:检查IMES_FA..ProductLog,如果存在Station = ’86' 的记录,则POD 栏位显示'86';否则如果存在Station = 'PD' 的记录,则POD 栏位显示'PD';两者都不存在时,显示为空
                IList<string> PODLst = new List<string>();
                IList<string> WCLst = new List<string>();
                foreach (string prodid in productNoList)
                {
                    IList<ProductLog> prodLogLst = new List<ProductLog>();
                    prodLogLst = iproductRepository.GetProductLogs(prodid, "86");
                    if (prodLogLst.Count> 0)
                    {
                        PODLst.Add("86");
                    }
                    else
                    {
                        prodLogLst = iproductRepository.GetProductLogs(prodid, "PD");
                        if (prodLogLst.Count > 0)
                        {
                            PODLst.Add("PD");
                        }
                        else
                        {
                            PODLst.Add("");
                        }
                    }

                    ProductStatusInfo productStatus = iproductRepository.GetProductStatusInfo(prodid);
                    if (productStatus.station != null)
                    {
                        WCLst.Add(productStatus.station);
                    }
                    else
                    {
                        erpara.Add(prodid);
                        ex = new FisException("PAK026", erpara);    //没有Product Status 站数据!
                        throw ex;
                    }

                }
                retLst.Add(PODLst);
                retLst.Add(WCLst);
                
                // Collection Data 为空 - retLst[6]
                retLst.Add("");

                // Pallet Qty -retLst[7]: (Sum(IMES_PAK..Delivery_Pallet.DeliveryQty))
                //int palletQty =0;
                //IList<DeliveryPallet> dnpltlist = new List<DeliveryPallet>();
                //IPalletRepository iPalletRepository = RepositoryFactory.GetInstance().GetRepository<IPalletRepository, Pallet>();
                //dnpltlist= iPalletRepository.GetDeliveryPallet(currentPalletNo);
                //if (dnpltlist != null && dnpltlist.Count > 0)
                //{
                //   foreach (DeliveryPallet dp in dnpltlist)
                //   {
                //       palletQty += dp.DeliveryQty;
                //   }
                //}
                //else
                //{
                //    erpara.Add(currentPalletNo);
                //    ex = new FisException("PAK027", erpara);    //没有获得当前Pallet的DeliveryQty!
                //    throw ex;
                //}

               string palletQty = (string)currentSession.GetValue(Session.SessionKeys.PalletQty);
               retLst.Add(palletQty);

               // Scan Qty - retLst[8]: 
               string scanQty = (string)currentSession.GetValue(Session.SessionKeys.ScanQty);
               retLst.Add(scanQty);
               
               // DPC - retLst[9]: 
               string DPC = (string)currentSession.GetValue(Session.SessionKeys.DummyPalletCase);
               retLst.Add(DPC);
               
               // total Qty - retLst[10]:
               string totalQty = (string)currentSession.GetValue(Session.SessionKeys.Qty);
               retLst.Add(totalQty);

               return retLst;             

            }
            catch (FisException e)
            {
                logger.Error(e.mErrmsg, e);
                throw new Exception(e.mErrmsg);
            }
            catch (Exception e)
            {
                logger.Error(e.Message, e);
                throw new SystemException(e.Message);
            }
            finally
            {
                logger.Debug("(PalletVerifyOnlyImpl)InputCustSNOnCooLabel end, custsn:" + firstSn + "pdLine:" + line + "editor:" + editor + "station:" + station + "customer:" + customer);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 刷第一个SN时,调用该方法启动工作流,根据输入CustSN获取PalletInfo,成功后调用InputCustSn
        /// 将custSN放到Session.CustSN中(string)
        /// 在获取了Pallet No 后,要进行Delivery Download Check,以保证并板情况下,该Pallet 所对应的Delivery 资料Download 完毕。
        /// 检查方法如下:
        ///     取得Customer S/N 绑定的Delivery No (IMES_FA..Product.DeliveryNo)
        ///     取得该Delivery No 的Consolidated 属性(IMES_PAK.DeliveryInfo)
        ///     如果Consolidated 属性存在,则解析Consolidated 属性(Consolidated 属性以'/' 为分隔符,分为两部分,前面的为Consolidate No,后面为Delivery数量),得到并板的Consolidate No 和Delivery 数量
        ///     使用Consolidate No 检索IMES_PAK.DeliveryInfo 表,取得相关记录,统计这些记录共有多少个不同的LEFT(DeliveryNo,10),该数据如果小于前面查询到的Delivery 的Consolidated 属性中定义的并板的Delivery 数量,则报告错误:“Delivery No 未完全Download!”
        ///     SELECT COUNT(DISTINCT LEFT(DeliveryNo,10)) AS Expr1
        ///     FROM IMES_PAK.dbo.DeliveryInfo
        ///     where InfoValue like @ConsolidateNo and InfoType = 'Consolidated'
        /// 返回ArrayList
        /// </summary>
        public ArrayList InputFirstCustSn(string sCheckBoxId,string firstSn, string line, string editor, string station, string customer, out int index, out string labeltypeBranch)
        {
            logger.Debug("(PalletVerifyImpl)InputCustSNOnCooLabel start, custsn:" + firstSn + "pdLine:" + line + "editor:" + editor + "station:" + station + "customer:" + customer);

            FisException ex;
            List<string> erpara = new List<string>();
            ArrayList retLst = new ArrayList();

            try
            {
                //根据输入的Customer S/N, 获得对应的Product
                var currentProduct = CommonImpl.GetProductByInput(firstSn, CommonImpl.InputTypeEnum.CustSN);
                if (string.IsNullOrEmpty(currentProduct.ProId))
                {
                    erpara.Add(firstSn);
                    ex = new FisException("CHK152", erpara);    //您所刷入的Customer S/N 无效 ,请重新刷入!
                    throw ex;

                }
                else
                {
                    if (CheckCTObyDN(currentProduct.DeliveryNo))
                    {
                        if (!CheckPODLabel(currentProduct))
                        {
                            throw new FisException("PAK172", erpara);
                        }
                    }
                
                }
            
                //取得Customer S/N 绑定的Delivery No :IMES_FA..Product.DeliveryNo
                if (string.IsNullOrEmpty(currentProduct.DeliveryNo))
                {
                    erpara.Add(firstSn);
                    ex = new FisException("PAK020", erpara);    //该Customer S/N还未与DN绑定!
                    throw ex;
                }
                string curDn = currentProduct.DeliveryNo;

                //获取Pallet No : IMES_FA..Product.PalletNo
                if (string.IsNullOrEmpty(currentProduct.PalletNo))
                {
                    erpara.Add(firstSn);
                    ex = new FisException("PAK021", erpara);     //该Customer S/N还未与Pallet绑定!
                    throw ex;
                }
                string currentPalletNo = currentProduct.PalletNo;

                if (currentPalletNo.Substring(0, 2) == "BA" || currentPalletNo.Substring(0, 2) == "NA")
                {
                    erpara.Add(currentPalletNo);
                    ex = new FisException("PAK044", erpara);     //散装Pallet,不能使用此功能!
                    throw ex;
                }

                //获取Pallet Info
                IPalletRepository iPalletRepository = RepositoryFactory.GetInstance().GetRepository<IPalletRepository, Pallet>();
                Pallet CurrentPallet = null;
                CurrentPallet = iPalletRepository.Find(currentPalletNo);
                if (CurrentPallet == null)
                {
                    erpara.Add(currentProduct.PalletNo);
                    ex = new FisException("CHK106", erpara);    // Pallet不存在!
                    throw ex;
                }
                IProductRepository iproductRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IMES.FisObject.FA.Product.IProduct>();
                IDeliveryRepository ideliveryRepository = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>();

                //2012/10/18	如果Pallet 结合的Delivery 为自动单(Pallet 结合的Delivery 的Flag 属性=’N’)时,如果Pallet 上所有Product 结合的BoxId有重复,则报告错误:“此Pallet 上的Product 结合的Box Id 有重复,请检查!”
                //IProductRepository::IList<ProductInfo> GetProductInfoListByPalletNo(ProductInfo condition, string palletNo);
                //----------------------------------------------------------------------
                //UC Update: 2012/10/25  BoxId 加:UCC
                //string Autoflag = ideliveryRepository.GetDeliveryInfoValue(curDn, "Flag");
                //如果Pallet 结合的Delivery 为自动单(Pallet 结合的Delivery 的Flag 属性=’N’)时,如果Pallet 上所有Product 结合的BoxId or UCC数量和Pallet 上所有Product数量不同,则报告错误:“此Pallet 上的Product 结合的Box Id or UCC数量不正确,请检查!”
                //if ((Autoflag == "N") && (sCheckBoxId =="Y"))
                //{
                    //IList<IMES.FisObject.FA.Product.ProductInfo> ProductsInfolst = new List<IMES.FisObject.FA.Product.ProductInfo>();
                    //var conProductInfo = new IMES.FisObject.FA.Product.ProductInfo();
                    //conProductInfo.InfoType = "BoxId";
                    //ProductsInfolst = iproductRepository.GetProductInfoListByPalletNo(conProductInfo,currentProduct.PalletNo);
                    //if ((ProductsInfolst==null)||(ProductsInfolst.Count ==0))
                    //{
                    //    //获取失败,这种情况应该不存在
                    //    erpara.Add(currentProduct.PalletNo);
                    //    ex = new FisException("PAK098", erpara);    // Pallet不存在!
                    //    throw ex;
                    //}
                    //else
                    //{
                    //   var boxidquery =
                    //       from q in ProductsInfolst
                    //       group q by q.InfoValue into gboxid
                    //       where gboxid.Count() >= 2
                    //       select new
                    //      {
                    //          _Boxid = gboxid.Key,
                    //          _Count = gboxid.Count()
                    //      };
                    //    if (boxidquery.Count() != 0)
                    //    {
                    //        //Product 结合的Box Id 有重复
                    //        var dupBoxid = "";
                    //        foreach (var vq in boxidquery)
                    //        {
                    //            dupBoxid = vq._Boxid;
                    //            break;
                    //        }
                    //        var prodidquery =
                    //            from qq in ProductsInfolst
                    //            where qq.InfoValue == dupBoxid
                    //            select qq;
                    //        var errProdidstring = "";
                    //        foreach (var vp in prodidquery)
                    //        {
                    //            if (errProdidstring == "")
                    //                errProdidstring = vp.ProductID;
                    //            else
                    //                errProdidstring = errProdidstring + ", " + vp.ProductID;
                    //        }

                    //        erpara.Add(currentProduct.PalletNo);
                    //        erpara.Add(errProdidstring);
                    //        erpara.Add(dupBoxid);
                    //        ex = new FisException("CHK963", erpara);    // 此Pallet 上的Product 结合的Box Id 有重复,请检查!!
                    //        throw ex;
                    //    }
                    //  }
                    //}
                //----------------------------------------------------------------------

                //if (!CurrentPallet.IsPalletFull(string.Empty))
                //{
                //    FisException fe = new FisException("CHK122", new string[] { currentProduct.PalletNo });
                //    throw fe;
                //}
                

                // 获取该Pallet 上的SKU 列表
                // 该Pallet 上的SKU 列表:IMES_FA..Product.PalletNo = @PalletNo的所有记录
                // SKU 列表显示如下信息:Product ID | Customer S/N | PAQC | POD | WC | Collection Data
                // 按照Customer S/N 升序排序
             
                IList<ProductModel> prodModelLst = new List<ProductModel>();
                prodModelLst = iproductRepository.GetProductListByPalletNoOrderByCustSN(currentPalletNo);
                int countInPallet = prodModelLst.Count;
            
                bool isBsamOrTablet = false; 
                if (prodModelLst == null || prodModelLst.Count <= 0)
                {
                    erpara.Add(firstSn);
                    ex = new FisException("CHK079", erpara);    //找不到与此序号 %1 匹配的Product! 
                    throw ex;
                }
                IBSamRepository bsamRepository = RepositoryFactory.GetInstance().GetRepository<IBSamRepository, BSamLocation>();
                BSamModel bsamModel = bsamRepository.GetBSamModel(currentProduct.Model);
                if (bsamModel != null || checkIsTablet(currentProduct))
                { isBsamOrTablet = true; }
             
                //UC Update: 2012/10/25  BoxId 加:UCC
                //如果Pallet 结合的Delivery 为自动单(Pallet 结合的Delivery 的Flag 属性=’N’)时,如果Pallet 上所有Product 结合的BoxId or UCC数量和Pallet 上所有Product数量不同,则报告错误:“此Pallet 上的Product 结合的Box Id or UCC数量不正确,请检查!”
                //----------------------------------------------------------------------------------------------------------------------
                string Autoflag = ideliveryRepository.GetDeliveryInfoValue(curDn, "Flag");
                if ((Autoflag == "N") && (sCheckBoxId == "Y"))
                {
                  
                    //For BSAM
                //    if (bsamModel != null || checkIsTablet(currentProduct))
                    if (isBsamOrTablet)
                    {
                      //  ICartonRepository cartonRep = RepositoryFactory.GetInstance().GetRepository<ICartonRepository, Carton>();
                      //  int cartonQty=  cartonRep.GetAssignedPalletCartonQty(currentProduct.PalletNo);
                      ////  int sumDnQty = iPalletRepository.GetDeliveryPallet(currentPalletNo).Sum(x => x.DeliveryQty);

                      // //Vincent 2013-10-07:併Carton case造成從Delivery_Pallet table計算carton 樹有問題,須重DeliveryInfo.PalletQty來計算Carton 總數
                      //  // int sumDnQty = ideliveryRepository.GetSumDeliveryQtyOfACertainPallet(currentProduct.PalletNo);
                      //  int sumDnQty = ideliveryRepository.GetFullPalletCartonQtyByDeliveryPallet(currentProduct.DeliveryNo, currentProduct.PalletNo);
                      //  if (sumDnQty != cartonQty)
                      //  {
                      //      erpara.Add(currentProduct.PalletNo);
                      //      ex = new FisException("CHK963", erpara);    //此Pallet 上的Product 结合的Box Id or UCC数量不正确,请检查! 
                      //      throw ex;
                      //  }

                       CommonUtl.CheckDeliveryPalletCartonQty(currentProduct.PalletNo);

                    }
                    else
                    {
                        //NEW Interface:2012/12/25
                        //IProductRepository::int GetCountOfInfoValueInProductInfo(string palletNo, string[] infoTypes);
                        string[] param = { "BoxId ", "UCC" };
                        int productsInfolstcount = iproductRepository.GetCountOfInfoValueInProductInfo(currentProduct.PalletNo, param);
                        if (productsInfolstcount != prodModelLst.Count)
                        {
                            erpara.Add(currentProduct.PalletNo);
                            ex = new FisException("CHK963", erpara);    //此Pallet 上的Product 结合的Box Id or UCC数量不正确,请检查! 
                            throw ex;
                        }
                    }
                }
                //----------------------------------------------------------------------------------------------------------------------
                IList<string> productNoList = new List<string>();
                IList<string> custSnList = new List<string>();
                int i = 0;
                index = 0;
                string curInfoBoxID = "";
                string curShipBoxDetID = "";

                foreach (ProductModel prod in prodModelLst)
                {
                    productNoList.Add(prod.ProductID);
                    custSnList.Add(prod.CustSN);
                    
                    if (prod.ProductID == currentProduct.ProId && prod.CustSN == firstSn)
                    {
                       //2012/10/25 取消检查每个Product 结合的Box Id 或UCC 的正确性
                       //--------------------------------------------------------------------------------------
                        ////Productinfo
                        //curInfoBoxID = iproductRepository.GetProductInfoValue(prod.ProductID, "BoxId");

                        ////ShipBoxDet
                        //IList<ShipBoxDetInfo> shipList;
                        //ShipBoxDetInfo shipInfo;
                        ////shipList = ideliveryRepository.GetShipBoxDetList(curDn, currentPalletNo, prod.ProductID);
                        //var conshipdet = new ShipBoxDetInfo();
                        //conshipdet.snoId = prod.ProductID;
                        //shipList = ideliveryRepository.GetShipBoxDetInfoListByCondition(conshipdet);

                        //if (shipList.Count != 0)
                        //{
                        //    shipInfo = shipList[0];
                        //    curShipBoxDetID=shipInfo.boxId;
                        //}
                        //--------------------------------------------------------------------------------------
                        index = i+1;
                       // break;
                    }
                    else i++;
                }

                // retLst[0]-[2]
                retLst.Add(currentPalletNo);
                retLst.Add(productNoList);
                retLst.Add(custSnList);
     

                string sessionKey = currentProduct.ProId;
                Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, Session.SessionType.Product);
                if (currentSession == null)
                {
                    currentSession = new Session(sessionKey, Session.SessionType.Product, editor, station, line, customer);

                    Dictionary<string, object> wfArguments = new Dictionary<string, object>();
                    wfArguments.Add("Key", sessionKey);
                    wfArguments.Add("Station", station);
                    wfArguments.Add("CurrentFlowSession", currentSession);
                    wfArguments.Add("Editor", editor);
                    wfArguments.Add("PdLine", line);
                    wfArguments.Add("Customer", customer);
                    wfArguments.Add("SessionType", Session.SessionType.Product);

                    string wfName, rlName;
                    RouteManagementUtils.GetWorkflow(station, "PalletVerify.xoml", "PalletVerify.rules", out wfName, out rlName);
                    WorkflowInstance instance = WorkflowRuntimeManager.getInstance.CreateXomlFisWorkflow(wfName, rlName, wfArguments);

                    currentSession.AddValue(Session.SessionKeys.CustSN, firstSn);
                    currentSession.AddValue(Session.SessionKeys.PalletNo, currentPalletNo);
                    currentSession.AddValue(Session.SessionKeys.Pallet, CurrentPallet);
                    currentSession.AddValue(Session.SessionKeys.Product, currentProduct);
                    currentSession.AddValue(Session.SessionKeys.ProdNoList, productNoList); 
                    currentSession.AddValue(Session.SessionKeys.NewScanedProductIDList, productNoList); // UpdateProductListStatusByProdID (Update IMES_FA..ProductStatus – 更新Pallet 上所有PRODUCT 的状态)
                    currentSession.AddValue(Session.SessionKeys.CustomSnList, custSnList);
                    currentSession.AddValue(Session.SessionKeys.DeliveryNo, curDn);
                    currentSession.AddValue(Session.SessionKeys.IsComplete, false);

                    // ***************** For Check OA3 *****************
                  
                    ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(CheckValidationResult);
                    IPartRepository partRepository = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
                    IBOMRepository bomRep = RepositoryFactory.GetInstance().GetRepository<IBOMRepository>();
                    string fkiPath = "";
                    string fkiUser = "";
                    string fkiPwd = "";
                    bool bNoNeedCheckEOA = false;
                    GetAndCheckOA3Setting(currentProduct.Model, out fkiPath, out fkiUser, out fkiPwd, out bNoNeedCheckEOA);
                    currentSession.AddValue("FKIServicePath", fkiPath);
                    currentSession.AddValue("FKIAuthUser", fkiUser);
                    currentSession.AddValue("FKIAuthPassword", fkiPwd);
                    CommonImpl2 cmm2 = new CommonImpl2();
                    CredentialCache FKICredentialCache = new CredentialCache();
                    if (fkiUser.Contains("\\"))
                    {
                        string user = fkiUser.Substring(fkiUser.IndexOf('\\') + 1);
                        string domain = fkiUser.Substring(0, fkiUser.IndexOf('\\'));
                        FKICredentialCache.Add(new System.Uri(fkiPath), "NTLM", new System.Net.NetworkCredential(user, fkiPwd, domain));
                    }
                    else
                    {
                        FKICredentialCache.Add(new System.Uri(fkiPath), "NTLM", new System.Net.NetworkCredential(fkiUser, fkiPwd));
                    }
                    IMES.FisObject.FA.Product.IProduct prd= (IMES.FisObject.FA.Product.IProduct)currentProduct;
                
                    // bNoNeedCheckEOA = partRepository.GetValueFromSysSettingByName("DisableOA3CheckOnPallet").
                                                            // Any(x => x == "Y");

                    IList<IMES.DataModel.ConstValueTypeInfo> lstConst = partRepository.GetConstValueTypeList("NoCheckOA3SN");
                    if (!lstConst.Any(x => x.value == currentProduct.CUSTSN) && !bNoNeedCheckEOA)
                    {
                        IHierarchicalBOM bom = bomRep.GetHierarchicalBOMByModel(currentProduct.Model);
                        if (!cmm2.CheckOA3Key(bom, currentProduct, fkiPath, FKICredentialCache, editor, (UnitOfWork)currentSession.UnitOfWork))
                        {
                          throw new FisException("PAK158", new string[] { currentProduct.CUSTSN, currentProduct.DeliveryNo });
                        }
                    }

                    // ***************** For Check OA3 *****************
                 

                    currentSession.SetInstance(instance);

                    if (!SessionManager.GetInstance.AddSession(currentSession))
                    {
                        currentSession.WorkflowInstance.Terminate("Session:" + sessionKey + " Exists.");
                        erpara.Add(sessionKey);
                        ex = new FisException("CHK020", erpara);
                        throw ex;
                    }

                    currentSession.WorkflowInstance.Start();
                    currentSession.SetHostWaitOne();
                }
                else
                {
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK020", erpara);
                    throw ex;
                }


                if (currentSession.Exception != null)
                {
                    if (currentSession.GetValue(Session.SessionKeys.WFTerminated) != null)
                    {
                        currentSession.ResumeWorkFlow();
                    }

                    throw currentSession.Exception;
                }
                
                               
                
                //Delivery Download Check,以保证并板情况下,该Pallet 所对应的Delivery 资料Download 完毕。
                //取得该Delivery No 的Consolidated 属性(IMES_PAK.DeliveryInfo)
                //如果Consolidated 属性存在,则解析Consolidated 属性(Consolidated 属性以'/' 为分隔符,分为两部分,前面的为Consolidate No,后面为Delivery数量),得到并板的Consolidate No 和Delivery 数量
                //IDeliveryRepository ideliveryRepository = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>();
                string Consolidated = string.Empty;
                Consolidated = ideliveryRepository.GetDeliveryInfoValue(curDn, "Consolidated");
                // SVN 2569: 如果Consolidated 属性不存在或者为空,则不用进行Delivery Download Check
                if (!string.IsNullOrEmpty(Consolidated))
                {
                    string[] pattern = Consolidated.Split('/');
                    string ConsolidateNo = string.Empty;
                    int dnQty = 0;
                    if (pattern.Length.ToString() != "2" || string.IsNullOrEmpty(pattern[0]) || string.IsNullOrEmpty(pattern[1]))
                    {
                        erpara.Add(curDn);
                        ex = new FisException("PAK024", erpara);  //找不到该Delivery No 的Consolidated 属性
                        throw ex;
                    }
                    ConsolidateNo = pattern[0];
                    dnQty = Int32.Parse(pattern[1]);

                    //使用Consolidate No 检索IMES_PAK.DeliveryInfo 表,取得相关记录,统计这些记录共有多少个不同的LEFT(DeliveryNo,10),该数据如果小于前面查询到的Delivery 的Consolidated 属性中定义的并板的Delivery 数量,则报告错误:“Delivery No 未完全Download!”
                    int DistinctDNQty = 0;
                    DistinctDNQty = ideliveryRepository.GetDistinctDeliveryNo(ConsolidateNo);
                    if (DistinctDNQty < dnQty)
                    {
                        erpara.Add(curDn);
                        ex = new FisException("PAK018", erpara);    //Delivery No 未完全Download!
                        throw ex;
                    }

                    int SumCartonQty = 0;
                    int SumDnPallletQty = 0;
                    IList<Delivery> dnList = ideliveryRepository.GetDeliveryListByInfoTypeAndValue("Consolidated", Consolidated);
                    foreach (Delivery dn in dnList)
                    {

                        SumCartonQty += dn.Qty;
                        int DnPallletQty = ideliveryRepository.GetSumDeliveryQtyOfACertainDN(dn.DeliveryNo);
                        SumDnPallletQty += DnPallletQty;
                    }
                    //临时注释掉,保出货
                    //if (SumCartonQty != SumDnPallletQty)
                    //{
                    //    //从整机库get
                    //    {
                    //        erpara.Add(currentProduct.PalletNo);
                    //        ex = new FisException("CHK903", erpara);    //PALLET  未完全Download!
                    //        throw ex;
                    //    }
                    //}
                }
                // PAQC –retLst[3]: 使用ProductID = @ProductId and Tp = 'PAQC' 查询IMES_FA..QCStatus 表取Udt 最新的记录,如果该记录的Status = '8',则PAQC 栏位显示'PAQC';Status = '9',则PAQC 栏位显示'Pass';Status = 'A',则PAQC 栏位显示'Fail';Status = '1',则PAQC 栏位显示'No Check';
                IList<string> PAQCStatusLst = new List<string>();
                foreach ( string iprod in productNoList)
                {
                    ProductQCStatus qcsStatus = ideliveryRepository.GetQCStatus(iprod, "PAQC");
                    if (qcsStatus ==null || string.IsNullOrEmpty(qcsStatus.Status))
                    {
                        erpara.Add(iprod);
                        erpara.Add("PAQC");
                        ex = new FisException("PAK051", erpara);    //QCStatus 中Product%1 的参数 %2 不存在!
                        throw ex;
                    }
                    switch (qcsStatus.Status)
                    {
                        case "8":
                        case "B":
                        case "C":
                            PAQCStatusLst.Add("PAQC");
                            break;
                        case "9":
                           // ITC-1360-1235 : 小写
                           // PAQCStatusLst.Add("PASS");
                            PAQCStatusLst.Add("Pass");
                            break;
                        case "A":
                            PAQCStatusLst.Add("Fail");
                            break;
                        case "1":
                            PAQCStatusLst.Add("No Check");
                            break;
                        default:
                            PAQCStatusLst.Add("");
                            break;
                    }

                }
                
                retLst.Add(PAQCStatusLst);    


                // POD –retLst[4]: 检查IMES_FA..ProductLog,如果存在Station = 'PD' 的记录,则POD 栏位显示'PD';如果存在Station = '86' 的记录,则POD 栏位显示'86';
                // WC –retLst[5]: IMES_ProductStatus.Station
                // UC Revision: 7366:修正POD 栏位数据的获取方法 :检查IMES_FA..ProductLog,如果存在Station = 'PD' 的记录,但不存在Station = '86' 的记录时,则POD 栏位显示'PD';如果存在Station = '86' 的记录,则POD 栏位显示'86';两者都不存在时,显示为空
                // UC Revision: 7422:检查IMES_FA..ProductLog,如果存在Station = ’86' 的记录,则POD 栏位显示'86';否则如果存在Station = 'PD' 的记录,则POD 栏位显示'PD';两者都不存在时,显示为空
                IList<string> PODLst = new List<string>();
                IList<string> WCLst = new List<string>();
              
                foreach (string prodid in productNoList)
                {
                    IList<ProductLog> prodLogLst = new List<ProductLog>();
                    prodLogLst = iproductRepository.GetProductLogs(prodid, "86");
                    if (prodLogLst.Count> 0)
                    {
                        PODLst.Add("86");
                    }
                    else
                    {
                        prodLogLst = iproductRepository.GetProductLogs(prodid, "PD");
                        if (prodLogLst.Count > 0)
                        {
                            PODLst.Add("PD");
                        }
                        else
                        {
                            PODLst.Add("");
                        }
                    }

                    ProductStatusInfo productStatus = iproductRepository.GetProductStatusInfo(prodid);
                    if (productStatus.station != null)
                    {
                        WCLst.Add(productStatus.station);
                    }
                    else
                    {
                        erpara.Add(prodid);
                        ex = new FisException("PAK026", erpara);    //没有Product Status 站数据!
                        throw ex;
                    }

                }
                retLst.Add(PODLst);
                retLst.Add(WCLst);
                
                // Collection Data 为空 - retLst[6]
                retLst.Add("");

                // Pallet Qty -retLst[7]: (Sum(IMES_PAK..Delivery_Pallet.DeliveryQty))
                int palletQty =0;
                int sumDeviceQty = 0;
                IList<DeliveryPallet> dnpltlist = new List<DeliveryPallet>();
                IList<string> DeliveryPerPalletList = new List<string>();
                IList<string> modelList = new List<string>();
            
                dnpltlist= iPalletRepository.GetDeliveryPallet(currentPalletNo);
                if (dnpltlist != null && dnpltlist.Count > 0)
                {
                   foreach (DeliveryPallet dp in dnpltlist)
                   {
                       palletQty += dp.DeliveryQty;
                       sumDeviceQty += dp.DeviceQty;
                       DeliveryPerPalletList.Add(dp.DeliveryID);
                       Delivery currentDelivery = ideliveryRepository.Find(dp.DeliveryID);
                       modelList.Add(currentDelivery.ModelName);
                   }
                }
                else
                {
                    erpara.Add(currentPalletNo);
                    ex = new FisException("PAK027", erpara);    //没有获得当前Pallet的DeliveryQty!
                    throw ex;
                }

              // retLst.Add(palletQty.ToString());

                if (isBsamOrTablet)
                {
                    //retLst.Add(countInPallet.ToString()); For Mantis 0001035]: PalletVerify界面针对平板和BSam的页面显示PalletQty需要防止资料异常
                    retLst.Add(sumDeviceQty.ToString());
                }
                else
                {
                    retLst.Add(palletQty.ToString());
                }


               // retLst[8]: SVN 2569: 9.	Scan '9999' or 'EMEA':当前Delivery 的RegId (IMES_PAK..DeliveryInfo.InfoValue, Condition: InfoType = 'RegId')属性
               string infoValue = string.Empty;
               infoValue = ideliveryRepository.GetDeliveryInfoValue(curDn, "RegId");
               if (String.IsNullOrEmpty(infoValue))
               {
                   //erpara.Add("RegId");
                   //ex = new FisException("PAK047", erpara);    //没有InfoType为 %1 的DeliveryInfo!
                   //throw ex;
                   infoValue = string.Empty;
               }
               retLst.Add(infoValue);

               //string PLEditsURL = string.Empty;
               //string PLEditsTemplate = string.Empty;
               //string PLEditsXML = string.Empty;
               //string PLEditsPDF = string.Empty;
               //string PLEditsImage = string.Empty;
               //string FOPFullFileName = string.Empty;
               
               IList<string> PDFPLLst = new List<string>();

               //当EDI_RegId = 'SNE' or 'SCE'时, Emea = 1;否则, Emea = 0
               decimal emea =0;

               //  SVN 2569: 自动单和手动单列印 (printflag =="C",表示手动单;否则表示自动单)
               labeltypeBranch = string.Empty;
               string printflag = ideliveryRepository.GetDeliveryInfoValue(curDn, "Flag");
               if (printflag == "SNE" || printflag == "SCE")
               {
                   emea = 1;
               }
               else emea = 0;
              
                if (printflag == "C")
               {
                   string cpmoflag = ideliveryRepository.GetDeliveryInfoValue(curDn, "Carrier");
                   if (cpmoflag == "XJ")
                   {
                       labeltypeBranch = "X";   //手动单:Pallet Label + CPMO Label
                   }
                   else labeltypeBranch = "C";   // 手动单:Pallet Label 
               }
               else
               {
                   labeltypeBranch = "A"; // 自动单:Pallet Label 

                   //UC Revision: 7636:要求Edits 文档所在的网络路径可配置:
                   // (\\hp-iis\OUT\)需要查询SysSetting 表获取, 参考方法:select Value from SysSetting nolock where Name = 'EditsFISAddr'
                   IPartRepository partRepository = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
                   IList<string> PLEditsURLLst = partRepository.GetValueFromSysSettingByName("PLEditsURL");
                   if (PLEditsURLLst != null && PLEditsURLLst.Count > 0)
                   {
                       PDFPLLst.Add(PLEditsURLLst[0]); //PDFPLLst[0]
                   }

                   IList<string> PLEditsTemplateLst = partRepository.GetValueFromSysSettingByName("PLEditsTemplate");
                   if (PLEditsTemplateLst != null && PLEditsTemplateLst.Count > 0)
                   {
                       PDFPLLst.Add(PLEditsTemplateLst[0]);//PDFPLLst[1]
                   }

                   IList<string> PLEditsXMLLst = partRepository.GetValueFromSysSettingByName("PLEditsXML");
                   if (PLEditsXMLLst != null && PLEditsXMLLst.Count > 0)
                   {
                       PDFPLLst.Add(PLEditsXMLLst[0]);//PDFPLLst[2]
                   }

                   IList<string> PLEditsPDFLst = partRepository.GetValueFromSysSettingByName("PLEditsPDF");
                   if (PLEditsPDFLst != null && PLEditsPDFLst.Count > 0)
                   {
                       PDFPLLst.Add(PLEditsPDFLst[0]); //PDFPLLst[3]
                   }
                   IList<string> PLEditsImageLst = partRepository.GetValueFromSysSettingByName("PLEditsImage");
                   if (PLEditsImageLst != null && PLEditsImageLst.Count > 0)
                   {
                       PDFPLLst.Add(PLEditsImageLst[0]); //PDFPLLst[4]
                   }

                   IList<string> FOPFullFileNameLst = partRepository.GetValueFromSysSettingByName("FOPFullFileName");
                   if (FOPFullFileNameLst != null && FOPFullFileNameLst.Count > 0)
                   {
                       PDFPLLst.Add(FOPFullFileNameLst[0]); //PDFPLLst[5]

                   }
                   IList<string> printexepathLst = partRepository.GetValueFromSysSettingByName("PDFPrintPath");
                   if (printexepathLst != null && printexepathLst.Count > 0)
                   {
                       PDFPLLst.Add(printexepathLst[0]); //PDFPLLst[6]
                   }


               }
               currentSession.AddValue(Session.SessionKeys.labelBranch,labeltypeBranch);
               // retList[9]: PLEditsPDF
               // retLst.Add(PLEditsPDF);
               retLst.Add(PDFPLLst);

                //retList[10]:DeliveryPerPalletList: 获取与当前Pallet 结合的Delivery
                retLst.Add(DeliveryPerPalletList);

                // retList[11]:'This Customer S/N's Delivery No – Product.DeliveryNo
                retLst.Add(currentProduct.DeliveryNo);

                //retList[12]: emea
                retLst.Add(emea);

                //retList[13]: modelList
                retLst.Add(modelList);

               // WriteProductLog (Insert IMES_FA..ProductLog – 记录Pallet 上所有PRODUCT 的Log)
               //IList<IMES.FisObject.FA.Product.IProduct> prodLst = iproductRepository.GetProductListByIdList(productNoList);
             //  currentSession.AddValue(Session.SessionKeys.ProdList, prodLst);
               //2012/10/18 
               //如果Product 结合的Delivery 为自动单,但Product 没有结合Box Id(ProductInfo.InfoValue; Condition: InfoType =’BoxId’)则报告错误:“此Product 尚未结合Box Id!”
               //如果Product 结合的Delivery 为自动单,但其结合的BoxId 在ProductInfo 和ShipBoxDet (ShipBoxDet.BoxId)中记录的不同,则报告错误:“Box Id 异常! 请检查ProductInfo 及ShipBoxDet 中的相关数据。”;
               //string curInfoBoxID = "";
               //string curShipBoxDetID = "";
               retLst.Add(curInfoBoxID);
               retLst.Add(curShipBoxDetID);

               return retLst;             

            }
            catch (FisException e)
            {
                logger.Error(e.mErrmsg, e);
                if (e.mErrcode == "CHK020") //序號已被刷入
                {
                    throw e;
                }
                throw new Exception(e.mErrmsg);
            }
            catch (Exception e)
            {
                logger.Error(e.Message, e);
                throw new SystemException(e.Message);
            }
            finally
            {
                logger.Debug("(PalletVerifyImpl)InputCustSNOnCooLabel end, custsn:" + firstSn + "pdLine:" + line + "editor:" + editor + "station:" + station + "customer:" + customer);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 每次刷SN都调用该方法,SFC
        /// 将custSN放到Session.CustSN中(string)
        /// 如果匹配到SKU List 中的某条记录,如果该记录的Collection Data为空,(页面处理): 如果该记录的PAQC 栏位等于'PAQC',则报告错误:“该机器尚未完成PAQC!”;
        ///                                                                                如果该记录的PAQC 栏位等于'Fail',则报告错误:“该机器PAQC Fail!”;
        ///                                                                                如果该记录的PD 栏位等于'PD',则报告错误:“该机器尚未完成POD Label Check!”;
        ///                                                                                如果上述错误均未发生,则该记录的Collection Data 栏位显示刷入的Customer S/N,并且Scan Qty + 1;
        ///                                  如果该记录的Collection Data 不为空,则报告错误:“You had duplicate scan.”。(页面处理)
        /// 如果没有匹配到SKU List 中的任何记录,则报告错误:“非法数据!”(service处理)
        /// </summary>
        /// <param name="firstSn">firstSn</param>
        /// <param name="custSn">custSn</param>
        /// <returns></returns>
        public int InputCustSn(string firstSn, string custSn)
        {
            logger.Debug("(PalletVerifyOnlyImpl)ScanSN start, firstSn:" + firstSn + " custSn:" + custSn);

            try
            {
                FisException ex;
                List<string> erpara = new List<string>();

                var currentProduct = CommonImpl.GetProductByInput(firstSn, CommonImpl.InputTypeEnum.CustSN);
                string sessionKey = currentProduct.ProId;
                Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, Session.SessionType.Product);


                if (currentSession == null)
                {
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK021", erpara);
                    throw ex;
                }
                else
                {
                    currentSession.AddValue(Session.SessionKeys.CustSN, custSn);
                    //SFC : 根据刷入的 Another Customer S/N (custSn), 获得其对应的Product
                    var newProduct = CommonImpl.GetProductByInput(custSn, CommonImpl.InputTypeEnum.CustSN);
                    if (string.IsNullOrEmpty(newProduct.ProId))
                    {
                        erpara.Add(custSn);
                        ex = new FisException("CHK152", erpara);    //您所刷入的Customer S/N 无效 ,请重新刷入!
                        throw ex;

                    }
       
                    IList<string> productNoList = (List<string>)(currentSession.GetValue(Session.SessionKeys.ProdNoList));
                    IList<string> custSnList = (List<string>)(currentSession.GetValue(Session.SessionKeys.CustomSnList));
                    int index = 0;
                    Boolean flag =false;
                    foreach (string sn in custSnList)
                    {
                        if (sn == custSn)
                        {
                            flag = true;
                            break;
                        }
                        index++;
                    }
                    if (!flag)
                    {
                        erpara.Add(custSn);
                        ex = new FisException("PAK022", erpara);    //非法数据!
                        throw ex;
                    }

                    if ((string.IsNullOrEmpty(newProduct.ProId)) || (newProduct.ProId != productNoList[index]))
                    {
                        erpara.Add(custSn);
                        ex = new FisException("PAK022", erpara);    //非法数据!
                        throw ex;
                    }


                    //For Check OA3
                    ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(CheckValidationResult);
                    IPartRepository partRepository = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
                    IList<ConstValueInfo> cvInfo = new List<ConstValueInfo>();
                    IBOMRepository bomRep = RepositoryFactory.GetInstance().GetRepository<IBOMRepository>();
                    string fkiPath = "";
                    string fkiUser = "";
                    string fkiPwd = "";
                    bool bNoNeedCheckEOA = false;
                    GetAndCheckOA3Setting(newProduct.Model, out fkiPath, out fkiUser, out fkiPwd, out bNoNeedCheckEOA);

                    //string fkiPath = System.Configuration.ConfigurationManager.AppSettings["FKIServicePath"].Trim();
                    //string fkiUser = System.Configuration.ConfigurationManager.AppSettings["FKIAuthUser"].Trim();
                    //string fkiPwd = System.Configuration.ConfigurationManager.AppSettings["FKIAuthPassword"].Trim();

                    CommonImpl2 cmm2 = new CommonImpl2();
                    CredentialCache FKICredentialCache = new CredentialCache();
                    if (fkiUser.Contains("\\"))
                    {
                        string user = fkiUser.Substring(fkiUser.IndexOf('\\') + 1);
                        string domain = fkiUser.Substring(0, fkiUser.IndexOf('\\'));
                        FKICredentialCache.Add(new System.Uri(fkiPath), "NTLM", new System.Net.NetworkCredential(user, fkiPwd, domain));
                    }
                    else
                    {
                        FKICredentialCache.Add(new System.Uri(fkiPath), "NTLM", new System.Net.NetworkCredential(fkiUser, fkiPwd));
                    }
                    IMES.FisObject.FA.Product.IProduct prd = (IMES.FisObject.FA.Product.IProduct)currentProduct;
                    IPartRepository partRep = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
                   // bool bNoNeedCheckEOA = partRepository.GetValueFromSysSettingByName("DisableOA3CheckOnPallet").
                                                              // Any(x => x == "Y");
                    IList<IMES.DataModel.ConstValueTypeInfo> lstConst = partRep.GetConstValueTypeList("NoCheckOA3SN");
                    if (!lstConst.Any(x => x.value == newProduct.CUSTSN) && !bNoNeedCheckEOA)
                    {
                        IHierarchicalBOM bom = bomRep.GetHierarchicalBOMByModel(newProduct.Model);
                        if (!cmm2.CheckOA3Key(bom, newProduct, fkiPath, FKICredentialCache, currentSession.Editor, (UnitOfWork)currentSession.UnitOfWork))
                        {
                            throw new FisException("PAK158", new string[] { newProduct.CUSTSN, newProduct.DeliveryNo });
                        }
                    }

                    //For Check OA3

                    currentSession.AddValue(Session.SessionKeys.Product, newProduct);
                    currentSession.Exception = null;
                    currentSession.SwitchToWorkFlow();

                    if (currentSession.Exception != null)
                    {
                        if (currentSession.GetValue(Session.SessionKeys.WFTerminated) != null)
                        {
                            currentSession.ResumeWorkFlow();
                        }
                        throw currentSession.Exception;
                    }
                    
                    //string currentPalletNo = (string)(currentSession.GetValue(Session.SessionKeys.PalletNo));
                    
                    //ITC-1360-1277:
                    //if ((string.IsNullOrEmpty(newProduct.ProId)) || (newProduct.PalletNo != currentPalletNo) || (newProduct.ProId != productNoList[index]))
                    //{
                    //    erpara.Add(custSn);
                    //    ex = new FisException("PAK022", erpara);    //非法数据!
                    //    throw ex;
                    //}

                   

                    //Mantis Bug :http://10.99.183.26/Mantis/view.php?id=627 (改为前台页面收集scanProductNoList)
                    //IList<string> scanProductNoList = (IList<string>)currentSession.GetValue(Session.SessionKeys.NewScanedProductIDList);
                    //Boolean exitFlag = false;
                    //foreach (string iprodid in scanProductNoList)
                    //{
                    //    if (iprodid == newProduct.ProId)
                    //    {
                    //        exitFlag = true;
                    //        break;
                    //    }
                    //}
                    //if (!exitFlag)
                    //{
                    //    scanProductNoList.Add(newProduct.ProId);
                    //    currentSession.AddValue(Session.SessionKeys.NewScanedProductIDList, scanProductNoList);
                    //}

                    return index;

                }
            }

            catch (FisException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw new SystemException(e.Message);
            }
            finally
            {
                logger.Debug("(PalletVerifyOnlyImpl)ScanSN end, firstSn:" + firstSn + " custSn:" + custSn);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 每次刷SN都调用该方法,SFC
        /// 将custSN放到Session.CustSN中(string)
        /// 如果匹配到SKU List 中的某条记录,如果该记录的Collection Data为空,(页面处理): 如果该记录的PAQC 栏位等于'PAQC',则报告错误:“该机器尚未完成PAQC!”;
        ///                                                                                如果该记录的PAQC 栏位等于'Fail',则报告错误:“该机器PAQC Fail!”;
        ///                                                                                如果该记录的PD 栏位等于'PD',则报告错误:“该机器尚未完成POD Label Check!”;
        ///                                                                                如果上述错误均未发生,则该记录的Collection Data 栏位显示刷入的Customer S/N,并且Scan Qty + 1;
        ///                                  如果该记录的Collection Data 不为空,则报告错误:“You had duplicate scan.”。(页面处理)
        /// 如果没有匹配到SKU List 中的任何记录,则报告错误:“非法数据!”(service处理)
        /// </summary>
        /// <param name="firstSn">firstSn</param>
        /// <param name="custSn">custSn</param>
        /// <param name="curInfoBoxId">custSn</param>
        /// <param name="curShipBoxDetId">custSn</param>
        /// <returns></returns>
        public int InputCustSn(string firstSn, string custSn, out string curInfoBoxId, out string curShipBoxDetId)
        {
            logger.Debug("(PalletVerifyImpl)ScanSN start, firstSn:" + firstSn + " custSn:" + custSn);

            try
            {
                FisException ex;
                List<string> erpara = new List<string>();
                var currentProduct = CommonImpl.GetProductByInput(firstSn, CommonImpl.InputTypeEnum.CustSN);
             
                string sessionKey = currentProduct.ProId;
                Session currentSession = SessionManager.GetInstance.GetSession(sessionKey, Session.SessionType.Product);


                if (currentSession == null)
                {
                    erpara.Add(sessionKey);
                    ex = new FisException("CHK021", erpara);
                    throw ex;
                }
                else
                {
                    currentSession.AddValue(Session.SessionKeys.CustSN, custSn);

                    //SFC : 根据刷入的 Another Customer S/N (custSn), 获得其对应的Product
                    var newProduct = CommonImpl.GetProductByInput(custSn, CommonImpl.InputTypeEnum.CustSN);
                    if (string.IsNullOrEmpty(newProduct.ProId))
                    {
                        erpara.Add(custSn);
                        ex = new FisException("CHK152", erpara);    //您所刷入的Customer S/N 无效 ,请重新刷入!
                        throw ex;

                    }
                    else
                    {
                        if (CheckCTObyDN(newProduct.DeliveryNo))
                        {
                            if (!CheckPODLabel(newProduct))
                            {
                                throw new FisException("PAK172", erpara);
                            }
                        }

                    }

                


                    IList<string> productNoList = (List<string>)(currentSession.GetValue(Session.SessionKeys.ProdNoList));
                    IList<string> custSnList = (List<string>)(currentSession.GetValue(Session.SessionKeys.CustomSnList));
                    int index = 0;
                    Boolean flag = false;
                    string currentPalletNo = (string)(currentSession.GetValue(Session.SessionKeys.PalletNo));
                    string currentDN = (string)(currentSession.GetValue(Session.SessionKeys.DeliveryNo));
                    foreach (string sn in custSnList)
                    {
                        if (sn == custSn)
                        {
                            flag = true;
                            break;
                        }
                        index++;
                    }
                    if (!flag)
                    {
                        erpara.Add(currentPalletNo);
                        erpara.Add(custSn);
                        ex = new FisException("PAK144", erpara);    //非法数据!
                        throw ex;
                    }

                   // string currentPalletNo = (string)(currentSession.GetValue(Session.SessionKeys.PalletNo));
                    if ((string.IsNullOrEmpty(newProduct.ProId)) || (newProduct.PalletNo != currentPalletNo) || (newProduct.ProId != productNoList[index]))
                    {
                        erpara.Add(currentPalletNo);
                        erpara.Add(custSn);
                        
                        ex = new FisException("PAK144", erpara);    //非法数据!
                        throw ex;
                    }
                 //For Check OA3
                    ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(CheckValidationResult);
                    IBOMRepository bomRep = RepositoryFactory.GetInstance().GetRepository<IBOMRepository>();
                    IPartRepository partRep = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
                
                    string fkiPath = "";
                    string fkiUser = "";
                    string fkiPwd = "";
                    bool bNoNeedCheckEOA = false;
                    GetAndCheckOA3Setting(newProduct.Model, out fkiPath, out fkiUser, out fkiPwd, out bNoNeedCheckEOA);
                    //string fkiPath = System.Configuration.ConfigurationManager.AppSettings["FKIServicePath"].Trim();
                    //string fkiUser = System.Configuration.ConfigurationManager.AppSettings["FKIAuthUser"].Trim();
                    //string fkiPwd = System.Configuration.ConfigurationManager.AppSettings["FKIAuthPassword"].Trim();

                    CommonImpl2 cmm2 = new CommonImpl2();
                    CredentialCache FKICredentialCache = new CredentialCache();
                    if (fkiUser.Contains("\\"))
                    {
                        string user = fkiUser.Substring(fkiUser.IndexOf('\\') + 1);
                        string domain = fkiUser.Substring(0, fkiUser.IndexOf('\\'));
                        FKICredentialCache.Add(new System.Uri(fkiPath), "NTLM", new System.Net.NetworkCredential(user, fkiPwd, domain));
                    }
                    else
                    {
                        FKICredentialCache.Add(new System.Uri(fkiPath), "NTLM", new System.Net.NetworkCredential(fkiUser, fkiPwd));
                    }


                    //bool bNoNeedCheckEOA = partRep.GetValueFromSysSettingByName("DisableOA3CheckOnPallet").
                    //                                                         Any(x => x == "Y");
                    IList<IMES.DataModel.ConstValueTypeInfo> lstConst = partRep.GetConstValueTypeList("NoCheckOA3SN");
                    if (!lstConst.Any(x => x.value == newProduct.CUSTSN) && !bNoNeedCheckEOA)
                    {
                        IHierarchicalBOM bom = bomRep.GetHierarchicalBOMByModel(newProduct.Model);
                        if ( !cmm2.CheckOA3Key(bom, newProduct, fkiPath, FKICredentialCache, currentSession.Editor, (UnitOfWork)currentSession.UnitOfWork))
                        {
                            throw new FisException("PAK158", new string[] { newProduct.CUSTSN, newProduct.DeliveryNo });
                        }
                    }

                    //For Check OA3



                    currentSession.AddValue(Session.SessionKeys.Product, newProduct);
                    currentSession.Exception = null;
                    currentSession.SwitchToWorkFlow();

                    if (currentSession.Exception != null)
                    {
                        if (currentSession.GetValue(Session.SessionKeys.WFTerminated) != null)
                        {
                            currentSession.ResumeWorkFlow();
                        }
                        throw currentSession.Exception;
                    }
                    //--------------------------------------------------------------------------------------
                    curInfoBoxId = "";
                    curShipBoxDetId = "";
                    //2012/10/25.	取消检查每个Product 结合的Box Id 或UCC 的正确性
                    //IProductRepository iproductRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IMES.FisObject.FA.Product.IProduct>();
                    //IDeliveryRepository ideliveryRepository = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>();

                    ////Productinfo
                    //curInfoBoxId = iproductRepository.GetProductInfoValue(newProduct.ProId, "BoxId");
                    ////ShipBoxDet
                    //IList<ShipBoxDetInfo> shipList;
                    //ShipBoxDetInfo shipInfo;
                    ////shipList = ideliveryRepository.GetShipBoxDetList(currentDN, currentPalletNo, newProduct.ProId);
                    //var conshipdet = new ShipBoxDetInfo();
                    //conshipdet.snoId = newProduct.ProId;
                    //shipList = ideliveryRepository.GetShipBoxDetInfoListByCondition(conshipdet);
                    //if (shipList.Count != 0)
                    //{
                    //    shipInfo = shipList[0];
                    //    curShipBoxDetId = shipInfo.boxId;
                    //}
                    //--------------------------------------------------------------------------------------
                    return index;

                }
            }

            catch (FisException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw new SystemException(e.Message);
            }
            finally
            {
                logger.Debug("(PalletVerifyImpl)ScanSN end, firstSn:" + firstSn + " custSn:" + custSn);
            }
        }