zhuangpei-mesbackend/DOAN.Service/MES/dev/DevicePartsTransactionsService.cs
2024-12-30 16:31:27 +08:00

85 lines
2.9 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 DOAN.Service.MES.dev.IService;
using System.Linq;
namespace DOAN.Service.MES.dev
{
/// <summary>
/// 备品备件出入库Service业务层处理
/// </summary>
[AppService(ServiceType = typeof(IDevicePartsTransactionsService), ServiceLifetime = LifeTime.Transient)]
public class DevicePartsTransactionsService : BaseService<DevicePartsTransactions>, IDevicePartsTransactionsService
{
/// <summary>
/// 查询备品备件出入库列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
public PagedInfo<DevicePartsTransactionsDto> GetList(DevicePartsTransactionsQueryDto parm)
{
// var predicate = Expressionable.Create<DevicePartsTransactions>();
var response = Queryable()
.LeftJoin<DeviceSpareParts>((t,s)=>t.PartId==s.PartId)
.WhereIF(!string.IsNullOrEmpty(parm.PartName), (t,s)=>s.PartName.Contains(parm.PartName))
.WhereIF(!string.IsNullOrEmpty(parm.TransactionType), (t,s)=>t.TransactionType==parm.TransactionType)
.Select((t,s)=>new DevicePartsTransactionsDto(),true )
.ToPage_NO_Convert(parm);
return response;
}
/// <summary>
/// 获取详情
/// </summary>
/// <param name="TransactionId"></param>
/// <returns></returns>
public DevicePartsTransactions GetInfo(int TransactionId)
{
var response = Queryable()
.Where(x => x.TransactionId == TransactionId)
.First();
return response;
}
/// <summary>
/// 添加备品备件出入库
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public DevicePartsTransactions AddDevicePartsTransactions(DevicePartsTransactions model)
{
return Context.Insertable(model).ExecuteReturnEntity();
}
/// <summary>
/// 修改备品备件出入库
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public int UpdateDevicePartsTransactions(DevicePartsTransactions model)
{
//var response = Update(w => w.TransactionId == model.TransactionId, it => new DevicePartsTransactions()
//{
// TransactionType = model.TransactionType,
// Quantity = model.Quantity,
// TransactionDate = model.TransactionDate,
// Remarks = model.Remarks,
// CreatedBy = model.CreatedBy,
//});
//return response;
return Update(model, true);
}
}
}