Commit e0d1c8ad by 纪旭 韦

增加一些默认查询超时时间

parent ae375ac7
...@@ -390,20 +390,20 @@ public List<EmployeeReservedDto> GetEmployeeReserved(ReservedRequest request) ...@@ -390,20 +390,20 @@ public List<EmployeeReservedDto> GetEmployeeReserved(ReservedRequest request)
string view = request.Source == 1 ? "view_allot_result_report_emp" : request.Source == 2 ? "view_allot_result_report_issue": request.Source == 3 ? "view_allot_result_report":""; string view = request.Source == 1 ? "view_allot_result_report_emp" : request.Source == 2 ? "view_allot_result_report_issue": request.Source == 3 ? "view_allot_result_report":"";
string sql = $"SELECT * FROM {view} WHERE HospitalID=@HospitalID AND Year=@Year"; string sql = $"SELECT * FROM {view} WHERE HospitalID=@HospitalID AND Year=@Year";
return DapperQuery<EmployeeReservedDto>(sql, new { HospitalID = request.HospitalId, Year = request.Year })?.ToList(); return DapperQuery<EmployeeReservedDto>(sql, new { HospitalID = request.HospitalId, Year = request.Year }, commandTimeout: 60 * 10)?.ToList();
} }
public List<view_allot_result> GetOwnerPerformance(List<int> hospitalId, string jobNumber) public List<view_allot_result> GetOwnerPerformance(List<int> hospitalId, string jobNumber)
{ {
string sql = "SELECT * FROM view_allot_result WHERE States IN (6,8) AND HospitalID IN @HospitalID AND JobNumber=@JobNumber"; string sql = "SELECT * FROM view_allot_result WHERE States IN (6,8) AND HospitalID IN @HospitalID AND JobNumber=@JobNumber";
return DapperQuery<view_allot_result>(sql, new { HospitalID = hospitalId, JobNumber = jobNumber })?.ToList(); return DapperQuery<view_allot_result>(sql, new { HospitalID = hospitalId, JobNumber = jobNumber }, commandTimeout: 60 * 10)?.ToList();
} }
public List<dynamic> QueryCompute(int allotId, string viewName) public List<dynamic> QueryCompute(int allotId, string viewName)
{ {
var sql = $@"SELECT * FROM {viewName} WHERE AllotId = @AllotId; "; var sql = $@"SELECT * FROM {viewName} WHERE AllotId = @AllotId; ";
return DapperQuery<dynamic>(sql, new { allotId })?.ToList(); return DapperQuery<dynamic>(sql, new { allotId }, commandTimeout: 60 * 10)?.ToList();
} }
public List<dynamic> QueryComputeByDate(string viewName, BeginEndTime request) public List<dynamic> QueryComputeByDate(string viewName, BeginEndTime request)
...@@ -423,7 +423,7 @@ public List<dynamic> QueryComputeByDate(string viewName, BeginEndTime request) ...@@ -423,7 +423,7 @@ public List<dynamic> QueryComputeByDate(string viewName, BeginEndTime request)
else else
sql += $" order by hospitalid,code,unittype,accountingunit"; sql += $" order by hospitalid,code,unittype,accountingunit";
return DapperQuery<dynamic>(sql, new { beginTime = request.BeginTime, endTime = request.EndTime }).ToList(); return DapperQuery<dynamic>(sql, new { beginTime = request.BeginTime, endTime = request.EndTime }, commandTimeout: 60 * 10).ToList();
} }
public List<dynamic> QueryComputeByDateAndTotal(string viewName, HospitalGrantSummary request) public List<dynamic> QueryComputeByDateAndTotal(string viewName, HospitalGrantSummary request)
...@@ -468,7 +468,7 @@ public List<dynamic> QueryComputeByDateAndTotal(string viewName, HospitalGrantSu ...@@ -468,7 +468,7 @@ public List<dynamic> QueryComputeByDateAndTotal(string viewName, HospitalGrantSu
} }
//sql = $"select {string.Join(",", request.GroupBy)}, {string.Join(",", request.SumBy.Select(t => $"sum({t}) {t}"))} from ({sql}) tab group by {string.Join(",", request.GroupBy)}"; //sql = $"select {string.Join(",", request.GroupBy)}, {string.Join(",", request.SumBy.Select(t => $"sum({t}) {t}"))} from ({sql}) tab group by {string.Join(",", request.GroupBy)}";
return DapperQuery<dynamic>(sql, new { beginTime = request.BeginTime, endTime = request.EndTime }).ToList(); return DapperQuery<dynamic>(sql, new { beginTime = request.BeginTime, endTime = request.EndTime },commandTimeout: 60*10).ToList();
} }
public (List<dynamic> list, int count) QueryComputePageData(string query, object param = null) public (List<dynamic> list, int count) QueryComputePageData(string query, object param = null)
...@@ -505,8 +505,8 @@ public CustonPagingData QueryCustom(string tableName, int allotId, string accoun ...@@ -505,8 +505,8 @@ public CustonPagingData QueryCustom(string tableName, int allotId, string accoun
var result = new CustonPagingData var result = new CustonPagingData
{ {
DataList = DapperQuery<dynamic>(dataQuery, new { allotId, unitType, accountingUnit })?.ToList(), DataList = DapperQuery<dynamic>(dataQuery, new { allotId, unitType, accountingUnit }, commandTimeout: 60 * 10)?.ToList(),
TotalCount = DapperQuery<int>(countQuery, new { allotId, unitType, accountingUnit })?.FirstOrDefault() ?? 0, TotalCount = DapperQuery<int>(countQuery, new { allotId, unitType, accountingUnit }, commandTimeout: 60 * 10)?.FirstOrDefault() ?? 0,
}; };
return result; return result;
...@@ -534,10 +534,10 @@ public CustonPagingData QueryCustom(CustomPagingRequest request, bool IsHead) ...@@ -534,10 +534,10 @@ public CustonPagingData QueryCustom(CustomPagingRequest request, bool IsHead)
sql = $@"SELECT * FROM {request.TableName} WHERE AllotId = @AllotId {Query} order by UnitType,AccountingUnit LIMIT {(request.PageIndex - 1) * request.PageSize},{request.PageSize} "; sql = $@"SELECT * FROM {request.TableName} WHERE AllotId = @AllotId {Query} order by UnitType,AccountingUnit LIMIT {(request.PageIndex - 1) * request.PageSize},{request.PageSize} ";
result.DataList = DapperQuery<dynamic>(sql, new { request.AllotId })?.ToList(); result.DataList = DapperQuery<dynamic>(sql, new { request.AllotId }, commandTimeout: 60 * 10)?.ToList();
sql = $@"SELECT COUNT(*) FROM {request.TableName} WHERE AllotId = @AllotId {Query} "; sql = $@"SELECT COUNT(*) FROM {request.TableName} WHERE AllotId = @AllotId {Query} ";
result.TotalCount = DapperQuery<int>(sql, new { request.AllotId })?.FirstOrDefault() ?? 0; result.TotalCount = DapperQuery<int>(sql, new { request.AllotId }, commandTimeout: 60 * 10)?.FirstOrDefault() ?? 0;
return result; return result;
} }
...@@ -546,7 +546,7 @@ public bool QueryIsAllotId(string tableName, params string[] columns) ...@@ -546,7 +546,7 @@ public bool QueryIsAllotId(string tableName, params string[] columns)
var database = context.Database.GetDbConnection().Database; var database = context.Database.GetDbConnection().Database;
var sql = $@"SELECT column_name FROM information_schema.COLUMNS s var sql = $@"SELECT column_name FROM information_schema.COLUMNS s
WHERE table_name = @table_name AND TABLE_SCHEMA = @database AND column_name in @columns;"; WHERE table_name = @table_name AND TABLE_SCHEMA = @database AND column_name in @columns;";
var result = DapperQuery<string>(sql, new { database = database, table_name = tableName, columns }); var result = DapperQuery<string>(sql, new { database = database, table_name = tableName, columns }, commandTimeout: 60 * 10);
var isExist = result?.Count() == 3; var isExist = result?.Count() == 3;
...@@ -558,7 +558,7 @@ public List<ColumnEntity> QueryCustomColumn(string tableName) ...@@ -558,7 +558,7 @@ public List<ColumnEntity> QueryCustomColumn(string tableName)
{ {
var database = context.Database.GetDbConnection().Database; var database = context.Database.GetDbConnection().Database;
var sql = $@"SELECT column_name as Name,ifnull(column_comment,column_name) as comment FROM information_schema.`COLUMNS` WHERE table_schema = @table_schema AND table_name = @table_name AND COLUMN_KEY <> 'PRI' "; var sql = $@"SELECT column_name as Name,ifnull(column_comment,column_name) as comment FROM information_schema.`COLUMNS` WHERE table_schema = @table_schema AND table_name = @table_name AND COLUMN_KEY <> 'PRI' ";
var result = DapperQuery<ColumnEntity>(sql, new { table_schema = database, table_name = tableName })?.ToList(); var result = DapperQuery<ColumnEntity>(sql, new { table_schema = database, table_name = tableName }, commandTimeout: 60 * 10)?.ToList();
return result; return result;
} }
...@@ -573,7 +573,7 @@ public bool CreatCustom(int AllotId, string tableName, List<dynamic> datas) ...@@ -573,7 +573,7 @@ public bool CreatCustom(int AllotId, string tableName, List<dynamic> datas)
var database = context.Database.GetDbConnection().Database; var database = context.Database.GetDbConnection().Database;
sql = $@"SELECT column_name FROM information_schema.COLUMNS s sql = $@"SELECT column_name FROM information_schema.COLUMNS s
WHERE table_name = @table_name AND TABLE_SCHEMA = @database AND COLUMN_KEY <> 'PRI';"; WHERE table_name = @table_name AND TABLE_SCHEMA = @database AND COLUMN_KEY <> 'PRI';";
var columns = DapperQuery<string>(sql, new { database = database, table_name = tableName })?.ToList(); var columns = DapperQuery<string>(sql, new { database = database, table_name = tableName }, commandTimeout: 60 * 10)?.ToList();
sql = $"INSERT INTO {tableName}({string.Join(",", columns.ToArray())}) VALUES({string.Join(",", columns.Select(t => "@" + t))});"; sql = $"INSERT INTO {tableName}({string.Join(",", columns.ToArray())}) VALUES({string.Join(",", columns.Select(t => "@" + t))});";
...@@ -588,7 +588,7 @@ public List<dynamic> QueryType(string tableName) ...@@ -588,7 +588,7 @@ public List<dynamic> QueryType(string tableName)
{ {
var database = context.Database.GetDbConnection().Database; var database = context.Database.GetDbConnection().Database;
var sql = $@"select column_name,data_type from information_schema.columns where table_name=@table_name and table_schema=@table_schema AND (data_type like '%int%' or data_type like '%decimal%' or data_type like '%date%') AND COLUMN_KEY <> 'PRI' "; var sql = $@"select column_name,data_type from information_schema.columns where table_name=@table_name and table_schema=@table_schema AND (data_type like '%int%' or data_type like '%decimal%' or data_type like '%date%') AND COLUMN_KEY <> 'PRI' ";
var result = DapperQuery<dynamic>(sql, new { table_schema = database, table_name = tableName })?.ToList(); var result = DapperQuery<dynamic>(sql, new { table_schema = database, table_name = tableName }, commandTimeout: 60 * 10)?.ToList();
return result; return result;
} }
......
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