示例#1
0
        /// <summary>
        /// 获取DCode
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            IProductRepository productRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            IDeliveryRepository deliveryRep = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>();
            IModelRepository modelRep = RepositoryFactory.GetInstance().GetRepository<IModelRepository, Model>();
            IPizzaRepository pizzaRep = RepositoryFactory.GetInstance().GetRepository<IPizzaRepository, Pizza>();
            ICOAStatusRepository coaRep = RepositoryFactory.GetInstance().GetRepository<ICOAStatusRepository, COAStatus>();
            IPrintLogRepository printLogRep = RepositoryFactory.GetInstance().GetRepository<IPrintLogRepository, PrintLog>();

            Product curProduct = (Product)CurrentSession.GetValue(Session.SessionKeys.Product);
            Delivery curDn = (Delivery)CurrentSession.GetValue(Session.SessionKeys.Delivery);
            string pizzaID = (string)CurrentSession.GetValue(Session.SessionKeys.PizzaID);
            string coaSN = (string)CurrentSession.GetValue(Session.SessionKeys.COASN);
            string curEditor = "";
            string curStation = "";

            if (!string.IsNullOrEmpty(this.Editor))
            {
                curEditor = this.Editor;
            }
            if (!string.IsNullOrEmpty(this.Station))
            {
                curStation = this.Station;
            }

            if (!curProduct.IsBT)
            {
                //Update Product – Combine DN
                //Product.DeliveryNo – Delivery No (from UI)
                bool bindFlag = false;
                curProduct.DeliveryNo = curDn.DeliveryNo;
                Delivery newDn = null;
                IList<string> proList = new List<string>();
                proList.Add(curProduct.ProId);
                bindFlag = productRep.BindDN(curDn.DeliveryNo, proList, curDn.Qty);
                while (!bindFlag)
                {
                    newDn = GetNextDelivery(curProduct);
                    if (newDn == null)
                    {
                        FisException fe = new FisException("PAK103", new string[] { });   //没找到可分配的delivery
                        throw fe;
                    }
                    else
                    {
                        bindFlag = productRep.BindDN(newDn.DeliveryNo, proList, newDn.Qty);
                    }
                }
                if (newDn != null)
                {
                    curDn = newDn;
                    curProduct.DeliveryNo = curDn.DeliveryNo;
                    CurrentSession.AddValue(Session.SessionKeys.Delivery, curDn);
                }

                int dvQty = productRep.GetCombinedQtyByDN(curDn.DeliveryNo);
                if (dvQty == curDn.Qty)
                {
                    curDn.Status = "87";
                    deliveryRep.Update(curDn, CurrentSession.UnitOfWork);
                }
            }

            //3.	如果有绑定COA,则需要完成如下操作
            //a)	Insert Product_Part - Combine COA 
            //b)	Update COAStatus - Update COA Status
            //      COAStatus.Status = 'A1'
            //c)	Insert COALog – Insert COA Log
            //      COASN – COA
            //      Line – 当前绑定的Customer S/N
            //      Station – 'A1'
            if (!string.IsNullOrEmpty(coaSN))
            {
                ProductPart coaPart = (ProductPart)CurrentSession.GetValue("COAPart");
                IPart bomPart = (IPart)CurrentSession.GetValue("COABOMPart");
                COAStatus reCOA = coaRep.Find(coaSN);

                IProductPart bindPart = new ProductPart();
                bindPart.ProductID = curProduct.ProId;
                bindPart.PartID = bomPart.PN;
                bindPart.PartSn = coaSN;
                bindPart.Cdt = DateTime.Now;
                bindPart.BomNodeType = "P1";
                bindPart.PartType = bomPart.Type;
                bindPart.CustomerPn = bomPart.CustPn;
                bindPart.Editor = curEditor;
                bindPart.Station = curStation;
                bindPart.CheckItemType = "";
                bindPart.Iecpn = "";
                curProduct.AddPart(bindPart);

                reCOA.Status = "A1";
                reCOA.Editor = curEditor;
                coaRep.UpdateCOAStatusDefered(CurrentSession.UnitOfWork, reCOA);

                COALog newItem = new COALog();
                newItem.COASN = coaSN;
                newItem.LineID = curProduct.CUSTSN;
                newItem.Editor = Editor;
                newItem.StationID = "A1";
                newItem.Tp = "";
                coaRep.InsertCOALogDefered(CurrentSession.UnitOfWork, newItem);
            }

            //7.Insert IMES_PAK..Pizza / IMES_PAK..PizzaStatus / 
            //IMES_PAK..Pizza.MMIID = ''
            //IMES_PAK..PizzaStatus.Station = '00'

            Pizza CurrentPizza = new Pizza();
            PizzaStatus currentPizzaStatus = new PizzaStatus();

            currentPizzaStatus.Editor = this.Editor;
            if (null == this.Line)
            {
                currentPizzaStatus.LineID = "";
            }
            else
            {
                currentPizzaStatus.LineID = this.Line;
            }
            currentPizzaStatus.PizzaID = pizzaID;
            currentPizzaStatus.StationID = "00";

            CurrentPizza.PizzaID = pizzaID;
            CurrentPizza.MMIID = "";
            CurrentPizza.Status = currentPizzaStatus;

            pizzaRep.Add(CurrentPizza, CurrentSession.UnitOfWork);

            //8.Update Product – Combine Pizza Id
            //Product.PizzaID – Pizza ID         
            curProduct.PizzaID = pizzaID;
            productRep.Update(curProduct, CurrentSession.UnitOfWork);

            //Model 的第10,11码是”29” 或者”39” 的产品是出货日本的产品;否则,是非出货日本的产品
            string jpmodel = curProduct.Model.Substring(9, 2);
            bool jpflag = false;

          //  if (jpmodel == "29" || jpmodel == "39")
            if((jpmodel == "29" || jpmodel == "39") && CheckJapanByPart(curProduct.Model))
            {
                jpflag = true;
            }

            //IMES_GetData..PrintLog
            var item = new PrintLog
            {
                Name = "PIZZA Label-1",
                BeginNo = curProduct.CUSTSN,
                EndNo = curProduct.CUSTSN,
                Descr = "PIZZA Label-1",
                Editor = this.Editor
            };

            printLogRep.Add(item, CurrentSession.UnitOfWork);

            //出货日本在列印列印Pizza Label 后,还需要列印Japan Pizza Label 
            if (jpflag)
            {
                var jitem = new PrintLog
                {
                    Name = "PIZZA Label-2",
                    BeginNo = curProduct.CUSTSN,
                    EndNo = curProduct.CUSTSN,
                    Descr = "PIZZA Label-2",
                    Editor = this.Editor
                };
                printLogRep.Add(jitem, CurrentSession.UnitOfWork);
            }
            if (curProduct.IsBT)
            {
                var btitem = new PrintLog
                {
                    Name = "BT COO Label",
                    BeginNo = curProduct.CUSTSN,
                    EndNo = curProduct.CUSTSN,
                    Descr = "BT COO Label",
                    Editor = this.Editor
                };
                printLogRep.Add(btitem, CurrentSession.UnitOfWork);
            }
            CurrentSession.AddValue("JPFlag", jpflag);

            return base.DoExecute(executionContext);
        }
示例#2
0
        /*
        /// <summary>
        /// 印第一个pizza标签
        /// </summary>
        /// <param name="custSN">CustomerSN</param>
        /// <param name="line"></param>
        /// <param name="editor"></param>
        /// <param name="station"></param>
        /// <param name="customer"></param>  
        /// <param name="printItems"></param>
        /// <returns>Print Items</returns>
        public IList<PrintItem> PrintPizzaLabelFinal(string custSN, string line, string editor, string station, string customer, IList<PrintItem> printItems)
        {
            logger.Debug("(_CombineCOAandDN)PrintPizzaLabelFinal start, [CustomerSN]:" + custSN
                + " [line]: " + line
                + " [editor]:" + editor
                + " [station]:" + station
                + " [customer]:" + customer);

            string sessionKey = custSN;
            try
            {
                Session session = SessionManager.GetInstance.GetSession(sessionKey, SessionType);
                if (session != null)
                {
                    string doDelivery = (string)session.GetValue("doDelivery");
                    if (doDelivery != null && doDelivery == "true")
                    {
                        var currentProduct = CommonImpl.GetProductByInput(custSN, CommonImpl.InputTypeEnum.CustSN);
                        if (null == currentProduct)
                        {
                            List<string> errpara = new List<string>();
                            errpara.Add(custSN);
                            throw new FisException("SFC002", errpara);
                        }
                        string DNTemp = (string)session.GetValue(Session.SessionKeys.DeliveryNo);
                        if (currentProduct.DeliveryNo != DNTemp)
                        {
                            return null;
                        }
                    }
                    session.AddValue(Session.SessionKeys.IsComplete, true);
                    session.AddValue(Session.SessionKeys.PrintItems, printItems);
                    session.AddValue(Session.SessionKeys.PrintLogName, "PIZZA Label");
                    session.AddValue(Session.SessionKeys.PrintLogBegNo, custSN);
                    session.AddValue(Session.SessionKeys.PrintLogEndNo, custSN);
                    session.AddValue(Session.SessionKeys.PrintLogDescr, "");
                    session.Exception = null;
                    session.SwitchToWorkFlow();

                    //check workflow exception
                    if (session.Exception != null)
                    {
                        if (session.GetValue(Session.SessionKeys.WFTerminated) != null)
                        {
                            session.ResumeWorkFlow();
                        }

                        throw session.Exception;
                    }
                    return (IList<PrintItem>)session.GetValue(Session.SessionKeys.PrintItems);
                    //return null;
                }
                else
                {
                    return null;
                }
                
            }
            catch (FisException e)
            {
                logger.Error(e.mErrmsg);
                throw e;
            }
            catch (Exception e)
            {
                logger.Error(e.Message);
                throw e;
            }
            finally
            {
                Session sessionDelete = SessionManager.GetInstance.GetSession(sessionKey, SessionType);
                if (sessionDelete != null)
                {
                    SessionManager.GetInstance.RemoveSession(sessionDelete);
                }
                logger.Debug("(_CombineCOAandDN)PrintPizzaLabelFinal end, [CustomerSN]:" + custSN
                    + " [line]: " + line
                    + " [editor]:" + editor
                    + " [station]:" + station
                    + " [customer]:" + customer);
            }
        }*/

        /// <summary>
        /// Insert Product_Part - Combine COA 
        /// </summary>
        /// <param name="custSN">CustomerSN</param>
        /// <param name="coaSN">coaSN</param>
        /// <param name="editor">editor</param>
        public void BindPart(string custSN, string coaSN,string editor)
        { 
            try 
            {
                COAStatus reCOA = coaRepository.Find(coaSN);
                IProduct product = productRepository.GetProductByCustomSn(custSN);
                if (product == null)
                {
                    return ;
                }
                IProductPart bindPart = new ProductPart();
                bindPart.ProductID = product.ProId;
                bindPart.PartID = reCOA.IECPN;
                bindPart.PartSn = coaSN;
                bindPart.Cdt = DateTime.Now;
                if (editor == null)
                {
                    editor = "";
                }
                bindPart.Editor = editor;
                product.AddPart(bindPart);
                
                reCOA.Status = "A1";
                reCOA.Editor = editor;
                coaRepository.UpdateCOAStatus(reCOA);
                COALog newItem = new COALog();
                newItem.COASN = coaSN;
                newItem.LineID = custSN;
                newItem.Editor = editor;
                newItem.StationID = "A1";
                coaRepository.InsertCOALog(newItem);
            }
            catch (Exception ee)
            {
                throw ee;
            }
        }