Exemple #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override System.Workflow.ComponentModel.ActivityExecutionStatus DoExecute(System.Workflow.ComponentModel.ActivityExecutionContext executionContext)
        { 
            IProduct product = (IProduct)CurrentSession.GetValue(Session.SessionKeys.Product);
            IProductRepository productRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            IDeliveryRepository deliveryRep = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>();
            IPalletRepository palletRep = RepositoryFactory.GetInstance().GetRepository<IPalletRepository, Pallet>();
            carton.ICartonSSCCRepository cartRep = RepositoryFactory.GetInstance().GetRepository<carton.ICartonSSCCRepository, IMES.FisObject.PAK.CartonSSCC.CartonSSCC>();

            try
            {
                //2.	Assign Pallet
                //Assign Pallet 的方法:
                //1.	找到与Product.DeliveryNo 结合的Pallets  
                //2.	取其中尚未完成Combine PO in Carton 的Pallets
                //3.	按照Pallet No 正序,和Pallet 已经完成Combine PO in Carton 的数量逆序排序,取第一个Pallet
                //DECLARE @dn char(16)
                //DECLARE @pea float
                //DECLARE @pea2 int
                //SELECT @pea = InfoValue FROM DeliveryInfo (NOLOCK) WHERE DeliveryNo=@dn AND InfoType = ‘CQty’
                string peastr;
                Delivery dev = deliveryRep.Find(product.DeliveryNo);
                peastr = (string)dev.GetExtendedProperty("CQty");

                int pea = 0;
                if (string.IsNullOrEmpty(peastr))
                {
                    pea = 0;
                }
                else
                {
                    decimal tmp = Convert.ToDecimal(peastr);
                    pea = Convert.ToInt32(tmp);
                }
                

                //SET @pea2=CONVERT(int, @pea)
                //CREATE TABLE #plt (Plt char(14), qty int, tot int)
                //CREATE TABLE #Pltamount (Plt char(14), qty int)

                //INSERT #plt 
	            //SELECT PalletNo, DeliveryQty, 0 
		        //FROM Delivery_Pallet (NOLOCK) 
		        //WHERE DeliveryNo=@dn 
                IList<DeliveryPalletInfo> palletList = deliveryRep.GetDeliveryPalletListByDN(product.DeliveryNo);

                //INSERT #Pltamount
	            //SELECT PalletNo, COUNT(ProductID) as Qty
		        //FROM Product (NOLOCK)
		        //WHERE DeliveryNo = @dn 
                IList<IProduct> mountList = productRep.GetProductListByDeliveryNo(product.DeliveryNo);

                //UPDATE #plt SET tot = b.qty FROM #plt a,#Pltamount b
                //WHERE a.Plt=b.Plt
                //SELECT * FROM #plt

                //DELETE FROM #plt WHERE @pea2 * CONVERT(int, qty) – CONVERT(int, tot) < 1
                //SELECT * FROM #plt
                 for (int i = palletList.Count-1; i >= 0; i--)
                {
                    DeliveryPalletInfo node = palletList[i];
                    IList <ProductModel> proList = productRep.GetProductByDnPallet(product.DeliveryNo,node.palletNo);

                    if ((proList != null) && (proList.Count > 0))
                    {
                        int tot = proList.Count;
                        int qty = node.deliveryQty;
                        node.id = tot;
                        if (pea*qty - tot <1)
                        {
                            //ITC-1414-0116
                            palletList.RemoveAt(i);
                        }
                    }
                }
                //SELECT TOP 1 Plt as [Pallet No]
	            //FROM #plt 
	            //ORDER BY Plt, tot DESC
                 var tmpList = from item in palletList orderby item.palletNo, item.id descending select item;
                 IList<DeliveryPalletInfo> orderList = tmpList.ToList<DeliveryPalletInfo>();

                 string palletNo = orderList[0].palletNo;

                //3.	Assign Location by Pallet
                //IF EXISTS(SELECT SnoId FROM PAK_LocMas (NOLOCK)WHERE Tp='PakLoc' AND Pno=@PalletNo) 
                //BEGIN
	            //    SELECT @loc=SnoId FROM PAK_LocMas(NOLOCK) WHERE Tp='PakLoc' AND Pno=@PalletNo
                //END
                //ELSE
                //BEGIN
	            //IF EXISTS(SELECT SnoId FROM PAK_LocMas(NOLOCK) WHERE Tp='PakLoc' AND Pno='' )
	            //BEGIN
		        //SELECT @loc=SnoId FROM PAK_LocMas(NOLOCK) WHERE Tp='PakLoc' AND Pno='' ORDER BY CONVERT(int, SnoId)
		        //UPDATE PAK_LocMas SET Pno=@PalletNo,Udt=GETDATE() WHERE Tp='PakLoc' AND SnoId=@loc
	            //END
	            //ELSE	
	            //BEGIN
		        //SELECT @loc='Others'
	            //END	
                //END

                //@PalletNo – 上文分配的Pallet No
                //@loc – 系统分配的库位
                 string loc = "";
                 IList<PakLocMasInfo> macList = palletRep.GetPakLocMasList(palletNo, "PakLoc");
                 if (macList.Count > 0)
                 {
                     loc = macList[0].snoId;
                 }
                 else
                 {
                     macList = palletRep.GetPakLocMasList("", "PakLoc");
                     if (macList.Count > 0)
                     {
                         PakLocMasInfo locInfo = macList[0];
                         foreach (var item in macList)
                         {
                             if (Convert.ToInt64(locInfo.snoId) > Convert.ToInt64(item.snoId))
                             {
                                 locInfo = item;
                             }
                         }
                         loc = locInfo.snoId;

                         PakLocMasInfo sitem= new PakLocMasInfo();
                         PakLocMasInfo cond= new PakLocMasInfo();
                         sitem.pno= palletNo;
                         sitem.udt = DateTime.Now;
                         cond.tp = "PakLoc";
                         cond.snoId = loc;
                         palletRep.UpdatePakLocMasInfoDefered(CurrentSession.UnitOfWork,sitem,cond );

                     }
                     else
                     {
                         loc = "Others";
                     }
                 }
                 CurrentSession.AddValue("Location",loc);

                //4.	Product结合Pallet and Carton    
                //将页面上[Products in Carton] 中的每一个Product和上文系统分配的Pallet 以及上文生成的Carton No 进行结合 – Update Product
                //Product.PalletNo – Pallet No
                //Product.CartonSN – Carton No

                 IList<IProduct> productList = (List<IProduct>)CurrentSession.GetValue(Session.SessionKeys.ProdList);
                 foreach (var item in productList)
                 {
                     item.PalletNo = palletNo;
                     item.CartonSN = product.CartonSN;
                     //productRep.Update(item,CurrentSession.UnitOfWork);
                     productRep.UpdateForBindDNAndPalletDefered(CurrentSession.UnitOfWork, (Product)item);
                 }

                //ITC-1414-0070
                //ITC-1414-0120
                //5.	更新CartonStatus 的状态为95 (Station = ‘95’ ,Status= ‘1’),记录CartonLog
                CartonStatusInfo sinfo = new CartonStatusInfo();
                CartonStatusInfo sconf = new CartonStatusInfo();
                sconf.cartonNo = product.CartonSN;

                sinfo.editor = Editor;
                sinfo.line = Line;
                sinfo.station ="95";//Station;
                sinfo.status = 1;//pass
                sinfo.udt = DateTime.Now;
                cartRep.UpdateCartonStatusDefered(CurrentSession.UnitOfWork,sinfo,sconf);

                CartonLogInfo linfo = new CartonLogInfo();
                linfo.cartonNo = product.CartonSN;
                linfo.editor = Editor;
                linfo.line = Line;
                linfo.station = "95";
                linfo.status = 1;//pass
                linfo.cdt = DateTime.Now;
                cartRep.AddCartonLogInfoDefered(CurrentSession.UnitOfWork, linfo);

                 //6.更新Carton上所有Product 的ProductStatus 的状态为Combine Po In Carton for Docking 的站号(Station = Combine Po In Carton for Docking 的站号,Status= ‘1’),并记录ProductLog
                 string line = string.IsNullOrEmpty(this.Line) ? product.Status.Line : this.Line;

                 var newStatus = new IMES.FisObject.FA.Product.ProductStatus();
                 newStatus.Editor = Editor;
                 newStatus.Line = line;
                 newStatus.StationId = Station;
                 newStatus.Status = IMES.FisObject.Common.Station.StationStatus.Pass;

                 IList<string> ProductIDList = (IList<string>)CurrentSession.GetValue(Session.SessionKeys.NewScanedProductIDList);
                 productRep.UpdateProductListStatusDefered(CurrentSession.UnitOfWork, newStatus, ProductIDList);

                 foreach (var item in productList)
                 {
                     var productLog = new ProductLog
                     {
                         Model = item.Model,
                         Status = IMES.FisObject.Common.Station.StationStatus.Pass,
                         Editor = Editor,
                         Line = line,
                         Station = Station,
                         Cdt = DateTime.Now
                     };

                     item.AddLog(productLog);
                     productRep.Update(item, CurrentSession.UnitOfWork);
                 }
            }
            catch (Exception)
            {
                throw;
            }
            
            return base.DoExecute(executionContext);
        }
Exemple #2
0
        /// <summary>
        /// 產生Carton NO號相关逻辑
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override System.Workflow.ComponentModel.ActivityExecutionStatus DoExecute(System.Workflow.ComponentModel.ActivityExecutionContext executionContext)
        { 
            IProduct product = (IProduct)CurrentSession.GetValue(Session.SessionKeys.Product);
            IProductRepository productRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();

            //Format of Carton No
            //CYMDDSSSS
            //Remark:
            //T – 前缀,固定字符’C’
            //Y – Year Code,西元年的最后一位
            //M – Month Code,1~9 表示1~9 月,A~C 表示10~12 月
            //DD – Day Code,两位,00~31
            //SSSS – 流水号,10进制,起始值为0001
            try
            {
        
                string CartonNO = "";
                string maxnum = "";
                string prestr = "";
                //求当前日期是一年的中第几周
                //int weeks = 0;
                DateTime curDate = DateTime.Now;
                /*var ret = IMES.Infrastructure.Utility.Generates.WeekRuleEngine.Calculate("103", dateTime);
                string weekCode = ret.Week.ToString().PadLeft(2, '0');
                string year = ret.Year.ToString();
                string month = ret.*/
                string year = curDate.Year.ToString();
                //string month = Convert.ToString(curDate.Month,16);
                string month = curDate.Month.ToString("X");//2012/10/05
                string dd = curDate.Day.ToString("d2");

                CartonNO = "C" + year.Substring(year.Length - 1, 1) + month + dd;
                prestr = CartonNO;
                // 自己管理事务开始
                SqlTransactionManager.Begin();
                IUnitOfWork uof = new UnitOfWork();//使用自己的UnitOfWork

                //从NumControl中获取流水号
                //GetMaxNumber
                INumControlRepository numControl = RepositoryFactory.GetInstance().GetRepository<INumControlRepository, NumControl>();

                bool addflag = false;

                //maxnum = numControl.GetMaxNumber("CARTONNO", prestr + "{0}");
                var maxObj = numControl.GetMaxValue("CARTONNO", prestr);
                //檢查有沒有lock index, 沒有lock index, 改變查詢條件
                if (maxObj == null)
                {
                    //lock NoType='CARTONNO'
                    //string maxData = numControl.GetMaxNumber("CARTONNO", "{0}");
                    //maxObj = numControl.GetMaxNumberObj("CARTONNO", prestr + "{0}");
                    var data = numControl.GetMaxValue("CARTONNO", "Lock");
                    maxObj = numControl.GetMaxValue("CARTONNO", prestr);
                }

                if (maxObj != null)
                {
                    maxnum = maxObj.Value;
                } 

                if (string.IsNullOrEmpty(maxnum))
                {
                    maxnum = "0001";//"8000";
                    addflag = true;
                }
                else
                {
                    //maxnum="CNU248000Y";                   
                    string numstr = maxnum.Substring(maxnum.Length - 4);
                    if (numstr.ToUpper() == "9999")
                    {
                        FisException fe = new FisException("CHK867", new string[] { });   //流水号已满!
                        throw fe;
                    }
                    //ITC-1414-0069
                    int result = Convert.ToInt32(numstr)+1;
                    maxnum = result.ToString("d4");
                }

                CartonNO = CartonNO + maxnum.ToUpper();

               
                NumControl item = null;// new NumControl();
                if (addflag)
                {
                    item = new NumControl();
                    item.NOType = "CARTONNO";
                    item.Value = CartonNO;
                    item.NOName = prestr;
                    item.Customer = this.Customer;
                }
                else
                {
                    item = maxObj;
                    item.Value = CartonNO;
                }

                //numControl.SaveMaxNumber(item, addflag, prestr + "{0}");
                numControl.SaveMaxNumber(item, addflag);

                uof.Commit();  //立即提交UnitOfWork更新NumControl里面的最大值

                SqlTransactionManager.Commit();//提交事物,释放行级更新锁

                product.CartonSN = CartonNO;

                //a.	Insert CartonStatus
                //INSERT INTO [CartonStatus]([CartonNo],[Station],[Status],[Line],[Editor],[Cdt],[Udt])
	            //VALUES(@CartonNo, @Station, 1, @PdLine, @Editor, GETDATE(), GETDATE())
                carton.ICartonSSCCRepository cartRep = RepositoryFactory.GetInstance().GetRepository<carton.ICartonSSCCRepository, IMES.FisObject.PAK.CartonSSCC.CartonSSCC>();
                CartonStatusInfo sinfo = new CartonStatusInfo();
                sinfo.cartonNo = product.CartonSN;
                sinfo.station = Station;
                sinfo.status = 1;//pass
                sinfo.line = Line;
                sinfo.editor = Editor;
                sinfo.cdt = DateTime.Now;
                sinfo.udt = DateTime.Now;
                cartRep.AddCartonStatusInfoDefered(CurrentSession.UnitOfWork,sinfo);
                
                //b.	Insert CartonLog
                //INSERT INTO [CartonLog]([CartonNo],[Station],[Status],[Line],[Editor],[Cdt])
            	//VALUES(@CartonNo, @Station, 1, @PdLine, @Editor, GETDATE())
                CartonLogInfo linfo = new CartonLogInfo();
                linfo.cartonNo = product.CartonSN;
                linfo.station = Station;
                linfo.status = 1;//pass
                linfo.line = Line;
                linfo.editor = Editor;
                linfo.cdt = DateTime.Now;
                cartRep.AddCartonLogInfoDefered(CurrentSession.UnitOfWork,linfo);
                
            }
            catch (Exception)
            {
                SqlTransactionManager.Rollback();
                throw;
            }
            finally
            {
                SqlTransactionManager.Dispose();
                SqlTransactionManager.End();
            }
            
            return base.DoExecute(executionContext);
        }
        /// <summary>
        /// 结束
        /// 
        /// </summary>
        /// <param name="CartonSN"></param>
		/// <param name="line"></param>
        /// <param name="editor"></param>
        /// <param name="station"></param>
        public void save(string CartonSN, string line, string editor, string station)
		{
			logger.Debug("(CheckCartonCTForRCTOImpl)save start, [CartonSN]:" + CartonSN + " [editor]:" + editor + " [station]:" + station);
            FisException ex;
            List<string> erpara = new List<string>();
			
			try
            {
                carton.ICartonSSCCRepository cartRep = RepositoryFactory.GetInstance().GetRepository<carton.ICartonSSCCRepository, IMES.FisObject.PAK.CartonSSCC.CartonSSCC>();
                CartonLogInfo linfo = new CartonLogInfo();
                linfo.cartonNo = CartonSN;
                linfo.station = station;
                linfo.status = 1;//pass
                linfo.line = line;
                linfo.editor = editor;
                linfo.cdt = DateTime.Now;
                cartRep.AddCartonLogInfo(linfo);
            }
            catch (FisException e)
            {
                logger.Error(e.mErrmsg);
                throw e;
            }
            catch (Exception e)
            {
                logger.Error(e.Message);
                throw e;
            }
            finally
            {
                logger.Debug("(CheckCartonCTForRCTOImpl)save end, [CartonSN]:" + CartonSN + " [editor]:" + editor + " [station]:" + station);
            }
		}
Exemple #4
0
        /// <summary>
        /// 执行根据DeliveryNo修改所有属于该DeliveryNo的Product状态的操作
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            string Delivery = (string)CurrentSession.GetValue(Session.SessionKeys.DeliveryNo);
            Delivery CurrentDelivery = (Delivery)CurrentSession.GetValue(Session.SessionKeys.Delivery);

            IDeliveryRepository DeliveryRepository = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>();
            IProductRepository repProduct = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            ////
           

            IList<string> nameList = new List<string>();
            nameList.Add("UCC");
            nameList.Add("BoxId");
            repProduct.BackUpProductByDnPure( Delivery, Editor);
            repProduct.BackUpProductInfoByDn( Delivery, Editor, nameList);
            repProduct.BackUpProductStatusByDnPure( Delivery, Editor);
           
            ////
            ProductStatus newStatus = new ProductStatus();
            newStatus.Editor = Editor;
            newStatus.Line = Line;
            newStatus.StationId = Station;
            newStatus.Status = StationStatus.Pass;
            newStatus.ReworkCode = "";

            repProduct.UpdateUnPackProductStatusByDn(newStatus, Delivery);
            carton.ICartonSSCCRepository cartRep = RepositoryFactory.GetInstance().GetRepository<carton.ICartonSSCCRepository, IMES.FisObject.PAK.CartonSSCC.CartonSSCC>();
            IPalletRepository palletRep = RepositoryFactory.GetInstance().GetRepository<IPalletRepository, Pallet>();

            ////
            ProductLog newLog = new ProductLog();
            newLog.Editor = Editor;
            newLog.Line = Line;
            newLog.Station = Station;
            newLog.Status = StationStatus.Pass;

            repProduct.WriteUnPackProductLogByDn(Delivery,newLog);

            //////
            repProduct.UnPackProductInfoByDeliveryNoAndInfoType("UCC",Delivery);
            repProduct.UnPackProductInfoByDeliveryNoAndInfoType("BoxId", Delivery);
            
            ////////
            if (Station != "8U")
            {
                IList<IProduct> lstProduct = repProduct.GetProductObjListByDn(Delivery);
                if (lstProduct != null && lstProduct.Count > 0)
                {
                    foreach(IProduct tmp in lstProduct)
                    {
                        string carton = tmp.CartonSN;
                        DM.CartonInfoInfo condition = new DM.CartonInfoInfo();
                        condition.cartonNo = carton;
                        cartRep.DeleteCartonInfo(condition);

                        //mantis 1395
                        DM.CartonStatusInfo cond = new DM.CartonStatusInfo();
                        DM.CartonStatusInfo sv = new DM.CartonStatusInfo();
                        cond.cartonNo = tmp.CartonSN;
                        sv.station = Station;
                        sv.status = 1;
                        sv.editor = Editor;
                        sv.udt = DateTime.Now;
                        cartRep.UpdateCartonStatusDefered(CurrentSession.UnitOfWork, sv, cond);

                        DM.CartonLogInfo item = new DM.CartonLogInfo();
                        item.cartonNo = tmp.CartonSN;
                        item.cdt = DateTime.Now;
                        item.editor = Editor;
                        item.line = tmp.Status.Line;
                        item.station = Station;
                        item.status = 1;
                        cartRep.AddCartonLogInfoDefered(CurrentSession.UnitOfWork, item);
                        //mantis 1395


                        string palletNo = tmp.PalletNo;
                        DM.PakLocMasInfo setValue = new DM.PakLocMasInfo();
                        DM.PakLocMasInfo pakLoc_condition = new DM.PakLocMasInfo();
                        setValue.pno = "";
                        setValue.editor = Editor;
                        pakLoc_condition.pno = palletNo;
                        pakLoc_condition.tp = "PakLoc";
                        palletRep.UpdatePakLocMasInfo(setValue, pakLoc_condition);
                    }
                }
            }

            if (Station != "8U")
                repProduct.UnPackProductByDn(Delivery);
            else
                repProduct.UnPackProductByDnWithoutCartonSN(Delivery);

    /////////////////////
            CurrentDelivery.Status = "00";
            CurrentDelivery.Editor = this.Editor;
            CurrentDelivery.Udt = DateTime.Now;
            DeliveryRepository.Update(CurrentDelivery, CurrentSession.UnitOfWork);
    /////////////////////


            return base.DoExecute(executionContext);
        }
Exemple #5
0
        /// <summary>
        /// 执行根据DeliveryNo修改所有属于该DeliveryNo的Product状态的操作
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            string CartonNo = (string)CurrentSession.GetValue(Session.SessionKeys.Carton);
            carton.ICartonSSCCRepository cartRep = RepositoryFactory.GetInstance().GetRepository<carton.ICartonSSCCRepository, IMES.FisObject.PAK.CartonSSCC.CartonSSCC>();
            IDeliveryRepository DeliveryRepository = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>();
            IProductRepository repProduct = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
    
            IList<IProduct> lstProduct = repProduct.GetProductListByCartonNo(CartonNo);

            CartonInfoInfo condition = new CartonInfoInfo();
            condition.cartonNo = CartonNo;
            cartRep.DeleteCartonInfo(condition);
            DeliveryRepository.UpdateDeliveryForStatusChange(Editor,  CartonNo);
            //
            CartonStatusInfo setValue = new CartonStatusInfo();
            CartonStatusInfo status_condition = new CartonStatusInfo();
            setValue.cartonNo = CartonNo;
            setValue.status = 1;
            setValue.editor = Editor;
            setValue.station = Station;

            status_condition.cartonNo = CartonNo; 
            cartRep.UpdateCartonStatus( setValue,  status_condition);

           
            ///////////////
            CartonLogInfo item = new CartonLogInfo();
            item.cartonNo = CartonNo;
            item.editor = Editor;
            item.line = Line;
            item.station = Station;
            item.status = 1;
            cartRep.AddCartonLogInfo(item);
            
           //////////////////

            CurrentSession.AddValue(Session.SessionKeys.ProdList, lstProduct);
            CurrentSession.AddValue(Session.SessionKeys.DnIndex, 0);
            CurrentSession.AddValue(Session.SessionKeys.DnCount, lstProduct.Count);

            return base.DoExecute(executionContext);
        }