增加空货架、非空货架 状态更新 并且呼叫空货架接口增加空货架限制

This commit is contained in:
hehaibing-1996
2025-03-05 17:59:33 +08:00
parent 2381624be4
commit cc62a28ee7
7 changed files with 36 additions and 21 deletions

View File

@ -17,31 +17,35 @@ namespace WCS.BLL.Manager
public static object flag = new object(); public static object flag = new object();
public static void UpdateShelfStatus() public static void UpdateShelfStatus()
{ {
lock (flag) Task.Run(() =>
{ {
var shelfIds = DbHelp.db.Queryable<MatDetailCurrentInfo>() lock (flag)
.Select(t => t.ShelfId) {
.Distinct() var shelfIds = DbHelp.db.Queryable<MatDetailCurrentInfo>()
.ToList(); .Select(t => t.ShelfId)
var shelfInfos = DbHelp.db.Queryable<ShelfInfo>().ToList(); .Distinct()
.ToList();
var shelfInfos = DbHelp.db.Queryable<ShelfInfo>().ToList();
var notEmptyToEmpty = shelfInfos.Where(t => t.ShelfStatus == ShelfStatusEnum.) var notEmptyToEmpty = shelfInfos.Where(t => t.ShelfStatus == ShelfStatusEnum.)
.Where(t => !shelfIds.Contains(t.Id)) .Where(t => !shelfIds.Contains(t.Id))
.ToList(); .ToList();
notEmptyToEmpty.ForEach(t => t.ShelfStatus = ShelfStatusEnum.); notEmptyToEmpty.ForEach(t => t.ShelfStatus = ShelfStatusEnum.);
var emptyToNotEmpty = shelfInfos.Where(t => t.ShelfStatus == ShelfStatusEnum.) var emptyToNotEmpty = shelfInfos.Where(t => t.ShelfStatus == ShelfStatusEnum.)
.Where(t => shelfIds.Contains(t.Id)) .Where(t => shelfIds.Contains(t.Id))
.ToList(); .ToList();
emptyToNotEmpty.ForEach(t => t.ShelfStatus = ShelfStatusEnum.); emptyToNotEmpty.ForEach(t => t.ShelfStatus = ShelfStatusEnum.);
DbHelp.db.Updateable(notEmptyToEmpty)
.UpdateColumns(t => new { t.ShelfStatus })
.ExecuteCommand();
DbHelp.db.Updateable(emptyToNotEmpty)
.UpdateColumns(t => new { t.ShelfStatus })
.ExecuteCommand();
}
});
DbHelp.db.Updateable(notEmptyToEmpty)
.UpdateColumns(t => new { t.ShelfStatus })
.ExecuteCommand();
DbHelp.db.Updateable(emptyToNotEmpty)
.UpdateColumns(t => new { t.ShelfStatus })
.ExecuteCommand();
}
} }
} }
} }

View File

@ -166,6 +166,7 @@ namespace WCS.BLL.Services.Service
else else
{ {
DbHelp.db.CommitTran(); DbHelp.db.CommitTran();
DataProcessManager.UpdateShelfStatus();
return new ResponseCommon<Object> return new ResponseCommon<Object>
{ {
Code = 200, Code = 200,
@ -226,6 +227,7 @@ namespace WCS.BLL.Services.Service
var deleteRows = await DbHelp.db.Deleteable(matDetailCurrentInfos).ExecuteCommandAsync(); var deleteRows = await DbHelp.db.Deleteable(matDetailCurrentInfos).ExecuteCommandAsync();
DbHelp.db.CommitTran(); DbHelp.db.CommitTran();
DataProcessManager.UpdateShelfStatus();
return new ResponseCommon<Object> return new ResponseCommon<Object>
{ {
Code = 200, Code = 200,
@ -467,6 +469,7 @@ namespace WCS.BLL.Services.Service
} }
await DbHelp.db.CommitTranAsync(); await DbHelp.db.CommitTranAsync();
DataProcessManager.UpdateShelfStatus();
return new ResponseCommon<List<string>>() return new ResponseCommon<List<string>>()
{ {
Code = 200, Code = 200,

View File

@ -232,6 +232,7 @@ namespace WCS.BLL.Services.Service
else else
{ {
DbHelp.db.CommitTran(); DbHelp.db.CommitTran();
DataProcessManager.UpdateShelfStatus();
return new ResponseCommon<Object> return new ResponseCommon<Object>
{ {
Code = 200, Code = 200,
@ -294,6 +295,7 @@ namespace WCS.BLL.Services.Service
var deleteRows = await DbHelp.db.Deleteable(matDetailCurrentInfos).ExecuteCommandAsync(); var deleteRows = await DbHelp.db.Deleteable(matDetailCurrentInfos).ExecuteCommandAsync();
DbHelp.db.CommitTran(); DbHelp.db.CommitTran();
DataProcessManager.UpdateShelfStatus();
return new ResponseCommon<Object> return new ResponseCommon<Object>
{ {
Code = 200, Code = 200,

View File

@ -82,6 +82,7 @@ namespace WCS.BLL.Services.Service
//获取空货架进行呼叫 //获取空货架进行呼叫
shelf = await DbHelp.db.Queryable<ShelfInfo>() shelf = await DbHelp.db.Queryable<ShelfInfo>()
.Where(t => t.TransStatus == TransStatusEnum. && t.CurrentLocationId != 0) .Where(t => t.TransStatus == TransStatusEnum. && t.CurrentLocationId != 0)
.Where(t => t.ShelfStatus == ShelfStatusEnum.)
.Where(t => t.ShelfTypeId == request.NeedShelfTypeId) .Where(t => t.ShelfTypeId == request.NeedShelfTypeId)
.Where(t => t.IsEnable == true) .Where(t => t.IsEnable == true)
.FirstAsync(); .FirstAsync();

View File

@ -1541,6 +1541,7 @@ namespace WCS.BLL.Services.Service
DbHelp.db.Updateable(stocktakingInfo).ExecuteCommand(); DbHelp.db.Updateable(stocktakingInfo).ExecuteCommand();
} }
DbHelp.db.CommitTran(); DbHelp.db.CommitTran();
DataProcessManager.UpdateShelfStatus();
return new ResponseCommon<object>() return new ResponseCommon<object>()
{ {
Code = 200, Code = 200,

View File

@ -405,6 +405,7 @@ namespace WCS.WebApi.Controllers
DbHelp.db.Insertable(historyInfo).ExecuteCommand(); DbHelp.db.Insertable(historyInfo).ExecuteCommand();
DbHelp.db.CommitTran(); DbHelp.db.CommitTran();
DataProcessManager.UpdateShelfStatus();
return new ResponseCommon() return new ResponseCommon()
{ {
Code = 200, Code = 200,

View File

@ -203,6 +203,7 @@ namespace WCS.WebApi.Controllers
else else
{ {
DbHelp.db.CommitTran(); DbHelp.db.CommitTran();
DataProcessManager.UpdateShelfStatus();
return new ResponseCommon<Object> return new ResponseCommon<Object>
{ {
Code = 200, Code = 200,
@ -347,6 +348,7 @@ namespace WCS.WebApi.Controllers
} }
DbHelp.db.Deleteable(matCurrentInfos).ExecuteCommand(); DbHelp.db.Deleteable(matCurrentInfos).ExecuteCommand();
DbHelp.db.CommitTran(); DbHelp.db.CommitTran();
DataProcessManager.UpdateShelfStatus();
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -369,6 +371,7 @@ namespace WCS.WebApi.Controllers
//库存更新记录 //库存更新记录
//全部删除 删除数量为0的 //全部删除 删除数量为0的
DbHelp.db.Deleteable(matCurrentInfos).ExecuteCommand(); DbHelp.db.Deleteable(matCurrentInfos).ExecuteCommand();
DataProcessManager.UpdateShelfStatus();
} }
#endregion #endregion