zhuangpei-mesbackend/MDM/Services/Plant/PlantProductlinebodyService.cs
gcw_MV9p2JJN a293df3710 1
2025-11-19 11:49:05 +08:00

91 lines
3.1 KiB
C#

using System;
using SqlSugar;
using Infrastructure.Attribute;
using MDM.Services.IPlantService;
using MDM.Service;
using MDM.Model;
using MDM.Model.Plant;
using MDM.Model.Plant.Dto;
using MDM.Repository;
namespace MDM.Services.Plant
{
/// <summary>
/// 产线/线体/工作中心Service业务层处理
/// </summary>
[AppService(ServiceType = typeof(IPlantProductlinebodyService), ServiceLifetime = LifeTime.Transient)]
public class PlantProductlinebodyService : BaseService<PlantProductlinebody>, IPlantProductlinebodyService
{
/// <summary>
/// 查询产线/线体/工作中心列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
public PagedInfo<PlantProductlinebodyDto> GetList(PlantProductlinebodyQueryDto parm)
{
var predicate = Expressionable.Create<PlantProductlinebody>()
.AndIF(!string.IsNullOrEmpty(parm.FkFactorySiteCode),it=>it.FkFactorySiteCode.Contains(parm.FkFactorySiteCode))
.AndIF(!string.IsNullOrEmpty(parm.FkWorkshopCode),it=>it.FkWorkshopCode.Contains(parm.FkWorkshopCode))
.AndIF(!string.IsNullOrEmpty(parm.LineCode),it=>it.LineCode.Contains(parm.LineCode))
.AndIF(!string.IsNullOrEmpty(parm.LineName),it=>it.LineName.Contains(parm.LineName))
;
var response = Queryable()
.Where(predicate.ToExpression())
.ToPage<PlantProductlinebody, PlantProductlinebodyDto>(parm);
return response;
}
/// <summary>
/// 获取详情
/// </summary>
/// <param name="LineId"></param>
/// <returns></returns>
public PlantProductlinebody GetInfo(int LineId)
{
var response = Queryable()
.Where(x => x.LineId == LineId)
.First();
return response;
}
/// <summary>
/// 添加产线/线体/工作中心
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public PlantProductlinebody AddPlantProductlinebody(PlantProductlinebody model)
{
return Context.Insertable(model).ExecuteReturnEntity();
}
/// <summary>
/// 修改产线/线体/工作中心
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public int UpdatePlantProductlinebody(PlantProductlinebody model)
{
//var response = Update(w => w.LineId == model.LineId, it => new PlantProductlinebody()
//{
// FkFactorySiteCode = model.FkFactorySiteCode,
// FkWorkshopCode = model.FkWorkshopCode,
// LineName = model.LineName,
// LineType = model.LineType,
// Description = model.Description,
// CreatedBy = model.CreatedBy,
// CreatedTime = model.CreatedTime,
// UpdatedBy = model.UpdatedBy,
// UpdatedTime = model.UpdatedTime,
//});
//return response;
return Update(model, true);
}
}
}