From a75fc548cbbccdf6e52cc527ef54f7e95c4d9ca7 Mon Sep 17 00:00:00 2001 From: majian <780924089@qq.com> Date: Thu, 11 Jul 2024 14:42:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5bip=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tnb.ProductionMgr/RedisBackGround.cs | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs b/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs index fc43353c..80297514 100644 --- a/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs +++ b/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs @@ -27,6 +27,7 @@ using NetTaste; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Npgsql; +using NPOI.OpenXmlFormats; using Org.BouncyCastle.Asn1.X509; using Org.BouncyCastle.Asn1.X509.Qualified; using Qiniu.Util; @@ -57,6 +58,7 @@ namespace Tnb.ProductionMgr public class RedisBackGround : IHostedService, IDisposable { #region 全局变量 + private static Timer? GenTaskExecutetimer; private static Timer? Readtimer; private static Timer? CheckGettimer; private static Timer? Scantimer; @@ -1445,7 +1447,8 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA LoggerFloor2RackDelivery.LogInformation($"【移走上升降区满托的料架】 开始执行预任务生成: 料架区为{wmsMechanicalArmH.name}{wmsMechanicalArmH.stackingposition} 料架为{wmsMechanicalArmH.rackcode}"); - bool result = await createPretask(wmsMechanicalArmH.location_id, endLocation.id, wmsMechanicalArmH.rackid, wmsMechanicalArmH.rackcode, LoggerFloor2RackDelivery, db_Floor2timer移走上升降区未生成预任务且满托的料架); + WmsMaterialTransfer wmsMaterialTransfer = await db_Floor2timer移走上升降区未生成预任务且满托的料架.Queryable().Where(r => r.bill_code == wmsMechanicalArmH.outbill).FirstAsync(); + bool result = await createPretask(wmsMechanicalArmH.location_id, endLocation.id, wmsMechanicalArmH.rackid, wmsMechanicalArmH.rackcode, LoggerFloor2RackDelivery, db_Floor2timer移走上升降区未生成预任务且满托的料架, true, wmsMaterialTransfer.id); if (!result) { LoggerFloor2RackDelivery.LogError($"【移走上升降区满托的料架】 未成功生成预任务 起点{wmsMechanicalArmH.location_code} 终点{endLocation.location_code} 料架 {wmsMechanicalArmH.rackcode}"); @@ -1577,7 +1580,8 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA LoggerFloor2RackDelivery.LogInformation($"【移走下升降区空托的料架】 开始执行预任务生成: 料架区为{wmsMechanicalArmH.name}{wmsMechanicalArmH.stackingposition} 料架为{wmsMechanicalArmH.rackcode}"); - bool result = await createPretask(wmsMechanicalArmH.location_id, endLocation.id, wmsMechanicalArmH.rackid, wmsMechanicalArmH.rackcode, LoggerFloor2RackDelivery, db_Floor2timer移走下升降区未生成预任务且空托的料架); + WmsMaterialTransfer wmsMaterialTransfer = await db_Floor2timer移走下升降区未生成预任务且空托的料架.Queryable().Where(r => r.bill_code == wmsMechanicalArmH.outbill).FirstAsync(); + bool result = await createPretask(wmsMechanicalArmH.location_id, endLocation.id, wmsMechanicalArmH.rackid, wmsMechanicalArmH.rackcode, LoggerFloor2RackDelivery, db_Floor2timer移走下升降区未生成预任务且空托的料架, true, wmsMaterialTransfer.id); if (!result) { LoggerFloor2RackDelivery.LogInformation($"【移走下升降区空托的料架】 未成功生成预任务 起点{wmsMechanicalArmH.location_code} 终点{endLocation.location_code} 料架 {wmsMechanicalArmH.rackcode}"); @@ -1613,8 +1617,19 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA } } + /// + /// 定时触发一次任务执行生成 + /// + /// + public async void GenTaskExecute(object? args) + { + Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} 触发任务执行"); + LoggerTimer.LogInformation($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} 触发任务执行"); + _wareHouseService.GenTaskExecute(); + } + // 上下升降机生成预任务(补充料架、上升降机取货到料架、上升降机满托运走,下升降机拿货到输送线、下升降机空托运走) - private async Task createPretask(string startlocation_id, string endlocation_id, string carry_id, string carry_code, ILogger logger, ISqlSugarClient dbConn) + private async Task createPretask(string startlocation_id, string endlocation_id, string carry_id, string carry_code, ILogger logger, ISqlSugarClient dbConn, bool isSync2Erp = false, string source_id = "") { CommonCreatePretaskInput commonCreatePretaskInput = new CommonCreatePretaskInput(); commonCreatePretaskInput.startlocation_id = startlocation_id; @@ -1622,8 +1637,9 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA commonCreatePretaskInput.carry_id = carry_id; commonCreatePretaskInput.carry_code = carry_code; commonCreatePretaskInput.task_type = WmsWareHouseConst.BIZTYPE_WMSTRANSFER_ID; - commonCreatePretaskInput.biz_type = ""; + commonCreatePretaskInput.biz_type = isSync2Erp ? "erp_qtrk" : ""; commonCreatePretaskInput.require_id = ""; + commonCreatePretaskInput.source_id = source_id; commonCreatePretaskInput.isExcuteMission = false; logger.LogInformation($"开始执行 GenPreTask {JsonConvert.SerializeObject(commonCreatePretaskInput)}"); @@ -1778,6 +1794,8 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA Floor2timer移走上升降区未生成预任务且满托的料架 = new Timer(移走上升降区未生成预任务且满托的料架, null, TimeSpan.Zero, TimeSpan.FromSeconds(30)); Floor2timer移走下升降区未生成预任务且空托的料架 = new Timer(移走下升降区未生成预任务且空托的料架, null, TimeSpan.Zero, TimeSpan.FromSeconds(30)); + GenTaskExecutetimer = new Timer(GenTaskExecute, null, TimeSpan.Zero, TimeSpan.FromSeconds(30)); + return Task.CompletedTask; }