箱信息增加软删除
This commit is contained in:
Binary file not shown.
@@ -76,7 +76,10 @@ namespace WMS.Web.Api.Controllers
|
|||||||
//找到需要删除的箱子
|
//找到需要删除的箱子
|
||||||
var deleteBoxIds = boxs.Where(w => !inBoxBillNo.Contains(w.BoxBillNo)).Select(s => s.Id).ToList();
|
var deleteBoxIds = boxs.Where(w => !inBoxBillNo.Contains(w.BoxBillNo)).Select(s => s.Id).ToList();
|
||||||
if (deleteBoxIds.Count() == 0) return Result<List<string>>.ReSuccess(inBoxBillNo);
|
if (deleteBoxIds.Count() == 0) return Result<List<string>>.ReSuccess(inBoxBillNo);
|
||||||
var deleteBoxBillNos = boxs.Where(w => deleteBoxIds.Contains(w.Id)).Select(s => s.BoxBillNo).ToList();
|
var deleteBoxs = boxs.Where(w => deleteBoxIds.Contains(w.Id)).ToList();
|
||||||
|
//软删除
|
||||||
|
deleteBoxs.ForEach(f => f.Delete());
|
||||||
|
var deleteBoxBillNos = deleteBoxs.Select(s => s.BoxBillNo).ToList();
|
||||||
_logger.LogInformation($"重置的箱号:{JsonConvert.SerializeObject(deleteBoxBillNos)}");
|
_logger.LogInformation($"重置的箱号:{JsonConvert.SerializeObject(deleteBoxBillNos)}");
|
||||||
//执行数据库
|
//执行数据库
|
||||||
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
|
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
|
||||||
@@ -88,7 +91,7 @@ namespace WMS.Web.Api.Controllers
|
|||||||
if (!res_Rollback)
|
if (!res_Rollback)
|
||||||
{
|
{
|
||||||
//删除箱信息
|
//删除箱信息
|
||||||
isSuccess = await _boxRepositories.DeleteEntityList(deleteBoxIds, false);
|
isSuccess = await _boxRepositories.EditEntityList(deleteBoxs, false);
|
||||||
if (!isSuccess) res_Rollback = true;
|
if (!isSuccess) res_Rollback = true;
|
||||||
}
|
}
|
||||||
isSuccess = _transactionRepositories.CommitTransaction(res_Rollback, _transaction);
|
isSuccess = _transactionRepositories.CommitTransaction(res_Rollback, _transaction);
|
||||||
|
|||||||
@@ -168,6 +168,11 @@
|
|||||||
创建时间(对应老OPS的创建时间)
|
创建时间(对应老OPS的创建时间)
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="P:WMS.Web.Domain.Entitys.Box.IsDelete">
|
||||||
|
<summary>
|
||||||
|
是否删除 ops供应链重新装箱后软删除
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
<member name="P:WMS.Web.Domain.Entitys.Box.Details">
|
<member name="P:WMS.Web.Domain.Entitys.Box.Details">
|
||||||
<summary>
|
<summary>
|
||||||
明细
|
明细
|
||||||
@@ -204,6 +209,11 @@
|
|||||||
<param name="inventory"></param>
|
<param name="inventory"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:WMS.Web.Domain.Entitys.Box.Delete">
|
||||||
|
<summary>
|
||||||
|
软删除
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
<member name="T:WMS.Web.Domain.Entitys.BoxDetails">
|
<member name="T:WMS.Web.Domain.Entitys.BoxDetails">
|
||||||
<summary>
|
<summary>
|
||||||
老ops箱信息明细
|
老ops箱信息明细
|
||||||
|
|||||||
@@ -55,6 +55,10 @@ namespace WMS.Web.Domain.Entitys
|
|||||||
/// 创建时间(对应老OPS的创建时间)
|
/// 创建时间(对应老OPS的创建时间)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime CreateTime { get; set; } = DateTime.Now;
|
public DateTime CreateTime { get; set; } = DateTime.Now;
|
||||||
|
/// <summary>
|
||||||
|
/// 是否删除 ops供应链重新装箱后软删除
|
||||||
|
/// </summary>
|
||||||
|
public bool? IsDelete { get; set; } = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 明细
|
/// 明细
|
||||||
@@ -191,5 +195,13 @@ namespace WMS.Web.Domain.Entitys
|
|||||||
|
|
||||||
return Result.ReSuccess();
|
return Result.ReSuccess();
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 软删除
|
||||||
|
/// </summary>
|
||||||
|
public void Delete()
|
||||||
|
{
|
||||||
|
this.IsDelete = true;
|
||||||
|
this.Details.Clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,5 @@ namespace WMS.Web.Domain.Infrastructure
|
|||||||
Task<List<Box>> GetEntityList(List<int> ids);
|
Task<List<Box>> GetEntityList(List<int> ids);
|
||||||
|
|
||||||
Task<List<Box>> GetEntityListByNos(List<string> billNos);
|
Task<List<Box>> GetEntityListByNos(List<string> billNos);
|
||||||
//批量删除
|
|
||||||
Task<bool> DeleteEntityList(List<int> boxIds, bool isTransaction = true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ namespace WMS.Web.Repositories
|
|||||||
public async Task<Box> Get(int id)
|
public async Task<Box> Get(int id)
|
||||||
{
|
{
|
||||||
var entity = await _context.Box.Include(x => x.Details)
|
var entity = await _context.Box.Include(x => x.Details)
|
||||||
.FirstOrDefaultAsync(f => f.Id.Equals(id));
|
.FirstOrDefaultAsync(f => f.Id.Equals(id) && f.IsDelete != true);
|
||||||
|
|
||||||
return entity.Clone();
|
return entity.Clone();
|
||||||
}
|
}
|
||||||
@@ -88,7 +88,7 @@ namespace WMS.Web.Repositories
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<List<BoxResponse>> GetBox(List<string> BoxBillNos)
|
public async Task<List<BoxResponse>> GetBox(List<string> BoxBillNos)
|
||||||
{
|
{
|
||||||
var list = await _context.Box.Include(x => x.Details).Where(f => BoxBillNos.Contains(f.BoxBillNo.ToLower())).ToListAsync();
|
var list = await _context.Box.Include(x => x.Details).Where(f => BoxBillNos.Contains(f.BoxBillNo.ToLower()) && f.IsDelete != true).ToListAsync();
|
||||||
var resList = _mapper.Map<List<BoxResponse>>(list);
|
var resList = _mapper.Map<List<BoxResponse>>(list);
|
||||||
|
|
||||||
var materials_result = await _erpService.BillQueryForMaterial();
|
var materials_result = await _erpService.BillQueryForMaterial();
|
||||||
@@ -153,14 +153,14 @@ namespace WMS.Web.Repositories
|
|||||||
public async Task<Box> GetByNo(string billNo)
|
public async Task<Box> GetByNo(string billNo)
|
||||||
{
|
{
|
||||||
var entity = await _context.Box.Include(x => x.Details)
|
var entity = await _context.Box.Include(x => x.Details)
|
||||||
.FirstOrDefaultAsync(f => f.BoxBillNo.Equals(billNo));
|
.FirstOrDefaultAsync(f => f.BoxBillNo.Equals(billNo) && f.IsDelete != true);
|
||||||
|
|
||||||
return entity.Clone();
|
return entity.Clone();
|
||||||
}
|
}
|
||||||
public async Task<List<Box>> GetEntityListByNos(List<string> billNos)
|
public async Task<List<Box>> GetEntityListByNos(List<string> billNos)
|
||||||
{
|
{
|
||||||
var entity = await _context.Box.Include(x => x.Details)
|
var entity = await _context.Box.Include(x => x.Details)
|
||||||
.Where(f => billNos.Contains(f.BoxBillNo)).ToListAsync();
|
.Where(f => billNos.Contains(f.BoxBillNo) && f.IsDelete != true).ToListAsync();
|
||||||
|
|
||||||
return entity.Clone();
|
return entity.Clone();
|
||||||
}
|
}
|
||||||
@@ -168,7 +168,7 @@ namespace WMS.Web.Repositories
|
|||||||
public async Task<List<string>> GetByNos(List<string> billNos)
|
public async Task<List<string>> GetByNos(List<string> billNos)
|
||||||
{
|
{
|
||||||
return await _context.Box
|
return await _context.Box
|
||||||
.Where(w => billNos.Contains(w.BoxBillNo)).Select(s => s.BoxBillNo).ToListAsync();
|
.Where(w => billNos.Contains(w.BoxBillNo) && w.IsDelete != true).Select(s => s.BoxBillNo).ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> AddRange(List<Box> entitys, bool isTransaction = true)
|
public async Task<bool> AddRange(List<Box> entitys, bool isTransaction = true)
|
||||||
@@ -203,41 +203,11 @@ namespace WMS.Web.Repositories
|
|||||||
{
|
{
|
||||||
var res = await _context.Box
|
var res = await _context.Box
|
||||||
.Include(s => s.Details)
|
.Include(s => s.Details)
|
||||||
.Where(f => ids.Contains(f.Id))
|
.Where(f => ids.Contains(f.Id) && f.IsDelete != true)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
return res.Clone();
|
return res.Clone();
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// 批量删除
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="billNos"></param>
|
|
||||||
/// <param name="isTransaction"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
/// <exception cref="NotImplementedException"></exception>
|
|
||||||
public async Task<bool> DeleteEntityList(List<int> boxIds, bool isTransaction = true)
|
|
||||||
{
|
|
||||||
IDbContextTransaction _transaction = null;
|
|
||||||
if (isTransaction)
|
|
||||||
_transaction = _context.Database.BeginTransaction();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var res = await _context.Box
|
|
||||||
.Include(s => s.Details)
|
|
||||||
.Where(f => boxIds.Contains(f.Id)).ToListAsync();
|
|
||||||
|
|
||||||
_context.Box.RemoveRange(res);
|
|
||||||
await _context.SaveChangesAsync();
|
|
||||||
if (_transaction != null)
|
|
||||||
_transaction.Commit();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
if (_transaction != null)
|
|
||||||
_transaction.Rollback();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user