2024-03-20 06:11:00 +00:00
|
|
|
|
using Admin.NET.Core.Service;
|
|
|
|
|
using Admin.NET.Application.Const;
|
|
|
|
|
using Admin.NET.Application.Entity;
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
namespace Admin.NET.Application;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 入库单服务
|
|
|
|
|
/// </summary>
|
|
|
|
|
[ApiDescriptionSettings(ApplicationConst.GroupName, Order = 100)]
|
|
|
|
|
public class WarehousingService : IDynamicApiController, ITransient
|
|
|
|
|
{
|
|
|
|
|
private readonly SqlSugarRepository<Warehousing> _rep;
|
|
|
|
|
public WarehousingService(SqlSugarRepository<Warehousing> rep)
|
|
|
|
|
{
|
|
|
|
|
_rep = rep;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 分页查询入库单
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost]
|
|
|
|
|
[ApiDescriptionSettings(Name = "Page")]
|
|
|
|
|
public async Task<SqlSugarPagedList<WarehousingOutput>> Page(WarehousingInput input)
|
|
|
|
|
{
|
2024-05-20 10:06:52 +00:00
|
|
|
|
var query = _rep.AsQueryable().Where(a => !a.IsDelete)
|
2024-03-20 06:11:00 +00:00
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.SearchKey), u =>
|
|
|
|
|
u.CodeNum.Contains(input.SearchKey.Trim())
|
|
|
|
|
|| u.BusinessType.Contains(input.SearchKey.Trim())
|
|
|
|
|
|| u.Supplier.Contains(input.SearchKey.Trim())
|
|
|
|
|
)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.CodeNum), u => u.CodeNum.Contains(input.CodeNum.Trim()))
|
|
|
|
|
.WhereIF(input.State>0, u => u.State == input.State)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.BusinessType), u => u.BusinessType.Contains(input.BusinessType.Trim()))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.Supplier), u => u.Supplier.Contains(input.Supplier.Trim()))
|
|
|
|
|
.WhereIF(input.ExaminerId>0, u => u.ExaminerId == input.ExaminerId)
|
|
|
|
|
.Select<WarehousingOutput>();
|
|
|
|
|
if(input.StartDateRange != null && input.StartDateRange.Count >0)
|
|
|
|
|
{
|
|
|
|
|
DateTime? start= input.StartDateRange[0];
|
|
|
|
|
query = query.WhereIF(start.HasValue, u => u.StartDate > start);
|
|
|
|
|
if (input.StartDateRange.Count >1 && input.StartDateRange[1].HasValue)
|
|
|
|
|
{
|
|
|
|
|
var end = input.StartDateRange[1].Value.AddDays(1);
|
|
|
|
|
query = query.Where(u => u.StartDate < end);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return await query.OrderBuilder(input).ToPagedListAsync(input.Page, input.PageSize);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 增加入库单
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost]
|
|
|
|
|
[ApiDescriptionSettings(Name = "Add")]
|
|
|
|
|
public async Task<long> Add(AddWarehousingInput input)
|
|
|
|
|
{
|
|
|
|
|
var entity = input.Adapt<Warehousing>();
|
|
|
|
|
await _rep.InsertAsync(entity);
|
|
|
|
|
return entity.Id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除入库单
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost]
|
|
|
|
|
[ApiDescriptionSettings(Name = "Delete")]
|
|
|
|
|
public async Task Delete(DeleteWarehousingInput input)
|
|
|
|
|
{
|
|
|
|
|
var entity = await _rep.GetFirstAsync(u => u.Id == input.Id) ?? throw Oops.Oh(ErrorCodeEnum.D1002);
|
|
|
|
|
await _rep.FakeDeleteAsync(entity); //假删除
|
|
|
|
|
//await _rep.DeleteAsync(entity); //真删除
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新入库单
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost]
|
|
|
|
|
[ApiDescriptionSettings(Name = "Update")]
|
|
|
|
|
public async Task Update(UpdateWarehousingInput input)
|
|
|
|
|
{
|
|
|
|
|
var entity = input.Adapt<Warehousing>();
|
|
|
|
|
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取入库单
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[ApiDescriptionSettings(Name = "Detail")]
|
|
|
|
|
public async Task<Warehousing> Detail([FromQuery] QueryByIdWarehousingInput input)
|
|
|
|
|
{
|
|
|
|
|
return await _rep.GetFirstAsync(u => u.Id == input.Id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取入库单列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[ApiDescriptionSettings(Name = "List")]
|
|
|
|
|
public async Task<List<WarehousingOutput>> List()
|
|
|
|
|
{
|
2024-05-24 10:22:01 +00:00
|
|
|
|
return await _rep.AsQueryable().Where(a => !a.IsDelete).Select<WarehousingOutput>().ToListAsync();
|
2024-03-20 06:11:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|