二楼流程优化 电梯bug修复

This commit is contained in:
2024-07-13 22:08:30 +08:00
parent 7d31cf037c
commit 2dc8f04e4e
5 changed files with 201 additions and 29 deletions

View File

@@ -49,6 +49,7 @@ using Tnb.WarehouseMgr.Entities.Configs;
using Tnb.WarehouseMgr.Entities.Consts;
using Tnb.WarehouseMgr.Entities.Dto;
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
using Tnb.WarehouseMgr.Entities.Dto.Queries;
using Tnb.WarehouseMgr.Entities.Entity;
using Tnb.WarehouseMgr.Entities.Enums;
using Tnb.WarehouseMgr.Interfaces;
@@ -82,6 +83,10 @@ namespace Tnb.ProductionMgr
// 四楼包材自动到二楼包材库
private static Timer? PackOutstockServicetimer;
// 检查到电梯任务异常断开后处理
private Thread? ElevatorTaskExceptionHandleThread;
public SemaphoreSlim s_taskCheckGet = new(1);
public SemaphoreSlim s_taskScan = new(1);
public SemaphoreSlim s_taskSSXcode = new(1);
@@ -920,7 +925,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 && a.status != WmsWareHouseConst.BILLSTATUS_COMPLETE_ID).ToList();
&& b.carry_code == barcode).ToList();
if (WmsMaterialTransfers.Count() == 0)
{
@@ -1458,7 +1463,16 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
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);
string wmsMaterialTransferId = "";
if (wmsMaterialTransfer != null)
{
wmsMaterialTransferId = wmsMaterialTransfer.id;
}
else
{
LoggerFloor2RackDelivery.LogWarning($"【移走上升降区满托的料架】找不到转库单{wmsMechanicalArmH.outbill}");
}
bool result = await createPretask(wmsMechanicalArmH.location_id, endLocation.id, wmsMechanicalArmH.rackid, wmsMechanicalArmH.rackcode, LoggerFloor2RackDelivery, db_Floor2timer移走上升降区未生成预任务且满托的料架, true, wmsMaterialTransferId);
if (!result)
{
LoggerFloor2RackDelivery.LogError($"【移走上升降区满托的料架】 未成功生成预任务 起点{wmsMechanicalArmH.location_code} 终点{endLocation.location_code} 料架 {wmsMechanicalArmH.rackcode}");
@@ -1697,7 +1711,29 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
LoggerTimer.LogInformation($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} 结束执行四楼包材自动到二楼包材库 {stopwatch.ElapsedMilliseconds} ms");
}
}
async void ElevatorTaskExceptionHandle(object args)
{
List<WmsDistaskH> wmsDistaskHs = _repository.AsSugarClient().Queryable<WmsDistaskH>()
.Where(r => r.startlocation_code.Contains("DT") && r.endlocation_code.Contains("DT") && r.act_start_date != null && r.act_end_date == null).ToList();
LoggerElevatorTask.Information($"【ElevatorTaskExceptionHandle】检查到需要恢复的电梯任务{wmsDistaskHs.Count}条 {string.Join(',', wmsDistaskHs.Select(x => x.bill_code))}");
foreach (WmsDistaskH wmsDistaskH in wmsDistaskHs)
{
ElevagorInfoQuery q = new() { endlocation_id = wmsDistaskH.endlocation_id, taskCode = wmsDistaskH.bill_code };
LoggerElevatorTask.Information($"【ElevatorTaskExceptionHandle】执行电梯任务时 根据任务单号获取电梯参数 {JsonConvert.SerializeObject(q)}");
var e = await _wareHouseService.FindElevatorFromPars(q);
LoggerElevatorTask.Information($"【ElevatorTaskExceptionHandle】执行电梯任务时 根据任务单号获取电梯结果 {JsonConvert.SerializeObject(e)}");
if (e == null)
continue;
wmsDistaskH.device_id = e.device_id;
await _wareHouseService.ExecuteTargetFloorTask(wmsDistaskH);
}
}
#region
@@ -1842,7 +1878,10 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
GenTaskExecutetimer = new Timer(GenTaskExecute, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
PackOutstockServicetimer = new Timer(PackOutstockService, null, TimeSpan.Zero, TimeSpan.FromSeconds(60));
//PackOutstockServicetimer = new Timer(PackOutstockService, null, TimeSpan.Zero, TimeSpan.FromSeconds(60));
ElevatorTaskExceptionHandleThread = new Thread(ElevatorTaskExceptionHandle);
ElevatorTaskExceptionHandleThread.Start();
return Task.CompletedTask;
}
@@ -1882,6 +1921,41 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
[LogLevel.Error] = "ERR",
};
protected string _LoggerElevatorTaskFileName = "";
protected ILogger _LoggerElevatorTask;
protected ILogger LoggerElevatorTask
{
get
{
string newFileName = $"{AppContext.BaseDirectory}/logs/customElevatorTask{DateTime.Now:yyyyMMdd}.log";
if (_LoggerElevatorTaskFileName != 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();
};
}));
_LoggerElevatorTask = loggerFactory.CreateLogger(this.GetType());
_LoggerElevatorTaskFileName = newFileName;
}
return _LoggerElevatorTask;
}
}
protected string _LoggerBGWFileName = "";
protected ILogger _LoggerBGW;
protected ILogger LoggerBGW