From 439e000bd1cf85a331702f31ccf139511ee70ed9 Mon Sep 17 00:00:00 2001 From: majian <780924089@qq.com> Date: Thu, 6 Jun 2024 16:42:31 +0800 Subject: [PATCH] =?UTF-8?q?bug=E5=A4=84=E7=90=86=EF=BC=8C=E4=BA=8C?= =?UTF-8?q?=E6=A5=BC=E7=A9=BA=E8=BD=BD=E5=85=B7=E6=96=99=E6=9E=B6=E5=85=A5?= =?UTF-8?q?=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tnb.BasicData.Entities.csproj | 1 + .../Tnb.BasicData.Interfaces.csproj | 1 + BasicData/Tnb.BasicData/Tnb.BasicData.csproj | 1 + .../Tnb.EquipMgr.Entities.csproj | 1 + .../Tnb.EquipMgr.Interfaces.csproj | 1 + EquipMgr/Tnb.EquipMgr/Tnb.EquipMgr.csproj | 1 + .../Tnb.PerMgr.Entities.csproj | 1 + .../Tnb.PerMgr.Interfaces.csproj | 1 + PerMgr/Tnb.PerMgr/Tnb.PerMgr.csproj | 1 + .../Tnb.ProductionMgr.Entities.csproj | 1 + .../Tnb.ProductionMgr.Interfaces.csproj | 1 + .../Tnb.ProductionMgr/RedisBackGround.cs | 1333 ++--------------- .../Tnb.ProductionMgr.csproj | 1 + .../Tnb.QcMgr.Entities.csproj | 1 + .../Tnb.QcMgr.Interfaces.csproj | 1 + QcMgr/Tnb.QcMgr/Tnb.QcMgr.csproj | 1 + .../Consts/WmsWareHouseConst.cs | 14 +- .../MaterialTransferRackInstockInput.cs | 46 + .../Tnb.WarehouseMgr.Entities.csproj | 1 + .../Tnb.WarehouseMgr.Interfaces.csproj | 1 + .../TimedTaskBackgroundService.cs | 2 +- .../Tnb.WarehouseMgr/Tnb.WarehouseMgr.csproj | 1 + .../Tnb.WarehouseMgr/WareHouseService.cs | 15 +- .../Tnb.WarehouseMgr/WmsCarryBindService.cs | 5 +- .../WmsMaterialTransferService.cs | 74 +- .../Tnb.WarehouseMgr/WmsPurchaseService.cs | 9 +- apihost/Tnb.API.Entry/Startup.cs | 1 + apihost/Tnb.API.Entry/Tnb.API.Entry.csproj | 2 + app/Tnb.Apps.Entitys/Tnb.Apps.Entitys.csproj | 1 + .../Tnb.Apps.Interfaces.csproj | 1 + app/Tnb.Apps/Tnb.Apps.csproj | 1 + .../Tnb.CollectiveOAuth.csproj | 1 + common/Tnb.Common.Core/Tnb.Common.Core.csproj | 1 + common/Tnb.Common/Redis/RedisData.cs | 18 +- common/Tnb.Common/Redis/StackExRedisHelper.cs | 88 ++ common/Tnb.Common/Tnb.Common.csproj | 2 + common/Tnb.SqlSugar/Tnb.SqlSugar.csproj | 1 + common/Tnb.Thirdparty/Tnb.Thirdparty.csproj | 1 + common/Tnb.WebSockets/Tnb.WebSockets.csproj | 1 + .../Tnb.Message.Entitys.csproj | 1 + .../Tnb.Message.Interfaces.csproj | 1 + message/Tnb.Message/Tnb.Message.csproj | 1 + system/Tnb.OAuth/Tnb.OAuth.csproj | 1 + .../Tnb.Systems.Entitys.csproj | 1 + .../Tnb.Systems.Interfaces.csproj | 1 + system/Tnb.Systems/Tnb.Systems.csproj | 1 + .../Tnb.TaskScheduler.Entitys.csproj | 1 + .../Tnb.TaskScheduler.Interfaces.csproj | 1 + .../Tnb.TaskScheduler.csproj | 1 + visualdev/Tnb.Vengine/Tnb.Vengine.csproj | 1 + .../Tnb.VisualDev.Engine.csproj | 1 + .../Tnb.VisualDev.Entitys.csproj | 1 + .../Tnb.VisualDev.Interfaces.csproj | 1 + visualdev/Tnb.VisualDev/Tnb.VisualDev.csproj | 1 + .../Tnb.WorkFlow.Entitys.csproj | 1 + .../Tnb.WorkFlow.Interfaces.csproj | 1 + workflow/Tnb.WorkFlow/Tnb.WorkFlow.csproj | 1 + 57 files changed, 457 insertions(+), 1196 deletions(-) create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/MaterialTransferRackInstockInput.cs create mode 100644 common/Tnb.Common/Redis/StackExRedisHelper.cs diff --git a/BasicData/Tnb.BasicData.Entities/Tnb.BasicData.Entities.csproj b/BasicData/Tnb.BasicData.Entities/Tnb.BasicData.Entities.csproj index 57e42217..d955e280 100644 --- a/BasicData/Tnb.BasicData.Entities/Tnb.BasicData.Entities.csproj +++ b/BasicData/Tnb.BasicData.Entities/Tnb.BasicData.Entities.csproj @@ -6,6 +6,7 @@ enable False Debug;Release;tianyi + false diff --git a/BasicData/Tnb.BasicData.Interfaces/Tnb.BasicData.Interfaces.csproj b/BasicData/Tnb.BasicData.Interfaces/Tnb.BasicData.Interfaces.csproj index 862aac48..0cd246dc 100644 --- a/BasicData/Tnb.BasicData.Interfaces/Tnb.BasicData.Interfaces.csproj +++ b/BasicData/Tnb.BasicData.Interfaces/Tnb.BasicData.Interfaces.csproj @@ -6,6 +6,7 @@ enable False Debug;Release;tianyi + false diff --git a/BasicData/Tnb.BasicData/Tnb.BasicData.csproj b/BasicData/Tnb.BasicData/Tnb.BasicData.csproj index 349cdb7c..261ba199 100644 --- a/BasicData/Tnb.BasicData/Tnb.BasicData.csproj +++ b/BasicData/Tnb.BasicData/Tnb.BasicData.csproj @@ -6,6 +6,7 @@ enable True Debug;Release;tianyi + false diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Tnb.EquipMgr.Entities.csproj b/EquipMgr/Tnb.EquipMgr.Entities/Tnb.EquipMgr.Entities.csproj index bd191439..88ce72e2 100644 --- a/EquipMgr/Tnb.EquipMgr.Entities/Tnb.EquipMgr.Entities.csproj +++ b/EquipMgr/Tnb.EquipMgr.Entities/Tnb.EquipMgr.Entities.csproj @@ -5,6 +5,7 @@ enable enable Debug;Release;tianyi + false diff --git a/EquipMgr/Tnb.EquipMgr.Interfaces/Tnb.EquipMgr.Interfaces.csproj b/EquipMgr/Tnb.EquipMgr.Interfaces/Tnb.EquipMgr.Interfaces.csproj index ab92314f..9c8c0608 100644 --- a/EquipMgr/Tnb.EquipMgr.Interfaces/Tnb.EquipMgr.Interfaces.csproj +++ b/EquipMgr/Tnb.EquipMgr.Interfaces/Tnb.EquipMgr.Interfaces.csproj @@ -5,6 +5,7 @@ enable enable Debug;Release;tianyi + false diff --git a/EquipMgr/Tnb.EquipMgr/Tnb.EquipMgr.csproj b/EquipMgr/Tnb.EquipMgr/Tnb.EquipMgr.csproj index b5cf8e54..51d59244 100644 --- a/EquipMgr/Tnb.EquipMgr/Tnb.EquipMgr.csproj +++ b/EquipMgr/Tnb.EquipMgr/Tnb.EquipMgr.csproj @@ -6,6 +6,7 @@ enable True Debug;Release;tianyi + false diff --git a/PerMgr/Tnb.PerMgr.Entities/Tnb.PerMgr.Entities.csproj b/PerMgr/Tnb.PerMgr.Entities/Tnb.PerMgr.Entities.csproj index 27dc0316..de76ccff 100644 --- a/PerMgr/Tnb.PerMgr.Entities/Tnb.PerMgr.Entities.csproj +++ b/PerMgr/Tnb.PerMgr.Entities/Tnb.PerMgr.Entities.csproj @@ -5,6 +5,7 @@ enable enable Debug;Release;tianyi + false diff --git a/PerMgr/Tnb.PerMgr.Interfaces/Tnb.PerMgr.Interfaces.csproj b/PerMgr/Tnb.PerMgr.Interfaces/Tnb.PerMgr.Interfaces.csproj index 33c6f24b..41983b16 100644 --- a/PerMgr/Tnb.PerMgr.Interfaces/Tnb.PerMgr.Interfaces.csproj +++ b/PerMgr/Tnb.PerMgr.Interfaces/Tnb.PerMgr.Interfaces.csproj @@ -5,6 +5,7 @@ enable enable Debug;Release;tianyi + false diff --git a/PerMgr/Tnb.PerMgr/Tnb.PerMgr.csproj b/PerMgr/Tnb.PerMgr/Tnb.PerMgr.csproj index f61d2bcb..017c2ce4 100644 --- a/PerMgr/Tnb.PerMgr/Tnb.PerMgr.csproj +++ b/PerMgr/Tnb.PerMgr/Tnb.PerMgr.csproj @@ -5,6 +5,7 @@ enable enable Debug;Release;tianyi + false diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Tnb.ProductionMgr.Entities.csproj b/ProductionMgr/Tnb.ProductionMgr.Entities/Tnb.ProductionMgr.Entities.csproj index 4adc18f3..ca97f34a 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Tnb.ProductionMgr.Entities.csproj +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Tnb.ProductionMgr.Entities.csproj @@ -6,6 +6,7 @@ enable False Debug;Release;tianyi + false diff --git a/ProductionMgr/Tnb.ProductionMgr.Interfaces/Tnb.ProductionMgr.Interfaces.csproj b/ProductionMgr/Tnb.ProductionMgr.Interfaces/Tnb.ProductionMgr.Interfaces.csproj index 34f5f41f..79a1815e 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Interfaces/Tnb.ProductionMgr.Interfaces.csproj +++ b/ProductionMgr/Tnb.ProductionMgr.Interfaces/Tnb.ProductionMgr.Interfaces.csproj @@ -6,6 +6,7 @@ enable False Debug;Release;tianyi + false diff --git a/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs b/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs index 7185f23c..4778ee14 100644 --- a/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs +++ b/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs @@ -4,6 +4,7 @@ using System.DirectoryServices.ActiveDirectory; using System.Dynamic; using System.Security.Policy; using System.Text; +using System.Text.RegularExpressions; using Aop.Api.Domain; using Aspose.Cells.Charts; using JNPF; @@ -26,6 +27,7 @@ using NPOI.SS.Formula.Functions; using Org.BouncyCastle.Asn1.X509; using Org.BouncyCastle.Asn1.X509.Qualified; using Qiniu.Util; +using Senparc.CO2NET.Helpers.Serializers; using SqlSugar; //using Swashbuckle.AspNetCore.SwaggerGen; using Tnb.BasicData.Entities; @@ -72,13 +74,13 @@ namespace Tnb.ProductionMgr // 7号线补充空料箱 //private Timer? SSX7Supplementtimer; - public static SemaphoreSlim s_taskExecuteFloor2UpMachinecodetimer = new(1); - public static SemaphoreSlim s_task送空托到上升降区 = new(1); - public static SemaphoreSlim s_task送满托到下升降区 = new(1); - public static SemaphoreSlim s_task移走上升降区未生成预任务且满托的料架 = new(1); - public static SemaphoreSlim s_task移走下升降区未生成预任务且空托的料架 = new(1); + public SemaphoreSlim s_taskExecuteFloor2UpMachinecodetimer = new(1); + public SemaphoreSlim s_task送空托到上升降区 = new(1); + public SemaphoreSlim s_task送满托到下升降区 = new(1); + public SemaphoreSlim s_task移走上升降区未生成预任务且满托的料架 = new(1); + public SemaphoreSlim s_task移走下升降区未生成预任务且空托的料架 = new(1); - private readonly RedisData _redisData; + private StackExRedisHelper _redisData; private readonly IPrdInstockService _prdInstockService; private readonly ISqlSugarRepository _repository; private readonly IWmsPDAScanInStockService _wmsPDAScanInStock; @@ -88,56 +90,9 @@ namespace Tnb.ProductionMgr private readonly IWmsCarryBindService _wmsCarryBindService; private readonly IWmsEmptyOutstockService _wmsEmptyOutstockService; - // 订阅到处理方法 - Dictionary> redisSubDic = new Dictionary>() - { - {"YTCS", new Dictionary() { - // ctu取货 - {"AllowFullOut_CS05","CheckGet"}, - {"AllowAgvFullIn_CS02","CheckGet"}, - {"AllowCtuFullOut_CS04","CheckGet"}, - {"AllowAgvEmptyOut_CS03","CheckGet"}, - {"AllowAgvEmptyOut_CS01","CheckGet"}, - }}, - {"东面提升机输送线", new Dictionary() { - // ctu取货 - {"入库输送线8允许出箱","CheckGet"}, - {"下升降机11允许出箱","CheckGet"}, - {"下升降机12允许出箱","CheckGet"}, - // 中储仓 - {"下升降机判断请求","SSXcode"}, - // 二楼机械手 - {"上升降机请求送空托1","送空托到上升降区"}, - {"上升降机请求送空托2","送空托到上升降区"}, - {"下升降机请求送满托1","送满托到下升降区"}, - {"下升降机请求送满托2","送满托到下升降区"}, - {"上升降机请求取满托1","移走上升降区未生成预任务且满托的料架"}, - {"上升降机请求取满托2","移走上升降区未生成预任务且满托的料架"}, - {"下升降机请求取空托1","移走下升降区未生成预任务且空托的料架"}, - {"下升降机请求取空托2","移走下升降区未生成预任务且空托的料架"}, - }}, - {"CP8", new Dictionary() { - // 原材料仓扫码入库 - {"AllowGetFullBox1","ScanInStock"}, - {"AllowGetFullBox2","ScanInStock"}, - // 八工位空托盘补充 - {"AllowPutEmptyBox1","BGWCarrySupplement"}, - }}, - {"CP3-5", new Dictionary() { - // 供料叠盘机空托盘自动入库 - {"AllowGetFullBox","YCLGLDPJInstock"}, - }}, - {"CP3-3", new Dictionary() { - // 外协叠盘机空托盘自动入库 - {"AllowGetFullBox","YCLWXDPJInstock"}, - }}, - - - }; - private readonly ElevatorControlConfiguration _eleCtlCfg = App.Configuration.Build(); - public RedisBackGround(RedisData redisData, IPrdInstockService prdInstockService, ISqlSugarRepository repository, IWmsPDAScanInStockService wmsPDAScanInStock + public RedisBackGround(StackExRedisHelper redisData, IPrdInstockService prdInstockService, ISqlSugarRepository repository, IWmsPDAScanInStockService wmsPDAScanInStock , IUserManager userManager, IBillRullService billRullService, IWareHouseService wareHouseService, IWmsCarryBindService wmsCarryBindService, IWmsEmptyOutstockService wmsEmptyOutstockService) { _redisData = redisData; @@ -150,1002 +105,12 @@ namespace Tnb.ProductionMgr _wmsCarryBindService = wmsCarryBindService; _wmsEmptyOutstockService = wmsEmptyOutstockService; - _redisData.rcvMsg += _redisData_rcvMsg; + //_redisData.rcvMsg += _redisData_rcvMsg; } - - #region 改为订阅 - private void _redisData_rcvMsg(string Channel, string Body) - { - Console.WriteLine($"Channel: {Channel}"); - Console.WriteLine($"Body: {Body}"); - return; - //Body: { "DevName":"Elevator4","TagName":"DoorStatus","StatusCode":0,"Value":1,"TagValueType":"Short","TimeStamp":"2024-06-03 13:07:48"} - JObject? keyValuePairs = JObject.Parse(Body); - if (keyValuePairs == null || !keyValuePairs.ContainsKey("DevName") || !keyValuePairs.ContainsKey("TagName")) - { - Console.WriteLine($"error Body: {Body}"); - return; - } - string DevName = keyValuePairs["DevName"].ToString(); - string TagName = keyValuePairs["TagName"].ToString(); - - string funcName = redisSubDic[DevName][TagName]; - switch (funcName) - { - case "CheckGet": - { - CheckGet(DevName, TagName); - break; - } - case "ScanInStock": - { - ScanInStock(DevName, TagName); - break; - } - case "BGWCarrySupplement": - { - BGWCarrySupplement(DevName, TagName); - break; - } - case "YCLGLDPJInstock": - { - YCLGLDPJInstock(DevName, TagName); - break; - } - case "YCLWXDPJInstock": - { - YCLWXDPJInstock(DevName, TagName); - break; - } - case "SSXcode": - { - SSXcode(DevName, TagName); - break; - } - case "送空托到上升降区": - { - 送空托到上升降区(DevName, TagName); - break; - } - case "送满托到下升降区": - { - 送满托到下升降区(DevName, TagName); - break; - } - case "移走上升降区未生成预任务且满托的料架": - { - 移走上升降区未生成预任务且满托的料架(DevName, TagName); - break; - } - case "移走下升降区未生成预任务且空托的料架": - { - 移走下升降区未生成预任务且空托的料架(DevName, TagName); - break; - } - } - } - - private void CheckGet(string DevName, string TagName) - { - Dictionary getdic = new Dictionary(); - getdic.Add("SSX-021-005", new string[] { "YTCS", "AllowFullOut_CS05", "LiftCode" }); - getdic.Add("SSX-011-002", new string[] { "YTCS", "AllowAgvFullIn_CS02", "Code_CS02" }); - getdic.Add("SSX-011-004", new string[] { "YTCS", "AllowCtuFullOut_CS04", "Code_CS04" }); - - getdic.Add("SSX-011-008", new string[] { "东面提升机输送线", "入库输送线8允许出箱", "入库输送线7条码" }); - - getdic.Add("SSX-111-011", new string[] { "东面提升机输送线", "下升降机11允许出箱", "下升降机11条码" }); - getdic.Add("SSX-111-012", new string[] { "东面提升机输送线", "下升降机12允许出箱", "下升降机12条码" }); - getdic.Add("ZSSSXCTU02", new string[] { "YTCS", "AllowAgvEmptyOut_CS03", "" }); - getdic.Add("ZSSSXCTU01", new string[] { "YTCS", "AllowAgvEmptyOut_CS01", "" }); - - var curdic = getdic.Where(p => p.Value[0] == DevName && p.Value[1] == TagName).First(); - var key = curdic.Key; - try - { - var strs = curdic.Value; - bool flag = _redisData.HashExist(strs[0], strs[1]).Result; - string data = _redisData.GetHash(strs[0], strs[1]).Result; - if (data == null) - { - return; - } - JObject? res = JsonConvert.DeserializeObject(data); - - bool result = res != null && res["Value"] != null ? res.Value("Value") : false; - if (result) - { - if (!string.IsNullOrEmpty(strs[2])) - { - string codedata = _redisData.GetHash(strs[0], strs[2]).Result; - if (codedata == null) - { - return; - } - JObject? coderes = JsonConvert.DeserializeObject(codedata); - string coderesult = coderes != null && coderes["Value"] != null ? coderes.Value("Value")! : ""; - coderesult = coderesult.Replace("\r", ""); - - - Logger.LogInformation($@"【定时任务CheckGet】 成功取到{strs[2]}值:{coderesult}"); - var DistaskH = _repository.AsSugarClient().Queryable().Where(p => p.carry_code == coderesult && p.status == WmsWareHouseConst.TASK_BILL_STATUS_YXD_ID && string.IsNullOrEmpty(p.extras)).First(); - - - if (DistaskH != null) - { - Logger.LogInformation($@"【定时任务CheckGet】 成功找到载具:{coderesult} 对应的任务执行单{DistaskH.bill_code}"); - dynamic reqBody = new ExpandoObject(); - reqBody.taskCode = DistaskH.bill_code; - reqBody.slotCode = key; - reqBody.containerCode = coderesult; - CancellationTokenSource Ctu = new(); - 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; - - Logger.LogInformation($"【定时任务CheckGet】 接收请求 http://192.168.11.104:1880/wcs/notify/cargo 结果 {respBody} "); - DistaskH.extras = respBody; - _repository.AsSugarClient().Updateable(DistaskH).ExecuteCommand(); - Ctu.Dispose(); - } - else - { - LoggerSSX.LogInformation($@"【定时任务CheckGet】 {key}->{strs[0]} {strs[2]} -采集结果:{$@"任务执行(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}' "}"); - - } - } - else - { - Logger.LogInformation($@"【定时任务CheckGet】 strs[2]信号为空 {strs[2]}"); - //var DistaskH = _repository.AsSugarClient().Queryable().Where(p => p.startlocation_code == key && p.status == WmsWareHouseConst.TASK_BILL_STATUS_YXD_ID && string.IsNullOrEmpty(p.extras)).First(); - //if (DistaskH != null) - //{ - // dynamic reqBody = new ExpandoObject(); - // reqBody.taskCode = DistaskH.bill_code; - // 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(); - //} - } - } - } - catch (Exception ex) - { - Console.WriteLine("【CheckGet】" + ex.Message); - LoggerSSX.LogError(ex.ToString()); - } - - } - - private void ScanInStock(string DevName, string TagName) - { - Dictionary getdic = new Dictionary(); - getdic.Add("BGWRKYCL02", new string[] { "CP8", "AllowGetFullBox1", "code1", "PutDoneEmptyBox", "false" }); - getdic.Add("BGWRKYCL01", new string[] { "CP8", "AllowGetFullBox2", "code2", "PutDoneEmptyBox", "false" }); - - var curdic = getdic.Where(p => p.Value[0] == DevName && p.Value[1] == TagName).First(); - var key = curdic.Key; - try - { - var strs = curdic.Value; - bool flag = _redisData.HashExist(strs[0], strs[1]).Result; - string data = _redisData.GetHash(strs[0], strs[1]).Result; - if (data == null) - { - return; - } - JObject? res = JsonConvert.DeserializeObject(data); - - - bool result = res != null && res["Value"] != null ? res.Value("Value") : false; - if (result) - { - Logger.LogInformation($"【ScanInStock】 八工位 {key} AllowGetFullBox1采集到 {res["Value"]}"); - - Dictionary dicCommand = new(StringComparer.OrdinalIgnoreCase) - { - ["DevName"] = strs[0], - ["token"] = _eleCtlCfg.token, - ["TagName"] = strs[3], - ["Value"] = strs[4], - }; - Logger.LogInformation($"【ScanInStock】 八工位 {key} 发送PutDoneEmptyBox指令 {_eleCtlCfg.WriteTagUrl} {JsonConvert.SerializeObject(dicCommand)}"); - HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand).Wait(); - string codedata = _redisData.GetHash(strs[0], strs[2]).Result; - Logger.LogInformation($"【ScanInStock】 八工位 {key} 获取到扫码信息: {codedata}"); - JObject? coderes = JsonConvert.DeserializeObject(codedata); - string coderesult = coderes != null && coderes["Value"] != null ? coderes.Value("Value")! : ""; - WmsCarryH? carry = _repository.AsSugarClient().Queryable().Single(it => it.carry_code == coderesult); - Logger.LogInformation($"【ScanInStock】 八工位 {key} 查找{coderesult}绑定的托盘: {JsonConvert.SerializeObject(carry)}"); - if (carry != null) - { - if (_repository.AsSugarClient().Queryable().Where(p => p.carry_id == carry.id && p.status != WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID).Any()) - { - Logger.LogInformation($"【ScanInStock】 八工位 {key} 托盘 {carry.id} 对应的执行任务状态(status)不是26126860808229(已完成),此时不能执行入库"); - return; - } - - var WmsCarryCode = _repository.AsSugarClient().Queryable().Where(it => it.carry_id == carry.id).OrderByDescending(it => it.id).First(); - // 用适当的字段替换 YourTimestampField - - if (WmsCarryCode != null) - { - Logger.LogInformation($"【ScanInStock】 八工位 {key} 查找到托盘{carry.carry_code}在WmsCarryCode中存在"); - - VisualDevModelDataCrInput input = new VisualDevModelDataCrInput(); - input.data = new Dictionary(); - input.data.Add("barcode", coderesult); - input.data.Add("codeqty", WmsCarryCode.codeqty);//条码数量 - input.data.Add("material_code", WmsCarryCode.material_code); - input.data.Add("extras", key);//location_code - input.data.Add("warehouse_id", "1");//TEST - input.data.Add("bill_code", "");//采购收货单号 - input.data.Add("code_batch", WmsCarryCode.code_batch!);//批次 - input.data.Add("material_specification", WmsCarryCode.material_specification!);//规格型号 - input.data.Add("container_no", WmsCarryCode.container_no!);//箱号 - input.data.Add("material_id", WmsCarryCode.material_id); - input.data.Add("id", null); - _wmsPDAScanInStock.ScanInStockByRedis(input).Wait(); - } - } - } - } - catch (Exception ex) - { - Console.WriteLine("【ScanInStock】" + ex.Message); - Logger.LogInformation($"【ScanInStock】 八工位扫到码发送入库请求发生异常:{ex}"); - } - } - - private async void BGWCarrySupplement(string DevName, string TagName) - { - Dictionary getdic = new Dictionary(); - getdic.Add("YCLCKBGW", new string[] { "CP8", "AllowPutEmptyBox1" }); - - var curdic = getdic.Where(p => p.Value[0] == DevName && p.Value[1] == TagName).First(); - var key = curdic.Key; - - try - { - var strs = curdic.Value; - string data = await _redisData.GetHash(strs[0], strs[1]); - if (data == null) - { - return; - } - JObject? res = JsonConvert.DeserializeObject(data); - - bool result = res != null && res["Value"] != null ? res.Value("Value") : false; - if (result) - { - LoggerBGWCarrySupplement.LogInformation($"【BGWCarrySupplementtimer】 八工位 {key} {strs[1]}采集到 {res["Value"]}"); - - BasLocation endLocation = _repository.AsSugarClient().Queryable().Where(r => r.location_code == key).First(); - if (endLocation == null) - { - LoggerBGWCarrySupplement.LogWarning($"【BGWCarrySupplementtimer】 {key}未维护库位信息"); - return; - } - if (endLocation.is_lock == 1) - { - LoggerBGWCarrySupplement.LogInformation($"【BGWCarrySupplementtimer】 八工位 {key} 已锁定"); - return; - } - - // 找到库位未锁定的空托盘 todo 待修改为使用出库策略 - var wmsLoc = _repository.AsSugarClient().Queryable() - .InnerJoin((a, b) => a.id == b.location_id) - .LeftJoin((a, b, c) => b.id == c.carry_id) - .Where((a, b, c) => string.IsNullOrEmpty(c.barcode) && a.wh_id == WmsWareHouseConst.WAREHOUSE_YCL_ID && a.location_code.Contains("YCL-")).OrderBy((a, b, c) => a.location_code).Select((a, b, c) => new - { - basLocation = a, - FirstWmsCarryH = b - }); - - BasLocation startLocation = wmsLoc.First().basLocation; - - WmsCarryH wmsCarryH = wmsLoc.First().FirstWmsCarryH; - - //锁定起点库位 - await _repository.AsSugarClient().Updateable().SetColumns(r => r.is_lock == 1).Where(r => r.id == startLocation.id).ExecuteCommandAsync(); - //锁定终点库位 更新为空闲 - await _repository.AsSugarClient().Updateable().SetColumns(r => new BasLocation { is_lock = 1, is_use = "0" }).Where(r => r.id == endLocation.id).ExecuteCommandAsync(); - - - bool result_createPretask = await createPretask(startLocation.id, endLocation.id, wmsCarryH.id, wmsCarryH.carry_code, LoggerBGWCarrySupplement); - if (!result_createPretask) - { - LoggerBGWCarrySupplement.LogWarning($"【BGWCarrySupplementtimer】 {startLocation.location_code} 到 {endLocation.location_code} 预任务生成失败 "); - return; - } - LoggerBGWCarrySupplement.LogWarning($"【BGWCarrySupplementtimer】 {startLocation.location_code} 到 {endLocation.location_code} 预任务生成成功"); - - - _ = _wareHouseService.GenTaskExecute(); - } - } - catch (Exception ex) - { - Console.WriteLine("【BGWCarrySupplement】" + ex.Message); - LoggerBGWCarrySupplement.LogInformation($"【BGWCarrySupplementtimer】 八工位空托盘补充发生异常:{ex}"); - } - } - - /// - /// 供料叠盘机空托盘自动入库 - /// - private async void YCLGLDPJInstock(string DevName, string TagName) - { - Dictionary getdic = new Dictionary(); - getdic.Add("SGW-YCL", new string[] { "CP3-5", "AllowGetFullBox" }); - - var curdic = getdic.Where(p => p.Value[0] == DevName && p.Value[1] == TagName).First(); - var key = curdic.Key; - try - { - var strs = curdic.Value; - string data = await _redisData.GetHash(strs[0], strs[1]); - if (data == null) - { - return; - } - JObject? res = JsonConvert.DeserializeObject(data); - - bool result = res != null && res["Value"] != null ? res.Value("Value") : false; - if (result) - { - LoggerYCLGLDPJInstock.LogInformation($"【YCLGLDPJInstock】 三工位叠盘机 {key} {strs[1]}采集到 {res["Value"]}"); - - using (var db = _repository.AsSugarClient().CopyNew()) - { - BasLocation startLocation = db.Queryable().Where(r => r.location_code == key).First(); - if (startLocation == null) - { - LoggerYCLGLDPJInstock.LogWarning($"【YCLGLDPJInstock】 {key}未维护库位信息"); - return; - } - if (startLocation.is_lock == 1) - { - LoggerYCLGLDPJInstock.LogInformation($"【YCLGLDPJInstock】 三工位叠盘机 {key} 已锁定"); - return; - } - - // 找到未锁定且未占用的库位 - var endLocations = db.Queryable() - .Where(a => a.is_lock == 0 && a.is_use == "0" && a.wh_id == WmsWareHouseConst.WAREHOUSE_YCL_ID && a.location_code.Contains("YCL-") && a.is_type == "0"); - - LoggerYCLGLDPJInstock.LogInformation($"【YCLGLDPJInstock】 sql {endLocations.ToSqlString()}"); - - if (endLocations.Count() == 0) - { - LoggerYCLGLDPJInstock.LogWarning($"【YCLGLDPJInstock】 当前没有空库位可以入库"); - return; - } - - BasLocation endLocation = endLocations.First(); - - //锁定起点库位 更新为空闲 - await db.Updateable().SetColumns(r => new BasLocation { is_lock = 1, is_use = "0" }).Where(r => r.id == startLocation.id).ExecuteCommandAsync(); - //锁定终点库位 - await db.Updateable().SetColumns(r => new BasLocation { is_lock = 1 }).Where(r => r.id == endLocation.id).ExecuteCommandAsync(); - - bool result_createPretask = await createPretask(startLocation.id, endLocation.id, "", "", LoggerYCLGLDPJInstock); - if (!result_createPretask) - { - LoggerYCLGLDPJInstock.LogWarning($"【YCLGLDPJInstock】 {startLocation.location_code} 到 {endLocation.location_code} 预任务生成失败"); - return; - } - LoggerYCLGLDPJInstock.LogWarning($"【YCLGLDPJInstock】 {startLocation.location_code} 到 {endLocation.location_code} 预任务生成成功"); - - } - - _ = _wareHouseService.GenTaskExecute(); - } - } - catch (Exception ex) - { - Console.WriteLine("【YCLGLDPJInstock】" + ex.Message); - LoggerYCLGLDPJInstock.LogInformation($"【YCLGLDPJInstock】 三工位叠盘机空托入库发生异常:{ex}"); - } - } - - /// - /// 外协叠盘机空托盘自动入库 - /// - private async void YCLWXDPJInstock(string DevName, string TagName) - { - Dictionary getdic = new Dictionary(); - getdic.Add("未定", new string[] { "CP3-3", "AllowGetFullBox" }); - - var curdic = getdic.Where(p => p.Value[0] == DevName && p.Value[1] == TagName).First(); - var key = curdic.Key; - try - { - var strs = curdic.Value; - string data = await _redisData.GetHash(strs[0], strs[1]); - if (data == null) - { - return; - } - JObject? res = JsonConvert.DeserializeObject(data); - - bool result = res != null && res["Value"] != null ? res.Value("Value") : false; - if (result) - { - LoggerYCLGLDPJInstock.LogInformation($"【YCLWXDPJInstock】 外协叠盘机 {key} {strs[1]}采集到 {res["Value"]}"); - - BasLocation startLocation = _repository.AsSugarClient().Queryable().Where(r => r.location_code == key).First(); - if (startLocation == null) - { - LoggerYCLGLDPJInstock.LogWarning($"【YCLWXDPJInstock】 {key}未维护库位信息"); - return; - } - if (startLocation.is_lock == 1) - { - LoggerYCLGLDPJInstock.LogInformation($"【YCLWXDPJInstock】 外协叠盘机 {key} 已锁定"); - return; - } - - // 找到未锁定且未占用的库位 - var endLocations = _repository.AsSugarClient().Queryable() - .Where(a => a.is_lock == 0 && a.is_use == "0" && a.wh_id == WmsWareHouseConst.WAREHOUSE_YCL_ID && a.location_code.Contains("YCL-") && a.is_type == "0"); - - LoggerYCLGLDPJInstock.LogInformation($"【YCLWXDPJInstock】 sql {endLocations.ToSqlString()}"); - - if (endLocations.Count() == 0) - { - LoggerYCLGLDPJInstock.LogWarning($"【YCLWXDPJInstock】 当前没有空库位可以入库"); - return; - } - - BasLocation endLocation = endLocations.First(); - - //锁定起点库位 更新为空闲 - await _repository.AsSugarClient().Updateable().SetColumns(r => new BasLocation { is_lock = 1, is_use = "0" }).Where(r => r.id == startLocation.id).ExecuteCommandAsync(); - //锁定终点库位 - await _repository.AsSugarClient().Updateable().SetColumns(r => new BasLocation { is_lock = 1 }).Where(r => r.id == endLocation.id).ExecuteCommandAsync(); - - bool result_createPretask = await createPretask(startLocation.id, endLocation.id, "", "", LoggerYCLGLDPJInstock); - if (!result_createPretask) - { - LoggerYCLGLDPJInstock.LogWarning($"【YCLWXDPJInstock】 {startLocation.location_code} 到 {endLocation.location_code} 预任务生成失败"); - return; - } - LoggerYCLGLDPJInstock.LogWarning($"【YCLWXDPJInstock】 {startLocation.location_code} 到 {endLocation.location_code} 预任务生成成功"); - - - _ = _wareHouseService.GenTaskExecute(); - } - } - catch (Exception ex) - { - LoggerYCLGLDPJInstock.LogInformation($"【YCLWXDPJInstock】 外协叠盘机空托入库发生异常:{ex}"); - } - } - - private void SSXcode(string DevName, string TagName) - { - Dictionary dic = new Dictionary(); - dic.Add("东面提升机输送线", new string[] { "下升降机判断请求", "下升降机判断条码", "下升降机判断完毕", "下升降机判断结果" }); - Dictionary putdic = new Dictionary(); - putdic.Add("SSX-111-011", 11); - putdic.Add("SSX-111-012", 12); - - var curdic = dic.Where(p => p.Value[0] == DevName && p.Value[1] == TagName).First(); - var key = curdic.Key; - - try - { - var strs = curdic.Value; - string dataflag = _redisData.GetHash(key, strs[0]).Result; - if (dataflag == null) - { - return; - } - JObject? resflag = JsonConvert.DeserializeObject(dataflag); - - - //Logger.LogInformation($"【定时任务SSXcode】 {key}->{strs[0]} 采集结果:{resflag}"); - bool re = resflag != null && resflag["Value"] != null ? resflag.Value("Value") : false; - if (!re) - return; - string data = _redisData.GetHash(key, strs[1]).Result; - if (data == null) - { - return; - } - JObject? res = JsonConvert.DeserializeObject(data); - //Logger.LogInformation($"【定时任务SSXcode】 {key}->{strs[1]} 采集结果:{res}"); - string? result = res != null && res["Value"] != null ? res.Value("Value") : ""; - if (!string.IsNullOrEmpty(result)) - { - if (result.Length < 5) - { - result = "LX" + result.Replace("\r", ""); - } - var DistaskH = _repository.AsSugarClient().Queryable().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)} {result}"); - - Dictionary dicCommand2 = new(StringComparer.OrdinalIgnoreCase) - { - ["DevName"] = key, - ["token"] = _eleCtlCfg.token, - ["TagName"] = strs[3], - ["Value"] = putdic.Keys.Contains(DistaskH.startlocation_code) ? putdic.Where(p => p.Key == DistaskH.startlocation_code).First().Value.ToString() : "13", - }; - HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand2).Wait(); - Dictionary dicCommand = new(StringComparer.OrdinalIgnoreCase) - { - ["DevName"] = key, - ["token"] = _eleCtlCfg.token, - ["TagName"] = strs[2], - ["Value"] = "true", - }; - HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand).Wait(); - } - else - { - Logger.LogInformation($"【定时任务SSXcode】DistaskH == null {_repository.AsSugarClient().Queryable().Where(p => p.carry_code == result && p.status != WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID).OrderByDescending(p => p.create_time).ToSqlString()}"); - Dictionary dicCommand2 = new(StringComparer.OrdinalIgnoreCase) - { - ["DevName"] = key, - ["token"] = _eleCtlCfg.token, - ["TagName"] = strs[3], - ["Value"] = "13", - }; - HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand2).Wait(); - Dictionary dicCommand = new(StringComparer.OrdinalIgnoreCase) - { - ["DevName"] = key, - ["token"] = _eleCtlCfg.token, - ["TagName"] = strs[2], - ["Value"] = "true", - }; - HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand).Wait(); - } - } - } - catch (Exception ex) - { - Console.WriteLine("【SSXcode】" + ex.Message); - Logger.LogInformation($"【定时任务SSXcode】发生异常 {ex}"); - } - } - - /// - /// 送空托到上升降区 - /// - /// - public async void 送空托到上升降区(string DevName, string TagName) - { - #region 检查信号 - List configs_upMachine = new List(); - if (await Floor2UpDownMachinecode_GetTag(TagName)) - { - LoggerFloor2RackDelivery.LogError($"【送空托到上升降区】{TagName} true"); - configs_upMachine.Add(floor2mechanicalAtmDic[TagName]); - } - // 没有有效信号 - if (configs_upMachine.Count == 0) - return; - #endregion - - await s_task送空托到上升降区.WaitAsync(); - using (var db = _repository.AsSugarClient().CopyNew()) - { - try - { - // 找到没有绑定料架的且库位未锁定的料架区 - ISugarQueryable WmsMechanicalArmHsuagar = db.Queryable() - .InnerJoin((a, b) => a.location_id == b.id) - .Where((a, b) => string.IsNullOrEmpty(a.rackcode) && b.is_lock == 0 && configs_upMachine.Contains(a.name)); - - List WmsMechanicalArmHs = WmsMechanicalArmHsuagar.ToList(); - - if (WmsMechanicalArmHs.Count() == 0) - { - LoggerFloor2RackDelivery.LogWarning($"【送空托到上升降区】 无需补充料架区 {WmsMechanicalArmHsuagar.ToSqlString()}"); - return; - } - - //await db.BeginTranAsync(); - // 料架区 - foreach (WmsMechanicalArmH wmsMechanicalArmH in WmsMechanicalArmHs) - { - // 找到占用且未锁定的库位上的空料架 - ISugarQueryable rackStartLocations = - db.Queryable() - .InnerJoin((a, b) => a.id == b.location_id) - .LeftJoin((a, b, c) => b.id == c.carry_id) - .Where((a, b, c) => a.wh_id == "33780009364245" && a.is_use == "1" && a.is_lock == 0 && string.IsNullOrEmpty(c.id) - && b.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID).OrderBy(a => a.id).Take(1); - - if (rackStartLocations.Count() == 0) - { - LoggerFloor2RackDelivery.LogWarning($"【送空托到上升降区】 暂存仓中没有可用的空料架 {rackStartLocations.ToSqlString()}"); - continue; - } - LoggerFloor2RackDelivery.LogInformation($"【送空托到上升降区】 即将补充料架区{wmsMechanicalArmH.name}"); - - BasLocation startLocation = rackStartLocations.First(); - - List wmsCarryHs = db.Queryable().Where(r => r.location_id == startLocation.id).ToList(); - if (wmsCarryHs.Count == 0) - { - LoggerFloor2RackDelivery.LogError($"【送空托到上升降区】 起点{startLocation.id} {startLocation.location_code}上找不到料架"); - continue; - } - - if (wmsCarryHs.Count > 1) - { - LoggerFloor2RackDelivery.LogError($"【送空托到上升降区】 起点{startLocation.id} {startLocation.location_code}上存在多个料架"); - continue; - } - - // 空料架 - WmsCarryH targetCarry = wmsCarryHs[0]; - - await db.Updateable().SetColumns(r => new BasLocation - { - is_lock = 1 - }).Where(r => r.id == startLocation.id).ExecuteCommandAsync(); - await db.Updateable().SetColumns(r => new BasLocation - { - is_lock = 1 - }).Where(r => r.id == wmsMechanicalArmH.location_id).ExecuteCommandAsync(); - - LoggerFloor2RackDelivery.LogInformation($"【送空托到上升降区】 开始生成预任务 起点{startLocation.location_code} 终点{wmsMechanicalArmH.location_code} 料架 {targetCarry.carry_code}"); - - bool result = await createPretask(startLocation.id, wmsMechanicalArmH.location_id, targetCarry.id, targetCarry.carry_code, LoggerFloor2RackDelivery); - if (!result) - { - LoggerFloor2RackDelivery.LogInformation($"【送空托到上升降区】 未成功生成预任务 起点{startLocation.location_code} 终点{wmsMechanicalArmH.location_code} 料架 {targetCarry.carry_code}"); - throw new Exception($"【送空托到上升降区】 未成功生成预任务 起点{startLocation.location_code} 终点{wmsMechanicalArmH.location_code} 料架 {wmsMechanicalArmH.rackcode}"); - } - } - //await db.CommitTranAsync(); - } - catch (Exception ex) - { - LoggerFloor2RackDelivery.LogInformation($"【送空托到上升降区】 {ex.Message}"); - LoggerFloor2RackDelivery.LogInformation($"【送空托到上升降区】 {ex.StackTrace}"); - //await db.RollbackTranAsync(); - } - finally - { - s_task送空托到上升降区.Release(); - _wareHouseService.GenTaskExecute(); - } - } - } - - /// - /// 送满托到下升降区 - /// - /// - public async void 送满托到下升降区(string DevName, string TagName) - { - #region 检查信号 - List configs_upMachine = new List(); - if (await Floor2UpDownMachinecode_GetTag(TagName)) - { - LoggerFloor2RackDelivery.LogError($"【送满托到下升降区】{TagName} true"); - configs_upMachine.Add(floor2mechanicalAtmDic[TagName]); - } - - // 没有有效信号 - if (configs_upMachine.Count == 0) - return; - #endregion - - await s_task送满托到下升降区.WaitAsync(); - using (var db = _repository.AsSugarClient().CopyNew()) - { - try - { - // 找到没有绑定料架的且库位未锁定的料架区 - ISugarQueryable WmsMechanicalArmHsuagar = db.Queryable() - .InnerJoin((a, b) => a.location_id == b.id) - .Where((a, b) => string.IsNullOrEmpty(a.rackcode) && b.is_lock == 0 && configs_upMachine.Contains(a.name)); - - List WmsMechanicalArmHs = WmsMechanicalArmHsuagar.ToList(); - - if (WmsMechanicalArmHs.Count() == 0) - { - LoggerFloor2RackDelivery.LogWarning($"【送满托到下升降区】 无需补充料架区 {WmsMechanicalArmHsuagar.ToSqlString()}"); - return; - } - - //await db.BeginTranAsync(); - // 料架区 - foreach (WmsMechanicalArmH wmsMechanicalArmH in WmsMechanicalArmHs) - { - // 找到占用且未锁定的库位上的满料架且料架中的料箱是空的 - List rackStartLocations = - db.Queryable() - .InnerJoin((a, b) => a.id == b.location_id) - .LeftJoin((a, b, c) => b.id == c.carry_id) // 有料箱 - .LeftJoin((a, b, c, d) => c.membercarry_id == d.carry_id) - .Where((a, b, c, d) => a.wh_id == "33780009364245" && a.is_use == "1" && a.is_lock == 0 && !string.IsNullOrEmpty(c.id) - && b.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID).OrderBy((a, b, c, d) => d.id).Select((a, b, c, d) => new // 关联载具物料明细表 - { - basLocation = a, - WmsCarryCode_id = d.id - }).ToList().GroupBy(r => r.basLocation.location_code).Select(r => - { - var item = r.FirstOrDefault(); - // 前面通过OrderBy(d => d.id)对WmsCarryCode_id进行了排序 那么如果第一行有数据则说明存在非空料箱 - if (!string.IsNullOrEmpty(item.WmsCarryCode_id)) - { - return new BasLocation(); - } - else - { - // 进这里说明库位下的料箱都为空 - return item.basLocation; - } - - }) - // 筛选非空库位数据 - .Where(r => !string.IsNullOrEmpty(r.location_code)).ToList(); - - - if (rackStartLocations.Count() == 0) - { - //LoggerFloor2RackDelivery.LogWarning($"【送满托到下升降区】 暂存仓中没有可用的满料架 {rackStartLocations.ToSqlString()}"); - continue; - } - LoggerFloor2RackDelivery.LogInformation($"【送满托到下升降区】 即将补充料架区{wmsMechanicalArmH.name}"); - - BasLocation startLocation = rackStartLocations.First(); - - List wmsCarryHs = db.Queryable().Where(r => r.location_id == startLocation.id).ToList(); - if (wmsCarryHs.Count == 0) - { - LoggerFloor2RackDelivery.LogError($"【送满托到下升降区】 起点{startLocation.id} {startLocation.location_code}上找不到料架"); - continue; - } - - if (wmsCarryHs.Count > 1) - { - LoggerFloor2RackDelivery.LogError($"【送满托到下升降区】 起点{startLocation.id} {startLocation.location_code}上存在多个料架"); - continue; - } - - // 满料架 - WmsCarryH targetCarry = wmsCarryHs[0]; - - await db.Updateable().SetColumns(r => new BasLocation - { - is_lock = 1 - }).Where(r => r.id == startLocation.id).ExecuteCommandAsync(); - - await db.Updateable().SetColumns(r => new BasLocation - { - is_lock = 1 - }).Where(r => r.id == wmsMechanicalArmH.location_id).ExecuteCommandAsync(); - - LoggerFloor2RackDelivery.LogInformation($"【送满托到下升降区】 开始生成预任务 起点{startLocation.location_code} 终点{wmsMechanicalArmH.location_code} 料架 {targetCarry.carry_code}"); - - bool result = await createPretask(startLocation.id, wmsMechanicalArmH.location_id, targetCarry.id, targetCarry.carry_code, LoggerFloor2RackDelivery); - if (!result) - { - LoggerFloor2RackDelivery.LogInformation($"【送满托到下升降区】 未成功生成预任务 起点{startLocation.location_code} 终点{wmsMechanicalArmH.location_code} 料架 {targetCarry.carry_code}"); - continue; - } - } - //await db.CommitTranAsync(); - } - catch (Exception ex) - { - LoggerFloor2RackDelivery.LogInformation($"【送满托到下升降区】 {ex.Message}"); - LoggerFloor2RackDelivery.LogInformation($"【送满托到下升降区】 {ex.StackTrace}"); - //await db.RollbackTranAsync(); - } - finally - { - s_task送满托到下升降区.Release(); - _wareHouseService.GenTaskExecute(); - } - } - } - - - /// - /// 移走上升降区未生成预任务且满托的料架 - /// - /// - public async void 移走上升降区未生成预任务且满托的料架(string DevName, string TagName) - { - #region 检查信号 - List configs_upMachine = new List(); - if (await Floor2UpDownMachinecode_GetTag(TagName)) - { - LoggerFloor2RackDelivery.LogError($"【移走上升降区未生成预任务且满托的料架】{TagName} true"); - configs_upMachine.Add(floor2mechanicalAtmDic[TagName]); - } - - // 没有有效信号 - if (configs_upMachine.Count == 0) - return; - #endregion - - await s_task移走上升降区未生成预任务且满托的料架.WaitAsync(); - using (var db = _repository.AsSugarClient().CopyNew()) - { - try - { - - //await db.BeginTranAsync(); - // 读取上升降机的左右料架区配置 - - List WmsMechanicalArmHs = db.Queryable().Where(r => r.stackingcount == r.maxnum && r.maxnum != 0 && !string.IsNullOrEmpty(r.rackcode) && r.iscreatepretask == 0 && configs_upMachine.Contains(r.name) && r.mechanicalconfirm == 1).ToList(); - - foreach (WmsMechanicalArmH wmsMechanicalArmH in WmsMechanicalArmHs) - { - LoggerFloor2RackDelivery.LogInformation($"【移走上升降区满托的料架】 开始执行预任务生成 {wmsMechanicalArmH.location_code} {wmsMechanicalArmH.outbill} {wmsMechanicalArmH.barcodes}"); - - await db.Updateable().SetColumns(r => new WmsMechanicalArmH - { - iscreatepretask = 1 - }).Where(r => r.id == wmsMechanicalArmH.id).ExecuteCommandAsync(); - - - // 找到未占用且未锁定的库位 - ISugarQueryable rackEndLocations = - db.Queryable() - .Where(r => r.wh_id == "33780009364245" && r.is_use == "0" && r.is_lock == 0).OrderBy(a => a.id).Take(1); - - if (rackEndLocations.Count() == 0) - { - LoggerFloor2RackDelivery.LogWarning($"【移走上升降区满托的料架】 暂存仓中没有可用的空库位 {rackEndLocations.ToSqlString()}"); - continue; - } - - BasLocation endLocation = rackEndLocations.First(); - - // 锁住终点库位 - await db.Updateable(r => new BasLocation - { - is_lock = 1 - }).Where(r => r.id == endLocation.id).ExecuteCommandAsync(); - - LoggerFloor2RackDelivery.LogInformation($"【移走上升降区满托的料架】 开始执行预任务生成: 料架区为{wmsMechanicalArmH.name}{wmsMechanicalArmH.stackingposition} 料架为{wmsMechanicalArmH.rackcode}"); - - - bool result = await createPretask(wmsMechanicalArmH.location_id, endLocation.id, wmsMechanicalArmH.rackid, wmsMechanicalArmH.rackcode, LoggerFloor2RackDelivery); - if (!result) - { - LoggerFloor2RackDelivery.LogError($"【移走上升降区满托的料架】 未成功生成预任务 起点{wmsMechanicalArmH.location_code} 终点{endLocation.location_code} 料架 {wmsMechanicalArmH.rackcode}"); - throw new Exception($"【移走上升降区满托的料架】 未成功生成预任务 起点{wmsMechanicalArmH.location_code} 终点{endLocation.location_code} 料架 {wmsMechanicalArmH.rackcode}"); - } - LoggerFloor2RackDelivery.LogInformation($"【移走上升降区满托的料架】 成功生成预任务 {result}"); - } - - //await db.CommitTranAsync(); - } - catch (Exception ex) - { - LoggerFloor2RackDelivery.LogInformation($"【移走上升降区未生成预任务且满托的料架】 {ex.Message}"); - LoggerFloor2RackDelivery.LogInformation($"【移走上升降区未生成预任务且满托的料架】 {ex.StackTrace}"); - //await db.RollbackTranAsync(); - } - finally - { - s_task移走上升降区未生成预任务且满托的料架.Release(); - _wareHouseService.GenTaskExecute(); - } - } - } - - - /// - /// 移走下升降区未生成预任务且空托的料架 - /// - /// - public async void 移走下升降区未生成预任务且空托的料架(string DevName, string TagName) - { - #region 检查信号 - List configs_upMachine = new List(); - if (await Floor2UpDownMachinecode_GetTag(TagName)) - { - LoggerFloor2RackDelivery.LogError($"【移走下升降区空托的料架】{TagName} true"); - configs_upMachine.Add(floor2mechanicalAtmDic[TagName]); - } - - // 没有有效信号 - if (configs_upMachine.Count == 0) - return; - #endregion - await s_task移走下升降区未生成预任务且空托的料架.WaitAsync(); - using (var db = _repository.AsSugarClient().CopyNew()) - { - try - { - - //await db.BeginTranAsync(); - // 读取下升降机的左右料架区配置 - - List WmsMechanicalArmHs = db.Queryable().Where(r => !string.IsNullOrEmpty(r.rackcode) && r.iscreatepretask == 0 && configs_upMachine.Contains(r.name)).ToList(); - - foreach (WmsMechanicalArmH wmsMechanicalArmH in WmsMechanicalArmHs) - { - LoggerFloor2RackDelivery.LogInformation($"【移走下升降区空托的料架】 开始执行预任务生成 {wmsMechanicalArmH.location_code} {wmsMechanicalArmH.outbill} {wmsMechanicalArmH.barcodes}"); - - await db.Updateable().SetColumns(r => new WmsMechanicalArmH - { - iscreatepretask = 1 - }).Where(r => r.id == wmsMechanicalArmH.id).ExecuteCommandAsync(); - - // 找到未占用且未锁定的库位 - ISugarQueryable rackEndLocations = - db.Queryable() - .Where(r => r.wh_id == "33780009364245" && r.is_use == "0" && r.is_lock == 0).OrderBy(a => a.id).Take(1); - - if (rackEndLocations.Count() == 0) - { - //LoggerFloor2RackDelivery.LogWarning($"【移走下升降区空托的料架】 暂存仓中没有可用的空库位 {rackEndLocations.ToSqlString()}"); - continue; - } - - BasLocation endLocation = rackEndLocations.First(); - - // 解除绑定料箱到料架 - CarryBindFloor2UpDownMachineInput carryBindFloor2UpDownMachineInput = new() { }; - carryBindFloor2UpDownMachineInput.carry_id = wmsMechanicalArmH.rackid; - carryBindFloor2UpDownMachineInput.carry_code = wmsMechanicalArmH.rackcode; - - await _wmsCarryBindService.CarryUnbindFloor2UpDownMachine(carryBindFloor2UpDownMachineInput); - - // 锁住终点库位 - await db.Updateable(r => new BasLocation - { - is_lock = 1 - }).Where(r => r.id == endLocation.id).ExecuteCommandAsync(); - - LoggerFloor2RackDelivery.LogInformation($"【移走下升降区空托的料架】 开始执行预任务生成: 料架区为{wmsMechanicalArmH.name}{wmsMechanicalArmH.stackingposition} 料架为{wmsMechanicalArmH.rackcode}"); - - bool result = await createPretask(wmsMechanicalArmH.location_id, endLocation.id, wmsMechanicalArmH.rackid, wmsMechanicalArmH.rackcode, LoggerFloor2RackDelivery); - if (!result) - { - LoggerFloor2RackDelivery.LogInformation($"【移走下升降区空托的料架】 未成功生成预任务 起点{wmsMechanicalArmH.location_code} 终点{endLocation.location_code} 料架 {wmsMechanicalArmH.rackcode}"); - continue; - } - } - //await db.CommitTranAsync(); - } - catch (Exception ex) - { - LoggerFloor2RackDelivery.LogInformation($"【移走下升降区空托的料架】 {ex.Message}"); - LoggerFloor2RackDelivery.LogInformation($"【移走下升降区空托的料架】 {ex.StackTrace}"); - //await db.RollbackTranAsync(); - } - finally - { - s_task移走下升降区未生成预任务且空托的料架.Release(); - _wareHouseService.GenTaskExecute(); - } - } - } - #endregion - - #region 旧版轮询 - //ctu取货 - private void CheckGet(object? state) + private async void CheckGet(object? state) { Dictionary getdic = new Dictionary(); getdic.Add("SSX-021-005", new string[] { "YTCS", "AllowFullOut_CS05", "LiftCode" }); @@ -1159,68 +124,60 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA getdic.Add("ZSSSXCTU02", new string[] { "YTCS", "AllowAgvEmptyOut_CS03", "" }); getdic.Add("ZSSSXCTU01", new string[] { "YTCS", "AllowAgvEmptyOut_CS01", "" }); - foreach (var key in getdic.Keys) { try { var strs = getdic.Where(p => p.Key == key).First().Value; - bool flag = _redisData.HashExist(strs[0], strs[1]).Result; - string data = _redisData.GetHash(strs[0], strs[1]).Result; - if (data == null) - { - continue; - } - JObject? res = JsonConvert.DeserializeObject(data); - bool result = res != null && res["Value"] != null ? res.Value("Value") : false; + bool result = await GetBoolTag(strs[0], strs[1]); + if (result) { if (!string.IsNullOrEmpty(strs[2])) { - string codedata = _redisData.GetHash(strs[0], strs[2]).Result; - if (codedata == null) + string coderesult = await GetStringTag(strs[0], strs[2]); + coderesult = coderesult.Replace("\r", "").Replace(" ", ""); + + if (string.IsNullOrEmpty(coderesult)) { continue; } - JObject? coderes = JsonConvert.DeserializeObject(codedata); - string coderesult = coderes != null && coderes["Value"] != null ? coderes.Value("Value")! : ""; - coderesult = coderesult.Replace("\r", ""); - - Logger.LogInformation($@"【定时任务CheckGet】 成功取到{strs[2]}值:{coderesult}"); - var DistaskH = _repository.AsSugarClient().Queryable().Where(p => p.carry_code == coderesult && p.status == WmsWareHouseConst.TASK_BILL_STATUS_YXD_ID && string.IsNullOrEmpty(p.extras)).First(); - - - if (DistaskH != null) + using (var _db = _repository.AsSugarClient().CopyNew()) { - Logger.LogInformation($@"【定时任务CheckGet】 成功找到载具:{coderesult} 对应的任务执行单{DistaskH.bill_code}"); - dynamic reqBody = new ExpandoObject(); - reqBody.taskCode = DistaskH.bill_code; - reqBody.slotCode = key; - reqBody.containerCode = coderesult; - CancellationTokenSource Ctu = new(); - 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; + var DistaskH = _db.Queryable().Where(p => p.carry_code == coderesult && p.status == WmsWareHouseConst.TASK_BILL_STATUS_YXD_ID && string.IsNullOrEmpty(p.extras)).First(); - Logger.LogInformation($"【定时任务CheckGet】 接收请求 http://192.168.11.104:1880/wcs/notify/cargo 结果 {respBody} "); - DistaskH.extras = respBody; - _repository.AsSugarClient().Updateable(DistaskH).ExecuteCommand(); - Ctu.Dispose(); - } - else - { - LoggerSSX.LogInformation($@"【定时任务CheckGet】 {key}->{strs[0]} {strs[2]} + if (DistaskH != null) + { + Logger.LogInformation($@"【定时任务CheckGet】 成功找到载具:{coderesult} 对应的任务执行单{DistaskH.bill_code}"); + dynamic reqBody = new ExpandoObject(); + reqBody.taskCode = DistaskH.bill_code; + reqBody.slotCode = key; + reqBody.containerCode = coderesult; + CancellationTokenSource Ctu = new(); + 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; + + Logger.LogInformation($"【定时任务CheckGet】 接收请求 http://192.168.11.104:1880/wcs/notify/cargo 结果 {respBody} "); + DistaskH.extras = respBody; + _db.Updateable(DistaskH).ExecuteCommand(); + Ctu.Dispose(); + } + else + { + LoggerSSX.LogInformation($@"【定时任务CheckGet】 {key}->{strs[0]} {strs[2]} 采集结果:{$@"任务执行(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}' "}"); + } } } else { - Logger.LogInformation($@"【定时任务CheckGet】 strs[2]信号为空 {strs[2]}"); + //Logger.LogInformation($@"【定时任务CheckGet】 {strs[2]}信号为空 {strs[2]}"); //var DistaskH = _repository.AsSugarClient().Queryable().Where(p => p.startlocation_code == key && p.status == WmsWareHouseConst.TASK_BILL_STATUS_YXD_ID && string.IsNullOrEmpty(p.extras)).First(); //if (DistaskH != null) //{ @@ -1415,7 +372,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA #region 八工位 //扫码入库 - private void ScanInStock(object? state) + private async void ScanInStock(object? state) { Dictionary getdic = new Dictionary(); getdic.Add("BGWRKYCL02", new string[] { "CP8", "AllowGetFullBox1", "code1", "PutDoneEmptyBox", "false" }); @@ -1425,19 +382,13 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA try { var strs = getdic.Where(p => p.Key == key).First().Value; - bool flag = _redisData.HashExist(strs[0], strs[1]).Result; - string data = _redisData.GetHash(strs[0], strs[1]).Result; - if (data == null) - { - continue; - } - JObject? res = JsonConvert.DeserializeObject(data); - bool result = res != null && res["Value"] != null ? res.Value("Value") : false; + bool result = await GetBoolTag(strs[0], strs[1]); + if (result) { - Logger.LogInformation($"【ScanInStock】 八工位 {key} AllowGetFullBox1采集到 {res["Value"]}"); + Logger.LogInformation($"【ScanInStock】 八工位 {key} AllowGetFullBox1采集到 {result}"); Dictionary dicCommand = new(StringComparer.OrdinalIgnoreCase) { @@ -1448,10 +399,12 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA }; Logger.LogInformation($"【ScanInStock】 八工位 {key} 发送PutDoneEmptyBox指令 {_eleCtlCfg.WriteTagUrl} {JsonConvert.SerializeObject(dicCommand)}"); HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand).Wait(); - string codedata = _redisData.GetHash(strs[0], strs[2]).Result; - Logger.LogInformation($"【ScanInStock】 八工位 {key} 获取到扫码信息: {codedata}"); - JObject? coderes = JsonConvert.DeserializeObject(codedata); - string coderesult = coderes != null && coderes["Value"] != null ? coderes.Value("Value")! : ""; + + + string coderesult = await GetStringTag(strs[0], strs[2]); + + Logger.LogInformation($"【ScanInStock】 八工位 {key} 获取到扫码信息: {coderesult}"); + WmsCarryH? carry = _repository.AsSugarClient().Queryable().Single(it => it.carry_code == coderesult); Logger.LogInformation($"【ScanInStock】 八工位 {key} 查找{coderesult}绑定的托盘: {JsonConvert.SerializeObject(carry)}"); if (carry != null) @@ -1508,43 +461,33 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA try { var strs = getdic.Where(p => p.Key == key).First().Value; - string data = await _redisData.GetHash(strs[0], strs[1]); - if (data == null) - { - continue; - } - JObject? res = JsonConvert.DeserializeObject(data); - - bool result = res != null && res["Value"] != null ? res.Value("Value") : false; + bool result = await GetBoolTag(strs[0], strs[1]); if (result) { - LoggerBGWCarrySupplement.LogInformation($"【BGWCarrySupplementtimer】 八工位 {key} {strs[1]}采集到 {res["Value"]}"); + //LoggerBGWCarrySupplement.LogInformation($"【BGWCarrySupplementtimer】 八工位 {key} {strs[1]}采集到 {result}"); BasLocation endLocation = _repository.AsSugarClient().Queryable().Where(r => r.location_code == key).First(); if (endLocation == null) { - LoggerBGWCarrySupplement.LogWarning($"【BGWCarrySupplementtimer】 {key}未维护库位信息"); + //LoggerBGWCarrySupplement.LogWarning($"【BGWCarrySupplementtimer】 {key}未维护库位信息"); continue; } if (endLocation.is_lock == 1) { - LoggerBGWCarrySupplement.LogInformation($"【BGWCarrySupplementtimer】 八工位 {key} 已锁定"); + //LoggerBGWCarrySupplement.LogInformation($"【BGWCarrySupplementtimer】 八工位 {key} 已锁定"); continue; } // 找到库位未锁定的空托盘 todo 待修改为使用出库策略 var wmsLoc = _repository.AsSugarClient().Queryable() - .InnerJoin((a, b) => a.id == b.location_id) - .LeftJoin((a, b, c) => b.id == c.carry_id) - .Where((a, b, c) => string.IsNullOrEmpty(c.barcode) && a.wh_id == WmsWareHouseConst.WAREHOUSE_YCL_ID && a.location_code.Contains("YCL-")).OrderBy((a, b, c) => a.location_code).Select((a, b, c) => new - { - basLocation = a, - FirstWmsCarryH = b - }); + .LeftJoin((a, b) => a.id == b.location_id) + .Where((a, b) => a.wh_id == WmsWareHouseConst.WAREHOUSE_YCL_ID + && a.is_lock == 0 && a.location_code.Contains("YCL-") && a.is_use == "1") + .OrderBy((a, b) => a.location_code); + - BasLocation startLocation = wmsLoc.First().basLocation; - WmsCarryH wmsCarryH = wmsLoc.First().FirstWmsCarryH; + BasLocation startLocation = wmsLoc.First(); //锁定起点库位 await _repository.AsSugarClient().Updateable().SetColumns(r => r.is_lock == 1).Where(r => r.id == startLocation.id).ExecuteCommandAsync(); @@ -1552,7 +495,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA await _repository.AsSugarClient().Updateable().SetColumns(r => new BasLocation { is_lock = 1, is_use = "0" }).Where(r => r.id == endLocation.id).ExecuteCommandAsync(); - bool result_createPretask = await createPretask(startLocation.id, endLocation.id, wmsCarryH.id, wmsCarryH.carry_code, LoggerBGWCarrySupplement); + bool result_createPretask = await createPretask(startLocation.id, endLocation.id, "", "", LoggerBGWCarrySupplement); if (!result_createPretask) { LoggerBGWCarrySupplement.LogWarning($"【BGWCarrySupplementtimer】 {startLocation.location_code} 到 {endLocation.location_code} 预任务生成失败 "); @@ -1583,7 +526,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA { try { - var json = _redisData.GetHash(config.dev_name!, config.tag_name!).Result; + var json = _redisData.GetHash(config.dev_name!, config.tag_name!); if (json == null) { continue; @@ -1751,17 +694,10 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA try { var strs = getdic.Where(p => p.Key == key).First().Value; - string data = await _redisData.GetHash(strs[0], strs[1]); - if (data == null) - { - continue; - } - JObject? res = JsonConvert.DeserializeObject(data); - - bool result = res != null && res["Value"] != null ? res.Value("Value") : false; + bool result = await GetBoolTag(strs[0], strs[1]); if (result) { - LoggerYCLGLDPJInstock.LogInformation($"【YCLGLDPJInstock】 三工位叠盘机 {key} {strs[1]}采集到 {res["Value"]}"); + LoggerYCLGLDPJInstock.LogInformation($"【YCLGLDPJInstock】 三工位叠盘机 {key} {strs[1]}采集到 {result}"); using (var db = _repository.AsSugarClient().CopyNew()) { @@ -1830,17 +766,10 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA try { var strs = getdic.Where(p => p.Key == key).First().Value; - string data = await _redisData.GetHash(strs[0], strs[1]); - if (data == null) - { - continue; - } - JObject? res = JsonConvert.DeserializeObject(data); - - bool result = res != null && res["Value"] != null ? res.Value("Value") : false; + bool result = await GetBoolTag(strs[0], strs[1]); if (result) { - LoggerYCLGLDPJInstock.LogInformation($"【YCLWXDPJInstock】 外协叠盘机 {key} {strs[1]}采集到 {res["Value"]}"); + LoggerYCLGLDPJInstock.LogInformation($"【YCLWXDPJInstock】 外协叠盘机 {key} {strs[1]}采集到 {result}"); BasLocation startLocation = _repository.AsSugarClient().Queryable().Where(r => r.location_code == key).First(); if (startLocation == null) @@ -1897,7 +826,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA #region 中储仓 - private void SSXcode(object? state) + private async void SSXcode(object? state) { Dictionary dic = new Dictionary(); dic.Add("东面提升机输送线", new string[] { "下升降机判断请求", "下升降机判断条码", "下升降机判断完毕", "下升降机判断结果" }); @@ -1909,26 +838,13 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA try { var strs = dic.Where(p => p.Key == key).First().Value; - string dataflag = _redisData.GetHash(key, strs[0]).Result; - if (dataflag == null) - { - continue; - } - JObject? resflag = JsonConvert.DeserializeObject(dataflag); - //Logger.LogInformation($"【定时任务SSXcode】 {key}->{strs[0]} 采集结果:{resflag}"); - bool re = resflag != null && resflag["Value"] != null ? resflag.Value("Value") : false; + + bool re = await GetBoolTag(key, strs[0]); if (!re) continue; - string data = _redisData.GetHash(key, strs[1]).Result; - if (data == null) - { - continue; - } - JObject? res = JsonConvert.DeserializeObject(data); - //Logger.LogInformation($"【定时任务SSXcode】 {key}->{strs[1]} 采集结果:{res}"); - string? result = res != null && res["Value"] != null ? res.Value("Value") : ""; + string? result = await GetStringTag(key, strs[1]); if (!string.IsNullOrEmpty(result)) { if (result.Length < 5) @@ -2012,13 +928,12 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA // 上升降机扫码 需要等待空料架区 此处需要轮询 private async void Floor2UpMachinecode(object? args) { - string barcode = await Floor2UpDownMachinecode_GetTag(MechanicalArmConsts.上升降机条码); + string barcode = await GetStringTag("东面提升机输送线", MechanicalArmConsts.上升降机条码); if (string.IsNullOrEmpty(barcode)) { LoggerFloor2UpDownMachine.LogError($@"【上升降机】未取到条码数据"); return; } - using (var db = _repository.AsSugarClient().CopyNew()) { try @@ -2189,12 +1104,12 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA { #region 检查信号 List configs_upMachine = new List(); - if (await Floor2UpDownMachinecode_GetTag($"上升降机请求送空托1")) + if (await GetBoolTag("东面提升机输送线", $"上升降机请求送空托1")) { LoggerFloor2RackDelivery.LogError($"【送空托到上升降区】上升降机请求送空托1 true"); configs_upMachine.Add(floor2mechanicalAtmDic["上升降机请求送空托1"]); } - if (await Floor2UpDownMachinecode_GetTag($"上升降机请求送空托2")) + if (await GetBoolTag("东面提升机输送线", $"上升降机请求送空托2")) { LoggerFloor2RackDelivery.LogError($"【送空托到上升降区】上升降机请求送空托2 true"); configs_upMachine.Add(floor2mechanicalAtmDic["上升降机请求送空托2"]); @@ -2302,12 +1217,12 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA { #region 检查信号 List configs_upMachine = new List(); - if (await Floor2UpDownMachinecode_GetTag($"下升降机请求送满托1")) + if (await GetBoolTag("东面提升机输送线", $"下升降机请求送满托1")) { LoggerFloor2RackDelivery.LogError($"【送满托到下升降区】下升降机请求送满托1 true"); configs_upMachine.Add(floor2mechanicalAtmDic["下升降机请求送满托1"]); } - if (await Floor2UpDownMachinecode_GetTag($"下升降机请求送满托2")) + if (await GetBoolTag("东面提升机输送线", $"下升降机请求送满托2")) { LoggerFloor2RackDelivery.LogError($"【送满托到下升降区】下升降机请求送满托2 true"); configs_upMachine.Add(floor2mechanicalAtmDic["下升降机请求送满托2"]); @@ -2439,12 +1354,12 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA { #region 检查信号 List configs_upMachine = new List(); - if (await Floor2UpDownMachinecode_GetTag($"上升降机请求取满托1")) + if (await GetBoolTag("东面提升机输送线", $"上升降机请求取满托1")) { LoggerFloor2RackDelivery.LogError($"【移走上升降区未生成预任务且满托的料架】上升降机请求取满托1 true"); configs_upMachine.Add(floor2mechanicalAtmDic["上升降机请求取满托1"]); } - if (await Floor2UpDownMachinecode_GetTag($"上升降机请求取满托2")) + if (await GetBoolTag("东面提升机输送线", $"上升降机请求取满托2")) { LoggerFloor2RackDelivery.LogError($"【移走上升降区未生成预任务且满托的料架】上升降机请求取满托2 true"); configs_upMachine.Add(floor2mechanicalAtmDic["上升降机请求取满托2"]); @@ -2489,11 +1404,11 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA BasLocation endLocation = rackEndLocations.First(); - // 锁住终点库位 - await db.Updateable(r => new BasLocation - { - is_lock = 1 - }).Where(r => r.id == endLocation.id).ExecuteCommandAsync(); + // 锁住终点库位 + //await db.Updateable(r => new BasLocation + //{ + // is_lock = 1 + //}).Where(r => r.id == endLocation.id).ExecuteCommandAsync(); LoggerFloor2RackDelivery.LogInformation($"【移走上升降区满托的料架】 开始执行预任务生成: 料架区为{wmsMechanicalArmH.name}{wmsMechanicalArmH.stackingposition} 料架为{wmsMechanicalArmH.rackcode}"); @@ -2532,13 +1447,13 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA { #region 检查信号 List configs_upMachine = new List(); - if (await Floor2UpDownMachinecode_GetTag($"下升降机请求取空托1")) + if (await GetBoolTag("东面提升机输送线", $"下升降机请求取空托1")) { LoggerFloor2RackDelivery.LogError($"【移走下升降区空托的料架】下升降机请求取空托1 true"); configs_upMachine.Add(floor2mechanicalAtmDic["下升降机请求取空托1"]); } - if (await Floor2UpDownMachinecode_GetTag($"下升降机请求取空托2")) + if (await GetBoolTag("东面提升机输送线", $"下升降机请求取空托2")) { LoggerFloor2RackDelivery.LogError($"【移走下升降区空托的料架】下升降机请求取空托2 true"); configs_upMachine.Add(floor2mechanicalAtmDic["下升降机请求取空托2"]); @@ -2642,11 +1557,79 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA return false; } - - private async Task Floor2UpDownMachinecode_GetTag(string tag) + public async Task GetBoolTag(string DevName, string field) { - string key = "东面提升机输送线"; - return await _redisData.TryGetValueByKeyField(key, tag.ToString()); + try + { + string jsonString = _redisData.GetHash(DevName, field); + + string pattern = @"""Value"":\s*(true|false)"; + + System.Text.RegularExpressions.Match match = Regex.Match(jsonString, pattern); + if (match.Success) + { + return bool.Parse(match.Groups[1].Value); + } + else + { + Console.WriteLine($"未找到匹配项{DevName} {field}"); + } + } + catch (Exception ex) + { + Console.WriteLine($"未找到匹配项{DevName} {field}"); + } + + return false; + } + public async Task GetStringTag(string DevName, string field) + { + try + { + string jsonString = _redisData.GetHash(DevName, field); + + JObject jsonObject = JObject.Parse(jsonString); + + if (jsonObject.TryGetValue("Value", out JToken valueToken)) + { + return valueToken.ToString(); + } + else + { + Console.WriteLine($"未找到匹配项 {DevName} {field}"); + } + } + catch (Exception ex) + { + // 捕获并处理异常 + Console.WriteLine($"发生异常: {ex.Message}"); + } + + return $"未找到匹配项 {DevName} {field}"; + //try + //{ + + // string jsonString = _redisData.GetHash(DevName, field); + + // string pattern = @"""Value"":\s*""([^""]+)"""; + + // System.Text.RegularExpressions.Match match = Regex.Match(jsonString, pattern); + // if (match.Success) + // { + + // return match.Groups[1].Value; + // } + // else + // { + // Console.WriteLine($"未找到匹配项{DevName} {field}"); + // } + //} + //catch (Exception ex) + //{ + // Console.WriteLine($"未找到匹配项{DevName} {field}"); + //} + + //return $"未找到匹配项 {DevName} {field}"; } private async Task Floor2UpDownMachinecode_SetTag(string tag, string value) @@ -2691,7 +1674,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA //YCLWXDPJInstocktimer = new Timer(YCLWXDPJInstock, null, TimeSpan.Zero, TimeSpan.FromSeconds(100000)); // 二楼上升降机 - Floor2UpMachinecodetimer = new Timer(Floor2UpMachinecode, null, TimeSpan.Zero, TimeSpan.FromSeconds(20)); + Floor2UpMachinecodetimer = new Timer(Floor2UpMachinecode, null, TimeSpan.Zero, TimeSpan.FromSeconds(30)); // 二楼料架配送 Floor2timer送空托到上升降区 = new Timer(送空托到上升降区, null, TimeSpan.Zero, TimeSpan.FromSeconds(60)); @@ -2704,7 +1687,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA return Task.CompletedTask; } - #endregion + public Task StopAsync(CancellationToken cancellationToken) { return Task.CompletedTask; diff --git a/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj b/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj index fd26adc3..c205c4ae 100644 --- a/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj +++ b/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj @@ -6,6 +6,7 @@ enable True Debug;Release;tianyi + false diff --git a/QcMgr/Tnb.QcMgr.Entities/Tnb.QcMgr.Entities.csproj b/QcMgr/Tnb.QcMgr.Entities/Tnb.QcMgr.Entities.csproj index bd191439..88ce72e2 100644 --- a/QcMgr/Tnb.QcMgr.Entities/Tnb.QcMgr.Entities.csproj +++ b/QcMgr/Tnb.QcMgr.Entities/Tnb.QcMgr.Entities.csproj @@ -5,6 +5,7 @@ enable enable Debug;Release;tianyi + false diff --git a/QcMgr/Tnb.QcMgr.Interfaces/Tnb.QcMgr.Interfaces.csproj b/QcMgr/Tnb.QcMgr.Interfaces/Tnb.QcMgr.Interfaces.csproj index 83334969..add463b1 100644 --- a/QcMgr/Tnb.QcMgr.Interfaces/Tnb.QcMgr.Interfaces.csproj +++ b/QcMgr/Tnb.QcMgr.Interfaces/Tnb.QcMgr.Interfaces.csproj @@ -5,6 +5,7 @@ enable enable Debug;Release;tianyi + false diff --git a/QcMgr/Tnb.QcMgr/Tnb.QcMgr.csproj b/QcMgr/Tnb.QcMgr/Tnb.QcMgr.csproj index 1cf08455..ee840965 100644 --- a/QcMgr/Tnb.QcMgr/Tnb.QcMgr.csproj +++ b/QcMgr/Tnb.QcMgr/Tnb.QcMgr.csproj @@ -5,6 +5,7 @@ enable enable Debug;Release;tianyi + false diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs index ba770235..28999084 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs @@ -39,6 +39,10 @@ /// 预任务生成EnCode /// public const string WMS_PRETASK_H_ENCODE = "PreTaskGen"; + /// + /// 采购收料物料流水号 + /// + public const string WMS_PURCHASE_MAT_ENCODE = "PurchaseMat"; /// 齐套出库生成Encode /// public const string WMS_KITTINGOUTSTK_ENCODE = "WmsKittingOutStk"; @@ -325,15 +329,19 @@ /// /// 一楼供料三工位库位 /// - public const string Floor1GLSGWOutstockStation1 = "30773146852476"; + public const string Floor1GLSGWOutstockStation1 = "30773146852478"; /// /// 一楼供料三工位库位 /// - public const string Floor1GLSGWOutstockStation2 = "30773146852477"; + public const string Floor1GLSGWOutstockStation2 = "30773146852479"; /// /// 一楼供料三工位库位 /// - public const string Floor1GLSGWOutstockStation3 = "30773146852478"; + public const string Floor1GLSGWOutstockStation3 = "30773146852480"; + /// + /// 一楼供料三工位库位 + /// + public const string Floor1GLSGWOutstockStation4 = "30773146852480"; /// /// todo 一楼外协三工位库位 /// diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/MaterialTransferRackInstockInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/MaterialTransferRackInstockInput.cs new file mode 100644 index 00000000..5f872527 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/MaterialTransferRackInstockInput.cs @@ -0,0 +1,46 @@ +namespace Tnb.WarehouseMgr.Entities.Dto +{ + /// + /// 库房业务更新输入参数 + /// + public class MaterialTransferRackInstockInput + { + /// + /// 组织ID + /// + public string org_id { get; set; } + /// + /// 创建用户 + /// + public string create_id { get; set; } + + /// + /// 料架号 + /// + public string? carry_code { get; set; } + + /// + /// 空料箱 + /// + public List details { get; set; } + + /// + /// 起始库位 + /// + public string? startlocation_id { get; set; } + + /// + /// 判断料箱是否为空 + /// + public bool judgeEmptyCarry { get; set; } = true; + } + + + public class MaterialTransferRackInstockDetail + { + /// + /// 料箱号 + /// + public string? carry_code { get; set; } + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Tnb.WarehouseMgr.Entities.csproj b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Tnb.WarehouseMgr.Entities.csproj index bd191439..88ce72e2 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Tnb.WarehouseMgr.Entities.csproj +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Tnb.WarehouseMgr.Entities.csproj @@ -5,6 +5,7 @@ enable enable Debug;Release;tianyi + false diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/Tnb.WarehouseMgr.Interfaces.csproj b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/Tnb.WarehouseMgr.Interfaces.csproj index abcaef0a..8dbb0ac5 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/Tnb.WarehouseMgr.Interfaces.csproj +++ b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/Tnb.WarehouseMgr.Interfaces.csproj @@ -5,6 +5,7 @@ enable enable Debug;Release;tianyi + false diff --git a/WarehouseMgr/Tnb.WarehouseMgr/TimedTaskBackgroundService.cs b/WarehouseMgr/Tnb.WarehouseMgr/TimedTaskBackgroundService.cs index 133ec02c..9fe7072d 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/TimedTaskBackgroundService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/TimedTaskBackgroundService.cs @@ -28,7 +28,7 @@ namespace Tnb.WarehouseMgr private readonly ElevatorControlConfiguration _elevatorControlConfiguration = App.Configuration.Build(); private readonly IServiceProvider _serviceProvider; private readonly IHostApplicationLifetime _lifeTime; - private static List s_heartbeatDevNames = new(); + private List s_heartbeatDevNames = new(); //private static Dictionary> _timedFuncMap = new(StringComparer.OrdinalIgnoreCase); public TimedTaskBackgroundService() { diff --git a/WarehouseMgr/Tnb.WarehouseMgr/Tnb.WarehouseMgr.csproj b/WarehouseMgr/Tnb.WarehouseMgr/Tnb.WarehouseMgr.csproj index 60b81e8b..45a62e7c 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/Tnb.WarehouseMgr.csproj +++ b/WarehouseMgr/Tnb.WarehouseMgr/Tnb.WarehouseMgr.csproj @@ -7,6 +7,7 @@ enable True Debug;Release + false diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index 98007293..23218026 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -247,8 +247,8 @@ namespace Tnb.WarehouseMgr /// public string[] GetFloor1GLSGWOutstockLocation() { - return new string[3] { WmsWareHouseConst.Floor1GLSGWOutstockStation1 , WmsWareHouseConst.Floor1GLSGWOutstockStation2 - , WmsWareHouseConst.Floor1GLSGWOutstockStation3 }; + return new string[4] { WmsWareHouseConst.Floor1GLSGWOutstockStation1 , WmsWareHouseConst.Floor1GLSGWOutstockStation2 + , WmsWareHouseConst.Floor1GLSGWOutstockStation3, WmsWareHouseConst.Floor1GLSGWOutstockStation4 }; } /// @@ -786,7 +786,10 @@ namespace Tnb.WarehouseMgr third_eqp_type = c.third_eqp_type, }, true); - Logger.Information("【GenTaskExecute】 执行SQL: " + sugarQueryable.ToSqlString()); + if (sugarQueryable.Count() == 0) + return; + + //Logger.Information("【GenTaskExecute】 执行SQL: " + sugarQueryable.ToSqlString()); List preTasks = await sugarQueryable.ToListAsync(); @@ -1105,9 +1108,13 @@ namespace Tnb.WarehouseMgr move_num = b.move_num, third_eqp_type = b.third_eqp_type, }, true).ToListAsync(); + + if (CTUTasks.Count == 0) + return; + List TaskCodes = await db.Queryable().Where(it => CTUTasks.Select(p => p.id).ToList().Contains(it.bill_id)).ToListAsync(); - Logger.Information($@"【CTUTaskExecute】 获取任务TaskCodes: {JsonConvert.SerializeObject(TaskCodes)}"); + //Logger.Information($@"【CTUTaskExecute】 获取任务TaskCodes: {JsonConvert.SerializeObject(TaskCodes)}"); var InTasks = CTUTasks.Where(a => a.task_type == WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID).ToList(); var OutTasks = CTUTasks.Where(a => a.task_type == WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID || a.task_type == WmsWareHouseConst.BIZTYPE_WMSTRANSFER_ID).ToList(); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs index f9a87004..c0173ca5 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs @@ -11,6 +11,7 @@ using JNPF.VisualDev.Entitys; using JNPF.VisualDev.Interfaces; using Mapster; using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; using Newtonsoft.Json; using Senparc.Weixin.MP.AdvancedAPIs.Card; using SqlSugar; @@ -166,8 +167,10 @@ namespace Tnb.WarehouseMgr if (WmsCarryCodes.Count > 0) await _db.Insertable(WmsCarryCodes).ExecuteCommandAsync(); } - catch (Exception) + catch (Exception ex) { + Logger.LogError(ex.Message); + Logger.LogError(ex.StackTrace); throw new AppFriendlyException("绑定失败", 500); } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs index afcd5094..e54c8c74 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs @@ -553,7 +553,7 @@ namespace Tnb.WarehouseMgr } /// - /// 从暂存仓呼叫料架到产线 + /// 通过工位查找料架信息 /// /// /// @@ -621,5 +621,77 @@ namespace Tnb.WarehouseMgr return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message); } } + + /// + /// 从产线呼叫装料架到暂存仓 + /// + /// + /// + [HttpPost, NonUnify, AllowAnonymous] + public async Task RackInstock(MaterialTransferRackInstockInput input) + { + try + { + BasLocation startlocation = _db.Queryable().Where(r => r.id == input.startlocation_id).First(); + if (startlocation == null) + { + Logger.LogWarning($"【RackEmptyInstock】不存在id为{input.startlocation_id}的库位!"); + throw new AppFriendlyException($"【RackEmptyInstock】不存在id为{input.startlocation_id}的库位!", 500); + } + if (string.IsNullOrEmpty(input.carry_code)) + { + Logger.LogWarning($"【RackEmptyInstock】料架不能为空!{input.carry_code}"); + throw new AppFriendlyException($"【RackEmptyInstock】料架不能为空!{input.carry_code}!", 500); + } + if (input.judgeEmptyCarry) + { + List wmsCarryCodes = _db.Queryable() + .InnerJoin((a, b) => a.id == b.carry_id) + .Where((a, b) => input.details.Select(r => r.carry_code).Contains(a.carry_code)).Select((a, b) => b).ToList(); + if (wmsCarryCodes.Count > 0) + { + Logger.LogWarning($"【RackEmptyInstock】存在非空料箱{string.Join(',', wmsCarryCodes.Select(r => r.carry_code).Distinct())},不能入库!{input.carry_code}"); + throw new AppFriendlyException($"【RackEmptyInstock】存在非空料箱{string.Join(',', wmsCarryCodes.Select(r => r.carry_code).Distinct())},不能入库!{input.carry_code}!", 500); + } + } + + // 找到未占用且未锁定的库位 + ISugarQueryable rackEndLocations = + _db.Queryable() + .Where(r => r.wh_id == "33780009364245" && r.is_use == "0" && r.is_lock == 0).OrderBy(a => a.id).Take(1); + + if (rackEndLocations.Count() == 0) + { + Logger.LogWarning($"【RackEmptyInstock】没有可用的终点库位"); + throw new AppFriendlyException($"【RackEmptyInstock】没有可用的终点库位!", 500); + } + + BasLocation endlocation = rackEndLocations.First(); + + + CommonCreatePretaskInput commonCreatePretaskInput = new CommonCreatePretaskInput(); + commonCreatePretaskInput.startlocation_id = startlocation.id; + commonCreatePretaskInput.endlocation_id = endlocation.id; + commonCreatePretaskInput.carry_code = input.carry_code; + commonCreatePretaskInput.task_type = ""; + commonCreatePretaskInput.biz_type = "FloorCallMaterial"; + + var res = await _wareHouseService.CommonCreatePretask(commonCreatePretaskInput); + if (res.code != JNPF.Common.Enums.HttpStatusCode.OK) + { + Logger.LogInformation($"【RackEmptyInstock】生成预任务失败 载具 {input.carry_code}"); + throw new AppFriendlyException($"生成预任务失败 载具 {input.carry_code}", 500); + } + } + catch (Exception ex) + { + Logger.LogError("【RackEmptyInstock】" + ex.Message); + Logger.LogError("【RackEmptyInstock】" + ex.StackTrace); + return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message); + } + + return await ToApiResult(HttpStatusCode.OK, "成功"); + + } } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs index 65c79cc6..7c38ddfc 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs @@ -41,11 +41,12 @@ namespace Tnb.WarehouseMgr private readonly IBillRullService _billRullService; private readonly ISqlSugarClient _db; private readonly IUserManager _userManager; - public WmsPurchaseService(ISqlSugarRepository repo, IUserManager userManager, IQcCheckPlanService qcCheckPlanService) + public WmsPurchaseService(ISqlSugarRepository repo, IUserManager userManager, IQcCheckPlanService qcCheckPlanService, IBillRullService billRullService) : base(repo, userManager, qcCheckPlanService) { _db = repo.AsSugarClient(); _userManager = userManager; + _billRullService = billRullService; } private async Task xxx(VisualDevModelDataCrInput input) @@ -179,7 +180,11 @@ namespace Tnb.WarehouseMgr for (int j = 0; j < codeNum; j++) { int index = j + 1; - string code = $"{WmsPurchaseD.material_code}-{WmsPurchaseD.code_batch}-{index.ToString().PadLeft(4, '0')}"; + //string code = $"{WmsPurchaseD.material_code}-{WmsPurchaseD.code_batch}-{index.ToString().PadLeft(4, '0')}"; + // 变更加流水号 + string watercode = await _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PURCHASE_MAT_ENCODE); ; + + string code = $"{WmsPurchaseD.material_code}-{WmsPurchaseD.code_batch}{watercode}"; WmsTempCode barCode = new() { material_id = WmsPurchaseD.material_id, diff --git a/apihost/Tnb.API.Entry/Startup.cs b/apihost/Tnb.API.Entry/Startup.cs index d8ac9877..692e0d5a 100644 --- a/apihost/Tnb.API.Entry/Startup.cs +++ b/apihost/Tnb.API.Entry/Startup.cs @@ -50,6 +50,7 @@ public class Startup : AppStartup services.AddMemoryCache(); // 使用本地缓存必须添加 services.AddConfigurableOptions(); services.AddSingleton(typeof(ISingleton), typeof(RedisData)); + services.AddSingleton(typeof(ISingleton), typeof(StackExRedisHelper)); // 微信 services.AddSenparcGlobalServices(App.Configuration) // Senparc.CO2NET 全局注册 .AddSenparcWeixinServices(App.Configuration); // Senparc.Weixin 注册(如果使用Senparc.Weixin SDK则添加) diff --git a/apihost/Tnb.API.Entry/Tnb.API.Entry.csproj b/apihost/Tnb.API.Entry/Tnb.API.Entry.csproj index 8267f70f..ad989d53 100644 --- a/apihost/Tnb.API.Entry/Tnb.API.Entry.csproj +++ b/apihost/Tnb.API.Entry/Tnb.API.Entry.csproj @@ -5,6 +5,8 @@ enable enable none + false + true diff --git a/app/Tnb.Apps.Entitys/Tnb.Apps.Entitys.csproj b/app/Tnb.Apps.Entitys/Tnb.Apps.Entitys.csproj index 91e9762b..3c7dd513 100644 --- a/app/Tnb.Apps.Entitys/Tnb.Apps.Entitys.csproj +++ b/app/Tnb.Apps.Entitys/Tnb.Apps.Entitys.csproj @@ -7,6 +7,7 @@ False $(NoWarn);CS8618; Debug;Release;tianyi + false diff --git a/app/Tnb.Apps.Interfaces/Tnb.Apps.Interfaces.csproj b/app/Tnb.Apps.Interfaces/Tnb.Apps.Interfaces.csproj index f86b6da1..d7c2cfa5 100644 --- a/app/Tnb.Apps.Interfaces/Tnb.Apps.Interfaces.csproj +++ b/app/Tnb.Apps.Interfaces/Tnb.Apps.Interfaces.csproj @@ -6,6 +6,7 @@ enable False Debug;Release;tianyi + false diff --git a/app/Tnb.Apps/Tnb.Apps.csproj b/app/Tnb.Apps/Tnb.Apps.csproj index 602d4ac6..32d1a872 100644 --- a/app/Tnb.Apps/Tnb.Apps.csproj +++ b/app/Tnb.Apps/Tnb.Apps.csproj @@ -7,6 +7,7 @@ True $(NoWarn);CS8600;CS8601;CS8602;CS8603;CS8604;CS8625;CS1572;CS1573; Debug;Release;tianyi + false diff --git a/common/Tnb.CollectiveOAuth/Tnb.CollectiveOAuth.csproj b/common/Tnb.CollectiveOAuth/Tnb.CollectiveOAuth.csproj index d6e59035..640d90e9 100644 --- a/common/Tnb.CollectiveOAuth/Tnb.CollectiveOAuth.csproj +++ b/common/Tnb.CollectiveOAuth/Tnb.CollectiveOAuth.csproj @@ -6,6 +6,7 @@ False $(NoWarn);CS8600;CS8601;CS8602;CS8603;CS8604;CS8618;CS8625;CS1572;CS1573;CS0168; Debug;Release;tianyi + false diff --git a/common/Tnb.Common.Core/Tnb.Common.Core.csproj b/common/Tnb.Common.Core/Tnb.Common.Core.csproj index 08b9033e..01637727 100644 --- a/common/Tnb.Common.Core/Tnb.Common.Core.csproj +++ b/common/Tnb.Common.Core/Tnb.Common.Core.csproj @@ -7,6 +7,7 @@ False $(NoWarn);CS8600;CS8601;CS8602;CS8603;CS8604;CS8618;CS8625;CS1572;CS1573;CS0168;CS1998; Debug;Release;tianyi + false diff --git a/common/Tnb.Common/Redis/RedisData.cs b/common/Tnb.Common/Redis/RedisData.cs index c11024d6..0455b220 100644 --- a/common/Tnb.Common/Redis/RedisData.cs +++ b/common/Tnb.Common/Redis/RedisData.cs @@ -17,7 +17,7 @@ namespace Tnb.Common.Redis { public class RedisData : ISingleton { - private static CSRedisClient _instance; + private CSRedisClient _instance; public delegate void rcvMsgHandler(string Channel, string Body); public event rcvMsgHandler rcvMsg; public RedisData() @@ -25,14 +25,14 @@ namespace Tnb.Common.Redis RedisOptions _RedisOptions = App.GetConfig("Redis", true); _instance = new CSRedis.CSRedisClient(string.Format(_RedisOptions.RedisConnectionString, _RedisOptions.ip, _RedisOptions.port, _RedisOptions.password)); - _instance.Subscribe(("devdata_change", msg => - { - if (rcvMsg != null) - { - rcvMsg(msg.Channel, msg.Body); - } - } - )); + //_instance.Subscribe(("devdata_change", msg => + //{ + // if (rcvMsg != null) + // { + // rcvMsg(msg.Channel, msg.Body); + // } + //} + //)); } /// diff --git a/common/Tnb.Common/Redis/StackExRedisHelper.cs b/common/Tnb.Common/Redis/StackExRedisHelper.cs new file mode 100644 index 00000000..d9b52d1d --- /dev/null +++ b/common/Tnb.Common/Redis/StackExRedisHelper.cs @@ -0,0 +1,88 @@ + +using JNPF; +using JNPF.DependencyInjection; +using Newtonsoft.Json; +using Spire.Xls.Core; +using StackExchange.Redis; +using System; +using System.Threading.Tasks; + +namespace Tnb.Common.Redis +{ + public class StackExRedisHelper : ISingleton + { + private ConnectionMultiplexer _redis; + private IDatabase _db; + + // 初始化 Redis 连接 + public StackExRedisHelper() + { + RedisOptions _RedisOptions = App.GetConfig("Redis", true); + _redis = ConnectionMultiplexer.Connect($"{_RedisOptions.ip}:{_RedisOptions.port},password={_RedisOptions.password}"); + _db = _redis.GetDatabase(); + } + + // 存储字符串值 + public void SetString(string key, string value) + { + _db.StringSet(key, value); + } + + // 获取字符串值 + public string GetString(string key) + { + return _db.StringGet(key); + } + + // 存储哈希值 + public void SetHash(string key, string field, string value) + { + _db.HashSet(key, field, value); + } + + // 获取哈希值 + public string GetHash(string key, string field) + { + return _db.HashGet(key, field); + } + + // 存储列表值 + public void ListRightPush(string key, string value) + { + _db.ListRightPush(key, value); + } + + // 关闭 Redis 连接 + public void Close() + { + if (_redis != null && _redis.IsConnected) + { + _redis.Close(); + } + } + + public async Task TryGetValueByKeyField(string key, string field) + { + if (_db.HashExists(key, field)) + { + string data = GetHash(key, field); + Dictionary json = JsonConvert.DeserializeObject>(data); + Type type = typeof(T); + if ((!type.IsValueType && type.GetGenericArguments().Length > 0) || (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>))) + { + return (T)Convert.ChangeType(json["Value"], type.GetGenericArguments()[0]); + } + else + { + return (T)Convert.ChangeType(json["Value"], type); + } + // return ; + } + return default(T); + } + + } +} + + + diff --git a/common/Tnb.Common/Tnb.Common.csproj b/common/Tnb.Common/Tnb.Common.csproj index 21b2e243..75a65b14 100644 --- a/common/Tnb.Common/Tnb.Common.csproj +++ b/common/Tnb.Common/Tnb.Common.csproj @@ -9,6 +9,7 @@ False $(NoWarn);CS8600;CS8601;CS8602;CS8603;CS8604;CS8605;CS8618;CS8619;CS8625;CS1572;CS1573; Debug;Release;tianyi + false @@ -17,6 +18,7 @@ + diff --git a/common/Tnb.SqlSugar/Tnb.SqlSugar.csproj b/common/Tnb.SqlSugar/Tnb.SqlSugar.csproj index 87c80703..3b764930 100644 --- a/common/Tnb.SqlSugar/Tnb.SqlSugar.csproj +++ b/common/Tnb.SqlSugar/Tnb.SqlSugar.csproj @@ -11,6 +11,7 @@ $(NoWarn);CS1591; False Debug;Release;tianyi + false diff --git a/common/Tnb.Thirdparty/Tnb.Thirdparty.csproj b/common/Tnb.Thirdparty/Tnb.Thirdparty.csproj index a89997d5..d7f6fece 100644 --- a/common/Tnb.Thirdparty/Tnb.Thirdparty.csproj +++ b/common/Tnb.Thirdparty/Tnb.Thirdparty.csproj @@ -8,6 +8,7 @@ False $(NoWarn);CS8600;CS8601;CS8602;CS8603;CS8604;CS8618;CS8625;CS1572;CS1573;CS0168;CS0618; Debug;Release;tianyi + false diff --git a/common/Tnb.WebSockets/Tnb.WebSockets.csproj b/common/Tnb.WebSockets/Tnb.WebSockets.csproj index 7800fba6..a64773e5 100644 --- a/common/Tnb.WebSockets/Tnb.WebSockets.csproj +++ b/common/Tnb.WebSockets/Tnb.WebSockets.csproj @@ -8,6 +8,7 @@ False $(NoWarn);CS8600;CS8601;CS8602;CS8603;CS8604;CS8618;CS1572;CS1573;CS1998; Debug;Release;tianyi + false diff --git a/message/Tnb.Message.Entitys/Tnb.Message.Entitys.csproj b/message/Tnb.Message.Entitys/Tnb.Message.Entitys.csproj index 91e9762b..3c7dd513 100644 --- a/message/Tnb.Message.Entitys/Tnb.Message.Entitys.csproj +++ b/message/Tnb.Message.Entitys/Tnb.Message.Entitys.csproj @@ -7,6 +7,7 @@ False $(NoWarn);CS8618; Debug;Release;tianyi + false diff --git a/message/Tnb.Message.Interfaces/Tnb.Message.Interfaces.csproj b/message/Tnb.Message.Interfaces/Tnb.Message.Interfaces.csproj index 82a14c27..f0a2ec26 100644 --- a/message/Tnb.Message.Interfaces/Tnb.Message.Interfaces.csproj +++ b/message/Tnb.Message.Interfaces/Tnb.Message.Interfaces.csproj @@ -7,6 +7,7 @@ False $(NoWarn);CS8625; Debug;Release;tianyi + false diff --git a/message/Tnb.Message/Tnb.Message.csproj b/message/Tnb.Message/Tnb.Message.csproj index 532b9e1f..f532b044 100644 --- a/message/Tnb.Message/Tnb.Message.csproj +++ b/message/Tnb.Message/Tnb.Message.csproj @@ -7,6 +7,7 @@ True $(NoWarn);CS8600;CS8601;CS8602;CS8603;CS8604;CS8625;CS1572;CS1573;CS0168; Debug;Release;tianyi + false diff --git a/system/Tnb.OAuth/Tnb.OAuth.csproj b/system/Tnb.OAuth/Tnb.OAuth.csproj index 0abba9be..afe5680d 100644 --- a/system/Tnb.OAuth/Tnb.OAuth.csproj +++ b/system/Tnb.OAuth/Tnb.OAuth.csproj @@ -7,6 +7,7 @@ True $(NoWarn);CS8600;CS8601;CS8602;CS8603;CS8604;CS8618;CS8625;CS1572;CS1573; Debug;Release;tianyi + false diff --git a/system/Tnb.Systems.Entitys/Tnb.Systems.Entitys.csproj b/system/Tnb.Systems.Entitys/Tnb.Systems.Entitys.csproj index 3eb5ce90..742281bb 100644 --- a/system/Tnb.Systems.Entitys/Tnb.Systems.Entitys.csproj +++ b/system/Tnb.Systems.Entitys/Tnb.Systems.Entitys.csproj @@ -7,6 +7,7 @@ False $(NoWarn);CS8603;CS8618; Debug;Release;tianyi + false diff --git a/system/Tnb.Systems.Interfaces/Tnb.Systems.Interfaces.csproj b/system/Tnb.Systems.Interfaces/Tnb.Systems.Interfaces.csproj index 2cc455e7..59e33b4b 100644 --- a/system/Tnb.Systems.Interfaces/Tnb.Systems.Interfaces.csproj +++ b/system/Tnb.Systems.Interfaces/Tnb.Systems.Interfaces.csproj @@ -7,6 +7,7 @@ False $(NoWarn);CS8625; Debug;Release;tianyi + false diff --git a/system/Tnb.Systems/Tnb.Systems.csproj b/system/Tnb.Systems/Tnb.Systems.csproj index ef1765d0..2d32bc3a 100644 --- a/system/Tnb.Systems/Tnb.Systems.csproj +++ b/system/Tnb.Systems/Tnb.Systems.csproj @@ -7,6 +7,7 @@ True $(NoWarn);CS8600;CS8601;CS8602;CS8603;CS8604;CS8619;CS8625;CS8629;CS1572;CS1573;CS0168;CS4014;CS1998; Debug;Release;tianyi + false diff --git a/taskschedule/Tnb.TaskScheduler.Entitys/Tnb.TaskScheduler.Entitys.csproj b/taskschedule/Tnb.TaskScheduler.Entitys/Tnb.TaskScheduler.Entitys.csproj index 76ff6275..5bcb8c4a 100644 --- a/taskschedule/Tnb.TaskScheduler.Entitys/Tnb.TaskScheduler.Entitys.csproj +++ b/taskschedule/Tnb.TaskScheduler.Entitys/Tnb.TaskScheduler.Entitys.csproj @@ -7,6 +7,7 @@ False $(NoWarn)CS8604;CS8618; Debug;Release;tianyi + false diff --git a/taskschedule/Tnb.TaskScheduler.Interfaces/Tnb.TaskScheduler.Interfaces.csproj b/taskschedule/Tnb.TaskScheduler.Interfaces/Tnb.TaskScheduler.Interfaces.csproj index 06e5f273..7aa58aee 100644 --- a/taskschedule/Tnb.TaskScheduler.Interfaces/Tnb.TaskScheduler.Interfaces.csproj +++ b/taskschedule/Tnb.TaskScheduler.Interfaces/Tnb.TaskScheduler.Interfaces.csproj @@ -6,6 +6,7 @@ enable False Debug;Release;tianyi + false diff --git a/taskschedule/Tnb.TaskScheduler/Tnb.TaskScheduler.csproj b/taskschedule/Tnb.TaskScheduler/Tnb.TaskScheduler.csproj index 64004e32..a78c6a54 100644 --- a/taskschedule/Tnb.TaskScheduler/Tnb.TaskScheduler.csproj +++ b/taskschedule/Tnb.TaskScheduler/Tnb.TaskScheduler.csproj @@ -7,6 +7,7 @@ True $(NoWarn);CS8600;CS8601;CS8602;CS8603;CS8604;CS8625;CS1572;CS1573; Debug;Release;tianyi + false diff --git a/visualdev/Tnb.Vengine/Tnb.Vengine.csproj b/visualdev/Tnb.Vengine/Tnb.Vengine.csproj index 76ce863d..d1e6e0a6 100644 --- a/visualdev/Tnb.Vengine/Tnb.Vengine.csproj +++ b/visualdev/Tnb.Vengine/Tnb.Vengine.csproj @@ -5,6 +5,7 @@ enable enable Debug;Release;tianyi + false diff --git a/visualdev/Tnb.VisualDev.Engine/Tnb.VisualDev.Engine.csproj b/visualdev/Tnb.VisualDev.Engine/Tnb.VisualDev.Engine.csproj index 39aadc75..9d962edb 100644 --- a/visualdev/Tnb.VisualDev.Engine/Tnb.VisualDev.Engine.csproj +++ b/visualdev/Tnb.VisualDev.Engine/Tnb.VisualDev.Engine.csproj @@ -7,6 +7,7 @@ False $(NoWarn);CS8600;CS8601;CS8602;CS8603;CS8604;CS8618;CS8625;CS8629;CS1572;CS1573;CS0168; Debug;Release;tianyi + false diff --git a/visualdev/Tnb.VisualDev.Entitys/Tnb.VisualDev.Entitys.csproj b/visualdev/Tnb.VisualDev.Entitys/Tnb.VisualDev.Entitys.csproj index 91e9762b..3c7dd513 100644 --- a/visualdev/Tnb.VisualDev.Entitys/Tnb.VisualDev.Entitys.csproj +++ b/visualdev/Tnb.VisualDev.Entitys/Tnb.VisualDev.Entitys.csproj @@ -7,6 +7,7 @@ False $(NoWarn);CS8618; Debug;Release;tianyi + false diff --git a/visualdev/Tnb.VisualDev.Interfaces/Tnb.VisualDev.Interfaces.csproj b/visualdev/Tnb.VisualDev.Interfaces/Tnb.VisualDev.Interfaces.csproj index b05836bd..89bbc55e 100644 --- a/visualdev/Tnb.VisualDev.Interfaces/Tnb.VisualDev.Interfaces.csproj +++ b/visualdev/Tnb.VisualDev.Interfaces/Tnb.VisualDev.Interfaces.csproj @@ -6,6 +6,7 @@ enable False Debug;Release;tianyi + false diff --git a/visualdev/Tnb.VisualDev/Tnb.VisualDev.csproj b/visualdev/Tnb.VisualDev/Tnb.VisualDev.csproj index 737ec225..8ec137c9 100644 --- a/visualdev/Tnb.VisualDev/Tnb.VisualDev.csproj +++ b/visualdev/Tnb.VisualDev/Tnb.VisualDev.csproj @@ -7,6 +7,7 @@ True $(NoWarn);CS8600;CS8601;CS8602;CS8603;CS8604;CS8625;CS8629;CS1572;CS1573;CS0168; Debug;Release;tianyi + false diff --git a/workflow/Tnb.WorkFlow.Entitys/Tnb.WorkFlow.Entitys.csproj b/workflow/Tnb.WorkFlow.Entitys/Tnb.WorkFlow.Entitys.csproj index 1d28267e..bd8d37cf 100644 --- a/workflow/Tnb.WorkFlow.Entitys/Tnb.WorkFlow.Entitys.csproj +++ b/workflow/Tnb.WorkFlow.Entitys/Tnb.WorkFlow.Entitys.csproj @@ -7,6 +7,7 @@ False $(NoWarn);CS8618; Debug;Release;tianyi + false diff --git a/workflow/Tnb.WorkFlow.Interfaces/Tnb.WorkFlow.Interfaces.csproj b/workflow/Tnb.WorkFlow.Interfaces/Tnb.WorkFlow.Interfaces.csproj index f6218d45..5e4df15c 100644 --- a/workflow/Tnb.WorkFlow.Interfaces/Tnb.WorkFlow.Interfaces.csproj +++ b/workflow/Tnb.WorkFlow.Interfaces/Tnb.WorkFlow.Interfaces.csproj @@ -7,6 +7,7 @@ False $(NoWarn);CS8625; Debug;Release;tianyi + false diff --git a/workflow/Tnb.WorkFlow/Tnb.WorkFlow.csproj b/workflow/Tnb.WorkFlow/Tnb.WorkFlow.csproj index 5d764794..8072e9b3 100644 --- a/workflow/Tnb.WorkFlow/Tnb.WorkFlow.csproj +++ b/workflow/Tnb.WorkFlow/Tnb.WorkFlow.csproj @@ -7,6 +7,7 @@ True $(NoWarn);CS8600;CS8601;CS8602;CS8603;CS8604;CS8619;CS8620;CS8625;CS8629;CS1572;CS1573;CS0168;CS4014;CS1998; Debug;Release;tianyi + false