From e18c82f784a148cb020d577c46910f16304a94b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E9=B9=8F?= Date: Thu, 15 May 2025 11:54:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=89=B9=E9=87=8F=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ReZero/SuperAPI/Application/App.cs | 13 + .../MethodGeneratorAPI/MethodGeneratorAPI.cs | 63 +- .../Controllers/StdObjectMappingController.cs | 6 +- SuperAPI/Program.cs | 12 +- .../wwwroot/rezero/default_ui/add_filed.html | 1538 ++++++++--------- medical.jzyb.entity/STD/STD_METHOD_CONFIG.cs | 2 +- .../STD/STD_OBJECT_ASSEMBLY.cs | 2 +- medical.jzyb.entity/STD/STD_OBJECT_MAPPING.cs | 105 +- .../std_object_mapping_business.cs | 44 +- 9 files changed, 924 insertions(+), 861 deletions(-) diff --git a/ReZero/SuperAPI/Application/App.cs b/ReZero/SuperAPI/Application/App.cs index 289be72..4d45090 100644 --- a/ReZero/SuperAPI/Application/App.cs +++ b/ReZero/SuperAPI/Application/App.cs @@ -95,6 +95,19 @@ namespace ReZero.SuperAPI { ReZero.DependencyInjection.DependencyResolver.GetLogger().LogInformation(UtilMethods.GetNativeSql(s, p)); }; + + // 添加Oracle批量操作配置 + if (zeroDatabaseInfo.DbType == DbType.Oracle) + { + db.Aop.OnError = (ex) => + { + if (ex.Message.Contains("bulkcopy no support identity")) + { + ReZero.DependencyInjection.DependencyResolver.GetLogger().LogWarning("Oracle批量操作遇到identity问题,使用单条插入模式"); + } + }; + db.Ado.CommandTimeOut = 120; // 增加超时时间 + } }); } /// diff --git a/ReZero/SuperAPI/MethodGeneratorAPI/MethodGeneratorAPI.cs b/ReZero/SuperAPI/MethodGeneratorAPI/MethodGeneratorAPI.cs index 1c66c24..0442ab4 100644 --- a/ReZero/SuperAPI/MethodGeneratorAPI/MethodGeneratorAPI.cs +++ b/ReZero/SuperAPI/MethodGeneratorAPI/MethodGeneratorAPI.cs @@ -173,7 +173,19 @@ namespace ReZero.SuperAPI var type = argsTypes![index]; if (IsObject(value, type)) { - value = JsonConvert.DeserializeObject(value + "", type); + try + { + var valueStr = value?.ToString(); + if (!string.IsNullOrEmpty(valueStr)) + { + value = JsonConvert.DeserializeObject(valueStr, type); + } + } + catch (JsonException ex) + { + throw new Exception(TextHandler.GetCommonText(p.Name + "JSON解析错误: " + ex.Message, + p.Name + " JSON parsing error: " + ex.Message)); + } } } try @@ -181,9 +193,10 @@ namespace ReZero.SuperAPI value = ConvetEmptyValue(p.ParameterType, value); value = UtilMethods.ChangeType2(value, p.ParameterType); } - catch (Exception) + catch (Exception ex) { - throw new Exception(TextHandler.GetCommonText(p.Name+"参数类型不匹配 "+value, p.Name + " Parameter type does not match " + value)); + throw new Exception(TextHandler.GetCommonText(p.Name + "参数类型不匹配 " + value + ", 错误: " + ex.Message, + p.Name + " Parameter type does not match " + value + ", Error: " + ex.Message)); } parameters[p.Position] = value!; index++; @@ -197,6 +210,36 @@ namespace ReZero.SuperAPI { value = null; } + + // 处理JSON数组或对象 + var strValue = value?.ToString()?.Trim(); + if (strValue != null) + { + if ((type.IsArray || type.FullName.StartsWith("System.Collections.Generic.List")) && + strValue.StartsWith("[") && strValue.EndsWith("]")) + { + try + { + return JsonConvert.DeserializeObject(strValue, type); + } + catch + { + // 保持原始值 + } + } + else if (!type.FullName.StartsWith("System.") && + strValue.StartsWith("{") && strValue.EndsWith("}")) + { + try + { + return JsonConvert.DeserializeObject(strValue, type); + } + catch + { + // 保持原始值 + } + } + } return value; } @@ -209,7 +252,19 @@ namespace ReZero.SuperAPI } private static bool IsObject(object? value, Type type) { - return (type.IsArray || type.FullName.StartsWith("System.Collections.Generic.List")) && value != null; + if ((type.IsArray || type.FullName.StartsWith("System.Collections.Generic.List")) && value != null) + { + return true; + } + + // 检查值是否为JSON数组字符串 + var valueStr = value?.ToString()?.Trim(); + if (valueStr != null && valueStr.StartsWith("[") && valueStr.EndsWith("]")) + { + return true; + } + + return false; } } } diff --git a/SuperAPI/Controllers/StdObjectMappingController.cs b/SuperAPI/Controllers/StdObjectMappingController.cs index f4fcb39..49ea642 100644 --- a/SuperAPI/Controllers/StdObjectMappingController.cs +++ b/SuperAPI/Controllers/StdObjectMappingController.cs @@ -10,12 +10,12 @@ namespace medical.insu.transfomer.Controllers public class StdObjectMappingController { [DI] - public std_object_mapping_business _StdObjectMappingBusiness { get; set; } + public std_object_mapping_business? std_object_mapping_business { get; set; } [ApiMethod("批量插入映射关系")] - public int insertList([FromBody]List list) + public int insertList(List list) { - return _StdObjectMappingBusiness.ListInsert(list); + return std_object_mapping_business!.ListInsert(list); } } } diff --git a/SuperAPI/Program.cs b/SuperAPI/Program.cs index 4b41212..f0a8158 100644 --- a/SuperAPI/Program.cs +++ b/SuperAPI/Program.cs @@ -19,7 +19,7 @@ builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); -//עdb: дԲע +//注册db: 这个不写代码可以不注册 builder.Services.AddScoped(it => { var config = ApiConfiguration.GetJsonValue("ReZero"); @@ -33,21 +33,21 @@ builder.Services.AddScoped(it => //builder.Services.AddCors(); -//עReZero.Api +//注册ReZero.Api builder.Services.AddReZeroServices(api => { - //ؿɻjsonļ + //有重载可换json文件 var apiObj = SuperAPIOptions.GetOptions(); - //IOCҵҪм̼ + //IOC业务等所有需要的所有集程集 var assemblyList = Assembly.GetExecutingAssembly() - .GetAllDependentAssemblies(it => it.Contains("medical.insu.transfomer")) + .GetAllDependentAssemblies(it => it.Contains("medical.insu.transfomer") || it.Contains("medical.transfomer")) .ToArray(); apiObj!.DependencyInjectionOptions = new DependencyInjectionOptions(assemblyList); - //óAPI + //启用超级API api.EnableSuperApi(apiObj); }); diff --git a/SuperAPI/wwwroot/rezero/default_ui/add_filed.html b/SuperAPI/wwwroot/rezero/default_ui/add_filed.html index 74485e5..8207051 100644 --- a/SuperAPI/wwwroot/rezero/default_ui/add_filed.html +++ b/SuperAPI/wwwroot/rezero/default_ui/add_filed.html @@ -1,796 +1,754 @@ @@master_page.html -
-
-
-
-
- 本地表 -
- {{`(${localJosnName})`}} -
-
- - - 导入本地表 -
-
-
-
- 表名 -
-
- 表注释 -
-
-
-
-
- 三方表 -
- ({{thirdJsonName}}) -
-
- - - 导入三方表 -
-
-
-
- 表名 -
-
- 表注释 -
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
序号字段名 - 字段注释 - - 字段类型 - - 字典名称 - 字段名 - 字段注释 - - 字段类型 - - 字典名称 - 操作
{{index + 1}} - {{item.SYSTEM_FIELD}} - - {{item.SYSTEM_NAME}} - - {{item.SYSTEM_FIELD_TYPE}} - - {{item.SYSTEM_DICT_NAME}} - - {{item.INTERFACE_FIELD}} - - {{item.INTERFACE_NAME}} - - {{item.OBJECT_FIELD_TYPE}} - - {{item.OBJECT_DICT_NAME}} - - -
{{data.length + 1}} - - - - - - - - - - - - - - - - - - - - -
- -
+
+
+
+
+
+ 本地表 +
+ {{`(${localJosnName})`}} +
+
+ + + 导入本地表 +
+
+
+
+ 表名 +
+
+ 表注释 +
+
+
+
+
+ 三方表 +
+ ({{thirdJsonName}}) +
+
+ + + 导入三方表 +
+
+
+
+ 表名 +
+
+ 表注释 +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
序号字段名字段注释字段类型字典名称字段名字段注释字段类型字典名称操作
{{index + 1}} + {{item.SYSTEM_FIELD}} + {{item.SYSTEM_NAME}}{{item.SYSTEM_FIELD_TYPE}}{{item.SYSTEM_DICT_NAME}}{{item.INTERFACE_FIELD}}{{item.INTERFACE_NAME}}{{item.OBJECT_FIELD_TYPE}}{{item.OBJECT_DICT_NAME}} + +
{{data.length + 1}} + + + + + + + + + + + + + + + + + + + + +
+ +
diff --git a/medical.jzyb.entity/STD/STD_METHOD_CONFIG.cs b/medical.jzyb.entity/STD/STD_METHOD_CONFIG.cs index a3dc3df..a9d48ca 100644 --- a/medical.jzyb.entity/STD/STD_METHOD_CONFIG.cs +++ b/medical.jzyb.entity/STD/STD_METHOD_CONFIG.cs @@ -19,7 +19,7 @@ namespace medical.transfomer.entity /// 默认值: ///
[SugarColumn(ColumnName="METHOD_ID" ,IsPrimaryKey = true) ] - public string METHOD_ID { get; set; } = null!; + public string? METHOD_ID { get; set; } = null!; /// /// 备 注:方法名称(需符合医保规范) diff --git a/medical.jzyb.entity/STD/STD_OBJECT_ASSEMBLY.cs b/medical.jzyb.entity/STD/STD_OBJECT_ASSEMBLY.cs index a8d1486..02c397e 100644 --- a/medical.jzyb.entity/STD/STD_OBJECT_ASSEMBLY.cs +++ b/medical.jzyb.entity/STD/STD_OBJECT_ASSEMBLY.cs @@ -60,7 +60,7 @@ namespace medical.transfomer.entity /// 默认值: /// [SugarColumn(ColumnName="ID" ,IsPrimaryKey = true,IsIdentity = true) ] - public decimal ID { get; set; } + public decimal? ID { get; set; } } diff --git a/medical.jzyb.entity/STD/STD_OBJECT_MAPPING.cs b/medical.jzyb.entity/STD/STD_OBJECT_MAPPING.cs index 1c8750c..f14d757 100644 --- a/medical.jzyb.entity/STD/STD_OBJECT_MAPPING.cs +++ b/medical.jzyb.entity/STD/STD_OBJECT_MAPPING.cs @@ -11,92 +11,99 @@ namespace medical.transfomer.entity [SugarTable("STD_OBJECT_MAPPING")] public class STD_OBJECT_MAPPING { - - + + + /// + /// 备 注:主键 + /// 默认值: + /// + [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)] + public decimal? ID { get; set; } + /// /// 备 注:本地系统名称(如姓名 年龄) /// 默认值: /// - [SugarColumn(ColumnName="SYSTEM_NAME" ) ] - public string? SYSTEM_NAME { get; set; } - + [SugarColumn(ColumnName = "SYSTEM_NAME")] + public string? SYSTEM_NAME { get; set; } + /// - /// 备 注:系统字段名(如name age) + /// 备 注:本地系统字段名(如name age) /// 默认值: /// - [SugarColumn(ColumnName="SYSTEM_FIELD" ) ] - public string? SYSTEM_FIELD { get; set; } - + [SugarColumn(ColumnName = "SYSTEM_FIELD")] + public string? SYSTEM_FIELD { get; set; } + /// - /// 备 注:医保接口字段名 + /// 备 注:对接系统名称 /// 默认值: /// - [SugarColumn(ColumnName="INTERFACE_NAME" ) ] - public string? INTERFACE_NAME { get; set; } - + [SugarColumn(ColumnName = "INTERFACE_NAME")] + public string? INTERFACE_NAME { get; set; } + /// - /// 备 注:医保字段名(需符合国标) + /// 备 注:对接系统字段名 /// 默认值: /// - [SugarColumn(ColumnName="INTERFACE_FIELD" ) ] - public string? INTERFACE_FIELD { get; set; } - + [SugarColumn(ColumnName = "INTERFACE_FIELD")] + public string? INTERFACE_FIELD { get; set; } + /// - /// 备 注:所属对象名(外键) + /// 备 注:对接系统表中文名 /// 默认值: /// - [SugarColumn(ColumnName="OBJECT_TABLE_NAME" ) ] - public string? OBJECT_TABLE_NAME { get; set; } - + [SugarColumn(ColumnName = "OBJECT_TABLE_CNNAME")] + public string? OBJECT_TABLE_CNNAME { get; set; } + /// - /// 备 注:所属对象存储表中文名 + /// 备 注:本地系统表中文名 /// 默认值: /// - [SugarColumn(ColumnName="OBJECT_TABLE_CNNAME" ) ] - public string? OBJECT_TABLE_CNNAME { get; set; } - + [SugarColumn(ColumnName = "SYSTEM_TABLE_CNNAME")] + public string? SYSTEM_TABLE_CNNAME { get; set; } + /// - /// 备 注:系统表中文名 + /// 备 注:本地系统表英文名 /// 默认值: /// - [SugarColumn(ColumnName="SYSTEM_TABLE_CNNAME" ) ] - public string? SYSTEM_TABLE_CNNAME { get; set; } - + [SugarColumn(ColumnName = "SYSTEM_TABLE_NAME")] + public string? SYSTEM_TABLE_NAME { get; set; } + /// - /// 备 注:系统表英文名 + /// 备 注:本地系统字段类型 /// 默认值: /// - [SugarColumn(ColumnName="SYSTEM_TABLE_NAME" ) ] - public string? SYSTEM_TABLE_NAME { get; set; } - + [SugarColumn(ColumnName = "SYSTEM_FIELD_TYPE")] + public string? SYSTEM_FIELD_TYPE { get; set; } + /// - /// 备 注:系统字段类型 + /// 备 注:本地系统字典名称 /// 默认值: /// - [SugarColumn(ColumnName="SYSTEM_FIELD_TYPE" ) ] - public decimal? SYSTEM_FIELD_TYPE { get; set; } - + [SugarColumn(ColumnName = "SYSTEM_DICT_NAME")] + public string? SYSTEM_DICT_NAME { get; set; } + /// - /// 备 注:系统字典名称 + /// 备 注:对接系统字段类型 /// 默认值: /// - [SugarColumn(ColumnName="SYSTEM_DICT_NAME" ) ] - public string? SYSTEM_DICT_NAME { get; set; } - + [SugarColumn(ColumnName = "OBJECT_FIELD_TYPE")] + public string? OBJECT_FIELD_TYPE { get; set; } + /// - /// 备 注:对接字段类型 + /// 备 注:对接系统字典名称 /// 默认值: /// - [SugarColumn(ColumnName="OBJECT_FIELD_TYPE" ) ] - public decimal? OBJECT_FIELD_TYPE { get; set; } - + [SugarColumn(ColumnName = "OBJECT_DICT_NAME")] + public string? OBJECT_DICT_NAME { get; set; } + /// - /// 备 注:对接字典名称 + /// 备 注:对接系统表英文名 /// 默认值: /// - [SugarColumn(ColumnName="OBJECT_DICT_NAME" ) ] - public string? OBJECT_DICT_NAME { get; set; } - + [SugarColumn(ColumnName = "OBJECT_TABLE_NAME")] + public string? OBJECT_TABLE_NAME { get; set; } + } diff --git a/medical.transfomer.business/std_object_mapping_business.cs b/medical.transfomer.business/std_object_mapping_business.cs index cb070e7..54196fd 100644 --- a/medical.transfomer.business/std_object_mapping_business.cs +++ b/medical.transfomer.business/std_object_mapping_business.cs @@ -1,5 +1,7 @@ -using medical.transfomer.entity; +using DocumentFormat.OpenXml.Drawing.Charts; +using medical.transfomer.entity; using ReZero.DependencyInjection; +using ReZero.SuperAPI; using SqlSugar; using System; using System.Collections.Generic; @@ -11,17 +13,45 @@ namespace medical.transfomer.business { public class std_object_mapping_business : IScopeContract { - //属性注入 - [DI] - public ISqlSugarClient? db { get; set; } + + + public ISqlSugarClient? db = ZeroDb.Db; + + public Task ExecuteAction(DataModel dataModel) + { + throw new NotImplementedException(); + } // 批量插入信息 public int ListInsert(List list) { - var result = new List(); - - return db.Insertable(list).ExecuteCommand(); + try + { + db!.Ado.BeginTran(); + + // 完全避免批量插入语法,改用循环逐条插入 + int result = 0; + foreach (var item in list) + { + // 不要设置ID为null,而是完全忽略ID列 + result += db!.Insertable(item) + .IgnoreColumns(it => new { it.ID }) // 完全忽略ID列,让Oracle生成 + .ExecuteCommand(); + } + + db!.Ado.CommitTran(); + return result; + } + catch (Exception ex) + { + db!.Ado.RollbackTran(); + // 记录错误详情以便调试 + Console.WriteLine($"Oracle插入错误: {ex.Message}"); + if (ex.InnerException != null) + Console.WriteLine($"内部错误: {ex.InnerException.Message}"); + throw; + } } } }