调整盘点单

This commit is contained in:
18942506660
2023-11-01 11:08:59 +08:00
parent 9dd32beba4
commit 54b894c5dd
3 changed files with 75 additions and 28 deletions

View File

@@ -91,10 +91,10 @@ namespace WMS.Web.Repositories.Configuration
ent.ToTable("t_wms_takestock");
ent.HasKey(x => x.Id);
ent.HasMany(p => p.Details)
.WithOne()
.HasForeignKey(p => p.Fid)
.OnDelete(DeleteBehavior.Cascade);
//ent.HasMany(p => p.Details)
// .WithOne()
// .HasForeignKey(p => p.Fid)
// .OnDelete(DeleteBehavior.Cascade);
});
builder.Entity<TakeStockDetails>(ent =>
{

View File

@@ -77,40 +77,40 @@ namespace WMS.Web.Repositories
/// <returns></returns>
public async Task<(List<TakeStockQueryInfoResponse> list, int total)> GetListAsync(TakeStockQueryRequest dto)
{
var query = _context.TakeStockDetails
.GroupJoin(_context.TakeStock, detail => detail.Fid, order => order.Id, (detail, orders) => new { detail, orders })
.SelectMany(x => x.orders.DefaultIfEmpty(), (p, order) => new { p.detail, order })
.OrderByDescending(o => o.order.Id)
var query = _context.TakeStock
//.GroupJoin(_context.TakeStock, detail => detail.Fid, order => order.Id, (detail, orders) => new { detail, orders })
//.SelectMany(x => x.orders.DefaultIfEmpty(), (p, order) => new { p.detail, order })
.OrderByDescending(o => o.Id)
.Where(adv => 1 == 1);
if (dto.ResultType != null)
query = query.Where(w => w.detail.ResultType == (TakeStockType)dto.ResultType);
query = query.Where(w => w.ResultType == (TakeStockType)dto.ResultType);
if (!string.IsNullOrEmpty(dto.BillNo))
query = query.Where(w => EF.Functions.Like(w.order.BillNo, "%" + dto.BillNo + "%"));
query = query.Where(w => EF.Functions.Like(w.BillNo, "%" + dto.BillNo + "%"));
if (dto.StockId != null)
query = query.Where(w => w.detail.StockId == dto.StockId);
query = query.Where(w => w.StockId == dto.StockId);
if (dto.DateBeginDate != null)
query = query.Where(w => w.order.Date >= dto.DateBeginDate);
query = query.Where(w => w.Date >= dto.DateBeginDate);
if (dto.DateEndDate != null)
query = query.Where(w => w.order.Date <= dto.DateEndDate);
query = query.Where(w => w.Date <= dto.DateEndDate);
//组装
int total = await query.CountAsync();
var list = await query.Select(s => new TakeStockQueryInfoResponse()
{
#region dto组装
Id = s.order.Id,
BillNo = s.order.BillNo,
Unit = _singleDataService.GetSingleData(SingleAction.Units, _loginRepositories.CompanyId, s.detail.UnitId),
Stock = _singleDataService.GetSingleData(SingleAction.Stocks, _loginRepositories.CompanyId, s.detail.StockId),
SubStock = _singleDataService.GetSingleData(SingleAction.SubStocks, _loginRepositories.CompanyId, s.detail.SubStockId),
BeforeQty = s.detail.BeforeQty,
AfterQty = s.detail.AfterQty,
FinalQty = s.detail.FinalQty,
ResultType = s.detail.ResultType.GetRemark(),
Remark = s.detail.Remark,
Creator = _singleDataService.GetSingleData(SingleAction.Staffs, _loginRepositories.CompanyId, s.order.CreatorId),
Date = s.order.Date.DateToStringSeconds(),
SuccessSync = s.order.SuccessSync
Id = s.Id,
BillNo = s.BillNo,
Unit = _singleDataService.GetSingleData(SingleAction.Units, _loginRepositories.CompanyId, s.UnitId),
Stock = _singleDataService.GetSingleData(SingleAction.Stocks, _loginRepositories.CompanyId, s.StockId),
SubStock = _singleDataService.GetSingleData(SingleAction.SubStocks, _loginRepositories.CompanyId, s.SubStockId),
BeforeQty = s.BeforeQty,
AfterQty = s.AfterQty,
FinalQty = s.FinalQty,
ResultType = s.ResultType.GetRemark(),
Remark = s.Remark,
Creator = _singleDataService.GetSingleData(SingleAction.Staffs, _loginRepositories.CompanyId, s.CreatorId),
Date = s.Date.DateToStringSeconds(),
SuccessSync = s.SuccessSync
#endregion
}).Skip((dto.PageNo - 1) * dto.PageSize).Take(dto.PageSize).ToListAsync();