Example #1
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);
        }
Example #2
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);
            }
        }
        /// <summary>
        /// Insert And Update ModelWeight
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            //4.	如果Product Model 的UnitWeight (IMES_GetData..ModelWeight) 属性不存在则记录该属性;如果该属性值的Udt 不是当天,则更新该记录的UnitWeightValue,Editor 和Udt;
            Product currentProduct = (Product)CurrentSession.GetValue(Session.SessionKeys.Product);
            IModelWeightRepository currentModelWeightRepository = RepositoryFactory.GetInstance().GetRepository<IModelWeightRepository, ModelWeight>();
            ModelWeight currentModelWeight = currentModelWeightRepository.Find(currentProduct.Model);

            //ITC-1360-1299: 如果Product Model 的UnitWeight (IMES_GetData..ModelWeight)属性,没有新Insert或Update时,不需要更新(Insert)HP EDI 数据(PAK_SkuMasterWeight_FIS)
            CurrentSession.AddValue(Session.SessionKeys.IsCheckPass, false);

            if (currentModelWeight == null)
            {
                ModelWeight newModelWeight = new ModelWeight();
                newModelWeight.Model = currentProduct.Model;
                newModelWeight.UnitWeight = (decimal)CurrentSession.GetValue(Session.SessionKeys.ActuralWeight);
                newModelWeight.CartonWeight = (decimal)0.00;
                newModelWeight.SendStatus = "";
                newModelWeight.Remark = "New";
                newModelWeight.Editor = this.Editor;
                newModelWeight.Udt = DateTime.Now;

                currentModelWeightRepository.Add(newModelWeight, CurrentSession.UnitOfWork);

                CurrentSession.AddValue(Session.SessionKeys.IsCheckPass, true);
                CurrentSession.AddValue("SetWeight", newModelWeight.UnitWeight);
            }
            else if (currentModelWeight.UnitWeight.Equals(0))
            {
                currentModelWeight.Model = currentProduct.Model;
                currentModelWeight.UnitWeight = (decimal)CurrentSession.GetValue(Session.SessionKeys.ActuralWeight);
                currentModelWeight.CartonWeight = (decimal)0.00;
                currentModelWeight.SendStatus = "";
                currentModelWeight.Remark = "0";
                currentModelWeight.Editor = this.Editor;
                currentModelWeight.Udt = DateTime.Now;

                currentModelWeightRepository.Update(currentModelWeight, CurrentSession.UnitOfWork);

                CurrentSession.AddValue(Session.SessionKeys.IsCheckPass, true);
                CurrentSession.AddValue("SetWeight", currentModelWeight.UnitWeight);

            }
            //ITC-1360-1302
            //if (currentModelWeight.Udt.ToShortDateString().ToString() != DateTime.Now.ToShortDateString().ToString())
            else if (currentModelWeight.Udt.ToShortDateString().ToString() != DateTime.Now.ToShortDateString().ToString())
            {
                currentModelWeight.Model = currentProduct.Model;
                currentModelWeight.Remark = currentModelWeight.UnitWeight.ToString();
                currentModelWeight.UnitWeight = (decimal)CurrentSession.GetValue(Session.SessionKeys.ActuralWeight);
                currentModelWeight.SendStatus = "";
              
                currentModelWeight.Editor = this.Editor;
                currentModelWeight.Udt = DateTime.Now;

                currentModelWeightRepository.Update(currentModelWeight, CurrentSession.UnitOfWork);

                CurrentSession.AddValue(Session.SessionKeys.IsCheckPass, true);
                CurrentSession.AddValue("SetWeight", currentModelWeight.UnitWeight);
            }
            //当 Product 为同机型机器当天的第50台Pass Unit Weight 站的机器,需要取这50台机器的Product.UnitWeight 的平均值,更新ModelWeight 对应记录的UnitWeight,Editor 和Udt
            else
            {
                IProductRepository productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
                if (49 == productRepository.GetCountOfCurrentDayByModelAndStation(currentProduct.Model, "85"))
                {
                    decimal avrWeight = productRepository.GetAverageModelWeightOfCurrentDay(currentProduct.Model, "85");
                    currentModelWeight.Remark = currentModelWeight.UnitWeight.ToString();
                    decimal thisWeight = (decimal)CurrentSession.GetValue(Session.SessionKeys.ActuralWeight);
                    currentModelWeight.Model = currentProduct.Model;
                    currentModelWeight.UnitWeight = (avrWeight * 49 + thisWeight) / 50;
                    currentModelWeight.SendStatus = "";
                  
                    currentModelWeight.Editor = this.Editor;
                    currentModelWeight.Udt = DateTime.Now;

                    currentModelWeightRepository.Update(currentModelWeight, CurrentSession.UnitOfWork);

                    CurrentSession.AddValue(Session.SessionKeys.IsCheckPass, true);
                    CurrentSession.AddValue("SetWeight", currentModelWeight.UnitWeight);
                }
            }


	        return base.DoExecute(executionContext);
        }
Example #4
0
        /// <summary>
        /// 执行逻辑
        /// 标准误差如果Model没有,再按Custormer找
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            IPartRepository ipartRepository = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
            string defaultTolerance = (string)CurrentSession.GetValue(Session.SessionKeys.Tolerance);
            Product currentProduct = (Product)CurrentSession.GetValue(Session.SessionKeys.Product);
            IModelWeightRepository currentModelWeightRepository = RepositoryFactory.GetInstance().GetRepository<IModelWeightRepository, ModelWeight>();
            ModelWeight currentModelWeight = currentModelWeightRepository.Find(currentProduct.Model);
            IFamilyRepository famliyRep = RepositoryFactory.GetInstance().GetRepository<IFamilyRepository, Family>();

            IModelToleranceRepository currentModelToleranceRepository = RepositoryFactory.GetInstance().GetRepository<IModelToleranceRepository, ModelTolerance>();
            ModelTolerance currentModelTolerance = currentModelToleranceRepository.Find(currentProduct.Model);
            if (currentModelTolerance == null)
            {
                currentModelTolerance = currentModelToleranceRepository.Find(Customer);
            }

            if (WeightType == WeightTypeEnum.Unit)
            {
                //if (currentModelTolerance == null || currentModelTolerance.UnitTolerance == null)
                //{
                //    List<string> errpara = new List<string>();

                //    errpara.Add(currentProduct.Model);

                //    throw new FisException("CHK004", errpara);
                //}

                //UC Revision:6912:修改误差可以配置( UnitWeight称重 新方案: 缺省是2)
                if (currentModelTolerance == null || currentModelTolerance.UnitTolerance == null)
                {
                    currentModelTolerance = new ModelTolerance();
                  //  currentModelTolerance.UnitTolerance = "2";

                    //ITC-1360-1204: 改由sysSeting配置
                    IList<string> ToleranceLst = new List<string>();
                    ToleranceLst = ipartRepository.GetValueFromSysSettingByName("UnitWeightTolerance");
                    //For BSAM
              //       BSamUnitWeightTolerance
                    if( (string)CurrentSession.GetValue(ExtendSession.SessionKeys.IsBSamModel)=="Y")
                    { ToleranceLst = ipartRepository.GetValueFromSysSettingByName("BSamUnitWeightTolerance"); }
                    //For BSAM

                   //For Tablet

                    FamilyInfoDef fcond = new FamilyInfoDef();
                    fcond.family = currentProduct.Family;
                    fcond.name = "Category";
                    IList<FamilyInfoDef> famValList = famliyRep.GetExistFamilyInfo(fcond);
                    if (famValList.Count > 0)
                    {
                        string sysName = famValList[0].value.Trim() + "UnitWeightTolerance";
                        ToleranceLst = ipartRepository.GetValueFromSysSettingByName(sysName);
                        if (ToleranceLst.Count == 0)
                        {
                            throw new FisException("PAK095", new string[] { sysName });
                        }
                    }

                   //For Tablet
                    
                    if (ToleranceLst != null && ToleranceLst.Count > 0)
                    {
                        // ITC-1360-1465 : 2%
                        if (!ToleranceLst[0].ToString().Contains("%"))
                        {
                            string sysSettingUnitTolerance = ToleranceLst[0].ToString() + "%";
                            currentModelTolerance.UnitTolerance = sysSettingUnitTolerance;
                        }
                        else
                        {
                            currentModelTolerance.UnitTolerance = ToleranceLst[0].ToString();
                        }
                    }
                    else
                    {
                        //List<string> errpara = new List<string>();
                        //errpara.Add("UnitWeightTolerance");
                        //throw new FisException("PAK095", errpara);

                        // ITC-1360-1465 : 2%
                        /*
                         * Answer to: ITC-1414-0105
                         * Description: Set default tolerance properly.
                         */
                        if (defaultTolerance != null && defaultTolerance != "")
                        {
                            currentModelTolerance.UnitTolerance = defaultTolerance;
                        }
                        else
                        {
                            currentModelTolerance.UnitTolerance = "2%";
                        }

                    }
                }



                //// UnitWeight称重 新方案:	Standard Weight – IMES_GetData..ModelWeight.UnitWeight(需转换为decimal(10,2)) – 如果没有取到,则标准重量为NULL (这台机器后面就不需要进行标准重量的比较了)
                if (currentModelWeight == null)
                {
                    //currentModelWeight = new ModelWeight();
                    //currentModelWeight.Model = currentProduct.Model;
                    //currentModelWeight.UnitWeight = (decimal)CurrentSession.GetValue(Session.SessionKeys.ActuralWeight);
                    //currentModelWeight.Editor = Editor;
                    //currentModelWeight.Udt = DateTime.Now;

                    //currentModelWeightRepository.Add(currentModelWeight, CurrentSession.UnitOfWork);


                    CurrentSession.AddValue(Session.SessionKeys.StandardWeight, null);


                }
                else if (currentModelWeight.UnitWeight.Equals(0))
                {
                    //currentModelWeight.UnitWeight = (decimal)CurrentSession.GetValue(Session.SessionKeys.ActuralWeight);
                    //currentModelWeight.Editor = Editor;
                    //currentModelWeight.Udt = DateTime.Now;

                    //currentModelWeightRepository.Update(currentModelWeight, CurrentSession.UnitOfWork);

                    //5.	如果称取的重量为0,则报告错误:“Unit weight should not be 0!”
                    List<string> errpara = new List<string>();
                    errpara.Add(currentProduct.Model);
                    throw new FisException("PAK072", errpara);
                   
                }
                else
                {
                    CurrentSession.AddValue(Session.SessionKeys.StandardWeight, currentModelWeight.UnitWeight);
                }

                CurrentSession.AddValue(Session.SessionKeys.Tolerance, currentModelTolerance.UnitTolerance);

            }
            else
            {
                if (currentModelTolerance == null || currentModelTolerance.CartonTolerance == null)
                {
                    List<string> errpara = new List<string>();

                    errpara.Add(currentProduct.Model);

                    throw new FisException("CHK005", errpara);
                }
                if (currentModelWeight == null )
                {
                    currentModelWeight = new ModelWeight();
                    currentModelWeight.Model = currentProduct.Model;
                    currentModelWeight.CartonWeight = (decimal)CurrentSession.GetValue(Session.SessionKeys.ActuralWeight);
                    currentModelWeight.SendStatus = "";
                    currentModelWeight.Remark = "New";
                    currentModelWeight.Editor = Editor;
                    currentModelWeight.Udt = DateTime.Now;

                    currentModelWeightRepository.Add(currentModelWeight, CurrentSession.UnitOfWork);
                }
                else if (currentModelWeight.CartonWeight.Equals(0))
                {
                    currentModelWeight.CartonWeight = (decimal)CurrentSession.GetValue(Session.SessionKeys.ActuralWeight);
                    currentModelWeight.SendStatus = "";
                    currentModelWeight.Remark = "0";
                    currentModelWeight.Editor = Editor;
                    currentModelWeight.Udt = DateTime.Now;

                    currentModelWeightRepository.Update(currentModelWeight, CurrentSession.UnitOfWork);
                }

                CurrentSession.AddValue(Session.SessionKeys.Tolerance, currentModelTolerance.CartonTolerance);
                CurrentSession.AddValue(Session.SessionKeys.StandardWeight, currentModelWeight.CartonWeight);
            }

            return base.DoExecute(executionContext);
        }
Example #5
0
        /// <summary>
        /// 更新Model的标准重量
        /// </summary>
        public void SetModelWeight(string model, decimal weight, string editor)
        {
            logger.Debug("(RCTOWeight)SetModelWeight start, Model:" + model);

            try
            {
                IPartRepository partRep = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
                bool need1000 = partRep.GetConstValueTypeList("RCTOModelWeightUnit").Where(x => x.value == model.Trim()).Any();
                if (need1000)
                {
                    weight = Math.Round(weight * 1000, 2);
                }
                weight = Math.Round(weight, 2);
                IMES.FisObject.PAK.StandardWeight.ModelWeight mw=mvRepository.Find(model);
                //if (mvRepository.Find(model) != null)
                if (mw!=null)
                {
                    ModelWeightInfo cond = new ModelWeightInfo();
                    ModelWeightInfo item = new ModelWeightInfo();

                    cond.model = model;

                    item.model = model;
                    item.unitWeight = weight;
                    item.editor = editor;
                    item.remark = mw.UnitWeight.ToString();
                    item.sendStatus = "";

                    mvRepository.UpdateModelWeight(item, cond);
                }
                else
                {
                    IMES.FisObject.PAK.StandardWeight.ModelWeight item = new IMES.FisObject.PAK.StandardWeight.ModelWeight();
                    item.Model = model;
                    item.SendStatus = "";
                    item.Remark = "New";
                    item.UnitWeight = weight;
                    item.CartonWeight = 0;
                    item.Editor = editor;
                    UnitOfWork uow = new UnitOfWork();
                    mvRepository.Add(item, uow);
                    uow.Commit();
                }
            }
            catch (FisException e)
            {
                logger.Error(e.mErrmsg, e);
                throw new Exception(e.mErrmsg);
            }
            catch (Exception e)
            {
                logger.Error(e.Message);
                throw new SystemException(e.Message);
            }
            finally
            {
                logger.Debug("(RCTOWeight)SetModelWeight end, Model:" + model);
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {

            Carton carton = (Carton)CurrentSession.GetValue(Session.SessionKeys.Carton);
            if (carton == null)
            {
                throw new FisException("No Session Key [" + Session.SessionKeys.Carton + "] value");
            }

            IList<IProduct> prodList = (IList<IProduct>)CurrentSession.GetValue(Session.SessionKeys.ProdList);
            IList<string> prodIdList = (IList<string>)CurrentSession.GetValue(Session.SessionKeys.NewScanedProductIDList);
            decimal actualCartonWeight = (decimal)CurrentSession.GetValue(ExtendSession.SessionKeys.ActualCartonWeight);
            decimal actualUnitWeight = (decimal)CurrentSession.GetValue(Session.SessionKeys.ActuralWeight);
            ICartonRepository cartonRep = RepositoryFactory.GetInstance().GetRepository<ICartonRepository, Carton>();
            IProductRepository prodRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();

         
            //4.	如果Product Model 的UnitWeight (IMES_GetData..ModelWeight) 属性不存在则记录该属性;如果该属性值的Udt 不是当天,则更新该记录的UnitWeightValue,Editor 和Udt;
            IProduct currentProduct = prodList[0];
            IModelWeightRepository currentModelWeightRepository = RepositoryFactory.GetInstance().GetRepository<IModelWeightRepository, ModelWeight>();
            ModelWeight currentModelWeight = currentModelWeightRepository.Find(currentProduct.Model);

            //ITC-1360-1299: 如果Product Model 的UnitWeight (IMES_GetData..ModelWeight)属性,没有新Insert或Update时,不需要更新(Insert)HP EDI 数据(PAK_SkuMasterWeight_FIS)
            CurrentSession.AddValue(Session.SessionKeys.IsCheckPass, false);
            

            if (currentModelWeight == null )
            {
                ModelWeight newModelWeight = new ModelWeight();
                newModelWeight.Model = currentProduct.Model;
                newModelWeight.UnitWeight = actualUnitWeight;
                newModelWeight.CartonWeight = actualCartonWeight;
                newModelWeight.SendStatus = "";
                newModelWeight.Remark = "New";
                newModelWeight.Editor = this.Editor;
                newModelWeight.Udt = DateTime.Now;

                currentModelWeightRepository.Add(newModelWeight, CurrentSession.UnitOfWork);

                CurrentSession.AddValue(Session.SessionKeys.IsCheckPass, true);
                CurrentSession.AddValue("SetWeight", newModelWeight.UnitWeight);
            }
            else if (currentModelWeight.UnitWeight.Equals(0))
            {
                currentModelWeight.Model = currentProduct.Model;
                currentModelWeight.UnitWeight = actualUnitWeight;
                currentModelWeight.CartonWeight = actualCartonWeight;
                currentModelWeight.SendStatus = "";
                currentModelWeight.Remark = "0";
                currentModelWeight.Editor = this.Editor;
                currentModelWeight.Udt = DateTime.Now;

                currentModelWeightRepository.Update(currentModelWeight, CurrentSession.UnitOfWork);

                CurrentSession.AddValue(Session.SessionKeys.IsCheckPass, true);
                CurrentSession.AddValue("SetWeight", currentModelWeight.UnitWeight);

            }
            //ITC-1360-1302
            //if (currentModelWeight.Udt.ToShortDateString().ToString() != DateTime.Now.ToShortDateString().ToString())
            else if (currentModelWeight.Udt.ToShortDateString().ToString() != DateTime.Now.ToShortDateString().ToString() && carton.Status == CartonStatusEnum.Full)
            {
                currentModelWeight.Model = currentProduct.Model;
                currentModelWeight.Remark = currentModelWeight.UnitWeight.ToString();
                currentModelWeight.UnitWeight = actualUnitWeight;
                currentModelWeight.CartonWeight = actualCartonWeight;
                currentModelWeight.SendStatus = "";               
                currentModelWeight.Editor = this.Editor;
                currentModelWeight.Udt = DateTime.Now;

                currentModelWeightRepository.Update(currentModelWeight, CurrentSession.UnitOfWork);

                CurrentSession.AddValue(Session.SessionKeys.IsCheckPass, true);
                CurrentSession.AddValue("SetWeight", currentModelWeight.UnitWeight);
            }
            //当 Product 为同机型机器当天的第50台Pass Unit Weight 站的机器,需要取这50台机器的Product.UnitWeight 的平均值,更新ModelWeight 对应记录的UnitWeight,Editor 和Udt
            //else
            //{
            //    IProductRepository productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            //    if (49 == productRepository.GetCountOfCurrentDayByModelAndStation(currentProduct.Model, "85"))
            //    {
            //        decimal avrWeight = productRepository.GetAverageModelWeightOfCurrentDay(currentProduct.Model, "85");
            //        decimal thisWeight = (decimal)CurrentSession.GetValue(Session.SessionKeys.ActuralWeight);
            //        currentModelWeight.Model = currentProduct.Model;
            //        currentModelWeight.UnitWeight = (avrWeight * 49 + thisWeight) / 50;
            //        currentModelWeight.CartonWeight = actualCartonWeight;
            //        currentModelWeight.Editor = this.Editor;
            //        currentModelWeight.Udt = DateTime.Now;

            //        currentModelWeightRepository.Update(currentModelWeight, CurrentSession.UnitOfWork);

            //        CurrentSession.AddValue(Session.SessionKeys.IsCheckPass, true);
            //        CurrentSession.AddValue("SetWeight", currentModelWeight.UnitWeight);
            //    }
            //}


            return base.DoExecute(executionContext);

        }