1、任务执行新增,更具目标库位判断是否为电梯库位进行呼梯操作

2、放货确认接口新增代码逻辑
This commit is contained in:
alex
2023-09-27 17:58:13 +08:00
parent c34762b0b3
commit 471d614cf2
12 changed files with 489 additions and 166 deletions

View File

@@ -65,14 +65,19 @@ namespace Tnb.WarehouseMgr
private readonly IBillRullService _billRullService;
private readonly IUserManager _userManager;
private readonly ICacheManager _cacheManager;
private readonly IElevatorControlService _elevatorControlService;
private static Dictionary<string, object> _elevatorMap = new Dictionary<string, object>();
public WareHouseService(ISqlSugarRepository<WmsInstockH> repository, IDictionaryDataService dictionaryDataService, IBillRullService billRullService, IUserManager userManager, ICacheManager cacheManager)
public WareHouseService(ISqlSugarRepository<WmsInstockH> repository, IDictionaryDataService dictionaryDataService,
IBillRullService billRullService, IUserManager userManager, ICacheManager cacheManager, IElevatorControlService elevatorControlService)
{
_db = repository.AsSugarClient();
_dictionaryDataService = dictionaryDataService;
_billRullService = billRullService;
_userManager = userManager;
_cacheManager = cacheManager;
_elevatorControlService = elevatorControlService;
}
@@ -232,6 +237,11 @@ namespace Tnb.WarehouseMgr
Stopwatch sw = Stopwatch.StartNew();
CancellationTokenSource agvCts = new();
if (_elevatorMap.Count < 1)
{
_elevatorMap = await _db.Queryable<WmsElevatorH>().ToDictionaryAsync(x => x.elevator_id, x => x.elevator_code);
}
var db = _db.CopyNew();
try
{
@@ -369,6 +379,42 @@ namespace Tnb.WarehouseMgr
var respBody = await HttpClientHelper.PostStreamAsync(url, reqBody, agvCts.Token);
Log.Information($"调用Agv接口响应结果:{respBody}");
}
//呼梯操作
var endLocCodes = disTasks.Select(it => (it.endlocation_code, it.device_id)).Where(it => it.endlocation_code.StartsWith("DT", StringComparison.OrdinalIgnoreCase)).ToList();
if (endLocCodes?.Count > 0)
{
foreach (var (_, devId) in endLocCodes)
{
var elevatorQueue = await _db.Queryable<WmsElevatorUnexecute>().Where(it => it.elevator_id == devId).ToListAsync();
if (_elevatorMap.ContainsKey(devId) && elevatorQueue?.Count < 1)
{
var devName = _elevatorMap[devId].ToString();
(int sysStatus, int runStatus, int floorNo, int doorStatus, int agvStatus) = await _elevatorControlService.GetElevatorStatus(devName, CancellationToken.None);
//判断当前楼层是否是放货楼层,如不是则呼叫电梯到当前楼层
if (sysStatus.ToEnum<EnumSysStatus>() == EnumSysStatus. && runStatus.ToEnum<EnumRunStatus>() == EnumRunStatus. &&
agvStatus.ToEnum<EnumAgvStatus>() != EnumAgvStatus.AGV运行状态 && floorNo != 4)
{
if (doorStatus.ToEnum<EnumDoorStatus>() != EnumDoorStatus.)
{
await _elevatorControlService.SendOpenCloseCmd(devName, (int)EnumAgvControl.);
}
await _elevatorControlService.WriteTagAsync(devName, ElevatorConsts.FloorExecute, 5); //呼叫电梯到4楼
//将当前呼梯任务放入待执行队列
WmsElevatorUnexecute elevatorQueueItem = new()
{
elevator_id = devId,
elevator_code = _elevatorMap[devId].ToString(),
floor = 4,
create_id = _userManager.UserId,
create_time = DateTime.Now
};
await _db.Storageable(elevatorQueueItem).ExecuteCommandAsync();
}
}
}
}
}
}
catch (Exception ex) when (ex is HttpRequestException hReqEx)
@@ -582,7 +628,7 @@ namespace Tnb.WarehouseMgr
{
//如果预任务出现起终库位相同,则删除对应预任务
//modifiy by ly on 20230922 将当前预任务操作者设为四场管理员
preTasks.ForEach(pt =>
preTasks.ForEach(pt =>
{
pt.org_id = WmsWareHouseConst.AdministratorOrgId;
pt.create_id = WmsWareHouseConst.AdministratorUserId;