diff --git a/src/WMS.Web.Core/Dto/OutStockTask/OutStockTaskQueryInfoResponse.cs b/src/WMS.Web.Core/Dto/OutStockTask/OutStockTaskQueryInfoResponse.cs
index 500b22f9..2f10f337 100644
--- a/src/WMS.Web.Core/Dto/OutStockTask/OutStockTaskQueryInfoResponse.cs
+++ b/src/WMS.Web.Core/Dto/OutStockTask/OutStockTaskQueryInfoResponse.cs
@@ -142,7 +142,13 @@ namespace WMS.Web.Core.Dto.OutStockTask
///
[Column("创建时间")]
public string CreateTime { get; set; }
+ ///
+ /// 是否作废
+ ///
+ [Column("是否作废")]
+ public bool IsRepeal { get; set; }
-
+
+
}
}
diff --git a/src/WMS.Web.Domain/Entitys/OutStockTask.cs b/src/WMS.Web.Domain/Entitys/OutStockTask.cs
index f5dcc81d..a0dff96b 100644
--- a/src/WMS.Web.Domain/Entitys/OutStockTask.cs
+++ b/src/WMS.Web.Domain/Entitys/OutStockTask.cs
@@ -191,11 +191,17 @@ namespace WMS.Web.Domain.Entitys
///
/// 作废
///
- public void Repeal(int creatorId)
+ public void Repeal(int creatorId, List ids)
{
this.OperatorId = creatorId;
this.OperateTime = DateTime.Now;
- this.Status = OutStockStatus.Repeal;
+ foreach (var d in this.Details.Where(w => ids.Contains(w.Id)))
+ {
+ d.IsRepeal = true;
+ }
+ //如果明细全部作废,则单据状态作废
+ if (this.Details.Where(w => w.IsRepeal == true).Count() == this.Details.Count())
+ this.Status = OutStockStatus.Repeal;
}
///
/// 合并
diff --git a/src/WMS.Web.Domain/Entitys/OutStockTaskDetails.cs b/src/WMS.Web.Domain/Entitys/OutStockTaskDetails.cs
index 14f2f55f..0bc8466b 100644
--- a/src/WMS.Web.Domain/Entitys/OutStockTaskDetails.cs
+++ b/src/WMS.Web.Domain/Entitys/OutStockTaskDetails.cs
@@ -63,6 +63,11 @@ namespace WMS.Web.Domain.Entitys
[Column("OutStockEndTime")]
public DateTime? OutStockEndTime { get; set; }
///
+ /// 是否作废
+ ///
+ [Column("IsRepeal")]
+ public bool? IsRepeal { get; set; } = false;
+ ///
/// 对应erp明细 同一个物料 存在于不同的来源单中(合并后出现多条)
///
public List ErpDetails { get; set; } = new List();
diff --git a/src/WMS.Web.Domain/Infrastructure/IOutStockTaskRepositories.cs b/src/WMS.Web.Domain/Infrastructure/IOutStockTaskRepositories.cs
index 7aa1a64c..5663c7a0 100644
--- a/src/WMS.Web.Domain/Infrastructure/IOutStockTaskRepositories.cs
+++ b/src/WMS.Web.Domain/Infrastructure/IOutStockTaskRepositories.cs
@@ -22,6 +22,8 @@ namespace WMS.Web.Domain.Infrastructure
Task<(List list, int total)> GetListAsync(OutStockTaskQueryRequest dto, int companyId = 0);
/// 查询实体集合
Task> GetEntityList(List ids);
+ /// 查询实体集合(明细Id)
+ Task> GetEntityListByDetailIds(List ids);
///
/// 列表-根据明细中的来源单号精确匹配
///
diff --git a/src/WMS.Web.Domain/Services/OutStockTaskService.cs b/src/WMS.Web.Domain/Services/OutStockTaskService.cs
index 53bf5dbd..9ce7c40e 100644
--- a/src/WMS.Web.Domain/Services/OutStockTaskService.cs
+++ b/src/WMS.Web.Domain/Services/OutStockTaskService.cs
@@ -54,11 +54,13 @@ namespace WMS.Web.Domain.Services
///
public async Task Repeal(OperateRequest dto, LoginInDto loginInfo)
{
- var list = await _outStockTaskRepositories.GetEntityList(dto.Ids);
+ var list = await _outStockTaskRepositories.GetEntityListByDetailIds(dto.Ids);
foreach (var entity in list)
{
+ List e_ids = entity.Details.Select(s => s.Id).ToList();
+ var j_ids = e_ids.Intersect(dto.Ids).ToList();
//作废
- entity.Repeal(loginInfo.UserInfo.StaffId);
+ entity.Repeal(loginInfo.UserInfo.StaffId, j_ids);
}
var isSuccess = await _outStockTaskRepositories.EditEntityList(list, true);
if (!isSuccess) return Result.ReFailure(ResultCodes.DateWriteError);
@@ -373,7 +375,7 @@ namespace WMS.Web.Domain.Services
if (!isSuccess)
return Result.ReFailure(ResultCodes.DateWriteError);
-
+
return Result.ReSuccess();
}
@@ -424,13 +426,13 @@ namespace WMS.Web.Domain.Services
if (!result.IsSuccess) isRollback = true;
}
-
+
//4.提交事务
isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction);
_redisClientService.SetStringKey($"wms_outstock_sync", false, TimeSpan.FromMinutes(5));
if (!isSuccess)
return Result.ReFailure(ResultCodes.DateWriteError);
-
+
return Result.ReSuccess();
}
diff --git a/src/WMS.Web.Repositories/OutStockTaskRepositories.cs b/src/WMS.Web.Repositories/OutStockTaskRepositories.cs
index ee0f7abf..5a3a9fa9 100644
--- a/src/WMS.Web.Repositories/OutStockTaskRepositories.cs
+++ b/src/WMS.Web.Repositories/OutStockTaskRepositories.cs
@@ -178,6 +178,20 @@ namespace WMS.Web.Repositories
return res.Clone();
}
+ ///
+ /// 根据明细id查找
+ ///
+ ///
+ ///
+ public async Task> GetEntityListByDetailIds(List ids)
+ {
+ var res = await _context.OutStockTask
+ .Include(s => s.Details).ThenInclude(s => s.ErpDetails)
+ .Where(f => f.Details.Where(dw => ids.Contains(dw.Id)).Count() > 0)
+ .ToListAsync();
+
+ return res.Clone();
+ }
///
/// 编辑
@@ -311,6 +325,7 @@ namespace WMS.Web.Repositories
AccruedQty = s.detail.AccruedQty,
RealityQty = s.detail.RealityQty,
CreateTime = s.order.CreateTime.DateToStringSeconds(),
+ IsRepeal = s.detail.IsRepeal ?? false,
OperateTime = s.order.OperateTime.DateToStringSeconds(),
Operator = _singleDataService.GetSingleData(SingleAction.Staffs, companyId, s.order.OperatorId ?? 0),
OutStockTime = s.order.OutStockTime.DateToStringSeconds(),
@@ -353,7 +368,7 @@ namespace WMS.Web.Repositories
List ids = new List();
List list = new List();
- var list1 = await _context.OutStockTask.Include(x => x.Details).ThenInclude(s => s.ErpDetails)
+ var list1 = await _context.OutStockTask.Include(x => x.Details.Where(w => w.IsRepeal != true)).ThenInclude(s => s.ErpDetails)
.Where(f => EF.Functions.Like(f.BillNo, "%" + billNo + "%") &&
(f.Status == OutStockStatus.Part || f.Status == OutStockStatus.Wait))
.OrderByDescending(o => o.Id)
@@ -361,7 +376,7 @@ namespace WMS.Web.Repositories
if (list1 != null && list1.Count() > 0)
list.AddRange(list1);
- var list2 = await _context.OutStockTask.Include(x => x.Details).ThenInclude(s => s.ErpDetails)
+ var list2 = await _context.OutStockTask.Include(x => x.Details.Where(w => w.IsRepeal != true)).ThenInclude(s => s.ErpDetails)
.Where(f => (f.Details.SelectMany(s => s.ErpDetails).Where(w => EF.Functions.Like(w.SourceBillNo, "%" + billNo + "%")).Any()) &&
(f.Status == OutStockStatus.Part || f.Status == OutStockStatus.Wait))
.OrderByDescending(o => o.Id)
@@ -398,7 +413,7 @@ namespace WMS.Web.Repositories
return new GetOutStockTaskByNoResponse();
var materials = materials_result.Data.ToList();
- var entity = await _context.OutStockTask.Include(x => x.Details).ThenInclude(s => s.ErpDetails)
+ var entity = await _context.OutStockTask.Include(x => x.Details.Where(w => w.IsRepeal != true)).ThenInclude(s => s.ErpDetails)
.FirstOrDefaultAsync(f => f.BillNo.Equals(billNo) &&
(f.Status == OutStockStatus.Part || f.Status == OutStockStatus.Wait));
@@ -471,14 +486,14 @@ namespace WMS.Web.Repositories
public async Task> GetOutStockTaskNosByNo(string billNo)
{
- var res = await _context.OutStockTask.Include(x => x.Details).ThenInclude(s => s.ErpDetails)
+ var res = await _context.OutStockTask.Include(x => x.Details.Where(w => w.IsRepeal != true)).ThenInclude(s => s.ErpDetails)
.Where(f => EF.Functions.Like(f.BillNo, "%" + billNo + "%") &&
(f.Status == OutStockStatus.Part || f.Status == OutStockStatus.Wait))
.OrderByDescending(o => o.Id)
.Select(s => s.BillNo)
.ToListAsync();
- var ress = await _context.OutStockTask.Include(x => x.Details).ThenInclude(s => s.ErpDetails)
+ var ress = await _context.OutStockTask.Include(x => x.Details.Where(w => w.IsRepeal != true)).ThenInclude(s => s.ErpDetails)
.Where(f => (f.Details.SelectMany(s => s.ErpDetails).Where(w => EF.Functions.Like(w.SourceBillNo, "%" + billNo + "%")).Any()) &&
(f.Status == OutStockStatus.Part || f.Status == OutStockStatus.Wait))
.OrderByDescending(o => o.Id)
@@ -514,5 +529,6 @@ namespace WMS.Web.Repositories
return entitys.Clone();
}
+
}
}