Commit 2b16cb62 by 纪旭 韦

Merge branch 'develop' of http://192.168.18.110:8880/zry/performance into 手工录入_

parents d76e0d33 31aa5153
......@@ -204,5 +204,26 @@ public void BulkDelete(IEnumerable<TEntity> entities)
}
#endregion Bulk
public int InsertExecute(IEnumerable<TEntity> data)
{
if (data == null || !data.Any()) return 0;
try
{
string tableName = typeof(TEntity).Name.ToLower();
string database = context.Database.GetDbConnection().Database;
var query = $"select distinct lower(column_name) from information_schema.columns where table_schema = '{database}' and lower(table_name) = '{tableName}' and lower(column_name) <> 'id'";
var columns = DapperQuery<string>(query, new { });
if (columns == null || !columns.Any()) return 0;
var exec = $"insert into {tableName}({string.Join(", ", columns)}) values({string.Join(", ", columns.Select(t => "@" + t))});";
return Execute(exec, data, commandTimeout: 1000 * 60 * 60);
}
catch
{
return 0;
}
}
}
}
......@@ -203,8 +203,15 @@ private List<ex_result> ExtractModuleData(per_allot allot, string groupName, boo
try
{
try
{
if (!pools.ContainsKey(config.Id))
pools.Add(config.Id, ConnectionBuilder.Create((DatabaseType)config.DataBaseType, config.DbSource, config.DbName, config.DbUser, config.DbPassword));
}
catch
{
logService.ReturnTheLog(allot.ID, groupName, 2, "数据库连接", $"数据库“{config.DbName}”连接失败", 3, isSingle);
}
IDbConnection connection = pools[config.Id];
......@@ -229,7 +236,7 @@ private List<ex_result> ExtractModuleData(per_allot allot, string groupName, boo
AllotId = allot.ID,
CreateTime = CreateTime,
}).ToList();
exresultRepository.AddRange(result.ToArray());
exresultRepository.InsertExecute(result.ToArray());
data.AddRange(result);
});
}
......@@ -238,8 +245,7 @@ private List<ex_result> ExtractModuleData(per_allot allot, string groupName, boo
}
catch (Exception ex)
{
logger.LogError($"数据库“{config.DbName}”连接失败: {ex}; {Infrastructure.JsonHelper.Serialize(script)}");
logService.ReturnTheLog(allot.ID, groupName, 2, "数据库连接", $"数据库“{config.DbName}”连接失败", 3, isSingle);
logger.LogError($"typeId: {typeId}提取数据异常{ex}{Infrastructure.JsonHelper.Serialize(script)}");
}
}
}
......@@ -301,7 +307,7 @@ private List<ex_result> ExtractItemData(per_allot allot, string groupName, bool
AllotId = allot.ID,
CreateTime = CreateTime,
}).ToList();
exresultRepository.AddRange(result.ToArray());
exresultRepository.InsertExecute(result.ToArray());
data.AddRange(result);
});
}
......@@ -364,7 +370,7 @@ private List<ex_result> ExtractSpecialData(per_allot allot, string groupName, bo
AllotId = allot.ID,
CreateTime = CreateTime,
}).ToList();
exresultRepository.AddRange(result.ToArray());
exresultRepository.InsertExecute(result.ToArray());
data.AddRange(result);
});
}
......
......@@ -225,7 +225,7 @@ public void ImportAllotData(int hospitalId, string filePath)
{
hisimportbaiscnormRepository.DeleteFromQuery(t => t.HospitalId == hospitalId && t.Year == item.Year && t.Month == item.Month);
}
hisimportbaiscnormRepository.BulkInsert(basicnormData);
hisimportbaiscnormRepository.InsertExecute(basicnormData);
}
#endregion 科室总绩效 人均绩效
......@@ -276,7 +276,7 @@ private void ImportBasicData(ISheet sheet, List<string> columns, int hospitalId,
{
hisimportdataRepository.DeleteFromQuery(t => t.HospitalId == hospitalId && t.Category == sheetName && t.Year == item.Year && t.Month == item.Month);
}
hisimportdataRepository.BulkInsert(data.Where(t => t.Year != 0 && t.Month != 0));
hisimportdataRepository.InsertExecute(data.Where(t => t.Year != 0 && t.Month != 0));
}
private void ImporAccountData(ISheet sheet, List<string> columns, int hospitalId, List<per_allot> allots, List<his_import_baiscnorm> basicnormData)
......@@ -342,7 +342,7 @@ private void ImporAccountData(ISheet sheet, List<string> columns, int hospitalId
{
hisimportaccountRepository.DeleteFromQuery(t => t.HospitalId == hospitalId && t.Year == item.Year && t.Month == item.Month);
}
hisimportaccountRepository.BulkInsert(data.Where(t => t.Year != 0 && t.Month != 0));
hisimportaccountRepository.InsertExecute(data.Where(t => t.Year != 0 && t.Month != 0));
#endregion his_import_account
}
......@@ -377,7 +377,7 @@ private void ImporAccountTag(ISheet sheet, List<string> columns, int hospitalId)
});
reportperformancetagsRepository.DeleteFromQuery(t => t.HospitalId == hospitalId);
reportperformancetagsRepository.BulkInsert(data.Where(t => !string.IsNullOrEmpty(t.UnitType) && !string.IsNullOrEmpty(t.AccountingUnit)));
reportperformancetagsRepository.InsertExecute(data.Where(t => !string.IsNullOrEmpty(t.UnitType) && !string.IsNullOrEmpty(t.AccountingUnit)));
}
private void ImporClinicData(ISheet sheet, List<string> columns, int hospitalId, List<per_allot> allots, List<his_import_baiscnorm> basicnormData)
......@@ -445,7 +445,7 @@ private void ImporClinicData(ISheet sheet, List<string> columns, int hospitalId,
{
hisimportclinicRepository.DeleteFromQuery(t => t.HospitalId == hospitalId && t.Year == item.Year && t.Month == item.Month);
}
hisimportclinicRepository.BulkInsert(data.Where(t => t.Year != 0 && t.Month != 0));
hisimportclinicRepository.InsertExecute(data.Where(t => t.Year != 0 && t.Month != 0));
#endregion his_import_clinic
}
......@@ -482,7 +482,7 @@ private void ImporClinicTag(ISheet sheet, List<string> columns, int hospitalId)
});
reportperformancepersontagsRepository.DeleteFromQuery(t => t.HospitalId == hospitalId);
reportperformancepersontagsRepository.BulkInsert(data.Where(t => !string.IsNullOrEmpty(t.PersonnelName) && !string.IsNullOrEmpty(t.PersonnelNumber)));
reportperformancepersontagsRepository.InsertExecute(data.Where(t => !string.IsNullOrEmpty(t.PersonnelName) && !string.IsNullOrEmpty(t.PersonnelNumber)));
}
private List<string> GetColumns(ISheet sheet, string sheetName, out string sourceType)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment