From 9d75314e88f8aac494d57715e3231fe3540cb867 Mon Sep 17 00:00:00 2001 From: wangxinhui <wangxinhui@hnkhzn.com> Date: 星期二, 23 九月 2025 03:03:03 +0800 Subject: [PATCH] 优化更新 --- 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Inbound.cs | 187 +++++++++++++++++++++++++--------------------- 1 files changed, 102 insertions(+), 85 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 3deae56..25714e7 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" @@ -100,6 +100,7 @@ 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), + BatchNo = stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.BatchNo }; //鑾峰彇鏄惁瀛樺湪鍏ュ簱鍗� Dt_InboundOrder? inboundOrder = null; @@ -275,7 +276,7 @@ _stockRepository.StockInfoRepository.AddData(stockInfo); _unitOfWorkManage.CommitTran(); PushTasksToWCS(new List<Dt_Task> { newTask }); - PutFinish(address, newTask.PalletCode, newTask.TaskNum.ToString()); + //PutFinish(address, newTask.PalletCode, newTask.TaskNum.ToString()); return WebResponseContent.Instance.OK(); } catch (Exception ex) @@ -395,10 +396,12 @@ }; 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) + string batchNo = stockInfoPPorGM.Details?.Where(x => x.StockId == stockInfoPPorGM.Id).FirstOrDefault()?.BatchNo; + if (MaterielCodeGMPP != null && QuantityGMPP != null && batchNo != null) { newTaskPPorGM.MaterielCode = MaterielCodeGMPP; newTaskPPorGM.Quantity = QuantityGMPP; + newTaskPPorGM.BatchNo = batchNo; } //鑾峰彇鏄惁瀛樺湪鍏ュ簱鍗� @@ -469,10 +472,12 @@ }; 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) + string BatchNo = stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.BatchNo; + if (MaterielCode != null && Quantity != null && BatchNo != null) { newTask.MaterielCode = MaterielCode; newTask.Quantity = Quantity; + newTask.BatchNo = BatchNo; } //鑾峰彇鏄惁瀛樺湪鍏ュ簱鍗� @@ -533,7 +538,7 @@ WMSTaskDTO wMSTaskDTO = _mapper.Map<WMSTaskDTO>(newTask); PushTasksToWCS(new List<Dt_Task> { newTask }); - if (newTask.WarehouseId == 5) PutFinish(stationCode.ToString(),newTask.PalletCode, newTask.TaskNum.ToString()); + //if (newTask.WarehouseId == 5) PutFinish(stationCode.ToString(),newTask.PalletCode, newTask.TaskNum.ToString()); return WebResponseContent.Instance.OK(data: wMSTaskDTO); } catch (Exception ex) @@ -594,10 +599,12 @@ }; 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) + string BatchNo = stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.BatchNo; + if (MaterielCode != null && Quantity != null && BatchNo != null) { newTask.MaterielCode = MaterielCode; - newTask.Quantity = (float)Quantity; + newTask.Quantity = Quantity; + newTask.BatchNo = BatchNo; } if (stockInfo.StockStatus == StockStatusEmun.鎵嬪姩缁勭洏鏆傚瓨.ObjToInt()) @@ -634,7 +641,7 @@ WMSTaskDTO wMSTaskDTO = _mapper.Map<WMSTaskDTO>(newTask); PushTasksToWCS(new List<Dt_Task> { newTask }); - if (newTask.WarehouseId == 5) PutFinish(stationCode, newTask.PalletCode, newTask.TaskNum.ToString()); + //if (newTask.WarehouseId == 5) PutFinish(stationCode, newTask.PalletCode, newTask.TaskNum.ToString()); return WebResponseContent.Instance.OK(data: wMSTaskDTO); } catch (Exception ex) @@ -700,10 +707,12 @@ }; 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) + string BatchNo = stockInfo.Details?.Where(x => x.StockId == stockInfo.Id).FirstOrDefault()?.BatchNo; + if (MaterielCode != null && Quantity != null && BatchNo != null) { newTask.MaterielCode = MaterielCode; newTask.Quantity = Quantity; + newTask.BatchNo = BatchNo; } if (stockInfo.StockStatus == StockStatusEmun.鎵嬪姩缁勭洏鏆傚瓨.ObjToInt()) { @@ -844,7 +853,7 @@ 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 => @@ -863,21 +872,21 @@ { 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() + //鑾峰彇闃荤剨鎵规 + WebResponseContent requestLotInfo = GetZHMesMaterialLot(materialLot); + if (!requestLotInfo.Status) { - Product="FH001", - ProductVersion="A1", - Qty=20, - LotNo= materialLot, - IsFullNumber=true - }; + 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, @@ -921,6 +930,7 @@ WarehouseId = warehouse.WarehouseId, MaterielCode = mesLotInfo.Product, Quantity = (float)mesLotInfo.Qty, + BatchNo = mesLotInfo.LotNo }; _unitOfWorkManage.BeginTran(); Db.InsertNav(stockInfo).Include(x => x.Details).ExecuteCommand(); @@ -1033,7 +1043,9 @@ 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) + Quantity = (float)proStockInfo.proStockInfoDetails?.Where(x => x.ProStockId == proStockInfo.Id).Sum(x => x.StockPcsQty), + BatchNo = proStockInfo.proStockInfoDetails?.Where(x => x.ProStockId == proStockInfo.Id).FirstOrDefault()?.LotNumber + }; _unitOfWorkManage.BeginTran(); int taskId = BaseDal.AddData(newTask); @@ -1052,78 +1064,83 @@ } return content; } + private static object emptyBack_inbound = new object(); /// <summary> /// 绌烘鍥炲簱 /// </summary> public WebResponseContent EmptyBackTask(string barCode, string startPoint) { - WebResponseContent content = new WebResponseContent(); - try + lock (emptyBack_inbound) { - string palletCode = @"^C\d{5}$"; // 姝e垯琛ㄨ揪寮� - bool isValid = Regex.IsMatch(barCode, palletCode); - if (!isValid) + WebResponseContent content = new WebResponseContent(); + try { - return content.Error($"妗嗙爜鏍煎紡閿欒{barCode}"); + 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) + //{ + // return content.Error($"绔欑偣{startPoint}宸插瓨鍦ㄤ换鍔�"); + //} + Dt_Task taskOld = BaseDal.QueryFirst(x => x.PalletCode == barCode); + if (taskOld != null) + { + 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 && x.StockStatus == StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt()); + 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() + { + CurrentAddress = startPoint, + Grade = 0, + NextAddress = "", + PalletCode = barCode, + Roadway = "CL01_CP", + SourceAddress = startPoint, + TargetAddress = "", + TaskType = TaskTypeEnum.EmptyProductBack.ObjToInt(), + TaskStatus = TaskStatusEnum.New.ObjToInt(), + WarehouseId = warehouse.WarehouseId, + PalletType = 1 + }; + _unitOfWorkManage.BeginTran(); + int taskId = BaseDal.AddData(newTask); + if (proStockInfo != null) + { + _stockRepository.ProStockInfoRepository.UpdateData(proStockInfo); + } + newTask.TaskId = taskId; + _unitOfWorkManage.CommitTran(); + //鎺ㄩ�佷换鍔� + PushTasksToWCS(new List<Dt_Task> { newTask }); + content.OK("鍙戦�佹垚鍔�"); } - if (!OutStartPonits.Contains(startPoint)) + catch (Exception ex) { - return content.Error($"璧风偣閿欒{startPoint}"); + content.Error(ex.Message); } - //鍒ゆ柇褰撳墠鐐逛綅鏄惁閲嶅 - 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) - //{ - // return content.Error($"绔欑偣{startPoint}宸插瓨鍦ㄤ换鍔�"); - //} - Dt_Task taskOld = BaseDal.QueryFirst(x => x.PalletCode == barCode); - if (taskOld != null) - { - 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() - { - CurrentAddress = startPoint, - Grade = 0, - NextAddress = "", - PalletCode = barCode, - Roadway = "CL01_CP", - SourceAddress = startPoint, - TargetAddress = "", - TaskType = TaskTypeEnum.EmptyProductBack.ObjToInt(), - TaskStatus = TaskStatusEnum.New.ObjToInt(), - WarehouseId = warehouse.WarehouseId, - PalletType = 1 - }; - _unitOfWorkManage.BeginTran(); - int taskId = BaseDal.AddData(newTask); - if (proStockInfo!=null) - { - _stockRepository.ProStockInfoRepository.UpdateData(proStockInfo); - } - newTask.TaskId = taskId; - _unitOfWorkManage.CommitTran(); - //鎺ㄩ�佷换鍔� - PushTasksToWCS(new List<Dt_Task> { newTask }); - content.OK("鍙戦�佹垚鍔�"); + return content; } - catch (Exception ex) - { - content.Error(ex.Message); - } - return content; + } } } -- Gitblit v1.9.3