二楼料箱下到一楼生成ctu任务和空载具入库单

This commit is contained in:
2024-05-23 00:33:23 +08:00
parent a53623823c
commit af6a562211
7 changed files with 247 additions and 203 deletions

View File

@@ -62,7 +62,7 @@ namespace Tnb.ProductionMgr
private Timer? Floor2UpMachinecodetimer;
// 二楼料架配送
private Timer? Floor2RackDeliverytimer;
public static SemaphoreSlim s_taskExecuteRackDelivery = new(1);
private readonly RedisData _redisData;
@@ -75,6 +75,7 @@ namespace Tnb.ProductionMgr
private readonly IWmsCarryBindService _wmsCarryBindService;
private readonly ElevatorControlConfiguration _eleCtlCfg = App.Configuration.Build<ElevatorControlConfiguration>();
public RedisBackGround(RedisData redisData, IPrdInstockService prdInstockService, ISqlSugarRepository<RedisReadConfig> repository, IWmsPDAScanInStockService wmsPDAScanInStock
, IUserManager userManager, IBillRullService billRullService, IWareHouseService wareHouseService, IWmsCarryBindService wmsCarryBindService)
{
@@ -182,7 +183,7 @@ namespace Tnb.ProductionMgr
getdic.Add("ZSSSXCTU02", new string[] { "YTCS", "AllowAgvEmptyOut_CS03", "" });
getdic.Add("ZSSSXCTU01", new string[] { "YTCS", "AllowAgvEmptyOut_CS01", "" });
foreach (var key in getdic.Keys)
{
try
@@ -195,7 +196,7 @@ namespace Tnb.ProductionMgr
continue;
}
JObject? res = JsonConvert.DeserializeObject<JObject>(data);
bool result = res != null && res["Value"] != null ? res.Value<bool>("Value") : false;
if (result)
{
@@ -224,7 +225,7 @@ namespace Tnb.ProductionMgr
CancellationTokenSource Ctu = new();
if (strs[0] == "东面提升机输送线")
{
Logger.LogInformation($"【定时任务CheckGet】 开始发送请求到 http://192.168.11.104:1880/wcs/notify/cargo ");
Logger.LogInformation($"【定时任务CheckGet】 开始发送请求到 http://192.168.11.104:1880/wcs/notify/cargo 载具:{coderesult}");
}
dynamic respBody = HttpClientHelper.PostStreamAsync("http://192.168.11.104:1880/wcs/notify/cargo", reqBody, Ctu.Token).Result;
if (strs[0] == "东面提升机输送线")
@@ -238,10 +239,10 @@ namespace Tnb.ProductionMgr
else
{
LoggerSSX.LogInformation($@"【定时任务CheckGet】 {key}->{strs[0]} {strs[2]}
采集结果:{ $@"(wms_distask_h) (carry_code){coderesult}
采集结果:{$@"(wms_distask_h) (carry_code){coderesult}
(status)(26126853976101) (extras)
select extras,* from wms_distask_h
where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STATUS_YXD_ID}' " }");
where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STATUS_YXD_ID}' "}");
}
}
@@ -256,7 +257,9 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
reqBody.slotCode = key;
reqBody.containerCode = DistaskH.carry_code;
CancellationTokenSource Ctu = new();
Logger.LogInformation($"【定时任务CheckGet】 开始发送请求到 http://192.168.11.104:1880/wcs/notify/cargo ");
dynamic respBody = HttpClientHelper.PostStreamAsync("http://192.168.11.104:1880/wcs/notify/cargo", reqBody, Ctu.Token).Result;
Logger.LogInformation($"【定时任务CheckGet】 接收请求 http://192.168.11.104:1880/wcs/notify/cargo 结果 {respBody} ");
DistaskH.extras = respBody;
_repository.AsSugarClient().Updateable(DistaskH).ExecuteCommand();
Ctu.Dispose();
@@ -397,7 +400,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
};
})).CreateLogger(this.GetType());
protected ILogger LoggerYCLGLDPJInstock => LoggerFactory.Create(builder => builder.AddFile($"{AppContext.BaseDirectory}/logs/customBGWCarrySupplement{DateTime.Now:yyyyMMdd}.log", cfgOpts =>
{
//cfgOpts.DateFormat = "yyyy-MM-dd HH:mm:ss.fff";
@@ -807,7 +810,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
var DistaskH = _repository.AsSugarClient().Queryable<WmsDistaskH>().Where(p => p.carry_code == result && p.status != WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID).OrderByDescending(p => p.create_time).First();
if (DistaskH != null)
{
Logger.LogInformation($"【定时任务SSXcode】DistaskH != null putdic.Keys.Contains(DistaskH.startlocation_code):{putdic.Keys.Contains(DistaskH.startlocation_code)}");
Logger.LogInformation($"【定时任务SSXcode】DistaskH != null putdic.Keys.Contains(DistaskH.startlocation_code):{putdic.Keys.Contains(DistaskH.startlocation_code)} {result}");
Dictionary<string, string> dicCommand2 = new(StringComparer.OrdinalIgnoreCase)
{
@@ -869,7 +872,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
BGWCarrySupplementtimer?.Dispose();
YCLGLDPJInstocktimer?.Dispose();
YCLWXDPJInstocktimer?.Dispose();
}
}
#region
// 上升降机
@@ -877,7 +880,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
{
using (var db = _repository.AsSugarClient().CopyNew())
{
string barcode = Floor2UpDownMachinecode_GetTag<string>(MechanicalArmConsts.).ToString();
string barcode = await Floor2UpDownMachinecode_GetTag<string>(MechanicalArmConsts.);
if (string.IsNullOrEmpty(barcode))
{
LoggerFloor2UpDownMachine.LogError($@"【上升降机】未取到条码数据");
@@ -1008,13 +1011,13 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
// 绑定料箱到料架
CarryBindFloor2UpDownMachineInput carryBindFloor2UpDownMachineInput = new() { };
carryBindFloor2UpDownMachineInput.carry_id = target.rackid;
carryBindFloor2UpDownMachineInput.carry_code= target.rackcode;
carryBindFloor2UpDownMachineInput.carry_code = target.rackcode;
carryBindFloor2UpDownMachineInput.membercarry_id = LX.id;
carryBindFloor2UpDownMachineInput.membercarry_code = LX.carry_code;
carryBindFloor2UpDownMachineInput.carrystd_id = rack.carrystd_id;
await _wmsCarryBindService.CarryBindFloor2UpDownMachine(carryBindFloor2UpDownMachineInput);
await db.Ado.CommitTranAsync();
@@ -1033,69 +1036,88 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
/// 检查机械臂料架区信号(下升降机满托1送到)
/// </summary>
/// <returns></returns>
public async Task<bool> _下升降机满托1送到()
//public async Task<bool> 检查机械臂料架区信号_下升降机满托1送到()
//{
// using (var db = _repository.AsSugarClient().CopyNew())
// {
// string[] configs_upMachine = new string[2] { "二楼下升降机机械臂左", "二楼下升降机机械臂右" };
// // 找到AGV已到货没有机械臂确认的数据
// ISugarQueryable<WmsMechanicalArmH> WmsMechanicalArmHsuagar = db.Queryable<WmsMechanicalArmH>()
// .Where(r => r.agvconfirm == 1 && r.mechanicalconfirm == 0 && configs_upMachine.Contains(r.name));
// LoggerFloor2UpDownMachine.LogInformation($@"【检查机械臂料架区信号_下升降机满托1送到】 {WmsMechanicalArmHsuagar.Count()}");
// foreach (WmsMechanicalArmH wmsMechanicalArmH in WmsMechanicalArmHsuagar.ToList())
// {
// int LXCount = db.Queryable<WmsCarryD>().Where(a => a.carry_id == wmsMechanicalArmH.rackid).Count();
// bool result = await Floor2UpDownMachinecode_SetTag($"下升降机满托{wmsMechanicalArmH.stackingposition}数量", LXCount.ToString());
// LoggerFloor2UpDownMachine.LogInformation($@"【送满托到下升降区】设定下升降机满托{wmsMechanicalArmH.stackingposition}满托数量为 {LXCount} 结果为 {result}");
// if (!result)
// {
// throw new Exception($@"【送满托到下升降区】设定升降机满托{wmsMechanicalArmH.stackingposition}满托数量为 {LXCount} 结果为 {result}");
// }
// // 尝试写入满托送到信号
// bool result下升降机空托送到 = await Floor2UpDownMachinecode_SetTag($"下升降机满托{wmsMechanicalArmH.stackingposition}送到", "true");
// LoggerFloor2UpDownMachine.LogInformation($@"【送满托到下升降区】回写 下升降机满托{wmsMechanicalArmH.stackingposition}送到 结果为{result下升降机空托送到}");
// if (!result下升降机空托送到)
// {
// return false;
// }
// // 绑定料架
// await db.Updateable<WmsMechanicalArmH>().SetColumns(r => new WmsMechanicalArmH
// {
// mechanicalconfirm = 1,
// maxnum = LXCount
// }).Where(r => r.id == wmsMechanicalArmH.id).ExecuteCommandAsync();
// LoggerFloor2UpDownMachine.LogInformation($@"【送满托到下升降区】 料架{wmsMechanicalArmH.rackid}下的料箱开始生成预任务");
// bool pretask_result = await _wareHouseService.Floor2EmptyCarryCreateZZCPretask(wmsMechanicalArmH.rackid);
// if (pretask_result)
// {
// LoggerFloor2UpDownMachine.LogInformation($@"【送满托到下升降区】 料架{wmsMechanicalArmH.rackid}下的料箱生成预任务完成");
// }
// else
// {
// LoggerFloor2UpDownMachine.LogInformation($@"【送满托到下升降区】 料架{wmsMechanicalArmH.rackid}下的料箱生成预任务失败");
// }
// }
// return true;
// }
//}
// 二楼机械臂信号对应机械臂字典
Dictionary<string, string> floor2mechanicalAtmDic = new Dictionary<string, string>()
{
using (var db = _repository.AsSugarClient().CopyNew())
{
string[] configs_upMachine = new string[2] { "二楼下升降机机械臂左", "二楼下升降机机械臂右" };
// 找到AGV已到货没有机械臂确认的数据
ISugarQueryable<WmsMechanicalArmH> WmsMechanicalArmHsuagar = db.Queryable<WmsMechanicalArmH>()
.Where(r => r.agvconfirm == 1 && r.mechanicalconfirm == 0 && configs_upMachine.Contains(r.name));
LoggerFloor2UpDownMachine.LogInformation($@"【检查机械臂料架区信号_下升降机满托1送到】 {WmsMechanicalArmHsuagar.Count()}");
foreach (WmsMechanicalArmH wmsMechanicalArmH in WmsMechanicalArmHsuagar.ToList())
{
int LXCount = db.Queryable<WmsCarryD>().Where(a => a.carry_id == wmsMechanicalArmH.rackid).Count();
bool result = await Floor2UpDownMachinecode_SetTag($"下升降机满托{wmsMechanicalArmH.stackingposition}数量", LXCount.ToString());
LoggerFloor2UpDownMachine.LogInformation($@"【送满托到下升降区】设定下升降机满托{wmsMechanicalArmH.stackingposition}满托数量为 {LXCount} 结果为 {result}");
if (!result)
{
throw new Exception($@"【送满托到下升降区】设定升降机满托{wmsMechanicalArmH.stackingposition}满托数量为 {LXCount} 结果为 {result}");
}
// 尝试写入满托送到信号
bool result下升降机空托送到 = await Floor2UpDownMachinecode_SetTag($"下升降机满托{wmsMechanicalArmH.stackingposition}送到", "true");
LoggerFloor2UpDownMachine.LogInformation($@"【送满托到下升降区】回写 下升降机满托{wmsMechanicalArmH.stackingposition}送到 结果为{result下升降机空托送到}");
if (!result下升降机空托送到)
{
return false;
}
// 绑定料架
await db.Updateable<WmsMechanicalArmH>().SetColumns(r => new WmsMechanicalArmH
{
mechanicalconfirm = 1,
maxnum = LXCount
}).Where(r => r.id == wmsMechanicalArmH.id).ExecuteCommandAsync();
LoggerFloor2UpDownMachine.LogInformation($@"【送满托到下升降区】 料架{wmsMechanicalArmH.rackid}下的料箱开始生成预任务");
bool pretask_result = await _wareHouseService.Floor2EmptyCarryCreateZZCPretask(wmsMechanicalArmH.rackid);
if (pretask_result)
{
LoggerFloor2UpDownMachine.LogInformation($@"【送满托到下升降区】 料架{wmsMechanicalArmH.rackid}下的料箱生成预任务完成");
}
else
{
LoggerFloor2UpDownMachine.LogInformation($@"【送满托到下升降区】 料架{wmsMechanicalArmH.rackid}下的料箱生成预任务失败");
}
}
return true;
}
}
{"上升降机请求送空托1","二楼上升降机机械臂左"},
{"上升降机请求送空托2","二楼上升降机机械臂右"},
};
/// <summary>
/// 送空托到上升降区
/// </summary>
/// <returns></returns>
public async Task<bool> ()
{
#region
List<string> configs_upMachine = new List<string>();
bool 1 = await Floor2UpDownMachinecode_GetTag<bool>($"上升降机请求送空托1");
bool 2 = await Floor2UpDownMachinecode_GetTag<bool>($"上升降机请求送空托2");
if (await Floor2UpDownMachinecode_GetTag<bool>($"上升降机请求送空托1"))
configs_upMachine.Add(floor2mechanicalAtmDic["上升降机请求送空托1"]);
if (await Floor2UpDownMachinecode_GetTag<bool>($"上升降机请求送空托2"))
configs_upMachine.Add(floor2mechanicalAtmDic["上升降机请求送空托2"]);
// 没有有效信号
if (configs_upMachine.Count == 0)
return false;
#endregion
using (var db = _repository.AsSugarClient().CopyNew())
{
string[] configs_upMachine = new string[2] { "二楼上升降机机械臂左", "二楼上升降机机械臂右" };
// 找到没有绑定料架的且库位未锁定的料架区
ISugarQueryable<WmsMechanicalArmH> WmsMechanicalArmHsuagar = db.Queryable<WmsMechanicalArmH>().
@@ -1224,7 +1246,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
foreach (WmsMechanicalArmH wmsMechanicalArmH in WmsMechanicalArmHs)
{
bool = (bool)Floor2UpDownMachinecode_GetTag<bool>($"下升降机请求送满托{wmsMechanicalArmH.stackingposition}");
bool = await Floor2UpDownMachinecode_GetTag<bool>($"下升降机请求送满托{wmsMechanicalArmH.stackingposition}");
if (!)
{
LoggerFloor2RackDelivery.LogWarning($"【送满托到下升降区】 料架区 {wmsMechanicalArmH.name}{wmsMechanicalArmH.stackingposition} 下升降机请求送满托{wmsMechanicalArmH.stackingposition}信号不为true");
@@ -1357,11 +1379,11 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
try
{
// 判断是否 上升降机请求取满托
bool = (bool)Floor2UpDownMachinecode_GetTag<bool>($"上升降机请求取满托{wmsMechanicalArmH.stackingposition}");
bool = await Floor2UpDownMachinecode_GetTag<bool>($"上升降机请求取满托{wmsMechanicalArmH.stackingposition}");
LoggerFloor2RackDelivery.LogError($"【移走上升降区满托的料架】上升降机请求取满托{wmsMechanicalArmH.stackingposition} {上升降机请求取满托}");
if (!)
{
return false;
continue;
}
await db.Updateable<WmsMechanicalArmH>().SetColumns(r => new WmsMechanicalArmH
@@ -1376,7 +1398,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
if (startPoints.Count == 0)
{
LoggerFloor2RackDelivery.LogError($"【移走上升降区满托的料架】 起点{wmsMechanicalArmH.point_id} {wmsMechanicalArmH.point_code}未在点位表维护对应的点位");
return false;
continue;
}
WmsPointH startPoint = startPoints.First();
@@ -1390,7 +1412,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
if (rackEndLocations.Count() == 0)
{
LoggerFloor2RackDelivery.LogWarning($"【移走上升降区满托的料架】 暂存仓中没有可用的空库位 {rackEndLocations.ToSqlString()}");
return false;
continue;
}
BasLocation endLocation = rackEndLocations.First();
@@ -1400,7 +1422,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
if (endPoints.Count == 0)
{
LoggerFloor2RackDelivery.LogError($"【移走上升降区满托的料架】 终点库位{endLocation.location_code}未在点位表维护对应的点位");
return false;
continue;
}
WmsPointH endPoint = endPoints.First();
@@ -1421,7 +1443,8 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
Tuple<bool, WmsPretaskH> result = await createPretask(points, wmsMechanicalArmH.rackid, wmsMechanicalArmH.rackcode, LoggerFloor2RackDelivery);
if (!result.Item1)
{
throw new Exception("未成功生成预任务");
LoggerFloor2RackDelivery.LogInformation($"未成功生成预任务");
continue;
}
LoggerFloor2RackDelivery.LogInformation($"【移走上升降区满托的料架】 成功生成预任务 {result.Item2}");
@@ -1460,7 +1483,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
try
{
// 判断是否 上升降机请求取满托
bool = (bool)Floor2UpDownMachinecode_GetTag<bool>($"下升降机请求取空托{wmsMechanicalArmH.stackingposition}");
bool = await Floor2UpDownMachinecode_GetTag<bool>($"下升降机请求取空托{wmsMechanicalArmH.stackingposition}");
LoggerFloor2RackDelivery.LogError($"【移走下升降区空托的料架】下升降机请求取空托{wmsMechanicalArmH.stackingposition} {下升降机请求取空托}" );
if (!)
{
@@ -1553,11 +1576,8 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
{
try
{
// 检查机械臂料架区信号(上升降机空托1送到)
//await 检查机械臂料架区信号_上升降机空托1送到();
// 检查机械臂料架区信号(下升降机满托1送到)
await _下升降机满托1送到();
//await 检查机械臂料架区信号_下升降机满托1送到();
// 送空托到上升降区
await ();
@@ -1637,30 +1657,10 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
return new Tuple<bool, WmsPretaskH>(false, null);
}
private object Floor2UpDownMachinecode_GetTag<T>(string tag)
private async Task<T> Floor2UpDownMachinecode_GetTag<T>(string tag)
{
string key = "东面提升机输送线";
string data = _redisData.GetHash(key, tag.ToString()).Result;
if (data == null)
{
LoggerFloor2UpDownMachine.LogError($@"{key} {tag} 未取到数值!");
return "";
}
JObject? res = JsonConvert.DeserializeObject<JObject>(data);
switch (typeof(T).ToString())
{
case "System.Boolean":
{
bool result = res != null && res["Value"] != null ? res.Value<bool>("Value") : false;
return result;
}
case "System.String":
{
string? result = res != null && res["Value"] != null ? res.Value<string>("Value") : "";
return result;
}
}
return "wrong type";
return await _redisData.TryGetValueByKeyField<T>(key, tag.ToString());
}
private async Task<bool> Floor2UpDownMachinecode_SetTag(string tag, string value)