Example #1
0
        /// <summary>
        /// Unpack Offline Pizza
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            List<string> errpara = new List<string>();

            IProductRepository prodRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            IPizzaRepository pizzaRepository = RepositoryFactory.GetInstance().GetRepository<IPizzaRepository, Pizza>();

            string pizzaId = this.Key;
            Pizza p = pizzaRepository.Find(pizzaId);

            if (null == p)
            {
                var ex = new FisException("CHK100", new string[] { pizzaId });
                throw ex;
            }

            if ((null == p.Status) || !("PKJOK".Equals(p.Status.StationID) || "PKJROK".Equals(p.Status.StationID)))
            {
                var ex = new FisException("CHK1046", new string[] { });
                throw ex;
            }

            IProduct prod = prodRep.GetProductByPizzaID(pizzaId);
            if ((null != prod) || (!string.IsNullOrEmpty(p.CartonSN)))
            {
                var ex = new FisException("CHK1047", new string[] { });
                throw ex;
            }

            pizzaRepository.BackUpPizzaStatusDefered(CurrentSession.UnitOfWork, pizzaId, CurrentSession.Editor);
            pizzaRepository.BackUpPizzaPartDefered(CurrentSession.UnitOfWork, pizzaId, CurrentSession.Editor);

            PizzaPart delpizza = new PizzaPart();
            delpizza.PizzaID = pizzaId;

            pizzaRepository.DeletePizzaPartDefered(CurrentSession.UnitOfWork, delpizza);


            p.Status.StationID = this.Station;

            string line = string.IsNullOrEmpty(this.Line) ? p.Status.LineID : this.Line;
            var PizzaLog = new PizzaLog
            {
                Model = p.Model,
                Editor = Editor,
                Line = line,
                Station = Station,
                Descr = "",
                PizzaID = p.PizzaID,
                Cdt = DateTime.Now
            };

            p.AddPizzaLog(PizzaLog);
            pizzaRepository.Update(p, CurrentSession.UnitOfWork);
Example #2
0
        /// <summary>
        /// To every one in a COANoList, delete bound to Product and COA No, set status to current product.
		/// set status to COA, and insert COA log.
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            string editor = this.Editor;
            string pdLine = this.Line;
            string scrap = (string)CurrentSession.GetValue("scrap");
            string cause = (string)CurrentSession.GetValue("cause");

            List<string> list = (List<string>)CurrentSession.GetValue(Session.SessionKeys.COASNList);
            List<string> Actionlist = (List<string>)CurrentSession.GetValue("ActionList");
            List<string> Causelist = (List<string>)CurrentSession.GetValue("CauseList");
            int listcount = list.Count;
            int i = 0;
            IProductRepository productRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            ICOAStatusRepository coaStatusRep = RepositoryFactory.GetInstance().GetRepository<ICOAStatusRepository, COAStatus>();

            IPizzaRepository repPizza = RepositoryFactory.GetInstance().GetRepository<IPizzaRepository, Pizza>();
          
            try
            {
                foreach (string coaNo in list)
                {
                    bool found = false;
                    string productID = "";
                    string CUSTSN = "";
                    string CustPartNo = "";

                    string pizzaID = "";

                    bool first_in = true;
                    string partSn = coaNo;
                    IMES.FisObject.FA.Product.ProductStatus newStatus = new IMES.FisObject.FA.Product.ProductStatus();
                    IList<string> product_list = new List<string>();
                    IList<ProductAndCustInfo> product_and_cust_info_list = productRep.GetProductAndCustInfoListByPartSn(partSn);
                    foreach (ProductAndCustInfo node in product_and_cust_info_list)
                    {
                        if (first_in)
                        {
                            productID = node.productId;
                            IProduct _product = productRep.FindOneProductWithProductIDOrCustSN(productID);
                            pizzaID = _product.PizzaID;
                            newStatus = _product.Status;
                            CUSTSN = node.custSn;
                            CustPartNo = node.custPno; //_product.ModelObj.CustPN;
                            found = true;
                            first_in = false;
                        }

                        product_list.Add(node.productId);
                        break;
                    }

                    if (found == false)
                    {
                        //FisException _ex = new FisException("CHK238"); //Get COA no bounding product info error!
                        //throw _ex;
                    }
                    /////////////////////////////////////////////////////////////////////////////
                    /* 
                     * delete Pizza_Part where PartSn=@coano and PizzaID=@PizzaId
                     */
                    ////////////////////////////////////////////////////////////////////////////////

                    IList<IProduct> pizza_list = productRep.GetProductInfoListByPizzaPartSn(partSn);
                    foreach (IProduct node in pizza_list)
                    {
                        pizzaID = node.PizzaID;
                        productID = node.ProId;
                        product_list.Add(productID);

                        break;
                    }
                    if (pizzaID != "")
                    {
                        PizzaPart delpizza = new PizzaPart();

                        delpizza.PizzaID = pizzaID;
                        delpizza.PartSn = partSn;

                        repPizza.DeletePizzaPartDefered(CurrentSession.UnitOfWork, delpizza);
                    }

                    /*
                     * 
                     * 6.解除Product与COA No的绑定:
                     * delete Product_Part where PartSn=@coano and ProductID=@productID
                     * 设置对应Product的当前状态:
                     * Update ProductStatus set Station=’69’, Editor=@user, Udt=GetDate where ProducntID=@productID
                     * 设置COA状态:
                     * Update COAStatus set Line=’REM’,Status=’A2’,Editor=@user, Udt=GetDate where COASN=@coano
                     * 记录COA Log:
                     * insert COALog values (@coano, 'A2',custsn+'/'+hppno, rtrim(@user), GetDate, ‘COA’)
                     * -----------------------------------------------------------------------------------------------
                     * IProductRepository::
                     * void DeleteProductPartByPartSn(string prodId, string partSn);
                     * 或void DeleteProductPartByPartSnDefered(IUnitOfWork uow, string prodId, string partSn);
                     * 
                     * 
                     * ProductStatus的修改请使用主体对象Product的Status属性,其被修改后,调用IProductRepository的Update方法来更新修改。
                     * 
                     * 
                     * COAStatus的更新使用ICOAStatusRepository的Update方法.
                     *
                     *
                     * ICOAStatusRepository::
                     * void InsertCOALog(COALog newLog);
                     * 或void InsertCOALogDefered(IUnitOfWork uow, COALog newLog);
                     * 
                     */

                    // if found == false, product_list has no node, and it does not exist in product_part.
                    // so we need not do:
                    //    1. productRep.DeleteProductPartByPartSn(productID, partSn)
                    //    2. productRep.UpdateProductListStatus.
                    if (found == true || pizzaID != "")
                    {
                        productRep.DeleteProductPartByPartSnDefered(CurrentSession.UnitOfWork, productID, partSn);
                        
                        //IMES.FisObject.FA.Product.ProductStatus newStatus = new IMES.FisObject.FA.Product.ProductStatus();
                        //Station=’69’, Editor=@user, Udt=GetDate where ProducntID=@productID
                        //上海mantis 0002406: PAK Remove COA 功能優化-- 判斷目前機器停留在 FA 站時不需要修改站點為69 站
                        IPartRepository partRep = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
                        IList<ConstValueTypeInfo> nonChange69StationList  = partRep.GetConstValueTypeList("RemoveCOANotChange69Station");

                        if (nonChange69StationList==null  ||  
                            nonChange69StationList.Count==0 ||  
                            !nonChange69StationList.Any(x => x.value == newStatus.StationId))
                        {
                            IList<IMES.DataModel.TbProductStatus> stationList = productRep.GetProductStatus(new List<string>() { productID });
                            productRep.UpdateProductPreStationDefered(CurrentSession.UnitOfWork, stationList);

                            newStatus.StationId = "CR";
                            newStatus.Editor = editor;
                            newStatus.Udt = DateTime.UtcNow;
                            newStatus.ProId = productID;
                            productRep.UpdateProductListStatusDefered(CurrentSession.UnitOfWork, newStatus, product_list); //Defered(CurrentSession.UnitOfWork, newStatus, ProductIDList);
                            productRep.WriteProductLogDefered(CurrentSession.UnitOfWork, 
                                                                                        new List<string>() { productID }, 
                                                                                        "RemoveCOA", 
                                                                                        newStatus.StationId , 
                                                                                        (int)newStatus.Status,
                                                                                        newStatus.Editor);
                        }
                    }

                    COAStatus _coaStatus = coaStatusRep.GetCoaStatus(coaNo);

                    if (Actionlist[i] == "Scrap")
                    {
                        ////////////////////////////////////////////////////////////////////////////
                        //Update COAStatus set Status=@cause,Editor=@user, Udt=GetDate where COASN=@coano
                        string strcause;
                        strcause = Causelist[i].Substring(0, Causelist[i].IndexOf(" "));

                        _coaStatus.Status = strcause;
                        _coaStatus.Editor = editor;
                        _coaStatus.Udt = DateTime.UtcNow;
                        _coaStatus.COASN = coaNo;
                        coaStatusRep.UpdateCOAStatusDefered(CurrentSession.UnitOfWork, _coaStatus);

                        ////////////////////////////////////////////////////////////////////////////
                        COAReturnInfo setCOA = new COAReturnInfo();
                        setCOA.status = strcause;
                        setCOA.editor = editor.Trim();
                        setCOA.udt = DateTime.UtcNow;

                        COAReturnInfo conditionCOA = new COAReturnInfo();
                        conditionCOA.coasn = coaNo;

                        coaStatusRep.UpdateCOAReturnInfoDefered(CurrentSession.UnitOfWork, setCOA, conditionCOA);

                    }
                    else
                    {
                        // found == true || found == false, program comes here, that is to say, COA Staus = 'A1',
                        // so we must update COA status to be 'A2'.
                        //Update COAStatus set Line=’REM’,Status=’A2’,Editor=@user, Udt=GetDate where COASN=@coano
                        _coaStatus.LineID = "REM";
                        _coaStatus.Status = "A2";
                        _coaStatus.Editor = editor;
                        _coaStatus.Udt = DateTime.UtcNow;
                        _coaStatus.COASN = coaNo;
                        coaStatusRep.UpdateCOAStatusDefered(CurrentSession.UnitOfWork, _coaStatus);
                    
                    }

                    // if found == false, we do not know the CUSTSN, and so we can not make a COALog.
                    if (found == true || pizzaID != "")
                    {
                        if (Actionlist[i] == "Scrap")
                        {
                            // insert COALog values (@coano, @cause,@coapn, rtrim(@user), GetDate, ‘COA’)
                            //Note:
                            //@cause – 该COA No录入时,选择的Cause
                            //@coapn – 该COA No 对应的COAStatus.IECPN
                            string strcause;
                            strcause = Causelist[i].Substring(0, Causelist[i].IndexOf(" "));

                            COALog newLog = new COALog();
                            newLog.COASN = coaNo;
                            newLog.StationID = strcause;
                            newLog.LineID = _coaStatus.IECPN;
                            newLog.Editor = editor.Trim();
                            newLog.Cdt = DateTime.Now;
                            newLog.Tp = "COA";

                            coaStatusRep.InsertCOALogDefered(CurrentSession.UnitOfWork, newLog);
                        }
 
                        else
                        {
                            //insert COALog values (@coano, 'A2',custsn+'/'+hppno, rtrim(@user), GetDate, ‘COA’)
                            COALog newLog = new COALog();
                            newLog.COASN = coaNo;
                            newLog.StationID = "A2";
                            newLog.LineID = CUSTSN + "/" + CustPartNo;
                            newLog.Editor = editor.Trim();
                            newLog.Cdt = DateTime.Now;
                            newLog.Tp = "COA";

                            coaStatusRep.InsertCOALogDefered(CurrentSession.UnitOfWork, newLog);
                        }
                    }
                    i++;
                }
            }
            catch(FisException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw e;
            }

            return base.DoExecute(executionContext);
        }
Example #3
0
        private void UnpackPizzaPart(Pizza p, string unpackForNotStation)
        {
            IPizzaRepository pizzaRepository = RepositoryFactory.GetInstance().GetRepository<IPizzaRepository, Pizza>();

            IList<PizzaPart> plistUnpack = new List<PizzaPart>();
            IList<PizzaPart> plist = pizzaRepository.GetPizzaPartsByValueLike(14, "", p.PizzaID);
            foreach (PizzaPart pp in plist)
            {
                if (unpackForNotStation.Equals(pp.Station))
                {
                    continue;
                }
                plistUnpack.Add(pp);
            }

            if (plistUnpack.Count > 0)
            {
                pizzaRepository.BackUpPizzaPartDefered(CurrentSession.UnitOfWork, p.PizzaID, CurrentSession.Editor);

                foreach (PizzaPart pp in plistUnpack)
                {
                    PizzaPart delpizza = new PizzaPart();
                    delpizza.PizzaID = p.PizzaID;
                    delpizza.PartNo = pp.PartNo;
                    delpizza.PartSn = pp.PartSn;
                    pizzaRepository.DeletePizzaPartDefered(CurrentSession.UnitOfWork, delpizza);
                }
            }
        }