外协入库与四楼自动移库逻辑修改、现场问题处理

This commit is contained in:
2024-10-09 18:12:33 +08:00
parent 05714f027d
commit c675ec3e07
16 changed files with 504 additions and 189 deletions

View File

@@ -2420,7 +2420,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
}
/// <summary>
/// 四楼灭菌线到灭菌
/// 四楼灭菌线到解析
/// </summary>
/// <param name="args"></param>
private async void Floor4MJX2MJC(object? args)
@@ -2432,8 +2432,8 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
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")} 开始执行四楼灭菌线到灭菌仓");
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[]> getdic = new Dictionary<string, string[]>();
getdic.Add("MJQ-QU01", new string[] { "4楼下料输送西区", "下料工位1请求取盘", "下料工位1条码" });
@@ -2446,75 +2446,89 @@ 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}");
InStockStrategyQuery inStockStrategyInput = new()
SemaphoreSlim semaphoreSlim = null;
try
{
warehouse_id = WmsWareHouseConst.WAREHOUSE_MJC_ID,
Size = 1
};
List<BasLocation> items = await _wareHouseService.InStockStrategy(inStockStrategyInput);
semaphoreSlim = _wareHouseService.GetSemaphore("instock", WmsWareHouseConst.WAREHOUSE_MJC_ID);
await semaphoreSlim.WaitAsync();
LoggerFloor4MJX2MJC.LogInformation($"【四楼灭菌线到解析仓】 下料点 {key} {strs[1]}采集到 {result}");
InStockStrategyQuery inStockStrategyInput = new()
{
warehouse_id = WmsWareHouseConst.WAREHOUSE_MJC_ID,
Size = 1
};
List<BasLocation> items = await _wareHouseService.InStockStrategy(inStockStrategyInput);
if (items.Count < 1)
{
LoggerFloor4MJX2MJC.LogWarning($"【四楼灭菌线到解析仓】 没有可以入库的库位");
break;
}
var endlocation = items.First();
await db_Floor4MJX2MJC.Ado.BeginTranAsync();
BasLocation startlocation = await db_Floor4MJX2MJC.Queryable<BasLocation>().Where(r => r.location_code == key).FirstAsync();
if (startlocation.is_lock == 1)
{
LoggerFloor4MJX2MJC.LogWarning($"【四楼灭菌线到解析仓】 起点库位{startlocation.location_code}已锁定");
continue;
}
string carry_code = (await GetStringTag(strs[0], strs[2])).Replace("\r", "").Replace(" ", "");
LoggerFloor4MJX2MJC.LogInformation($"【四楼灭菌线到解析仓】 下料点 {key} {strs[2]}采集到 {carry_code}");
LoggerFloor4MJX2MJC.LogInformation($"【四楼灭菌线到解析仓】 下料点 {key} {strs[2]}采集到长度 {carry_code.Length}");
WmsCarryH wmsCarryH = await db_Floor4MJX2MJC.Queryable<WmsCarryH>().Where(r => r.carry_code == carry_code).FirstAsync();
if (wmsCarryH == null)
{
LoggerFloor4MJX2MJC.LogWarning($"【四楼灭菌线到解析仓】 托盘号{carry_code}在系统中不存在");
continue;
}
//锁定起点库位
await db_Floor4MJX2MJC.Updateable<BasLocation>().SetColumns(r => new BasLocation { is_lock = 1 }).Where(r => r.id == startlocation.id).ExecuteCommandAsync();
//锁定终点库位
await db_Floor4MJX2MJC.Updateable<BasLocation>().SetColumns(r => new BasLocation { is_lock = 1 }).Where(r => r.id == endlocation.id).ExecuteCommandAsync();
DateTime dateTime = DateTime.Now;
WmsSterilizationInstockH wmsSterilizationInstockH = new WmsSterilizationInstockH();
string code = await _billRullService.GetBillNumber("WmsSterilizationInstockH");
wmsSterilizationInstockH.bill_code = code;
wmsSterilizationInstockH.carry_id = wmsCarryH.id;
wmsSterilizationInstockH.carry_code = wmsCarryH.carry_code;
wmsSterilizationInstockH.location_id = endlocation.id;
wmsSterilizationInstockH.location_code = endlocation.location_code;
wmsSterilizationInstockH.create_id = WmsWareHouseConst.AdministratorUserId;
wmsSterilizationInstockH.create_time = dateTime;
wmsSterilizationInstockH.instock_time = dateTime;
wmsSterilizationInstockH.org_id = WmsWareHouseConst.AdministratorOrgId;
wmsSterilizationInstockH.xl_location_id = startlocation.id;
wmsSterilizationInstockH.xl_location_code = startlocation.location_code;
wmsSterilizationInstockH.status = WmsWareHouseConst.BILLSTATUS_ADD_ID;
wmsSterilizationInstockH.origin = "生产入库";
int row = await db_Floor4MJX2MJC.Insertable(wmsSterilizationInstockH).ExecuteCommandAsync();
if (row > 0)
LoggerFloor4MJX2MJC.LogInformation($"【四楼灭菌线到解析仓】 灭菌入库记录生成成功");
else
LoggerFloor4MJX2MJC.LogWarning($"【四楼灭菌线到解析仓】 灭菌入库记录生成失败");
bool result_createPretask = await createPretask(startlocation.id, endlocation.id, wmsCarryH.id, wmsCarryH.carry_code, LoggerFloor4MJX2MJC, db_Floor4MJX2MJC, WmsWareHouseConst.BIZTYPE_WMSSTERILIZATIONINSTOCKCH_ID, "", wmsSterilizationInstockH.id);
if (!result_createPretask)
{
LoggerFloor4MJX2MJC.LogWarning($"【四楼灭菌线到解析仓】 {startlocation.location_code} 到 {endlocation.location_code} 预任务生成失败");
throw new Exception($"【四楼灭菌线到解析仓】 {startlocation.location_code} 到 {endlocation.location_code} 预任务生成失败");
}
LoggerFloor4MJX2MJC.LogInformation($"【四楼灭菌线到解析仓】 {startlocation.location_code} 到 {endlocation.location_code} 预任务生成成功");
if (items.Count < 1)
{
LoggerFloor4MJX2MJC.LogWarning($"【四楼待灭菌线到灭菌仓】 没有可以入库的库位");
break;
}
var endlocation = items.First();
await db_Floor4MJX2MJC.Ado.BeginTranAsync();
BasLocation startlocation = await db_Floor4MJX2MJC.Queryable<BasLocation>().Where(r => r.location_code == key).FirstAsync();
if (startlocation.is_lock == 1)
catch
{
LoggerFloor4MJX2MJC.LogWarning($"【四楼待灭菌线到灭菌仓】 起点库位{startlocation.location_code}已锁定");
continue;
throw;
}
string carry_code = (await GetStringTag(strs[0], strs[2])).Replace("\r", "").Replace(" ", "");
LoggerFloor4MJX2MJC.LogInformation($"【四楼待灭菌线到灭菌仓】 下料点 {key} {strs[2]}采集到 {carry_code}");
LoggerFloor4MJX2MJC.LogInformation($"【四楼待灭菌线到灭菌仓】 下料点 {key} {strs[2]}采集到长度 {carry_code.Length}");
WmsCarryH wmsCarryH = await db_Floor4MJX2MJC.Queryable<WmsCarryH>().Where(r => r.carry_code == carry_code).FirstAsync();
if (wmsCarryH == null)
finally
{
LoggerFloor4MJX2MJC.LogWarning($"【四楼待灭菌线到灭菌仓】 托盘号{carry_code}在系统中不存在");
continue;
semaphoreSlim.Release();
}
//锁定起点库位
await db_Floor4MJX2MJC.Updateable<BasLocation>().SetColumns(r => new BasLocation { is_lock = 1 }).Where(r => r.id == startlocation.id).ExecuteCommandAsync();
//锁定终点库位
await db_Floor4MJX2MJC.Updateable<BasLocation>().SetColumns(r => new BasLocation { is_lock = 1 }).Where(r => r.id == endlocation.id).ExecuteCommandAsync();
DateTime dateTime = DateTime.Now;
WmsSterilizationInstockH wmsSterilizationInstockH = new WmsSterilizationInstockH();
string code = await _billRullService.GetBillNumber("WmsSterilizationInstockH");
wmsSterilizationInstockH.bill_code = code;
wmsSterilizationInstockH.carry_id = wmsCarryH.id;
wmsSterilizationInstockH.carry_code = wmsCarryH.carry_code;
wmsSterilizationInstockH.location_id = endlocation.id;
wmsSterilizationInstockH.location_code = endlocation.location_code;
wmsSterilizationInstockH.create_id = WmsWareHouseConst.AdministratorUserId;
wmsSterilizationInstockH.create_time = dateTime;
wmsSterilizationInstockH.instock_time = dateTime;
wmsSterilizationInstockH.org_id = WmsWareHouseConst.AdministratorOrgId;
wmsSterilizationInstockH.xl_location_id = startlocation.id;
wmsSterilizationInstockH.xl_location_code = startlocation.location_code;
wmsSterilizationInstockH.status = WmsWareHouseConst.BILLSTATUS_ADD_ID;
int row = await db_Floor4MJX2MJC.Insertable(wmsSterilizationInstockH).ExecuteCommandAsync();
if (row > 0)
LoggerFloor4MJX2MJC.LogInformation($"【四楼待灭菌线到灭菌仓】 灭菌入库记录生成成功");
else
LoggerFloor4MJX2MJC.LogWarning($"【四楼待灭菌线到灭菌仓】 灭菌入库记录生成失败");
bool result_createPretask = await createPretask(startlocation.id, endlocation.id, wmsCarryH.id, wmsCarryH.carry_code, LoggerFloor4MJX2MJC, db_Floor4MJX2MJC, WmsWareHouseConst.BIZTYPE_WMSSTERILIZATIONINSTOCKCH_ID, "", wmsSterilizationInstockH.id);
if (!result_createPretask)
{
LoggerFloor4MJX2MJC.LogWarning($"【四楼待灭菌线到灭菌仓】 {startlocation.location_code} 到 {endlocation.location_code} 预任务生成失败");
throw new Exception($"【四楼待灭菌线到灭菌仓】 {startlocation.location_code} 到 {endlocation.location_code} 预任务生成失败");
}
LoggerFloor4MJX2MJC.LogInformation($"【四楼待灭菌线到灭菌仓】 {startlocation.location_code} 到 {endlocation.location_code} 预任务生成成功");
}
await db_Floor4MJX2MJC.Ado.CommitTranAsync();
}
@@ -2523,16 +2537,16 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
}
catch (ObjectDisposedException ex)
{
LoggerFloor4MJX2MJC.LogError($"【四楼灭菌线到灭菌仓】 数据库连接异常:{ex.Message}");
LoggerFloor4MJX2MJC.LogError($"【四楼灭菌线到灭菌仓】 数据库连接异常:{ex.StackTrace}");
LoggerFloor4MJX2MJC.LogError($"【四楼灭菌线到解析仓】 数据库连接异常:{ex.Message}");
LoggerFloor4MJX2MJC.LogError($"【四楼灭菌线到解析仓】 数据库连接异常:{ex.StackTrace}");
if (ex.Source == "Npgsql")
db_Floor4MJX2MJC = _repository.AsSugarClient().CopyNew();
}
catch (Exception ex)
{
Console.WriteLine("【四楼灭菌线到灭菌仓】" + ex.Message);
LoggerFloor4MJX2MJC.LogError($"【四楼灭菌线到灭菌仓】 {ex.Message}");
LoggerFloor4MJX2MJC.LogError($"【四楼灭菌线到灭菌仓】 {ex.StackTrace}");
Console.WriteLine("【四楼灭菌线到解析仓】" + ex.Message);
LoggerFloor4MJX2MJC.LogError($"【四楼灭菌线到解析仓】 {ex.Message}");
LoggerFloor4MJX2MJC.LogError($"【四楼灭菌线到解析仓】 {ex.StackTrace}");
// 数据库连接断开时会报错
try { await db_Floor4MJX2MJC.Ado.RollbackTranAsync(); } catch { };
}
@@ -2543,8 +2557,8 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
try { await db_Floor4MJX2MJC.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");
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");
}
}
@@ -2593,60 +2607,79 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
foreach (WmsSterilizationInstockH wmsSterilizationInstockH in wmsSterilizationInstockHs)
{
WmsCarryH wmsCarryH = await db_Floor4DMC2CPK.Queryable<WmsCarryH>().Where(r => r.id == wmsSterilizationInstockH.carry_id).FirstAsync();
if (wmsCarryH.location_id != wmsSterilizationInstockH.location_id)
SemaphoreSlim semaphoreSlim_MJC = null;
SemaphoreSlim semaphoreSlim_CPK = null;
try
{
LoggerFloor4DMC2CPK.LogWarning($"【四楼灭菌仓到成品库】载具{wmsCarryH.carry_code}实际位置与灭菌入库记录位置不一致");
continue;
semaphoreSlim_MJC = _wareHouseService.GetSemaphore("outstock", WmsWareHouseConst.WAREHOUSE_MJC_ID);
await semaphoreSlim_MJC.WaitAsync();
semaphoreSlim_CPK = _wareHouseService.GetSemaphore("instock", WmsWareHouseConst.WAREHOUSE_CP_ID);
await semaphoreSlim_CPK.WaitAsync();
WmsCarryH wmsCarryH = await db_Floor4DMC2CPK.Queryable<WmsCarryH>().Where(r => r.id == wmsSterilizationInstockH.carry_id).FirstAsync();
if (wmsCarryH.location_id != wmsSterilizationInstockH.location_id)
{
LoggerFloor4DMC2CPK.LogWarning($"【四楼灭菌仓到成品库】载具{wmsCarryH.carry_code}实际位置与灭菌入库记录位置不一致");
continue;
}
BasLocation startlocation = await db_Floor4DMC2CPK.Queryable<BasLocation>().Where(r => r.id == wmsCarryH.location_id).FirstAsync();
if (startlocation.is_lock == 1)
{
LoggerFloor4DMC2CPK.LogWarning($"【四楼待灭菌线到灭菌仓】 起点库位{startlocation.location_code}已锁定");
continue;
}
await db_Floor4DMC2CPK.Ado.BeginTranAsync();
InStockStrategyQuery inStockStrategyInput = new()
{
warehouse_id = WmsWareHouseConst.WAREHOUSE_CP_ID,
Region_id = WmsWareHouseConst.REGION_CPOutstock_ID,
Size = 1
};
List<BasLocation> items = await _wareHouseService.InStockStrategy(inStockStrategyInput);
if (items.Count < 1)
{
LoggerFloor4DMC2CPK.LogWarning($"【四楼灭菌仓到成品库】 没有可以入库的库位");
break;
}
BasLocation endlocation = items[0];
//锁定起点库位
await db_Floor4DMC2CPK.Updateable<BasLocation>().SetColumns(r => new BasLocation { is_lock = 1 }).Where(r => r.id == startlocation.id).ExecuteCommandAsync();
//锁定终点库位
await db_Floor4DMC2CPK.Updateable<BasLocation>().SetColumns(r => new BasLocation { is_lock = 1 }).Where(r => r.id == endlocation.id).ExecuteCommandAsync();
bool result_createPretask = await createPretask(startlocation.id, endlocation.id, wmsCarryH.id, wmsCarryH.carry_code,
LoggerFloor4DMC2CPK, db_Floor4DMC2CPK, WmsWareHouseConst.BIZTYPE_WMSSTERILIZATIONINSTOCKCH_ID, "", wmsSterilizationInstockH.id);
if (!result_createPretask)
{
LoggerFloor4DMC2CPK.LogWarning($"【四楼灭菌仓到成品库】 {startlocation.location_code} 到 {endlocation.location_code} 预任务生成失败");
throw new Exception($"【四楼灭菌仓到成品库】 {startlocation.location_code} 到 {endlocation.location_code} 预任务生成失败");
}
LoggerFloor4DMC2CPK.LogInformation($"【四楼灭菌仓到成品库】 {startlocation.location_code} 到 {endlocation.location_code} 预任务生成成功");
wmsSterilizationInstockH.status = WmsWareHouseConst.BILLSTATUS_ON_ID;
wmsSterilizationInstockH.cp_location_id = endlocation.id;
wmsSterilizationInstockH.cp_location_code = endlocation.location_code;
await db_Floor4DMC2CPK.Updateable(wmsSterilizationInstockH).UpdateColumns(r => new { r.status }).ExecuteCommandAsync();
await db_Floor4DMC2CPK.Ado.CommitTranAsync();
}
BasLocation startlocation = await db_Floor4DMC2CPK.Queryable<BasLocation>().Where(r => r.id == wmsCarryH.location_id).FirstAsync();
if (startlocation.is_lock == 1)
catch
{
LoggerFloor4DMC2CPK.LogWarning($"【四楼待灭菌线到灭菌仓】 起点库位{startlocation.location_code}已锁定");
continue;
throw;
}
await db_Floor4DMC2CPK.Ado.BeginTranAsync();
InStockStrategyQuery inStockStrategyInput = new()
finally
{
warehouse_id = WmsWareHouseConst.WAREHOUSE_CP_ID,
Region_id = WmsWareHouseConst.REGION_CPOutstock_ID,
Size = 1
};
List<BasLocation> items = await _wareHouseService.InStockStrategy(inStockStrategyInput);
if (items.Count < 1)
{
LoggerFloor4DMC2CPK.LogWarning($"【四楼灭菌仓到成品库】 没有可以入库的库位");
break;
semaphoreSlim_MJC.Release();
semaphoreSlim_CPK.Release();
}
BasLocation endlocation = items[0];
//锁定起点库位
await db_Floor4DMC2CPK.Updateable<BasLocation>().SetColumns(r => new BasLocation { is_lock = 1 }).Where(r => r.id == startlocation.id).ExecuteCommandAsync();
//锁定终点库位
await db_Floor4DMC2CPK.Updateable<BasLocation>().SetColumns(r => new BasLocation { is_lock = 1 }).Where(r => r.id == endlocation.id).ExecuteCommandAsync();
bool result_createPretask = await createPretask(startlocation.id, endlocation.id, wmsCarryH.id, wmsCarryH.carry_code,
LoggerFloor4DMC2CPK, db_Floor4DMC2CPK, WmsWareHouseConst.BIZTYPE_WMSSTERILIZATIONINSTOCKCH_ID, "", wmsSterilizationInstockH.id);
if (!result_createPretask)
{
LoggerFloor4DMC2CPK.LogWarning($"【四楼灭菌仓到成品库】 {startlocation.location_code} 到 {endlocation.location_code} 预任务生成失败");
throw new Exception($"【四楼灭菌仓到成品库】 {startlocation.location_code} 到 {endlocation.location_code} 预任务生成失败");
}
LoggerFloor4DMC2CPK.LogInformation($"【四楼灭菌仓到成品库】 {startlocation.location_code} 到 {endlocation.location_code} 预任务生成成功");
wmsSterilizationInstockH.status = WmsWareHouseConst.BILLSTATUS_ON_ID;
wmsSterilizationInstockH.cp_location_id = endlocation.id;
wmsSterilizationInstockH.cp_location_code = endlocation.location_code;
await db_Floor4DMC2CPK.Updateable(wmsSterilizationInstockH).UpdateColumns(r => new { r.status }).ExecuteCommandAsync();
await db_Floor4DMC2CPK.Ado.CommitTranAsync();
}
}
catch (ObjectDisposedException ex)
@@ -3189,7 +3222,8 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
Floor4DMJ2MJXtimer = new Timer(Floor4DMJ2MJX, null, TimeSpan.Zero, TimeSpan.FromSeconds(10));
Floor4MJX2MJCtimer = new Timer(Floor4MJX2MJC, null, TimeSpan.Zero, TimeSpan.FromSeconds(10));
Floor4DMC2CPKtimer = new Timer(Floor4DMC2CPK, null, TimeSpan.Zero, TimeSpan.FromSeconds(10));
// 需求变更弃用
//Floor4DMC2CPKtimer = new Timer(Floor4DMC2CPK, null, TimeSpan.Zero, TimeSpan.FromSeconds(10));
F2KTPsupplementtimer = new Timer(F2KTPsupplement, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
YCLInternalTransfertimer = new Timer(YCLInternalTransfer, null, TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(185));
@@ -3391,7 +3425,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
{
get
{
string newFileName = $"{AppContext.BaseDirectory}/logs/{DateTime.Now:yyyyMMdd}/原材料仓/custom{DateTime.Now:yyyyMMdd}八工位空托盘补充.log";
string newFileName = $"{AppContext.BaseDirectory}/logs/{DateTime.Now:yyyyMMdd}/原材料仓/custom{DateTime.Now:yyyyMMdd}八工位入库/空托盘补充.log";
if (_LoggerBGWCarrySupplementFileName != newFileName)
{
ILoggerFactory loggerFactory = LoggerFactory.Create(builder => builder.AddFile(newFileName, cfgOpts =>
@@ -3561,7 +3595,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
{
get
{
string newFileName = $"{AppContext.BaseDirectory}/logs/{DateTime.Now:yyyyMMdd}/四楼灭菌/custom{DateTime.Now:yyyyMMdd}灭菌仓到成品仓.log";
string newFileName = $"{AppContext.BaseDirectory}/logs/{DateTime.Now:yyyyMMdd}/四楼灭菌/custom{DateTime.Now:yyyyMMdd}四楼灭菌线到解析仓.log";
if (_LoggerFloor4DMC2CPKFileName != newFileName)
{
ILoggerFactory loggerFactory = LoggerFactory.Create(builder => builder.AddFile(newFileName, cfgOpts =>