二楼空托到码垛线,库存报表变更
This commit is contained in:
@@ -90,6 +90,9 @@ namespace Tnb.ProductionMgr
|
||||
private static Timer? PackOutstockServicetimer;
|
||||
// 检查到电梯任务异常断开后处理
|
||||
private Thread? ElevatorTaskExceptionHandleThread;
|
||||
// 二楼空托盘自动补充到线边
|
||||
private static Timer? F2KTPsupplementtimer;
|
||||
|
||||
|
||||
public SemaphoreSlim s_taskCheckGet = new(1);
|
||||
public SemaphoreSlim s_taskScan = new(1);
|
||||
@@ -106,6 +109,7 @@ namespace Tnb.ProductionMgr
|
||||
public SemaphoreSlim s_taskFloor4DMJ2MJXService = new(1);
|
||||
public SemaphoreSlim s_taskFloor4MJX2MJCService = new(1);
|
||||
public SemaphoreSlim s_taskFloor4DMC2CPKService = new(1);
|
||||
public SemaphoreSlim s_taskF2KTPsupplement = new(1);
|
||||
|
||||
private StackExRedisHelper _redisData;
|
||||
private readonly IPrdInstockService _prdInstockService;
|
||||
@@ -127,7 +131,8 @@ namespace Tnb.ProductionMgr
|
||||
private ISqlSugarClient db_Floor4MJX2MJC;
|
||||
private ISqlSugarClient db_Floor4DMC2CPK;
|
||||
private ISqlSugarClient db_ElevatorTaskExceptionHandle;
|
||||
|
||||
private ISqlSugarClient db_F2KTPsupplement;
|
||||
|
||||
|
||||
private readonly IWmsPDAScanInStockService _wmsPDAScanInStock;
|
||||
private readonly IUserManager _userManager;
|
||||
@@ -183,6 +188,7 @@ namespace Tnb.ProductionMgr
|
||||
db_Floor4MJX2MJC = repository.CopyNew();
|
||||
db_Floor4DMC2CPK = repository.CopyNew();
|
||||
db_ElevatorTaskExceptionHandle = repository.CopyNew();
|
||||
db_F2KTPsupplement = repository.CopyNew();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -1922,13 +1928,11 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} 开始执行四楼待灭菌仓到灭菌线");
|
||||
LoggerTimer.LogInformation($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} 开始执行四楼待灭菌仓到灭菌线");
|
||||
|
||||
if (true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Dictionary<string, string[]> putdic = new Dictionary<string, string[]>();
|
||||
putdic.Add("SLD1", new string[] { "设备名", "信号" });
|
||||
putdic.Add("MJQ-FAN01", new string[] { "4楼上料输送西区", "上料工位1请求送盘" });
|
||||
putdic.Add("MJQ-FAN02", new string[] { "4楼上料输送西区", "上料工位2请求送盘" });
|
||||
putdic.Add("MJQ-FAN03", new string[] { "4楼上料输送西区", "上料工位3请求送盘" });
|
||||
putdic.Add("MJQ-FAN04", new string[] { "4楼上料输送西区", "上料工位4请求送盘" });
|
||||
|
||||
//Dictionary<BasLocation, string[]> putdic = new Dictionary<BasLocation, string[]>();
|
||||
//List<BasLocation> endLocations = db_Floor4DMJ2MJX.Queryable<BasLocation>().Where(r => r.wh_id == WmsWareHouseConst.WAREHOUSE_DMJC_ID
|
||||
@@ -1958,7 +1962,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
|
||||
if (items.Count < 1)
|
||||
{
|
||||
LoggerFloor4DMJ2MJX.LogWarning($"【四楼待灭菌仓到灭菌线】 没有可以出库的空载具");
|
||||
LoggerFloor4DMJ2MJX.LogWarning($"【四楼待灭菌仓到灭菌线】 没有可以出库的载具");
|
||||
break;
|
||||
}
|
||||
BasLocation endlocation = await db_Floor4DMJ2MJX.Queryable<BasLocation>().Where(r => r.location_code == key).FirstAsync();
|
||||
@@ -2027,13 +2031,9 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} 开始执行四楼待灭菌线到灭菌仓");
|
||||
LoggerTimer.LogInformation($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} 开始执行四楼待灭菌线到灭菌仓");
|
||||
|
||||
if (true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Dictionary<string, string[]> getdic = new Dictionary<string, string[]>();
|
||||
getdic.Add("SLD1", new string[] { "设备名", "信号", "条码信号" });
|
||||
getdic.Add("MJQ-QU02", new string[] { "4下上料输送西区", "下料工位2请求取盘", "下料工位2条码" });
|
||||
getdic.Add("MJQ-QU01", new string[] { "4下上料输送西区", "下料工位1请求取盘", "下料工位1条码" });
|
||||
|
||||
//List<BasLocation> startLocations = db_Floor4MJX2MJC.Queryable<BasLocation>().Where(r => r.wh_id == WmsWareHouseConst.WAREHOUSE_MJC_ID
|
||||
//&& r.is_type == ((int)EnumLocationType.分拣库位).ToString() && r.is_lock == 0).ToList();
|
||||
@@ -2051,7 +2051,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
bool result = await GetBoolTag(strs[0], strs[1]);
|
||||
if (result)
|
||||
{
|
||||
LoggerFloor4MJX2MJC.LogInformation($"【四楼待灭菌线到灭菌仓】 上料点 {key} {strs[1]}采集到 {result}");
|
||||
LoggerFloor4MJX2MJC.LogInformation($"【四楼待灭菌线到灭菌仓】 下料点 {key} {strs[1]}采集到 {result}");
|
||||
|
||||
InStockStrategyQuery inStockStrategyInput = new()
|
||||
{
|
||||
@@ -2070,7 +2070,8 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
BasLocation startlocation = await db_Floor4DMJ2MJX.Queryable<BasLocation>().Where(r => r.location_code == key).FirstAsync();
|
||||
BasLocation endlocation = items[0];
|
||||
|
||||
string carry_code = "";
|
||||
string carry_code = await GetStringTag(strs[0], strs[2]);
|
||||
LoggerFloor4MJX2MJC.LogInformation($"【四楼待灭菌线到灭菌仓】 下料点 {key} {strs[2]}采集到 {carry_code}");
|
||||
WmsCarryH wmsCarryH = await db_Floor4MJX2MJC.Queryable<WmsCarryH>().Where(r => r.carry_code == carry_code).FirstAsync();
|
||||
|
||||
//锁定起点库位
|
||||
@@ -2160,7 +2161,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
|
||||
if (wmsFloor4StewingConfig == null)
|
||||
{
|
||||
LoggerFloor4MJX2MJC.LogWarning($"【四楼灭菌仓到成品库】 未在静置仓配置中配置 静置时间(小时)");
|
||||
LoggerFloor4DMC2CPK.LogWarning($"【四楼灭菌仓到成品库】 未在静置仓配置中配置 静置时间(小时)");
|
||||
return;
|
||||
}
|
||||
int hours = 168;
|
||||
@@ -2187,7 +2188,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
await db_Floor4DMC2CPK.Ado.BeginTranAsync();
|
||||
|
||||
|
||||
BasLocation startlocation = await db_Floor4DMJ2MJX.Queryable<BasLocation>().Where(r => r.id == wmsCarryH.location_id).FirstAsync();
|
||||
BasLocation startlocation = await db_Floor4DMC2CPK.Queryable<BasLocation>().Where(r => r.id == wmsCarryH.location_id).FirstAsync();
|
||||
|
||||
InStockStrategyQuery inStockStrategyInput = new()
|
||||
{
|
||||
@@ -2253,6 +2254,107 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 二楼空托盘自动补充到线边
|
||||
/// </summary>
|
||||
/// <param name="args"></param>
|
||||
private async void F2KTPsupplement(object? args)
|
||||
{
|
||||
if (s_taskF2KTPsupplement.CurrentCount == 0)
|
||||
return;
|
||||
await s_taskF2KTPsupplement.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")} 开始执行二楼空托盘自动补充到线边");
|
||||
|
||||
Dictionary<string, string[]> putdic = new Dictionary<string, string[]>();
|
||||
putdic.Add("ZZ-01-01", new string[] { "外包装箱码垛线", "WBZX_x1_AGV_fan" });
|
||||
putdic.Add("ZZ-02-01", new string[] { "外包装箱码垛线", "WBZX_x2_AGV_fan" });
|
||||
|
||||
foreach (var key in putdic.Keys)
|
||||
{
|
||||
await db_F2KTPsupplement.Ado.BeginTranAsync();
|
||||
var strs = putdic.Where(p => p.Key == key).First().Value;
|
||||
bool result = await GetBoolTag(strs[0], strs[1]);
|
||||
if (result)
|
||||
{
|
||||
|
||||
LoggerF2KTPsupplement.LogInformation($"【二楼空托盘自动补充到线边】 上料点 {key} {strs[1]}采集到 {result}");
|
||||
|
||||
OutStockStrategyQuery outStockStrategyInput = new()
|
||||
{
|
||||
warehouse_id = WmsWareHouseConst.WAREHOUSE_F2KTQ_ID,
|
||||
Size = 1
|
||||
};
|
||||
List<WmsCarryH> items = await _wareHouseService.OutStockStrategy(outStockStrategyInput);
|
||||
|
||||
if (items.Count < 1)
|
||||
{
|
||||
LoggerF2KTPsupplement.LogWarning($"【二楼空托盘自动补充到线边】 没有可以出库的空载具");
|
||||
break;
|
||||
}
|
||||
BasLocation endlocation = await db_F2KTPsupplement.Queryable<BasLocation>().Where(r => r.location_code == key).FirstAsync();
|
||||
|
||||
if (endlocation.is_use == "1")
|
||||
{
|
||||
LoggerF2KTPsupplement.LogWarning($"【二楼空托盘自动补充到线边】 终点库位{endlocation.location_code}已占用");
|
||||
continue;
|
||||
}
|
||||
if (endlocation.is_lock == 1)
|
||||
{
|
||||
LoggerF2KTPsupplement.LogWarning($"【二楼空托盘自动补充到线边】 终点库位{endlocation.location_code}已锁定");
|
||||
continue;
|
||||
}
|
||||
|
||||
WmsCarryH wmsCarryH = items[0];
|
||||
|
||||
//锁定起点库位
|
||||
await db_F2KTPsupplement.Updateable<BasLocation>().SetColumns(r => new BasLocation { is_lock = 1 }).Where(r => r.id == wmsCarryH.location_id).ExecuteCommandAsync();
|
||||
//锁定终点库位
|
||||
await db_F2KTPsupplement.Updateable<BasLocation>().SetColumns(r => new BasLocation { is_lock = 1 }).Where(r => r.id == endlocation.id).ExecuteCommandAsync();
|
||||
|
||||
bool result_createPretask = await createPretask(wmsCarryH.location_id, endlocation.id, wmsCarryH.id, wmsCarryH.carry_code, LoggerF2KTPsupplement, db_F2KTPsupplement);
|
||||
if (!result_createPretask)
|
||||
{
|
||||
LoggerF2KTPsupplement.LogWarning($"【二楼空托盘自动补充到线边】 {wmsCarryH.location_code} 到 {endlocation.location_code} 预任务生成失败");
|
||||
throw new Exception($"【二楼空托盘自动补充到线边】 {wmsCarryH.location_code} 到 {endlocation.location_code} 预任务生成失败");
|
||||
}
|
||||
LoggerF2KTPsupplement.LogInformation($"【二楼空托盘自动补充到线边】 {wmsCarryH.location_code} 到 {endlocation.location_code} 预任务生成成功");
|
||||
|
||||
}
|
||||
await db_F2KTPsupplement.Ado.CommitTranAsync();
|
||||
}
|
||||
_ = _wareHouseService.GenTaskExecute();
|
||||
}
|
||||
catch (ObjectDisposedException ex)
|
||||
{
|
||||
LoggerF2KTPsupplement.LogError($"【二楼空托盘自动补充到线边】 数据库连接异常:{ex.Message}");
|
||||
LoggerF2KTPsupplement.LogError($"【二楼空托盘自动补充到线边】 数据库连接异常:{ex.StackTrace}");
|
||||
if (ex.Source == "Npgsql")
|
||||
db_F2KTPsupplement = _repository.AsSugarClient().CopyNew();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("【二楼空托盘自动补充到线边】" + ex.Message);
|
||||
LoggerF2KTPsupplement.LogError($"【二楼空托盘自动补充到线边】 {ex.Message}");
|
||||
LoggerF2KTPsupplement.LogError($"【二楼空托盘自动补充到线边】 {ex.StackTrace}");
|
||||
// 数据库连接断开时会报错
|
||||
try { await db_F2KTPsupplement.Ado.RollbackTranAsync(); } catch { };
|
||||
}
|
||||
finally
|
||||
{
|
||||
s_taskF2KTPsupplement.Release();
|
||||
if (!db_F2KTPsupplement.Ado.Transaction.IsNull())
|
||||
try { await db_F2KTPsupplement.Ado.CommitTranAsync(); } catch { };
|
||||
_wareHouseService.GenTaskExecute();
|
||||
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");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public Task StartAsync(CancellationToken cancellationToken)
|
||||
@@ -2287,10 +2389,11 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
ElevatorTaskExceptionHandleThread = new Thread(ElevatorTaskExceptionHandle);
|
||||
ElevatorTaskExceptionHandleThread.Start();
|
||||
|
||||
//Floor4DMJ2MJXtimer = new Timer(Floor4DMJ2MJX, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
|
||||
//Floor4MJX2MJCtimer = new Timer(Floor4MJX2MJC, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
|
||||
//Floor4DMC2CPKtimer = new Timer(Floor4DMC2CPK, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
|
||||
Floor4DMJ2MJXtimer = new Timer(Floor4DMJ2MJX, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
|
||||
Floor4MJX2MJCtimer = new Timer(Floor4MJX2MJC, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
|
||||
Floor4DMC2CPKtimer = new Timer(Floor4DMC2CPK, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
|
||||
|
||||
F2KTPsupplementtimer = new Timer(F2KTPsupplement, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
@@ -2321,6 +2424,8 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
Floor4MJX2MJCtimer?.Dispose();
|
||||
Floor4DMC2CPKtimer?.Dispose();
|
||||
ElevatorTaskExceptionHandleThread.Abort();
|
||||
F2KTPsupplementtimer?.Dispose();
|
||||
|
||||
}
|
||||
|
||||
#region 日志
|
||||
@@ -2710,6 +2815,40 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
|
||||
return _LoggerFloor4DMC2CPK;
|
||||
}
|
||||
}
|
||||
|
||||
protected string _LoggerF2KTPsupplementFileName = "";
|
||||
protected ILogger _LoggerF2KTPsupplement;
|
||||
protected ILogger LoggerF2KTPsupplement
|
||||
{
|
||||
get
|
||||
{
|
||||
string newFileName = $"{AppContext.BaseDirectory}/logs/custom二楼空托盘补充{DateTime.Now:yyyyMMdd}.log";
|
||||
if (_LoggerF2KTPsupplementFileName != newFileName)
|
||||
{
|
||||
ILoggerFactory loggerFactory = LoggerFactory.Create(builder => builder.AddFile(newFileName, cfgOpts =>
|
||||
{
|
||||
|
||||
//cfgOpts.DateFormat = "yyyy-MM-dd HH:mm:ss.fff";
|
||||
cfgOpts.MessageFormat = (logMsg) =>
|
||||
{
|
||||
var logLevel = s_logLevelMap[logMsg.LogLevel];
|
||||
var sb = new StringBuilder();
|
||||
_ = sb.Append($"[{logLevel}] ");
|
||||
_ = sb.Append($"{logMsg.LogName} ");
|
||||
_ = sb.Append($"{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff} ");
|
||||
_ = sb.Append($"#{logMsg.EventId.Id} ");
|
||||
_ = sb.Append(logMsg.Message + " ");
|
||||
_ = sb.Append(logMsg.Exception?.ToString());
|
||||
return sb.ToString();
|
||||
};
|
||||
|
||||
}));
|
||||
_LoggerF2KTPsupplement = loggerFactory.CreateLogger(this.GetType());
|
||||
_LoggerF2KTPsupplementFileName = newFileName;
|
||||
}
|
||||
return _LoggerF2KTPsupplement;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user