zhuangpei-mesbackend/DOAN.Service/MES/dev/DevicePartsStorageLocationsService.cs
qianhao.xu a6516c19be 1
2024-12-30 15:42:57 +08:00

89 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(IDevicePartsStorageLocationsService), ServiceLifetime = LifeTime.Transient)]
public class DevicePartsStorageLocationsService : BaseService<DevicePartsStorageLocations>, IDevicePartsStorageLocationsService
{
/// <summary>
/// 查询备品备件库位列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
public PagedInfo<DevicePartsStorageLocationsDto> GetList(DevicePartsStorageLocationsQueryDto parm)
{
var predicate = Expressionable.Create<DevicePartsStorageLocations>();
var response = Queryable()
.Where(predicate.ToExpression())
.ToPage<DevicePartsStorageLocations, DevicePartsStorageLocationsDto>(parm);
return response;
}
public string[] QueryDevicePartsStorageLocationsLocationCode(string query)
{
return Queryable()
.WhereIF(!string.IsNullOrEmpty(query),x => x.LocationCode.Contains(query))
.Select(x => x.LocationCode)
.ToArray();
}
/// <summary>
/// 获取详情
/// </summary>
/// <param name="LocationId"></param>
/// <returns></returns>
public DevicePartsStorageLocations GetInfo(int LocationId)
{
var response = Queryable()
.Where(x => x.LocationId == LocationId)
.First();
return response;
}
/// <summary>
/// 添加备品备件库位
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public DevicePartsStorageLocations AddDevicePartsStorageLocations(DevicePartsStorageLocations model)
{
return Context.Insertable(model).ExecuteReturnEntity();
}
/// <summary>
/// 修改备品备件库位
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public int UpdateDevicePartsStorageLocations(DevicePartsStorageLocations model)
{
//var response = Update(w => w.LocationId == model.LocationId, it => new DevicePartsStorageLocations()
//{
// LocationCode = model.LocationCode,
// Description = model.Description,
// CreatedAt = model.CreatedAt,
// UpdatedAt = model.UpdatedAt,
//});
//return response;
return Update(model, true);
}
}
}