diff --git a/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs b/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs index 854a02c3..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; @@ -121,8 +125,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 @@ -137,15 +140,18 @@ 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(); - 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(); + 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) + { + 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) @@ -157,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) + { + + } } + + + } @@ -186,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(300)); - // 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.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.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..4e75ac29 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; } @@ -247,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-011-006", new string[] { "YTCS", "AllowEmptyIn_CS06" }); + var strs = new string[] { }; if (!putdic.ContainsKey(input.targetName)) @@ -270,6 +269,63 @@ namespace Tnb.WarehouseMgr throw new AppFriendlyException("点位" + input.targetName + "不可放", 500); } + /// + /// 判断CTU是否可以取货 + /// + /// + + [HttpGet] + [AllowAnonymous] + public async Task Test() + { + var a = _db.Queryable().Where(p => p.id == "31900194166806").First(); + await SsxControl(a, "UNLOAD"); + } + public async Task SsxControl(WmsDistaskH disTask, string action) + { + Dictionary putdic = new Dictionary(); + 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)) + { + 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], + }; + Logger.Information($"SsxControlLOAD:{dicCommand}"); + var str= await HttpClientHelper.GetAsync(_eleCtlCfg.WriteTagUrl, new Dictionary(), dicCommand); + Logger.Information($"SsxControlLOAD:{str}"); + } + } + 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], + }; + Logger.Information($"SsxControlUNLOAD:{dicCommand}"); + var str = await HttpClientHelper.GetAsync(_eleCtlCfg.WriteTagUrl, new Dictionary(), dicCommand); + Logger.Information($"SsxControlUNLOAD:{str}"); + } + } + + } + + /// /// 生成任务执行 /// @@ -1058,6 +1114,8 @@ namespace Tnb.WarehouseMgr } await _db.Ado.CommitTranAsync(); + + } catch (Exception ex) { 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/WmsKittingInStkService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsKittingInStkService.cs index 6b2cf63a..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) @@ -93,10 +97,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) @@ -132,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(); @@ -211,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 }); } 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/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/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) 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 => { 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..dd4c9ae1 100644 --- a/apihost/Tnb.API.Entry/Startup.cs +++ b/apihost/Tnb.API.Entry/Startup.cs @@ -57,12 +57,13 @@ public class Startup : AppStartup services.AddOverideVisualDev(); //定时任务 + SnowflakeIdHelper.InitYitIdWorker(); services.AddHostedService(); services.AddSingleton(sp => new TimedTaskBackgroundService()); //var bgSvc = App.GetRequiredService(); //bgSvc.StartAsync(CancellationToken.None); - //services.AddHostedService(); + // services.AddHostedService(); } @@ -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)