コード例 #1
0
 /// 添加新纪录
 public void AddModelWeightTolerance(ModelWeightTolerance modelWeightTolerance)
 {
     ModelTolerance modelTolerance = new ModelTolerance();
     modelTolerance.Model = modelWeightTolerance.Model;
     modelTolerance.Udt = modelWeightTolerance.Udt;
     modelTolerance.UnitTolerance = modelWeightTolerance.UnitTolerance;
     modelTolerance.CartonTolerance = modelWeightTolerance.CartonTolerance;
     modelTolerance.Cdt = modelWeightTolerance.Cdt;
     modelTolerance.Editor = modelWeightTolerance.Editor;
     modelToleranceRepository.AddModelWeightTolerance(modelTolerance);
 }
コード例 #2
0
 /// 更新纪录
 public void UpdateModelWeightTolerance(ModelWeightTolerance modelWeightTolerance,string model)
 {
     ModelTolerance modelTolerance = new ModelTolerance();
     modelTolerance.Model = modelWeightTolerance.Model;
     modelTolerance.Udt = new DateTime();
     modelTolerance.UnitTolerance = modelWeightTolerance.UnitTolerance;
     modelTolerance.CartonTolerance = modelWeightTolerance.CartonTolerance;
     modelTolerance.Cdt = modelWeightTolerance.Cdt;
     modelTolerance.Editor = modelWeightTolerance.Editor;
     modelToleranceRepository.UpdateModelWeightTolerance(modelTolerance,model);
 }
コード例 #3
0
ファイル: GetModelWeight.cs プロジェクト: wra222/testgit
        /// <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);
        }