呼叫空货架计算最空的位置

This commit is contained in:
hehaibing-1996
2025-03-06 17:33:38 +08:00
parent c48bef5af1
commit f0693b0b2b

View File

@ -48,6 +48,7 @@ namespace WCS.BLL.Services.Service
Data = null,
};
}
#endregion
//获取当前工位的货架
var shelf = await DbHelp.db.Queryable<ShelfInfo>()
@ -86,29 +87,72 @@ namespace WCS.BLL.Services.Service
};
}
}
#region
//判断参数
if (request.LocationId == 0 || string.IsNullOrEmpty(request.LocationCode))
{
return new ResponseCommon()
{
Code = 201,
Message = "工位或工位编码为空!\r\n请重新扫工位码",
Data = null,
};
}
#endregion
//获取空货架进行呼叫
var locations = await DbHelp.db.Queryable<ShelfInfo>()
.LeftJoin<LocationInfo>((si, li) => si.CurrentLocationId == li.Id)
.Where((si, li) => si.TransStatus == TransStatusEnum. && si.CurrentLocationId != 0)
.Where((si, li) => si.ShelfStatus == ShelfStatusEnum.)
.Where((si, li) => si.ShelfTypeId == request.NeedShelfTypeId)
.Where((si, li) => si.IsEnable == true && li.IsEnable == true)
.Select(((si, li) => li))
.ToListAsync();
if (locations == null || locations.Count == 0)
{
return new ResponseCommon()
{
Code = 201,
Message = $"货架类型[{request.NeedShelfTypeName}],不存在空货架!\r\n请稍后重试",
Data = null,
};
}
locations.ForEach(l => l.RowNumber = (int)Math.Abs(endLocation.X - l.X)*2 + (int)Math.Abs(endLocation.Y - l.Y));
locations = locations.OrderBy(l => l.RowNumber).ToList();
var startLocation = locations.FirstOrDefault();
if (startLocation == null)
{
return new ResponseCommon()
{
Code = 201,
Message = $"货架类型[{request.NeedShelfTypeName}],不存在空货架!\r\n请稍后重试",
Data = null,
};
}
shelf = await DbHelp.db.Queryable<ShelfInfo>()
.Where(t => t.TransStatus == TransStatusEnum. && t.CurrentLocationId != 0)
.Where(t => t.ShelfStatus == ShelfStatusEnum.)
.Where(t => t.ShelfTypeId == request.NeedShelfTypeId)
.Where(t => t.IsEnable == true)
.Where(t => t.TransStatus == TransStatusEnum.)
.Where(t => t.CurrentLocationId == startLocation.Id)
.FirstAsync();
if (shelf == null)
{
return new ResponseCommon()
{
Code = 201,
Message = $"货架类型[{request.NeedShelfTypeName}],不存在空货架!",
Message = $"货架类型[{request.NeedShelfTypeName}],不存在空货架!\r\n请稍后重试",
Data = null,
};
}
var startLocation = await DbHelp.db.Queryable<LocationInfo>()
.Where(t => t.Id == shelf.CurrentLocationId)
.Where(t => t.IsEnable == true)
.FirstAsync();
//var startLocation = await DbHelp.db.Queryable<LocationInfo>()
// .Where(t => t.Id == shelf.CurrentLocationId)
// .Where(t => t.IsEnable == true)
// .FirstAsync();
var response = AGVManager.GenAgvSchedulingTask(startLocation, endLocation, shelf.ShelfCode, request.UserName);
if (response.code == "0" && response.message == "成功")