pan
2025-11-17 f5df33d51a8555d709a4e8369fa98ce70759ddfc
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_OutboundService/SplitPackageService.cs
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Http;
using Org.BouncyCastle.Asn1.Ocsp;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -61,12 +62,31 @@
                    return WebResponseContent.Instance.Error($"拆包数量不能大于剩余锁定数量,剩余:{remainingLockQuantity}");
                var stockDetail = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
               .Where(x => x.Barcode == request.OriginalBarcode)
               .Where(x => x.Barcode == request.OriginalBarcode && x.StockId == lockInfo.StockId)
               .FirstAsync();
                if (stockDetail == null)
                    throw new Exception($"未找到条码{request.OriginalBarcode}对应的库存记录");
                var seq = await _dailySequenceService.GetNextSequenceAsync();
                // 3. ç”Ÿæˆæ–°æ¡ç 
                string newBarcode = "WSLOT" + DateTime.Now.ToString("yyyyMMdd") + seq.ToString()?.PadLeft(5, '0');
                string newBarcode = "WSLOT" + DateTime.Now.ToString("yyyyMMdd") + seq.ToString()?.PadLeft(5, '0');
                decimal remainingQty = remainingLockQuantity - request.SplitQuantity;
                // ä¸ºæ‹†åŒ…产生的新条码创建库存记录
                var newStockDetail = new Dt_StockInfoDetail
                {
                    StockId = lockInfo.StockId,
                    MaterielCode = lockInfo.MaterielCode,
                    OrderNo = lockInfo.OrderNo,
                    BatchNo = lockInfo.BatchNo,
                    StockQuantity = remainingQty,
                    OutboundQuantity = remainingQty, // é”å®šå…¨éƒ¨æ•°é‡
                    Barcode = newBarcode,
                    InboundOrderRowNo = stockDetail.InboundOrderRowNo,
                };
                await _outStockLockInfoService.Db.Insertable(newStockDetail).ExecuteCommandAsync();
                // 4. åˆ›å»ºæ–°çš„出库锁定信息(新条码)
                var newLockInfo = new Dt_OutStockLockInfo
@@ -78,9 +98,9 @@
                    MaterielCode = lockInfo.MaterielCode,
                    MaterielName = lockInfo.MaterielName,
                    StockId = lockInfo.StockId,
                    OrderQuantity = lockInfo.OrderQuantity,
                    OriginalQuantity = lockInfo.OriginalQuantity,
                    AssignQuantity = request.SplitQuantity, // æ–°æ¡ç åˆ†é…æ•°é‡
                    OrderQuantity = remainingQty,
                    OriginalQuantity = remainingQty,
                    AssignQuantity = remainingQty, // æ–°æ¡ç åˆ†é…æ•°é‡
                    PickedQty = 0, // æ–°æ¡ç æœªæ‹£é€‰
                    LocationCode = lockInfo.LocationCode,
                    PalletCode = lockInfo.PalletCode,
@@ -97,7 +117,7 @@
                await _outStockLockInfoService.Db.Insertable(newLockInfo).ExecuteCommandAsync();
                // 5. æ›´æ–°åŽŸé”å®šä¿¡æ¯çš„åˆ†é…æ•°é‡ï¼ˆå‡å°‘æ‹†åŒ…æ•°é‡ï¼‰
                lockInfo.AssignQuantity -= request.SplitQuantity;
                lockInfo.AssignQuantity = request.SplitQuantity;
                await _outStockLockInfoService.Db.Updateable(lockInfo).ExecuteCommandAsync();
                // 6. è®°å½•拆包历史(用于追踪)