呼叫空货架计算最空的位置
This commit is contained in:
@ -48,6 +48,7 @@ namespace WCS.BLL.Services.Service
|
||||
Data = null,
|
||||
};
|
||||
}
|
||||
#endregion
|
||||
|
||||
//获取当前工位的货架
|
||||
var shelf = await DbHelp.db.Queryable<ShelfInfo>()
|
||||
@ -67,7 +68,7 @@ namespace WCS.BLL.Services.Service
|
||||
};
|
||||
}
|
||||
//运输中
|
||||
else if(shelf.TransStatus == TransStatusEnum.运输中 && shelf.DestinationLocationId == endLocation.Id)
|
||||
else if (shelf.TransStatus == TransStatusEnum.运输中 && shelf.DestinationLocationId == endLocation.Id)
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
@ -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)
|
||||
.FirstAsync();
|
||||
.Where(t => t.ShelfStatus == ShelfStatusEnum.空货架)
|
||||
.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 == "成功")
|
||||
@ -209,7 +253,7 @@ namespace WCS.BLL.Services.Service
|
||||
#endregion
|
||||
|
||||
var endLocation = await DbHelp.db.Queryable<LocationInfo>()
|
||||
.LeftJoin<ShelfInfo>((li,si) => (li.Id == si.CurrentLocationId && si.TransStatus == TransStatusEnum.静止) || (li.Id == si.DestinationLocationId && si.TransStatus == TransStatusEnum.运输中))
|
||||
.LeftJoin<ShelfInfo>((li, si) => (li.Id == si.CurrentLocationId && si.TransStatus == TransStatusEnum.静止) || (li.Id == si.DestinationLocationId && si.TransStatus == TransStatusEnum.运输中))
|
||||
.Where((li, si) => li.LocationAreaId == request.SendBackLocationAreaId)
|
||||
.Where((li, si) => li.IsEnable == true)
|
||||
.Where((li, si) => li.Id != shelf.CurrentLocationId)
|
||||
|
Reference in New Issue
Block a user