From f56441867f2cc77567f97a92348a5d878f0dca05 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期四, 12 三月 2026 18:24:15 +0800
Subject: [PATCH] Add AGENTS instructions and updates

---
 Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseServices/ServiceBase.cs |  101 +++++++++++++++++++++++++-------------------------
 1 files changed, 50 insertions(+), 51 deletions(-)

diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseServices/ServiceBase.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseServices/ServiceBase.cs
index 6b3275f..6a89499 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseServices/ServiceBase.cs
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseServices/ServiceBase.cs
@@ -1,4 +1,3 @@
-锘縰sing AutoMapper.Execution;
 using Magicodes.ExporterAndImporter.Core;
 using Magicodes.ExporterAndImporter.Core.Models;
 using Magicodes.ExporterAndImporter.Excel;
@@ -33,7 +32,7 @@
             this.BaseDal = BaseDal;
         }
 
-        public TRepository BaseDal { get; set; } //閫氳繃鍦ㄥ瓙绫荤殑鏋勯�犲嚱鏁颁腑娉ㄥ叆锛岃繖閲屾槸鍩虹被锛屼笉鐢ㄦ瀯閫犲嚱鏁�
+        public TRepository BaseDal { get; set; } //通过在子类的构造函数中注入,这里是基类,不用构造函数
 
         public ISqlSugarClient Db => BaseDal.Db;
 
@@ -73,7 +72,7 @@
             }
             if (EnableWebOrderBy)
             {
-                //鑾峰彇鎺掑簭瀛楁
+                //获取排序字段
                 Dictionary<string, OrderByType> orderbyDic = GetPageDataSort(options, TProperties);
 
                 foreach (var item in orderbyDic)
@@ -159,7 +158,7 @@
 
 
             parameter = parameter ?? Expression.Parameter(typeof(TEntity), "x");
-            //鍒涘缓鑺傜偣鐨勫睘鎬=>p.name 灞炴�ame
+            //创建节点的属性p=>p.name 属性name
             MemberExpression memberProperty = Expression.PropertyOrField(parameter, propertyName);
 
             if (expressionType == LinqExpressionType.In)
@@ -172,7 +171,7 @@
                     }
                     else
                     {
-                        throw new Exception("灞炴�у�肩被鍨嬩笉姝g‘");
+                        throw new Exception("属性值类型不正确");
                     }
                 }
                 //
@@ -192,15 +191,15 @@
 
                 //if (isStringValue)
                 //{
-                //    //string 绫诲瀷鐨勫瓧娈碉紝濡傛灉鍊煎甫鏈�'鍗曞紩鍙�,EF浼氶粯璁ゅ彉鎴�''涓や釜鍗曞紩鍙�
+                //    //string 类型的字段,如果值带有'单引号,EF会默认变成''两个单引号
                 //    MethodInfo method = typeof(System.Collections.IList).GetMethod("Contains");
-                //    //鍒涘缓闆嗗悎甯搁噺骞惰缃负甯搁噺鐨勫��
+                //    //创建集合常量并设置为常量的值
                 //    ConstantExpression constantCollection = Expression.Constant(list);
-                //    //鍒涘缓涓�涓〃绀鸿皟鐢ㄥ甫鍙傛暟鐨勬柟娉曠殑锛歯ew string[]{"1","a"}.Contains("a");
+                //    //创建一个表示调用带参数的方法的:new string[]{"1","a"}.Contains("a");
                 //    MethodCallExpression methodCall = Expression.Call(constantCollection, method, memberProperty);
                 //    return Expression.Lambda<Func<TEntity, bool>>(methodCall, parameter);
                 //}
-                //闈瀞tring瀛楁锛屾寜涓婇潰鏂瑰紡澶勭悊鎶ュ紓甯窷ull TypeMapping in Sql Tree
+                //非string字段,按上面方式处理报异常Null TypeMapping in Sql Tree
                 BinaryExpression body = null;
                 foreach (var values in list)
                 {
@@ -217,7 +216,7 @@
             ConstantExpression constant = proType.ToString() == "System.String"
               ? Expression.Constant(propertyValue) : Expression.Constant(value.ChangeType(proType));
 
-            // DateTime鍙�夋嫨浜嗘棩鏈熺殑鏃跺�欒嚜鍔ㄥ湪缁撴潫鏃ユ湡鍔犱竴澶╋紝淇DateTime绫诲瀷浣跨敤鏃ユ湡鍖洪棿鏌ヨ鏃犳硶鏌ヨ鍒扮粨鏉熸棩鏈熺殑闂
+            // DateTime只选择了日期的时候自动在结束日期加一天,修复DateTime类型使用日期区间查询无法查询到结束日期的问题
             if ((proType == typeof(DateTime) || proType == typeof(DateTime?)) && expressionType == LinqExpressionType.LessThanOrEqual && value.Length == 10)
             {
                 constant = Expression.Constant(Convert.ToDateTime(value).AddDays(1));
@@ -273,7 +272,7 @@
         }
 
         /// <summary>
-        /// 鑾峰彇鎺掑簭瀛楁
+        /// 获取排序字段
         /// </summary>
         /// <param name="pageData"></param>
         /// <param name="propertyInfo"></param>
@@ -311,7 +310,7 @@
         //    {
         //        UserRole? userRole = PermissionDataHostService.UserRoles.FirstOrDefault(x => x.UserId == App.User.UserId);
         //        if (userRole == null)
-        //            throw new Exception($"鏃犳潈闄�");
+        //            throw new Exception($"无权限");
 
         //        if (type.IsAssignableFrom(typeof(BaseWarehouseEntity)) || type.GetProperty(nameof(BaseWarehouseEntity.WarehouseId)) != null)
         //        {
@@ -330,7 +329,7 @@
 
         //        //UserRole? userRole = PermissionDataHostService.UserRoles.FirstOrDefault(x => x.UserId == App.User.UserId);
         //        //if (userRole == null)
-        //        //    throw new Exception($"鏃犳潈闄�");
+        //        //    throw new Exception($"无权限");
 
         //        //if (userRole.AuthorityScope == (int)AuthorityScopeEnum.CurrentRole)
         //        //{
@@ -349,7 +348,7 @@
         //    }
         //    catch (Exception ex)
         //    {
-        //        throw new Exception($"鏃犳潈闄愶紝{ex.Message}");
+        //        throw new Exception($"无权限,{ex.Message}");
         //    }
         //}
 
@@ -359,7 +358,7 @@
 
             if (pageData.Value == null) return new PageGridData<object>(total: 0, null);
             string keyName = t.GetKeyName();
-            ////鐢熸垚鏌ヨ鏉′欢
+            ////生成查询条件
             //Expression<Func<TEntity, bool>> whereExpression = keyName.CreateExpression<TEntity>(pageData.Value, LinqExpressionType.Equal);
             int totalCount = 0;
             PropertyInfo propertyInfo = t.GetProperties().FirstOrDefault(x => x.GetCustomAttribute<Navigate>() != null);
@@ -374,9 +373,9 @@
         }
 
         /// <summary>
-        /// 娣诲姞鏁版嵁
+        /// 添加数据
         /// </summary>
-        /// <param name="entity">鍗曚釜瀹炰綋</param>
+        /// <param name="entity">单个实体</param>
         /// <returns></returns>
         public virtual WebResponseContent AddData(TEntity entity)
         {
@@ -391,9 +390,9 @@
         }
 
         /// <summary>
-        /// 娣诲姞鏁版嵁
+        /// 添加数据
         /// </summary>
-        /// <param name="entities">瀹炰綋闆嗗悎</param>
+        /// <param name="entities">实体集合</param>
         /// <returns></returns>
         public virtual WebResponseContent AddData(List<TEntity> entities)
         {
@@ -408,7 +407,7 @@
         }
 
         /// <summary>
-        /// 娣诲姞鏁版嵁
+        /// 添加数据
         /// </summary>
         /// <param name="saveModel"></param>
         /// <returns></returns>
@@ -416,9 +415,9 @@
         {
             try
             {
-                if (saveModel == null || saveModel.MainData == null || saveModel.MainData.Count == 0)//鍒ゆ柇鍙傛暟鏄惁浼犲叆
+                if (saveModel == null || saveModel.MainData == null || saveModel.MainData.Count == 0)//判断参数是否传入
                 {
-                    return WebResponseContent.Instance.Error("浼犲弬閿欒,鍙傛暟涓嶈兘涓虹┖");
+                    return WebResponseContent.Instance.Error("传参错误,参数不能为空");
                 }
                 string validResult = typeof(TEntity).ValidateDicInEntity(saveModel.MainData, true, TProperties);
 
@@ -430,7 +429,7 @@
                 PropertyInfo keyPro = typeof(TEntity).GetKeyProperty();
                 if (keyPro == null)
                 {
-                    return WebResponseContent.Instance.Error("璇峰厛璁剧疆涓婚敭");
+                    return WebResponseContent.Instance.Error("请先设置主键");
                 }
                 if (keyPro.PropertyType == typeof(Guid))
                 {
@@ -454,7 +453,7 @@
 
                 if (typeof(TEntity).GetNavigatePro() == null)
                 {
-                    return WebResponseContent.Instance.Error("鏈厤缃鑸睘鎬�");
+                    return WebResponseContent.Instance.Error("未配置导航属性");
                 }
 
                 Type detailType = typeof(TEntity).GetDetailType();
@@ -506,9 +505,9 @@
         }
 
         /// <summary>
-        /// 淇敼鏁版嵁
+        /// 修改数据
         /// </summary>
-        /// <param name="entity">鍗曚釜瀹炰綋</param>
+        /// <param name="entity">单个实体</param>
         /// <returns></returns>
         public virtual WebResponseContent UpdateData(TEntity entity)
         {
@@ -523,9 +522,9 @@
         }
 
         /// <summary>
-        /// 淇敼鏁版嵁
+        /// 修改数据
         /// </summary>
-        /// <param name="entities">瀹炰綋闆嗗悎</param>
+        /// <param name="entities">实体集合</param>
         /// <returns></returns>
         public virtual WebResponseContent UpdateData(List<TEntity> entities)
         {
@@ -540,7 +539,7 @@
         }
 
         /// <summary>
-        /// 淇敼鏁版嵁
+        /// 修改数据
         /// </summary>
         /// <param name="saveModel"></param>
         /// <returns></returns>
@@ -549,9 +548,9 @@
             try
             {
                 List<string>? list = UpdateIgnoreColOnExecute?.Invoke(saveModel);
-                if (saveModel == null || saveModel.MainData == null || saveModel.MainData.Count == 0)//鍒ゆ柇鍙傛暟鏄惁浼犲叆
+                if (saveModel == null || saveModel.MainData == null || saveModel.MainData.Count == 0)//判断参数是否传入
                 {
-                    return WebResponseContent.Instance.Error("浼犲弬閿欒,鍙傛暟涓嶈兘涓虹┖");
+                    return WebResponseContent.Instance.Error("传参错误,参数不能为空");
                 }
                 string validResult = typeof(TEntity).ValidateDicInEntity(saveModel.MainData, false, TProperties, list?.ToArray() ?? null);
 
@@ -563,7 +562,7 @@
                 PropertyInfo keyPro = typeof(TEntity).GetKeyProperty();
                 if (keyPro == null)
                 {
-                    return WebResponseContent.Instance.Error("璇峰厛璁剧疆涓婚敭");
+                    return WebResponseContent.Instance.Error("请先设置主键");
                 }
 
                 TEntity entity = saveModel.MainData.DicToModel<TEntity>();
@@ -594,7 +593,7 @@
 
                 if (typeof(TEntity).GetNavigatePro() == null)
                 {
-                    return WebResponseContent.Instance.Error("鏈厤缃鑸睘鎬�");
+                    return WebResponseContent.Instance.Error("未配置导航属性");
                 }
 
                 Type detailType = typeof(TEntity).GetDetailType();
@@ -675,7 +674,7 @@
                 }
                 else
                 {
-                    content = WebResponseContent.Instance.Error("鏈壘鍒颁富琛ㄤ富閿��");
+                    content = WebResponseContent.Instance.Error("未找到主表主键值");
                 }
 
             }
@@ -688,9 +687,9 @@
         }
 
         /// <summary>
-        /// 鍒犻櫎鏁版嵁
+        /// 删除数据
         /// </summary>
-        /// <param name="key">涓婚敭</param>
+        /// <param name="key">主键</param>
         /// <returns></returns>
         public virtual WebResponseContent DeleteData(object key)
         {
@@ -705,9 +704,9 @@
         }
 
         /// <summary>
-        /// 鍒犻櫎鏁版嵁
+        /// 删除数据
         /// </summary>
-        /// <param name="keys">涓婚敭鏁扮粍</param>
+        /// <param name="keys">主键数组</param>
         /// <returns></returns>
         public virtual WebResponseContent DeleteData(object[] keys)
         {
@@ -740,7 +739,7 @@
                     }
                     else
                     {
-                        return WebResponseContent.Instance.Error("鍙傛暟閿欒");
+                        return WebResponseContent.Instance.Error("参数错误");
                     }
                 }
             }
@@ -752,9 +751,9 @@
         }
 
         /// <summary>
-        /// 鍒犻櫎鏁版嵁
+        /// 删除数据
         /// </summary>
-        /// <param name="entity">鍗曚釜瀹炰綋</param>
+        /// <param name="entity">单个实体</param>
         /// <returns></returns>
         public virtual WebResponseContent DeleteData(TEntity entity)
         {
@@ -769,9 +768,9 @@
         }
 
         /// <summary>
-        /// 鍒犻櫎鏁版嵁
+        /// 删除数据
         /// </summary>
-        /// <param name="entities">瀹炰綋闆嗗悎</param>
+        /// <param name="entities">实体集合</param>
         /// <returns></returns>
         public virtual WebResponseContent DeleteData(List<TEntity> entities)
         {
@@ -786,7 +785,7 @@
         }
 
         /// <summary>
-        /// 瀵煎嚭鏁版嵁
+        /// 导出数据
         /// </summary>
         /// <param name="pageData"></param>
         /// <returns></returns>
@@ -800,7 +799,7 @@
                 string savePath = AppDomain.CurrentDomain.BaseDirectory + $"ExcelExport";
                 IExporter exporter = new ExcelExporter();
                 string wheres = options.ValidatePageOptions(TProperties);
-                //鑾峰彇鎺掑簭瀛楁
+                //获取排序字段
                 Dictionary<string, OrderByType> orderbyDic = options.GetPageDataSort(TProperties);
 
                 List<TEntity> entities = BaseDal.QueryData(wheres, orderbyDic);
@@ -830,7 +829,7 @@
         }
 
         /// <summary>
-        /// 瀵煎叆鏁版嵁
+        /// 导入数据
         /// </summary>
         /// <param name="files"></param>
         /// <returns></returns>
@@ -839,7 +838,7 @@
             try
             {
                 if (files == null || files.Count == 0)
-                    return new WebResponseContent { Status = true, Message = "璇烽�夋嫨涓婁紶鐨勬枃浠�" };
+                    return new WebResponseContent { Status = true, Message = "请选择上传的文件" };
                 Microsoft.AspNetCore.Http.IFormFile formFile = files[0];
                 string dicPath = AppDomain.CurrentDomain.BaseDirectory + $"ExcelImprot/{DateTime.Now.ToString("yyyMMdd")}/{typeof(TEntity).Name}/";
                 if (!Directory.Exists(dicPath)) Directory.CreateDirectory(dicPath);
@@ -865,7 +864,7 @@
         }
 
         /// <summary>
-        /// 涓婁紶鏂囦欢
+        /// 上传文件
         /// </summary>
         /// <param name="files"></param>
         /// <returns></returns>
@@ -875,7 +874,7 @@
         }
 
         /// <summary>
-        /// 妯℃澘涓嬭浇
+        /// 模板下载
         /// </summary>
         /// <returns></returns>
         public virtual WebResponseContent DownLoadTemplate()
@@ -888,11 +887,11 @@
             SugarTable sugarTable = t.GetCustomAttribute<SugarTable>();
             if (sugarTable != null)
             {
-                fileName = sugarTable.TableDescription + "瀵煎叆妯℃澘.xlsx";
+                fileName = sugarTable.TableDescription + "导入模板.xlsx";
             }
             else
             {
-                fileName = nameof(TEntity) + "瀵煎叆妯℃澘.xlsx";
+                fileName = nameof(TEntity) + "导入模板.xlsx";
             }
             string savePath = AppDomain.CurrentDomain.BaseDirectory + $"ExcelImprotTemplate";
             FileHelper.WriteFile(savePath, fileName, data);

--
Gitblit v1.9.3