优先级、巷道、分区

This commit is contained in:
2024-07-25 09:58:47 +08:00
parent 79a1828b21
commit 5b5783376b
14 changed files with 314 additions and 79 deletions

View File

@@ -92,6 +92,8 @@ namespace Tnb.ProductionMgr
private Thread? ElevatorTaskExceptionHandleThread;
// 二楼空托盘自动补充到线边
private static Timer? F2KTPsupplementtimer;
// 原材料仓内转移
private static Timer? YCLInternalTransfertimer;
public SemaphoreSlim s_taskCheckGet = new(1);
@@ -110,6 +112,7 @@ namespace Tnb.ProductionMgr
public SemaphoreSlim s_taskFloor4MJX2MJCService = new(1);
public SemaphoreSlim s_taskFloor4DMC2CPKService = new(1);
public SemaphoreSlim s_taskF2KTPsupplement = new(1);
public SemaphoreSlim s_taskYCLInternalTransfer = new(1);
private StackExRedisHelper _redisData;
private readonly IPrdInstockService _prdInstockService;
@@ -120,7 +123,7 @@ namespace Tnb.ProductionMgr
private ISqlSugarClient db_BGWCarrySupplementtimer;
private ISqlSugarClient db_YCLGLDPJInstocktimer;
private ISqlSugarClient db_YCLWXDPJInstocktimer;
private ISqlSugarClient db_Floor2UpMachinecodetimer;
private ISqlSugarClient db_Floor2UpMachinecodetimer;
private ISqlSugarClient db_Floor2timer送空托到上升降区;
private ISqlSugarClient db_Floor2timer送满托到下升降区;
private ISqlSugarClient db_Floor2timer移走上升降区未生成预任务且满托的料架;
@@ -132,6 +135,7 @@ namespace Tnb.ProductionMgr
private ISqlSugarClient db_Floor4DMC2CPK;
private ISqlSugarClient db_ElevatorTaskExceptionHandle;
private ISqlSugarClient db_F2KTPsupplement;
private ISqlSugarClient db_YCLInternalTransfer;
private readonly IWmsPDAScanInStockService _wmsPDAScanInStock;
@@ -189,6 +193,7 @@ namespace Tnb.ProductionMgr
db_Floor4DMC2CPK = repository.CopyNew();
db_ElevatorTaskExceptionHandle = repository.CopyNew();
db_F2KTPsupplement = repository.CopyNew();
db_YCLInternalTransfer = repository.CopyNew();
}
#endregion
@@ -274,7 +279,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
}
}
}
catch(NpgsqlException ex)
catch (NpgsqlException ex)
{
Console.WriteLine("【CheckGet】" + ex.Message);
LoggerSSX.LogError(ex.ToString());
@@ -417,8 +422,8 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
["TagName"] = strs[3],
["Value"] = strs[4],
};
LoggerBGWCarrySupplement.LogInformation($"【ScanInStock】 八工位 {key} 发送PutDoneEmptyBox指令 {_eleCtlCfg.WriteTagUrl} {JsonConvert.SerializeObject(dicCommand)}");
HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand).Wait();
//LoggerBGWCarrySupplement.LogInformation($"【ScanInStock】 八工位 {key} 发送PutDoneEmptyBox指令 {_eleCtlCfg.WriteTagUrl} {JsonConvert.SerializeObject(dicCommand)}");
//HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand).Wait();
string coderesult = await GetStringTag(strs[0], strs[2]);
@@ -429,11 +434,11 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
{
WmsCarryH? carry = db_Scantimer.Queryable<WmsCarryH>().Single(it => it.carry_code == coderesult);
LoggerBGWCarrySupplement.LogInformation($"【ScanInStock】 八工位 {key} 查找{coderesult}绑定的托盘: {JsonConvert.SerializeObject(carry)}");
//if (carry.location_id != "30773146852470")
//{
// LoggerBGWCarrySupplement.LogInformation($"【ScanInStock】 八工位 {key} 查找{coderesult}绑定的托盘{carry.carry_code}起始库位既不是空也不是拆盘机,此时不能生成入库任务(防止重复生成任务)");
// continue;
//}
if (carry.location_id != WmsWareHouseConst.LOCATION_YCLBGWDRK)
{
LoggerBGWCarrySupplement.LogInformation($"【ScanInStock】 八工位 {key} 查找{coderesult}绑定的托盘{carry.carry_code}不是待入库状态(还未绑定物料),此时不能生成入库任务(防止重复生成任务)");
continue;
}
if (carry != null)
{
if (db_Scantimer.Queryable<WmsDistaskH>().Where(p => p.carry_id == carry.id && p.status != WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID && p.status != WmsWareHouseConst.TASK_BILL_STATUS_CANCEL_ID).Any())
@@ -623,6 +628,89 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
}
}
/// <summary>
/// 原材料仓内转移
/// </summary>
/// <param name="state"></param>
private async void YCLInternalTransfer(object? state)
{
if (s_taskYCLInternalTransfer.CurrentCount == 0)
return;
await s_taskYCLInternalTransfer.WaitAsync();
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
try
{
Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} 开始执行YCLInternalTransfer");
LoggerTimer.LogInformation($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} 开始执行YCLInternalTransfer");
OutStockStrategyQuery outStockStrategyInput = new()
{
warehouse_id = WmsWareHouseConst.WAREHOUSE_YCL_ID,
Region_id = WmsWareHouseConst.REGION_YCLCache_ID,
AvoidBusyPassage = true,
Size = 5,
filter_carry_status = false
};
List<WmsCarryH> items = await _wareHouseService.OutStockStrategy(outStockStrategyInput);
if (items.Count < 1)
{
LoggerF2KTPsupplement.LogWarning($"【YCLInternalTransfer】 没有可以出库的空载具");
return;
}
foreach (WmsCarryH wmsCarryH in items)
{
BasLocation startlocation = await db_YCLInternalTransfer.Queryable<BasLocation>().Where(r => r.id == wmsCarryH.location_id).FirstAsync();
InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = "1", Size = 1, passage = startlocation.passage, AvoidBusyPassage = true, Region_id = WmsWareHouseConst.REGION_Purchase_ID };
List<BasLocation> endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
if (endLocations.Count() == 0)
{
LoggerYCLInternalTransfer.LogWarning($"【YCLInternalTransfer】 当前巷道没有空库位可以入库或者有任务正在执行");
continue;
}
BasLocation endLocation = endLocations.First();
await db_YCLInternalTransfer.Ado.BeginTranAsync();
LoggerYCLInternalTransfer.LogInformation($"【YCLInternalTransfer】托盘{wmsCarryH.carry_code} {wmsCarryH.location_code} 转移到 {endLocation.location_code}");
bool result_createPretask = await createPretask(wmsCarryH.location_id, endLocation.id, wmsCarryH.id, wmsCarryH.carry_code, LoggerYCLInternalTransfer, db_YCLInternalTransfer);
if (!result_createPretask)
{
LoggerYCLInternalTransfer.LogWarning($"【YCLInternalTransfer】 {wmsCarryH.location_code} 到 {endLocation.location_code} 预任务生成失败");
throw new Exception($"【YCLInternalTransfer】 {wmsCarryH.location_code} 到 {endLocation.location_code} 预任务生成失败");
}
LoggerYCLInternalTransfer.LogWarning($"【YCLInternalTransfer】 {wmsCarryH.location_code} 到 {endLocation.location_code} 预任务生成成功");
await db_YCLInternalTransfer.Ado.CommitTranAsync();
}
_ = _wareHouseService.GenTaskExecute();
}
catch (ObjectDisposedException ex)
{
LoggerYCLInternalTransfer.LogError($"【YCLInternalTransfer】 数据库连接异常:{ex.Message}");
LoggerYCLInternalTransfer.LogError($"【YCLInternalTransfer】 数据库连接异常:{ex.StackTrace}");
if (ex.Source == "Npgsql")
db_YCLInternalTransfer = _repository.AsSugarClient().CopyNew();
}
catch (Exception ex)
{
Console.WriteLine("【YCLInternalTransfer】" + ex.Message);
LoggerYCLInternalTransfer.LogError($"【YCLInternalTransfer】 数据库连接异常:{ex}");
// 数据库连接断开时会报错
try { await db_YCLInternalTransfer.Ado.RollbackTranAsync(); } catch { };
}
finally
{
s_taskYCLInternalTransfer.Release();
stopwatch.Stop();
Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} 结束执行YCLInternalTransfer {stopwatch.ElapsedMilliseconds} ms");
LoggerTimer.LogInformation($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} 结束执行YCLInternalTransfer {stopwatch.ElapsedMilliseconds} ms");
}
}
/// <summary>
/// 供料叠盘机空托盘自动入库
/// </summary>
@@ -1381,7 +1469,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
LoggerFloor2RackDelivery.LogError($"【送满托到下升降区】 起点{startLocation.id} {startLocation.location_code}上存在多个料架");
continue;
}
WmsPretaskH wmsPretaskH = db_Floor2timer送满托到下升降区.Queryable<WmsPretaskH>().Where(r => r.endlocation_code == wmsMechanicalArmH.location_code
&& r.status != WmsWareHouseConst.PRETASK_BILL_STATUS_COMPLE_ID && r.status != WmsWareHouseConst.PRETASK_BILL_STATUS_CANCEL_ID).First();
if (wmsPretaskH != null)
@@ -1761,7 +1849,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
// 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");
@@ -1790,7 +1878,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
await _wareHouseService.ExecuteTargetFloorTask(wmsDistaskH);
}
}
catch(Exception ex)
catch (Exception ex)
{
LoggerFloor2RackDelivery.LogError($"【ElevatorTaskExceptionHandle】{ex.Message}");
LoggerFloor2RackDelivery.LogError($"【ElevatorTaskExceptionHandle】{ex.StackTrace}");
@@ -2216,7 +2304,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
//锁定终点库位
await db_Floor4MJX2MJC.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,
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)
{
@@ -2364,9 +2452,44 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
}
#endregion
public Task StartAsync(CancellationToken cancellationToken)
{
//Readtimer = new Timer(GetRedisData, null, TimeSpan.Zero, TimeSpan.FromSeconds(300));
CheckGettimer = new Timer(CheckGet, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));
Scantimer = new Timer(ScanInStock, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));
SSXcodetimer = new Timer(SSXcode, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));
// 八工位缓存区补充空托盘
BGWCarrySupplementtimer = new Timer(BGWCarrySupplement, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));
// 供料叠盘机空托盘自动入库
YCLGLDPJInstocktimer = new Timer(YCLGLDPJInstock, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));
// 外协叠盘机空托盘自动入库
//YCLWXDPJInstocktimer = new Timer(YCLWXDPJInstock, null, TimeSpan.Zero, TimeSpan.FromSeconds(100000));
// 二楼上升降机
Floor2UpMachinecodetimer = new Timer(Floor2UpMachinecode, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));
// 二楼料架配送
Floor2timer送空托到上升降区 = new Timer(, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));
Floor2timer送满托到下升降区 = new Timer(, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));
Floor2timer移走上升降区未生成预任务且满托的料架 = new Timer(, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));
Floor2timer移走下升降区未生成预任务且空托的料架 = new Timer(, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));
GenTaskExecutetimer = new Timer(GenTaskExecute, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));
// 停用
//PackOutstockServicetimer = new Timer(PackOutstockService, null, TimeSpan.Zero, TimeSpan.FromSeconds(60));
ElevatorTaskExceptionHandleThread = new Thread(ElevatorTaskExceptionHandle);
ElevatorTaskExceptionHandleThread.Start();
Floor4DMJ2MJXtimer = new Timer(Floor4DMJ2MJX, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));
Floor4MJX2MJCtimer = new Timer(Floor4MJX2MJC, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));
Floor4DMC2CPKtimer = new Timer(Floor4DMC2CPK, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));
F2KTPsupplementtimer = new Timer(F2KTPsupplement, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));//Readtimer = new Timer(GetRedisData, null, TimeSpan.Zero, TimeSpan.FromSeconds(300));
CheckGettimer = new Timer(CheckGet, null, TimeSpan.Zero, TimeSpan.FromSeconds(10));
Scantimer = new Timer(ScanInStock, null, TimeSpan.Zero, TimeSpan.FromSeconds(60));
SSXcodetimer = new Timer(SSXcode, null, TimeSpan.Zero, TimeSpan.FromSeconds(10));
@@ -2401,6 +2524,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
Floor4DMC2CPKtimer = new Timer(Floor4DMC2CPK, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
F2KTPsupplementtimer = new Timer(F2KTPsupplement, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
YCLInternalTransfertimer = new Timer(YCLInternalTransfer, null, TimeSpan.Zero, TimeSpan.FromSeconds(180));
return Task.CompletedTask;
}
@@ -2432,7 +2556,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
Floor4DMC2CPKtimer?.Dispose();
ElevatorTaskExceptionHandleThread.Abort();
F2KTPsupplementtimer?.Dispose();
YCLInternalTransfertimer?.Dispose();
}
#region
@@ -2452,7 +2576,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
{
get
{
string newFileName = $"{AppContext.BaseDirectory}/logs/customElevatorTask{DateTime.Now:yyyyMMdd}.log";
string newFileName = $"{AppContext.BaseDirectory}/logs/{DateTime.Now:yyyyMMdd}/custom{DateTime.Now:yyyyMMdd}ElevatorTask.log";
if (_LoggerElevatorTaskFileName != newFileName)
{
ILoggerFactory loggerFactory = LoggerFactory.Create(builder => builder.AddFile(newFileName, cfgOpts =>
@@ -2480,40 +2604,6 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
}
}
protected string _LoggerBGWFileName = "";
protected ILogger _LoggerBGW;
protected ILogger LoggerBGW
{
get
{
string newFileName = $"{AppContext.BaseDirectory}/logs/customBGW{DateTime.Now:yyyyMMdd}.log";
if (_LoggerBGWFileName != 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();
};
}));
_LoggerBGW = loggerFactory.CreateLogger(this.GetType());
_LoggerBGWFileName = newFileName;
}
return _LoggerBGW;
}
}
protected string _LoggerSSXFileName = "";
protected ILogger _LoggerSSX;
@@ -2521,7 +2611,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
{
get
{
string newFileName = $"{AppContext.BaseDirectory}/logs/customSSX{DateTime.Now:yyyyMMdd}.log";
string newFileName = $"{AppContext.BaseDirectory}/logs/{DateTime.Now:yyyyMMdd}/中储仓/custom{DateTime.Now:yyyyMMdd}中储仓输送线.log";
if (_LoggerSSXFileName != newFileName)
{
ILoggerFactory loggerFactory = LoggerFactory.Create(builder => builder.AddFile(newFileName, cfgOpts =>
@@ -2556,7 +2646,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
{
get
{
string newFileName = $"{AppContext.BaseDirectory}/logs/customFloor2UpDownMachine{DateTime.Now:yyyyMMdd}.log";
string newFileName = $"{AppContext.BaseDirectory}/logs/{DateTime.Now:yyyyMMdd}/二楼暂存仓/custom{DateTime.Now:yyyyMMdd}二楼暂存仓机械手.log";
if (_LoggerFloor2UpDownMachineFileName != newFileName)
{
ILoggerFactory loggerFactory = LoggerFactory.Create(builder => builder.AddFile(newFileName, cfgOpts =>
@@ -2591,7 +2681,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
{
get
{
string newFileName = $"{AppContext.BaseDirectory}/logs/customFloor2RackDelivery{DateTime.Now:yyyyMMdd}.log";
string newFileName = $"{AppContext.BaseDirectory}/logs/{DateTime.Now:yyyyMMdd}/二楼暂存仓/custom{DateTime.Now:yyyyMMdd}二楼暂存仓配送任务.log";
if (_LoggerFloor2RackDeliveryFileName != newFileName)
{
ILoggerFactory loggerFactory = LoggerFactory.Create(builder => builder.AddFile(newFileName, cfgOpts =>
@@ -2625,7 +2715,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
{
get
{
string newFileName = $"{AppContext.BaseDirectory}/logs/customBGWCarrySupplement{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 =>
@@ -2659,7 +2749,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
{
get
{
string newFileName = $"{AppContext.BaseDirectory}/logs/customYCLGLDPJInstock{DateTime.Now:yyyyMMdd}.log";
string newFileName = $"{AppContext.BaseDirectory}/logs/{DateTime.Now:yyyyMMdd}/原材料仓/custom{DateTime.Now:yyyyMMdd}原材料供料叠盘机.log";
if (_LoggerYCLGLDPJInstockFileName != newFileName)
{
ILoggerFactory loggerFactory = LoggerFactory.Create(builder => builder.AddFile(newFileName, cfgOpts =>
@@ -2693,7 +2783,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
{
get
{
string newFileName = $"{AppContext.BaseDirectory}/logs/customTimer{DateTime.Now:yyyyMMdd}.log";
string newFileName = $"{AppContext.BaseDirectory}/logs/{DateTime.Now:yyyyMMdd}/custom{DateTime.Now:yyyyMMdd}Timer.log";
if (_LoggerTimerFileName != newFileName)
{
ILoggerFactory loggerFactory = LoggerFactory.Create(builder => builder.AddFile(newFileName, cfgOpts =>
@@ -2727,7 +2817,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
{
get
{
string newFileName = $"{AppContext.BaseDirectory}/logs/customFloor4DMJ2MJX{DateTime.Now:yyyyMMdd}.log";
string newFileName = $"{AppContext.BaseDirectory}/logs/{DateTime.Now:yyyyMMdd}/四楼灭菌/custom{DateTime.Now:yyyyMMdd}待灭菌到上料点.log";
if (_LoggerFloor4DMJ2MJXFileName != newFileName)
{
ILoggerFactory loggerFactory = LoggerFactory.Create(builder => builder.AddFile(newFileName, cfgOpts =>
@@ -2761,7 +2851,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
{
get
{
string newFileName = $"{AppContext.BaseDirectory}/logs/customFloor4MJX2MJC{DateTime.Now:yyyyMMdd}.log";
string newFileName = $"{AppContext.BaseDirectory}/logs/{DateTime.Now:yyyyMMdd}/四楼灭菌/custom{DateTime.Now:yyyyMMdd}下料点到灭菌区.log";
if (_LoggerFloor4MJX2MJCFileName != newFileName)
{
ILoggerFactory loggerFactory = LoggerFactory.Create(builder => builder.AddFile(newFileName, cfgOpts =>
@@ -2795,7 +2885,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
{
get
{
string newFileName = $"{AppContext.BaseDirectory}/logs/customFloor4DMC2CPK{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 =>
@@ -2829,7 +2919,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
{
get
{
string newFileName = $"{AppContext.BaseDirectory}/logs/custom二楼空托盘补充{DateTime.Now:yyyyMMdd}.log";
string newFileName = $"{AppContext.BaseDirectory}/logs/{DateTime.Now:yyyyMMdd}/二楼组装线/custom{DateTime.Now:yyyyMMdd}二楼空托盘补充.log";
if (_LoggerF2KTPsupplementFileName != newFileName)
{
ILoggerFactory loggerFactory = LoggerFactory.Create(builder => builder.AddFile(newFileName, cfgOpts =>
@@ -2856,6 +2946,41 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
return _LoggerF2KTPsupplement;
}
}
protected string _LoggerYCLInternalTransferFileName = "";
protected ILogger _LoggerYCLInternalTransfer;
protected ILogger LoggerYCLInternalTransfer
{
get
{
string newFileName = $"{AppContext.BaseDirectory}/logs/{DateTime.Now:yyyyMMdd}/原材料仓/custom{DateTime.Now:yyyyMMdd}原材料仓内转移.log";
if (_LoggerYCLInternalTransferFileName != 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();
};
}));
_LoggerYCLInternalTransfer = loggerFactory.CreateLogger(this.GetType());
_LoggerYCLInternalTransferFileName = newFileName;
}
return _LoggerYCLInternalTransfer;
}
}
#endregion
}
}

View File

@@ -522,5 +522,20 @@
/// 单位类型id
/// </summary>
public const string UNITTYPEID = "24906054811669";
/// <summary>
/// 优先级-出库
/// </summary>
public const int priority_outstock = -50;
/// <summary>
/// 优先级-入库
/// </summary>
public const int priority_instock = -100;
/// <summary>
/// 原材料八工位待入库
/// </summary>
public const string LOCATION_YCLBGWDRK = "35750287617301";
}
}

View File

@@ -56,6 +56,10 @@ namespace Tnb.WarehouseMgr.Entities.Dto.Inputs
/// </summary>
public bool isChangeCarryLoc2StartLoc { get; set; } = true;
}
/// <summary>
/// 优先级
/// </summary>
public int priority { get; set; } = 0;
}
}

View File

@@ -23,5 +23,13 @@
public int BllType { get; set; }
public int Size { get; set; }
public string Region_id { get; set; }
// 排除有任务的通道
public bool AvoidBusyPassage { get; set; } = false;
// 巷道
public string passage { get; set; }
}
}

View File

@@ -41,5 +41,13 @@
/// 箱号
/// </summary>
public string? container_no { get; set; }
public string Region_id { get; set; }
// 排除有任务的通道
public bool AvoidBusyPassage { get; set; } = false;
// 是否过滤载具占用状态
public bool filter_carry_status { get; set; } = true;
}
}

View File

@@ -235,4 +235,8 @@ public partial class WmsDistaskH : BaseEntity<string>
/// </summary>
public string endlocation_code { get; set; } = string.Empty;
/// <summary>
/// 优先级
/// </summary>
public int? priority { get; set; }
}

View File

@@ -176,7 +176,7 @@ public partial class WmsPretaskH : BaseEntity<string>
/// <summary>
/// 优先级
/// </summary>
public int priority { get; set; } = 1;
public int priority { get; set; } = 0;
/// <summary>
/// 优先级
/// </summary>

View File

@@ -57,7 +57,7 @@ namespace Tnb.WarehouseMgr
{
get
{
string newFileName = $"{AppContext.BaseDirectory}/logs/custom{DateTime.Now:yyyyMMdd}.log";
string newFileName = $"{AppContext.BaseDirectory}/logs/{DateTime.Now:yyyyMMdd}/custom{DateTime.Now:yyyyMMdd}汇总日志.log";
if (_LoggerFileName != newFileName)
{
ILoggerFactory loggerFactory = LoggerFactory.Create(builder => builder.AddFile(newFileName, cfgOpts =>

View File

@@ -157,7 +157,7 @@ namespace Tnb.WarehouseMgr
}
try
{
if (s_elevatorMap.TryGetValue(elevator.device_id, out object? elevatorCode))
if (elevator != null && s_elevatorMap.TryGetValue(elevator.device_id, out object? elevatorCode))
{
//s_eleUseStatusDic[elevator.device_id] = (int)EnumElevatorUseStatus.空闲;
string devName = elevatorCode?.ToString();

View File

@@ -215,18 +215,36 @@ namespace Tnb.WarehouseMgr
List<BasLocation> items = new();
try
{
WmsInstockPolicies policy = await _db.CopyNew().Queryable<WmsInstockPolicies>().Where(it => it.status == 1).FirstAsync();
var db = _db.CopyNew();
WmsInstockPolicies policy = await db.Queryable<WmsInstockPolicies>().Where(it => it.status == 1).FirstAsync();
if (policy == null)
{
throw new AppFriendlyException("没有可用的策略", 500);
}
List<string> busyPassages = new();
if (input.AvoidBusyPassage)
{
busyPassages = await db.Queryable<WmsPretaskH>()
.InnerJoin<BasLocation>((a, b) =>
(a.status != WmsWareHouseConst.PRETASK_BILL_STATUS_COMPLE_ID && a.status != WmsWareHouseConst.PRETASK_BILL_STATUS_CANCEL_ID)
&& (b.id == a.startlocation_id || b.id == a.endlocation_id))
.Where((a, b) => b.wh_id == input.warehouse_id)
.Where((a, b) => b.is_type == ((int)EnumLocationType.).ToString())
.WhereIF(!string.IsNullOrEmpty(input.Region_id), (a, b) => b.region_id == input.Region_id)
.Select((a, b) => b.passage).ToListAsync();
}
Expression<Func<BasLocation, bool>> whereExp = Expressionable.Create<BasLocation>()
.And(it => it.wh_id == input.warehouse_id)
.And(it => it.is_lock == 0)
.And(it => it.is_type == ((int)EnumLocationType.).ToString())
.And(it => it.is_use == ((int)EnumCarryStatus.).ToString())
.AndIF(!string.IsNullOrEmpty(input.Region_id), it => it.region_id == input.Region_id)
.AndIF(input.AvoidBusyPassage, it => !busyPassages.Contains(it.passage))
.AndIF(!string.IsNullOrEmpty(input.passage), it => it.passage == input.passage)
.ToExpression();
items = await _db.CopyNew().Queryable<BasLocation>().Where(whereExp).OrderBy(policy.policy).ToListAsync();
}
catch (Exception)
@@ -410,6 +428,20 @@ namespace Tnb.WarehouseMgr
public async Task<List<WmsCarryH>> OutStockStrategy([FromQuery] OutStockStrategyQuery input)
{
SqlSugarClient cyDb = _db.CopyNew();
List<string> busyPassages = new();
if (input.AvoidBusyPassage)
{
busyPassages = await cyDb.Queryable<WmsPretaskH>()
.InnerJoin<BasLocation>((a, b) =>
(a.status != WmsWareHouseConst.PRETASK_BILL_STATUS_COMPLE_ID && a.status != WmsWareHouseConst.PRETASK_BILL_STATUS_CANCEL_ID)
&& (b.id == a.startlocation_id || b.id == a.endlocation_id))
.Where((a, b) => b.wh_id == input.warehouse_id)
.Where((a, b) => b.is_type == ((int)EnumLocationType.).ToString())
.WhereIF(!string.IsNullOrEmpty(input.Region_id), (a, b) => b.region_id == input.Region_id)
.Select((a, b) => b.passage).ToListAsync();
}
Expressionable<WmsCarryH, WmsCarryCode, BasLocation> whereExprable = Expressionable.Create<WmsCarryH, WmsCarryCode, BasLocation>()
.And((a, b, c) => a.is_lock == 0 && c.is_lock == 0)
.And((a, b, c) => !string.IsNullOrEmpty(a.location_id))
@@ -420,14 +452,20 @@ namespace Tnb.WarehouseMgr
.AndIF(!string.IsNullOrEmpty(input.code_batch), (a, b, c) => b.code_batch == input.code_batch)
.AndIF(!string.IsNullOrEmpty(input.material_specification), (a, b, c) => b.material_specification == input.material_specification)
.AndIF(!string.IsNullOrEmpty(input.container_no), (a, b, c) => b.container_no == input.container_no)
.AndIF(!string.IsNullOrEmpty(input.carrystd_id), (a, b, c) => a.carrystd_id == input.carrystd_id);
Expression<Func<WmsCarryH, WmsCarryCode, BasLocation, bool>> carryStatusFilterExp = !input.material_id.IsNullOrWhiteSpace()
? (a, b, c) => a.carry_status == ((int)EnumCarryStatus.).ToString()
: (a, b, c) => a.carry_status == ((int)EnumCarryStatus.).ToString();
_ = whereExprable.And(carryStatusFilterExp);
.AndIF(!string.IsNullOrEmpty(input.carrystd_id), (a, b, c) => a.carrystd_id == input.carrystd_id)
.AndIF(input.AvoidBusyPassage, (a, b, c) => !busyPassages.Contains(c.passage))
.AndIF(!string.IsNullOrEmpty(input.Region_id), (a, b, c) => c.region_id == input.Region_id);
if (input.filter_carry_status)
{
Expression<Func<WmsCarryH, WmsCarryCode, BasLocation, bool>> carryStatusFilterExp = !input.material_id.IsNullOrWhiteSpace()
? (a, b, c) => a.carry_status == ((int)EnumCarryStatus.).ToString()
: (a, b, c) => a.carry_status == ((int)EnumCarryStatus.).ToString();
_ = whereExprable.And(carryStatusFilterExp);
}
Expression<Func<WmsCarryH, WmsCarryCode, BasLocation, bool>> whereExpr = whereExprable.ToExpression();
SqlSugarClient cyDb = _db.CopyNew();
WmsInstockPolicies policy = await cyDb.Queryable<WmsInstockPolicies>().Where(it => it.status == 1).FirstAsync();
if (policy == null)
{
@@ -442,6 +480,7 @@ namespace Tnb.WarehouseMgr
.Select<WmsCarryH>()
.ToListAsync();
items = items.DistinctBy(r => r.id).ToList();
return input.Size > 0 ? items.Take(input.Size).ToList() : items;
}
@@ -486,7 +525,7 @@ namespace Tnb.WarehouseMgr
.Select<WmsCarryH>()
.ToListAsync();
items = items.Distinct().ToList();
items = items.DistinctBy(r => r.id).ToList();
return input.Size > 0 ? items.Take(input.Size).ToList() : items;
}
@@ -1348,7 +1387,8 @@ namespace Tnb.WarehouseMgr
.Where((a, b) => a.status == WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID && !string.IsNullOrWhiteSpace(a.startlocation_id)
// 载具为空时 不校验载具当前位置是否与预任务起点相同
&& (string.IsNullOrEmpty(a.carry_id) || (!string.IsNullOrEmpty(a.carry_id) && a.startlocation_id == b.location_id)))
.OrderBy(a => new { priority = SqlFunc.Desc(a.priority), a.bill_code })
.OrderBy(a => new { a.bill_code })
.OrderByDescending(a => new { priority = SqlFunc.Desc(a.priority) })
.Select((a, b, c, d) => new WmsPretaskH
{
move_num = c.move_num,
@@ -2233,8 +2273,19 @@ namespace Tnb.WarehouseMgr
dynamic reqBody = new ExpandoObject();
reqBody.taskChainCode = k;
reqBody.type = typeflag ? (int)EnumTaskChainType.KIVA : (int)EnumTaskChainType.AGV;
reqBody.sequential = false;
reqBody.taskChainPriority = 0;
// 原材料仓使用优先级
if (dis.area_code == "A")
{
reqBody.sequential = true;
reqBody.taskChainPriority = dis.priority;
}
else
{
reqBody.sequential = false;
reqBody.taskChainPriority = 0;
}
reqBody.taskList = v;
reqBody.floor = dis.end_floor;
Logger.Information($"【AgvDispatch】 Agv任务执行 开始请求联核/task-chain/create接口 请求地址:{url} 请求参数:{JsonConvert.SerializeObject(reqBody)} ");
@@ -3433,7 +3484,8 @@ namespace Tnb.WarehouseMgr
require_id = input.require_id,
require_code = input.require_code,
create_id = _userManager.UserId,
create_time = DateTime.Now
create_time = DateTime.Now,
priority = input.priority
};
return preTask;
@@ -3466,6 +3518,10 @@ namespace Tnb.WarehouseMgr
{
wmsCarryHChangeExp = a => new WmsCarryH { is_lock = 1, location_id = preTaskUpInput.CarryStartLocationId, location_code = preTaskUpInput.CarryStartLocationCode };
}
else
{
wmsCarryHChangeExp = a => new WmsCarryH { is_lock = 1 };
}
await GenInStockTaskHandleAfter(preTaskUpInput,
wmsCarryHChangeExp,

View File

@@ -17,6 +17,7 @@ using Npgsql;
using Senparc.Weixin.MP.AdvancedAPIs.Card;
using SqlSugar;
using Tnb.WarehouseMgr.Entities;
using Tnb.WarehouseMgr.Entities.Consts;
using Tnb.WarehouseMgr.Entities.Dto;
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
using Tnb.WarehouseMgr.Entities.Dto.Outputs;
@@ -152,6 +153,12 @@ namespace Tnb.WarehouseMgr
return result;
}
/// <summary>
/// 仅原材料仓八工位PDA使用
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="AppFriendlyException"></exception>
[HttpPost]
public async Task CarryMaterialBind(CarryMaterialBindInput input)
{
@@ -172,6 +179,12 @@ namespace Tnb.WarehouseMgr
int rows = 0;
if (WmsCarryCodes.Count > 0)
rows = await _db.Insertable(WmsCarryCodes).ExecuteCommandAsync();
await _db.Updateable<WmsCarryH>().SetColumns(r => new WmsCarryH
{
location_id = WmsWareHouseConst.LOCATION_YCLBGWDRK,
location_code = "YCLBGWDRK"
}).Where(r => r.id == carry.id).ExecuteCommandAsync();
if (rows == 0)
{
throw new Exception($"物料列表为空,不能提交绑定,可能的原因;1.需要检查扫码设置(新PDA) 2.未扫到有效的二维码 详细信息:接收到{input.details.Count}个条码 但是成功绑定的条码数量为0个");

View File

@@ -513,6 +513,7 @@ namespace Tnb.WarehouseMgr
commonCreatePretaskInput.carry_id = wmsCarryHs[index].id;
commonCreatePretaskInput.carry_code = wmsCarryHs[index].carry_code;
commonCreatePretaskInput.isExcuteMission = false;
commonCreatePretaskInput.priority = WmsWareHouseConst.priority_outstock;
Entities.Dto.Outputs.Result res = await _wareHouseService.CommonCreatePretask(commonCreatePretaskInput, _db);

View File

@@ -483,8 +483,8 @@ namespace Tnb.WarehouseMgr
_ = await _dbScanInStockByRedis.Insertable(instockCode).ExecuteCommandAsync();
Logger.LogInformation($"【ScanInStockByRedis】插入WmsInstockCode {JsonConvert.SerializeObject(instockCode)}");
}
InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = "1", Size = 1 };
InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = "1", Size = 1, AvoidBusyPassage = true, Region_id = WmsWareHouseConst.REGION_YCLCache_ID };
List<BasLocation> endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
WmsPointH sPoint = new();
WmsPointH ePoint = new();
@@ -554,7 +554,8 @@ namespace Tnb.WarehouseMgr
require_id = instock.id,
require_code = instock.bill_code,
create_id = _userManager.User == null ? "" : _userManager.UserId!,
create_time = DateTime.Now
create_time = DateTime.Now,
priority = WmsWareHouseConst.priority_instock
};
return preTask;
}).ToList();

View File

@@ -7,7 +7,7 @@
},
"File": {
"Enabled": true, // 启用文件日志
"FileName": "logs/{0:yyyyMMdd}.log", // 日志文件
"FileName": "logs/{0:yyyyMMdd}/{0:yyyyMMdd}.log", // 日志文件
"Append": true, // 追加覆盖
// "MinimumLevel": "Information", // 日志级别
"FileSizeLimitBytes": 10485760, // 10M=10*1024*1024