Exemplo n.º 1
0
        /// <summary>
        /// Bind part to owner
        /// 1.Update COAStatus, Status=A1
        ///2.记录COALOG
        ///3.Product.COAID=Code
        /// </summary>
        /// <param name="part">part</param>
        /// <param name="owner">owner</param>
        public override void BindTo(IProductPart part, IPartOwner owner)
        {
//            if (!part.ValueType.Equals(("SN")))
//            {
//                base.BindTo(part, owner);
//                return;
//            }

            var product = (IProduct)owner;
            Session session = SessionManager.GetInstance.GetSession(product.ProId, Session.SessionType.Product);
            var productRepoistory = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            var coaRepository = RepositoryFactory.GetInstance().GetRepository<ICOAStatusRepository, COAStatus>();
            COAStatus coa = coaRepository.Find(part.Value);

            //1
            coa.Status = COAStatus.COAStatusConst.A1;

            //2
            var log = new COALog
                          {
                              COASN = coa.COASN,
                              StationID = session.Station,
                              LineID = session.Line,
                              Editor = session.Editor,
                              Cdt = DateTime.Now
                          };
            coa.addCOALog(log);

            //3
            product.COAID = part.Value;

            coaRepository.Update(coa, session.UnitOfWork);
            productRepoistory.Update(product, session.UnitOfWork);
        }
Exemplo n.º 2
0
        public void Save(object part_unit, object part_owner, string station, string key)
        {
            //需要更新状态为’A1’ (IMES_PAK..COAStatus.Station),并记录Log (IMES_PAK..COALog)
            if (part_unit == null)
            {
                throw new ArgumentNullException();
            }
            if (part_owner == null)
            {
                throw new ArgumentNullException();
            }
            //if (part_unit != null)
            //{
                string sn = ((PartUnit)part_unit).Sn;
                //Pizza pizza = (Pizza) part_owner;
                Session session = SessionManager.GetInstance.GetSession(key, Session.SessionType.Product);
                if (session == null)
                {
                    throw new InstanceNotFoundException("Can not get Session instance from SessionManager!");
                }
                Product product = (Product)session.GetValue(Session.SessionKeys.Product);
                
                ICOAStatusRepository coastatus_repository = RepositoryFactory.GetInstance().GetRepository<ICOAStatusRepository, COAStatus>();
                COAStatus coa_status = coastatus_repository.GetCoaStatus(sn);
                if (coa_status != null)
                {
                    coa_status.Status = "A1";
                 //   coastatus_repository.UpdateCOAStatus(coa_status);
                    coastatus_repository.UpdateCOAStatusDefered(session.UnitOfWork, coa_status);
                   
                    var coa_log = new COALog
                                      {
                                          COASN = coa_status.COASN,
                                          StationID = "A1",
                                          Editor = session.Editor,
                                          IsDirty = coa_status.IsDirty,
                                          LineID = product.CUSTSN,
                                          Cdt = coa_status.Cdt,
                                          Tracker = coa_status.Tracker,
                                          Tp = ""
                                      };
              //      coastatus_repository.InsertCOALog(coa_log);
                    coastatus_repository.InsertCOALogDefered(session.UnitOfWork, coa_log);

                }
//                IPizzaRepository pizza_repository = RepositoryFactory.GetInstance().GetRepository<IPizzaRepository, Pizza>();
//                Pizza pizza = product.PizzaObj;
//                IProductPart part = new ProductPart();
//                part.PartID = ((PartUnit)part_unit).Pn;
//                part.PartSn = ((PartUnit)part_unit).Sn;
//                part.BomNodeType = ((PartUnit)part_unit).Type;
//                part.CheckItemType = ((PartUnit)part_unit).ItemType;
//                part.PartType = ((PartUnit)part_unit).ValueType;
//                part.Station = station;
//                part.Editor = session.Editor;
//                pizza.AddPart(part);
//                pizza_repository.Update(pizza, session.UnitOfWork);
        }
Exemplo n.º 3
0
 public void Save(object part_unit, object part_owner, string station, string key)
 {
     //需要更新状态为'A1' (IMES_PAK..COAStatus.Status)并记录Log (IMES_PAK..COALog)
     if (part_unit == null)
     {
         throw new ArgumentNullException();
     }
     if (part_owner == null)
     {
         throw new ArgumentNullException();
     }
     //if (part_unit != null)
     //{
     var product = (Product)part_owner;
     string sn = ((PartUnit)part_unit).Sn.Trim();
     Session session = SessionManager.GetInstance.GetSession(((PartUnit)part_unit).ProductId, Session.SessionType.Product);
     if (session == null)
     {
         throw new InstanceNotFoundException("Can not get Session instance from SessionManager!");
     }
     ICOAStatusRepository pizza_repository =
         RepositoryFactory.GetInstance().GetRepository<ICOAStatusRepository, COAStatus>();
     COAStatus coa_status = pizza_repository.GetCoaStatus(sn);
     if (coa_status != null)
     {
         coa_status.Status = "A1";
         pizza_repository.UpdateCOAStatusDefered(session.UnitOfWork, coa_status);
         var coa_log = new COALog
         {
             COASN = coa_status.COASN,
             StationID = "A1",
             Editor = session.Editor,
             IsDirty = coa_status.IsDirty,
             LineID = product.CUSTSN,
             Cdt = coa_status.Cdt,
             Tracker = coa_status.Tracker,
             Tp = "COA"
         };
         pizza_repository.InsertCOALogDefered(session.UnitOfWork, coa_log);
     }
     //}
     //else
     //{
     //    throw new FisException("CHK174", new string[] { "IMES.CheckItemModule.RoyaltyPaper.Filter.SaveModule.Save" });
     //}
 }
Exemplo n.º 4
0
        /// <summary>
        /// Update COA
        /// </summary>
        public void UpdateCOA(string begNO, string endNO, string editor, string status, string pdLine, string station)
        {
            logger.Debug("(_COAStatusChange)UpdateCOA start, begin NO:" + begNO + " end NO:" + endNO);
            try
            {
                string pno = "";
                string preStatus = "";
                IList<COAStatus> coaList = currentRepository.GetCOAStatusRange(begNO, endNO);
                foreach (COAStatus tmp in coaList)
                {
                    string preLine = "";
                    if ("" == pno)
                    {
                        pno = tmp.IECPN;
                    }
                    if ("" == preStatus)
                    {
                        preStatus = tmp.Status;
                    }


                    if (status != null && status != "")
                    {
                        tmp.Status = status.Substring(0,2);
                        if (status.Length > 3)
                        {
                            pdLine = status.Substring(3, 1);
                        }
                    }
                    if (editor != null && editor != "")
                    {
                        tmp.Editor = editor;
                    }
                    
                    tmp.Udt = DateTime.Now;

                    preLine = tmp.LineID;
                    if (pdLine!= null && pdLine != "")
                    {
                        tmp.LineID = pdLine;
                    }

                    currentRepository.UpdateCOAStatus(tmp);
                    COALog newItem = new COALog();
                    newItem.Cdt = DateTime.Now;
                    newItem.Tp = "COA";
                    newItem.COASN = tmp.COASN;
                    newItem.Editor = editor;
                    newItem.LineID = preLine;
                    if (preStatus == "")
                    {
                        newItem.StationID = "16";
                    }
                    else
                    {
                        newItem.StationID = preStatus;
                    }
                    
                    currentRepository.InsertCOALog(newItem);
                }
                COATransLog newLog = new COATransLog();
                newLog.begNo = begNO;
                newLog.endNo = endNO;
                newLog.cdt = DateTime.Now;
                newLog.status = status.Substring(0, 2);
                newLog.editor = editor;
                newLog.pno = pno;
                newLog.preStatus = preStatus;
                currentRepository.InsertCOATransLog(newLog);
            }
            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("(_COAStatusChange)UpdateCOA end, begin NO:" + begNO + " end NO:" + endNO);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Receive COA
        /// </summary>
        public void ReceiveCOA(string begNO, string endNO, string editor)
        {
            logger.Debug("(_COAStatusChange)ReceiveCOA start, begin NO:" + begNO + " end NO:" + endNO);
            try
            {
                string pno = "";
                IList<COAStatus> coaList = currentRepository.GetCOAStatusRange(begNO, endNO);
                foreach (COAStatus tmp in coaList)
                {
                    string station = "";
                    station = currentRepository.GetStationOfNewestCOALog(tmp.COASN);

                    if (null == editor)
                    {
                        editor = "";
                    }
                    if (null == station || "" == station)
                    {
                        station = "16";
                    }
                    if ("" == pno)
                    {
                        pno = tmp.IECPN;
                    }
                    COALog newItem = new COALog();
                    newItem.Cdt = DateTime.Now;
                    newItem.COASN = tmp.COASN;
                    newItem.Editor = editor;
                    newItem.Tp="COA";
                    newItem.LineID = "RCV";
                    newItem.StationID = station;
                    currentRepository.InsertCOALog(newItem);
                    tmp.Status = station;
                    tmp.Editor = editor;
                    tmp.Udt = DateTime.Now;
                    currentRepository.UpdateCOAStatus(tmp);
                }
                COATransLog newLog = new COATransLog();
                newLog.begNo = begNO;
                newLog.endNo = endNO;
                newLog.cdt = DateTime.Now;
                newLog.status = "01";
                newLog.editor = editor;
                newLog.pno = pno;
                newLog.preStatus = "RE";
                currentRepository.InsertCOATransLog(newLog);
            }
            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("(_COAStatusChange)ReceiveCOA end, begin NO:" + begNO + " end NO:" + endNO);
            }
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
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;
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Update CSNMas
        /// </summary>
        public void UpdateCSN(string begNO, string endNO, string editor, string udt, string status, string pdLine)
        {
            logger.Debug("(_CNCardStatusChange)UpdateCSN start, begin NO:" + begNO + " end NO:" + endNO);
            try
            {
                string pno = "";
                string preStatus = "";
                IList<CSNMasInfo> csnMasList = currentRepository.GetCSNMasRange(begNO, endNO);
                foreach (CSNMasInfo tmp in csnMasList)
                {
                    if ("" == pno)
                    {
                        pno = tmp.pno;
                    }
                    if ("" == preStatus)
                    {
                        preStatus = tmp.status;
                    }

                    if (status != "")
                    {
                        tmp.status = status.Substring(0, 2);
                        if (status.Length > 3)
                        {
                            pdLine = status.Substring(3, 1);
                        }
                    }
                    if (editor != "")
                    {
                        tmp.editor = editor;
                    }
                    if (udt != "")
                    {
                        tmp.udt = DateTime.Parse(udt);
                    }
                    if (pdLine != "" && pdLine != null)
                    {
                        tmp.pdLine = pdLine;
                    }
                    else
                    {
                        tmp.pdLine = "";
                    }
                    currentRepository.UpdateCSNMas(tmp);
                     
                    
                    
                    COALog newItem = new COALog();
                    newItem.Cdt = DateTime.Now;
                    newItem.Tp = "CNCard";
                    newItem.COASN = tmp.csn2;
               
                    newItem.Editor = editor;
                    newItem.StationID = "";
                    if (pdLine != "" && pdLine != null)
                    {
                        newItem.LineID = pdLine;
                    }
                    else if (tmp.pdLine != null && tmp.pdLine != "")
                    {
                        newItem.LineID = tmp.pdLine;
                    }
                    else
                    {
                        newItem.LineID = "";
                    }
                    
                    currentRepository.InsertCOALog(newItem);
                }
                COATransLog newLog = new COATransLog();
                newLog.begNo = begNO;
                newLog.endNo = endNO;
                newLog.cdt = DateTime.Now;
                newLog.status = status.Substring(0, 2);
                newLog.editor = editor;
                newLog.pno = pno;
                newLog.preStatus = preStatus;
                currentRepository.InsertCOATransLog(newLog);
                
            }
            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("(_CNCardStatusChange)UpdateCSN end, begin NO:" + begNO + " end NO:" + endNO);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Wrint COALog
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            if (Editor.Trim() == "")
                logger.Error("Editor from activity is empty!");

            var currentRepository = RepositoryFactory.GetInstance().GetRepository<ICOAStatusRepository, COAStatus>();
            if (COASNFrom == COAFrom.COASN)
            {
                var coaSN = CurrentSession.GetValue(Session.SessionKeys.COASN) as string;
                if (coaSN == null)
                {
                    throw new NullReferenceException("COASN in session is null");
                }

                var newLog = new COALog
                {
                    COASN = coaSN,
                    Tp = Tp,
                    Editor = Editor,
                    LineID = Line,
                    StationID = Station,
                    Cdt = DateTime.Now
                };

                currentRepository.InsertCOALogDefered(CurrentSession.UnitOfWork, newLog);
            }
            else
            {
                var coaSNList = CurrentSession.GetValue(Session.SessionKeys.COASNList) as List<string>;
                if (coaSNList == null)
                {
                    throw new NullReferenceException("COASNList in session is null");
                }
                foreach (var coaSN in coaSNList)
                {
                    var newLog = new COALog
                    {
                        COASN = coaSN,
                        Tp = Tp,
                        Editor = Editor,
                        LineID = Line,
                        StationID = Station,
                        Cdt = DateTime.Now
                    };

                    currentRepository.InsertCOALogDefered(CurrentSession.UnitOfWork, newLog);
                }
            }
            return base.DoExecute(executionContext);
        }
Exemplo n.º 10
0
        /// <summary>
        /// 产生BindCoaToProduct
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            IProductRepository productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            ICOAStatusRepository coaRepository = RepositoryFactory.GetInstance().GetRepository<ICOAStatusRepository, COAStatus>();
            IPart part = null;
            string custSN = (string)CurrentSession.GetValue(Session.SessionKeys.CustSN);
            var product = productRepository.GetProductByCustomSn(custSN);
            if (null == product)
            {
                List<string> errpara = new List<string>();

                errpara.Add(custSN);
                throw new FisException("SFC002", errpara);
            }

            //var product = (IProduct)CurrentSession.GetValue(Session.SessionKeys.Product);
            string model = product.Model;
            // 取ModelBOM 中Model 直接下阶中有BomNodeType 为'P1' 的Part
            IBOMRepository ibomRepository = RepositoryFactory.GetInstance().GetRepository<IMES.FisObject.Common.FisBOM.IBOMRepository>();
            IHierarchicalBOM sessionBOM = null;
            sessionBOM = ibomRepository.GetHierarchicalBOMByModel(product.Model);
            IList<IBOMNode> bomNodeLst = new List<IBOMNode>();
            bomNodeLst = sessionBOM.FirstLevelNodes;
            if (bomNodeLst != null && bomNodeLst.Count > 0)
            {
                foreach (IBOMNode ibomnode in bomNodeLst)
                {
                    IPart currentPart = ibomnode.Part;
                    if (currentPart.BOMNodeType == "P1" && currentPart.Descr.IndexOf("COA") == 0)
                    {
                        part = currentPart;
                        break;
                    }
                }
            }
            
            string coaSN = (string)CurrentSession.GetValue(Session.SessionKeys.COASN);
           
            if (coaSN != "" && part == null)
            {
                List<string> err = new List<string>();
                err.Add(coaSN);
                err.Add(custSN);
                throw new FisException("CHK187", err);
            }
            else if (coaSN != "" && part != null)
            {

                ICOAStatusRepository currentRepository = RepositoryFactory.GetInstance().GetRepository<ICOAStatusRepository, COAStatus>();
                IList<COAStatus> coaList = currentRepository.GetCOAStatusRange(coaSN, coaSN);
                if (null == coaList || coaList.Count == 0)
                {
                    List<string> err = new List<string>();
                    err.Add(coaSN);
                    err.Add(custSN);
                    throw new FisException("CHK187", err);
                }
                foreach (COAStatus tmp in coaList)
                {
                    if (part.PN != tmp.IECPN)
                    {
                        List<string> err = new List<string>();
                        err.Add(coaSN);
                        err.Add(custSN);
                        throw new FisException("CHK187", err);
                    }
                }
                IList<ProductPart> parts = new List<ProductPart>();
                parts = productRepository.GetProductPartsByPartSn(coaSN);
                foreach (ProductPart iparts in parts)
                {
                    if (iparts.PartSn == coaSN && iparts.ProductID != product.ProId)
                    {
                        List<string> err = new List<string>();
                        err.Add(coaSN);
                        err.Add(custSN);
                        throw new FisException("CHK187", err);
                    }
                }
                /*// IMES_FA..Product_Part 表中与当前Product 绑定的Parts 
                IList<IProductPart> productParts = new List<IProductPart>();
                productParts = ((IProduct)product).ProductParts;
                if (productParts == null || productParts.Count <= 0)
                {
                    //该Product尚未绑定Part!
                    List<string> err = new List<string>();
                    err.Add(coaSN);
                    err.Add(custSN);
                    throw new FisException("CHK187", err);
                }*/
                
                
                
                
                COAStatus reCOA = coaRepository.Find(coaSN);
                IProductPart bindPart = new ProductPart();
                bindPart.ProductID = product.ProId;
                bindPart.PartID = part.PN;
                bindPart.PartSn = coaSN;
                bindPart.Cdt = DateTime.Now;
                bindPart.BomNodeType = "P1";
                bindPart.PartType = part.Type;
                bindPart.CustomerPn = part.CustPn;
                if (this.Editor == null)
                {
                    Editor = "";
                }
                if (this.Station == null)
                {
                    Station = "";
                }
                bindPart.Station = Station;
                bindPart.Editor = Editor;
                bindPart.CheckItemType = "";
                bindPart.Iecpn = "";
                product.AddPart(bindPart);
                reCOA.Editor = Editor;
                reCOA.Status = "A1";
                coaRepository.UpdateCOAStatusDefered(CurrentSession.UnitOfWork, reCOA);
                COALog newItem = new COALog();
                newItem.COASN = coaSN;
                newItem.LineID = custSN;
                newItem.Editor = Editor;
                newItem.StationID = "A1";
                newItem.Tp = "";
                coaRepository.InsertCOALogDefered(CurrentSession.UnitOfWork, newItem);
                productRepository.Update(product, CurrentSession.UnitOfWork);
            }
            

            return base.DoExecute(executionContext);
        }
Exemplo n.º 11
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")
            {
                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);
        }
Exemplo n.º 12
0
        public void addCOALog(COALog newLog)
        {
            if (newLog == null)
                return;

            lock (_syncObj_coaLogs)
            {
                if (_coaLogs == null)
                {
                    _coaLogs = new List<COALog>();
                }

                //object naught = this.CoaLogs;
                if (this._coaLogs.Contains(newLog))
                    return;

                newLog.Tracker = this._tracker.Merge(newLog.Tracker);
                this._coaLogs.Add(newLog);
                this._tracker.MarkAsAdded(newLog);
                this._tracker.MarkAsModified(this);
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Wrint COALog
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            if (Editor.Trim() == "")
                logger.Error("Editor from activity is empty!");

            var currentRepository = RepositoryFactory.GetInstance().GetRepository<ICOAStatusRepository, COAStatus>();
            ICOAStatusRepository coaStatusRep = RepositoryFactory.GetInstance().GetRepository<ICOAStatusRepository, COAStatus>();
            string coaSN = (string)CurrentSession.GetValue(Session.SessionKeys.COASN);
            Product productPartOwner = (Product)CurrentSession.GetValue(Session.SessionKeys.Product);

            if (coaSN == null)
            {
                throw new NullReferenceException("COASN in session is null");
            }

            var newLog = new COALog
            {
                COASN = coaSN,
                Tp = "",
                Editor = Editor,
                LineID = productPartOwner.CUSTSN + "/" +productPartOwner.ModelObj.CustPN,
                StationID = this.Station,
                Cdt = DateTime.Now
            };

            currentRepository.InsertCOALogDefered(CurrentSession.UnitOfWork, newLog);


            COAStatus _coaStatus = coaStatusRep.GetCoaStatus(coaSN);
            if (_coaStatus != null)
            {
                _coaStatus.Status = this.Station;
                _coaStatus.COASN = coaSN;
                _coaStatus.Editor = this.Editor;
                coaStatusRep.UpdateCOAStatusDefered(CurrentSession.UnitOfWork, _coaStatus);
            }
            return base.DoExecute(executionContext);
        }