From 7e4e747ae508578c15fc93a40a9cb0de289706bd Mon Sep 17 00:00:00 2001
From: pan <antony1029@163.com>
Date: 星期三, 26 十一月 2025 00:45:07 +0800
Subject: [PATCH] 提交

---
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundPickingService.cs |  291 ++++++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 221 insertions(+), 70 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 01a0644..81def2c 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"
@@ -237,7 +237,7 @@
 
                 _unitOfWorkManage.CommitTran();
 
-                return WebResponseContent.Instance.OK($"鍙栨秷鍒嗘嫞鎴愬姛锛屾仮澶嶆暟閲忥細{pickingRecord.PickQuantity}");
+                return WebResponseContent.Instance.OK($"鍙栨秷鍒嗘嫞鎴愬姛");
             }
             catch (Exception ex)
             {
@@ -295,7 +295,7 @@
 
 
                 // 鍒涘缓鍥炲簱浠诲姟
-                await CreateReturnTaskAndHandleESS(orderNo, palletCode, task, TaskTypeEnum.InPick,task.PalletType);
+                await CreateReturnTaskAndHandleESS(orderNo, palletCode, task, TaskTypeEnum.InPick, task.PalletType);
 
                 // 鏇存柊璁㈠崟鐘舵�侊紙涓嶈Е鍙慚ES鍥炰紶锛�
                 await UpdateOrderStatusForReturn(orderNo);
@@ -738,7 +738,73 @@
         #endregion
 
         #region 鍙栨秷鍒嗘嫞绉佹湁鏂规硶
+        private async Task<ValidationResult<bool>> ValidateDataConsistencyBeforeCancel(CancelPickingContext context)
+        {
+            try
+            {
+                // 1. 楠岃瘉璁㈠崟鏄庣粏鏁版嵁
+                var currentOrderDetail = await _outboundOrderDetailService.Db.Queryable<Dt_OutboundOrderDetail>()
+                    .FirstAsync(x => x.Id == context.OrderDetail.Id);
 
+                if (currentOrderDetail.OverOutQuantity < context.PickingRecord.PickQuantity)
+                    return ValidationResult<bool>.Error($"璁㈠崟鏄庣粏宸插嚭搴撴暟閲�({currentOrderDetail.OverOutQuantity})灏忎簬鍙栨秷鏁伴噺({context.PickingRecord.PickQuantity})");
+
+                if (currentOrderDetail.PickedQty < context.PickingRecord.PickQuantity)
+                    return ValidationResult<bool>.Error($"璁㈠崟鏄庣粏宸叉嫞閫夋暟閲�({currentOrderDetail.PickedQty})灏忎簬鍙栨秷鏁伴噺({context.PickingRecord.PickQuantity})");
+
+                // 2. 楠岃瘉閿佸畾淇℃伅鏁版嵁
+                var currentLockInfo = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
+                    .FirstAsync(x => x.Id == context.LockInfo.Id);
+
+                if (currentLockInfo.PickedQty < context.PickingRecord.PickQuantity)
+                    return ValidationResult<bool>.Error($"閿佸畾淇℃伅宸叉嫞閫夋暟閲�({currentLockInfo.PickedQty})灏忎簬鍙栨秷鏁伴噺({context.PickingRecord.PickQuantity})");
+
+                // 3. 楠岃瘉搴撳瓨鏁版嵁
+                var currentStockDetail = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
+                    .FirstAsync(x => x.Barcode == context.PickingRecord.Barcode && x.StockId == context.PickingRecord.StockId);
+
+                if (currentStockDetail == null)
+                    return ValidationResult<bool>.Error($"鏈壘鍒板搴旂殑搴撳瓨鏄庣粏璁板綍");
+
+                if (currentStockDetail.Status == StockStatusEmun.鍏ュ簱纭.ObjToInt() ||
+                    currentStockDetail.Status == StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt())
+                    return ValidationResult<bool>.Error($"鏉$爜{context.PickingRecord.Barcode}宸茬粡鍥炲簱锛屾棤娉曞彇娑堝垎鎷�");
+
+                // 4. 楠岃瘉鐘舵�佹祦杞殑鍚堟硶鎬�
+                if (!await CanCancelPicking(currentLockInfo, currentStockDetail))
+                    return ValidationResult<bool>.Error($"褰撳墠鐘舵�佷笉鍏佽鍙栨秷鍒嗘嫞");
+
+                return ValidationResult<bool>.Success(true);
+            }
+            catch (Exception ex)
+            {
+                _logger.LogError($"鍙栨秷鍒嗘嫞鏁版嵁涓�鑷存�ч獙璇佸け璐�: {ex.Message}");
+                return ValidationResult<bool>.Error($"鏁版嵁楠岃瘉澶辫触: {ex.Message}");
+            }
+        }
+
+        private async Task<bool> CanCancelPicking(Dt_OutStockLockInfo lockInfo, Dt_StockInfoDetail stockDetail)
+        {
+            // 閿佸畾淇℃伅鐘舵�佹鏌�
+            if (lockInfo.Status != (int)OutLockStockStatusEnum.鎷i�夊畬鎴�)
+                return false;
+
+            // 搴撳瓨鐘舵�佹鏌�
+            if (stockDetail.Status == StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt())
+                return false;
+
+            // 濡傛灉鏄媶鍖呰褰曪紝杩橀渶瑕佹鏌ョ埗閿佸畾淇℃伅鐘舵��
+            if (lockInfo.IsSplitted == 1 && lockInfo.ParentLockId.HasValue)
+            {
+                var parentLock = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
+                    .FirstAsync(x => x.Id == lockInfo.ParentLockId.Value);
+
+                if (parentLock == null || parentLock.Status == (int)OutLockStockStatusEnum.鍥炲簱涓�)
+                    return false;
+            }
+
+            return true;
+        }
         private async Task<ValidationResult<(Dt_PickingRecord, Dt_OutStockLockInfo, Dt_OutboundOrderDetail)>> ValidateCancelRequest(string orderNo, string palletCode, string barcode)
         {
             // 鍩虹鍙傛暟楠岃瘉
@@ -846,30 +912,25 @@
                    stockDetail.Status == StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
         }
         private async Task ExecuteCancelLogic(Dt_OutStockLockInfo lockInfo, Dt_PickingRecord pickingRecord,
-            Dt_OutboundOrderDetail orderDetail, string orderNo)
+        Dt_OutboundOrderDetail orderDetail, string orderNo)
         {
             decimal cancelQty = pickingRecord.PickQuantity;
 
-            var currentStockDetail = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
-        .Where(it => it.Barcode == pickingRecord.Barcode && it.StockId == pickingRecord.StockId)
-        .FirstAsync();
-
-            if (currentStockDetail != null &&
-                (currentStockDetail.Status == StockStatusEmun.鍏ュ簱纭.ObjToInt() ||
-                 currentStockDetail.Status == StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt()))
+            // 1. 鏁版嵁涓�鑷存�ч獙璇�
+            var context = new CancelPickingContext
             {
-                throw new Exception($"鏉$爜{pickingRecord.Barcode}宸茬粡鍥炲簱锛屾棤娉曞彇娑堝垎鎷�");
-            }
-            //   妫�鏌ュ彇娑堝悗鏁伴噺涓嶄細涓鸿礋鏁�
-            decimal newOverOutQuantity = orderDetail.OverOutQuantity - cancelQty;
-            decimal newPickedQty = orderDetail.PickedQty - cancelQty;
+                LockInfo = lockInfo,
+                PickingRecord = pickingRecord,
+                OrderDetail = orderDetail,
+                OrderNo = orderNo,
+                CancelQuantity = cancelQty
+            };
 
-            if (newOverOutQuantity < 0 || newPickedQty < 0)
-            {
-                throw new Exception($"鍙栨秷鍒嗘嫞灏嗗鑷存暟鎹紓甯革細宸插嚭搴搟newOverOutQuantity}锛屽凡鎷i�墈newPickedQty}");
-            }
+            var validationResult = await ValidateDataConsistencyBeforeCancel(context);
+            if (!validationResult.IsValid)
+                throw new Exception(validationResult.ErrorMessage);
 
-            //  澶勭悊涓嶅悓绫诲瀷鐨勫彇娑�
+            // 2. 澶勭悊涓嶅悓绫诲瀷鐨勫彇娑�
             if (lockInfo.IsSplitted == 1 && lockInfo.ParentLockId.HasValue)
             {
                 await HandleSplitBarcodeCancel(lockInfo, pickingRecord, cancelQty);
@@ -879,16 +940,23 @@
                 await HandleNormalBarcodeCancel(lockInfo, pickingRecord, cancelQty);
             }
 
-            // 鏇存柊璁㈠崟鏄庣粏
+            //  鏇存柊璁㈠崟鏄庣粏
             await UpdateOrderDetailOnCancel(pickingRecord.OrderDetailId, cancelQty);
 
             //  鍒犻櫎鎷i�夎褰�
-            await Db.Deleteable<Dt_PickingRecord>()
+            var deleteResult = await Db.Deleteable<Dt_PickingRecord>()
                 .Where(x => x.Id == pickingRecord.Id)
                 .ExecuteCommandAsync();
 
-            //  閲嶆柊妫�鏌ヨ鍗曠姸鎬�
+            if (deleteResult <= 0)
+                throw new Exception("鍒犻櫎鎷i�夎褰曞け璐�");
+
+            _logger.LogInformation($"鍒犻櫎鎷i�夎褰� - 璁板綍ID: {pickingRecord.Id}, 鏉$爜: {pickingRecord.Barcode}");
+
+            // 閲嶆柊妫�鏌ヨ鍗曠姸鎬�
             await UpdateOrderStatusForReturn(orderNo);
+
+
         }
 
         private async Task HandleSplitBarcodeCancel(Dt_OutStockLockInfo lockInfo, Dt_PickingRecord pickingRecord, decimal cancelQty)
@@ -901,61 +969,85 @@
             if (parentLockInfo == null)
                 throw new Exception("鏈壘鍒扮埗閿佸畾淇℃伅锛屾棤娉曞彇娑堟媶鍖呭垎鎷�");
 
+            // 妫�鏌ョ埗鏉$爜鍜屾媶鍖呮潯鐮佺殑鐘舵��
             if (await IsLockInfoReturned(parentLockInfo))
-            {
                 throw new Exception($"鐖舵潯鐮亄parentLockInfo.CurrentBarcode}宸茬粡鍥炲簱锛屾棤娉曞彇娑堟媶鍖呭垎鎷�");
-            }
+
             if (await IsLockInfoReturned(lockInfo))
-            {
                 throw new Exception($"鎷嗗寘鏉$爜{lockInfo.CurrentBarcode}宸茬粡鍥炲簱锛屾棤娉曞彇娑堟媶鍖呭垎鎷�");
-            }
+
             // 鎭㈠鐖堕攣瀹氫俊鎭殑鍒嗛厤鏁伴噺
             parentLockInfo.AssignQuantity += cancelQty;
+            parentLockInfo.Status = (int)OutLockStockStatusEnum.鍑哄簱涓�; // 鎭㈠涓哄嚭搴撲腑鐘舵��
             await _outStockLockInfoService.Db.Updateable(parentLockInfo).ExecuteCommandAsync();
 
-            // 鎭㈠搴撳瓨
-            var stockDetail = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
+            // 鎭㈠鐖舵潯鐮佸簱瀛�
+            var parentStockDetail = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
                 .Where(x => x.Barcode == parentLockInfo.CurrentBarcode && x.StockId == parentLockInfo.StockId)
                 .FirstAsync();
 
-            if (stockDetail != null)
+            if (parentStockDetail != null)
             {
-                stockDetail.StockQuantity += cancelQty;
-                stockDetail.OutboundQuantity = stockDetail.StockQuantity;
-                stockDetail.Status = StockStatusEmun.鍑哄簱閿佸畾.ObjToInt();
-                await _stockInfoDetailService.Db.Updateable(stockDetail).ExecuteCommandAsync();
+                parentStockDetail.StockQuantity += cancelQty;
+                parentStockDetail.OutboundQuantity = parentStockDetail.StockQuantity;
+                parentStockDetail.Status = StockStatusEmun.鍑哄簱閿佸畾.ObjToInt();
+                await _stockInfoDetailService.Db.Updateable(parentStockDetail).ExecuteCommandAsync();
+
+                _logger.LogInformation($"鎭㈠鐖舵潯鐮佸簱瀛� - 鏉$爜: {parentStockDetail.Barcode}, 鎭㈠鏁伴噺: {cancelQty}, 鏂板簱瀛�: {parentStockDetail.StockQuantity}");
+            }
+
+            // 澶勭悊鎷嗗寘浜х敓鐨勬柊鏉$爜搴撳瓨
+            var splitStockDetail = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
+                .Where(x => x.Barcode == lockInfo.CurrentBarcode && x.StockId == lockInfo.StockId)
+                .FirstAsync();
+
+            if (splitStockDetail != null)
+            {
+                // 鍒犻櫎鎷嗗寘浜х敓鐨勬柊鏉$爜搴撳瓨璁板綍
+                await _stockInfoDetailService.Db.Deleteable(splitStockDetail).ExecuteCommandAsync();
+                _logger.LogInformation($"鍒犻櫎鎷嗗寘鏂版潯鐮佸簱瀛� - 鏉$爜: {splitStockDetail.Barcode}");
             }
 
             // 鏇存柊鎷嗗寘璁板綍鐘舵��
-            await _splitPackageService.Db.Updateable<Dt_SplitPackageRecord>()
+            var updateCount = await _splitPackageService.Db.Updateable<Dt_SplitPackageRecord>()
                 .SetColumns(x => new Dt_SplitPackageRecord
                 {
                     Status = (int)SplitPackageStatusEnum.宸叉挙閿�,
                     IsReverted = true,
+                    Operator = App.User.UserName,
+                    RevertTime = DateTime.Now
                 })
                 .Where(x => x.NewBarcode == lockInfo.CurrentBarcode && !x.IsReverted)
                 .ExecuteCommandAsync();
+
+            _logger.LogInformation($"鏇存柊鎷嗗寘璁板綍鐘舵�� - 鏇存柊璁板綍鏁�: {updateCount}");
 
             // 鍒犻櫎鎷嗗寘浜х敓鐨勯攣瀹氫俊鎭�
             await _outStockLockInfoService.Db.Deleteable<Dt_OutStockLockInfo>()
                 .Where(x => x.Id == lockInfo.Id)
                 .ExecuteCommandAsync();
 
-            await UpdateOrderDetailOnCancel(pickingRecord.OrderDetailId, cancelQty);
+            _logger.LogInformation($"鍒犻櫎鎷嗗寘閿佸畾淇℃伅 - 閿佸畾ID: {lockInfo.Id}, 鏉$爜: {lockInfo.CurrentBarcode}");
         }
-
         private async Task HandleNormalBarcodeCancel(Dt_OutStockLockInfo lockInfo, Dt_PickingRecord pickingRecord, decimal cancelQty)
         {
             if (await IsLockInfoReturned(lockInfo))
-            {
                 throw new Exception($"鏉$爜{lockInfo.CurrentBarcode}宸茬粡鍥炲簱锛屾棤娉曞彇娑堝垎鎷�");
-            }
+
             // 鎭㈠閿佸畾淇℃伅
             lockInfo.PickedQty -= cancelQty;
             if (lockInfo.PickedQty < 0) lockInfo.PickedQty = 0;
 
-            lockInfo.Status = (int)OutLockStockStatusEnum.鍑哄簱涓�;
+            // 鍙湁褰撴嫞閫夋暟閲忓畬鍏ㄥ彇娑堟椂鎵嶆仮澶嶇姸鎬�
+            if (lockInfo.PickedQty == 0)
+            {
+                lockInfo.Status = (int)OutLockStockStatusEnum.鍑哄簱涓�;
+            }
+
+            lockInfo.Operator = App.User.UserName;
             await _outStockLockInfoService.Db.Updateable(lockInfo).ExecuteCommandAsync();
+
+            _logger.LogInformation($"鎭㈠閿佸畾淇℃伅 - 閿佸畾ID: {lockInfo.Id}, 鎵e噺鎷i�夋暟閲�: {cancelQty}, 鏂板凡鎷i�夋暟閲�: {lockInfo.PickedQty}");
 
             // 鎭㈠搴撳瓨
             var stockDetail = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
@@ -966,36 +1058,57 @@
             {
                 stockDetail.StockQuantity += cancelQty;
                 stockDetail.OutboundQuantity = stockDetail.StockQuantity;
-                stockDetail.Status = StockStatusEmun.鍑哄簱閿佸畾.ObjToInt();
+
+                // 鎭㈠搴撳瓨鐘舵��
+                if (stockDetail.Status == StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt())
+                {
+                    stockDetail.Status = StockStatusEmun.鍑哄簱閿佸畾.ObjToInt();
+                }
+
                 await _stockInfoDetailService.Db.Updateable(stockDetail).ExecuteCommandAsync();
+
+                _logger.LogInformation($"鎭㈠搴撳瓨 - 鏉$爜: {stockDetail.Barcode}, 鎭㈠鏁伴噺: {cancelQty}, " +
+                                      $"鏂板簱瀛�: {stockDetail.StockQuantity}, 鏂扮姸鎬�: {stockDetail.Status}");
+            }
+            else
+            {
+                _logger.LogWarning($"鏈壘鍒板簱瀛樿褰� - 鏉$爜: {pickingRecord.Barcode}, 搴撳瓨ID: {pickingRecord.StockId}");
             }
         }
-
         private async Task UpdateOrderDetailOnCancel(int orderDetailId, decimal cancelQty)
         {
-            // 鑾峰彇鏈�鏂扮殑璁㈠崟鏄庣粏鏁版嵁
+            // 鑾峰彇鏈�鏂扮殑璁㈠崟鏄庣粏鏁版嵁锛堝甫閿侊級
             var currentOrderDetail = await _outboundOrderDetailService.Db.Queryable<Dt_OutboundOrderDetail>()
+                .With(SqlWith.RowLock)
                 .FirstAsync(x => x.Id == orderDetailId);
 
             decimal newOverOutQuantity = currentOrderDetail.OverOutQuantity - cancelQty;
             decimal newPickedQty = currentOrderDetail.PickedQty - cancelQty;
 
-            // 妫�鏌ュ彇娑堝悗鏁伴噺涓嶄細涓鸿礋鏁�
-            if (newOverOutQuantity < 0 || newPickedQty < 0)
-            {
-                throw new Exception($"鍙栨秷鍒嗘嫞灏嗗鑷村凡鍑哄簱鏁伴噺({newOverOutQuantity})鎴栧凡鎷i�夋暟閲�({newPickedQty})涓鸿礋鏁�");
-            }
+            // 涓ユ牸妫�鏌ュ彇娑堝悗鏁伴噺涓嶄細涓鸿礋鏁�
+            if (newOverOutQuantity < 0)
+                throw new Exception($"鍙栨秷鍒嗘嫞灏嗗鑷村凡鍑哄簱鏁伴噺({newOverOutQuantity})涓鸿礋鏁�");
 
-            await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
+            if (newPickedQty < 0)
+                throw new Exception($"鍙栨秷鍒嗘嫞灏嗗鑷村凡鎷i�夋暟閲�({newPickedQty})涓鸿礋鏁�");
+
+            // 鏇存柊璁㈠崟鏄庣粏
+            var updateResult = await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
                 .SetColumns(it => new Dt_OutboundOrderDetail
                 {
                     PickedQty = newPickedQty,
-                    OverOutQuantity = newOverOutQuantity,
+                    OverOutQuantity = newOverOutQuantity
                 })
                 .Where(it => it.Id == orderDetailId)
                 .ExecuteCommandAsync();
-        }
 
+            if (updateResult <= 0)
+                throw new Exception("鏇存柊璁㈠崟鏄庣粏澶辫触");
+
+            _logger.LogInformation($"鏇存柊璁㈠崟鏄庣粏 - OrderDetailId: {orderDetailId}, " +
+                                  $"鎵e噺宸插嚭搴�: {cancelQty}, 鏂板凡鍑哄簱: {newOverOutQuantity}, " +
+                                  $"鎵e噺宸叉嫞閫�: {cancelQty}, 鏂板凡鎷i��: {newPickedQty}");
+        }
         #endregion
 
         #region 鍥炲簱鎿嶄綔绉佹湁鏂规硶
@@ -1121,7 +1234,7 @@
                 var targetAddress = originalTask.TargetAddress;
 
                 await CleanupZeroStockData(stockInfoId);
-             
+
 
                 var emptystockInfo = new Dt_StockInfo() { PalletType = PalletTypeEnum.Empty.ObjToInt(), StockStatus = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt(), PalletCode = palletCode, LocationType = locationtype };
                 emptystockInfo.Details = new List<Dt_StockInfoDetail>();
@@ -1129,7 +1242,7 @@
                 //绌烘墭鐩樺浣曞鐞�  杩樻湁涓�涓嚭搴撲换鍔¤澶勭悊銆�
                 originalTask.PalletType = PalletTypeEnum.Empty.ObjToInt();
 
-                await CreateReturnTaskAndHandleESS(orderNo, palletCode, originalTask, TaskTypeEnum.InEmpty,PalletTypeEnum.Empty.ObjToInt());
+                await CreateReturnTaskAndHandleESS(orderNo, palletCode, originalTask, TaskTypeEnum.InEmpty, PalletTypeEnum.Empty.ObjToInt());
 
             }
             catch (Exception ex)
@@ -1342,7 +1455,7 @@
         /// <param name="originalTask"></param>
         /// <param name="analysis"></param>
         /// <returns></returns>
-        private async Task CreateReturnTaskAndHandleESS(string orderNo, string palletCode, Dt_Task originalTask, TaskTypeEnum taskTypeEnum,int palletType)
+        private async Task CreateReturnTaskAndHandleESS(string orderNo, string palletCode, Dt_Task originalTask, TaskTypeEnum taskTypeEnum, int palletType)
         {
             var firstLocation = await _locationInfoService.Db.Queryable<Dt_LocationInfo>()
                 .FirstAsync(x => x.LocationCode == originalTask.SourceAddress);
@@ -1365,7 +1478,7 @@
                 TaskType = taskTypeEnum.ObjToInt(),
                 PalletType = palletType,
                 WarehouseId = originalTask.WarehouseId
-                
+
             };
             // 淇濆瓨鍥炲簱浠诲姟
             await _taskRepository.Db.Insertable(returnTask).ExecuteCommandAsync();
@@ -1399,15 +1512,15 @@
                     containerCode = palletCode
                 });
 
-                if (moveResult)
+                //if (moveResult)
+                //{
+                // 2. 鍒涘缓鍥炲簱浠诲姟
+                var essTask = new TaskModel()
                 {
-                    // 2. 鍒涘缓鍥炲簱浠诲姟
-                    var essTask = new TaskModel()
-                    {
-                        taskType = "putaway",
-                        taskGroupCode = "",
-                        groupPriority = 0,
-                        tasks = new List<TasksType>{  new() {
+                    taskType = "putaway",
+                    taskGroupCode = "",
+                    groupPriority = 0,
+                    tasks = new List<TasksType>{  new() {
                             taskCode = returnTask.TaskNum.ToString(),
                             taskPriority = 0,
                             taskDescribe = new TaskDescribeType
@@ -1421,11 +1534,11 @@
                                 storageTag = ""
                             }
                         } }
-                    };
+                };
 
-                    var resultTask = await _eSSApiService.CreateTaskAsync(essTask);
-                    _logger.LogInformation($"ReturnRemaining 鍒涘缓浠诲姟鎴愬姛: {resultTask}");
-                }
+                var resultTask = await _eSSApiService.CreateTaskAsync(essTask);
+                _logger.LogInformation($"ReturnRemaining 鍒涘缓浠诲姟鎴愬姛: {resultTask}");
+                //}
             }
             catch (Exception ex)
             {
@@ -1468,7 +1581,11 @@
                 if (outboundOrder.OrderStatus != newStatus)
                 {
                     await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
-                        .SetColumns(x => x.OrderStatus == newStatus)
+                        .SetColumns(x => new Dt_OutboundOrder
+                        {
+                            OrderStatus = newStatus,
+                            Operator = App.User.UserName,
+                        })
                         .Where(x => x.OrderNo == orderNo)
                         .ExecuteCommandAsync();
 
@@ -1517,7 +1634,11 @@
                 if (outboundOrder.OrderStatus != newStatus)
                 {
                     await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
-                        .SetColumns(x => x.OrderStatus == newStatus)
+                          .SetColumns(x => new Dt_OutboundOrder
+                          {
+                              OrderStatus = newStatus,
+                              Operator = App.User.UserName,
+                          })
                         .Where(x => x.OrderNo == orderNo)
                         .ExecuteCommandAsync();
 
@@ -1590,7 +1711,12 @@
                         .ExecuteCommandAsync();
 
                     await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
-                        .SetColumns(x => x.ReturnToMESStatus == 1)
+                          .SetColumns(x => new Dt_OutboundOrder
+                          {
+                              ReturnToMESStatus = 1,
+                              Operator = App.User.UserName,
+                          })
+
                         .Where(x => x.OrderNo == orderNo)
                         .ExecuteCommandAsync();
                 }
@@ -1732,6 +1858,7 @@
             if (outboundOrder != null && allCompleted && outboundOrder.OrderStatus != (int)OutOrderStatusEnum.鍑哄簱瀹屾垚)
             {
                 outboundOrder.OrderStatus = (int)OutOrderStatusEnum.鍑哄簱瀹屾垚;
+                outboundOrder.Operator = App.User.UserName;
                 await _outboundOrderService.Db.Updateable(outboundOrder).ExecuteCommandAsync();
 
                 _logger.LogInformation($"璁㈠崟 {orderNo} 宸叉爣璁颁负鍑哄簱瀹屾垚");
@@ -2159,5 +2286,29 @@
         public bool CanReturn => HasItemsToReturn && !HasActiveTasks;
         public bool CanRemove => IsEmptyPallet && !HasActiveTasks;
     }
+    public class PickingContext
+    {
+        public string OrderNo { get; set; }
+        public string PalletCode { get; set; }
+        public string Barcode { get; set; }
+        public string Operator { get; set; }
+        public Dt_OutStockLockInfo LockInfo { get; set; }
+        public Dt_OutboundOrderDetail OrderDetail { get; set; }
+        public Dt_StockInfoDetail StockDetail { get; set; }
+        public decimal ActualQuantity { get; set; }
+        public string AdjustedReason { get; set; }
+    }
+    public class CancelPickingContext
+    {
+        public string OrderNo { get; set; }
+        public string PalletCode { get; set; }
+        public string Barcode { get; set; }
+        public string Operator { get; set; }
+
+        public decimal CancelQuantity { get; set; }
+        public Dt_PickingRecord PickingRecord { get; set; }
+        public Dt_OutStockLockInfo LockInfo { get; set; }
+        public Dt_OutboundOrderDetail OrderDetail { get; set; }
+    }
     #endregion
 }

--
Gitblit v1.9.3