列表查询条件添加
This commit is contained in:
37
src/WMS.Web.Core/Dto/Basics/SysStaffResponse.cs
Normal file
37
src/WMS.Web.Core/Dto/Basics/SysStaffResponse.cs
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace WMS.Web.Core.Dto.Basics
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 员工响应
|
||||||
|
/// </summary>
|
||||||
|
public class SysStaffResponse
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// StaffID
|
||||||
|
/// </summary>
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 名称
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 部门ID
|
||||||
|
/// </summary>
|
||||||
|
public int DeptId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 电话
|
||||||
|
/// </summary>
|
||||||
|
public string Telephone { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否禁用:true为禁用,false为启用
|
||||||
|
/// </summary>
|
||||||
|
public bool Disable { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,11 +10,11 @@ namespace WMS.Web.Core.Dto.ChangeBoxRecord
|
|||||||
public class ChangeBoxRecordQueryRequest: PaginationBaseRequestDto
|
public class ChangeBoxRecordQueryRequest: PaginationBaseRequestDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 原箱子ID
|
/// 原箱子
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string SrcBox { get; set; }
|
public string SrcBox { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 目标箱子ID
|
/// 目标箱子
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string DestBox { get; set; }
|
public string DestBox { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
21
src/WMS.Web.Domain/Infrastructure/IBasicsRepositories.cs
Normal file
21
src/WMS.Web.Domain/Infrastructure/IBasicsRepositories.cs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using WMS.Web.Core.Dto.Basics;
|
||||||
|
|
||||||
|
namespace WMS.Web.Domain.Infrastructure
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 基础数据
|
||||||
|
/// </summary>
|
||||||
|
public interface IBasicsRepositories
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取所有人员-根据主体
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="CompanyId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<SysStaffResponse>> GetStaffListAsync(int CompanyId);
|
||||||
|
}
|
||||||
|
}
|
||||||
54
src/WMS.Web.Repositories/BasicsRepositories.cs
Normal file
54
src/WMS.Web.Repositories/BasicsRepositories.cs
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using WMS.Web.Core.Dto.Basics;
|
||||||
|
using WMS.Web.Core.Dto.SingleData;
|
||||||
|
using WMS.Web.Core.Internal.Results;
|
||||||
|
using WMS.Web.Domain.Infrastructure;
|
||||||
|
using WMS.Web.Domain.IService.Public;
|
||||||
|
using WMS.Web.Domain.Values;
|
||||||
|
using WMS.Web.Domain.Values.Single;
|
||||||
|
using WMS.Web.Repositories.Configuration;
|
||||||
|
|
||||||
|
namespace WMS.Web.Repositories
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 基础数据
|
||||||
|
/// </summary>
|
||||||
|
public class BasicsRepositories : IBasicsRepositories
|
||||||
|
{
|
||||||
|
private readonly IMapper _mapper;
|
||||||
|
private readonly IServiceProvider _serviceProvider;
|
||||||
|
private RepositoryDbContext _context;
|
||||||
|
private readonly ILoginRepositories _loginService;
|
||||||
|
private readonly ISingleDataService _singleDataService;
|
||||||
|
|
||||||
|
|
||||||
|
public BasicsRepositories(RepositoryDbContext context, IMapper mapper, IServiceProvider serviceProvider,
|
||||||
|
ILoginRepositories loginService, ISingleDataService singleDataService)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
_mapper = mapper;
|
||||||
|
_serviceProvider = serviceProvider;
|
||||||
|
_loginService = loginService;
|
||||||
|
_singleDataService = singleDataService;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获取所有人员
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="CompanyId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<List<SysStaffResponse>> GetStaffListAsync(int CompanyId)
|
||||||
|
{
|
||||||
|
var result = await _singleDataService.GetSysConfigData<ResultList<SysStaffResponse>, SingleDataRequest>
|
||||||
|
(new SingleDataRequest(CompanyId),
|
||||||
|
SysConfigAction.GetStaffByCompany);
|
||||||
|
if (!result.Success)
|
||||||
|
return null;
|
||||||
|
return result.Data.ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,16 +24,17 @@ namespace WMS.Web.Repositories
|
|||||||
private readonly RepositoryDbContext _context;
|
private readonly RepositoryDbContext _context;
|
||||||
private readonly ISingleDataService _singleDataService;
|
private readonly ISingleDataService _singleDataService;
|
||||||
private readonly ILoginRepositories _loginRepositories;
|
private readonly ILoginRepositories _loginRepositories;
|
||||||
|
private readonly IBasicsRepositories _basicsRepositories;
|
||||||
|
|
||||||
public ChangeBoxRecordRepositories(RepositoryDbContext context, IMapper mapper, IServiceProvider serviceProvider,
|
public ChangeBoxRecordRepositories(RepositoryDbContext context, IMapper mapper, IServiceProvider serviceProvider,
|
||||||
ISingleDataService singleDataService, ILoginRepositories loginRepositories)
|
ISingleDataService singleDataService, ILoginRepositories loginRepositories, IBasicsRepositories basicsRepositories)
|
||||||
{
|
{
|
||||||
_context = context;
|
_context = context;
|
||||||
_mapper = mapper;
|
_mapper = mapper;
|
||||||
_serviceProvider = serviceProvider;
|
_serviceProvider = serviceProvider;
|
||||||
_singleDataService = singleDataService;
|
_singleDataService = singleDataService;
|
||||||
_loginRepositories = loginRepositories;
|
_loginRepositories = loginRepositories;
|
||||||
|
_basicsRepositories = basicsRepositories;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 新增
|
/// 新增
|
||||||
@@ -76,14 +77,33 @@ namespace WMS.Web.Repositories
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<(List<ChangeBoxRecordQueryInfoResponse> list, int total)> GetListAsync(ChangeBoxRecordQueryRequest dto)
|
public async Task<(List<ChangeBoxRecordQueryInfoResponse> list, int total)> GetListAsync(ChangeBoxRecordQueryRequest dto)
|
||||||
{
|
{
|
||||||
|
List<int> ids = new List<int>();
|
||||||
|
if (!string.IsNullOrEmpty(dto.Creator))
|
||||||
|
{
|
||||||
|
var staffList = await _basicsRepositories.GetStaffListAsync(_loginRepositories.CompanyId);
|
||||||
|
ids = staffList.Where(w => EF.Functions.Like(w.Name, "%" + dto.Creator + "%")).Select(s => s.Id).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
var query = _context.ChangeBoxRecord
|
var query = _context.ChangeBoxRecord
|
||||||
.GroupJoin(_context.Box, changeBox => changeBox.SrcBoxId, srcBox => srcBox.Id, (changeBox, srcBox) => new { changeBox, srcBox })
|
.GroupJoin(_context.Box, changeBox => changeBox.SrcBoxId, srcBox => srcBox.Id, (changeBox, srcBox) => new { changeBox, srcBox })
|
||||||
.SelectMany(x => x.srcBox.DefaultIfEmpty(), (d, srcBox) => new { d.changeBox, srcBox })
|
.SelectMany(x => x.srcBox.DefaultIfEmpty(), (d, srcBox) => new { d.changeBox, srcBox })
|
||||||
.GroupJoin(_context.Box, d => d.changeBox.DestBoxId, destBox => destBox.Id, (d, destBox) => new { d.changeBox, d.srcBox, destBox })
|
.GroupJoin(_context.Box, d => d.changeBox.DestBoxId, destBox => destBox.Id, (d, destBox) => new { d.changeBox, d.srcBox, destBox })
|
||||||
.SelectMany(x => x.destBox.DefaultIfEmpty(), (d, destBox) => new { d.changeBox,d.srcBox, destBox })
|
.SelectMany(x => x.destBox.DefaultIfEmpty(), (d, destBox) => new { d.changeBox, d.srcBox, destBox })
|
||||||
.OrderByDescending(o => o.changeBox.Id)
|
.OrderByDescending(o => o.changeBox.Id)
|
||||||
.Where(adv => 1 == 1);
|
.Where(adv => 1 == 1);
|
||||||
|
|
||||||
|
if (ids.Count() > 0)
|
||||||
|
query = query.Where(w => ids.Contains(w.changeBox.CreatorId));
|
||||||
|
if (!string.IsNullOrEmpty(dto.SrcBox))
|
||||||
|
query = query.Where(w => EF.Functions.Like(w.srcBox.BoxBillNo, "%" + dto.SrcBox + "%"));
|
||||||
|
if (!string.IsNullOrEmpty(dto.DestBox))
|
||||||
|
query = query.Where(w => EF.Functions.Like(w.destBox.BoxBillNo, "%" + dto.DestBox + "%"));
|
||||||
|
if (dto.StockId != null)
|
||||||
|
query = query.Where(w => w.changeBox.StockId == dto.StockId);
|
||||||
|
if (dto.SrcSubStockId != null)
|
||||||
|
query = query.Where(w => w.changeBox.SrcSubStockId == dto.SrcSubStockId);
|
||||||
|
if (dto.DestSubStockId != null)
|
||||||
|
query = query.Where(w => w.changeBox.DestSubStockId == dto.DestSubStockId);
|
||||||
if (dto.CreateBeginDate != null)
|
if (dto.CreateBeginDate != null)
|
||||||
query = query.Where(w => w.changeBox.CreateTime >= dto.CreateBeginDate);
|
query = query.Where(w => w.changeBox.CreateTime >= dto.CreateBeginDate);
|
||||||
if (dto.CreateEndDate != null)
|
if (dto.CreateEndDate != null)
|
||||||
@@ -103,7 +123,7 @@ namespace WMS.Web.Repositories
|
|||||||
SrcSubStock = _singleDataService.GetSingleData(SingleAction.SubStocks, _loginRepositories.CompanyId, s.changeBox.SrcSubStockId),
|
SrcSubStock = _singleDataService.GetSingleData(SingleAction.SubStocks, _loginRepositories.CompanyId, s.changeBox.SrcSubStockId),
|
||||||
DestSubStock = _singleDataService.GetSingleData(SingleAction.SubStocks, _loginRepositories.CompanyId, s.changeBox.DestSubStockId),
|
DestSubStock = _singleDataService.GetSingleData(SingleAction.SubStocks, _loginRepositories.CompanyId, s.changeBox.DestSubStockId),
|
||||||
Creator = _singleDataService.GetSingleData(SingleAction.Staffs, _loginRepositories.CompanyId, s.changeBox.CreatorId),
|
Creator = _singleDataService.GetSingleData(SingleAction.Staffs, _loginRepositories.CompanyId, s.changeBox.CreatorId),
|
||||||
CreateTime =s.changeBox.CreateTime.DateToStringSeconds()
|
CreateTime = s.changeBox.CreateTime.DateToStringSeconds()
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}).Skip((dto.PageNo - 1) * dto.PageSize).Take(dto.PageSize).ToListAsync();
|
}).Skip((dto.PageNo - 1) * dto.PageSize).Take(dto.PageSize).ToListAsync();
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||||||
{
|
{
|
||||||
services.AddHttpContextAccessor();
|
services.AddHttpContextAccessor();
|
||||||
services.AddScoped<ILoginRepositories, LoginRepositories>();
|
services.AddScoped<ILoginRepositories, LoginRepositories>();
|
||||||
|
services.AddScoped<IBasicsRepositories, BasicsRepositories>();
|
||||||
|
|
||||||
services.AddTransient<ITransactionRepositories, TransactionRepositories>();
|
services.AddTransient<ITransactionRepositories, TransactionRepositories>();
|
||||||
|
|
||||||
services.AddTransient<IInStockRepositories, InStockRepositories>();
|
services.AddTransient<IInStockRepositories, InStockRepositories>();
|
||||||
|
|||||||
Reference in New Issue
Block a user