From c455612b03e6ecac994884dde5b5f4bc4909c181 Mon Sep 17 00:00:00 2001 From: dengjunjie <dengjunjie@hnkhzn.com> Date: 星期二, 11 三月 2025 17:12:52 +0800 Subject: [PATCH] 1 --- 项目代码/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Inbound.cs | 81 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 80 insertions(+), 1 deletions(-) diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Inbound.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Inbound.cs" index bc40862..90c8d2c 100644 --- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Inbound.cs" +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Inbound.cs" @@ -10,6 +10,7 @@ using WIDESEA_Core.Helper; using WIDESEAWCS_DTO.WCSInfo; using System.Transactions; +using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup; namespace WIDESEA_TaskInfoService { @@ -176,6 +177,11 @@ if (task == null) throw new Exception($"鏈壘鍒版墭鐩樺彿[{lineDTO.Barcode}]鐨勫叆搴撲换鍔�"); if (task.TaskState >= (int)InTaskStatusEnum.SC_InExecuting) throw new Exception($"鎵樼洏鍙穂{lineDTO.Barcode}]鐨勫叆搴撲换鍔$姸鎬佷笉鍖归厤"); + #region 鍒ゆ柇鏄惁涓虹┖鎵樺叆搴� + if (task.TaskType == TaskTypeEnum.PalletInbound.ObjToInt()) + return GetEmptyLocation(task); + #endregion + Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(lineDTO.Barcode); if (stockInfo == null) throw new Exception($"鏈壘鍒版墭鐩榌{lineDTO.Barcode}]鐨勭粍鐩樹俊鎭�"); Dt_StockInfoDetail? stockInfoDetail = stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault(); @@ -241,7 +247,7 @@ #region 淇敼搴撳瓨鍙婅揣浣嶄俊鎭� task.TaskState = (int)InTaskStatusEnum.SC_InExecuting; task.CurrentAddress = task.NextAddress; - task.NextAddress = locationInfo.LocationCode;//浣跨敤璐т綅澶囨敞瀛楁锛屽搴斿爢鍨涙満鎺掑垪灞� + task.NextAddress = locationInfo.LocationCode; task.TargetAddress = task.NextAddress; string[] targetCodes = task.NextAddress.Split("-"); var Row = Convert.ToInt16(targetCodes[0]); @@ -278,6 +284,79 @@ return content; } + /// <summary> + /// 鑾峰彇绌烘墭鐩樺叆搴撹揣浣� + /// </summary> + /// <param name="task"></param> + /// <returns></returns> + public WebResponseContent GetEmptyLocation(Dt_Task task) + { + try + { + Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode); + if (stockInfo == null) throw new Exception($"鏈壘鍒版墭鐩榌{task.PalletCode}]鐨勭粍鐩樹俊鎭�"); + Dt_StockInfoDetail? stockInfoDetail = stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault(); + if (stockInfoDetail == null) throw new Exception($"鏈壘鍒版墭鐩榌{task.PalletCode}]鐨勭粍鐩樿鎯�"); + if (stockInfo.StockStatus != StockStatusEmun.鍏ュ簱纭.ObjToInt() || !string.IsNullOrEmpty(stockInfo.LocationCode)) + throw new Exception($"鎵樼洏[{task.PalletCode}],璇ョ粍鐩樼姸鎬佷笉鍙叆搴�"); + Dt_StockInfo? instockInfo = null; + Dt_LocationInfo? locationInfo = null; + string CarChargingStation = AppSettings.Configuration[nameof(CarChargingStation)];//鑾峰彇绌挎杞﹀厖鐢典綅缃� + var ChargingStations = CarChargingStation.Split(","); + Dt_StockInfoDetail instockInfoDetail = _stockService.StockInfoDetailService.Repository.QueryData(x => x.MaterielCode == stockInfoDetail.MaterielCode).OrderByDescending(x => x.CreateDate).First(); + if (instockInfoDetail != null) instockInfo = _stockService.StockInfoService.Repository.GetStockInfo(instockInfoDetail.StockId); + if (instockInfo != null)//鏃犲簱瀛� + { + locationInfo = _basicRepository.LocationInfoRepository.QueryFirst(x => x.LocationCode == instockInfo.LocationCode); + if (ChargingStations.Contains(locationInfo.LocationCode)) + { + if (locationInfo.MaxQty - locationInfo.CurrentQty <= 1) locationInfo = null; + } + else if (locationInfo.MaxQty - locationInfo.CurrentQty < 1) + { + locationInfo = null; + } + } + else + { + locationInfo = _basicService.LocationInfoService.AssignLocation(ChargingStations);//鏌ユ壘绌挎杞﹀厖鐢佃揣浣� + } + if (locationInfo == null) locationInfo = _basicService.LocationInfoService.AssignLocation(2);//閲嶆柊鍒嗛厤璐т綅 + if (locationInfo == null) throw new Exception($"鏃犲彲鍏ヨ揣浣�"); + task.TaskState = (int)InTaskStatusEnum.SC_InExecuting; + task.CurrentAddress = task.NextAddress; + task.NextAddress = locationInfo.LocationCode; + task.TargetAddress = task.NextAddress; + task.TargetIsPickPlace = locationInfo.Row > 1 ? locationInfo.MaxQty - locationInfo.CurrentQty == 1 : false; + task.SourceIsPickPlace = false; + stockInfo.LocationCode = locationInfo.LocationCode; + stockInfo.StockStatus = StockStatusEmun.鍏ュ簱涓�.ObjToInt(); + stockInfoDetail.Status = StockStatusEmun.鍏ュ簱涓�.ObjToInt(); + locationInfo.CurrentQty++; + if (locationInfo.MaxQty < locationInfo.CurrentQty) throw new Exception(); + locationInfo.EnableStatus = EnableStatusEnum.OnlyOut.ObjToInt(); + locationInfo.LocationStatus = LocationStatusEnum.Inbounding.ObjToInt(); + + Db.Ado.BeginTran(); + UpdateData(task); + _stockService.StockInfoService.Repository.UpdateData(stockInfo); + _stockService.StockInfoDetailService.Repository.UpdateData(stockInfoDetail); + _basicService.LocationInfoService.Repository.UpdateData(locationInfo); + Db.Ado.CommitTran(); + + return WebResponseContent.Instance.OK(data: new ReceiveWMSInfo() + { + TargetAddress = task.TargetAddress, + SourceIsPickPlace = task.SourceIsPickPlace, + TargetIsPickPlace = task.TargetIsPickPlace, + }); + } + catch (Exception ex) + { + Db.Ado.RollbackTran(); + return WebResponseContent.Instance.Error(ex.Message); + } + } } } -- Gitblit v1.9.3