优先级、巷道、分区

This commit is contained in:
2024-07-25 09:58:47 +08:00
parent 79a1828b21
commit 5b5783376b
14 changed files with 314 additions and 79 deletions

View File

@@ -522,5 +522,20 @@
/// 单位类型id
/// </summary>
public const string UNITTYPEID = "24906054811669";
/// <summary>
/// 优先级-出库
/// </summary>
public const int priority_outstock = -50;
/// <summary>
/// 优先级-入库
/// </summary>
public const int priority_instock = -100;
/// <summary>
/// 原材料八工位待入库
/// </summary>
public const string LOCATION_YCLBGWDRK = "35750287617301";
}
}

View File

@@ -56,6 +56,10 @@ namespace Tnb.WarehouseMgr.Entities.Dto.Inputs
/// </summary>
public bool isChangeCarryLoc2StartLoc { get; set; } = true;
}
/// <summary>
/// 优先级
/// </summary>
public int priority { get; set; } = 0;
}
}

View File

@@ -23,5 +23,13 @@
public int BllType { get; set; }
public int Size { get; set; }
public string Region_id { get; set; }
// 排除有任务的通道
public bool AvoidBusyPassage { get; set; } = false;
// 巷道
public string passage { get; set; }
}
}

View File

@@ -41,5 +41,13 @@
/// 箱号
/// </summary>
public string? container_no { get; set; }
public string Region_id { get; set; }
// 排除有任务的通道
public bool AvoidBusyPassage { get; set; } = false;
// 是否过滤载具占用状态
public bool filter_carry_status { get; set; } = true;
}
}

View File

@@ -235,4 +235,8 @@ public partial class WmsDistaskH : BaseEntity<string>
/// </summary>
public string endlocation_code { get; set; } = string.Empty;
/// <summary>
/// 优先级
/// </summary>
public int? priority { get; set; }
}

View File

@@ -176,7 +176,7 @@ public partial class WmsPretaskH : BaseEntity<string>
/// <summary>
/// 优先级
/// </summary>
public int priority { get; set; } = 1;
public int priority { get; set; } = 0;
/// <summary>
/// 优先级
/// </summary>

View File

@@ -57,7 +57,7 @@ namespace Tnb.WarehouseMgr
{
get
{
string newFileName = $"{AppContext.BaseDirectory}/logs/custom{DateTime.Now:yyyyMMdd}.log";
string newFileName = $"{AppContext.BaseDirectory}/logs/{DateTime.Now:yyyyMMdd}/custom{DateTime.Now:yyyyMMdd}汇总日志.log";
if (_LoggerFileName != newFileName)
{
ILoggerFactory loggerFactory = LoggerFactory.Create(builder => builder.AddFile(newFileName, cfgOpts =>

View File

@@ -157,7 +157,7 @@ namespace Tnb.WarehouseMgr
}
try
{
if (s_elevatorMap.TryGetValue(elevator.device_id, out object? elevatorCode))
if (elevator != null && s_elevatorMap.TryGetValue(elevator.device_id, out object? elevatorCode))
{
//s_eleUseStatusDic[elevator.device_id] = (int)EnumElevatorUseStatus.空闲;
string devName = elevatorCode?.ToString();

View File

@@ -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,

View File

@@ -17,6 +17,7 @@ using Npgsql;
using Senparc.Weixin.MP.AdvancedAPIs.Card;
using SqlSugar;
using Tnb.WarehouseMgr.Entities;
using Tnb.WarehouseMgr.Entities.Consts;
using Tnb.WarehouseMgr.Entities.Dto;
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
using Tnb.WarehouseMgr.Entities.Dto.Outputs;
@@ -152,6 +153,12 @@ namespace Tnb.WarehouseMgr
return result;
}
/// <summary>
/// 仅原材料仓八工位PDA使用
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="AppFriendlyException"></exception>
[HttpPost]
public async Task CarryMaterialBind(CarryMaterialBindInput input)
{
@@ -172,6 +179,12 @@ namespace Tnb.WarehouseMgr
int rows = 0;
if (WmsCarryCodes.Count > 0)
rows = await _db.Insertable(WmsCarryCodes).ExecuteCommandAsync();
await _db.Updateable<WmsCarryH>().SetColumns(r => new WmsCarryH
{
location_id = WmsWareHouseConst.LOCATION_YCLBGWDRK,
location_code = "YCLBGWDRK"
}).Where(r => r.id == carry.id).ExecuteCommandAsync();
if (rows == 0)
{
throw new Exception($"物料列表为空,不能提交绑定,可能的原因;1.需要检查扫码设置(新PDA) 2.未扫到有效的二维码 详细信息:接收到{input.details.Count}个条码 但是成功绑定的条码数量为0个");

View File

@@ -513,6 +513,7 @@ namespace Tnb.WarehouseMgr
commonCreatePretaskInput.carry_id = wmsCarryHs[index].id;
commonCreatePretaskInput.carry_code = wmsCarryHs[index].carry_code;
commonCreatePretaskInput.isExcuteMission = false;
commonCreatePretaskInput.priority = WmsWareHouseConst.priority_outstock;
Entities.Dto.Outputs.Result res = await _wareHouseService.CommonCreatePretask(commonCreatePretaskInput, _db);

View File

@@ -483,8 +483,8 @@ namespace Tnb.WarehouseMgr
_ = await _dbScanInStockByRedis.Insertable(instockCode).ExecuteCommandAsync();
Logger.LogInformation($"【ScanInStockByRedis】插入WmsInstockCode {JsonConvert.SerializeObject(instockCode)}");
}
InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = "1", Size = 1 };
InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = "1", Size = 1, AvoidBusyPassage = true, Region_id = WmsWareHouseConst.REGION_YCLCache_ID };
List<BasLocation> endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput);
WmsPointH sPoint = new();
WmsPointH ePoint = new();
@@ -554,7 +554,8 @@ namespace Tnb.WarehouseMgr
require_id = instock.id,
require_code = instock.bill_code,
create_id = _userManager.User == null ? "" : _userManager.UserId!,
create_time = DateTime.Now
create_time = DateTime.Now,
priority = WmsWareHouseConst.priority_instock
};
return preTask;
}).ToList();