即时库存-仓储
This commit is contained in:
@@ -40,8 +40,12 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||
services.AddTransient<IInStockRepositories, InStockRepositories>();
|
||||
services.AddTransient<IInStockTaskRepositories, InStockTaskRepositories>();
|
||||
services.AddTransient<IBackRecordRepositories, BackRecordRepositories>();
|
||||
services.AddTransient<IInventoryDetailsRepositories, InventoryDetailsRepositories>();
|
||||
services.AddTransient<IInventoryInOutDetailsRepositories, InventoryInOutDetailsRepositories>();
|
||||
|
||||
|
||||
|
||||
|
||||
services.AddTransient<IChangeBoxRecordRepositories, ChangeBoxRecordRepositories>();
|
||||
services.AddTransient<IMoveBoxRecordRepositories, MoveBoxRecordRepositories>();
|
||||
services.AddTransient<IOutStockRepositories, OutStockRepositories>();
|
||||
|
||||
142
src/WMS.Web.Repositories/InventoryDetailsRepositories.cs
Normal file
142
src/WMS.Web.Repositories/InventoryDetailsRepositories.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 库存相关-仓储
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 列表-分页
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ResultPagedList<InventoryDetailsQueryResponse>> 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<InventoryDetailsQueryResponse>();
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量添加
|
||||
/// </summary>
|
||||
/// <param name="entitys"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> AddRange(List<InventoryDetails> 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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量修改
|
||||
/// </summary>
|
||||
/// <param name="entitys"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> UpdateRange(List<InventoryDetails> entitys, bool isTransaction = true)
|
||||
{
|
||||
IDbContextTransaction _transaction = null;
|
||||
if (isTransaction)
|
||||
_transaction = _context.Database.BeginTransaction();
|
||||
{
|
||||
try
|
||||
{
|
||||
List<int> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
121
src/WMS.Web.Repositories/InventoryInOutDetailsRepositories.cs
Normal file
121
src/WMS.Web.Repositories/InventoryInOutDetailsRepositories.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 物料收发明细-仓储
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 列表-分页
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ResultPagedList<InventoryInOutDetailsQueryResponse>> 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<InventoryInOutDetailsQueryResponse>();
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量添加
|
||||
/// </summary>
|
||||
/// <param name="entitys"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> AddRange(List<InventoryInOutDetails> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user