zhuangpei-mesbackend/DOAN.Service/MES/dev/DevicePartsInventoryService.cs
qianhao.xu e641706300 1
2024-12-30 13:58:42 +08:00

83 lines
2.7 KiB
C#

using System;
using SqlSugar;
using Infrastructure.Attribute;
using Infrastructure.Extensions;
using DOAN.Model;
using DOAN.Model.Dto;
using DOAN.Repository;
using DOAN.Model.MES.dev.Dto;
using DOAN.Model.MES.dev;
using System.Linq;
using DOAN.Service.MES.dev.IService;
namespace DOAN.Service.MES.dev
{
/// <summary>
/// 库存信息表Service业务层处理
/// </summary>
[AppService(ServiceType = typeof(IDevicePartsInventoryService), ServiceLifetime = LifeTime.Transient)]
public class DevicePartsInventoryService : BaseService<DevicePartsInventory>, IDevicePartsInventoryService
{
/// <summary>
/// 查询库存信息表列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
public PagedInfo<DevicePartsInventoryDto2> GetList(DevicePartsInventoryQueryDto parm)
{
var predicate = Expressionable.Create<DevicePartsInventory>();
var response = Queryable()
.Where(predicate.ToExpression());
var result= Context.Queryable(response).LeftJoin<DeviceSpareParts>((r, s) => r.PartId == s.PartId)
.Select((r, s) => new DevicePartsInventoryDto2(), true)
.ToPage_NO_Convert(parm);
return result;
}
/// <summary>
/// 获取详情
/// </summary>
/// <param name="InventoryId"></param>
/// <returns></returns>
public DevicePartsInventory GetInfo(int InventoryId)
{
var response = Queryable()
.Where(x => x.InventoryId == InventoryId)
.First();
return response;
}
/// <summary>
/// 添加库存信息表
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public DevicePartsInventory AddDevicePartsInventory(DevicePartsInventory model)
{
return Context.Insertable(model).ExecuteReturnEntity();
}
/// <summary>
/// 修改库存信息表
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public int UpdateDevicePartsInventory(DevicePartsInventory model)
{
//var response = Update(w => w.InventoryId == model.InventoryId, it => new DevicePartsInventory()
//{
// Quantity = model.Quantity,
// Location = model.Location,
// LastInventoryCheck = model.LastInventoryCheck,
// CreatedAt = model.CreatedAt,
// UpdatedAt = model.UpdatedAt,
//});
//return response;
return Update(model, true);
}
}
}