报表、电梯优化......

This commit is contained in:
2024-08-27 22:44:42 +08:00
parent be5bdc46e3
commit ab2f4c5b9b
9 changed files with 262 additions and 40 deletions

View File

@@ -117,7 +117,6 @@ namespace Tnb.ProductionMgr
public SemaphoreSlim s_taskF2KTPsupplement = new(1);
public SemaphoreSlim s_taskYCLInternalTransfer = new(1);
public Dictionary<string, SemaphoreSlim> s_elevatortaskDic = new();
private StackExRedisHelper _redisData;
private readonly IPrdInstockService _prdInstockService;
@@ -138,7 +137,6 @@ namespace Tnb.ProductionMgr
private ISqlSugarClient db_Floor4DMJ2MJX;
private ISqlSugarClient db_Floor4MJX2MJC;
private ISqlSugarClient db_Floor4DMC2CPK;
private List<ISqlSugarClient> db_ElevatorTaskExceptionHandles = new ();
private ISqlSugarClient db_F2KTPsupplement;
private ISqlSugarClient db_YCLInternalTransfer;
@@ -203,9 +201,9 @@ namespace Tnb.ProductionMgr
foreach (var s_elevatorArea in elevatorAreas)
{
ISqlSugarClient db_ElevatorTaskExceptionHandle = repository.CopyNew();
db_ElevatorTaskExceptionHandles.Add(db_ElevatorTaskExceptionHandle);
_wareHouseService.db_ElevatorTaskExceptionHandles.Add(db_ElevatorTaskExceptionHandle);
SemaphoreSlim s_elevatortask = new(1);
s_elevatortaskDic.Add(s_elevatorArea, s_elevatortask);
_wareHouseService.s_elevatortaskDic.Add(s_elevatorArea, s_elevatortask);
}
}
@@ -1010,7 +1008,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
continue;
}
var DistaskH = db_SSXcodetimer.Queryable<WmsDistaskH>().Where(p => p.carry_code == result && p.status != WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID).OrderByDescending(p => p.create_time).First();
var DistaskH = db_SSXcodetimer.Queryable<WmsDistaskH>().Where(p => p.carry_code == result && p.status != WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID && p.status != WmsWareHouseConst.TASK_BILL_STATUS_CANCEL_ID).OrderByDescending(p => p.create_time).First();
if (DistaskH != null)
{
string target = putdic.Keys.Contains(DistaskH.startlocation_code) ? putdic.Where(p => p.Key == DistaskH.startlocation_code).First().Value.ToString() : "13";
@@ -1926,24 +1924,26 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
async void ElevatorTaskExceptionHandle(object args)
{
Task[] taskActions = new Task[s_elevatortaskDic.Count];
Task[] taskActions = new Task[_wareHouseService.s_elevatortaskDic.Count];
int index = 0;
foreach (string area in s_elevatortaskDic.Keys)
foreach (string area in _wareHouseService.s_elevatortaskDic.Keys)
{
SemaphoreSlim s_elevatortask = s_elevatortaskDic[area];
SemaphoreSlim s_elevatortask = _wareHouseService.s_elevatortaskDic[area];
if (s_elevatortask.CurrentCount == 0)
return;
await s_elevatortask.WaitAsync();
var db_ElevatorTaskExceptionHandle = db_ElevatorTaskExceptionHandles[index];
var db_ElevatorTaskExceptionHandle = _wareHouseService.db_ElevatorTaskExceptionHandles[index];
taskActions[index] = Task.Run(async () =>
{
try
{
// 获取未判定几托下的电梯任务或者已判定一托下的电梯任务
// 因为电梯任务判定为一托下之后会回写act_start_date后续同电梯小车不会进入到已判定过几托下的电梯不存在同电梯既有act_start_date为空又有act_start_date不为空的情况
List<WmsDistaskH> elevatorTasks = db_ElevatorTaskExceptionHandle.Queryable<WmsDistaskH>()
.Where(r => r.area_code == area && r.act_start_date == null && r.act_end_date == null
.Where(r => r.area_code == area && r.act_end_date == null
&& r.status != WmsWareHouseConst.TASK_BILL_STATUS_CANCEL_ID && r.status != WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID).ToList();
LoggerElevatorTask.Information($"【ElevatorTaskExceptionHandle】检查到需要恢复/执行的电梯任务{elevatorTasks.Count}条 {string.Join(',', elevatorTasks.Select(x => x.bill_code))}");
@@ -1951,6 +1951,8 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
if (elevatorTasks?.Count > 0)
{
LoggerElevatorTask.Information($"【ElevatorTaskExceptionHandle】{JsonConvert.SerializeObject(elevatorTasks)}");
List<IGrouping<string, WmsDistaskH>> elevatorTaskGroup = elevatorTasks.GroupBy(r => $"{r.endlocation_code} {r.end_floor}").ToList();
foreach (IGrouping<string, WmsDistaskH> group in elevatorTaskGroup)
{
@@ -1977,8 +1979,9 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
wmsDistaskHs[0].device_id = e.device_id;
wmsDistaskHs[1].device_id = e.device_id;
}
LoggerElevatorTask.Information($"【ElevatorTaskExceptionHandle】呼叫电梯 {e.elevator_code}");
await _wareHouseService.ExecuteTargetFloorTask(wmsDistaskHs);
await _wareHouseService.ExecuteTargetFloorTask(wmsDistaskHs, db_ElevatorTaskExceptionHandle);
LoggerElevatorTask.Information($"【ElevatorTaskExceptionHandle】呼叫电梯 {e.elevator_code}执行完成");
}
// 一托货
@@ -1993,9 +1996,13 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
{
wmsDistaskHs[0].device_id = e.device_id;
}
LoggerElevatorTask.Information($"【ElevatorTaskExceptionHandle】呼叫电梯 {e.elevator_code}");
await _wareHouseService.ExecuteTargetFloorTask(wmsDistaskHs);
await _wareHouseService.ExecuteTargetFloorTask(wmsDistaskHs, db_ElevatorTaskExceptionHandle);
LoggerElevatorTask.Information($"【ElevatorTaskExceptionHandle】呼叫电梯 {e.elevator_code}执行完成");
}
}
else
@@ -2011,7 +2018,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
wmsDistaskHs[0].device_id = e.device_id;
}
LoggerElevatorTask.Information($"【ElevatorTaskExceptionHandle】呼叫电梯 {e.elevator_code}");
await _wareHouseService.ExecuteTargetFloorTask(wmsDistaskHs);
await _wareHouseService.ExecuteTargetFloorTask(wmsDistaskHs, db_ElevatorTaskExceptionHandle);
LoggerElevatorTask.Information($"【ElevatorTaskExceptionHandle】呼叫电梯 {e.elevator_code}执行完成");
}