From c4b7483bb96d813e4f2f4bccf8bbfe89f3f9b08c Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期日, 29 十二月 2024 10:54:44 +0800
Subject: [PATCH] 更新

---
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_Core/AOP/SqlSugarAop.cs |   61 ++++++++----------------------
 1 files changed, 16 insertions(+), 45 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Core/AOP/SqlSugarAop.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Core/AOP/SqlSugarAop.cs"
index dac84c9..50c68e1 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Core/AOP/SqlSugarAop.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Core/AOP/SqlSugarAop.cs"
@@ -8,6 +8,7 @@
 using System.Text;
 using System.Threading.Tasks;
 using WIDESEA_Core.Attributes;
+using WIDESEA_Core.CodeConfigEnum;
 using WIDESEA_Core.Const;
 using WIDESEA_Core.DB;
 using WIDESEA_Core.DB.Models;
@@ -44,7 +45,7 @@
                     }
                 }
 
-                SequenceAttirbute? sequenceAttirbute = propertyInfo.GetCustomAttribute<SequenceAttirbute>();
+                SequenceAttribute? sequenceAttirbute = propertyInfo.GetCustomAttribute<SequenceAttribute>();
                 if (sequenceAttirbute != null)
                 {
                     if (propertyInfo.GetValue(entityInfo.EntityValue)?.ObjToInt() <= 0)
@@ -65,28 +66,23 @@
                         int seq = sugarClient.Ado.GetScalar($"SELECT NEXT VALUE FOR {sequenceAttirbute.SequenceName}").ObjToInt();
                         propertyInfo.SetValue(entityInfo.EntityValue, seq, null);
                     }
-                  
                 }
             }
 
             if (entityInfo.EntityValue is BaseEntity baseEntity)
             {
                 // 鏂板鎿嶄綔
-                if (entityInfo.OperationType == DataFilterType.InsertByObject)
+                if (entityInfo.OperationType == DataFilterType.InsertByObject && entityInfo.PropertyName == nameof(BaseEntity.CreateDate))
                 {
-                    if (entityInfo.PropertyName == nameof(BaseEntity.CreateDate))
-                    {
-                        baseEntity.CreateDate = DateTime.Now;
-                    }
+                    baseEntity.CreateDate = DateTime.Now;
                 }
 
-                if (entityInfo.OperationType == DataFilterType.UpdateByObject)
+                if (entityInfo.OperationType == DataFilterType.UpdateByObject && entityInfo.PropertyName == nameof(BaseEntity.ModifyDate))
                 {
                     baseEntity.ModifyDate = DateTime.Now;
                 }
 
-
-                if (App.User?.UserId > 0)
+                //if (App.User?.UserId > 0)
                 {
                     switch (entityInfo.OperationType)
                     {
@@ -99,17 +95,13 @@
                     }
                 }
             }
-        }
 
-        private static void UpdateConfigData(dynamic ruleConfig)
-        {
-            try
+            if (entityInfo.EntityValue is IBaseHistoryEntity baseHistoryEntity)
             {
-
-            }
-            catch (Exception ex)
-            {
-
+                if (entityInfo.OperationType == DataFilterType.InsertByObject && entityInfo.PropertyName == nameof(IBaseHistoryEntity.InsertTime))
+                {
+                    baseHistoryEntity.InsertTime = DateTime.Now;
+                }
             }
         }
 
@@ -142,11 +134,11 @@
                 ruleConfig.ModifyDate = DateTime.Now;
 
                 code = ruleConfig.Format;
-                code = code.Replace($"[{CodeFormat.YYYY}]", now.Year.ToString().PadLeft(4, '0'));
-                code = code.Replace($"[{CodeFormat.MM}]", now.Month.ToString().PadLeft(2, '0'));
-                code = code.Replace($"[{CodeFormat.DD}]", now.Day.ToString().PadLeft(2, '0'));
-                code = code.Replace($"[{CodeFormat.ST}]", ruleConfig.StartStr.ToString());
-                code = code.Replace($"[{CodeFormat.NUM}]", ruleConfig.CurrentVal.ToString().PadLeft(ruleConfig.Length ?? 0, '0'));
+                code = code.Replace($"[{CodeFormatTypeEnum.YYYY}]", now.Year.ToString().PadLeft(4, '0'));
+                code = code.Replace($"[{CodeFormatTypeEnum.MM}]", now.Month.ToString().PadLeft(2, '0'));
+                code = code.Replace($"[{CodeFormatTypeEnum.DD}]", now.Day.ToString().PadLeft(2, '0'));
+                code = code.Replace($"[{CodeFormatTypeEnum.ST}]", ruleConfig.StartStr.ToString());
+                code = code.Replace($"[{CodeFormatTypeEnum.NUM}]", ruleConfig.CurrentVal.ToString().PadLeft(ruleConfig.Length ?? 0, '0'));
             }
             catch (Exception ex)
             {
@@ -158,27 +150,6 @@
                 sugarClient.Updateable(keyValuePairs).AS(MainDb.CodeRuleConfig).WhereColumns(nameof(ruleConfig.Id)).ExecuteCommand();
             }
             return code;
-        }
-
-        private static string GetWholeSql(SugarParameter[] paramArr, string sql)
-        {
-            foreach (var param in paramArr)
-            {
-                sql = sql.Replace(param.ParameterName, $@"'{param.Value.ObjToString()}'");
-            }
-
-            return sql;
-        }
-
-        private static string GetParas(SugarParameter[] pars)
-        {
-            string key = "銆怱QL鍙傛暟銆戯細";
-            foreach (var param in pars)
-            {
-                key += $"{param.ParameterName}:{param.Value}\n";
-            }
-
-            return key;
         }
     }
 }

--
Gitblit v1.9.3