From e1dd1dc9ba7135e3d64a65587d6c1be2c3e18c5a Mon Sep 17 00:00:00 2001 From: wangxinhui <wangxinhui@hnkhzn.com> Date: 星期三, 25 六月 2025 11:01:22 +0800 Subject: [PATCH] 提交最新优化代码 --- 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Inbound.cs | 358 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 337 insertions(+), 21 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 ff7ba14..3deae56 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,19 +1,25 @@ -锘縰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; using System.Linq; using System.Text; +using System.Text.RegularExpressions; using System.Threading.Tasks; 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.Enums; using WIDESEA_Core.Helper; using WIDESEA_DTO; +using WIDESEA_DTO.MES; using WIDESEA_DTO.Task; using WIDESEA_Model.Models; @@ -55,7 +61,7 @@ { return WebResponseContent.Instance.Error($"鏈壘鍒扮粍鐩樹俊鎭�"); } - if (stockInfo.StockStatus != StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.鎵嬪姩缁勭洏鏆傚瓨.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.鎷i�夊畬鎴�.ObjToInt()) + if (stockInfo.StockStatus != StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.鎵嬪姩缁勭洏鏆傚瓨.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.鎷i�夊畬鎴�.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.閫佹搴撳瓨瀹屾垚.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.鐩樼偣搴撳瓨瀹屾垚.ObjToInt()) { return WebResponseContent.Instance.Error($"璇ユ墭鐩樼姸鎬佷笉姝g‘,涓嶅彲鐢宠鍏ュ簱"); } @@ -71,6 +77,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 @@ -87,7 +97,9 @@ TaskType = TaskTypeEnum.Inbound.ObjToInt(), TaskStatus = TaskStatusEnum.New.ObjToInt(), WarehouseId = stockInfo.WarehouseId, - PalletType = stockInfo.PalletType + PalletType = stockInfo.PalletType, + 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; @@ -123,9 +135,28 @@ stockInfo.StockStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt(); newTask.TaskType = TaskTypeEnum.InPick.ObjToInt(); } + else if (stockInfo.StockStatus == StockStatusEmun.閫佹搴撳瓨瀹屾垚.ObjToInt()) + { + stockInfo.StockStatus = StockStatusEmun.鎵嬪姩缁勭洏鍏ュ簱纭.ObjToInt(); + newTask.TaskType = TaskTypeEnum.InQuality.ObjToInt(); + } + else if(stockInfo.StockStatus == StockStatusEmun.鐩樼偣搴撳瓨瀹屾垚.ObjToInt()) + { + stockInfo.StockStatus = StockStatusEmun.鎵嬪姩缁勭洏鍏ュ簱纭.ObjToInt(); + newTask.TaskType = TaskTypeEnum.InInventory.ObjToInt(); + } else { stockInfo.StockStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt(); + } + + if (warehouse.WarehouseCode==WarehouseEnum.HA57.ToString()) + { + Dt_Task dt_TaskMesReturn = BaseDal.QueryFirst(x=>x.TaskType==TaskTypeEnum.MesMatReturn.ObjToInt() && x.TaskStatus!=TaskStatusEnum.SC_Executing.ObjToInt()); + if (dt_TaskMesReturn!=null) + { + return WebResponseContent.Instance.Error($"閫�鏂欎换鍔℃鎵ц"); + } } _unitOfWorkManage.BeginTran(); int taskId = BaseDal.AddData(newTask); @@ -142,7 +173,52 @@ return WebResponseContent.Instance.Error(ex.Message); } } - + /// <summary> + /// 鏌ヨ璐ㄦ鏁伴噺 + /// </summary> + /// <param name="palletCode">鎵樼洏鍙�</param> + /// <returns></returns> + public WebResponseContent InQualityConfirm(string palletCode) + { + WebResponseContent content = new WebResponseContent(); + try + { + Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(palletCode); + if (stockInfo == null) + { + return content.Error($"鏈壘鍒拌鎵樼洏搴撳瓨淇℃伅"); + } + if (stockInfo.Details.Count<=0) + { + return content.Error($"璇ユ墭鐩樺簱瀛樻槑缁嗕负绌�"); + } + if (stockInfo.StockStatus != StockStatusEmun.閫佹搴撳瓨瀹屾垚.ObjToInt()) + { + return content.Error($"璇ユ墭鐩樿繕鏈�佹妫�楠屽畬鎴�"); + } + Dt_OutStockLockInfo? outStockLockInfo = _outboundRepository.OutboundStockLockInfoRepository.QueryData(x => x.PalletCode == palletCode && x.Status == OutLockStockStatusEnum.鍑哄簱瀹屾垚.ObjToInt() && x.OrderType== OutOrderTypeEnum.Quality.ObjToInt()).OrderByDescending(x=>x.Id).FirstOrDefault(); + if (outStockLockInfo != null) + { + //鑾峰彇瀵瑰簲妫�楠屽崟 + Dt_CheckOrder checkOrder = _checkOrderRepository.QueryFirst(x=>x.ReceiveDetailRowNo== outStockLockInfo.Id && x.CheckOrderStatus==CheckOrderStatusEnum.Checked.ObjToInt()); + if (checkOrder == null) + { + return content.Error($"璇ユ墭鐩橀�佹淇℃伅鏈"); + } + content.OK("鎴愬姛", data:new { stockInfo.Details.FirstOrDefault()?.MaterielCode,checkOrder.ReceivedQuantity,checkOrder.ScrappedQuantity,checkOrder.DefectedQuantity,checkOrder.QualifiedQuantity,stockQuantity= stockInfo.Details.Sum(x=>x.StockQuantity) }) ; + } + else + { + content.Error("璇ユ墭鐩橀�佹鍑哄簱璇︽儏涓嶅瓨鍦�"); + } + } + catch (Exception ex) + { + _unitOfWorkManage.RollbackTran(); + content.Error(ex.Message); + } + return content; + } /// <summary> /// 鍏ョ┖绠� /// </summary> @@ -199,7 +275,7 @@ _stockRepository.StockInfoRepository.AddData(stockInfo); _unitOfWorkManage.CommitTran(); PushTasksToWCS(new List<Dt_Task> { newTask }); - PutFinish(address); + PutFinish(address, newTask.PalletCode, newTask.TaskNum.ToString()); return WebResponseContent.Instance.OK(); } catch (Exception ex) @@ -268,7 +344,7 @@ /// <param name="roadwayNo"></param> /// <param name="palletCode"></param> /// <returns></returns> - public WebResponseContent DeviceRequestInboundTask(string stationCode, string roadwayNo, string palletCode) + public WebResponseContent DeviceRequestInboundTask(string stationCode, string roadwayNo, string palletCode,string materielBoxCode = "") { try { @@ -283,13 +359,86 @@ { return WebResponseContent.Instance.Error($"璇ョ珯鐐瑰凡鏈夋湭鎵ц鐨勪换鍔�"); } + if (!string.IsNullOrEmpty(materielBoxCode)) + { + _unitOfWorkManage.BeginTran(); + WebResponseContent responseGroup = _inboundOrderService.MaterielPPorGM(materielBoxCode); + if (!responseGroup.Status) + { + return WebResponseContent.Instance.Error($"{responseGroup.Message}"); + } + Dt_StockInfo stockInfoPPorGM = responseGroup.Data as Dt_StockInfo ?? null; + if (stockInfoPPorGM==null) + { + return WebResponseContent.Instance.Error($"缁勭洏鏁版嵁杞崲澶辫触"); + } + Dt_LocationInfo? locationInfoPPorGM = _basicService.LocationInfoService.AssignLocation(roadwayNo, stockInfoPPorGM.PalletType, stockInfoPPorGM.WarehouseId); + if (locationInfoPPorGM == null) + { + return WebResponseContent.Instance.Error($"璐т綅鍒嗛厤澶辫触,鏈壘鍒板彲鍒嗛厤璐т綅"); + } + Dt_Task newTaskPPorGM = new Dt_Task() + { + CurrentAddress = stationCode, + Grade = 0, + NextAddress = locationInfoPPorGM.LocationCode, + PalletCode = stockInfoPPorGM.PalletCode, + Roadway = roadwayNo, + SourceAddress = stationCode, + TargetAddress = locationInfoPPorGM.LocationCode, + TaskType = TaskTypeEnum.Inbound.ObjToInt(), + TaskStatus = TaskStatusEnum.New.ObjToInt(), + WarehouseId = stockInfoPPorGM.WarehouseId, + PalletType = stockInfoPPorGM.PalletType, + 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; + if (stockInfoPPorGM != null && stockInfoPPorGM.Details.Count > 0) + { + string? orderNo = stockInfoPPorGM.Details.FirstOrDefault()?.OrderNo ?? ""; + inboundOrderPPorGM = _inboundOrderService.Repository.QueryFirst(x => x.InboundOrderNo == orderNo && x.OrderStatus < InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt()); + } + + if (inboundOrderPPorGM != null) + { + if (inboundOrderPPorGM.OrderType == InOrderTypeEnum.Allocat.ObjToInt()) + { + newTaskPPorGM.TaskType = TaskTypeEnum.InAllocate.ObjToInt(); + } + else if (inboundOrderPPorGM.OrderType == InOrderTypeEnum.Return.ObjToInt()) + { + newTaskPPorGM.TaskType = TaskTypeEnum.ProductionReturn.ObjToInt(); + } + } + stockInfoPPorGM.StockStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt(); + LocationStatusEnum lastStatusPPorGM = (LocationStatusEnum)locationInfoPPorGM.LocationStatus; + _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfoPPorGM, lastStatusPPorGM, LocationStatusEnum.Lock, LocationChangeType.InboundAssignLocation); + _basicService.LocationInfoService.UpdateLocationStatus(locationInfoPPorGM, newTaskPPorGM.PalletType, LocationStatusEnum.Lock, newTaskPPorGM.WarehouseId); + int taskIdPPorGM = BaseDal.AddData(newTaskPPorGM); + newTaskPPorGM.TaskId = taskIdPPorGM; + _stockRepository.StockInfoRepository.Db.InsertNav(stockInfoPPorGM).Include(x => x.Details).ExecuteCommand(); + _unitOfWorkManage.CommitTran(); + WMSTaskDTO wMSTaskDTOPPorGM = _mapper.Map<WMSTaskDTO>(newTaskPPorGM); + + PushTasksToWCS(new List<Dt_Task> { newTaskPPorGM }); + return WebResponseContent.Instance.OK(data: wMSTaskDTOPPorGM); + } 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($"鏈壘鍒扮粍鐩樹俊鎭�"); } - if (stockInfo.StockStatus != StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.鎵嬪姩缁勭洏鏆傚瓨.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.鎷i�夊畬鎴�.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.閫�搴�.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.MES閫�搴�.ObjToInt()) + if (stockInfo.StockStatus != StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.鎵嬪姩缁勭洏鏆傚瓨.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.鎷i�夊畬鎴�.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.閫�搴�.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.MES閫�搴�.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.閫佹搴撳瓨瀹屾垚.ObjToInt() && stockInfo.StockStatus!=StockStatusEmun.鐩樼偣搴撳瓨瀹屾垚.ObjToInt()) { return WebResponseContent.Instance.Error($"璇ユ墭鐩樼姸鎬佷笉姝g‘,涓嶅彲鐢宠鍏ュ簱"); } @@ -316,8 +465,15 @@ TaskType = TaskTypeEnum.Inbound.ObjToInt(), TaskStatus = TaskStatusEnum.New.ObjToInt(), WarehouseId = stockInfo.WarehouseId, - PalletType = stockInfo.PalletType + PalletType = stockInfo.PalletType, }; + 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; @@ -348,7 +504,18 @@ } else if (stockInfo.StockStatus == StockStatusEmun.鎷i�夊畬鎴�.ObjToInt()) { + stockInfo.StockStatus = StockStatusEmun.鍏ュ簱纭.ObjToInt(); newTask.TaskType = TaskTypeEnum.InPick.ObjToInt(); + } + else if (stockInfo.StockStatus == StockStatusEmun.閫佹搴撳瓨瀹屾垚.ObjToInt()) + { + stockInfo.StockStatus = StockStatusEmun.鎵嬪姩缁勭洏鍏ュ簱纭.ObjToInt(); + newTask.TaskType = TaskTypeEnum.InQuality.ObjToInt(); + } + else if (stockInfo.StockStatus == StockStatusEmun.鐩樼偣搴撳瓨瀹屾垚.ObjToInt()) + { + stockInfo.StockStatus = StockStatusEmun.鎵嬪姩缁勭洏鍏ュ簱纭.ObjToInt(); + newTask.TaskType = TaskTypeEnum.InInventory.ObjToInt(); } else { @@ -366,7 +533,7 @@ WMSTaskDTO wMSTaskDTO = _mapper.Map<WMSTaskDTO>(newTask); PushTasksToWCS(new List<Dt_Task> { newTask }); - if (newTask.WarehouseId == 5) PutFinish(stationCode); + if (newTask.WarehouseId == 5) PutFinish(stationCode.ToString(),newTask.PalletCode, newTask.TaskNum.ToString()); return WebResponseContent.Instance.OK(data: wMSTaskDTO); } catch (Exception ex) @@ -397,13 +564,12 @@ { 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($"鏈壘鍒扮粍鐩樹俊鎭�"); } - if (stockInfo.StockStatus != StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.鎵嬪姩缁勭洏鏆傚瓨.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.鎷i�夊畬鎴�.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.閫�搴�.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.MES閫�搴�.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.MES绌烘墭閫�搴�.ObjToInt()) + if (stockInfo.StockStatus != StockStatusEmun.閫�搴�.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.MES閫�搴�.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.MES绌烘墭閫�搴�.ObjToInt()) { return WebResponseContent.Instance.Error($"璇ユ墭鐩樼姸鎬佷笉姝g‘,涓嶅彲鐢宠鍏ュ簱"); } @@ -424,9 +590,15 @@ TaskType = TaskTypeEnum.Inbound.ObjToInt(), TaskStatus = TaskStatusEnum.New.ObjToInt(), WarehouseId = stockInfo.WarehouseId, - PalletType = stockInfo.PalletType + PalletType = stockInfo.PalletType, }; - + 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()) { @@ -438,8 +610,9 @@ } else if (stockInfo.StockStatus == StockStatusEmun.MES绌烘墭閫�搴�.ObjToInt()) { + Dt_PalletTypeInfo palletTypeInfo = _palletTypeInfoRepository.QueryFirst(x=>x.WarehouseId==stockInfo.WarehouseId && x.PalletType==stockInfo.PalletType); //todo 灏忔墭鐩樻殏鏃舵湭鍚敤 - if (stockInfo.PalletType == PalletTypeEnum.MediumPallet.ObjToInt()) + if (palletTypeInfo.LocaitonCount==2) { newTask.TaskType = TaskTypeEnum.MesPalletLargeReturn.ObjToInt(); } @@ -461,7 +634,7 @@ WMSTaskDTO wMSTaskDTO = _mapper.Map<WMSTaskDTO>(newTask); PushTasksToWCS(new List<Dt_Task> { newTask }); - if (newTask.WarehouseId == 5) PutFinish(stationCode); + if (newTask.WarehouseId == 5) PutFinish(stationCode, newTask.PalletCode, newTask.TaskNum.ToString()); return WebResponseContent.Instance.OK(data: wMSTaskDTO); } catch (Exception ex) @@ -497,7 +670,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($"鏈壘鍒扮粍鐩樹俊鎭�"); @@ -523,9 +696,15 @@ TaskType = TaskTypeEnum.Inbound.ObjToInt(), TaskStatus = TaskStatusEnum.New.ObjToInt(), WarehouseId = stockInfo.WarehouseId, - PalletType = stockInfo.PalletType + PalletType = stockInfo.PalletType, }; - + 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(); @@ -659,6 +838,108 @@ 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> /// 鎴愬搧浣欐枡閫�搴撳叆浠� /// </summary> @@ -670,6 +951,16 @@ WebResponseContent content = new WebResponseContent(); try { + string palletCode = @"^C\d{5}$"; // 姝e垯琛ㄨ揪寮� + bool isValid = Regex.IsMatch(barCode, palletCode); + if (!isValid) + { + return content.Error($"妗嗙爜鏍煎紡閿欒{barCode}"); + } + if (!OutStartPonits.Contains(startPoint)) + { + return content.Error($"璧风偣閿欒{startPoint}"); + } //鍒ゆ柇褰撳墠鐐逛綅鏄惁閲嶅 Dt_Task taskOldPoint = BaseDal.QueryFirst(x=>x.SourceAddress==startPoint && (x.TaskStatus == TaskStatusEnum.New.ObjToInt()||x.TaskStatus==TaskStatusEnum.Line_Execute.ObjToInt()|| x.TaskStatus == TaskStatusEnum.Line_Executing.ObjToInt() || x.TaskStatus == TaskStatusEnum.AGV_Takeing.ObjToInt())); if (taskOldPoint != null) @@ -740,7 +1031,9 @@ TaskType = TaskTypeEnum.InProductBack.ObjToInt(), TaskStatus = TaskStatusEnum.New.ObjToInt(), WarehouseId = warePoint.WarehouseId, - PalletType = proStockInfo.PalletType + 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) }; _unitOfWorkManage.BeginTran(); int taskId = BaseDal.AddData(newTask); @@ -767,6 +1060,16 @@ WebResponseContent content = new WebResponseContent(); try { + string palletCode = @"^C\d{5}$"; // 姝e垯琛ㄨ揪寮� + bool isValid = Regex.IsMatch(barCode, palletCode); + if (!isValid) + { + return content.Error($"妗嗙爜鏍煎紡閿欒{barCode}"); + } + if (!OutStartPonits.Contains(startPoint)) + { + return content.Error($"璧风偣閿欒{startPoint}"); + } //鍒ゆ柇褰撳墠鐐逛綅鏄惁閲嶅 Dt_Task taskOldPoint = BaseDal.QueryFirst(x => x.SourceAddress == startPoint && (x.TaskStatus == TaskStatusEnum.New.ObjToInt() || x.TaskStatus == TaskStatusEnum.Line_Execute.ObjToInt() || x.TaskStatus == TaskStatusEnum.Line_Executing.ObjToInt())); //if (taskOldPoint != null) @@ -778,7 +1081,16 @@ { return content.Error($"鑳舵{barCode}浠诲姟宸插瓨鍦�"); } - + //if (_stockRepository.ProStockInfoRepository.QueryFirst(x => x.PalletCode == barCode) != null) + //{ + // return content.Error($"鑳舵{barCode}搴撳瓨淇℃伅宸插瓨鍦�"); + //} + //todo:涓存椂瑙g粦 + Dt_ProStockInfo proStockInfo = _stockRepository.ProStockInfoRepository.QueryFirst(x => x.PalletCode == barCode); + if (_stockRepository.ProStockInfoRepository.QueryFirst(x => x.PalletCode == barCode) != null) + { + proStockInfo.PalletCode = proStockInfo.PalletCode + ":" + DateTime.Now.ToString("MM/dd"); + } //鑾峰彇鎴愬搧骞冲簱 Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.HA101.ToString()); Dt_Task newTask = new Dt_Task() @@ -797,6 +1109,10 @@ }; _unitOfWorkManage.BeginTran(); int taskId = BaseDal.AddData(newTask); + if (proStockInfo!=null) + { + _stockRepository.ProStockInfoRepository.UpdateData(proStockInfo); + } newTask.TaskId = taskId; _unitOfWorkManage.CommitTran(); //鎺ㄩ�佷换鍔� -- Gitblit v1.9.3