允许电梯放两托货

This commit is contained in:
2024-08-01 16:32:50 +08:00
parent 5693ef6ed2
commit b5e7495dfe
6 changed files with 198 additions and 53 deletions

View File

@@ -1866,21 +1866,70 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
{
try
{
List<WmsDistaskH> wmsDistaskHs = db_ElevatorTaskExceptionHandle.Queryable<WmsDistaskH>()
List<WmsDistaskH> elevatorTasks = db_ElevatorTaskExceptionHandle.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】检查到需要恢复的电梯任务{elevatorTasks.Count}条 {string.Join(',', elevatorTasks.Select(x => x.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);
if (elevatorTasks?.Count > 0)
{
List<IGrouping<string, WmsDistaskH>> elevatorTaskGroup = elevatorTasks.GroupBy(r => $"{r.endlocation_code} {r.end_floor}").ToList();
foreach (IGrouping<string, WmsDistaskH> group in elevatorTaskGroup)
{
List<WmsDistaskH> wmsDistaskHs = group.ToList();
ElevagorInfoQuery q = new() { endlocation_id = wmsDistaskHs[0].endlocation_id, taskCode = wmsDistaskHs[0].bill_code };
LoggerElevatorTask.Information($"【GenTaskExecute】执行电梯任务时 根据任务单号获取电梯参数 {JsonConvert.SerializeObject(q)}");
var e = await _wareHouseService.FindElevatorFromPars(q);
LoggerElevatorTask.Information($"【GenTaskExecute】执行电梯任务时 根据任务单号获取电梯结果 {JsonConvert.SerializeObject(e)}");
// 三、四号梯发货带两托货
string[] doubleCarryRunElevators =
{
"Elevator3","Elevator4"
};
if (doubleCarryRunElevators.Contains(e.elevator_code) && wmsDistaskHs[0].end_floor == 1)
{
// 电梯内放置两托货呼叫电梯下
if (group.Count() == 2)
{
if (e != null)
{
wmsDistaskHs[0].device_id = e.device_id;
wmsDistaskHs[1].device_id = e.device_id;
}
await _wareHouseService.ExecuteTargetFloorTask(wmsDistaskHs);
}
// 一托货
else if (group.Count() == 1)
{
// 如果当前电梯没有执行中的任务 则呼叫电梯下
if (db_ElevatorTaskExceptionHandle.Queryable<WmsDistaskH>().Where(r => r.status != WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID
&& r.status != WmsWareHouseConst.TASK_BILL_STATUS_CANCEL_ID && r.endlocation_id == wmsDistaskHs[0].startlocation_id).Count() == 0)
{
if (e != null)
{
wmsDistaskHs[0].device_id = e.device_id;
}
await _wareHouseService.ExecuteTargetFloorTask(wmsDistaskHs);
}
}
else
{
LoggerElevatorTask.LogError($"电梯 {e.elevator_code} 待执行的电梯任务数异常 目前是{group.Count()} 超过了两托");
}
}
else
{
if (e != null)
{
wmsDistaskHs[0].device_id = e.device_id;
}
await _wareHouseService.ExecuteTargetFloorTask(wmsDistaskHs);
}
}
}
}
catch (Exception ex)