diff --git a/src/WMS.Web.Api/Controllers/SysConfigController.cs b/src/WMS.Web.Api/Controllers/SysConfigController.cs index 3b9ecbe1..4488185a 100644 --- a/src/WMS.Web.Api/Controllers/SysConfigController.cs +++ b/src/WMS.Web.Api/Controllers/SysConfigController.cs @@ -65,6 +65,15 @@ namespace WMS.Web.Api.Controllers { response.BackRecordType.Add(enumv.ToString(), enumv.GetRemark()); } + foreach (InventoryInOutType enumv in Enum.GetValues(typeof(InventoryInOutType))) + { + response.InventoryInOutType.Add(enumv.ToString(), enumv.GetRemark()); + } + foreach (OrderType enumv in Enum.GetValues(typeof(OrderType))) + { + response.OrderType.Add(enumv.ToString(), enumv.GetRemark()); + } + //2 //1 return Task.FromResult(Result.ReSuccess(response)); diff --git a/src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml b/src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml index db5470e7..eb3f89aa 100644 --- a/src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml +++ b/src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml @@ -450,6 +450,16 @@ 类型:1为入库回退下架,2为出库回退上架 + + + 类型:1为入库,2为出库 + + + + + 单据类型 + + ERP:单据查询-dto @@ -830,6 +840,161 @@ 明细 + + + 即时库存明细-查询请求对象 + + + + + 仓库ID + + + + + 物料编码 + + + + + 库存量 + + + + + 即时库存明细-查询响应对象 + + + + + ID + + + + + 物料名称 + + + + + 物料编码 + + + + + 物料规格型号 + + + + + 仓库 + + + + + 仓位 + + + + + 库存量 + + + + + 单位 + + + + + 物料收发明细-查询请求 + + + + + 仓库ID + + + + + 物料编码 + + + + + 单据类型 + + + + + 创建日期 + + + + + 创建日期 + + + + + 物料收发明细-查询响应对象 + + + + + ID + + + + + 物料名称 + + + + + 物料编码 + + + + + 物料规格型号 + + + + + 类型:1为入库,2为出库 + + + + + 仓库 + + + + + 单据类型 + + + + + 单据编号 + + + + + 数量 + + + + + 结存 + + + + + 创建日期 + + 授权token -- 给前端用的验证token diff --git a/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml b/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml index 6e7e534c..01775fe3 100644 --- a/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml +++ b/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml @@ -1119,6 +1119,54 @@ + + + 库存相关-仓储接口 + + + + + 列表-分页 + + + + + + + 批量添加 + + + + + + + + 批量修改 + + + + + + + + 物料收发明细-仓储接口 + + + + + 列表-分页 + + + + + + + 批量添加 + + + + + 公司Id diff --git a/src/WMS.Web.Core/Dto/EnumStatusResponse.cs b/src/WMS.Web.Core/Dto/EnumStatusResponse.cs index 2b4c868f..9f9fe246 100644 --- a/src/WMS.Web.Core/Dto/EnumStatusResponse.cs +++ b/src/WMS.Web.Core/Dto/EnumStatusResponse.cs @@ -34,6 +34,14 @@ namespace WMS.Web.Core.Dto /// 类型:1为入库回退下架,2为出库回退上架 /// public Dictionary BackRecordType { get; set; } = new Dictionary(); + /// + /// 类型:1为入库,2为出库 + /// + public Dictionary InventoryInOutType { get; set; } = new Dictionary(); + /// + /// 单据类型 + /// + public Dictionary OrderType { get; set; } = new Dictionary(); diff --git a/src/WMS.Web.Core/Dto/Inventory/InventoryDetailsQueryRequest.cs b/src/WMS.Web.Core/Dto/Inventory/InventoryDetailsQueryRequest.cs new file mode 100644 index 00000000..4a1bfc2d --- /dev/null +++ b/src/WMS.Web.Core/Dto/Inventory/InventoryDetailsQueryRequest.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WMS.Web.Core.Dto.Inventory +{ + /// + /// 即时库存明细-查询请求对象 + /// + public class InventoryDetailsQueryRequest : PaginationBaseRequestDto + { + /// + /// 仓库ID + /// + public int? StockId { get; set; } + + /// + /// 物料编码 + /// + public string MaterialNumber { get; set; } + + /// + /// 库存量 + /// + public decimal? Qty { get; set; } + } +} diff --git a/src/WMS.Web.Core/Dto/Inventory/InventoryDetailsQueryResponse.cs b/src/WMS.Web.Core/Dto/Inventory/InventoryDetailsQueryResponse.cs new file mode 100644 index 00000000..a1f415da --- /dev/null +++ b/src/WMS.Web.Core/Dto/Inventory/InventoryDetailsQueryResponse.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WMS.Web.Core.Dto.Inventory +{ + /// + /// 即时库存明细-查询响应对象 + /// + public class InventoryDetailsQueryResponse + { + /// + /// ID + /// + public int Id { get; set; } + + /// + /// 物料名称 + /// + public string MaterialName { get; set; } + /// + /// 物料编码 + /// + public string MaterialNumber { get; set; } + /// + /// 物料规格型号 + /// + public string Specifications { get; set; } + + /// + /// 仓库 + /// + public string Stock { get; set; } + /// + /// 仓位 + /// + public string SubStock { get; set; } + + /// + /// 库存量 + /// + public decimal Qty { get; set; } + + /// + /// 单位 + /// + public string Unit { get; set; } + } +} diff --git a/src/WMS.Web.Core/Dto/Inventory/InventoryInOutDetailsQueryRequest.cs b/src/WMS.Web.Core/Dto/Inventory/InventoryInOutDetailsQueryRequest.cs new file mode 100644 index 00000000..94c5f655 --- /dev/null +++ b/src/WMS.Web.Core/Dto/Inventory/InventoryInOutDetailsQueryRequest.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WMS.Web.Core.Dto.Inventory +{ + /// + /// 物料收发明细-查询请求 + /// + public class InventoryInOutDetailsQueryRequest : PaginationBaseRequestDto + { + /// + /// 仓库ID + /// + public int? StockId { get; set; } + + /// + /// 物料编码 + /// + public string MaterialNumber { get; set; } + + /// + /// 单据类型 + /// + public int? OrderType { get; set; } + + /// + /// 创建日期 + /// + public DateTime? CreateBeginDate { get; set; } = null; + /// + /// 创建日期 + /// + public DateTime? CreateEndDate { get; set; } = null; + } +} diff --git a/src/WMS.Web.Core/Dto/Inventory/InventoryInOutDetailsQueryResponse.cs b/src/WMS.Web.Core/Dto/Inventory/InventoryInOutDetailsQueryResponse.cs new file mode 100644 index 00000000..12b449d1 --- /dev/null +++ b/src/WMS.Web.Core/Dto/Inventory/InventoryInOutDetailsQueryResponse.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WMS.Web.Core.Dto.Inventory +{ + /// + /// 物料收发明细-查询响应对象 + /// + public class InventoryInOutDetailsQueryResponse + { + /// + /// ID + /// + public int Id { get; set; } + + /// + /// 物料名称 + /// + public string MaterialName { get; set; } + /// + /// 物料编码 + /// + public string MaterialNumber { get; set; } + /// + /// 物料规格型号 + /// + public string Specifications { get; set; } + + /// + /// 类型:1为入库,2为出库 + /// + public string Type { get; set; } + + /// + /// 仓库 + /// + public string Stock { get; set; } + + /// + /// 单据类型 + /// + public string OrderType { get; set; } + + /// + /// 单据编号 + /// + public string OrderBillNo { get; set; } + /// + /// 数量 + /// + public decimal Qty { get; set; } + /// + /// 结存 + /// + public decimal SurplusQty { get; set; } + + /// + /// 创建日期 + /// + public DateTime CreateTime { get; set; } + } +} diff --git a/src/WMS.Web.Domain/Infrastructure/IInventoryDetailsRepositories.cs b/src/WMS.Web.Domain/Infrastructure/IInventoryDetailsRepositories.cs new file mode 100644 index 00000000..dc411c00 --- /dev/null +++ b/src/WMS.Web.Domain/Infrastructure/IInventoryDetailsRepositories.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using WMS.Web.Core.Dto.Inventory; +using WMS.Web.Core.Internal.Results; +using WMS.Web.Domain.Entitys; + +namespace WMS.Web.Domain.Infrastructure +{ + /// + /// 库存相关-仓储接口 + /// + public interface IInventoryDetailsRepositories + { + /// + /// 列表-分页 + /// + /// + /// + Task> GetPagedList(InventoryDetailsQueryRequest dto); + + /// + /// 批量添加 + /// + /// + /// + /// + Task AddRange(List entitys, bool isTransaction = true); + + /// + /// 批量修改 + /// + /// + /// + /// + Task UpdateRange(List entitys, bool isTransaction = true); + } +} diff --git a/src/WMS.Web.Domain/Infrastructure/IInventoryInOutDetailsRepositories.cs b/src/WMS.Web.Domain/Infrastructure/IInventoryInOutDetailsRepositories.cs new file mode 100644 index 00000000..e10eac5c --- /dev/null +++ b/src/WMS.Web.Domain/Infrastructure/IInventoryInOutDetailsRepositories.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using WMS.Web.Core.Dto.Inventory; +using WMS.Web.Core.Internal.Results; +using WMS.Web.Domain.Entitys; + +namespace WMS.Web.Domain.Infrastructure +{ + /// + /// 物料收发明细-仓储接口 + /// + public interface IInventoryInOutDetailsRepositories + { + /// + /// 列表-分页 + /// + /// + /// + Task> GetPagedList(InventoryInOutDetailsQueryRequest dto); + + /// + /// 批量添加 + /// + /// + /// + /// + Task AddRange(List entitys, bool isTransaction = true); + } +} diff --git a/src/WMS.Web.Repositories/DependencyInjection/AppBuilderExtensions.cs b/src/WMS.Web.Repositories/DependencyInjection/AppBuilderExtensions.cs index 598a9565..4fb86fe4 100644 --- a/src/WMS.Web.Repositories/DependencyInjection/AppBuilderExtensions.cs +++ b/src/WMS.Web.Repositories/DependencyInjection/AppBuilderExtensions.cs @@ -40,8 +40,12 @@ namespace Microsoft.Extensions.DependencyInjection services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + + services.AddTransient(); services.AddTransient(); services.AddTransient(); diff --git a/src/WMS.Web.Repositories/InventoryDetailsRepositories.cs b/src/WMS.Web.Repositories/InventoryDetailsRepositories.cs new file mode 100644 index 00000000..65038a6d --- /dev/null +++ b/src/WMS.Web.Repositories/InventoryDetailsRepositories.cs @@ -0,0 +1,142 @@ +using AutoMapper; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Storage; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using WMS.Web.Core.Dto.Inventory; +using WMS.Web.Core.Internal.Results; +using WMS.Web.Domain.Entitys; +using WMS.Web.Domain.Infrastructure; +using WMS.Web.Domain.IService.Public; +using WMS.Web.Repositories.Configuration; + +namespace WMS.Web.Repositories +{ + /// + /// 库存相关-仓储 + /// + public class InventoryDetailsRepositories: IInventoryDetailsRepositories + { + private readonly IMapper _mapper; + private readonly IServiceProvider _serviceProvider; + private readonly ILoginRepositories _loginRepositories; + private readonly RepositoryDbContext _context; + private readonly ISingleDataService _singleDataService; + + + public InventoryDetailsRepositories(RepositoryDbContext context, + IMapper mapper, + ILoginRepositories loginRepositories, + IServiceProvider serviceProvider, + ISingleDataService singleDataService) + { + _context = context; + _mapper = mapper; + _serviceProvider = serviceProvider; + _loginRepositories = loginRepositories; + _singleDataService = singleDataService; + } + + /// + /// 列表-分页 + /// + /// + /// + public async Task> GetPagedList(InventoryDetailsQueryRequest dto) + { + var query = _context.InventoryDetails + .Where(adv => 1 == 1); + + //if (!string.IsNullOrEmpty(dto.MaterialNumber)) + // query = query.Where(w => EF.Functions.Like(w.detail.BillNo, "%" + dto.BillNo + "%")); + + if (dto.StockId.HasValue) + query = query.Where(w => w.StockId == dto.StockId.Value); + + if (dto.Qty.HasValue) + query = query.Where(w => w.Qty == dto.Qty); + + var response = new ResultPagedList(); + int total = await query.CountAsync(); + response.TotalCount = total; + + var list = await query.Select(s => new InventoryDetailsQueryResponse() + { + Id=s.Id, + MaterialName = "", + MaterialNumber = "", + Specifications = "", + Stock = "", + Qty = s.Qty, + SubStock ="", + Unit = "" + }).OrderByDescending(x => x.Id).Skip((dto.PageNo - 1) * dto.PageSize).Take(dto.PageSize).ToListAsync(); + + response.Data = list; + return response; + } + + /// + /// 批量添加 + /// + /// + /// + /// + public async Task AddRange(List entitys, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + try + { + if (entitys != null && entitys.Count != 0) + { + await _context.InventoryDetails.AddRangeAsync(entitys); + await _context.SaveChangesAsync(); + } + if (_transaction != null) + _transaction.Commit(); + return true; + } + catch + { + if (_transaction != null) + _transaction.Rollback(); + return false; + } + } + + /// + /// 批量修改 + /// + /// + /// + public async Task UpdateRange(List entitys, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + { + try + { + List list = entitys.Select(s => s.Id).ToList(); + var res = await _context.InventoryDetails.Where(f => list.Contains(f.Id)).ToListAsync(); + _mapper.Map(entitys, res); + await _context.SaveChangesAsync(); + if (_transaction != null) + _transaction.Commit(); + } + catch (Exception ex) + { + if (_transaction != null) + _transaction.Rollback(); + return false; + } + return true; + } + } + } +} diff --git a/src/WMS.Web.Repositories/InventoryInOutDetailsRepositories.cs b/src/WMS.Web.Repositories/InventoryInOutDetailsRepositories.cs new file mode 100644 index 00000000..cc6d8727 --- /dev/null +++ b/src/WMS.Web.Repositories/InventoryInOutDetailsRepositories.cs @@ -0,0 +1,121 @@ +using AutoMapper; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Storage; +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.Inventory; +using WMS.Web.Core.Internal.Results; +using WMS.Web.Domain.Entitys; +using WMS.Web.Domain.Infrastructure; +using WMS.Web.Domain.IService.Public; +using WMS.Web.Repositories.Configuration; + +namespace WMS.Web.Repositories +{ + /// + /// 物料收发明细-仓储 + /// + public class InventoryInOutDetailsRepositories: IInventoryInOutDetailsRepositories + { + private readonly IMapper _mapper; + private readonly IServiceProvider _serviceProvider; + private readonly ILoginRepositories _loginRepositories; + private readonly RepositoryDbContext _context; + private readonly ISingleDataService _singleDataService; + + + public InventoryInOutDetailsRepositories(RepositoryDbContext context, + IMapper mapper, + ILoginRepositories loginRepositories, + IServiceProvider serviceProvider, + ISingleDataService singleDataService) + { + _context = context; + _mapper = mapper; + _serviceProvider = serviceProvider; + _loginRepositories = loginRepositories; + _singleDataService = singleDataService; + } + + /// + /// 列表-分页 + /// + /// + /// + public async Task> GetPagedList(InventoryInOutDetailsQueryRequest dto) + { + var query = _context.InventoryInOutDetails + .Where(adv => 1 == 1); + + //if (!string.IsNullOrEmpty(dto.MaterialNumber)) + // query = query.Where(w => EF.Functions.Like(w.detail.BillNo, "%" + dto.BillNo + "%")); + + if (dto.StockId.HasValue) + query = query.Where(w => w.StockId == dto.StockId.Value); + + if (dto.OrderType.HasValue) + query = query.Where(w => (int)w.OrderType == dto.OrderType.Value); + + if (dto.CreateBeginDate != null) + query = query.Where(w => w.CreateTime >= dto.CreateBeginDate.Value); + if (dto.CreateEndDate != null) + query = query.Where(w => w.CreateTime <= dto.CreateEndDate.Value); + + var response = new ResultPagedList(); + int total = await query.CountAsync(); + response.TotalCount = total; + + var list = await query.Select(s => new InventoryInOutDetailsQueryResponse() + { + Id = s.Id, + MaterialName = "", + MaterialNumber = "", + Specifications = "", + Type=s.Type.GetRemark(), + OrderType=s.OrderType.GetRemark(), + OrderBillNo=s.OrderBillNo, + Stock = "", + Qty = s.Qty, + SurplusQty=s.SurplusQty, + CreateTime = s.CreateTime + }).OrderByDescending(x => x.Id).Skip((dto.PageNo - 1) * dto.PageSize).Take(dto.PageSize).ToListAsync(); + + response.Data = list; + return response; + } + + /// + /// 批量添加 + /// + /// + /// + /// + public async Task AddRange(List entitys, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + try + { + if (entitys != null && entitys.Count != 0) + { + await _context.InventoryInOutDetails.AddRangeAsync(entitys); + await _context.SaveChangesAsync(); + } + if (_transaction != null) + _transaction.Commit(); + return true; + } + catch + { + if (_transaction != null) + _transaction.Rollback(); + return false; + } + } + } +}