This commit is contained in:
2024-06-14 17:06:57 +08:00
parent 5721d85013
commit 71e83874bf
11 changed files with 334 additions and 147 deletions

View File

@@ -364,6 +364,50 @@ namespace Tnb.WarehouseMgr
return input.Size > 0 ? items.Take(input.Size).ToList() : items;
}
/// <summary>
/// 原材料仓出库策略
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="AppFriendlyException"></exception>
public async Task<List<WmsCarryH>> OutStockStrategyYCL([FromQuery] OutStockStrategyQuery input)
{
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))
.And((a, b, c) => c.is_type == ((int)EnumLocationType.).ToString())
.And((a, b, c) => a.out_status == "0")
.And((a, b, c) => c.wh_id == input.warehouse_id)
.AndIF(!string.IsNullOrEmpty(input.material_id), (a, b, c) => b.material_id == input.material_id)
.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);
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)
{
throw new AppFriendlyException("没有可用策略", 500);
}
List<WmsCarryH> items = await cyDb.Queryable<WmsCarryH>().LeftJoin<WmsCarryCode>((a, b) => a.id == b.carry_id)
.LeftJoin<BasLocation>((a, b, c) => a.location_id == c.id)
.Where(whereExpr)
//.OrderByIF((a,b,c)=>SqlFunc.IsNullOrEmpty())
.OrderBy(policy.policy)
.Select<WmsCarryH>()
.Distinct()
.ToListAsync();
return input.Size > 0 ? items.Take(input.Size).ToList() : items;
}
/// <summary>
/// 判断CTU是否可以放货
/// </summary>
@@ -564,8 +608,27 @@ namespace Tnb.WarehouseMgr
getdic.Add("ZS-C04-2", new string[] { "hxjC", "A5AGV允许入满箱", "true" });
getdic.Add("ZS-C05-2", new string[] { "hxjC", "A6AGV允许入满箱", "true" });
getdic.Add("ZS-C06-2", new string[] { "hxjC", "A7AGV允许入满箱", "true" });
getdic.Add("ZS-C07-2", new string[] { "hxjC", "A8AGV允许入满箱", "true" });
getdic.Add("ZS-C08-2", new string[] { "hxjC", "A9AGV允许入满箱", "true" });
getdic.Add("ZS-C09-2", new string[] { "hxjC", "A10AGV允许入满箱", "true" });
getdic.Add("ZS-C10-2", new string[] { "hxjC", "A11AGV允许入满箱", "true" });
getdic.Add("ZS-C11-2", new string[] { "hxjC", "A12AGV允许入满箱", "true" });
getdic.Add("ZS-C12-2", new string[] { "hxjC", "A13AGV允许入满箱", "true" });
getdic.Add("ZS-C13-2", new string[] { "hxjC", "A14AGV允许入满箱", "true" });
getdic.Add("ZS-C14-2", new string[] { "hxjC", "A1AGV允许入满箱", "true" });
getdic.Add("ZS-A01-2", new string[] { "hxjA", "A3AGV允许入满箱", "true" });
getdic.Add("ZS-A02-2", new string[] { "hxjA", "A4AGV允许入满箱", "true" });
getdic.Add("ZS-A03-2", new string[] { "hxjA", "A5AGV允许入满箱", "true" });
getdic.Add("ZS-A04-2", new string[] { "hxjA", "A6AGV允许入满箱", "true" });
getdic.Add("ZS-A05-2", new string[] { "hxjA", "A7AGV允许入满箱", "true" });
getdic.Add("ZS-A06-2", new string[] { "hxjA", "A8AGV允许入满箱", "true" });
getdic.Add("ZS-A07-2", new string[] { "hxjA", "A9AGV允许入满箱", "true" });
getdic.Add("ZS-A08-2", new string[] { "hxjA", "A10AGV允许入满箱", "true" });
getdic.Add("ZS-A09-2", new string[] { "hxjA", "A11AGV允许入满箱", "true" });
getdic.Add("ZS-A10-2", new string[] { "hxjA", "A12AGV允许入满箱", "true" });
getdic.Add("ZS-A11-2", new string[] { "hxjA", "A13AGV允许入满箱", "true" });
getdic.Add("ZS-A12-2", new string[] { "hxjA", "A14AGV允许入满箱", "true" });
@@ -584,6 +647,28 @@ namespace Tnb.WarehouseMgr
putdic.Add("ZS-C04-1", new string[] { "hxjC", "A5AGV允许出空箱", "true" });
putdic.Add("ZS-C05-1", new string[] { "hxjC", "A6AGV允许出空箱", "true" });
putdic.Add("ZS-C06-1", new string[] { "hxjC", "A7AGV允许出空箱", "true" });
putdic.Add("ZS-C07-1", new string[] { "hxjC", "A8AGV允许出空箱", "true" });
putdic.Add("ZS-C08-1", new string[] { "hxjC", "A9AGV允许出空箱", "true" });
putdic.Add("ZS-C09-1", new string[] { "hxjC", "A10AGV允许出空箱", "true" });
putdic.Add("ZS-C10-1", new string[] { "hxjC", "A11AGV允许出空箱", "true" });
putdic.Add("ZS-C11-1", new string[] { "hxjC", "A12AGV允许出空箱", "true" });
putdic.Add("ZS-C12-1", new string[] { "hxjC", "A13AGV允许出空箱", "true" });
putdic.Add("ZS-C13-1", new string[] { "hxjC", "A14AGV允许出空箱", "true" });
putdic.Add("ZS-C14-1", new string[] { "hxjC", "A1AGV允许出空箱", "true" });
putdic.Add("ZS-A01-1", new string[] { "hxjA", "A3AGV允许出空箱", "true" });
putdic.Add("ZS-A02-1", new string[] { "hxjA", "A4AGV允许出空箱", "true" });
putdic.Add("ZS-A03-1", new string[] { "hxjA", "A5AGV允许出空箱", "true" });
putdic.Add("ZS-A04-1", new string[] { "hxjA", "A6AGV允许出空箱", "true" });
putdic.Add("ZS-A05-1", new string[] { "hxjA", "A7AGV允许出空箱", "true" });
putdic.Add("ZS-A06-1", new string[] { "hxjA", "A8AGV允许出空箱", "true" });
putdic.Add("ZS-A07-1", new string[] { "hxjA", "A9AGV允许出空箱", "true" });
putdic.Add("ZS-A08-1", new string[] { "hxjA", "A10AGV允许出空箱", "true" });
putdic.Add("ZS-A09-1", new string[] { "hxjA", "A11AGV允许出空箱", "true" });
putdic.Add("ZS-A10-1", new string[] { "hxjA", "A12AGV允许出空箱", "true" });
putdic.Add("ZS-A11-1", new string[] { "hxjA", "A13AGV允许出空箱", "true" });
putdic.Add("ZS-A12-1", new string[] { "hxjA", "A14AGV允许出空箱", "true" });
if (action == "LOAD")//取货
{
if (getdic.Keys.Contains(disTask.startlocation_code))
@@ -826,6 +911,11 @@ namespace Tnb.WarehouseMgr
[HttpPost]
public async Task GenTaskExecute()
{
if (s_taskExecuteSemaphore.CurrentCount == 0)
{
Logger.Information("【GenTaskExecute】 【测试】 丢弃此执行");
return;
}
await s_taskExecuteSemaphore.WaitAsync();
await CTUTaskExecute();
@@ -852,6 +942,7 @@ namespace Tnb.WarehouseMgr
third_eqp_type = c.third_eqp_type,
}, true);
Logger.Information($"【GenTaskExecute】 获取到{sugarQueryable.Count()}条可执行的预任务...");
if (sugarQueryable.Count() == 0)
return;
@@ -1088,7 +1179,7 @@ namespace Tnb.WarehouseMgr
}
catch (Exception ex)
{
Logger.Error("生成预任务执行时出现错误", ex);
Logger.Error("【GenTaskExecute】生成预任务执行时出现错误", ex);
Logger.Error(ex.StackTrace!);
await db.Ado.RollbackTranAsync();
throw;
@@ -1097,6 +1188,9 @@ namespace Tnb.WarehouseMgr
{
_ = s_taskExecuteSemaphore.Release();
agvCts.Dispose();
sw.Stop();
Logger.Error($"【GenTaskExecute】 任务执行耗时{sw.ElapsedMilliseconds}毫秒");
}
}
@@ -2240,6 +2334,8 @@ namespace Tnb.WarehouseMgr
private async Task<List<WmsPointH>> LocPathCalcAlgorithms(string pStartId, string pEndId, List<WmsRoad> roads)
{
Logger.Information($"【LocPathCalcAlgorithms】开始执行 pStartId:{pStartId} pEndId:{pEndId}");
Stopwatch stopwatch = Stopwatch.StartNew();
#region dp
//List<WmsPointH> results = new();
//var points = await _db.Queryable<WmsPointH>().ToListAsync();
@@ -2318,6 +2414,12 @@ namespace Tnb.WarehouseMgr
Logger.Error("路径算法错误", ex);
throw;
}
finally
{
stopwatch.Stop();
Logger.Information($"【LocPathCalcAlgorithms】耗时{stopwatch.ElapsedMilliseconds}");
}
return results;
#endregion
@@ -2551,6 +2653,16 @@ namespace Tnb.WarehouseMgr
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == input.endlocation_id);
}
if (sPoint == null)
{
throw new Exception($"库位{input.startlocation_id} 的起点点位未维护");
}
if (ePoint == null)
{
throw new Exception($"库位{input.endlocation_id} 的终点点位未维护");
}
List<WmsPointH> points = new List<WmsPointH>();
if (sPoint.area_code != ePoint.area_code)
{