优化接口

This commit is contained in:
tongfei
2024-01-03 14:25:04 +08:00
parent 9488b88256
commit 8be6864b3c
5 changed files with 83 additions and 3 deletions

View File

@@ -830,6 +830,11 @@
箱号
</summary>
</member>
<member name="P:WMS.Web.Domain.Entitys.InStockTaskBox.CreateTime">
<summary>
收货时间
</summary>
</member>
<member name="P:WMS.Web.Domain.Entitys.InStockTaskBox.Details">
<summary>
明细
@@ -2196,6 +2201,13 @@
<param name="taskId"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.Infrastructure.IInStockTaskBoxRepositories.GetListBy(System.Collections.Generic.List{System.Int32})">
<summary>
集合根据boxIDS
</summary>
<param name="boxIds"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.Infrastructure.IInStockTaskBoxRepositories.GetListBy(System.Collections.Generic.List{System.String})">
<summary>
集合:根据箱号集合
@@ -2218,6 +2230,14 @@
<param name="isTransaction"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.Infrastructure.IInStockTaskBoxRepositories.DeleteRange(System.Collections.Generic.List{System.Int32},System.Boolean)">
<summary>
批量删除
</summary>
<param name="ids"></param>
<param name="isTransaction"></param>
<returns></returns>
</member>
<member name="T:WMS.Web.Domain.Infrastructure.IInStockTaskRepositories">
<summary>
入库任务-仓储接口

View File

@@ -34,6 +34,11 @@ namespace WMS.Web.Domain.Entitys
/// </summary>
public string BoxBillNo { get; set; }
/// <summary>
/// 收货时间
/// </summary>
public DateTime CreateTime { get; set; } = DateTime.Now;
/// <summary>
/// 明细
/// </summary>

View File

@@ -18,6 +18,13 @@ namespace WMS.Web.Domain.Infrastructure
/// <returns></returns>
Task<List<InStockTaskBox>> GetListBy(int taskId);
/// <summary>
/// 集合根据boxIDS
/// </summary>
/// <param name="boxIds"></param>
/// <returns></returns>
Task<List<InStockTaskBox>> GetListBy(List<int> boxIds);
/// <summary>
/// 集合:根据箱号集合
/// </summary>
@@ -39,5 +46,13 @@ namespace WMS.Web.Domain.Infrastructure
/// <param name="isTransaction"></param>
/// <returns></returns>
Task<bool> AddRange(List<InStockTaskBox> entitys, bool isTransaction = true);
/// <summary>
/// 批量删除
/// </summary>
/// <param name="ids"></param>
/// <param name="isTransaction"></param>
/// <returns></returns>
Task<bool> DeleteRange(List<int> ids, bool isTransaction = false);
}
}

View File

@@ -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<InStockTask>.ReFailure(ResultCodes.InStockTaskBoxIsHaveData);
//3.组装绑定关系表,要添加的集合

View File

@@ -59,6 +59,18 @@ namespace WMS.Web.Repositories
return entitys;
}
/// <summary>
/// 集合根据boxIDS
/// </summary>
/// <param name="boxIds"></param>
/// <returns></returns>
public async Task<List<InStockTaskBox>> GetListBy(List<int> boxIds)
{
var entitys = await _context.InstockTaskBox
.Include(s => s.Details).Where(x => boxIds.Contains(x.BoxId)).ToListAsync();
return entitys;
}
/// <summary>
/// 集合:根据箱号集合
/// </summary>
@@ -112,5 +124,34 @@ namespace WMS.Web.Repositories
return false;
}
}
/// <summary>
/// 批量删除
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<bool> DeleteRange(List<int> 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;
}
}
}