From 1bf2ea761ca55bddde7c88b1341c873d50b2f0f3 Mon Sep 17 00:00:00 2001
From: z8018 <1282578289@qq.com>
Date: 星期四, 08 一月 2026 14:02:58 +0800
Subject: [PATCH] 更新出库扫描

---
 项目代码/WMS无仓储版/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.1204.46620/SemanticSymbols.db |    0 
 项目代码/WMS无仓储版/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.1204.46620/CodeChunks.db      |    0 
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs                               |   37 +++++++++++++++++-
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs                            |   66 +++++++++++++++-----------------
 4 files changed, 66 insertions(+), 37 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/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.1204.46620/CodeChunks.db" "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/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.1204.46620/CodeChunks.db"
index 330b4ee..2a93723 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/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.1204.46620/CodeChunks.db"
+++ "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/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.1204.46620/CodeChunks.db"
Binary files differ
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/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.1204.46620/SemanticSymbols.db" "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/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.1204.46620/SemanticSymbols.db"
index 088d42a..7ca1092 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/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.1204.46620/SemanticSymbols.db"
+++ "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/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.1204.46620/SemanticSymbols.db"
Binary files differ
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_Core/BaseRepository/RepositoryBase.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_Core/BaseRepository/RepositoryBase.cs"
index a49d374..09541ce 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_Core/BaseRepository/RepositoryBase.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_Core/BaseRepository/RepositoryBase.cs"
@@ -920,52 +920,48 @@
         {
             Type type = typeof(TEntity);
             Assembly assembly = type.Assembly;
-            Type? htyType = assembly.GetType(type.FullName + "_Hty");
+
+            Type? htyType = assembly.GetTypes().FirstOrDefault(t => !t.IsInterface && !t.IsAbstract && type.IsAssignableFrom(t) && typeof(IBaseHistoryEntity).IsAssignableFrom(t));
             if (htyType != null)
             {
-                object? obj2 = Activator.CreateInstance(htyType);
-                PropertyInfo keyPro = typeof(TEntity).GetKeyProperty();
-                PropertyInfo? operateTypePro = htyType.GetProperty(nameof(IBaseHistoryEntity.OperateType));
-                PropertyInfo? sourceIdPro = htyType.GetProperty(nameof(IBaseHistoryEntity.SourceId));
-                if (obj2 != null && keyPro != null && operateTypePro != null && sourceIdPro != null)
+                List<object> list = new List<object>();
+                foreach (var item in entities)
                 {
-                    List<PropertyInfo> propertyInfos = htyType.GetProperties().Where(x => x.Name != operateTypePro.Name && x.Name != sourceIdPro.Name && x.Name != keyPro.Name).ToList();
-                    List<object> list = new List<object>();
-                    foreach (var item in entities)
+                    object? obj = Activator.CreateInstance(htyType);
+                    PropertyInfo keyPro = typeof(TEntity).GetKeyProperty();
+                    PropertyInfo? operateTypePro = htyType.GetProperty(nameof(IBaseHistoryEntity.OperateType));
+                    PropertyInfo? sourceIdPro = htyType.GetProperty(nameof(IBaseHistoryEntity.SourceId));
+                    if (obj != null && keyPro != null && operateTypePro != null && sourceIdPro != null)
                     {
-                        object? obj = Activator.CreateInstance(htyType);
-                        if (obj != null)
-                        {
-                            operateTypePro.SetValue(obj, operateType.ToString());
-                            sourceIdPro.SetValue(obj, keyPro.GetValue(item));
-                            for (int i = 0; i < propertyInfos.Count; i++)
-                            {
-                                PropertyInfo propertyInfo = propertyInfos[i];
-                                PropertyInfo? property = type.GetProperty(propertyInfo.Name);
+                        operateTypePro.SetValue(obj, operateType.ToString());
+                        sourceIdPro.SetValue(obj, keyPro.GetValue(item));
 
-                                if (property != null)
+                        List<PropertyInfo> propertyInfos = htyType.GetProperties().Where(x => x.Name != operateTypePro.Name && x.Name != sourceIdPro.Name && x.Name != keyPro.Name).ToList();
+
+                        for (int i = 0; i < propertyInfos.Count; i++)
+                        {
+                            PropertyInfo propertyInfo = propertyInfos[i];
+                            PropertyInfo? property = type.GetProperty(propertyInfo.Name);
+
+                            if (property != null && property.CanWrite)
+                            {
+                                if (propertyInfo.Name == nameof(BaseEntity.Modifier))
                                 {
-                                    if (propertyInfo.Name == nameof(BaseEntity.Modifier))
-                                    {
-                                        propertyInfo.SetValue(obj, App.User.UserId > 0 ? App.User.UserName : "System");
-                                    }
-                                    else if (propertyInfo.Name == nameof(BaseEntity.ModifyDate))
-                                    {
-                                        propertyInfo.SetValue(obj, DateTime.Now);
-                                    }
-                                    else
-                                    {
-                                        propertyInfo.SetValue(obj, property.GetValue(item));
-                                    }
+                                    propertyInfo.SetValue(obj, App.User.UserId > 0 ? App.User.UserName : "System");
+                                }
+                                else
+                                {
+                                    propertyInfo.SetValue(obj, property.GetValue(item));
                                 }
                             }
-                            list.Add(obj);
                         }
-                    }
-                    if (list.Count > 0)
-                        _db.InsertableByObject(list).AS(type.Name + "_Hty").ExecuteCommand();
 
+                        list.Add(obj);
+                    }
                 }
+
+                if (list != null && list.Any())
+                    _db.InsertableByObject(list).AS(htyType.Name).ExecuteCommand();
             }
             return DeleteData(entities);
         }
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/OutboundService.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/OutboundService.cs"
index 53bfd2c..edcb58a 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/OutboundService.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/OutboundService.cs"
@@ -3,6 +3,7 @@
 using Dm.filter;
 using MailKit.Search;
 using Mapster;
+using Microsoft.IdentityModel.Tokens;
 using Newtonsoft.Json;
 using Newtonsoft.Json.Serialization;
 using Org.BouncyCastle.Asn1.Ocsp;
@@ -1447,7 +1448,6 @@
                     {
                         if (allocatedQuantity <= 0) break;
 
-
                         //if (item.OrderQuantity - item.MoveQty - item.OverOutQuantity >= allocatedQuantity)
                         //{
                         //    item.OverOutQuantity += allocatedQuantity;
@@ -1500,7 +1500,7 @@
 
                     lockInfo.SortedQuantity = lockInfo.SortedQuantity + actualOutboundQuantity;
 
-                    if (lockInfo.SortedQuantity == lockInfo.AssignQuantity)
+                    if (lockInfo.SortedQuantity >= lockInfo.AssignQuantity)
                     {
                         _outboundLockInfoRepository.DeleteAndMoveIntoHty(lockInfo, WIDESEA_Core.Enums.OperateTypeEnum.鑷姩瀹屾垚);
                     }
@@ -1546,6 +1546,22 @@
                         _feedbackMesService.BarcodeFeedback(newBarcode);
                     }
 
+                    // 鍒犻櫎閿佸畾璁板綍锛堝鏋滃嚭搴撴槑缁嗗叏閮ㄥ畬鎴愶級 涓嶤alculateActualOutboundQuantity鏂规硶閲岄潰娉ㄩ噴浠g爜2閫�1浣跨敤
+                    if (CheckOutboundOrderDetailCompletedByMatCode(request.OrderNo, lockInfo.MaterielCode, outboundOrderDetails.First()))
+                    {
+                        Func<Dt_OutStockLockInfo, bool> supWhere = x => string.IsNullOrEmpty(outboundOrderDetails.First().SupplyCode) ? true : x.SupplyCode == outboundOrderDetails.First().SupplyCode;
+
+                        Func<Dt_OutStockLockInfo, bool> wareWhere = x => string.IsNullOrEmpty(outboundOrderDetails.First().WarehouseCode) ? true : x.WarehouseCode == outboundOrderDetails.First().WarehouseCode;
+
+                        List<Dt_OutStockLockInfo> stockLockInfos = _outboundLockInfoRepository.QueryData(x =>
+                                x.OrderNo == request.OrderNo &&
+                                x.MaterielCode == stockDetail.MaterielCode).Where(supWhere).Where(wareWhere).ToList();
+                        if (stockLockInfos != null && stockLockInfos.Any())
+                        {
+                            _outboundLockInfoRepository.DeleteAndMoveIntoHty(stockLockInfos, WIDESEA_Core.Enums.OperateTypeEnum.鑷姩鍒犻櫎);
+                        }
+                    }
+
                     // 妫�鏌ュ嚭搴撳崟鏄惁瀹屾垚
                     if (CheckOutboundOrderCompleted(request.OrderNo))
                     {
@@ -1556,6 +1572,7 @@
                             _feedbackMesService.OutboundFeedback(outboundOrder.OrderNo);
                         }
                     }
+
                 }
                 catch (Exception ex)
                 {
@@ -1603,6 +1620,8 @@
         /// </summary>
         private decimal CalculateActualOutboundQuantity(Dt_StockInfoDetail stockDetail, List<Dt_OutboundOrderDetail> outboundDetails, Dt_OutStockLockInfo lockInfo)
         {
+            // decimal availableOutboundQuantity = lockInfo.AssignQuantity - lockInfo.SortedQuantity;
+
             decimal availableOutboundQuantity = lockInfo.AssignQuantity;
             decimal detailRemainingQuantity = outboundDetails.Sum(x => x.OrderQuantity - x.OverOutQuantity - x.MoveQty);//outboundDetail.OrderQuantity - outboundDetail.OverOutQuantity;
 
@@ -1879,6 +1898,20 @@
             return details.All(x => x.OverOutQuantity >= x.OrderQuantity - x.MoveQty);
         }
 
+        /// <summary>
+        /// 妫�鏌ュ嚭搴撳崟鏄庣粏鏄惁瀹屾垚
+        /// </summary>
+        public bool CheckOutboundOrderDetailCompletedByMatCode(string orderNo, string materialCode, Dt_OutboundOrderDetail outboundOrderDetail)
+        {
+            Dt_OutboundOrder outboundOrder = _outboundRepository.QueryFirst(x => x.OrderNo == orderNo);
+            if (outboundOrder == null) return false;
+
+            List<Dt_OutboundOrderDetail> details = _detailRepository.QueryData(x => x.OrderId == outboundOrder.Id && x.MaterielCode == materialCode && (string.IsNullOrEmpty(outboundOrderDetail.SupplyCode) || x.SupplyCode == outboundOrderDetail.SupplyCode) && (string.IsNullOrEmpty(outboundOrderDetail.WarehouseCode) || x.WarehouseCode == outboundOrderDetail.WarehouseCode));
+
+            // 妫�鏌ユ墍鏈夋槑缁嗙殑宸插嚭鏁伴噺鏄惁閮界瓑浜庡崟鎹暟閲�
+            return details.All(x => x.OverOutQuantity >= x.OrderQuantity - x.MoveQty);
+        }
+
         #endregion
 
         #region 鍙栫┖绠�

--
Gitblit v1.9.3