Valeo_Line_MES_backend/MDM/Services/Recipe/PfRefProductRecipeService.cs
2026-01-10 13:47:54 +08:00

112 lines
3.5 KiB
C#

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
{
/// <summary>
/// 产品配方关联表Service业务层处理
/// </summary>
[AppService(ServiceType = typeof(IPfRefProductRecipeService), ServiceLifetime = LifeTime.Transient)]
public class PfRefProductRecipeService : BaseService<PfRefProductRecipe>, IPfRefProductRecipeService
{
/// <summary>
/// 查询产品配方关联表列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
public PagedInfo<PfRefProductRecipeDto> GetList(PfRefProductRecipeQueryDto parm)
{
var predicate = QueryExp(parm);
var response = Queryable()
.Where(predicate.ToExpression())
.ToPage<PfRefProductRecipe, PfRefProductRecipeDto>(parm);
return response;
}
/// <summary>
/// 获取详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public PfRefProductRecipe GetInfo(int Id)
{
var response = Queryable()
.Where(x => x.Id == Id)
.First();
return response;
}
/// <summary>
/// 添加产品配方关联表
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public PfRefProductRecipe AddPfRefProductRecipe(PfRefProductRecipe model)
{
return Insertable(model).ExecuteReturnEntity();
}
/// <summary>
/// 修改产品配方关联表
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public int UpdatePfRefProductRecipe(PfRefProductRecipe model)
{
return Update(model, true);
}
/// <summary>
/// 查询导出表达式
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
private static Expressionable<PfRefProductRecipe> QueryExp(PfRefProductRecipeQueryDto parm)
{
var predicate = Expressionable.Create<PfRefProductRecipe>();
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<RecipeCodePullDownDto> GetRecipeCodePullDown()
{
return Queryable()
.Select(x => new RecipeCodePullDownDto
{
label = x.RecipeCode,
value = x.RecipeCode
}).ToList();
}
}
}