优先级、巷道、分区
This commit is contained in:
@@ -215,18 +215,36 @@ namespace Tnb.WarehouseMgr
|
||||
List<BasLocation> items = new();
|
||||
try
|
||||
{
|
||||
WmsInstockPolicies policy = await _db.CopyNew().Queryable<WmsInstockPolicies>().Where(it => it.status == 1).FirstAsync();
|
||||
var db = _db.CopyNew();
|
||||
WmsInstockPolicies policy = await db.Queryable<WmsInstockPolicies>().Where(it => it.status == 1).FirstAsync();
|
||||
if (policy == null)
|
||||
{
|
||||
throw new AppFriendlyException("没有可用的策略", 500);
|
||||
}
|
||||
|
||||
List<string> busyPassages = new();
|
||||
if (input.AvoidBusyPassage)
|
||||
{
|
||||
busyPassages = await db.Queryable<WmsPretaskH>()
|
||||
.InnerJoin<BasLocation>((a, b) =>
|
||||
(a.status != WmsWareHouseConst.PRETASK_BILL_STATUS_COMPLE_ID && a.status != WmsWareHouseConst.PRETASK_BILL_STATUS_CANCEL_ID)
|
||||
&& (b.id == a.startlocation_id || b.id == a.endlocation_id))
|
||||
.Where((a, b) => b.wh_id == input.warehouse_id)
|
||||
.Where((a, b) => b.is_type == ((int)EnumLocationType.存储库位).ToString())
|
||||
.WhereIF(!string.IsNullOrEmpty(input.Region_id), (a, b) => b.region_id == input.Region_id)
|
||||
.Select((a, b) => b.passage).ToListAsync();
|
||||
}
|
||||
|
||||
Expression<Func<BasLocation, bool>> whereExp = Expressionable.Create<BasLocation>()
|
||||
.And(it => it.wh_id == input.warehouse_id)
|
||||
.And(it => it.is_lock == 0)
|
||||
.And(it => it.is_type == ((int)EnumLocationType.存储库位).ToString())
|
||||
.And(it => it.is_use == ((int)EnumCarryStatus.空闲).ToString())
|
||||
.AndIF(!string.IsNullOrEmpty(input.Region_id), it => it.region_id == input.Region_id)
|
||||
.AndIF(input.AvoidBusyPassage, it => !busyPassages.Contains(it.passage))
|
||||
.AndIF(!string.IsNullOrEmpty(input.passage), it => it.passage == input.passage)
|
||||
.ToExpression();
|
||||
|
||||
items = await _db.CopyNew().Queryable<BasLocation>().Where(whereExp).OrderBy(policy.policy).ToListAsync();
|
||||
}
|
||||
catch (Exception)
|
||||
@@ -410,6 +428,20 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
public async Task<List<WmsCarryH>> OutStockStrategy([FromQuery] OutStockStrategyQuery input)
|
||||
{
|
||||
SqlSugarClient cyDb = _db.CopyNew();
|
||||
List<string> busyPassages = new();
|
||||
if (input.AvoidBusyPassage)
|
||||
{
|
||||
busyPassages = await cyDb.Queryable<WmsPretaskH>()
|
||||
.InnerJoin<BasLocation>((a, b) =>
|
||||
(a.status != WmsWareHouseConst.PRETASK_BILL_STATUS_COMPLE_ID && a.status != WmsWareHouseConst.PRETASK_BILL_STATUS_CANCEL_ID)
|
||||
&& (b.id == a.startlocation_id || b.id == a.endlocation_id))
|
||||
.Where((a, b) => b.wh_id == input.warehouse_id)
|
||||
.Where((a, b) => b.is_type == ((int)EnumLocationType.存储库位).ToString())
|
||||
.WhereIF(!string.IsNullOrEmpty(input.Region_id), (a, b) => b.region_id == input.Region_id)
|
||||
.Select((a, b) => b.passage).ToListAsync();
|
||||
}
|
||||
|
||||
Expressionable<WmsCarryH, WmsCarryCode, BasLocation> whereExprable = Expressionable.Create<WmsCarryH, WmsCarryCode, BasLocation>()
|
||||
.And((a, b, c) => a.is_lock == 0 && c.is_lock == 0)
|
||||
.And((a, b, c) => !string.IsNullOrEmpty(a.location_id))
|
||||
@@ -420,14 +452,20 @@ namespace Tnb.WarehouseMgr
|
||||
.AndIF(!string.IsNullOrEmpty(input.code_batch), (a, b, c) => b.code_batch == input.code_batch)
|
||||
.AndIF(!string.IsNullOrEmpty(input.material_specification), (a, b, c) => b.material_specification == input.material_specification)
|
||||
.AndIF(!string.IsNullOrEmpty(input.container_no), (a, b, c) => b.container_no == input.container_no)
|
||||
.AndIF(!string.IsNullOrEmpty(input.carrystd_id), (a, b, c) => a.carrystd_id == input.carrystd_id);
|
||||
Expression<Func<WmsCarryH, WmsCarryCode, BasLocation, bool>> carryStatusFilterExp = !input.material_id.IsNullOrWhiteSpace()
|
||||
? (a, b, c) => a.carry_status == ((int)EnumCarryStatus.占用).ToString()
|
||||
: (a, b, c) => a.carry_status == ((int)EnumCarryStatus.空闲).ToString();
|
||||
_ = whereExprable.And(carryStatusFilterExp);
|
||||
.AndIF(!string.IsNullOrEmpty(input.carrystd_id), (a, b, c) => a.carrystd_id == input.carrystd_id)
|
||||
.AndIF(input.AvoidBusyPassage, (a, b, c) => !busyPassages.Contains(c.passage))
|
||||
.AndIF(!string.IsNullOrEmpty(input.Region_id), (a, b, c) => c.region_id == input.Region_id);
|
||||
|
||||
if (input.filter_carry_status)
|
||||
{
|
||||
Expression<Func<WmsCarryH, WmsCarryCode, BasLocation, bool>> carryStatusFilterExp = !input.material_id.IsNullOrWhiteSpace()
|
||||
? (a, b, c) => a.carry_status == ((int)EnumCarryStatus.占用).ToString()
|
||||
: (a, b, c) => a.carry_status == ((int)EnumCarryStatus.空闲).ToString();
|
||||
_ = whereExprable.And(carryStatusFilterExp);
|
||||
}
|
||||
|
||||
Expression<Func<WmsCarryH, WmsCarryCode, BasLocation, bool>> whereExpr = whereExprable.ToExpression();
|
||||
|
||||
SqlSugarClient cyDb = _db.CopyNew();
|
||||
WmsInstockPolicies policy = await cyDb.Queryable<WmsInstockPolicies>().Where(it => it.status == 1).FirstAsync();
|
||||
if (policy == null)
|
||||
{
|
||||
@@ -442,6 +480,7 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
.Select<WmsCarryH>()
|
||||
.ToListAsync();
|
||||
items = items.DistinctBy(r => r.id).ToList();
|
||||
return input.Size > 0 ? items.Take(input.Size).ToList() : items;
|
||||
}
|
||||
|
||||
@@ -486,7 +525,7 @@ namespace Tnb.WarehouseMgr
|
||||
.Select<WmsCarryH>()
|
||||
.ToListAsync();
|
||||
|
||||
items = items.Distinct().ToList();
|
||||
items = items.DistinctBy(r => r.id).ToList();
|
||||
return input.Size > 0 ? items.Take(input.Size).ToList() : items;
|
||||
}
|
||||
|
||||
@@ -1348,7 +1387,8 @@ namespace Tnb.WarehouseMgr
|
||||
.Where((a, b) => a.status == WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID && !string.IsNullOrWhiteSpace(a.startlocation_id)
|
||||
// 载具为空时 不校验载具当前位置是否与预任务起点相同
|
||||
&& (string.IsNullOrEmpty(a.carry_id) || (!string.IsNullOrEmpty(a.carry_id) && a.startlocation_id == b.location_id)))
|
||||
.OrderBy(a => new { priority = SqlFunc.Desc(a.priority), a.bill_code })
|
||||
.OrderBy(a => new { a.bill_code })
|
||||
.OrderByDescending(a => new { priority = SqlFunc.Desc(a.priority) })
|
||||
.Select((a, b, c, d) => new WmsPretaskH
|
||||
{
|
||||
move_num = c.move_num,
|
||||
@@ -2233,8 +2273,19 @@ namespace Tnb.WarehouseMgr
|
||||
dynamic reqBody = new ExpandoObject();
|
||||
reqBody.taskChainCode = k;
|
||||
reqBody.type = typeflag ? (int)EnumTaskChainType.KIVA : (int)EnumTaskChainType.AGV;
|
||||
reqBody.sequential = false;
|
||||
reqBody.taskChainPriority = 0;
|
||||
|
||||
// 原材料仓使用优先级
|
||||
if (dis.area_code == "A")
|
||||
{
|
||||
reqBody.sequential = true;
|
||||
reqBody.taskChainPriority = dis.priority;
|
||||
}
|
||||
else
|
||||
{
|
||||
reqBody.sequential = false;
|
||||
reqBody.taskChainPriority = 0;
|
||||
}
|
||||
|
||||
reqBody.taskList = v;
|
||||
reqBody.floor = dis.end_floor;
|
||||
Logger.Information($"【AgvDispatch】 Agv任务执行 开始请求联核/task-chain/create接口 请求地址:{url} 请求参数:{JsonConvert.SerializeObject(reqBody)} ");
|
||||
@@ -3433,7 +3484,8 @@ namespace Tnb.WarehouseMgr
|
||||
require_id = input.require_id,
|
||||
require_code = input.require_code,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now
|
||||
create_time = DateTime.Now,
|
||||
priority = input.priority
|
||||
};
|
||||
|
||||
return preTask;
|
||||
@@ -3466,6 +3518,10 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
wmsCarryHChangeExp = a => new WmsCarryH { is_lock = 1, location_id = preTaskUpInput.CarryStartLocationId, location_code = preTaskUpInput.CarryStartLocationCode };
|
||||
}
|
||||
else
|
||||
{
|
||||
wmsCarryHChangeExp = a => new WmsCarryH { is_lock = 1 };
|
||||
}
|
||||
|
||||
await GenInStockTaskHandleAfter(preTaskUpInput,
|
||||
wmsCarryHChangeExp,
|
||||
|
||||
Reference in New Issue
Block a user