Lyyyi 16 часов назад
Родитель
Сommit
803fdf9730

+ 2 - 1
OASystem/OASystem.Api/OAMethodLib/GeneralMethod.cs

@@ -4345,13 +4345,14 @@ namespace OASystem.API.OAMethodLib
             //合并已使用币种及汇率
             //合并已使用币种及汇率
             infos.ForEach(x =>
             infos.ForEach(x =>
             {
             {
-                if (x.CurrencyCode.Equals("CNY")) x.Rate = 1.0000M;
+                x.Rate = x.Rate == 0.00M ? 1.0000M : x.Rate;
 
 
                 var eexCurrencyInfo = eexCurrencyInfos.Where(y => y.CurrencyCode == x.CurrencyCode).FirstOrDefault();
                 var eexCurrencyInfo = eexCurrencyInfos.Where(y => y.CurrencyCode == x.CurrencyCode).FirstOrDefault();
                 if (eexCurrencyInfo != null)
                 if (eexCurrencyInfo != null)
                 {
                 {
                     x.Rate = eexCurrencyInfo.Rate;
                     x.Rate = eexCurrencyInfo.Rate;
                 }
                 }
+
             });
             });
 
 
             //未存储费用集合
             //未存储费用集合

+ 20 - 52
OASystem/OASystem.Api/Program.cs

@@ -173,12 +173,11 @@ var groups = new List<Tuple<string, string>>
 #endregion
 #endregion
 
 
 #region 注入数据库
 #region 注入数据库
+
+#region old
+
 builder.Services.AddScoped(options =>
 builder.Services.AddScoped(options =>
 {
 {
-    var cpuCount = Environment.ProcessorCount;
-    var poolMin = Math.Max(5, cpuCount * 2);
-    var poolMax = Math.Max(100, cpuCount * 20);
-
     return new SqlSugarClient(new List<ConnectionConfig>()
     return new SqlSugarClient(new List<ConnectionConfig>()
     {
     {
         new() {
         new() {
@@ -197,65 +196,31 @@ builder.Services.AddScoped(options =>
     }
     }
     , db =>
     , db =>
     {
     {
-        //SQL执行完
+        // SQL执行完
         db.Aop.OnLogExecuted = (sql, pars) =>
         db.Aop.OnLogExecuted = (sql, pars) =>
         {
         {
-            //if (db.Ado.SqlExecutionTime.TotalSeconds > 1)
-            //{
-            //代码CS文件名
-            var fileName = db.Ado.SqlStackTrace.FirstFileName;
-            //代码行数
-            var fileLine = db.Ado.SqlStackTrace.FirstLine;
-            //方法名
-            var FirstMethodName = db.Ado.SqlStackTrace.FirstMethodName;
-            //执行完了可以输出SQL执行时间 (OnLogExecutedDelegate) 
-            Console.WriteLine("NowTime:" + DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"));
-            Console.WriteLine("MethodName:" + FirstMethodName);
-            Console.WriteLine("ElapsedTime:" + db.Ado.SqlExecutionTime.ToString());
-            Console.WriteLine("ExecuteSQL:" + sql);
-
-            //}
+            // 超过1秒
+            if (db.Ado.SqlExecutionTime.TotalSeconds > 1)
+            {
+                var fileName = db.Ado.SqlStackTrace.FirstFileName;
+                var fileLine = db.Ado.SqlStackTrace.FirstLine;
+                var FirstMethodName = db.Ado.SqlStackTrace.FirstMethodName;
+                //执行完了可以输出SQL执行时间 (OnLogExecutedDelegate) 
+                Console.WriteLine("NowTime:" + DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"));
+                Console.WriteLine("MethodName:" + FirstMethodName);
+                Console.WriteLine("ElapsedTime:" + db.Ado.SqlExecutionTime.ToString());
+                Console.WriteLine("ExecuteSQL:" + sql);
+            }
         };
         };
         //SQL执行前
         //SQL执行前
         db.Aop.OnLogExecuting = (sql, pars) =>
         db.Aop.OnLogExecuting = (sql, pars) =>
         {
         {
-            //获取原生SQL推荐 5.1.4.63  性能OK
-            UtilMethods.GetNativeSql(sql, pars);
-
-            //获取无参数化SQL 影响性能只适合调试
-            //UtilMethods.GetSqlString(DbType.SqlServer, sql, pars);
-
-            if (pars != null || pars.Length > 0)
-            {
-                Console.WriteLine("============== 完整 SQL ==============");
-                var resultSql = sql;
-
-                foreach (var param in pars)
-                {
-                    var par = param.Value;
-                    if (par != null)
-                    {
-                        var formattedValue = par switch
-                        {
-                            string str => $"'{str.Replace("'", "''")}'",
-                            DateTime date => $"'{date:yyyy-MM-dd HH:mm:ss}'",
-                            bool b => b ? "1" : "0",
-                            _ => par.ToString()
-                        };
-                        resultSql = resultSql.Replace(param.ParameterName, formattedValue);
-                    }
-
-                }
-                Console.WriteLine(resultSql);
-                Console.WriteLine("=====================================");
-            }
         };
         };
         //SQL报错
         //SQL报错
         db.Aop.OnError = (exp) =>
         db.Aop.OnError = (exp) =>
         {
         {
             //获取原生SQL推荐 5.1.4.63  性能OK
             //获取原生SQL推荐 5.1.4.63  性能OK
             //UtilMethods.GetNativeSql(exp.Sql, exp.Parametres);
             //UtilMethods.GetNativeSql(exp.Sql, exp.Parametres);
-
             //获取无参数SQL对性能有影响,特别大的SQL参数多的,调试使用
             //获取无参数SQL对性能有影响,特别大的SQL参数多的,调试使用
             //UtilMethods.GetSqlString(DbType.SqlServer, exp.sql, exp.parameters);
             //UtilMethods.GetSqlString(DbType.SqlServer, exp.sql, exp.parameters);
 
 
@@ -270,6 +235,9 @@ builder.Services.AddScoped(options =>
     }
     }
     );
     );
 });
 });
+
+#endregion
+
 #endregion
 #endregion
 
 
 //#region Identity 配置
 //#region Identity 配置
@@ -576,7 +544,7 @@ var app = builder.Build();
 //});
 //});
 
 
 //自定义异常中间件
 //自定义异常中间件
-app.UseMiddleware<ExceptionHandlingMiddleware>();
+//app.UseMiddleware<ExceptionHandlingMiddleware>();
 
 
 //serilog日志 请求中间管道
 //serilog日志 请求中间管道
 app.UseSerilogRequestLogging(options =>
 app.UseSerilogRequestLogging(options =>

+ 2 - 2
OASystem/OASystem.Api/appsettings.json

@@ -1,7 +1,7 @@
 {
 {
   "ConnectionStrings": {
   "ConnectionStrings": {
-    "OA2023DB": "server=132.232.92.186;uid=sa;pwd=Yjx@158291;database=OA2023DB;MultipleActiveResultSets=True;Connect Timeout=30;Encrypt=True;TrustServerCertificate=True;Pooling=True;Max Pool Size=150;Min Pool Size=10;",
-    "OA2014DB": "server=132.232.92.186;uid=sa;pwd=Yjx@158291;database=OA2014;MultipleActiveResultSets=True;Connect Timeout=30;Encrypt=True;TrustServerCertificate=True;Pooling=True;Max Pool Size=150;Min Pool Size=10;"
+    "OA2023DB": "server=132.232.92.186;uid=sa;pwd=Yjx@158291;database=OA2023DB;MultipleActiveResultSets=True;Connect Timeout=30;Encrypt=True;TrustServerCertificate=True;Pooling=true;Max Pool Size=100;Min Pool Size=0;Connection Lifetime=1800;",
+    "OA2014DB": "server=132.232.92.186;uid=sa;pwd=Yjx@158291;database=OA2014;MultipleActiveResultSets=True;Connect Timeout=30;Encrypt=True;TrustServerCertificate=True;Pooling=true;Max Pool Size=100;Min Pool Size=0;Connection Lifetime=1800;"
   },
   },
   "ApiAccessTime": {
   "ApiAccessTime": {
     "StartTime": "2025-01-09 15:00:00",
     "StartTime": "2025-01-09 15:00:00",

+ 2 - 6
OASystem/OASystem.Infrastructure/Repositories/BaseRepository.cs

@@ -1,8 +1,4 @@
-using OASystem.Domain.Entities;
-using OASystem.Domain.Enums;
-using System.Reflection;
-
-namespace OASystem.Infrastructure.Repositories
+namespace OASystem.Infrastructure.Repositories
 {
 {
     public class BaseRepository<TEntity, TDto> where TEntity : EntityBase, new()
     public class BaseRepository<TEntity, TDto> where TEntity : EntityBase, new()
     {
     {
@@ -324,6 +320,6 @@ namespace OASystem.Infrastructure.Repositories
         }
         }
         #endregion
         #endregion
 
 
-        
+
     }
     }
 }
 }

+ 17 - 11
OASystem/OASystem.Infrastructure/Repositories/Resource/OverseaVehicleRepository.cs

@@ -242,11 +242,6 @@ namespace OASystem.Infrastructure.Repositories.Resource
                     return new JsonView(false, $"车信息,操作失败!");
                     return new JsonView(false, $"车信息,操作失败!");
                 }
                 }
 
 
-                await _sqlSugar.Deleteable<Res_OverseaVehicleTypePrice>()
-                     .Where(x => x.OvId == info.Id)
-                     .ExecuteCommandAsync();
-
-
                 foreach (var subInfo in subInfos)
                 foreach (var subInfo in subInfos)
                 {
                 {
                     subInfo.OvId = info.Id;
                     subInfo.OvId = info.Id;
@@ -259,12 +254,23 @@ namespace OASystem.Infrastructure.Repositories.Resource
                     }
                     }
                 }
                 }
 
 
-                var insert = await _sqlSugar.Insertable(subInfos).ExecuteCommandAsync();
-                if (insert < 1)
-                {
-                    _sqlSugar.RollbackTran();
-                    return new JsonView(false, $"车型信息,部分新增,操作失败!");
-                }
+                var insertList = subInfos.Where(x => x.Id == 0).ToList();
+                var updateList = subInfos.Where(x => x.Id > 0).ToList();
+
+                var insert = await _sqlSugar.Insertable(insertList).ExecuteCommandAsync();
+                
+                var update = await _sqlSugar.Updateable(updateList)
+                    .UpdateColumns(it => new
+                    {
+                        it.CarTypeName,
+                        it.ServiceType,
+                        it.Price,
+                        it.LastUpdateUserId,
+                        it.LastUpdateTime,
+                        it.Remark
+                    })
+                    .Where(it => it.Id == it.Id)
+                    .ExecuteCommandAsync();
             }
             }
             catch (Exception ex)
             catch (Exception ex)
             {
             {