[後端] 修改判斷table存在問題
This commit is contained in:
parent
da9b6f678d
commit
8840d501ed
@ -1148,21 +1148,24 @@ 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}%'");
|
||||||
var device_item_infos = await frontendRepository.GetAllAsync<DeviceItemInfo>(sqlDeviceItemInfo, new { Device_number = hi.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_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();
|
||||||
|
|
||||||
var sql = $@"select '{device_item_info.Building_name}' as Building_name, '{device_item_info.Main_system_name}' as Main_system_name,
|
var sql = $@"select '{device_item_info.Building_name}' as Building_name, '{device_item_info.Main_system_name}' as Main_system_name,
|
||||||
'{device_item_info.Sub_system_name}' as Sub_system_name', {device_item_info.Device_number}' as Device_number,
|
'{device_item_info.Sub_system_name}' as Sub_system_name', {device_item_info.Device_number}' as Device_number,
|
||||||
'{device_item_info.Device_name}' as Device_name, '{device_item_info.Item_name}' as Item_name, '{device_item_info.Points}' as Points,
|
'{device_item_info.Device_name}' as Device_name, '{device_item_info.Item_name}' as Item_name, '{device_item_info.Points}' as Points,
|
||||||
'{device_item_info.Unit}' as Unit, timestamp as Timestamp, round(value, 2) as Value
|
'{device_item_info.Unit}' as Unit, timestamp as Timestamp, round(value, 2) as Value
|
||||||
from FIC_CENTER_{device_number}_{point}
|
from FIC_CENTER_{device_number}_{point}
|
||||||
where replace(convert(varchar, [timestamp], 111), '/', '-') >= @startTime
|
where replace(convert(varchar, [timestamp], 111), '/', '-') >= @startTime
|
||||||
and replace(convert(varchar, [timestamp], 111), '/', '-') <= @endTime order by timestamp";
|
and replace(convert(varchar, [timestamp], 111), '/', '-') <= @endTime order by timestamp";
|
||||||
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)
|
||||||
//{
|
//{
|
||||||
//}
|
//}
|
||||||
|
Loading…
Reference in New Issue
Block a user