From db1d71e270bfe8776b08c03e6673e86478496b37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8C=83?= <15095123350@163.com> Date: Sat, 27 Jul 2024 09:14:15 +0800 Subject: [PATCH] 20240727 --- src/Khd.Core.Wcs/Wcs/CreateTaskByRecord.cs | 45 ++++++++++++---------- src/Khd.Core.Wcs/Wcs/FiveFloorPoint.cs | 14 ++++--- src/Khd.Core.Wcs/Wcs/SecondFloorLine.cs | 16 +++++--- src/Khd.Core.Wcs/Wcs/ThirdFloorPoint.cs | 16 +++++--- 4 files changed, 54 insertions(+), 37 deletions(-) diff --git a/src/Khd.Core.Wcs/Wcs/CreateTaskByRecord.cs b/src/Khd.Core.Wcs/Wcs/CreateTaskByRecord.cs index 54e064d..a2b5bd6 100644 --- a/src/Khd.Core.Wcs/Wcs/CreateTaskByRecord.cs +++ b/src/Khd.Core.Wcs/Wcs/CreateTaskByRecord.cs @@ -347,6 +347,7 @@ namespace Khd.Core.Wcs.Wcs { using var scope = _host.Services.CreateScope(); using var dbContext = scope.ServiceProvider.GetRequiredService(); + List cannotIn = new List(); while (true) { try @@ -399,9 +400,9 @@ namespace Khd.Core.Wcs.Wcs select new { a, b };//在上面的基础上获取对应托盘的外侧库位的空库位信息 WmsBaseLocation? wmsBaseLocation = null; - wmsBaseLocation ??= outBill.FirstOrDefault()?.b;//先找相同物料的外侧库位 - wmsBaseLocation ??= wmsBaseLocations.Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault(t => t.locDeep == 1);//找不到再找深库位 - wmsBaseLocation ??= wmsBaseLocations.Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault();//找不到再找任意库位 + wmsBaseLocation ??= outBill.Where(t=> !cannotIn.Contains(t.b.locationCode)).FirstOrDefault()?.b;//先找相同物料的外侧库位 + wmsBaseLocation ??= wmsBaseLocations.Where(t => !cannotIn.Contains(t.locationCode)).Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault(t => t.locDeep == 1);//找不到再找深库位 + wmsBaseLocation ??= wmsBaseLocations.Where(t => !cannotIn.Contains(t.locationCode)).Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault();//找不到再找任意库位 //深浅库位问题?库位入库优先级等 var AgvEquip = StaticData.BaseEquip.First(t => t.objid == 28);//5楼叉车 @@ -414,8 +415,9 @@ namespace Khd.Core.Wcs.Wcs .Where(t => t.locColumn == wmsBaseLocation.locColumn).Any(); if (!hasLocation) { - Console.WriteLine(DateTime.Now + $":目标库位{wmsBaseLocation.locationCode}的浅库位库位状态异常,无法入库"); - _logger.Info($"目标库位{wmsBaseLocation.locationCode}的浅库位库位状态异常,无法入库"); + cannotIn.Add(wmsBaseLocation.locationCode); + Console.WriteLine(DateTime.Now + $":目标库位{cannotIn.Join(",")}的浅库位库位状态异常,无法入库"); + _logger.Info($"目标库位{cannotIn.Join(",")}的浅库位库位状态异常,无法入库"); continue; } } @@ -466,6 +468,7 @@ namespace Khd.Core.Wcs.Wcs WcsTaskLog wcsTaskLog = CoreMapper.Map(newTask); dbContext.Add(wcsTaskLog); dbContext.SaveChanges(); + cannotIn.Clear(); } } } @@ -1447,22 +1450,6 @@ namespace Khd.Core.Wcs.Wcs MesBasePalletInfo? mesBasePalletInfo = dbContext.MesBasePalletInfo.FirstOrDefault(t => t.palletInfoCode == location.containerCode); if (mesBasePalletInfo != null) { - WmsProductOutstockDetail detail = new() - { - productId = item.productId, - productOutstockId = item.productOutstockId, - locationCode = location.locationCode, - executeStatus = "1", - beginTime = DateTime.Now, - warehouseId = item.warehouseId, - erpAmount = 0, - confirmAmount = 0, - outstockAmount = 1, - planAmount = 1, - productBatch = item.productBatch, - productOutstockDetailId = StaticData.SnowId.NextId(), - productBarcode = mesBasePalletInfo.materialBarcode, - }; if (location.locDeep == 1)//如果是深库位 { int? row = 0; @@ -1588,6 +1575,22 @@ namespace Khd.Core.Wcs.Wcs useFlag = 1, qty = 1 }; + WmsProductOutstockDetail detail = new() + { + productId = item.productId, + productOutstockId = item.productOutstockId, + locationCode = location.locationCode, + executeStatus = "1", + beginTime = DateTime.Now, + warehouseId = item.warehouseId, + erpAmount = 0, + confirmAmount = 0, + outstockAmount = 1, + planAmount = 1, + productBatch = item.productBatch, + productOutstockDetailId = StaticData.SnowId.NextId(), + productBarcode = mesBasePalletInfo.materialBarcode, + }; location.locationStatus = "6"; location.updateBy = "WCS"; location.updateTime = DateTime.Now; diff --git a/src/Khd.Core.Wcs/Wcs/FiveFloorPoint.cs b/src/Khd.Core.Wcs/Wcs/FiveFloorPoint.cs index 3a8b8cd..a63f18d 100644 --- a/src/Khd.Core.Wcs/Wcs/FiveFloorPoint.cs +++ b/src/Khd.Core.Wcs/Wcs/FiveFloorPoint.cs @@ -4,6 +4,7 @@ using Khd.Core.Library; using Khd.Core.Library.Mapper; using Khd.Core.Plc.S7; using Khd.Core.Wcs.Global; +using Masuit.Tools; using Masuit.Tools.Logging; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; @@ -50,6 +51,7 @@ namespace Khd.Core.Wcs.Wcs List ITypes = new() { 1, 3, 5, 7 }; using var scope = _host.Services.CreateScope(); using var dbContext = scope.ServiceProvider.GetRequiredService(); + List canNotIn = new(); while (true) { try @@ -114,9 +116,9 @@ namespace Khd.Core.Wcs.Wcs select new { a,b };//在上面的基础上获取对应托盘的外侧库位的空库位信息 WmsBaseLocation? wmsBaseLocation = null; - wmsBaseLocation ??= outBill.FirstOrDefault()?.b;//先找相同物料的外侧库位 - wmsBaseLocation ??= wmsBaseLocations.Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault(t => t.locDeep == 1);//找不到再找深库位 - wmsBaseLocation ??= wmsBaseLocations.Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault();//找不到再找任意库位 + wmsBaseLocation ??= outBill.Where(t=>!canNotIn.Contains(t.b.locationCode)).FirstOrDefault()?.b;//先找相同物料的外侧库位 + wmsBaseLocation ??= wmsBaseLocations.Where(t => !canNotIn.Contains(t.locationCode)).Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault(t => t.locDeep == 1);//找不到再找深库位 + wmsBaseLocation ??= wmsBaseLocations.Where(t => !canNotIn.Contains(t.locationCode)).Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault();//找不到再找任意库位 //深浅库位问题?库位入库优先级等 var AgvEquip = StaticData.BaseEquip.First(t => t.objid == 28);//5楼叉车 @@ -130,8 +132,9 @@ namespace Khd.Core.Wcs.Wcs .Any(); if (!hasLocation) { - Console.WriteLine(DateTime.Now + $":目标库位{wmsBaseLocation.locationCode}的浅库位库位状态异常,无法入库"); - _logger.Info($"目标库位{wmsBaseLocation.locationCode}的浅库位库位状态异常,无法入库"); + canNotIn.Add(wmsBaseLocation.locationCode); + Console.WriteLine(DateTime.Now + $":目标库位{canNotIn.Join(",")}的浅库位库位状态异常,无法入库"); + _logger.Info($"目标库位{canNotIn.Join(",")}的浅库位库位状态异常,无法入库"); continue; } } @@ -163,6 +166,7 @@ namespace Khd.Core.Wcs.Wcs WcsTaskLog wcsTaskLog = CoreMapper.Map(newTask); dbContext.Add(wcsTaskLog); dbContext.SaveChanges(); + canNotIn.Clear(); } else { diff --git a/src/Khd.Core.Wcs/Wcs/SecondFloorLine.cs b/src/Khd.Core.Wcs/Wcs/SecondFloorLine.cs index 943dc16..67d4c0e 100644 --- a/src/Khd.Core.Wcs/Wcs/SecondFloorLine.cs +++ b/src/Khd.Core.Wcs/Wcs/SecondFloorLine.cs @@ -5,6 +5,7 @@ using Khd.Core.Library; using Khd.Core.Library.Mapper; using Khd.Core.Plc.S7; using Khd.Core.Wcs.Global; +using Masuit.Tools; using Masuit.Tools.Logging; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; @@ -49,6 +50,7 @@ namespace Khd.Core.Wcs.Wcs var agvPutPoint = StaticData.BasePlcpointList.First(t => t.id == 54); BaseEquip agvEquip = StaticData.BaseEquip.First(t => t.objid == 8); BaseEquip endEquip = StaticData.BaseEquip.First(t => t.objid == 36); + List canNotIn = new List(); while (true) { try @@ -268,9 +270,9 @@ namespace Khd.Core.Wcs.Wcs && string.IsNullOrEmpty(b.containerCode) select new { a.b };//在上面的基础上获取对应托盘的外侧库位的空库位信息 - wmsBaseLocation ??= outBill.FirstOrDefault()?.b;//先找相同物料的外侧库位 - wmsBaseLocation ??= wmsBaseLocations.Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault(t => t.locDeep == 1);//找不到再找深库位 - wmsBaseLocation ??= wmsBaseLocations.Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault();//找不到再找任意库位 + wmsBaseLocation ??= outBill.Where(t => !canNotIn.Contains(t.b.locationCode)).FirstOrDefault()?.b;//先找相同物料的外侧库位 + wmsBaseLocation ??= wmsBaseLocations.Where(t => !canNotIn.Contains(t.locationCode)).Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault(t => t.locDeep == 1);//找不到再找深库位 + wmsBaseLocation ??= wmsBaseLocations.Where(t => !canNotIn.Contains(t.locationCode)).Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault();//找不到再找任意库位 if (wmsBaseLocation != null)//如果找到库位,生成入库任务 { if (wmsBaseLocation.locDeep == 1) @@ -280,8 +282,9 @@ namespace Khd.Core.Wcs.Wcs .Where(t => t.locColumn == wmsBaseLocation.locColumn).Any(); if (!hasLocation) { - Console.WriteLine(DateTime.Now + $":目标库位{wmsBaseLocation.locationCode}的浅库位库位状态异常,无法入库"); - _logger.Info($"目标库位{wmsBaseLocation.locationCode}的浅库位库位状态异常,无法入库"); + canNotIn.Add(wmsBaseLocation.locationCode); + Console.WriteLine(DateTime.Now + $":目标库位{canNotIn.Join(",")}的浅库位库位状态异常,无法入库"); + _logger.Info($"目标库位{canNotIn.Join(",")}的浅库位库位状态异常,无法入库"); continue; } } @@ -310,6 +313,7 @@ namespace Khd.Core.Wcs.Wcs WcsTaskLog wcsTaskLog = CoreMapper.Map(wcsTask); dbContext.Add(wcsTaskLog); dbContext.SaveChanges(); + canNotIn.Clear(); Console.WriteLine(DateTime.Now + ":二楼码垛输送线生成入库托盘任务成功:" + wcsTask.objid); _logger.Info("二楼码垛输送线生成入库托盘任务成功:" + wcsTask.objid); } @@ -327,7 +331,7 @@ namespace Khd.Core.Wcs.Wcs { if (ex is PlcException) { - + } else { diff --git a/src/Khd.Core.Wcs/Wcs/ThirdFloorPoint.cs b/src/Khd.Core.Wcs/Wcs/ThirdFloorPoint.cs index 0a51109..a3d3db4 100644 --- a/src/Khd.Core.Wcs/Wcs/ThirdFloorPoint.cs +++ b/src/Khd.Core.Wcs/Wcs/ThirdFloorPoint.cs @@ -4,6 +4,7 @@ using Khd.Core.Library; using Khd.Core.Library.Mapper; using Khd.Core.Plc.S7; using Khd.Core.Wcs.Global; +using Masuit.Tools; using Masuit.Tools.Logging; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; @@ -47,6 +48,7 @@ namespace Khd.Core.Wcs.Wcs List ITypes = new List { 1, 3, 5, 7 }; using var scope = _host.Services.CreateScope(); using var dbContext = scope.ServiceProvider.GetRequiredService(); + List canNotIn= new List(); while (true) { try @@ -102,9 +104,9 @@ namespace Khd.Core.Wcs.Wcs && b.locationStatus == "1" && string.IsNullOrEmpty(b.containerCode) select new { b };//在上面的基础上获取对应托盘的外侧库位的空库位信息 - WmsBaseLocation? wmsBaseLocation = outBill.FirstOrDefault()?.b;//先找相同物料的外侧库位 - wmsBaseLocation ??= wmsBaseLocations.Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault(t => t.locDeep == 1);//找不到再找深库位 - wmsBaseLocation ??= wmsBaseLocations.Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault();//找不到再找任意库位 + WmsBaseLocation? wmsBaseLocation = outBill.Where(t=>!canNotIn.Contains(t.b.locationCode)).FirstOrDefault()?.b;//先找相同物料的外侧库位 + wmsBaseLocation ??= wmsBaseLocations.Where(t => !canNotIn.Contains(t.locationCode)).Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault(t => t.locDeep == 1);//找不到再找深库位 + wmsBaseLocation ??= wmsBaseLocations.Where(t => !canNotIn.Contains(t.locationCode)).Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault();//找不到再找任意库位 if (wmsBaseLocations.Count > 0 && wmsBaseLocation != null) { @@ -116,8 +118,9 @@ namespace Khd.Core.Wcs.Wcs .Any(); if (!hasLocation) { - Console.WriteLine(DateTime.Now + $":目标库位{wmsBaseLocation.locationCode}的浅库位库位状态异常,无法入库"); - _logger.Info($"目标库位{wmsBaseLocation.locationCode}的浅库位库位状态异常,无法入库"); + canNotIn.Add(wmsBaseLocation.locationCode); + Console.WriteLine(DateTime.Now + $":目标库位{canNotIn.Join(",")}的浅库位库位状态异常,无法入库"); + _logger.Info($"目标库位{canNotIn.Join(",")}的浅库位库位状态异常,无法入库"); continue; } } @@ -140,6 +143,9 @@ namespace Khd.Core.Wcs.Wcs WcsTaskLog wcsTaskLog = CoreMapper.Map(newTask); dbContext.Add(wcsTaskLog); dbContext.SaveChanges(); + canNotIn.Clear(); + Console.WriteLine(DateTime.Now + $":三楼接驳位调度入库任务,物料{mesBaseBarcodeInfo.materialId},托盘{rfid},库位{wmsBaseLocation.locationCode}"); + _logger.Info($"三楼接驳位调度入库任务,物料{mesBaseBarcodeInfo.materialId},托盘{rfid},库位{wmsBaseLocation.locationCode}"); } else {