From 2de09bec5cc05bf875543fa8956167ca7db73021 Mon Sep 17 00:00:00 2001 From: 刘磊 <1161824510@qq.com> Date: 星期三, 25 六月 2025 11:36:44 +0800 Subject: [PATCH] 合并 --- 项目代码/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs | 144 +++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 142 insertions(+), 2 deletions(-) diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs" index d8f37f8..e320f9d 100644 --- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs" +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs" @@ -102,6 +102,62 @@ } } + + /// <summary> + /// 妫�鏌ュ苟鐢熸垚绉诲簱浠诲姟鎴栬繑鍥炲叆搴撲换鍔� + /// </summary> + /// <param name="locationID">浠诲姟鍙�</param> + /// <returns>浠诲姟瀵硅薄</returns> + public virtual async Task<Dt_Task> InTransferCheckAsync(RequestTaskDto input) + { + try + { + int taskNum = input.taskNum; + + // 鏍规嵁浠诲姟鍙疯幏鍙栧叆搴撲换鍔� + var inboundTask = await _taskRepository.QueryFirstAsync(x => x.TaskNum == taskNum); + if (inboundTask == null) + return null; + LogFactory.GetLog("妫�鏌ユ槸鍚﹂渶瑕佺Щ搴�").InfoFormat(true, "鏍规嵁浠诲姟鍙疯幏鍙栦换鍔�", $"浠诲姟鍙凤細{taskNum}锛屼换鍔℃暟鎹細{inboundTask}"); + + var location = await BaseDal.QueryFirstAsync(x => x.LocationCode == inboundTask.TargetAddress); + LogFactory.GetLog("妫�鏌ユ槸鍚﹂渶瑕佺Щ搴�").InfoFormat(true, "鑾峰彇鎸囧畾搴撲綅鐨勮揣浣嶆暟鎹�", $"璐т綅鍙凤細{inboundTask.TargetAddress}锛岃揣浣嶆暟鎹細{location}"); + + // 妫�鏌ユ槸鍚﹂渶瑕佽繘琛岀Щ搴� + if (CheckForInternalTransfer(location)) + { + LogFactory.GetLog("妫�鏌ユ槸鍚﹂渶瑕佺Щ搴�").InfoFormat(true, "闇�瑕佺Щ搴�", $"璐т綅鍙凤細{inboundTask.TargetAddress}锛岃揣浣嶆暟鎹細{location}"); + // 璁$畻瀵瑰簲浣嶇疆鐨勭浉瀵瑰簱浣� 锛堝鏁拌鐨勪笅涓�琛屾垨鑰呭伓鏁拌鐨勪笂涓�琛岋級 + var newLocationID = GetRelativeLocationID(location); + LogFactory.GetLog("妫�鏌ユ槸鍚﹂渶瑕佺Щ搴�").InfoFormat(true, "闇�瑕佺Щ搴�,缁勫缓闇�瑕佺Щ搴撹揣浣嶅彿", $"鏂扮殑搴撲綅ID锛歿newLocationID}"); + + var relocationTask = await _taskRepository.QueryFirstAsync(x => x.TargetAddress == newLocationID && x.Roadway == inboundTask.Roadway && x.TaskType == (int)TaskTypeEnum.Relocation); + if (relocationTask != null) return relocationTask; + + // 鑾峰彇鏂扮殑搴撲綅鐨勪换鍔� + var internalTransferTask = await _taskRepository.QueryFirstAsync(x => x.TargetAddress == newLocationID && x.Roadway == inboundTask.Roadway && x.TaskState == (int)TaskOutStatusEnum.OutNew); + + LogFactory.GetLog("妫�鏌ユ槸鍚﹂渶瑕佺Щ搴�").InfoFormat(true, "闇�瑕佺Щ搴�,鑾峰彇鏂板簱浣嶇殑浠诲姟", $"鏂板簱浣嶄换鍔★細{internalTransferTask}"); + // 濡傛灉鏂扮殑搴撲綅娌℃湁鎵惧埌瀵瑰簲鐨勪换鍔� + if (internalTransferTask == null) + { + LogFactory.GetLog("妫�鏌ユ槸鍚﹂渶瑕佺Щ搴�").InfoFormat(true, "闇�瑕佺Щ搴�,鏈幏鍙栧埌鏂板簱浣嶄换鍔�", $""); + return await InHandleLocation(inboundTask.TargetAddress, newLocationID, inboundTask); + } + LogFactory.GetLog("妫�鏌ユ槸鍚﹂渶瑕佺Щ搴�").InfoFormat(true, "闇�瑕佺Щ搴�,鑾峰彇鍒版柊搴撲綅浠诲姟鐩存帴杩斿洖", $"鏂板簱浣嶄换鍔★細{internalTransferTask}"); + // 鐩存帴杩斿洖涓�娣变綅鍑哄簱浠诲姟 + return internalTransferTask; + } + + // 杩斿洖褰撳墠搴撲綅鐨勫嚭搴撲换鍔� + return inboundTask; + } + catch (Exception) + { + return null; + } + } + public override WebResponseContent UpdateData(SaveModel saveModel) { int id = saveModel.MainData["id"].ObjToInt(); @@ -253,6 +309,32 @@ #endregion 鍚敤绂佺敤璐т綅 + #region 澶у睆搴撲綅鐘舵�佽幏鍙� + public WebResponseContent LocationStatus() + { + WebResponseContent content = new WebResponseContent(); + + // 鑾峰彇鎵�鏈夊簱浣嶆暟鎹� + List<DtLocationInfo> locations = BaseDal.QueryData(); + + // 鎸塋ocationStatus鍒嗙粍缁熻 + var statusGroups = locations + .GroupBy(l => l.LocationStatus) + .Select(g => new + { + Status = g.Key==0?"绌鸿揣浣�": g.Key == 1 ? "閿佸畾": g.Key == 2 ? "鏈夎揣": "鏈夎揣绂佺敤", + Count = g.Count(), + }) + .ToList(); + + // 灏嗙粺璁$粨鏋滄斁鍏ュ搷搴斿唴瀹� + content.Data = statusGroups; + + return content; + } + #endregion + + #region 鍐呴儴鏂规硶 #region 绉诲簱鏂规硶 @@ -331,6 +413,61 @@ } /// <summary> + /// 澶勭悊鍏ュ簱娌℃湁浠诲姟鐨勫簱浣嶆儏鍐� + /// </summary> + /// <param name="originalLocationID">鍘熷搴撲綅ID</param> + /// <param name="newLocationID">鏂扮殑搴撲綅ID</param> + /// <param name="outboundTask">鍑哄簱浠诲姟</param> + /// <returns>鐢熸垚鐨勭Щ搴撲换鍔℃垨鍘熷鍑哄簱浠诲姟</returns> + private async Task<Dt_Task> InHandleLocation(string originalLocationID, string newLocationID, Dt_Task inboundTask) + { + // 鍒ゆ柇璇ヤ綅缃槸鍚︽湁搴撳瓨 + var stockInfo = await _WheelsStockRepository.QueryFirstAsync(x => x.Wheels_Location == newLocationID); + + LogFactory.GetLog("妫�鏌ユ槸鍚﹂渶瑕佺Щ搴�").InfoFormat(true, "闇�瑕佺Щ搴�,鏈幏鍙栧埌鏂板簱浣嶄换鍔�", $"璇ヤ綅缃槸鍚︽湁搴撳瓨锛歿stockInfo}"); + if (stockInfo == null) + { + LogFactory.GetLog("妫�鏌ユ槸鍚﹂渶瑕佺Щ搴�").InfoFormat(true, "闇�瑕佺Щ搴�,鏈幏鍙栧埌搴撳瓨鏁版嵁", $"鐩存帴杩斿洖鍘熷厛鍑哄簱浠诲姟锛歿inboundTask}"); + // 濡傛灉娌℃湁搴撳瓨锛岀洿鎺ヨ繑鍥炲綋鍓嶅嚭搴撲换鍔� + return inboundTask; + } + else + { + // 濡傛灉鏈夊簱瀛橈紝鐢熸垚绉诲簱浠诲姟 + var emptyLocation = RequestLocation("SC1"); + if (emptyLocation == null) throw new Exception("鏆傛棤绌哄簱"); + + LogFactory.GetLog("妫�鏌ユ槸鍚﹂渶瑕佺Щ搴�").InfoFormat(true, "闇�瑕佺Щ搴�,鏌ユ壘鑳界Щ搴撹揣浣�", $"璐т綅鏁版嵁锛歿emptyLocation}"); + var taskNo = await _taskRepository.GetTaskNo(); + Dt_Task newTransferTask = new Dt_Task() + { + CreateDate = DateTime.Now, + Creater = App.User.UserName == null ? "admin" : App.User.UserName, + CurrentAddress = stockInfo.Wheels_Location, + Grade = 99, + MaterialNo = stockInfo.Wheels_Type, + NextAddress = emptyLocation.LocationCode, + PalletCode = stockInfo.Wheels_Num, + Remark = "绉诲簱", + Roadway = "SC1", + SourceAddress = stockInfo.Wheels_Location, + TaskNum = taskNo, + TargetAddress = emptyLocation.LocationCode, + TaskState = (int)TaskStatus.Created, + TaskType = (int)TaskTypeEnum.Relocation, + Dispatchertime = DateTime.Now, + }; + LogFactory.GetLog("妫�鏌ユ槸鍚﹂渶瑕佺Щ搴�").InfoFormat(true, "闇�瑕佺Щ搴�,鏂板缓绉诲簱浠诲姟", $"绉诲簱浠诲姟鏁版嵁锛歿newTransferTask}"); + + //淇敼搴撲綅鐘舵�� + emptyLocation.LocationStatus = (int)LocationEnum.FreeDisable; + BaseDal.UpdateData(emptyLocation); + + return await _taskRepository.Create(newTransferTask); + } + } + + /// <summary> /// 鏍规嵁璐т綅鏄惁闇�瑕佺Щ搴� /// </summary> /// <param name="locationID">璐т綅ID</param> @@ -361,16 +498,19 @@ if (locationInfos == null || locationInfos.Count == 0) { locationInfos = BaseDal.QueryData(x => x.LocationStatus == (int)LocationEnum.Free && x.RoadwayNo == "SC1" && x.EnalbeStatus == 1 && x.LocationType == 1); + } - var location = GetEmptyLocation(locationInfos); + var location = GetEmptyLocation(locationInfos); //鎵惧嚭璐т綅 if (location != null) { if (location.Depth == 2) { int row = location.Row; - int relativeLine = row % 2 == 1 ? row + 1 : row - 1; + //int relativeLine = row % 2 == 1 ? row + 1 : row - 1; + + int relativeLine = row == 1 ? row + 1 : row - 1; var insideLocation = BaseDal.QueryFirst(x => x.Row == relativeLine && x.Layer == location.Layer && x.Column == location.Column); -- Gitblit v1.9.3