电梯控制bug处理 包材出库逻辑变更

This commit is contained in:
2024-07-12 15:11:11 +08:00
parent a75fc548cb
commit f4cf422a83
15 changed files with 283 additions and 156 deletions

View File

@@ -43,6 +43,7 @@ using Tnb.ProductionMgr.Entities;
using Tnb.ProductionMgr.Entities.Dto;
using Tnb.ProductionMgr.Entities.Enums;
using Tnb.ProductionMgr.Interfaces;
using Tnb.WarehouseMgr;
using Tnb.WarehouseMgr.Entities;
using Tnb.WarehouseMgr.Entities.Configs;
using Tnb.WarehouseMgr.Entities.Consts;
@@ -78,6 +79,9 @@ namespace Tnb.ProductionMgr
private static Timer? Floor2timer移走上升降区未生成预任务且满托的料架;
private static Timer? Floor2timer移走下升降区未生成预任务且空托的料架;
// 四楼包材自动到二楼包材库
private static Timer? PackOutstockServicetimer;
public SemaphoreSlim s_taskCheckGet = new(1);
public SemaphoreSlim s_taskScan = new(1);
public SemaphoreSlim s_taskSSXcode = new(1);
@@ -89,6 +93,7 @@ namespace Tnb.ProductionMgr
public SemaphoreSlim s_task送满托到下升降区 = new(1);
public SemaphoreSlim s_task移走上升降区未生成预任务且满托的料架 = new(1);
public SemaphoreSlim s_task移走下升降区未生成预任务且空托的料架 = new(1);
public SemaphoreSlim s_taskPackOutstockService = new(1);
private StackExRedisHelper _redisData;
private readonly IPrdInstockService _prdInstockService;
@@ -104,6 +109,7 @@ namespace Tnb.ProductionMgr
private ISqlSugarClient db_Floor2timer送满托到下升降区;
private ISqlSugarClient db_Floor2timer移走上升降区未生成预任务且满托的料架;
private ISqlSugarClient db_Floor2timer移走下升降区未生成预任务且空托的料架;
private ISqlSugarClient db_PackOutstockService;
private readonly IWmsPDAScanInStockService _wmsPDAScanInStock;
private readonly IUserManager _userManager;
private readonly IBillRullService _billRullService;
@@ -111,6 +117,7 @@ namespace Tnb.ProductionMgr
private readonly IWmsCarryBindService _wmsCarryBindService;
private readonly IWmsCarryUnbindService _wmsCarryUnbindService;
private readonly IWmsEmptyOutstockService _wmsEmptyOutstockService;
private readonly IWmsPackOutstockService _wmsPackOutstockService;
private readonly ElevatorControlConfiguration _eleCtlCfg = App.Configuration.Build<ElevatorControlConfiguration>();
@@ -127,7 +134,7 @@ namespace Tnb.ProductionMgr
#region
public RedisBackGround(StackExRedisHelper redisData, IPrdInstockService prdInstockService, ISqlSugarRepository<RedisReadConfig> repository, IWmsPDAScanInStockService wmsPDAScanInStock
, IUserManager userManager, IBillRullService billRullService, IWareHouseService wareHouseService, IWmsCarryBindService wmsCarryBindService,
IWmsCarryUnbindService wmsCarryUnbindService, IWmsEmptyOutstockService wmsEmptyOutstockService)
IWmsCarryUnbindService wmsCarryUnbindService, IWmsEmptyOutstockService wmsEmptyOutstockService, IWmsPackOutstockService wmsPackOutstockService)
{
_redisData = redisData;
_prdInstockService = prdInstockService;
@@ -139,6 +146,7 @@ namespace Tnb.ProductionMgr
_wmsCarryBindService = wmsCarryBindService;
_wmsEmptyOutstockService = wmsEmptyOutstockService;
_wmsCarryUnbindService = wmsCarryUnbindService;
_wmsPackOutstockService = wmsPackOutstockService;
db_CheckGettimer = repository.CopyNew();
db_Scantimer = repository.CopyNew();
@@ -151,7 +159,7 @@ namespace Tnb.ProductionMgr
db_Floor2timer送满托到下升降区 = repository.CopyNew();
db_Floor2timer移走上升降区未生成预任务且满托的料架 = repository.CopyNew();
db_Floor2timer移走下升降区未生成预任务且空托的料架 = repository.CopyNew();
db_PackOutstockService = repository.CopyNew();
}
#endregion
@@ -912,7 +920,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
List<WmsMaterialTransfer> WmsMaterialTransfers = db_Floor2UpMachinecodetimer.Queryable<WmsMaterialTransfer>()
.InnerJoin<WmsMaterialTransferCarry>((a, b) => a.id == b.bill_id)
.Where((a, b) => a.warehouse_instock == "33780009364245" && a.warehouse_outstock == "2" && a.remainbindracknum > 0
&& b.carry_code == barcode).ToList();
&& b.carry_code == barcode && a.status != WmsWareHouseConst.BILLSTATUS_COMPLETE_ID).ToList();
if (WmsMaterialTransfers.Count() == 0)
{
@@ -1187,7 +1195,8 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
catch (Exception ex)
{
Console.WriteLine("【上升降机】" + ex.Message);
LoggerFloor2RackDelivery.LogError($"【送空托到上升降区】 数据库连接异常:{ex}");
LoggerFloor2RackDelivery.LogError($"【送空托到上升降区】 {ex.Message}");
LoggerFloor2RackDelivery.LogError($"【送空托到上升降区】 {ex.StackTrace}");
// 数据库连接断开时会报错
try { await db_Floor2timer送空托到上升降区.Ado.RollbackTranAsync(); } catch { };
}
@@ -1355,7 +1364,8 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
catch (Exception ex)
{
Console.WriteLine("【上升降机】" + ex.Message);
LoggerFloor2RackDelivery.LogError($"【送满托到下升降区】 数据库连接异常:{ex}");
LoggerFloor2RackDelivery.LogError($"【送满托到下升降区】 {ex.Message}");
LoggerFloor2RackDelivery.LogError($"【送满托到下升降区】 {ex.StackTrace}");
// 数据库连接断开时会报错
try { await db_Floor2timer送满托到下升降区.Ado.RollbackTranAsync(); } catch { };
}
@@ -1470,7 +1480,8 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
catch (Exception ex)
{
Console.WriteLine("【上升降机】" + ex.Message);
LoggerFloor2RackDelivery.LogError($"【移走上升降区未生成预任务且满托的料架】 数据库连接异常:{ex}");
LoggerFloor2RackDelivery.LogError($"【移走上升降区未生成预任务且满托的料架】{ex.Message}");
LoggerFloor2RackDelivery.LogError($"【移走上升降区未生成预任务且满托的料架】{ex.StackTrace}");
// 数据库连接断开时会报错
try { await db_Floor2timer移走上升降区未生成预任务且满托的料架.Ado.RollbackTranAsync(); } catch { };
}
@@ -1580,8 +1591,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
LoggerFloor2RackDelivery.LogInformation($"【移走下升降区空托的料架】 开始执行预任务生成: 料架区为{wmsMechanicalArmH.name}{wmsMechanicalArmH.stackingposition} 料架为{wmsMechanicalArmH.rackcode}");
WmsMaterialTransfer wmsMaterialTransfer = await db_Floor2timer移走下升降区未生成预任务且空托的料架.Queryable<WmsMaterialTransfer>().Where(r => r.bill_code == wmsMechanicalArmH.outbill).FirstAsync();
bool result = await createPretask(wmsMechanicalArmH.location_id, endLocation.id, wmsMechanicalArmH.rackid, wmsMechanicalArmH.rackcode, LoggerFloor2RackDelivery, db_Floor2timer移走下升降区未生成预任务且空托的料架, true, wmsMaterialTransfer.id);
bool result = await createPretask(wmsMechanicalArmH.location_id, endLocation.id, wmsMechanicalArmH.rackid, wmsMechanicalArmH.rackcode, LoggerFloor2RackDelivery, db_Floor2timer移走下升降区未生成预任务且空托的料架, true);
if (!result)
{
LoggerFloor2RackDelivery.LogInformation($"【移走下升降区空托的料架】 未成功生成预任务 起点{wmsMechanicalArmH.location_code} 终点{endLocation.location_code} 料架 {wmsMechanicalArmH.rackcode}");
@@ -1600,8 +1610,9 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
}
catch (Exception ex)
{
Console.WriteLine("【上升降机】" + ex.Message);
LoggerFloor2RackDelivery.LogError($"【移走下升降区空托的料架】 数据库连接异常:{ex}");
Console.WriteLine("【移走下升降区空托的料架】" + ex.Message);
LoggerFloor2RackDelivery.LogError($"【移走下升降区空托的料架】{ex.Message}");
LoggerFloor2RackDelivery.LogError($"【移走下升降区空托的料架】{ex.StackTrace}");
// 数据库连接断开时会报错
try { await db_Floor2timer移走下升降区未生成预任务且空托的料架.Ado.RollbackTranAsync(); } catch { };
}
@@ -1653,6 +1664,41 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
return false;
}
/// <summary>
/// 四楼包材自动到二楼包材库
/// </summary>
/// <param name="args"></param>
public async void PackOutstockService(object? args)
{
if (s_taskPackOutstockService.CurrentCount == 0)
return;
await s_taskPackOutstockService.WaitAsync();
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
try
{
Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} 开始执行四楼包材自动到二楼包材库");
LoggerTimer.LogInformation($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} 开始执行四楼包材自动到二楼包材库");
await _wmsPackOutstockService.Distribute();
}
catch (Exception ex)
{
Console.WriteLine("【四楼包材自动到二楼包材库】" + ex.Message);
LoggerFloor2RackDelivery.LogError($"【四楼包材自动到二楼包材库】{ex.Message}");
LoggerFloor2RackDelivery.LogError($"【四楼包材自动到二楼包材库】{ex.StackTrace}");
}
finally
{
s_taskPackOutstockService.Release();
stopwatch.Stop();
Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} 结束四楼包材自动到二楼包材库 {stopwatch.ElapsedMilliseconds} ms");
LoggerTimer.LogInformation($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} 结束执行四楼包材自动到二楼包材库 {stopwatch.ElapsedMilliseconds} ms");
}
}
#region
public async Task<bool> GetBoolTag(string DevName, string field)
@@ -1795,7 +1841,9 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
Floor2timer移走下升降区未生成预任务且空托的料架 = new Timer(, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
GenTaskExecutetimer = new Timer(GenTaskExecute, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
PackOutstockServicetimer = new Timer(PackOutstockService, null, TimeSpan.Zero, TimeSpan.FromSeconds(60));
return Task.CompletedTask;
}