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/8] 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(); } From 4d050d837874ea0216ca78c2bafa9722dc62cc8e Mon Sep 17 00:00:00 2001 From: qianjiawei <1184704771@qq.com> Date: Mon, 29 Jan 2024 17:35:45 +0800 Subject: [PATCH 2/8] 1 --- WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index 3ac1d3a0..7d247735 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -248,11 +248,9 @@ namespace Tnb.WarehouseMgr public async Task CheckPut(CheckPutInput input) { Dictionary putdic = new Dictionary(); - putdic.Add("SSX-021-005", new string[] { "CS05", "ConveyorAllowPutEmptyBox" }); - putdic.Add("SSX-021-006", new string[] { "CS06", "ConveyorAllowPutEmptyBox" }); - // Dictionary getdic = new Dictionary(); - // getdic.Add("SSX-021-005", new string[] { "CS05", "FullBoxAllowGet" }); - // getdic.Add("SSX-021-006", new string[] { "CS06", "FullBoxAllowGet" }); + + putdic.Add("SSX-021-006", new string[] { "YTCS", "AllowEmptyIn_CS06" }); + var strs = new string[] { }; if (!putdic.ContainsKey(input.targetName)) @@ -309,8 +307,8 @@ namespace Tnb.WarehouseMgr { 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", "", "" }); + getdic.Add("SSX-021-005", new string[] { "YTCS", "FullOut_CS05Done", "true" }); + putdic.Add("SSX-021-006", new string[] { "YTCS", "EmptyIn_CS06Done", "true" }); if (action == "LOAD")//取货 { if (getdic.Keys.Contains(disTask.startlocation_code)) From bee26d9a92b857ad7f43315b337c421ee8132ac9 Mon Sep 17 00:00:00 2001 From: qianjiawei <1184704771@qq.com> Date: Tue, 30 Jan 2024 16:55:51 +0800 Subject: [PATCH 3/8] bug --- ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs | 2 +- .../Entity/WmsEmptyOutstockD.cs | 2 +- WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs | 10 ++++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs b/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs index 93da9279..1bffebbf 100644 --- a/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs +++ b/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs @@ -136,7 +136,7 @@ namespace Tnb.ProductionMgr string codedata = _redisData.GetHash(strs[0], strs[2]).Result; 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(); + var DistaskH = _repository.AsSugarClient().Queryable().Where(p => p.carry_code == coderesult && p.status == WmsWareHouseConst.TASK_BILL_STATUS_YXD_ID).First(); if (DistaskH != null) { dynamic reqBody = new ExpandoObject(); diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsEmptyOutstockD.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsEmptyOutstockD.cs index 16246d7b..74b94791 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsEmptyOutstockD.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsEmptyOutstockD.cs @@ -17,7 +17,7 @@ public partial class WmsEmptyOutstockD : BaseEntity /// /// 行号 /// - public int? no { get; set; } + public string? no { get; set; } /// /// 所属组织ID diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index 7d247735..56d9785e 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -249,7 +249,7 @@ namespace Tnb.WarehouseMgr { Dictionary putdic = new Dictionary(); - putdic.Add("SSX-021-006", new string[] { "YTCS", "AllowEmptyIn_CS06" }); + putdic.Add("SSX-011-006", new string[] { "YTCS", "AllowEmptyIn_CS06" }); var strs = new string[] { }; @@ -308,7 +308,7 @@ namespace Tnb.WarehouseMgr Dictionary putdic = new Dictionary(); Dictionary getdic = new Dictionary(); getdic.Add("SSX-021-005", new string[] { "YTCS", "FullOut_CS05Done", "true" }); - putdic.Add("SSX-021-006", new string[] { "YTCS", "EmptyIn_CS06Done", "true" }); + putdic.Add("SSX-011-006", new string[] { "YTCS", "EmptyIn_CS06Done", "true" }); if (action == "LOAD")//取货 { if (getdic.Keys.Contains(disTask.startlocation_code)) @@ -321,7 +321,8 @@ namespace Tnb.WarehouseMgr ["TagName"] = strarr[1], ["Value"] = strarr[2], }; - await HttpClientHelper.GetAsync(_eleCtlCfg.WriteTagUrl, pars: dicCommand); + var str= await HttpClientHelper.GetAsync(_eleCtlCfg.WriteTagUrl, pars: dicCommand); + Logger.Information($"SsxControlLOAD:{str}"); } } else if (action == "UNLOAD")//放货 @@ -336,7 +337,8 @@ namespace Tnb.WarehouseMgr ["TagName"] = strarr[1], ["Value"] = strarr[2], }; - await HttpClientHelper.GetAsync(_eleCtlCfg.WriteTagUrl, pars: dicCommand); + var str = await HttpClientHelper.GetAsync(_eleCtlCfg.WriteTagUrl, pars: dicCommand); + Logger.Information($"SsxControlUNLOAD:{str}"); } } From 02dafc3c745c7a49555d81738a5389285652cdf8 Mon Sep 17 00:00:00 2001 From: qianjiawei <1184704771@qq.com> Date: Fri, 2 Feb 2024 10:29:12 +0800 Subject: [PATCH 4/8] bug --- .../Tnb.ProductionMgr/RedisBackGround.cs | 85 ++++++++++++++----- .../Tnb.WarehouseMgr/WareHouseService.cs | 39 +++------ apihost/Tnb.API.Entry/Startup.cs | 2 +- 3 files changed, 76 insertions(+), 50 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs b/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs index 1bffebbf..b6497f72 100644 --- a/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs +++ b/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs @@ -7,11 +7,13 @@ using JNPF.Common.Cache; using JNPF.Common.Dtos.VisualDev; using JNPF.FriendlyException; using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; using NetTaste; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Qiniu.Util; using SqlSugar; +using Tnb.Common.Extension; using Tnb.Common.Redis; using Tnb.Common.Utils; using Tnb.ProductionMgr.Entities; @@ -19,6 +21,7 @@ using Tnb.ProductionMgr.Entities.Dto; using Tnb.ProductionMgr.Entities.Enums; using Tnb.ProductionMgr.Interfaces; using Tnb.WarehouseMgr.Entities; +using Tnb.WarehouseMgr.Entities.Configs; using Tnb.WarehouseMgr.Entities.Consts; using Tnb.WarehouseMgr.Interfaces; @@ -34,6 +37,7 @@ namespace Tnb.ProductionMgr private readonly IPrdInstockService _prdInstockService; private readonly ISqlSugarRepository _repository; private readonly IWmsPDAScanInStockService _wmsPDAScanInStock; + private readonly ElevatorControlConfiguration _eleCtlCfg = App.Configuration.Build(); public RedisBackGround(RedisData redisData, IPrdInstockService prdInstockService, ISqlSugarRepository repository, IWmsPDAScanInStockService wmsPDAScanInStock) { _redisData = redisData; @@ -136,6 +140,7 @@ namespace Tnb.ProductionMgr string codedata = _redisData.GetHash(strs[0], strs[2]).Result; JObject? coderes = JsonConvert.DeserializeObject(codedata); string coderesult = coderes != null && coderes["Value"] != null ? coderes.Value("Value")! : ""; + coderesult = coderesult.Replace("\r", ""); var DistaskH = _repository.AsSugarClient().Queryable().Where(p => p.carry_code == coderesult && p.status == WmsWareHouseConst.TASK_BILL_STATUS_YXD_ID).First(); if (DistaskH != null) { @@ -158,27 +163,66 @@ namespace Tnb.ProductionMgr //扫码入库 private void ScanInStock(object state) { - var carry_code = "TestLX0001";//从数采读取载具 - WmsCarryH? carry = _repository.AsSugarClient().Queryable().Single(it => it.carry_code == carry_code); - if (carry != null) + Dictionary getdic = new Dictionary(); + getdic.Add("BGWRKYCL02", new string[] { "CP8", "AllowGetFullBox1", "code1", "PutDoneEmptyBox","false" }); + foreach (var key in getdic.Keys) { - var WmsCarryCode = _repository.AsSugarClient().Queryable().Single(it => it.carry_id == carry.id); + 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; + JObject? res = JsonConvert.DeserializeObject(data); + bool result = res != null && res["Value"] != null ? res.Value("Value") : false; + if (result) + { + Dictionary dicCommand = new(StringComparer.OrdinalIgnoreCase) + { + ["DevName"] = strs[0], + ["token"] = _eleCtlCfg.token, + ["TagName"] = strs[3], + ["Value"] = strs[4], + }; + HttpClientHelper.GetAsync(_eleCtlCfg.WriteTagUrl, new Dictionary(), dicCommand).Wait(); - VisualDevModelDataCrInput input = new VisualDevModelDataCrInput(); - input.data = new Dictionary(); - input.data.Add("barcode", carry_code); - input.data.Add("codeqty", WmsCarryCode.codeqty);//条码数量 - input.data.Add("material_code", WmsCarryCode.material_code); - input.data.Add("extras", carry.location_code!);//location_code - input.data.Add("warehouse_id", WmsCarryCode.warehouse_id!); - 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); + + string codedata = _redisData.GetHash(strs[0], strs[2]).Result; + 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); + if (carry != null) + { + if (_repository.AsSugarClient().Queryable().Where(p => p.carry_id == carry.id && (p.status == WmsWareHouseConst.TASK_BILL_STATUS_DZX_ID || p.status == WmsWareHouseConst.TASK_BILL_STATUS_YXD_ID || p.status == WmsWareHouseConst.TASK_BILL_STATUS_RUNING_ID)).Any()) + continue; + var WmsCarryCode = _repository.AsSugarClient().Queryable().Single(it => it.carry_id == carry.id); + if (WmsCarryCode != null) + { + 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); + } + } + } + } + catch (Exception) + { + + } } + + + } @@ -187,12 +231,13 @@ namespace Tnb.ProductionMgr { Readtimer?.Dispose(); CheckGettimer?.Dispose(); + Scantimer?.Dispose(); } public Task StartAsync(CancellationToken cancellationToken) { // Readtimer = new Timer(GetRedisData, 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)); + CheckGettimer = new Timer(CheckGet, null, TimeSpan.Zero, TimeSpan.FromSeconds(10)); + Scantimer = new Timer(ScanInStock, null, TimeSpan.Zero, TimeSpan.FromSeconds(20)); return Task.CompletedTask; } public Task StopAsync(CancellationToken cancellationToken) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index 56d9785e..4e75ac29 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -273,35 +273,13 @@ namespace Tnb.WarehouseMgr /// 判断CTU是否可以取货 /// /// - [HttpPost] + + [HttpGet] [AllowAnonymous] - public async Task CheckGet() + public async Task Test() { - 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); - } + var a = _db.Queryable().Where(p => p.id == "31900194166806").First(); + await SsxControl(a, "UNLOAD"); } public async Task SsxControl(WmsDistaskH disTask, string action) { @@ -309,6 +287,7 @@ namespace Tnb.WarehouseMgr Dictionary getdic = new Dictionary(); getdic.Add("SSX-021-005", new string[] { "YTCS", "FullOut_CS05Done", "true" }); putdic.Add("SSX-011-006", new string[] { "YTCS", "EmptyIn_CS06Done", "true" }); + putdic.Add("YCLCKBGW", new string[] { "CP8", "PutDoneEmptyBox", "true" }); if (action == "LOAD")//取货 { if (getdic.Keys.Contains(disTask.startlocation_code)) @@ -321,7 +300,8 @@ namespace Tnb.WarehouseMgr ["TagName"] = strarr[1], ["Value"] = strarr[2], }; - var str= await HttpClientHelper.GetAsync(_eleCtlCfg.WriteTagUrl, pars: dicCommand); + Logger.Information($"SsxControlLOAD:{dicCommand}"); + var str= await HttpClientHelper.GetAsync(_eleCtlCfg.WriteTagUrl, new Dictionary(), dicCommand); Logger.Information($"SsxControlLOAD:{str}"); } } @@ -337,7 +317,8 @@ namespace Tnb.WarehouseMgr ["TagName"] = strarr[1], ["Value"] = strarr[2], }; - var str = await HttpClientHelper.GetAsync(_eleCtlCfg.WriteTagUrl, pars: dicCommand); + Logger.Information($"SsxControlUNLOAD:{dicCommand}"); + var str = await HttpClientHelper.GetAsync(_eleCtlCfg.WriteTagUrl, new Dictionary(), dicCommand); Logger.Information($"SsxControlUNLOAD:{str}"); } } diff --git a/apihost/Tnb.API.Entry/Startup.cs b/apihost/Tnb.API.Entry/Startup.cs index 707d96b2..d8ac9877 100644 --- a/apihost/Tnb.API.Entry/Startup.cs +++ b/apihost/Tnb.API.Entry/Startup.cs @@ -57,6 +57,7 @@ public class Startup : AppStartup services.AddOverideVisualDev(); //定时任务 + SnowflakeIdHelper.InitYitIdWorker(); services.AddHostedService(); services.AddSingleton(sp => new TimedTaskBackgroundService()); @@ -112,7 +113,6 @@ public class Startup : AppStartup endpoints.MapControllerRoute(name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); }); - SnowflakeIdHelper.InitYitIdWorker(); bool isStartTimeJob = App.GetConfig("IsStartTimeJob"); if (isStartTimeJob) From 77816a998916a03d43f35068b95e71d1504e4a93 Mon Sep 17 00:00:00 2001 From: qianjiawei <1184704771@qq.com> Date: Sun, 4 Feb 2024 17:35:13 +0800 Subject: [PATCH 5/8] bug --- .../WmsPDAOutBaleServiceService.cs | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAOutBaleServiceService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAOutBaleServiceService.cs index c0bac3be..f274f92c 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAOutBaleServiceService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAOutBaleServiceService.cs @@ -60,11 +60,12 @@ namespace Tnb.WarehouseMgr try { await _db.Ado.BeginTranAsync(); - - VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSOUTBALEPDA_ID, true); - await _runService.Create(templateEntity, input); //出库取起点 WmsCarryH carry = await _db.Queryable().FirstAsync(it => it.id == input.data[nameof(WmsOutbale.carry_id)].ToString()); + if (carry == null) + { + throw new AppFriendlyException("请选择载具", 500); + } WmsPointH? sPoint = null; WmsPointH? ePoint = null; if (input.data.ContainsKey(nameof(WmsPointH.location_id))) @@ -75,19 +76,26 @@ namespace Tnb.WarehouseMgr { sPoint = await _db.Queryable().FirstAsync(it => it.location_id == carry.location_id); } - + if (sPoint != null && ePoint != null) { - List points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); - //根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序) - if (points?.Count > 0) + var points=new List(); + if (sPoint.area_code != ePoint.area_code) { - + points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); if (points.Count <= 2) { throw new AppFriendlyException("该路径不存在", 500); } - + } + else + { + points.Add(sPoint); + points.Add(ePoint); + } + //根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序) + if (points?.Count > 0) + { List preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it => { WmsPointH? sPoint = it.FirstOrDefault(); @@ -150,7 +158,8 @@ namespace Tnb.WarehouseMgr } } } - + VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSOUTBALEPDA_ID, true); + await _runService.Create(templateEntity, input); await _db.Ado.CommitTranAsync(); } catch (Exception) From 130e69669919c6a6926499ebc6b8f72142f37a9b Mon Sep 17 00:00:00 2001 From: qianjiawei <1184704771@qq.com> Date: Mon, 5 Feb 2024 10:33:52 +0800 Subject: [PATCH 6/8] bug --- WarehouseMgr/Tnb.WarehouseMgr/WmsCarryService.cs | 9 +++++++-- .../Tnb.WarehouseMgr/WmsPDAInbaleService.cs | 16 ++++++++++------ apihost/Tnb.API.Entry/Startup.cs | 2 +- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryService.cs index 39d5ad2d..d7e250f7 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryService.cs @@ -71,8 +71,13 @@ namespace Tnb.WarehouseMgr carryOutPut.carryMats = await _db.Queryable().Where(it => it.carry_id == carryId).ToListAsync(); return carryOutPut; } - - + [HttpGet] + public async Task GetCarryInfoByCode([FromRoute] string carrycode) + { + var carryOutPut = await _db.Queryable().Where(it => it.carry_code == carrycode).FirstAsync(); + + return carryOutPut; + } /// /// 更换载具 /// diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInbaleService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInbaleService.cs index 9f5ff757..0579a3fd 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInbaleService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInbaleService.cs @@ -88,16 +88,22 @@ namespace Tnb.WarehouseMgr if (sPoint != null && ePoint != null) { - List points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); - //根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序) - if (points?.Count > 0) + List points = new List(); + if (sPoint.area_code != ePoint.area_code) { + points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); if (points.Count <= 2) { throw new AppFriendlyException("该路径不存在", 500); } + } + else + { + points.Add(sPoint); + points.Add(ePoint); + } - List preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it => + List preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it => { WmsPointH? sPoint = it.FirstOrDefault(); WmsPointH? ePoint = it.LastOrDefault(); @@ -167,8 +173,6 @@ namespace Tnb.WarehouseMgr //((int)EnumCarryStatus.寄存).ToString() } } - } - await _db.Ado.CommitTranAsync(); } catch (Exception) diff --git a/apihost/Tnb.API.Entry/Startup.cs b/apihost/Tnb.API.Entry/Startup.cs index d8ac9877..dd4c9ae1 100644 --- a/apihost/Tnb.API.Entry/Startup.cs +++ b/apihost/Tnb.API.Entry/Startup.cs @@ -63,7 +63,7 @@ public class Startup : AppStartup services.AddSingleton(sp => new TimedTaskBackgroundService()); //var bgSvc = App.GetRequiredService(); //bgSvc.StartAsync(CancellationToken.None); - services.AddHostedService(); + // services.AddHostedService(); } From af1c94170bf71fbb5364be0cda776ea05342020f Mon Sep 17 00:00:00 2001 From: qianjiawei <1184704771@qq.com> Date: Mon, 5 Feb 2024 11:30:58 +0800 Subject: [PATCH 7/8] bug --- .../Tnb.WarehouseMgr/WmsKittingInStkService.cs | 15 ++++++++++++--- .../Tnb.WarehouseMgr/WmsPDADeliveryService.cs | 3 ++- .../Tnb.WarehouseMgr/WmsPDAInStockService.cs | 16 ++++++++++++---- .../Tnb.WarehouseMgr/WmsPDATransferService.cs | 16 +++++++++++++--- 4 files changed, 39 insertions(+), 11 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsKittingInStkService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsKittingInStkService.cs index 6b2cf63a..a5d0e856 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsKittingInStkService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsKittingInStkService.cs @@ -93,10 +93,19 @@ namespace Tnb.WarehouseMgr if (sPoint != null && ePoint != null) { - List points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); - if (points.Count <= 2) + List points = new List(); + if (sPoint.area_code != ePoint.area_code) { - throw new AppFriendlyException("该路径不存在", 500); + points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); + if (points.Count <= 2) + { + throw new AppFriendlyException("该路径不存在", 500); + } + } + else + { + points.Add(sPoint); + points.Add(ePoint); } //根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序) if (points?.Count > 0) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDADeliveryService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDADeliveryService.cs index 64acaea5..044d02a9 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDADeliveryService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDADeliveryService.cs @@ -198,7 +198,8 @@ namespace Tnb.WarehouseMgr } catch (Exception) { - return await Task.FromResult(false); + await _db.Ado.RollbackTranAsync(); + throw; } finally { diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs index cc9bd7a3..a34f765c 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs @@ -98,11 +98,19 @@ namespace Tnb.WarehouseMgr if (sPoint != null && ePoint != null) { - List? points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); - //根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序) - if (points?.Count <= 2) + List points = new List(); + if (sPoint.area_code != ePoint.area_code) { - throw new AppFriendlyException("该路径不存在", 500); + points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); + if (points.Count <= 2) + { + throw new AppFriendlyException("该路径不存在", 500); + } + } + else + { + points.Add(sPoint); + points.Add(ePoint); } if (points?.Count > 0) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDATransferService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDATransferService.cs index 93af33c6..ab7bd955 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDATransferService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDATransferService.cs @@ -79,14 +79,24 @@ namespace Tnb.WarehouseMgr if (sPoint != null && ePoint != null) { - List points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); - //根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序) - if (points?.Count > 0) + List points = new List(); + if (sPoint.area_code != ePoint.area_code) { + points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); if (points.Count <= 2) { throw new AppFriendlyException("该路径不存在", 500); } + } + else + { + points.Add(sPoint); + points.Add(ePoint); + } + //根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序) + if (points?.Count > 0) + { + List preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it => { From a5c60fb131af52cdba345891b1ab9ea4b8912f4b Mon Sep 17 00:00:00 2001 From: qianjiawei <1184704771@qq.com> Date: Mon, 5 Feb 2024 16:34:18 +0800 Subject: [PATCH 8/8] bug --- .../WmsKittingInStkService.cs | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsKittingInStkService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsKittingInStkService.cs index a5d0e856..bf2f2155 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsKittingInStkService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsKittingInStkService.cs @@ -65,19 +65,23 @@ namespace Tnb.WarehouseMgr try { await _db.Ado.BeginTranAsync(); - + var Location = await _db.Queryable().FirstAsync(it => it.location_code == input.data["location_code"].ToString()); + input.data.Add("warehouse_id", Location.wh_id); + input.data.Add("location_id", Location.id); + input.data.Add("status", "25065138925589"); //入库取终点 //出库起点 InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = input.data[nameof(InStockStrategyQuery.warehouse_id)].ToString()!, Size = 1 }; List endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput); WmsPointH? sPoint = null; WmsPointH? ePoint = null; - if (input.data.ContainsKey(nameof(WmsPointH.location_id))) + if (input.data.ContainsKey("location_code")) { - sPoint = await _db.Queryable().FirstAsync(it => it.location_id == input.data[nameof(WmsPointH.location_id)].ToString()); + sPoint = await _db.Queryable().FirstAsync(it => it.location_code == input.data["location_code"].ToString()); } if (endLocations?.Count > 0) { - WmsCarryH carry = await _db.Queryable().SingleAsync(it => it.id == input.data[nameof(WmsCarryD.carry_id)].ToString()); + WmsCarryH carry = await _db.Queryable().SingleAsync(it => it.carry_code == input.data["carry_code"].ToString()); + input.data.Add("carry_id", carry.id); BasLocation loc = await _db.Queryable().SingleAsync(it => it.id == endLocations[0].id); bool isMatch = await IsCarryAndLocationMatchByCarryStd(carry, loc); if (!isMatch) @@ -141,8 +145,8 @@ namespace Tnb.WarehouseMgr preTask.require_code = input.data[nameof(preTask.bill_code)]?.ToString()!; preTask.create_id = _userManager.UserId; preTask.create_time = DateTime.Now; - preTask.source_id = input.data[nameof(WmsKittingInstock.source_id)].ToString(); - preTask.source_code = input.data[nameof(WmsKittingInstock.source_code)].ToString(); + preTask.source_id = ""; + preTask.source_code = ""; return preTask; }).ToList(); List carryCodes = new(); @@ -220,8 +224,8 @@ namespace Tnb.WarehouseMgr location_id = preTaskUpInput.CarryStartLocationId, location_code = preTaskUpInput.CarryStartLocationCode, carry_status = ((int)EnumCarryStatus.齐套).ToString(), - collocation_scheme_id = input.data[nameof(WmsKittingInstock.collocation_scheme_id)].ToString(), - collocation_scheme_code = input.data[nameof(WmsKittingInstock.collocation_scheme_code)].ToString() + // collocation_scheme_id = input.data[nameof(WmsKittingInstock.collocation_scheme_id)].ToString(), + // collocation_scheme_code = input.data[nameof(WmsKittingInstock.collocation_scheme_code)].ToString() }, it => new BasLocation { is_lock = 1 }); }