diff --git a/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml b/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml index 24c5bc1a..aae25d2b 100644 --- a/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml +++ b/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml @@ -330,6 +330,12 @@ 明细 + + + 创建订单号 + + + erp入库任务明细表 @@ -861,6 +867,38 @@ + + + 批量添加 + + + + + + + + 添加 + + + + + + + + 批量修改 + + + + + + + + 修改 + + + + + 获取事务 用来处理即时库存 diff --git a/src/WMS.Web.Domain/Infrastructure/IInStockTaskRepositories.cs b/src/WMS.Web.Domain/Infrastructure/IInStockTaskRepositories.cs index 6a2f2292..572f1a85 100644 --- a/src/WMS.Web.Domain/Infrastructure/IInStockTaskRepositories.cs +++ b/src/WMS.Web.Domain/Infrastructure/IInStockTaskRepositories.cs @@ -4,6 +4,7 @@ using System.Text; using System.Threading.Tasks; using WMS.Web.Core.Dto; using WMS.Web.Core.Internal.Results; +using WMS.Web.Domain.Entitys; namespace WMS.Web.Domain.Infrastructure { @@ -18,5 +19,37 @@ namespace WMS.Web.Domain.Infrastructure /// /// Task> GetPagedList(InStockTaskQueryRequest dto); + + /// + /// 批量添加 + /// + /// + /// + /// + Task AddRange(List entitys, bool isTransaction = true); + + /// + /// 添加 + /// + /// + /// + /// + Task Add(InStockTask entity, bool isTransaction = true); + + /// + /// 批量修改 + /// + /// + /// + /// + Task UpdateRange(List entitys, bool isTransaction = true); + + /// + /// 修改 + /// + /// + /// + /// + Task Update(InStockTask entity, bool isTransaction = true); } } diff --git a/src/WMS.Web.Repositories/InStockTaskRepositories.cs b/src/WMS.Web.Repositories/InStockTaskRepositories.cs index 37f5eabd..03e210f6 100644 --- a/src/WMS.Web.Repositories/InStockTaskRepositories.cs +++ b/src/WMS.Web.Repositories/InStockTaskRepositories.cs @@ -146,5 +146,67 @@ namespace WMS.Web.Repositories } } + + /// + /// 批量修改 + /// + /// + /// + 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.InStockTask.Include(x => x.Details).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; + } + } + + /// + /// 修改 + /// + /// + /// + public async Task Update(InStockTask entity,bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + try + { + var model = await _context.InStockTask + .AsNoTracking() + .Include(s => s.Details) + .FirstOrDefaultAsync(f => f.Id == entity.Id); + if (model == null) + return null; + _mapper.Map(entity, model); + await _context.SaveChangesAsync(); + if (_transaction != null) + _transaction.Commit(); + return model; + } + catch (Exception) + { + if (_transaction != null) + _transaction.Rollback(); + return null; + } + } } }