99 lines
3.2 KiB
C#
99 lines
3.2 KiB
C#
using System;
|
|
using SqlSugar;
|
|
using Infrastructure.Attribute;
|
|
using Infrastructure.Extensions;
|
|
using DOAN.Model;
|
|
using DOAN.Model.Dto;
|
|
using DOAN.Model.MES.dev.Dto;
|
|
using DOAN.Model.MES.dev;
|
|
using DOAN.Repository;
|
|
|
|
using System.Linq;
|
|
using DOAN.Service.MES.dev.IService;
|
|
using Mapster;
|
|
|
|
namespace DOAN.Service.MES.dev
|
|
{
|
|
/// <summary>
|
|
/// 备品备件基本信息表Service业务层处理
|
|
/// </summary>
|
|
[AppService(ServiceType = typeof(IDeviceSparePartsService), ServiceLifetime = LifeTime.Transient)]
|
|
public class DeviceSparePartsService : BaseService<DeviceSpareParts>, IDeviceSparePartsService
|
|
{
|
|
/// <summary>
|
|
/// 查询备品备件基本信息表列表
|
|
/// </summary>
|
|
/// <param name="parm"></param>
|
|
/// <returns></returns>
|
|
public PagedInfo<DeviceSparePartsDto> GetList(DeviceSparePartsQueryDto parm)
|
|
{
|
|
var predicate = Expressionable.Create<DeviceSpareParts>()
|
|
.AndIF(!string.IsNullOrEmpty(parm.PartName), it => it.PartName.Contains(parm.PartName))
|
|
.AndIF(!string.IsNullOrEmpty(parm.PartCode), it => it.PartCode.Contains(parm.PartCode))
|
|
;
|
|
|
|
var response = Queryable()
|
|
.Where(predicate.ToExpression())
|
|
.ToPage<DeviceSpareParts, DeviceSparePartsDto>(parm);
|
|
|
|
return response;
|
|
}
|
|
|
|
public List<DeviceSparePartsDto> GetListNOPage(string query)
|
|
{
|
|
var response = Queryable()
|
|
.WhereIF(!string.IsNullOrEmpty(query),x => x.PartName.Contains(query)||x.PartCode.Contains(query))
|
|
.ToList().Adapt<List<DeviceSpareParts>,List<DeviceSparePartsDto>>();
|
|
|
|
return response;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取详情
|
|
/// </summary>
|
|
/// <param name="PartId"></param>
|
|
/// <returns></returns>
|
|
public DeviceSpareParts GetInfo(int PartId)
|
|
{
|
|
var response = Queryable()
|
|
.Where(x => x.PartId == PartId)
|
|
.First();
|
|
|
|
return response;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加备品备件基本信息表
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public DeviceSpareParts AddDeviceSpareParts(DeviceSpareParts model)
|
|
{
|
|
return Context.Insertable(model).ExecuteReturnEntity();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改备品备件基本信息表
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public int UpdateDeviceSpareParts(DeviceSpareParts model)
|
|
{
|
|
//var response = Update(w => w.PartId == model.PartId, it => new DeviceSpareParts()
|
|
//{
|
|
// PartName = model.PartName,
|
|
// PartNumber = model.PartNumber,
|
|
// Description = model.Description,
|
|
// UnitOfMeasure = model.UnitOfMeasure,
|
|
// MinStockLevel = model.MinStockLevel,
|
|
// MaxStockLevel = model.MaxStockLevel,
|
|
// CreatedAt = model.CreatedAt,
|
|
// UpdatedAt = model.UpdatedAt,
|
|
//});
|
|
//return response;
|
|
return Update(model, true);
|
|
}
|
|
|
|
}
|
|
} |