[後端] 修改判斷table存在問題

This commit is contained in:
dev02 2023-05-17 10:41:47 +08:00
parent da9b6f678d
commit 8840d501ed

View File

@ -1148,7 +1148,9 @@ namespace FrontendWebApi.ApiControllers
{ {
var device_number = hi.Device_number_point.Split(":")[0]; var device_number = hi.Device_number_point.Split(":")[0];
var point = hi.Device_number_point.Split(":")[1]; var point = hi.Device_number_point.Split(":")[1];
//var tableName = await backgroundServiceMsSqlRepository.GetAllAsync<string>($"select table_name from INFORMATION_SCHEMA.TABLES where table_name like '%{device_number}%'"); var tableName = await backgroundServiceMsSqlRepository.GetOneAsync<string>($"select table_name from INFORMATION_SCHEMA.TABLES where table_name like '%{device_number}_{point}%'");
if (!string.IsNullOrEmpty(tableName))
{
var device_item_infos = await frontendRepository.GetAllAsync<DeviceItemInfo>(sqlDeviceItemInfo, new { Device_number = hi.Device_number_point }); var device_item_infos = await frontendRepository.GetAllAsync<DeviceItemInfo>(sqlDeviceItemInfo, new { Device_number = hi.Device_number_point });
var device_item_info = device_item_infos.Where(x => x.Device_number == device_number && x.Points == point).FirstOrDefault(); var device_item_info = device_item_infos.Where(x => x.Device_number == device_number && x.Points == point).FirstOrDefault();
@ -1163,6 +1165,7 @@ namespace FrontendWebApi.ApiControllers
apiResult.Data.AddRange( apiResult.Data.AddRange(
await backgroundServiceMsSqlRepository.GetAllAsync<HistoryRawData>(sql, new { startTime = input.Start_timestamp, endTime = input.End_timestamp }) await backgroundServiceMsSqlRepository.GetAllAsync<HistoryRawData>(sql, new { startTime = input.Start_timestamp, endTime = input.End_timestamp })
); );
}
//foreach (var tn in tableName) //foreach (var tn in tableName)
//{ //{
//} //}