回退仓储

This commit is contained in:
tongfei
2023-10-30 18:12:20 +08:00
parent 0fedf62c93
commit 3b8558b793
8 changed files with 333 additions and 1 deletions

View File

@@ -0,0 +1,92 @@
using AutoMapper;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WMS.Web.Core;
using WMS.Web.Core.Dto;
using WMS.Web.Core.Internal.Results;
using WMS.Web.Domain.Infrastructure;
using WMS.Web.Domain.IService.Public;
using WMS.Web.Repositories.Configuration;
namespace WMS.Web.Repositories
{
/// <summary>
/// 出入库回退记录-仓储
/// </summary>
public class BackRecordRepositories: IBackRecordRepositories
{
private readonly IMapper _mapper;
private readonly IServiceProvider _serviceProvider;
private readonly ILoginRepositories _loginRepositories;
private readonly RepositoryDbContext _context;
private readonly ISingleDataService _singleDataService;
public BackRecordRepositories(RepositoryDbContext context,
IMapper mapper,
ILoginRepositories loginRepositories,
IServiceProvider serviceProvider,
ISingleDataService singleDataService)
{
_context = context;
_mapper = mapper;
_serviceProvider = serviceProvider;
_loginRepositories = loginRepositories;
_singleDataService = singleDataService;
}
/// <summary>
/// 列表-分页
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
public async Task<ResultPagedList<BackRecordQueryResponse>> GetPagedList(BackRecordQueryRequest dto)
{
var query = _context.BackRecordDetails
.GroupJoin(_context.BackRecord, detail => detail.Fid, order => order.Id, (detail, orders) => new { detail, orders })
.SelectMany(x => x.orders.DefaultIfEmpty(), (p, order) => new { p.detail, order })
.Where(adv => 1 == 1);
//if (!string.IsNullOrEmpty(dto.BoxBillNo))
// query = query.Where(w => EF.Functions.Like(w.order.BoxBillNo, "%" + dto.BoxBillNo + "%"));
//if (!string.IsNullOrEmpty(dto.MaterialNumber))
// query = query.Where(w => EF.Functions.Like(w.detail.BillNo, "%" + dto.BillNo + "%"));
if (dto.SubStockId.HasValue)
query = query.Where(w => w.detail.SubStockId == dto.SubStockId.Value);
if (dto.CreateBeginDate != null)
query = query.Where(w => w.order.CreateTime >= dto.CreateBeginDate.Value);
if (dto.CreateEndDate != null)
query = query.Where(w => w.order.CreateTime <= dto.CreateEndDate.Value);
var response = new ResultPagedList<BackRecordQueryResponse>();
int total = await query.CountAsync();
response.TotalCount = total;
var list = await query.Select(s => new BackRecordQueryResponse()
{
Id = s.order.Id,
DetailsId = s.detail.Id,
BoxBillNo = "",
Type = s.order.Type.GetRemark(),
Creator = "",
CreateTime =s.order.CreateTime,
MaterialName = "",
MaterialNumber = "",
Specifications = "",
Qty = s.detail.Qty,
SubStock = "",
SerialNumbers = s.detail.SerialNumbers
}).OrderByDescending(x => x.Id).Skip((dto.PageNo - 1) * dto.PageSize).Take(dto.PageSize).ToListAsync();
response.Data = list;
return response;
}
}
}

View File

@@ -38,6 +38,8 @@ namespace Microsoft.Extensions.DependencyInjection
services.AddTransient<IInStockRepositories, InStockRepositories>();
services.AddTransient<IInStockTaskRepositories, InStockTaskRepositories>();
services.AddTransient<IBackRecordRepositories, BackRecordRepositories>();
services.AddTransient<IChangeBoxRecordRepositories, ChangeBoxRecordRepositories>();
services.AddTransient<IMoveBoxRecordRepositories, MoveBoxRecordRepositories>();

View File

@@ -29,7 +29,11 @@ namespace WMS.Web.Repositories
private readonly ISingleDataService _singleDataService;
public InStockRepositories(RepositoryDbContext context, IMapper mapper, ILoginRepositories loginRepositories, IServiceProvider serviceProvider, ISingleDataService singleDataService)
public InStockRepositories(RepositoryDbContext context,
IMapper mapper,
ILoginRepositories loginRepositories,
IServiceProvider serviceProvider,
ISingleDataService singleDataService)
{
_context = context;
_mapper = mapper;