From 0ec125e0e0e020c442b0a779cd8760946f635f23 Mon Sep 17 00:00:00 2001 From: dev02 Date: Mon, 29 Jan 2024 14:10:39 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=BE=8C=E7=AB=AF]=20=E8=AA=BF=E6=95=B4?= =?UTF-8?q?=E6=96=B0=E9=9C=80=E6=B1=82=E6=9E=B6=E6=A7=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FrontendWebApi/ApiControllers/HistoryController.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/FrontendWebApi/ApiControllers/HistoryController.cs b/FrontendWebApi/ApiControllers/HistoryController.cs index 3f99f55..d67aaf8 100644 --- a/FrontendWebApi/ApiControllers/HistoryController.cs +++ b/FrontendWebApi/ApiControllers/HistoryController.cs @@ -1326,11 +1326,13 @@ namespace FrontendWebApi.ApiControllers var device_item_infos = await frontendRepository.GetAllAsync(sqlDeviceItemInfo, new { Device_number = device_number }); var device_item_info = device_item_infos.Where(x => x.Device_number == device_number && x.Points == point).FirstOrDefault(); + var valueType = await backgroundServiceMsSqlRepository.GetOneAsync($"select Data_Type from INFORMATION_SCHEMA.COLUMNS where table_name = '{tableName}' and column_name = 'Value'"); 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.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, + {(valueType.Equals("bit") ? "Case when value = 1 then 'true' when value = 0 then 'false' else 'Unknow' End" : "round(value, 2)")} as Value from {tableName} where replace(convert(varchar, [timestamp], 111), '/', '-') >= @startTime and replace(convert(varchar, [timestamp], 111), '/', '-') <= @endTime order by timestamp";