From 878a800bc77b68dfa7e061e845a305b2f908df4b Mon Sep 17 00:00:00 2001 From: qianjiawei <1184704771@qq.com> Date: Mon, 29 Jan 2024 15:55:11 +0800 Subject: [PATCH] 1 --- .../Tnb.ProductionMgr/RedisBackGround.cs | 23 +++--- .../IWareHouseService.cs | 1 + .../Tnb.WarehouseMgr/DeviceProviderService.cs | 4 +- .../Tnb.WarehouseMgr/WareHouseService.cs | 77 +++++++++++++++++++ .../Configurations/ConnectionStrings.json | 8 +- apihost/Tnb.API.Entry/Startup.cs | 2 +- 6 files changed, 97 insertions(+), 18 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs b/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs index 854a02c3..93da9279 100644 --- a/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs +++ b/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs @@ -121,8 +121,7 @@ namespace Tnb.ProductionMgr private void CheckGet(object state) { Dictionary getdic = new Dictionary(); - getdic.Add("SSX-021-005", new string[] { "CS05", "FullBoxAllowGet", "Code" }); - getdic.Add("SSX-021-006", new string[] { "CS06", "FullBoxAllowGet", "Code" }); + getdic.Add("SSX-021-005", new string[] { "YTCS", "AllowFullOut_CS05", "LiftCode" }); foreach (var key in getdic.Keys) { try @@ -138,14 +137,16 @@ namespace Tnb.ProductionMgr JObject? coderes = JsonConvert.DeserializeObject(codedata); string coderesult = coderes != null && coderes["Value"] != null ? coderes.Value("Value")! : ""; var DistaskH = _repository.AsSugarClient().Queryable().Where(p => p.carry_code == coderesult && p.status == WmsWareHouseConst.TASK_BILL_STATUS_RUNING_ID).First(); - dynamic reqBody = new ExpandoObject(); - reqBody.taskCode = DistaskH.bill_code; - reqBody.slotCode = key; - reqBody.containerCode = coderesult; - CancellationTokenSource Ctu = new(); - //{"code":500,"msg":"成功!"} - dynamic respBody = HttpClientHelper.PostStreamAsync("http://192.168.11.104:1880/wcs/notify/cargo", reqBody, Ctu.Token).Result; - Ctu.Dispose(); + if (DistaskH != null) + { + dynamic reqBody = new ExpandoObject(); + reqBody.taskCode = DistaskH.bill_code; + reqBody.slotCode = key; + reqBody.containerCode = coderesult; + CancellationTokenSource Ctu = new(); + dynamic respBody = HttpClientHelper.PostStreamAsync("http://192.168.11.104:1880/wcs/notify/cargo", reqBody, Ctu.Token).Result; + Ctu.Dispose(); + } } } catch (Exception) @@ -190,7 +191,7 @@ namespace Tnb.ProductionMgr public Task StartAsync(CancellationToken cancellationToken) { // Readtimer = new Timer(GetRedisData, null, TimeSpan.Zero, TimeSpan.FromSeconds(300)); - // CheckGettimer = new Timer(CheckGet, null, TimeSpan.Zero, TimeSpan.FromSeconds(300)); + CheckGettimer = new Timer(CheckGet, null, TimeSpan.Zero, TimeSpan.FromSeconds(60)); // Scantimer = new Timer(ScanInStock, null, TimeSpan.Zero, TimeSpan.FromSeconds(300)); return Task.CompletedTask; } diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWareHouseService.cs index a79e8faa..a829edea 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWareHouseService.cs @@ -74,6 +74,7 @@ namespace Tnb.WarehouseMgr.Interfaces /// /// Task> PathAlgorithmsEle(string pStartId, string pEndId, int ele); + Task SsxControl(WmsDistaskH disTask, string action); Func AddUnExecuteTask { get; set; } } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs b/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs index 56c7c513..79774753 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs @@ -403,7 +403,7 @@ namespace Tnb.WarehouseMgr { _ = await _db.Deleteable(elevatorQueueItem).ExecuteCommandAsync(); } - + await _wareHouseService.SsxControl(disTask, "LOAD"); } else if (input.action == "UNLOAD") { @@ -414,7 +414,7 @@ namespace Tnb.WarehouseMgr }; Logger.Information($"taskCompleUpInput json parameter:{JsonConvert.SerializeObject(taskCompleUpInput)}"); await _wareHouseService.TaskComplate(taskCompleUpInput); - + await _wareHouseService.SsxControl(disTask, "UNLOAD"); } } catch (Exception ex) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index 3a51e087..3ac1d3a0 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -57,6 +57,7 @@ namespace Tnb.WarehouseMgr private static Dictionary locMap = new Dictionary(StringComparer.OrdinalIgnoreCase); private readonly IConfiguration _configuration; private readonly RedisData _redisData; + public Func AddUnExecuteTask { get; set; } @@ -270,6 +271,80 @@ namespace Tnb.WarehouseMgr throw new AppFriendlyException("点位" + input.targetName + "不可放", 500); } + /// + /// 判断CTU是否可以取货 + /// + /// + [HttpPost] + [AllowAnonymous] + public async Task CheckGet() + { + try + { + Dictionary getdic = new Dictionary(); + getdic.Add("SSX-021-005", new string[] { "YTCS", "AllowFullOut_CS05", "LiftCode" }); + + var strs = getdic.First().Value; + string data = await _redisData.GetHash(strs[0], strs[1]); + JObject? res = JsonConvert.DeserializeObject(data); + bool result = res != null && res["Value"] != null ? res.Value("Value") : false; + if (result) + { + string codedata = _redisData.GetHash(strs[0], strs[2]).Result; + JObject? coderes = JsonConvert.DeserializeObject(codedata); + string coderesult = coderes != null && coderes["Value"] != null ? coderes.Value("Value")! : ""; + return new { flag =true, code = coderesult }; + } + else + { + return new { flag = false, code = "" }; + } + } + catch (Exception ex) + { + throw new AppFriendlyException($"接口请求异常", 500); + } + } + public async Task SsxControl(WmsDistaskH disTask, string action) + { + Dictionary putdic = new Dictionary(); + Dictionary getdic = new Dictionary(); + getdic.Add("SSX-021-005", new string[] { "YTCS", "AllowFullOut_CS05", "true" }); + putdic.Add("SSX-021-006", new string[] { "YTCS", "", "" }); + if (action == "LOAD")//取货 + { + if (getdic.Keys.Contains(disTask.startlocation_code)) + { + var strarr = getdic.Where(p => p.Key == disTask.startlocation_code).First().Value; + Dictionary dicCommand = new(StringComparer.OrdinalIgnoreCase) + { + ["DevName"] = strarr[0], + ["token"] = _eleCtlCfg.token, + ["TagName"] = strarr[1], + ["Value"] = strarr[2], + }; + await HttpClientHelper.GetAsync(_eleCtlCfg.WriteTagUrl, pars: dicCommand); + } + } + else if (action == "UNLOAD")//放货 + { + if (putdic.Keys.Contains(disTask.endlocation_code)) + { + var strarr = putdic.Where(p => p.Key == disTask.endlocation_code).First().Value; + Dictionary dicCommand = new(StringComparer.OrdinalIgnoreCase) + { + ["DevName"] = strarr[0], + ["token"] = _eleCtlCfg.token, + ["TagName"] = strarr[1], + ["Value"] = strarr[2], + }; + await HttpClientHelper.GetAsync(_eleCtlCfg.WriteTagUrl, pars: dicCommand); + } + } + + } + + /// /// 生成任务执行 /// @@ -1058,6 +1133,8 @@ namespace Tnb.WarehouseMgr } await _db.Ado.CommitTranAsync(); + + } catch (Exception ex) { diff --git a/apihost/Tnb.API.Entry/Configurations/ConnectionStrings.json b/apihost/Tnb.API.Entry/Configurations/ConnectionStrings.json index 847490c1..04943f3c 100644 --- a/apihost/Tnb.API.Entry/Configurations/ConnectionStrings.json +++ b/apihost/Tnb.API.Entry/Configurations/ConnectionStrings.json @@ -2,14 +2,14 @@ "ConnectionStrings": { "ConfigId": "default", "DBType": "PostgreSQL", //MySql;SqlServer;Oracle;PostgreSQL;Dm;Kdbndp;Sqlite; - "Host": "localhost", + "Host": "192.168.11.109", "Port": "5432", //"DBName": "tianyi_db", //"UserName": "postgres", //"Password": "pass@word123", - "DBName": "tianyi_bas", - "UserName": "totong", - "Password": "IPANyxGSKxIXg0dBM", + "DBName": "tianyi", + "UserName": "postgres", + "Password": "pass@word123", //SqlServer //"DefaultConnection": "server={0},{1};database={2};uid={3};pwd={4};MultipleActiveResultSets=true" //Kdbndp diff --git a/apihost/Tnb.API.Entry/Startup.cs b/apihost/Tnb.API.Entry/Startup.cs index bc4afbe2..707d96b2 100644 --- a/apihost/Tnb.API.Entry/Startup.cs +++ b/apihost/Tnb.API.Entry/Startup.cs @@ -62,7 +62,7 @@ public class Startup : AppStartup services.AddSingleton(sp => new TimedTaskBackgroundService()); //var bgSvc = App.GetRequiredService(); //bgSvc.StartAsync(CancellationToken.None); - //services.AddHostedService(); + services.AddHostedService(); }