From a3e64c16c5390b552816b8e619b3d58acfd960c8 Mon Sep 17 00:00:00 2001
From: pan <antony1029@163.com>
Date: 星期一, 17 十一月 2025 08:41:14 +0800
Subject: [PATCH] 提交
---
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundPickingService.cs | 80 ++++++++++++++++-----------------------
1 files changed, 33 insertions(+), 47 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_OutboundService/OutboundPickingService.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_OutboundService/OutboundPickingService.cs"
index cf875b6..06a4835 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_OutboundService/OutboundPickingService.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_OutboundService/OutboundPickingService.cs"
@@ -216,58 +216,44 @@
try
{
_unitOfWorkManage.BeginTran();
- // 1. 楠岃瘉鏉$爜鏈夋晥鎬�
+ var lockInfo = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
+ .Where(it => it.OrderNo == orderNo &&
+ it.Status == (int)OutLockStockStatusEnum.鍑哄簱涓� &&
+ it.PalletCode == palletCode &&
+ it.CurrentBarcode == barcode)
+ .FirstAsync();
+
+ if (lockInfo == null)
+ throw new Exception($"鏉$爜{barcode}涓嶅睘浜庢墭鐩榹palletCode}鎴栦笉瀛樺湪寰呭垎鎷h褰�");
+
+
+
var stockDetail = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
- .Where(x => x.Barcode == barcode)
+ .Where(x => x.Barcode == barcode && x.StockId == lockInfo.StockId)
.FirstAsync();
if (stockDetail == null)
return WebResponseContent.Instance.Error("鏃犳晥鐨勬潯鐮佹垨鐗╂枡缂栫爜");
- //// 2. 妫�鏌ュ簱瀛樺彲鐢ㄦ暟閲�
- //var availableQty = stockDetail.StockQuantity - stockDetail.OutboundQuantity;
- //if (availableQty <= 0)
- // return WebResponseContent.Instance.Error("搴撳瓨鏁伴噺涓嶈冻");
- // 3. 鏌ユ壘鐩稿叧鐨勫嚭搴撹鎯呬俊鎭�
- var outStockInfo = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
- .Where(x => x.OrderNo == orderNo &&
- x.PalletCode == palletCode &&
- x.CurrentBarcode == barcode &&
- x.Status == (int)OutLockStockStatusEnum.鍑哄簱涓� &&
- x.AssignQuantity - x.PickedQty > 0)
- .FirstAsync();
+ decimal actualQty = lockInfo.AssignQuantity - lockInfo.PickedQty;
+
+ // 4. 鏇存柊搴撳瓨
+ stockDetail.StockQuantity -= actualQty;
+ stockDetail.OutboundQuantity -= actualQty;
+ await _stockInfoDetailService.Db.Updateable(stockDetail).ExecuteCommandAsync();
+
+ lockInfo.PickedQty += actualQty;
+ lockInfo.Status = (int)OutLockStockStatusEnum.鎷i�夊畬鎴�;
+ await _outStockLockInfoService.Db.Updateable(lockInfo).ExecuteCommandAsync();
- if (outStockInfo == null)
- return WebResponseContent.Instance.Error("鏈壘鍒板搴旂殑鎷i�変俊鎭垨宸叉嫞閫夊畬鎴�");
+ await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
+ .SetColumns(it => it.PickedQty == it.PickedQty + actualQty)
+ .Where(it => it.Id == lockInfo.OrderDetailId)
+ .ExecuteCommandAsync();
- // 4. 妫�鏌ュ嚭搴撹鎯呴攣瀹氭暟閲�
- if (outStockInfo.RemainQuantity <= 0)
- return WebResponseContent.Instance.Error("璇ユ潯鐮佸凡鏃犲墿浣欏彲鎷i�夋暟閲�");
-
- // 5. 鏇存柊鍑哄簱璇︽儏鐨勫凡鎷i�夋暟閲�
- outStockInfo.PickedQty = outStockInfo.AssignQuantity;
- outStockInfo.Status = (int)OutLockStockStatusEnum.宸叉嫞閫�;
- await _outStockLockInfoService.Db.Updateable(outStockInfo).ExecuteCommandAsync();
-
- //// 6. 鏇存柊搴撳瓨鍑哄簱鏁伴噺
- //await _stockInfoDetailService.Db.Updateable<Dt_StockInfoDetail>()
- // .SetColumns(x => x.OutboundQuantity == x.OutboundQuantity + outStockInfo.AssignQuantity)
- // .Where(x => x.Id == stockDetail.Id)
- // .ExecuteCommandAsync();
-
- // 7. 鏇存柊鍑哄簱鍗曟槑缁�
- var orderDetail = await _outboundOrderDetailService.Db.Queryable<Dt_OutboundOrderDetail>()
- .Where(x => x.Id == outStockInfo.OrderDetailId)
- .FirstAsync();
- if (orderDetail != null)
- {
- orderDetail.OverOutQuantity += outStockInfo.AssignQuantity;
- orderDetail.LockQuantity -= outStockInfo.AssignQuantity;
- await _outboundOrderDetailService.Db.Updateable(orderDetail).ExecuteCommandAsync();
- }
- // 8. 妫�鏌ユ槸鍚﹀畬鎴愬嚭搴�
+
await CheckAndUpdateOrderStatus(orderNo);
//鏌ヨ浠诲姟琛�
@@ -275,19 +261,19 @@
// 9. 璁板綍鎷i�夊巻鍙�
var pickingHistory = new Dt_PickingRecord
{
- FactoryArea = outStockInfo.FactoryArea,
+ FactoryArea = lockInfo.FactoryArea,
TaskNo = task?.TaskNum ?? 0,
LocationCode = task?.SourceAddress ?? "",
StockId = stockDetail.Id,
OrderNo = orderNo,
- OrderDetailId = orderDetail?.Id ?? 0,
+ OrderDetailId = lockInfo.OrderDetailId,
PalletCode = palletCode,
Barcode = barcode,
- MaterielCode = outStockInfo.MaterielCode,
- PickQuantity = outStockInfo.AssignQuantity,
+ MaterielCode = lockInfo.MaterielCode,
+ PickQuantity = lockInfo.AssignQuantity,
PickTime = DateTime.Now,
Operator = App.User.UserName,
- OutStockLockId = outStockInfo.Id
+ OutStockLockId = lockInfo.Id
};
await Db.Insertable(pickingHistory).ExecuteCommandAsync();
--
Gitblit v1.9.3