163 lines
7.6 KiB
C#
163 lines
7.6 KiB
C#
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 ReportDetailTableService : IDynamicApiController, ITransient
|
|
{
|
|
private readonly SqlSugarRepository<ReportDetailTable> _rep;
|
|
public ReportDetailTableService(SqlSugarRepository<ReportDetailTable> rep)
|
|
{
|
|
_rep = rep;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 分页查询汇报单详情
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
[ApiDescriptionSettings(Name = "Page")]
|
|
public async Task<SqlSugarPagedList<ReportDetailTableOutput>> Page(ReportDetailTableInput input)
|
|
{
|
|
var query = _rep.AsQueryable().Where(a => !a.IsDelete)
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.SearchKey), u =>
|
|
u.ProductName.Contains(input.SearchKey.Trim())
|
|
|| u.ProductCodeNum.Contains(input.SearchKey.Trim())
|
|
|| u.OddNumber.Contains(input.SearchKey.Trim())
|
|
|| u.State.Contains(input.SearchKey.Trim())
|
|
|| u.ProductType.Contains(input.SearchKey.Trim())
|
|
|| u.ProductionLine.Contains(input.SearchKey.Trim())
|
|
|| u.CodeNum.Contains(input.SearchKey.Trim())
|
|
|| u.SourceNumber.Contains(input.SearchKey.Trim())
|
|
|| u.Specifications.Contains(input.SearchKey.Trim())
|
|
|| u.Unit.Contains(input.SearchKey.Trim())
|
|
|| u.BaseUnit.Contains(input.SearchKey.Trim())
|
|
|| u.Batch.Contains(input.SearchKey.Trim())
|
|
|| u.Package.Contains(input.SearchKey.Trim())
|
|
|| u.TeamGroup.Contains(input.SearchKey.Trim())
|
|
|| u.Operator.Contains(input.SearchKey.Trim())
|
|
|| u.SourceOddNumber.Contains(input.SearchKey.Trim())
|
|
|| u.Remarks.Contains(input.SearchKey.Trim())
|
|
)
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.ProductName), u => u.ProductName.Contains(input.ProductName.Trim()))
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.ProductCodeNum), u => u.ProductCodeNum.Contains(input.ProductCodeNum.Trim()))
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.OddNumber), u => u.OddNumber.Contains(input.OddNumber.Trim()))
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.State), u => u.State.Contains(input.State.Trim()))
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.ProductType), u => u.ProductType.Contains(input.ProductType.Trim()))
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.ProductionLine), u => u.ProductionLine.Contains(input.ProductionLine.Trim()))
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.CodeNum), u => u.CodeNum.Contains(input.CodeNum.Trim()))
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.SourceNumber), u => u.SourceNumber.Contains(input.SourceNumber.Trim()))
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.Specifications), u => u.Specifications.Contains(input.Specifications.Trim()))
|
|
.WhereIF(input.ProductCount>0, u => u.ProductCount == input.ProductCount)
|
|
.WhereIF(input.PutWarehouse>0, u => u.PutWarehouse == input.PutWarehouse)
|
|
.WhereIF(input.BaseProductCount>0, u => u.BaseProductCount == input.BaseProductCount)
|
|
.WhereIF(input.BasePutWarehouse>0, u => u.BasePutWarehouse == input.BasePutWarehouse)
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.Unit), u => u.Unit.Contains(input.Unit.Trim()))
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.BaseUnit), u => u.BaseUnit.Contains(input.BaseUnit.Trim()))
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.Batch), u => u.Batch.Contains(input.Batch.Trim()))
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.Package), u => u.Package.Contains(input.Package.Trim()))
|
|
.WhereIF(input.PackageCount>0, u => u.PackageCount == input.PackageCount)
|
|
.WhereIF(input.GatherFalseCount>0, u => u.GatherFalseCount == input.GatherFalseCount)
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.TeamGroup), u => u.TeamGroup.Contains(input.TeamGroup.Trim()))
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.Operator), u => u.Operator.Contains(input.Operator.Trim()))
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.SourceOddNumber), u => u.SourceOddNumber.Contains(input.SourceOddNumber.Trim()))
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.Remarks), u => u.Remarks.Contains(input.Remarks.Trim()))
|
|
.Select<ReportDetailTableOutput>();
|
|
if(input.ProductDateRange != null && input.ProductDateRange.Count >0)
|
|
{
|
|
DateTime? start= input.ProductDateRange[0];
|
|
query = query.WhereIF(start.HasValue, u => u.ProductDate > start);
|
|
if (input.ProductDateRange.Count >1 && input.ProductDateRange[1].HasValue)
|
|
{
|
|
var end = input.ProductDateRange[1].Value.AddDays(1);
|
|
query = query.Where(u => u.ProductDate < end);
|
|
}
|
|
}
|
|
if(input.EndDateRange != null && input.EndDateRange.Count >0)
|
|
{
|
|
DateTime? start= input.EndDateRange[0];
|
|
query = query.WhereIF(start.HasValue, u => u.EndDate > start);
|
|
if (input.EndDateRange.Count >1 && input.EndDateRange[1].HasValue)
|
|
{
|
|
var end = input.EndDateRange[1].Value.AddDays(1);
|
|
query = query.Where(u => u.EndDate < 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(AddReportDetailTableInput input)
|
|
{
|
|
var entity = input.Adapt<ReportDetailTable>();
|
|
await _rep.InsertAsync(entity);
|
|
return entity.Id;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除汇报单详情
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
[ApiDescriptionSettings(Name = "Delete")]
|
|
public async Task Delete(DeleteReportDetailTableInput 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(UpdateReportDetailTableInput input)
|
|
{
|
|
var entity = input.Adapt<ReportDetailTable>();
|
|
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取汇报单详情
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
[ApiDescriptionSettings(Name = "Detail")]
|
|
public async Task<ReportDetailTable> Detail([FromQuery] QueryByIdReportDetailTableInput input)
|
|
{
|
|
return await _rep.GetFirstAsync(u => u.Id == input.Id);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取汇报单详情列表
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
[ApiDescriptionSettings(Name = "List")]
|
|
public async Task<List<ReportDetailTableOutput>> List()
|
|
{
|
|
return await _rep.AsQueryable().Where(a => !a.IsDelete).Select<ReportDetailTableOutput>().ToListAsync();
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|