wms电梯设定,新增开关电梯控制接口
This commit is contained in:
@@ -161,7 +161,7 @@ namespace Tnb.WarehouseMgr
|
||||
List<BasLocation> items = new();
|
||||
try
|
||||
{
|
||||
WmsInstockPolicies policy = await _db.Queryable<WmsInstockPolicies>().Where(it => it.status == 1).FirstAsync();
|
||||
WmsInstockPolicies policy = await _db.CopyNew().Queryable<WmsInstockPolicies>().Where(it => it.status == 1).FirstAsync();
|
||||
if (policy == null)
|
||||
{
|
||||
throw new AppFriendlyException("没有可用的策略", 500);
|
||||
@@ -173,7 +173,7 @@ namespace Tnb.WarehouseMgr
|
||||
.And(it => it.is_type == ((int)EnumLocationType.存储库位).ToString())
|
||||
.And(it => it.is_use == ((int)EnumCarryStatus.空闲).ToString())
|
||||
.ToExpression();
|
||||
items = await _db.Queryable<BasLocation>().Where(whereExp).OrderBy(policy.policy).ToListAsync();
|
||||
items = await _db.CopyNew().Queryable<BasLocation>().Where(whereExp).OrderBy(policy.policy).ToListAsync();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -238,6 +238,7 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
//获取电梯数据
|
||||
List<WmsElevatorH> elevatorList = await db.Queryable<WmsElevatorH>().InnerJoin<WmsElevatorD>((a, b) => a.id == b.bill_id)
|
||||
.Where((a, b) => a.enabled == 1)
|
||||
.Select((a, b) => new WmsElevatorH
|
||||
{
|
||||
|
||||
@@ -249,6 +250,7 @@ namespace Tnb.WarehouseMgr
|
||||
floor = b.floor
|
||||
|
||||
}, true).ToListAsync();
|
||||
Logger.Information($"可用电梯信息:{elevatorList.Select(e => e.elevator_code)}");
|
||||
|
||||
|
||||
//获取所有未下发的预任务申请
|
||||
@@ -416,14 +418,14 @@ namespace Tnb.WarehouseMgr
|
||||
foreach (var at in agvDTTasks)
|
||||
{
|
||||
var ele = elevatorList.Find(x => x.location_code == at.endlocation_code);
|
||||
Logger.Information($"ele.elevator_id={ele?.elevator_id}");
|
||||
Logger.Information($"ele.elevator_id:{ele?.elevator_id},elevator_code:{ele.elevator_code}");
|
||||
if (ele != null)
|
||||
{
|
||||
at.device_id = ele.elevator_id;
|
||||
}
|
||||
}
|
||||
|
||||
List<(string endlocation_code, string device_id, string id, string? start_floor)> endLocCodes = agvDTTasks
|
||||
List<(string endlocation_code, string device_id, string id, int start_floor)> endLocCodes = agvDTTasks
|
||||
.Select(it => (it.endlocation_code, it.device_id, it.id, it.start_floor)).ToList();
|
||||
if (endLocCodes?.Count > 0)
|
||||
{
|
||||
@@ -475,13 +477,13 @@ namespace Tnb.WarehouseMgr
|
||||
/// </summary>
|
||||
/// <param name="endLocCodes"></param>
|
||||
/// <returns></returns>
|
||||
private async Task CallingLanding(List<(string endlocation_code, string device_id, string id, string floorNO)> endLocCodes)
|
||||
private async Task CallingLanding(List<(string endlocation_code, string device_id, string id, int floorNO)> endLocCodes)
|
||||
{
|
||||
Logger.Information($" 开始呼梯操作.............");
|
||||
Logger.Information($"电梯信息:{JsonConvert.SerializeObject(s_elevatorMap)}");
|
||||
try
|
||||
{
|
||||
foreach ((_, string devId, string disTaskId, string floorNO) in endLocCodes)
|
||||
foreach ((_, string devId, string disTaskId, int floorNO) in endLocCodes)
|
||||
{
|
||||
Logger.Information($"devId:{devId}");
|
||||
if (!s_elevatorMap.TryGetValue(devId, out object? elevatorCode))
|
||||
@@ -597,7 +599,7 @@ namespace Tnb.WarehouseMgr
|
||||
} while (doorStatus != 4);
|
||||
Logger.Information($"当前门状态:{doorStatus}");
|
||||
|
||||
int floor = await GetRealFloor(disTask.end_floor.ParseToInt());
|
||||
int floor = await GetRealFloor(disTask.end_floor);
|
||||
|
||||
Logger.Information($"目标楼层:{floor}");
|
||||
|
||||
@@ -608,7 +610,7 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
do
|
||||
{
|
||||
tuple = await _elevatorControlService.GetElevatorStatus(devName,tags, CancellationToken.None);
|
||||
tuple = await _elevatorControlService.GetElevatorStatus(devName, tags, CancellationToken.None);
|
||||
await Task.Delay(1000);
|
||||
} while (tuple.sysStatus != 3 && tuple.runStatus != 0);
|
||||
|
||||
@@ -986,27 +988,38 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
List<WmsRoad> roads = await _db.Queryable<WmsRoad>().Where(it => it.status == 1).ToListAsync();
|
||||
List<WmsPointH> points = await LocPathCalcAlgorithms(pStartId, pEndId, roads);
|
||||
Logger.Information($"points:{string.Join(",", points.Select(p => p.point_code))}");
|
||||
try
|
||||
{
|
||||
if (points.FindAll(x => x.location_code != null && x.location_code.Contains("dt", StringComparison.OrdinalIgnoreCase))?.Count > 0)
|
||||
if (points?.FindAll(x => x.location_code != null && x.location_code.Contains("dt", StringComparison.OrdinalIgnoreCase))?.Count > 0)
|
||||
{
|
||||
Logger.Information("包含电梯Agv任务");
|
||||
//查询当前电梯点
|
||||
List<WmsElevatorD> curEleDs = await _db.Queryable<WmsElevatorD>().Where(it => points.Select(x => x.id).Contains(it.point_id)).ToListAsync();
|
||||
List<WmsElevatorD> curEleDs = await _db.Queryable<WmsElevatorD>().InnerJoin<WmsElevatorH>((a, b) => a.bill_id == b.id).Where((a, b) => points.Select(x => x.id).Contains(a.point_id)).ToListAsync();
|
||||
Logger.Information($"curEleDs==null :{curEleDs == null},curEleDs:{string.Join(",", curEleDs.Select(x => x.bill_id))}");
|
||||
//如果有电梯点,则会进行电梯的均匀分配
|
||||
if (curEleDs?.Count > 0)
|
||||
{
|
||||
//当前电梯
|
||||
WmsElevatorH curEle = await _db.Queryable<WmsElevatorH>().SingleAsync(it => it.id == curEleDs.First().bill_id && it.enabled == 1);
|
||||
WmsElevatorH curEle = await _db.Queryable<WmsElevatorH>().SingleAsync(it => it.id == curEleDs.First().bill_id);
|
||||
Logger.Information($"curEle==null :{curEle == null}");
|
||||
|
||||
//同电梯组电梯
|
||||
List<WmsElevatorH> sGpEle = await _db.Queryable<WmsElevatorH>().Where(it => it.elevator_group == curEle.elevator_group && it.id != curEle.id && it.enabled == 1).ToListAsync();
|
||||
|
||||
if (curEle == null && sGpEle?.Count > 0)
|
||||
if (curEle.enabled == 0 && (sGpEle == null || sGpEle.Count < 1))
|
||||
{
|
||||
throw new AppFriendlyException("电梯被禁用或未配置", 500);
|
||||
}
|
||||
|
||||
if ((sGpEle == null || sGpEle.Count < 1) && curEle.enabled == 1)
|
||||
{
|
||||
return points;
|
||||
}
|
||||
if (sGpEle?.Count > 0 && curEle.enabled == 0)
|
||||
{
|
||||
return points;
|
||||
}
|
||||
//判断电梯组中各电梯任务数
|
||||
if (curEle == null || sGpEle.FindAll(x => Math.Abs(x.task_nums - curEle.task_nums) % 2 == 1)?.Count > 0)
|
||||
if (sGpEle.FindAll(x => Math.Abs(x.task_nums - curEle.task_nums) % 2 == 1)?.Count > 0)
|
||||
{
|
||||
List<WmsElevatorD> sGpDs = await _db.Queryable<WmsElevatorD>().Where(it => it.bill_id == sGpEle.First().id).ToListAsync();
|
||||
if (sGpDs?.Count > 0)
|
||||
|
||||
Reference in New Issue
Block a user