现场问题处理,电梯逻辑处理

This commit is contained in:
2024-09-10 17:42:47 +08:00
parent ddae9f34d7
commit fc57a19cf8
20 changed files with 410 additions and 90 deletions

View File

@@ -276,7 +276,11 @@ namespace Tnb.WarehouseMgr
List<BasLocation> items = new();
try
{
var db = _db.CopyNew();
var db = input.dbConn;
if (input.dbConn == null)
{
db = _db.CopyNew();
}
WmsInstockPolicies policy = await db.Queryable<WmsInstockPolicies>().Where(it => it.status == 1 && (string.IsNullOrEmpty(input.PolicyCode)||
it.bill_code == input.PolicyCode)).FirstAsync();
if (policy == null)
@@ -307,7 +311,7 @@ namespace Tnb.WarehouseMgr
.AndIF(!string.IsNullOrEmpty(input.passage), it => it.passage == input.passage)
.ToExpression();
items = await _db.CopyNew().Queryable<BasLocation>().Where(whereExp).OrderBy(policy.policy).ToListAsync();
items = await db.Queryable<BasLocation>().Where(whereExp).OrderBy(policy.policy).ToListAsync();
}
catch (Exception)
{
@@ -325,7 +329,12 @@ namespace Tnb.WarehouseMgr
List<BasLocation> items = new();
try
{
WmsInstockPolicies policy = await _db.CopyNew().Queryable<WmsInstockPolicies>().Where(it => it.status == 1).FirstAsync();
var db = input.dbConn;
if (input.dbConn == null)
{
db = _db.CopyNew();
}
WmsInstockPolicies policy = await db.Queryable<WmsInstockPolicies>().Where(it => it.status == 1).FirstAsync();
if (policy == null)
{
throw new AppFriendlyException("没有可用的策略", 500);
@@ -337,7 +346,7 @@ namespace Tnb.WarehouseMgr
.And(it => it.is_type == ((int)EnumLocationType.).ToString())
.And(it => it.is_use == ((int)EnumCarryStatus.).ToString())
.ToExpression();
items = await _db.CopyNew().Queryable<BasLocation>().Where(whereExp).OrderBy(policy.policy).ToListAsync();
items = await db.Queryable<BasLocation>().Where(whereExp).OrderBy(policy.policy).ToListAsync();
}
catch (Exception)
{
@@ -356,7 +365,12 @@ namespace Tnb.WarehouseMgr
List<BasLocation> items = new();
try
{
WmsInstockPolicies policy = await _db.CopyNew().Queryable<WmsInstockPolicies>().Where(it => it.status == 1).FirstAsync();
var db = input.dbConn;
if (input.dbConn == null)
{
db = _db.CopyNew();
}
WmsInstockPolicies policy = await db.Queryable<WmsInstockPolicies>().Where(it => it.status == 1).FirstAsync();
if (policy == null)
{
throw new AppFriendlyException("没有可用的策略", 500);
@@ -368,7 +382,7 @@ namespace Tnb.WarehouseMgr
.And(it => it.is_type == ((int)EnumLocationType.).ToString())
.And(it => it.is_use == ((int)EnumCarryStatus.).ToString())
.ToExpression();
items = await _db.CopyNew().Queryable<BasLocation>().Where(whereExp).OrderBy(policy.policy).ToListAsync();
items = await db.Queryable<BasLocation>().Where(whereExp).OrderBy(policy.policy).ToListAsync();
}
catch (Exception)
{
@@ -472,7 +486,11 @@ namespace Tnb.WarehouseMgr
_ = whereExprable.And(carryStatusFilterExp);
Expression<Func<WmsCarryH, WmsCarryCode, BasLocation, bool>> whereExpr = whereExprable.ToExpression();
SqlSugarClient cyDb = _db.CopyNew();
var cyDb = input.dbConn;
if (input.dbConn == null)
{
cyDb = _db.CopyNew();
}
List<Tuple<string, WmsCarryH, WmsCarryCode, BasLocation>> items = cyDb.Queryable<WmsCarryH>().LeftJoin<WmsCarryCode>((a, b) => a.id == b.carry_id)
.LeftJoin<BasLocation>((a, b, c) => a.location_id == c.id)
@@ -513,7 +531,11 @@ namespace Tnb.WarehouseMgr
public async Task<List<WmsCarryH>> OutStockStrategy([FromQuery] OutStockStrategyQuery input)
{
SqlSugarClient cyDb = _db.CopyNew();
var cyDb = input.dbConn;
if (input.dbConn == null)
{
cyDb = _db.CopyNew();
}
List<string> busyPassages = new();
if (input.AvoidBusyPassage)
{
@@ -915,8 +937,8 @@ namespace Tnb.WarehouseMgr
putdic.Add("ZS-A03-1", new string[] { "hxjA", "A5允许入空箱", });
getdic.Add("ZS-A03-2", new string[] { "hxjA", "A5允许取满箱" });
putdic.Add("ZS-A04-1", new string[] { "hxjA", "A6允许入空箱", });
getdic.Add("ZS-A04-2", new string[] { "hxjA", "A6允许取满箱" });
putdic.Add("ZS-D06-1", new string[] { "hxjA", "A6允许入空箱", });
getdic.Add("ZS-D06-2", new string[] { "hxjA", "A6允许取满箱" });
putdic.Add("ZS-A05-1", new string[] { "hxjA", "A7允许入空箱", });
getdic.Add("ZS-A05-2", new string[] { "hxjA", "A7允许取满箱" });
@@ -1028,7 +1050,7 @@ namespace Tnb.WarehouseMgr
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-D06-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" });
@@ -1067,7 +1089,7 @@ namespace Tnb.WarehouseMgr
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-D06-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" });
@@ -1116,6 +1138,131 @@ namespace Tnb.WarehouseMgr
}
public async Task SsxControl_complete(WmsDistaskH disTask, string action)
{
Logger.Information($"输送线控制SsxControl_complete传入参数: {JsonConvert.SerializeObject(disTask)} {action}");
Dictionary<string, string[]> putdic = new Dictionary<string, string[]>();
Dictionary<string, string[]> getdic = new Dictionary<string, string[]>();
getdic.Add("SSX-021-005", new string[] { "YTCS", "FullOut_CS05Done", "true" });
getdic.Add("SSX-111-011", new string[] { "东面提升机输送线", "下升降机11出箱完毕", "true" });
getdic.Add("SSX-111-012", new string[] { "东面提升机输送线", "下升降机12出箱完毕", "true" });
getdic.Add("ZZ-01-02", new string[] { "外包装箱码垛线", "WBZX_x1_take_mtp", "true" });
getdic.Add("ZZ-02-02", new string[] { "外包装箱码垛线", "WBZX_x2_take_mtp", "true" });
getdic.Add("ZSSSXCTU02", new string[] { "YTCS", "右输送线上层允许出箱3", "true" });
getdic.Add("ZSSSXCTU01", new string[] { "YTCS", "左输送线上层允许出箱1", "true" });
getdic.Add("SSX-011-008", new string[] { "东面提升机输送线", "入库输送线8出箱完毕", "true" });
getdic.Add("ZS-C01-2", new string[] { "hxjC", "A2AGV允许入满箱", "true" });
getdic.Add("ZS-C02-2", new string[] { "hxjC", "A3AGV允许入满箱", "true" });
getdic.Add("ZS-C03-2", new string[] { "hxjC", "A4AGV允许入满箱", "true" });
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-D06-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" });
putdic.Add("SSX-021-007", new string[] { "东面提升机输送线", "出库输送线7入箱完毕", "true" });
putdic.Add("SSX-011-006", new string[] { "YTCS", "EmptyIn_CS06Done", "true" });
putdic.Add("SSX-021-003", new string[] { "YTCS", "AgvFullIn_CS03Done", "true" });
putdic.Add("SSX-021-001", new string[] { "YTCS", "CtuEmptyIn_CS01Done", "true" });
putdic.Add("ZSSSXCTU02", new string[] { "YTCS", "右输送线下层允许入箱4", "true" });
putdic.Add("ZSSSXCTU01", new string[] { "YTCS", "左输送线下层允许入箱2", "true" });
putdic.Add("SSX-121-009", new string[] { "东面提升机输送线", "上升降机9入箱完毕", "true" });
putdic.Add("SSX-121-010", new string[] { "东面提升机输送线", "上升降机10入箱完毕", "true" });
putdic.Add("YCLCKBGW", new string[] { "CP8", "PutDoneEmptyBox", "true" });
putdic.Add("ZS-C01-1", new string[] { "hxjC", "A2AGV允许出空箱", "true" });
putdic.Add("ZS-C02-1", new string[] { "hxjC", "A3AGV允许出空箱", "true" });
putdic.Add("ZS-C03-1", new string[] { "hxjC", "A4AGV允许出空箱", "true" });
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-D06-1", new string[] { "hxjA", "A6AGV允许出空箱", "false" });
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允许出空箱", "false" });
putdic.Add("ZS-A12-1", new string[] { "hxjA", "A14AGV允许出空箱", "true" });
if (action == "LOAD")//取货
{
if (getdic.Keys.Contains(disTask.startlocation_code))
{
var strarr = getdic.Where(p => p.Key == disTask.startlocation_code).First().Value;
Dictionary<string, string> dicCommand = new(StringComparer.OrdinalIgnoreCase)
{
["DevName"] = strarr[0],
["token"] = _eleCtlCfg.token,
["TagName"] = strarr[1],
["Value"] = strarr[2],
};
Logger.Information($"SsxControlLOAD:{JsonConvert.SerializeObject(dicCommand)}");
var str = await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand);
Logger.Information($"SsxControlLOAD:{str}");
//Logger.Information($"SsxControlUNLOAD - 控制后查询:{_redisData.GetHash(strarr[0], strarr[1]).Result}");
}
}
else if (action == "UNLOAD")//放货
{
if (putdic.Keys.Contains(disTask.endlocation_code))
{
var strarr = putdic.Where(p => p.Key == disTask.endlocation_code).First().Value;
Dictionary<string, string> dicCommand = new(StringComparer.OrdinalIgnoreCase)
{
["DevName"] = strarr[0],
["token"] = _eleCtlCfg.token,
["TagName"] = strarr[1],
["Value"] = strarr[2],
};
Logger.Information($"SsxControlUNLOAD:{JsonConvert.SerializeObject(dicCommand)}");
var str = await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand);
Logger.Information($"SsxControlUNLOAD:{str}");
//Logger.Information($"SsxControlUNLOAD - 控制后查询:{_redisData.GetHash(strarr[0], strarr[1]).Result}");
}
}
}
/// <summary>
/// 二楼机械臂
/// </summary>
@@ -1480,6 +1627,35 @@ namespace Tnb.WarehouseMgr
agvElevatorTasks = agvElevatorTasks.Where(x => !equalEndLocPreTasks.Contains(x.endlocation_code)).ToList();
}
#region
// 原材料仓的未完成任务
List<WmsPretaskH> wmspretasks_ycl = await db.Queryable<WmsPretaskH>()
.InnerJoin<BasLocation>((a, b) => a.endlocation_id == b.id)
.InnerJoin<WmsAreaH>((a, b, c) => a.area_id == c.id)
.InnerJoin<BasLocation>((a, b, c, d) => a.startlocation_id == d.id)
.Where((a, b, c, d) => a.status != WmsWareHouseConst.PRETASK_BILL_STATUS_COMPLE_ID && a.status != WmsWareHouseConst.PRETASK_BILL_STATUS_CANCEL_ID
&& b.is_use == "0" && d.is_type == "0" && b.wh_id == WmsWareHouseConst.WAREHOUSE_YCL_ID)
.Select((a, b, c, d) => new WmsPretaskH
{
move_num = c.move_num,
third_eqp_type = c.third_eqp_type,
passage = d.passage
}, true)
.ToListAsync();
// 原材料仓的执行中任务
List<WmsPretaskH> wmspretasksrun_ycl = wmspretasks_ycl.Where(r => r.status == WmsWareHouseConst.PRETASK_BILL_STATUS_YXF_ID || r.status == WmsWareHouseConst.PRETASK_BILL_STATUS_START_ID).ToList();
// 过滤normalPreTasks中的原材料仓的任务
normalPreTasks = normalPreTasks.Where(r => !wmspretasks_ycl.Select(a => a.id).Contains(r.id)).ToList();
// 过滤原材料仓同巷道的正在执行的任务
var yclTasks = wmspretasks_ycl.Where(r => !wmspretasksrun_ycl.Select(a => a.passage).Contains(r.passage)).ToList();
// 过滤重复巷道的预任务
yclTasks = yclTasks.OrderBy(r => r.passage).GroupBy(r => r.passage).Select(r => { return r.ToList()[0]; }).OrderBy(r => r.bill_code).ToList();
normalPreTasks = normalPreTasks.Concat(yclTasks).ToList();
#endregion
#region
#region
@@ -1507,7 +1683,7 @@ namespace Tnb.WarehouseMgr
// 过滤到三楼暂存区同目标库位的正在执行的任务
var cacheLocTasks = wmspretasks_agvElevator.Where(r => !wmsdistasks_agvElevator.Select(a => a.endlocation_id).Contains(r.endlocation_id)).ToList();
// 过滤重复目标库位的预任务
cacheLocTasks = cacheLocTasks.OrderBy(r => r.endlocation_code).GroupBy(r => r.endlocation_code).Select(r => { return r.ToList()[0]; }).ToList();
cacheLocTasks = cacheLocTasks.OrderBy(r => r.endlocation_code).GroupBy(r => r.endlocation_code).Select(r => { return r.ToList()[0]; }).OrderBy(r => r.bill_code).ToList();
normalPreTasks = normalPreTasks.Concat(cacheLocTasks).ToList();
#endregion
@@ -4085,8 +4261,7 @@ namespace Tnb.WarehouseMgr
code_batch = input.code_batch,
Size = 100,
Region_id = WmsWareHouseConst.REGION_Purchase_ID,
PolicyCode = WmsWareHouseConst.POLICY_YCLOUTSTOCK,
AvoidBusyPassage = true
PolicyCode = WmsWareHouseConst.POLICY_YCLOUTSTOCK
};
List<WmsCarryH> items = await OutStockStrategy(outStockStrategyInput);