using Infrastructure.Attribute; using Infrastructure.Extensions; using MDM.Service; using RIZO.Model; using RIZO.Model.MES.recipe; using RIZO.Model.MES.recipe.Dto; using RIZO.Repository; using RIZO.Service.MES.recipe.IService; namespace RIZO.Service.MES.recipe { /// /// 产品配方关联表Service业务层处理 /// [AppService(ServiceType = typeof(IPfRefProductRecipeService), ServiceLifetime = LifeTime.Transient)] public class PfRefProductRecipeService : BaseService, IPfRefProductRecipeService { /// /// 查询产品配方关联表列表 /// /// /// public PagedInfo GetList(PfRefProductRecipeQueryDto parm) { var predicate = QueryExp(parm); var response = Queryable() .Where(predicate.ToExpression()) .ToPage(parm); return response; } /// /// 获取详情 /// /// /// public PfRefProductRecipe GetInfo(int Id) { var response = Queryable() .Where(x => x.Id == Id) .First(); return response; } /// /// 添加产品配方关联表 /// /// /// public PfRefProductRecipe AddPfRefProductRecipe(PfRefProductRecipe model) { return Insertable(model).ExecuteReturnEntity(); } /// /// 修改产品配方关联表 /// /// /// public int UpdatePfRefProductRecipe(PfRefProductRecipe model) { return Update(model, true); } /// /// 查询导出表达式 /// /// /// private static Expressionable QueryExp(PfRefProductRecipeQueryDto parm) { var predicate = Expressionable.Create(); if (parm != null) { if (!string.IsNullOrEmpty(parm.RecipeCode)) { predicate = predicate.And(x => x.RecipeCode.Contains(parm.RecipeCode)); } if (!string.IsNullOrEmpty(parm.Productcode)) { predicate = predicate.And(x => x.Productcode.Contains(parm.Productcode)); } if (!string.IsNullOrEmpty(parm.ProductName)) { predicate = predicate.And(x => x.ProductName.Contains(parm.ProductName)); } if (!string.IsNullOrEmpty(parm.FkLineCode)) { predicate = predicate.And(x => x.FkLineCode.Contains(parm.FkLineCode)); } } return predicate; } public List GetRecipeCodePullDown() { return Queryable() .Select(x => new RecipeCodePullDownDto { label = x.RecipeCode, value = x.RecipeCode }).ToList(); } } }