From 266e4bf654c55ce2f7e9271048e4625f1b8b49f6 Mon Sep 17 00:00:00 2001
From: heshaofeng <heshaofeng@hnkhzn.com>
Date: 星期一, 29 十二月 2025 14:36:08 +0800
Subject: [PATCH] Merge branch 'htq20251215' of http://115.159.85.185:8098/r/ZhongRui/ALDbanyunxiangmu into htq20251215

---
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs |   21 ++++++++-------------
 1 files changed, 8 insertions(+), 13 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_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 171d380..a49d374 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"
@@ -873,7 +873,10 @@
         {
             Type type = entity.GetType();
             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));
+
+            //assembly.GetType(type.FullName + "_Hty");
             if (htyType != null)
             {
                 object? obj = Activator.CreateInstance(htyType);
@@ -892,16 +895,12 @@
                         PropertyInfo propertyInfo = propertyInfos[i];
                         PropertyInfo? property = type.GetProperty(propertyInfo.Name);
 
-                        if (property != null)
+                        if (property != null && property.CanWrite)
                         {
                             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(entity));
@@ -909,12 +908,13 @@
                         }
                     }
                     if (obj != null)
-                        _db.InsertableByObject(obj).AS(type.Name + "_Hty").ExecuteCommand();
+                        _db.InsertableByObject(obj).AS(htyType.Name).ExecuteCommand();
                 }
             }
             return DeleteData(entity);
-           
+
         }
+
 
         public bool DeleteAndMoveIntoHty(List<TEntity> entities, OperateTypeEnum operateType)
         {
@@ -969,10 +969,5 @@
             }
             return DeleteData(entities);
         }
-        //List<TResult> QueryMuch<T, T2, T3, TResult>(
-        //    Expression<Func<T, T2, T3, object[]>> joinExpression,
-        //    Expression<Func<T, T2, T3, TResult>> selectExpression,
-        //    Expression<Func<T, T2, T3, bool>> whereLambda = null) where T : class, new(){throw new NotImplementedException();}
-        //Task<PageModel<TEntity>> QueryPage(PaginationModel pagination){throw new NotImplementedException();}
     }
 }

--
Gitblit v1.9.3