From 68628c6cc163cddfcc745c225a9f3f34767261ef Mon Sep 17 00:00:00 2001
From: 647556386 <647556386@qq.com>
Date: 星期六, 22 十一月 2025 20:44:40 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/ZhongRui/ALDbanyunxiangmu
---
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs | 74 +++++++++++++++++++++++++++++++++----
1 files changed, 66 insertions(+), 8 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 f3e6e0a..8682865 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"
@@ -454,7 +454,7 @@
}
}
- public WebResponseContent InPickTaskCompleted(Dt_Task task)
+ public async Task<WebResponseContent> InPickTaskCompleted(Dt_Task task)
{
_logger.LogInformation($"TaskService InPickTaskCompleted: {task.TaskNum}");
//鏌ュ簱瀛�
@@ -467,7 +467,12 @@
{
return WebResponseContent.Instance.Error($"鏈壘鍒拌鎵樼洏搴撳瓨鏄庣粏淇℃伅");
}
-
+ //鏌ヨ揣浣�
+ Dt_LocationInfo locationInfo = _locationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress);
+ if (locationInfo == null)
+ {
+ return WebResponseContent.Instance.Error($"鏈壘鍒板搴旂殑缁堢偣璐т綅淇℃伅");
+ }
// 鑾峰彇鎵�鏈夊洖搴撲腑鐨勫嚭搴撻攣瀹氳褰�
var returnLocks = _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
.Where(it => it.OrderNo == task.OrderNo && it.PalletCode == task.PalletCode && it.Status == (int)OutLockStockStatusEnum.鍥炲簱涓�)
@@ -479,12 +484,8 @@
}
_outStockLockInfoService.Db.Updateable(returnLocks).ExecuteCommand();
- //鏌ヨ揣浣�
- Dt_LocationInfo locationInfo = _locationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress);
- if (locationInfo == null)
- {
- return WebResponseContent.Instance.Error($"鏈壘鍒板搴旂殑缁堢偣璐т綅淇℃伅");
- }
+ await DeleteZeroQuantityStockDetails(stockInfo.Id);
+
stockInfo.LocationCode = task.TargetAddress;
stockInfo.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
stockInfo.Details.ForEach(x =>
@@ -493,6 +494,9 @@
});
_stockService.StockInfoService.Repository.UpdateData(stockInfo);
_stockService.StockInfoDetailService.Repository.UpdateData(stockInfo.Details);
+ await ProcessStockDetailsForReturn(task, stockInfo.Id);
+
+
if (stockInfo.PalletType == PalletTypeEnum.Empty.ObjToInt())
{
@@ -511,6 +515,60 @@
return WebResponseContent.Instance.OK();
}
+ /// <summary>
+ /// 鍒犻櫎搴撳瓨鏁颁负0鐨勫簱瀛樻槑缁嗚褰�
+ /// </summary>
+ private async Task DeleteZeroQuantityStockDetails(int stockId)
+ {
+ try
+ {
+ // 鍒犻櫎搴撳瓨鏁伴噺涓�0鐨勮褰�
+ var deleteCount = await _stockService.StockInfoDetailService.Db.Deleteable<Dt_StockInfoDetail>()
+ .Where(x => x.StockId == stockId &&
+ x.StockQuantity == 0 &&
+ (x.Status==StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt()|| x.Status==
+ StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt())) // 鍙垹闄ゅ凡瀹屾垚鐘舵�佺殑闆跺簱瀛�
+ .ExecuteCommandAsync();
+
+ if (deleteCount > 0)
+ {
+ _logger.LogInformation($"鍒犻櫎{deleteCount}鏉¢浂搴撳瓨鏄庣粏璁板綍 - StockId: {stockId}");
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogWarning($"鍒犻櫎闆跺簱瀛樿褰曞け璐� - StockId: {stockId}, Error: {ex.Message}");
+ // 娉ㄦ剰锛氬垹闄ゅけ璐ヤ笉搴旇褰卞搷涓绘祦绋嬶紝璁板綍鏃ュ織鍚庣户缁�
+ }
+ }
+ /// <summary>
+ /// 澶勭悊鍥炲簱鐩稿叧鐨勬墍鏈夊簱瀛樻槑缁嗙姸鎬佸彉鏇�
+ /// </summary>
+ private async Task ProcessStockDetailsForReturn(Dt_Task returnTask, int stockId)
+ {
+ // 鑾峰彇璇ユ墭鐩樹笅鎵�鏈夐渶瑕佸洖搴撶殑搴撳瓨鏄庣粏
+ var stockDetails = await _stockService.StockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
+ .Where(x => x.StockId == stockId &&
+ x.StockQuantity > 0 &&
+ ( x.Status == StockStatusEmun.鍑哄簱閿佸畾.ObjToInt()|| x.Status==
+ StockStatusEmun.鍏ュ簱纭.ObjToInt())) // 鍖呮嫭鍑哄簱閿佸畾鍜屽叆搴撶‘璁ょ殑
+ .ToListAsync();
+
+ foreach (var detail in stockDetails)
+ {
+
+ detail.Status = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
+ detail.OutboundQuantity = 0; // 娓呯┖鍑哄簱鏁伴噺
+
+ _logger.LogInformation($"鏇存柊搴撳瓨鏄庣粏鐘舵�� - 鏉$爜: {detail.Barcode}, 鏁伴噺: {detail.StockQuantity}");
+ }
+
+ if (stockDetails.Any())
+ {
+ await _stockService.StockInfoDetailService.Db.Updateable(stockDetails).ExecuteCommandAsync();
+ _logger.LogInformation($"鍏辨洿鏂皗stockDetails.Count}涓簱瀛樻槑缁嗙姸鎬佷负鍏ュ簱瀹屾垚");
+ }
+ }
public async Task<WebResponseContent> OutEmptyTaskCompleted(Dt_Task task)
{
WebResponseContent content = new WebResponseContent();
--
Gitblit v1.9.3