/// <summary>
        /// InsertPakSkuMasterWeightFis
        /// input parameters:model dn.
        /// via product object, can be changed if needed
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {

            //???
            Product currentProduct = (Product) CurrentSession.GetValue(Session.SessionKeys.Product);
            string productModel = currentProduct.Model;
            string productDn = currentProduct.DeliveryNo;
            IPizzaRepository repPizza = RepositoryFactory.GetInstance().GetRepository<IPizzaRepository, Pizza>();
            decimal weightget = repPizza.GetAverageWeightFromPakSkuMasterWeightFis(productModel);

            if (weightget == 0)
            {
                FisException ex;
                List<string> erpara = new List<string>();
                erpara.Add(productDn);
                erpara.Add(productModel);
                ex = new FisException("PAK041", erpara);
                throw ex;
            }
            var item = new PakSkuMasterWeightFisInfo { model = productModel, weight = weightget, cdt = DateTime.Now };
            repPizza.InsertPakSkuMasterWeightFis(item);
            return base.DoExecute(executionContext);
        }
示例#2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            IPizzaRepository repPizza = RepositoryFactory.GetInstance().GetRepository<IPizzaRepository, Pizza>();
            IModelWeightRepository ModelWeightRepository = RepositoryFactory.GetInstance().GetRepository<IModelWeightRepository, ModelWeight>();
            IList<PakSkuMasterWeightFisInfo> weightList = new List<PakSkuMasterWeightFisInfo>();
            
            switch (InputType)
            {
                case InputTypeEnum.DN:
                case InputTypeEnum.Shipment:
                case InputTypeEnum.Waybill:
                    IList<VShipmentPakComnInfo> comnList1 = (IList<VShipmentPakComnInfo>)CurrentSession.GetValue("ComnList");
                    string data = (string)CurrentSession.GetValue("Data");

                    foreach (VShipmentPakComnInfo temp in comnList1)
                    {
                        //若其model在IMES_PAK..ModelWeight.UnitWeight 没有定义weight
                        //若在PAK_SkuMasterWeight_FIS能找到model前4位一样的数据(left(PAK_SkuMasterWeight_FIS.Model,4)=left(@model,4))时
                        ModelWeight mw = new ModelWeight();
                        mw = ModelWeightRepository.Find(temp.model);                                                 
                        weightList = repPizza.GetPakSkuMasterWeightFisListByLikeModel(temp.model.Substring(0, 4));
                        if ((mw == null || mw.UnitWeight == 0) && (weightList != null && weightList.Count != 0))
                        {                            
                            //将写入Packinglist_RePrint:insert  into  Packinglist_RePrint values (@DN--刷入的code,ACTUAL_SHIPDATE, @model)
                            PackinglistRePrintInfo item = new PackinglistRePrintInfo();
                            item.model = temp.model;
                            item.dn = data;                            
                            item.shipDate = temp.actual_shipdate;
                            repPizza.InsertPackinglistRePrint(item);                            
                        }
                        //按照model在PAK_SkuMasterWeight_FIS里找不到记录的,需要得到weight写入
                        //insert into PAK_SkuMasterWeight_FIS values(@model,@weight,getdate())                        
                        if(!repPizza.CheckExistModelInPakSkuMasterWeightFis(temp.model))                        
                        {
                            decimal weight = 0;
                            PakSkuMasterWeightFisInfo newinfo = new PakSkuMasterWeightFisInfo();
                            //@weight = convert(decimal(10,3), sum(Weight)/count(*)) from PAK_SkuMasterWeight_FIS where Left(Model,4) = left(@model,4) and substring(Model,10,2)<>'25'
                            //UC疑问??????????
                            
                            weight = repPizza.GetAverageWeightFromPakSkuMasterWeightFisByModel(temp.model.Substring(0,4));
                            if (weight < 0)
                            {
                                FisException ex;
                                List<string> erpara = new List<string>();
                                //ITC-1360-1096
                                erpara.Add(data);
                                erpara.Add(temp.model);
                                ex = new FisException("CHK819", erpara);
                                //ex.stopWF = false;
                                throw ex;
                            }
                            else
                            {                                
                                newinfo.weight = weight;
                                newinfo.model = temp.model;
                                newinfo.cdt = DateTime.Now;
                                repPizza.InsertPakSkuMasterWeightFis(newinfo);                        
                            }
                        }
                    }
                    break;
                case InputTypeEnum.DNForPL:
                    //4.保存数据
                    IList<VShipmentPakComnInfo> listShip = (IList<VShipmentPakComnInfo>)CurrentSession.GetValue("ComnList");
                    string deliveryNo = (string)CurrentSession.GetValue(Session.SessionKeys.DeliveryNo);

                    foreach (VShipmentPakComnInfo temp in listShip)
                    {
                        //按照model在PAK_SkuMasterWeight_FIS里找不到记录的,需要得到weight写入
                        //insert into PAK_SkuMasterWeight_FIS values(@model,@weight,getdate())                    
                        if (!repPizza.CheckExistModelInPakSkuMasterWeightFis(temp.model))
                        {
                            //@weight = convert(decimal(10,3), sum(Weight)/count(*)) from PAK_SkuMasterWeight_FIS where Left(Model,4) = left(@model,4) 
                            decimal weight;
                            //ITC-1360-1042  底层接口返回值修改为-1
                            weight = repPizza.GetAverageWeightFromPakSkuMasterWeightFis(temp.model.Substring(0, 4));
                            if (weight < 0)
                            {
                                FisException ex;
                                List<string> erpara = new List<string>();
                                erpara.Add(deliveryNo);
                                erpara.Add(temp.model);
                                ex = new FisException("CHK819", erpara);
                                throw ex;
                            }
                            PakSkuMasterWeightFisInfo item = new PakSkuMasterWeightFisInfo();
                            item.weight = weight;
                            item.model = temp.model;
                            item.cdt = DateTime.Now;
                            repPizza.InsertPakSkuMasterWeightFis(item);
                        }
                        IList<decimal> wList = new List<decimal>();
                        //select @weight = Weight from PAK_SkuMasterWeight_FIS where Model = @model if @shipment = ''
                        wList = repPizza.GetWeightFromPakSkuMasterWeightFis(temp.model);
                        foreach (decimal y in wList)
                        {
                            //if @shipment = '
                            if (string.IsNullOrEmpty(temp.consol_invoice.TrimEnd()))
                            {
                                // if not exists(select * from PAK_ShipmentWeight_FIS where Shipment = left(@DN,10))
                                if (!repPizza.CheckExistPakShipmentWeightFis(deliveryNo.Substring(0, 10)))
                                {
                                    IList<decimal> qtyList = new List<decimal>();
                                    //select @qty = PACK_ID_LINE_ITEM_BOX_QTY from v_Shipment_PAKComn where InternalID = @deliveryno


                                    //ITC-1360-1049  底层接口抛异常 返回值修改为<decimal>
                                    qtyList = repPizza.GetPackIdLineItemBoxQtyFromPakShipmentWeightFis(deliveryNo);

                                    foreach (decimal t in qtyList)
                                    {
                                        PakShipmentWeightFisInfo item1 = new PakShipmentWeightFisInfo();
                                        item1.weight = y * t;
                                        item1.cdt = DateTime.Now;
                                        item1.type = "D";
                                        item1.shipment = deliveryNo;
                                        //insert into PAK_ShipmentWeight_FIS values(@DN,'D',convert(decimal(10,3),@qty)*@weight,getdate())
                                        repPizza.InsertPakShipmentWeightFis(item1);
                                    }
                                }
                            }
                            else
                            {
                                //if not exists (select * from PAK_ShipmentWeight_FIS where Shipment = @shipment)
                                if (!repPizza.CheckExistPakShipmentWeightFis(temp.consol_invoice.TrimEnd()))
                                {
                                    decimal qty;
                                    //select @qty = sum(PACK_ID_LINE_ITEM_BOX_QTY) from [v_Shipment_PAKComn] where CONSOL_INVOICE = @shipment
                                    qty = repPizza.GetSumOfPackIdLineItemBoxQtyFromVShipmentPakComn(temp.consol_invoice.TrimEnd());
                                    PakShipmentWeightFisInfo item1 = new PakShipmentWeightFisInfo();
                                    item1.weight = y * qty;
                                    item1.cdt = DateTime.Now;
                                    item1.type = "S";
                                    item1.shipment = temp.consol_invoice.TrimEnd();
                                    //insert into PAK_ShipmentWeight_FIS values(@shipment,'S',convert(decimal(10,3),@qty)*@weight,getdate())
                                    repPizza.InsertPakShipmentWeightFis(item1);
                                }
                            }
                        }
                    }                    
                    break;
                default:
                    FisException ex1;
                    List<string> erpara1 = new List<string>();
                    erpara1.Add((string)CurrentSession.GetValue("Data"));
                    ex1 = new FisException("CHK816", erpara1);
                    //ex1.stopWF = false;
                    throw ex1;
                //break;
            }

            return base.DoExecute(executionContext);
        }
示例#3
0
        public void SaveModelWeightItemAndHold(ModelWeightDef item, IList<string> lstPrdID, string holdStation, string defectCode)
        {
            try
            {

                IModelWeightRepository itemRepositoryModelWeight = RepositoryFactory.GetInstance().GetRepository<IModelWeightRepository>();
                //看取得的数据是否有, 防止update的是空记录,但[PAK_SkuMasterWeight_FIS]中加入了记录
                DataTable modelWeight = itemRepositoryModelWeight.GetModelWeightItem(item.Model);
                //if (modelWeight == null || modelWeight.Rows.Count == 0)
                //{
                //    //该Model尚无标准重量,请先去称重。
                //    List<string> erpara = new List<string>();
                //    erpara.Add(item.Model);
                //    FisException ex;
                //    ex = new FisException("PAK123", erpara);
                //    throw ex;
                //}
                if (modelWeight == null || modelWeight.Rows.Count == 0)
                {
                    item.UnitWeight = "0.00";
                }
                else
                {
                    item.UnitWeight = modelWeight.Rows[0][1].ToString();
                }

                IPizzaRepository itemRepositoryPizza = RepositoryFactory.GetInstance().GetRepository<IPizzaRepository>();

                ModelWeightInfo setValue = new ModelWeightInfo();
                setValue.unitWeight = Decimal.Parse(item.UnitWeight);
                setValue.sendStatus = "";
                setValue.remark = "";
                setValue.editor = item.Editor;

                setValue.udt = DateTime.Now;

                ModelWeightInfo condition = new ModelWeightInfo();
                condition.model = item.Model;

                PakSkuMasterWeightFisInfo pakSkuMasterWeight = new PakSkuMasterWeightFisInfo();
                pakSkuMasterWeight.model = item.Model;
                pakSkuMasterWeight.weight = setValue.unitWeight;                
                pakSkuMasterWeight.cdt = setValue.udt;

                UnitOfWork uow = new UnitOfWork();
                itemRepositoryModelWeight.UpdateModelWeightDefered(uow, setValue, condition);
                itemRepositoryPizza.DeletetPakSkuMasterWeightFisByModelDefered(uow, item.Model);
                itemRepositoryPizza.InsertPakSkuMasterWeightFisDefered(uow, pakSkuMasterWeight);
                HoldProductByProductList(lstPrdID, item, uow,holdStation);
             
             //void WriteHoldCodeDefered(IUnitOfWork uow, IList<string> productIDList, TestLog log, IList<string> defectList);
                TestLog testLog = new TestLog(0, "", "", "", "HOLD", TestLog.TestLogStatus.Fail, "", "HOLD", "", "", item.Editor, "HOLD", DateTime.Now);
                IProductRepository prodyctRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
                IList<string> defectLst = new List<string>();
                defectLst.Add(defectCode);
                prodyctRep.WriteHoldCodeDefered(uow, lstPrdID, testLog, defectLst);
                uow.Commit();

            }
            catch (FisException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw new SystemException(e.Message);
            }
        
        }
示例#4
0
        /// <summary>
        /// 保存修改的ModelWeight
        /// </summary>
        /// <param name="item">item</param>
        /// <returns></returns>
        public void SaveModelWeightItem(ModelWeightDef item)
        {
            
            try
            {

                IModelWeightRepository itemRepositoryModelWeight = RepositoryFactory.GetInstance().GetRepository<IModelWeightRepository>();
                ////看取得的数据是否有, 防止update的是空记录,但[PAK_SkuMasterWeight_FIS]中加入了记录
                //DataTable modelWeight = itemRepositoryModelWeight.GetModelWeightItem(item.Model);
                ////if (modelWeight == null || modelWeight.Rows.Count == 0)
                ////{
                ////    //该Model尚无标准重量,请先去称重。
                ////    List<string> erpara = new List<string>();
                ////    erpara.Add(item.Model);
                ////    FisException ex;
                ////    ex = new FisException("PAK123", erpara);
                ////    throw ex;
                ////}
                //if (modelWeight == null || modelWeight.Rows.Count == 0 || item.UnitWeight == "0.00")
                //{
                //    item.UnitWeight = "0.00";
                //}
                //else if (item.UnitWeight != "0.00")
                //{ 
                    
                //}
                //else
                //{
                //    item.UnitWeight = modelWeight.Rows[0][1].ToString();
                //}
                if (string.IsNullOrEmpty(item.Model))
                {
                    //该Model尚无标准重量,请先去称重。
                    List<string> erpara = new List<string>();
                    erpara.Add("Model");
                    FisException ex;
                    ex = new FisException("CQCHK0006", erpara);
                    throw ex;
                }

                decimal  inputUnitweight =decimal.Parse(item.UnitWeight);
                if (inputUnitweight == 0)
                {
                    //该Model尚无标准重量,请先去称重。
                        List<string> erpara = new List<string>();
                        erpara.Add(item.Model);
                        FisException ex;
                        ex = new FisException("CQCHK0048", erpara);
                        throw ex;
                }

                IModelWeightRepository currentModelWeightRepository = RepositoryFactory.GetInstance().GetRepository<IModelWeightRepository>();
                IMES.FisObject.PAK.StandardWeight.ModelWeight currentModelWeight = currentModelWeightRepository.Find(item.Model);
                bool isAdd = false;
                if (currentModelWeight == null)
                {
                    currentModelWeight = new IMES.FisObject.PAK.StandardWeight.ModelWeight();
                    //每次手動修改標準重需將ModelWeight.Remark='New',在10分鐘後送給SAP Unitweight
                    currentModelWeight.Remark = "New";
                    isAdd = true;
                }
                else
                {
                    if (!string.IsNullOrEmpty(currentModelWeight.SendStatus))
                    {
                        currentModelWeight.Remark = currentModelWeight.UnitWeight.ToString();
                    }
                }

                

                currentModelWeight.Model = item.Model;
                //currentModelWeight.UnitWeight = Decimal.Parse(item.UnitWeight);
                currentModelWeight.UnitWeight = inputUnitweight;
                currentModelWeight.SendStatus = "";
                currentModelWeight.Editor = item.Editor;
                currentModelWeight.Udt = DateTime.Now;

                IPizzaRepository itemRepositoryPizza = RepositoryFactory.GetInstance().GetRepository<IPizzaRepository>();

                //ModelWeightInfo setValue =new ModelWeightInfo();
                //setValue.unitWeight = Decimal.Parse(item.UnitWeight);
                //setValue.editor = item.Editor;
                //setValue.udt = DateTime.Now;

                //ModelWeightInfo condition =new ModelWeightInfo();
                //condition.model = item.Model;

                PakSkuMasterWeightFisInfo pakSkuMasterWeight = new PakSkuMasterWeightFisInfo();
                pakSkuMasterWeight.model = item.Model;
                //pakSkuMasterWeight.weight = setValue.unitWeight;               
                //pakSkuMasterWeight.cdt = setValue.udt;
                pakSkuMasterWeight.weight = inputUnitweight;
                pakSkuMasterWeight.cdt = currentModelWeight.Udt; 

                UnitOfWork uow = new UnitOfWork();
                //itemRepositoryModelWeight.UpdateModelWeightDefered(uow,setValue,condition);
                itemRepositoryPizza.DeletetPakSkuMasterWeightFisByModelDefered(uow, item.Model);
                itemRepositoryPizza.InsertPakSkuMasterWeightFisDefered(uow, pakSkuMasterWeight);
                if (isAdd)
                {
                    currentModelWeightRepository.Add(currentModelWeight, uow);
                }
                else
                {
                    currentModelWeightRepository.Update(currentModelWeight, uow);
                }
                
                
                uow.Commit();

            }
            catch (FisException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw new SystemException(e.Message);
            }
        }
示例#5
0
        /// <summary>
        /// WritePQCLog
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            // 更新HP EDI 数据:
            // DELETE HP_EDI.dbo.PAK_SkuMasterWeight_FIS WHERE Model = RTRIM(@model)
            // INSERT INTO HP_EDI.dbo.PAK_SkuMasterWeight_FIS 
            // VALUES(RTRIM(@model),CONVERT(decimal(10,2),@weight),GETDATE())
            IPizzaRepository ipizzaRepository = RepositoryFactory.GetInstance().GetRepository<IPizzaRepository, Pizza>();
            Product currentProduct = (Product)CurrentSession.GetValue(Session.SessionKeys.Product);

            //ITC-1360-1299: 如果Product Model 的UnitWeight (IMES_GetData..ModelWeight)属性,没有新Insert或Update时,不需要更新(Insert)HP EDI 数据(PAK_SkuMasterWeight_FIS)
            Boolean Updateflg=(Boolean)CurrentSession.GetValue(Session.SessionKeys.IsCheckPass);
           
            if (Updateflg)
            {
                ipizzaRepository.DeletetPakSkuMasterWeightFisByModelDefered(CurrentSession.UnitOfWork, currentProduct.Model);

                PakSkuMasterWeightFisInfo pakSMWFInfo = new PakSkuMasterWeightFisInfo();
                pakSMWFInfo.model = currentProduct.Model;
                pakSMWFInfo.weight = (decimal)CurrentSession.GetValue("SetWeight");
                pakSMWFInfo.cdt = DateTime.Now;
                ipizzaRepository.InsertPakSkuMasterWeightFisDefered(CurrentSession.UnitOfWork, pakSMWFInfo);
            }
           
            return base.DoExecute(executionContext);
         }
示例#6
0
        /// <summary>
        /// 保存修改的ModelWeight
        /// </summary>
        /// <param name="item">item</param>
        /// <returns></returns>
        public void SaveModelWeightItem(ModelWeightDef item)
        {

            try
            {

                IModelWeightRepository itemRepositoryModelWeight = RepositoryFactory.GetInstance().GetRepository<IModelWeightRepository>();
                //看取得的数据是否有, 防止update的是空记录,但[PAK_SkuMasterWeight_FIS]中加入了记录
                DataTable modelWeight = itemRepositoryModelWeight.GetModelWeightItem(item.Model);
                if (modelWeight == null || modelWeight.Rows.Count == 0)
                {
                    //该Model尚无标准重量,请先去称重。
                    List<string> erpara = new List<string>();
                    erpara.Add(item.Model);
                    FisException ex;
                    ex = new FisException("PAK123", erpara);
                    throw ex;
                }

                IPizzaRepository itemRepositoryPizza = RepositoryFactory.GetInstance().GetRepository<IPizzaRepository>();

                ModelWeightInfo setValue = new ModelWeightInfo();
                setValue.unitWeight = Decimal.Parse(item.UnitWeight);
                setValue.editor = item.Editor;
                setValue.udt = DateTime.Now;

                ModelWeightInfo condition = new ModelWeightInfo();
                condition.model = item.Model;

                PakSkuMasterWeightFisInfo pakSkuMasterWeight = new PakSkuMasterWeightFisInfo();
                pakSkuMasterWeight.model = item.Model;
                pakSkuMasterWeight.weight = setValue.unitWeight;
                pakSkuMasterWeight.cdt = setValue.udt;

                UnitOfWork uow = new UnitOfWork();
                itemRepositoryModelWeight.UpdateModelWeightDefered(uow, setValue, condition);
                itemRepositoryPizza.DeletetPakSkuMasterWeightFisByModelDefered(uow, item.Model);
                itemRepositoryPizza.InsertPakSkuMasterWeightFisDefered(uow, pakSkuMasterWeight);
                uow.Commit();

            }
            catch (FisException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw new SystemException(e.Message);
            }
        }