From 461524a7a1def4532b9af4ab40733f899f360db7 Mon Sep 17 00:00:00 2001
From: heshaofeng <heshaofeng@hnkhzn.com>
Date: 星期四, 09 四月 2026 14:39:45 +0800
Subject: [PATCH] Merge branch 'htq20251215' of http://115.159.85.185:8098/r/ZhongRui/ALDbanyunxiangmu into htq20251215
---
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs | 134 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 133 insertions(+), 1 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
index 9b7fa57..d195df9 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
@@ -311,7 +311,7 @@
stockInfo.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
stockInfo.Details.ForEach(x =>
{
- x.Status = StockStatusEmun.鍏ュ簱纭.ObjToInt();
+ x.Status = inboundOrders.FirstOrDefault().CreateType == (int)OrderCreateTypeEnum.CreateInSystem ? StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt():StockStatusEmun.鍏ュ簱纭.ObjToInt();
});
_stockService.StockInfoService.Repository.UpdateData(stockInfo);
_stockService.StockInfoDetailService.Repository.UpdateData(stockInfo.Details);
@@ -2711,6 +2711,138 @@
return await Task.FromResult(WebResponseContent.Instance.Error($"绉诲簱浠诲姟澶勭悊澶辫触锛歿ex.Message}"));
}
}
+
+
+ /// <summary>
+ /// 璺ㄥ尯鍩熺Щ搴撲换鍔″畬鎴�
+ /// </summary>
+ /// <param name="task"></param>
+ /// <returns></returns>
+ public async Task<WebResponseContent> CrossAreaRelocationTaskCompleted(Dt_Task task)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ if (task == null || string.IsNullOrEmpty(task.PalletCode) || string.IsNullOrEmpty(task.TargetAddress))
+ {
+ return WebResponseContent.Instance.Error("璺ㄥ尯鍩熺Щ搴撲换鍔′俊鎭笉瀹屾暣锛堟墭鐩樺彿/鐩爣璐т綅涓虹┖锛�");
+ }
+
+ // 2. 鏌ヨ鎵樼洏搴撳瓨淇℃伅
+ Dt_StockInfo stockInfo = await _stockRepository.Db.Queryable<Dt_StockInfo>()
+ .Includes(x => x.Details)
+ .Where(x => x.PalletCode == task.PalletCode)
+ .FirstAsync();
+
+ if (stockInfo == null)
+ {
+ return WebResponseContent.Instance.Error($"鏈壘鍒版墭鐩榌{task.PalletCode}]瀵瑰簲鐨勫簱瀛樹俊鎭�");
+ }
+
+ // 闈炵┖鎵樼洏蹇呴』鏈夋槑缁�
+ if (stockInfo.Details.Count == 0 && stockInfo.PalletType != PalletTypeEnum.Empty.ObjToInt())
+ {
+ _logger.LogInformation($"CrossAreaRelocationTaskCompleted: 鏈壘鍒拌鎵樼洏搴撳瓨鏄庣粏淇℃伅.{task.TaskNum}");
+ return WebResponseContent.Instance.Error($"鏈壘鍒拌鎵樼洏[{task.PalletCode}]搴撳瓨鏄庣粏淇℃伅");
+ }
+
+ // 3. 鏌ヨ鐩爣璐т綅 + 鍘熻揣浣嶄俊鎭�
+ Dt_LocationInfo targetLocationInfo = _locationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress);
+ if (targetLocationInfo == null)
+ {
+ return content.Error($"鏈壘鍒板搴旂殑缁堢偣璐т綅[{task.TargetAddress}]淇℃伅");
+ }
+
+ // 鍘熻揣浣嶄俊鎭�
+ Dt_LocationInfo oldLocationInfo = null;
+ if (!string.IsNullOrEmpty(stockInfo.LocationCode))
+ {
+ oldLocationInfo = _locationInfoService.Repository.QueryFirst(x => x.LocationCode == stockInfo.LocationCode);
+ if (oldLocationInfo == null)
+ {
+ return content.Error($"鏈壘鍒板師璐т綅[{stockInfo.LocationCode}]淇℃伅");
+ }
+ }
+
+ // 4. 璐т綅鐘舵�佹牎楠�
+ if (targetLocationInfo.LocationStatus == LocationStatusEnum.InStock.ObjToInt())
+ {
+ return WebResponseContent.Instance.Error($"鐩爣璐т綅[{task.TargetAddress}]鐘舵�佷笉姝g‘锛堝綋鍓嶄负宸插崰鐢級");
+ }
+
+ // 5. 寮�鍚簨鍔″鐞嗘牳蹇冮�昏緫
+ _unitOfWorkManage.BeginTran();
+
+ // 5.1 鐩爣璐т綅鏇存柊涓哄崰鐢�
+ var beforeTargetLocationStatus = targetLocationInfo.LocationStatus;
+ targetLocationInfo.LocationStatus = stockInfo.PalletType == PalletTypeEnum.Empty.ObjToInt()
+ ? LocationStatusEnum.Pallet.ObjToInt()
+ : LocationStatusEnum.InStock.ObjToInt();
+ _locationInfoService.Repository.UpdateData(targetLocationInfo);
+
+ // 5.2 鍘熻揣浣嶉噴鏀剧┖闂�
+ int beforeOldLocationStatus = 0;
+ if (oldLocationInfo != null)
+ {
+ beforeOldLocationStatus = oldLocationInfo.LocationStatus;
+ oldLocationInfo.LocationStatus = LocationStatusEnum.Free.ObjToInt();
+ _locationInfoService.Repository.UpdateData(oldLocationInfo);
+ }
+
+ // 5.3 鏇存柊搴撳瓨锛氱粦瀹氭柊璐т綅 + 鎭㈠姝e父鐘舵��
+ string oldLocationCode = stockInfo.LocationCode;
+ stockInfo.LocationCode = targetLocationInfo.LocationCode;
+ stockInfo.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
+ stockInfo.LocationType = targetLocationInfo.LocationType;
+ _stockRepository.UpdateData(stockInfo);
+
+ // 5.4 浠诲姟鏍囪涓哄畬鎴�
+ task.TaskStatus = TaskStatusEnum.Finish.ObjToInt();
+ var result = _task_HtyService.DeleteAndMoveIntoHty(task, OperateTypeEnum.鑷姩瀹屾垚);
+
+ // 鎻愪氦浜嬪姟
+ _unitOfWorkManage.CommitTran();
+
+ // 浠诲姟褰掓。澶辫触鍒欏垹闄�
+ if (!result)
+ {
+ await Db.Deleteable(task).ExecuteCommandAsync();
+ }
+
+ // 璁板綍璐т綅鐘舵�佸彉鏇存棩蹇�
+ try
+ {
+ _locationStatusChangeRecordService.AddLocationStatusChangeRecord(
+ targetLocationInfo,
+ beforeTargetLocationStatus,
+ StockChangeType.Inbound.ObjToInt(),
+ $"璺ㄥ尯鍩熺Щ搴撳叆搴擄紙鍘熻揣浣嶏細{oldLocationCode}锛�",
+ task.TaskNum);
+
+ if (oldLocationInfo != null)
+ {
+ _locationStatusChangeRecordService.AddLocationStatusChangeRecord(
+ oldLocationInfo,
+ beforeOldLocationStatus,
+ StockChangeType.Outbound.ObjToInt(),
+ $"璺ㄥ尯鍩熺Щ搴撳嚭搴擄紙鐩爣璐т綅锛歿targetLocationInfo.LocationCode}锛�",
+ task.TaskNum);
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogInformation($"CrossAreaRelocationTaskCompleted 璁板綍鏃ュ織寮傚父锛歿ex.Message}");
+ }
+
+ return content.OK("璺ㄥ尯鍩熺Щ搴撲换鍔″畬鎴�");
+ }
+ catch (Exception ex)
+ {
+ _unitOfWorkManage.RollbackTran();
+ _logger.LogError($"CrossAreaRelocationTaskCompleted 澶勭悊澶辫触锛歿ex.Message}", ex);
+ return await Task.FromResult(WebResponseContent.Instance.Error($"璺ㄥ尯鍩熺Щ搴撲换鍔″鐞嗗け璐ワ細{ex.Message}"));
+ }
+ }
}
}
--
Gitblit v1.9.3