From 6f8fe2fc191fb466e3141a6e915d6aa63802c269 Mon Sep 17 00:00:00 2001 From: helongyang <647556386@qq.com> Date: 星期日, 22 六月 2025 11:43:35 +0800 Subject: [PATCH] 更新优化 --- 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Inbound.cs | 164 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 147 insertions(+), 17 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Inbound.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Inbound.cs" index deb5750..2a0977a 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Inbound.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Inbound.cs" @@ -1,4 +1,6 @@ -锘縰sing OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup; +锘縰sing Newtonsoft.Json; +using OfficeOpenXml.FormulaParsing.Excel.Functions.Math; +using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup; using System; using System.Collections; using System.Collections.Generic; @@ -9,12 +11,14 @@ using WIDESEA_Common.CommonEnum; using WIDESEA_Common.LocationEnum; using WIDESEA_Common.OrderEnum; +using WIDESEA_Common.OtherEnum; using WIDESEA_Common.StockEnum; using WIDESEA_Common.TaskEnum; using WIDESEA_Common.WareHouseEnum; using WIDESEA_Core; using WIDESEA_Core.Helper; using WIDESEA_DTO; +using WIDESEA_DTO.MES; using WIDESEA_DTO.Task; using WIDESEA_Model.Models; @@ -72,6 +76,10 @@ { Dt_LocationInfo locationInfo = _basicRepository.LocationInfoRepository.QueryFirst(x => x.WarehouseId == warehouseId); if (locationInfo == null) return WebResponseContent.Instance.Error($"鏈壘鍒板綋鍓嶅簱鍖鸿揣浣嶄俊鎭�"); + if (stationCode!= "8005") + { + return WebResponseContent.Instance.Error($"璧风偣閿欒锛歿stationCode}"); + } return DeviceRequestInboundTask(stationCode, locationInfo.RoadwayNo, palletCode); } else @@ -89,8 +97,8 @@ TaskStatus = TaskStatusEnum.New.ObjToInt(), WarehouseId = stockInfo.WarehouseId, PalletType = stockInfo.PalletType, - MaterielCode = stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode, - Quantity = (float)stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.StockQuantity, + MaterielCode = stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode, + Quantity = (float)stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).Sum(x => x.StockQuantity), }; //鑾峰彇鏄惁瀛樺湪鍏ュ簱鍗� Dt_InboundOrder? inboundOrder = null; @@ -326,8 +334,16 @@ TaskStatus = TaskStatusEnum.New.ObjToInt(), WarehouseId = stockInfoPPorGM.WarehouseId, PalletType = stockInfoPPorGM.PalletType, - TaskLength= stockInfoPPorGM.StockLength + TaskLength= stockInfoPPorGM.StockLength, + }; + string MaterielCodeGMPP = stockInfoPPorGM.Details?.Where(x => x.StockId == stockInfoPPorGM.Id).FirstOrDefault()?.MaterielCode; + float QuantityGMPP = (float)stockInfoPPorGM.Details?.Where(x => x.StockId == stockInfoPPorGM.Id).Sum(x => x.StockQuantity); + if (MaterielCodeGMPP != null && QuantityGMPP != null) + { + newTaskPPorGM.MaterielCode = MaterielCodeGMPP; + newTaskPPorGM.Quantity = QuantityGMPP; + } //鑾峰彇鏄惁瀛樺湪鍏ュ簱鍗� Dt_InboundOrder? inboundOrderPPorGM = null; @@ -394,9 +410,14 @@ TaskStatus = TaskStatusEnum.New.ObjToInt(), WarehouseId = stockInfo.WarehouseId, PalletType = stockInfo.PalletType, - MaterielCode = stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode, - Quantity = (float)stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.StockQuantity, }; + string MaterielCode = stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode; + float Quantity = (float)stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).Sum(x => x.StockQuantity); + if (MaterielCode != null && Quantity != null) + { + newTask.MaterielCode = MaterielCode; + newTask.Quantity = Quantity; + } //鑾峰彇鏄惁瀛樺湪鍏ュ簱鍗� Dt_InboundOrder? inboundOrder = null; @@ -427,6 +448,7 @@ } else if (stockInfo.StockStatus == StockStatusEmun.鎷i�夊畬鎴�.ObjToInt()) { + stockInfo.StockStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt(); newTask.TaskType = TaskTypeEnum.InPick.ObjToInt(); } else @@ -476,8 +498,7 @@ { return WebResponseContent.Instance.Error($"璇ョ珯鐐瑰凡鏈夋湭鎵ц鐨勪换鍔�"); } - - Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == palletCode); + Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == palletCode).Includes(x => x.Details).First(); if (stockInfo == null) { return WebResponseContent.Instance.Error($"鏈壘鍒扮粍鐩樹俊鎭�"); @@ -504,10 +525,14 @@ TaskStatus = TaskStatusEnum.New.ObjToInt(), WarehouseId = stockInfo.WarehouseId, PalletType = stockInfo.PalletType, - MaterielCode = stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode, - Quantity = (float)stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.StockQuantity, }; - + string MaterielCode = stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode; + float Quantity = (float)stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).Sum(x => x.StockQuantity); + if (MaterielCode != null && Quantity != null) + { + newTask.MaterielCode = MaterielCode; + newTask.Quantity = (float)Quantity; + } if (stockInfo.StockStatus == StockStatusEmun.鎵嬪姩缁勭洏鏆傚瓨.ObjToInt()) { @@ -578,7 +603,7 @@ string roadwayNo = AssignRoadwayNo(staions, palletCode, heightType); - Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == palletCode); + Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == palletCode).Includes(x => x.Details).First(); if (stockInfo == null) { return WebResponseContent.Instance.Error($"鏈壘鍒扮粍鐩樹俊鎭�"); @@ -605,10 +630,14 @@ TaskStatus = TaskStatusEnum.New.ObjToInt(), WarehouseId = stockInfo.WarehouseId, PalletType = stockInfo.PalletType, - MaterielCode = stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode, - Quantity = (float)stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.StockQuantity, }; - + string MaterielCode = stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.MaterielCode; + float Quantity = (float)stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).Sum(x => x.StockQuantity); + if (MaterielCode != null && Quantity != null) + { + newTask.MaterielCode = MaterielCode; + newTask.Quantity = Quantity; + } if (stockInfo.StockStatus == StockStatusEmun.鎵嬪姩缁勭洏鏆傚瓨.ObjToInt()) { stockInfo.StockStatus = StockStatusEmun.鎵嬪姩缁勭洏鍏ュ簱纭.ObjToInt(); @@ -742,6 +771,107 @@ return WebResponseContent.Instance.Error(ex.Message); } } + + public WebResponseContent RequestZHInboundTask(string agvTaskCode, string palletCode, string palletType, string materialLot) + { + WebResponseContent content = new WebResponseContent(); + try + { + //鑾峰彇娴嬭瘯鏋跺師搴撳瓨淇℃伅 + Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA154.ToString()); + //鑾峰彇搴撳瓨璁板綍 + List<Dt_StockInfo> stockInfos = _stockRepository.StockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => + x.WarehouseId == warehouse.WarehouseId && x.PalletCode== palletCode).Includes(x => x.Details).ToList(); + if (stockInfos.Count > 0) + { + return content.Error($"杞藉叿鎵樼洏宸插瓨鍦�"); + } + Dt_StockInfo? stockInfoOld = stockInfos.FirstOrDefault(x => x.Details.Any(x => x.BatchNo == materialLot)); + if (stockInfoOld != null) + { + return content.Error($"搴撳瓨淇℃伅宸插瓨鍦�"); + } + Dt_PalletTypeInfo palletTypeInfo = _palletTypeInfoRepository.QueryFirst(x=>x.CodeStartStr== palletType); + if (palletTypeInfo == null) + { + return content.Error($"鎵樼洏绫诲瀷淇℃伅涓嶅瓨鍦�"); + } + ////鑾峰彇闃荤剨鎵规 + //WebResponseContent requestLotInfo = GetZHMesMaterialLot(materialLot); + //if (!requestLotInfo.Status) + //{ + // return content.Error($"璇锋眰闃荤剨鎵规淇℃伅澶辫触,{requestLotInfo.Message}"); + //} + //MesLotInfoModel mesLotInfo = JsonConvert.DeserializeObject<MesLotInfoModel>(requestLotInfo.Data.ToString()); + MesLotInfoModel mesLotInfo = new MesLotInfoModel() + { + Product="FH001", + ProductVersion="A1", + Qty=20, + LotNo= materialLot, + IsFullNumber=true + }; + Dt_StockInfoDetail stockInfoDetail = new Dt_StockInfoDetail() + { + MaterielSpec = mesLotInfo.ProductVersion, + BatchNo = materialLot, + EffectiveDate = mesLotInfo.DateCode ?? " ", + MaterielCode = mesLotInfo.Product, + InboundOrderRowNo = 0, + MaterielName = mesLotInfo.Product, + ProductionDate = mesLotInfo.DateCode ?? " ", + OrderNo = "", + OutboundQuantity = 0, + SerialNumber = materialLot, + StockQuantity = (float)mesLotInfo.Qty, + Status = StockStatusEmun.鍏ュ簱纭.ObjToInt(), + Unit = "Lot", + Remark= mesLotInfo.IsFullNumber?"婊ot":"涓嶆弧Lot" + }; + Dt_StockInfo stockInfo = new Dt_StockInfo() + { + PalletCode = palletCode, + PalletType = palletTypeInfo.PalletType, + WarehouseId = warehouse.WarehouseId, + StockStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt(), + Details = new List<Dt_StockInfoDetail> { stockInfoDetail } + }; + + //鐢熸垚閫�搴撲换鍔� + Dt_Task taskIn = new() + { + CurrentAddress = "AGV_ZH", + Grade = 0, + PalletCode = palletCode, + NextAddress = "", + Roadway = "SC01_ZH", + SourceAddress = "AGV_ZH", + TargetAddress = "", + TaskStatus = (int)TaskStatusEnum.New, + TaskType = palletTypeInfo.LocaitonCount==2? (int)TaskTypeEnum.InZHProductLarge : (int)TaskTypeEnum.InZHProductSmall, + TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), + PalletType = palletTypeInfo.PalletType, + WarehouseId = warehouse.WarehouseId, + MaterielCode = mesLotInfo.Product, + Quantity = (float)mesLotInfo.Qty, + }; + _unitOfWorkManage.BeginTran(); + Db.InsertNav(stockInfo).Include(x => x.Details).ExecuteCommand(); + BaseDal.AddData(taskIn); + //BaseDal.AddData(task); + _unitOfWorkManage.CommitTran(); + //灏嗕换鍔℃帹閫佸埌WCS + PushTasksToWCS(new List<Dt_Task>() { taskIn }, "AGV_ZH", agvTaskCode); + content.OK(data: taskIn); + } + catch (Exception ex) + { + _unitOfWorkManage.RollbackTran(); + content.Error(ex.Message); + } + return content; + } + public readonly string[] OutStartPonits = { "5230", "5237", "5244" }; /// <summary> /// 鎴愬搧浣欐枡閫�搴撳叆浠� @@ -835,8 +965,8 @@ TaskStatus = TaskStatusEnum.New.ObjToInt(), WarehouseId = warePoint.WarehouseId, PalletType = proStockInfo.PalletType, - MaterielCode = proStockInfo.proStockInfoDetails.Where(x => x.ProStockId == proStockInfo.Id).FirstOrDefault()?.ProductCode, - Quantity = (float)proStockInfo.proStockInfoDetails.Where(x => x.ProStockId == proStockInfo.Id).Sum(x => x.StockPcsQty) + MaterielCode = proStockInfo.proStockInfoDetails?.Where(x => x.ProStockId == proStockInfo.Id).FirstOrDefault()?.ProductCode, + Quantity = (float)proStockInfo.proStockInfoDetails?.Where(x => x.ProStockId == proStockInfo.Id).Sum(x => x.StockPcsQty) }; _unitOfWorkManage.BeginTran(); int taskId = BaseDal.AddData(newTask); -- Gitblit v1.9.3