From cc62a28ee77448cc721e218eb16623e36f865478 Mon Sep 17 00:00:00 2001 From: hehaibing-1996 Date: Wed, 5 Mar 2025 17:59:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=A9=BA=E8=B4=A7=E6=9E=B6?= =?UTF-8?q?=E3=80=81=E9=9D=9E=E7=A9=BA=E8=B4=A7=E6=9E=B6=20=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E6=9B=B4=E6=96=B0=20=E5=B9=B6=E4=B8=94=E5=91=BC?= =?UTF-8?q?=E5=8F=AB=E7=A9=BA=E8=B4=A7=E6=9E=B6=E6=8E=A5=E5=8F=A3=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E7=A9=BA=E8=B4=A7=E6=9E=B6=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WCS.BLL/Manager/DataProcessManager.cs | 46 ++++++++++--------- .../Service/BatchBindMatDetailService.cs | 3 ++ .../Service/MatDetailCurrentInfoService.cs | 2 + WCS.BLL/Services/Service/PDAMatBindService.cs | 1 + .../Services/Service/StockTakingService.cs | 1 + .../Controllers/PDAMatBindController.cs | 1 + .../PDAProductionLineCallOutController.cs | 3 ++ 7 files changed, 36 insertions(+), 21 deletions(-) diff --git a/WCS.BLL/Manager/DataProcessManager.cs b/WCS.BLL/Manager/DataProcessManager.cs index 1f223ab..58bb801 100644 --- a/WCS.BLL/Manager/DataProcessManager.cs +++ b/WCS.BLL/Manager/DataProcessManager.cs @@ -17,31 +17,35 @@ namespace WCS.BLL.Manager public static object flag = new object(); public static void UpdateShelfStatus() { - lock (flag) + Task.Run(() => { - var shelfIds = DbHelp.db.Queryable() - .Select(t => t.ShelfId) - .Distinct() - .ToList(); - var shelfInfos = DbHelp.db.Queryable().ToList(); + lock (flag) + { + var shelfIds = DbHelp.db.Queryable() + .Select(t => t.ShelfId) + .Distinct() + .ToList(); + var shelfInfos = DbHelp.db.Queryable().ToList(); - var notEmptyToEmpty = shelfInfos.Where(t => t.ShelfStatus == ShelfStatusEnum.非空货架) - .Where(t => !shelfIds.Contains(t.Id)) - .ToList(); - notEmptyToEmpty.ForEach(t => t.ShelfStatus = ShelfStatusEnum.空货架); + var notEmptyToEmpty = shelfInfos.Where(t => t.ShelfStatus == ShelfStatusEnum.非空货架) + .Where(t => !shelfIds.Contains(t.Id)) + .ToList(); + notEmptyToEmpty.ForEach(t => t.ShelfStatus = ShelfStatusEnum.空货架); - var emptyToNotEmpty = shelfInfos.Where(t => t.ShelfStatus == ShelfStatusEnum.空货架) - .Where(t => shelfIds.Contains(t.Id)) - .ToList(); - emptyToNotEmpty.ForEach(t => t.ShelfStatus = ShelfStatusEnum.非空货架); + var emptyToNotEmpty = shelfInfos.Where(t => t.ShelfStatus == ShelfStatusEnum.空货架) + .Where(t => shelfIds.Contains(t.Id)) + .ToList(); + 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(); - } } } } diff --git a/WCS.BLL/Services/Service/BatchBindMatDetailService.cs b/WCS.BLL/Services/Service/BatchBindMatDetailService.cs index 6cae0b2..b068cec 100644 --- a/WCS.BLL/Services/Service/BatchBindMatDetailService.cs +++ b/WCS.BLL/Services/Service/BatchBindMatDetailService.cs @@ -166,6 +166,7 @@ namespace WCS.BLL.Services.Service else { DbHelp.db.CommitTran(); + DataProcessManager.UpdateShelfStatus(); return new ResponseCommon { Code = 200, @@ -226,6 +227,7 @@ namespace WCS.BLL.Services.Service var deleteRows = await DbHelp.db.Deleteable(matDetailCurrentInfos).ExecuteCommandAsync(); DbHelp.db.CommitTran(); + DataProcessManager.UpdateShelfStatus(); return new ResponseCommon { Code = 200, @@ -467,6 +469,7 @@ namespace WCS.BLL.Services.Service } await DbHelp.db.CommitTranAsync(); + DataProcessManager.UpdateShelfStatus(); return new ResponseCommon>() { Code = 200, diff --git a/WCS.BLL/Services/Service/MatDetailCurrentInfoService.cs b/WCS.BLL/Services/Service/MatDetailCurrentInfoService.cs index 19d6173..f38c2b9 100644 --- a/WCS.BLL/Services/Service/MatDetailCurrentInfoService.cs +++ b/WCS.BLL/Services/Service/MatDetailCurrentInfoService.cs @@ -232,6 +232,7 @@ namespace WCS.BLL.Services.Service else { DbHelp.db.CommitTran(); + DataProcessManager.UpdateShelfStatus(); return new ResponseCommon { Code = 200, @@ -294,6 +295,7 @@ namespace WCS.BLL.Services.Service var deleteRows = await DbHelp.db.Deleteable(matDetailCurrentInfos).ExecuteCommandAsync(); DbHelp.db.CommitTran(); + DataProcessManager.UpdateShelfStatus(); return new ResponseCommon { Code = 200, diff --git a/WCS.BLL/Services/Service/PDAMatBindService.cs b/WCS.BLL/Services/Service/PDAMatBindService.cs index 77b4fa3..3a9eca7 100644 --- a/WCS.BLL/Services/Service/PDAMatBindService.cs +++ b/WCS.BLL/Services/Service/PDAMatBindService.cs @@ -82,6 +82,7 @@ namespace WCS.BLL.Services.Service //获取空货架进行呼叫 shelf = await DbHelp.db.Queryable() .Where(t => t.TransStatus == TransStatusEnum.静止 && t.CurrentLocationId != 0) + .Where(t => t.ShelfStatus == ShelfStatusEnum.空货架) .Where(t => t.ShelfTypeId == request.NeedShelfTypeId) .Where(t => t.IsEnable == true) .FirstAsync(); diff --git a/WCS.BLL/Services/Service/StockTakingService.cs b/WCS.BLL/Services/Service/StockTakingService.cs index 61b3e82..f9ab31b 100644 --- a/WCS.BLL/Services/Service/StockTakingService.cs +++ b/WCS.BLL/Services/Service/StockTakingService.cs @@ -1541,6 +1541,7 @@ namespace WCS.BLL.Services.Service DbHelp.db.Updateable(stocktakingInfo).ExecuteCommand(); } DbHelp.db.CommitTran(); + DataProcessManager.UpdateShelfStatus(); return new ResponseCommon() { Code = 200, diff --git a/WCS.WebApi/Controllers/PDAMatBindController.cs b/WCS.WebApi/Controllers/PDAMatBindController.cs index dda1c49..14b0cc6 100644 --- a/WCS.WebApi/Controllers/PDAMatBindController.cs +++ b/WCS.WebApi/Controllers/PDAMatBindController.cs @@ -405,6 +405,7 @@ namespace WCS.WebApi.Controllers DbHelp.db.Insertable(historyInfo).ExecuteCommand(); DbHelp.db.CommitTran(); + DataProcessManager.UpdateShelfStatus(); return new ResponseCommon() { Code = 200, diff --git a/WCS.WebApi/Controllers/PDAProductionLineCallOutController.cs b/WCS.WebApi/Controllers/PDAProductionLineCallOutController.cs index c689de0..20f2f76 100644 --- a/WCS.WebApi/Controllers/PDAProductionLineCallOutController.cs +++ b/WCS.WebApi/Controllers/PDAProductionLineCallOutController.cs @@ -203,6 +203,7 @@ namespace WCS.WebApi.Controllers else { DbHelp.db.CommitTran(); + DataProcessManager.UpdateShelfStatus(); return new ResponseCommon { Code = 200, @@ -347,6 +348,7 @@ namespace WCS.WebApi.Controllers } DbHelp.db.Deleteable(matCurrentInfos).ExecuteCommand(); DbHelp.db.CommitTran(); + DataProcessManager.UpdateShelfStatus(); } catch (Exception ex) { @@ -369,6 +371,7 @@ namespace WCS.WebApi.Controllers //库存更新记录 //全部删除 删除数量为0的 DbHelp.db.Deleteable(matCurrentInfos).ExecuteCommand(); + DataProcessManager.UpdateShelfStatus(); } #endregion