diff --git a/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml b/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml index 68d87d3c..3d4177a5 100644 --- a/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml +++ b/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml @@ -830,6 +830,11 @@ 箱号 + + + 收货时间 + + 明细 @@ -2196,6 +2201,13 @@ + + + 集合:根据boxIDS + + + + 集合:根据箱号集合 @@ -2218,6 +2230,14 @@ + + + 批量删除 + + + + + 入库任务-仓储接口 diff --git a/src/WMS.Web.Domain/Entitys/InStockTaskBox.cs b/src/WMS.Web.Domain/Entitys/InStockTaskBox.cs index 75103f16..abc4f8f6 100644 --- a/src/WMS.Web.Domain/Entitys/InStockTaskBox.cs +++ b/src/WMS.Web.Domain/Entitys/InStockTaskBox.cs @@ -34,6 +34,11 @@ namespace WMS.Web.Domain.Entitys /// public string BoxBillNo { get; set; } + /// + /// 收货时间 + /// + public DateTime CreateTime { get; set; } = DateTime.Now; + /// /// 明细 /// diff --git a/src/WMS.Web.Domain/Infrastructure/IInStockTaskBoxRepositories.cs b/src/WMS.Web.Domain/Infrastructure/IInStockTaskBoxRepositories.cs index 234545ad..725acfbb 100644 --- a/src/WMS.Web.Domain/Infrastructure/IInStockTaskBoxRepositories.cs +++ b/src/WMS.Web.Domain/Infrastructure/IInStockTaskBoxRepositories.cs @@ -18,6 +18,13 @@ namespace WMS.Web.Domain.Infrastructure /// Task> GetListBy(int taskId); + /// + /// 集合:根据boxIDS + /// + /// + /// + Task> GetListBy(List boxIds); + /// /// 集合:根据箱号集合 /// @@ -39,5 +46,13 @@ namespace WMS.Web.Domain.Infrastructure /// /// Task AddRange(List entitys, bool isTransaction = true); + + /// + /// 批量删除 + /// + /// + /// + /// + Task DeleteRange(List ids, bool isTransaction = false); } } diff --git a/src/WMS.Web.Domain/Services/InStockService.cs b/src/WMS.Web.Domain/Services/InStockService.cs index 936dc02a..5b599c3f 100644 --- a/src/WMS.Web.Domain/Services/InStockService.cs +++ b/src/WMS.Web.Domain/Services/InStockService.cs @@ -597,10 +597,9 @@ namespace WMS.Web.Domain.Services }); //2.修改箱和任务单的绑定关系,先判断箱没有被收货过 - var taskBoxList = await _inStockTaskBoxRepositories.GetListBy(entity.Id); var dto_boxIds = dto.Boxs.GroupBy(x => x.BoxId).Select(x => x.Key).ToList(); - var isHaveBox = taskBoxList.Where(x => dto_boxIds.Contains(x.BoxId)).Any(); - if (isHaveBox) + var taskBoxList = await _inStockTaskBoxRepositories.GetListBy(dto_boxIds); + if (taskBoxList != null && taskBoxList.Count != 0) return Result.ReFailure(ResultCodes.InStockTaskBoxIsHaveData); //3.组装绑定关系表,要添加的集合 diff --git a/src/WMS.Web.Repositories/InStockTaskBoxRepositories.cs b/src/WMS.Web.Repositories/InStockTaskBoxRepositories.cs index 798ca318..f7315c40 100644 --- a/src/WMS.Web.Repositories/InStockTaskBoxRepositories.cs +++ b/src/WMS.Web.Repositories/InStockTaskBoxRepositories.cs @@ -59,6 +59,18 @@ namespace WMS.Web.Repositories return entitys; } + /// + /// 集合:根据boxIDS + /// + /// + /// + public async Task> GetListBy(List boxIds) + { + var entitys = await _context.InstockTaskBox + .Include(s => s.Details).Where(x => boxIds.Contains(x.BoxId)).ToListAsync(); + return entitys; + } + /// /// 集合:根据箱号集合 /// @@ -112,5 +124,34 @@ namespace WMS.Web.Repositories return false; } } + + /// + /// 批量删除 + /// + /// + /// + public async Task DeleteRange(List ids, bool isTransaction = false) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + try + { + var list = await _context.InstockTaskBox.Include(x => x.Details) + .Where(f => ids.Contains(f.Id)).ToListAsync(); + _context.InstockTaskBox.RemoveRange(list); + await _context.SaveChangesAsync(); + + if (_transaction != null) + _transaction.Commit(); + } + catch (Exception ex) + { + if (_transaction != null) + _transaction.Rollback(); + return false; + } + return true; + } } }