From 5c2bbe0eb68c53b8071013cab17b3b0be9a990ff Mon Sep 17 00:00:00 2001 From: dev02 Date: Thu, 11 May 2023 20:05:44 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=BE=8C=E7=AB=AF]=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=B0=B4=E9=9B=BB=E8=A1=A8=E5=88=97=E8=A1=A8=E9=8C=AF=E8=AA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/HydroMeterController.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/FrontendWebApi/ApiControllers/HydroMeterController.cs b/FrontendWebApi/ApiControllers/HydroMeterController.cs index 94790e5..d6d2f2a 100644 --- a/FrontendWebApi/ApiControllers/HydroMeterController.cs +++ b/FrontendWebApi/ApiControllers/HydroMeterController.cs @@ -53,17 +53,17 @@ namespace FrontendWebApi.ApiControllers : input.tableType == "month" ? input.startTime + "-01-01" : null; ; var endTime = input.tableType == "day" || input.tableType == "week" - ? input.startTime.Split("-")[0] + "-" + (input.startTime.Split("-")[1] + 1).ToString().PadLeft(2,'0') + "-01" - : input.tableType == "month" ? (input.startTime.Split("-")[0] + 1) + "-01-01" + ? input.startTime.Split("-")[0] + "-" + (Int32.Parse(input.startTime.Split("-")[1]) + 1).ToString().PadLeft(2, '0') + "-01" + : input.tableType == "month" ? (Int32.Parse(input.startTime.Split("-")[0]) + 1) + "-01-01" : null; string sqlWhere = ""; if (input.floor_tag != null) - sqlWhere = $@" and substring_index(device_number, '_', 3) == @floor_tag"; + sqlWhere = $@" and substring_index(device_number, '_', 3) = @floor_tag"; var table = "archive_electric_meter_" + input.tableType; var dateFormat = input.tableType == "day" || input.tableType == "week" ? "%Y-%m-%d" : input.tableType == "month" ? "%Y-%m" : input.tableType == "year" ? "%Y" : null; var sql = $@"select device_number, avg_rawdata, DATE_FORMAT(start_timestamp, @dateFormat) as timeStamp from {table} - where start_timestamp >= @startTime and end_timestamp < @endTime and point = 'KWH' and substring_index(device_number, '_', 1) == @building_tag + where start_timestamp >= @startTime and end_timestamp < @endTime and point = 'KWH' and substring_index(device_number, '_', 1) = @building_tag {sqlWhere} order by created_at desc;"; var rawData = await backendRepository.GetAllAsync(sql, @@ -131,17 +131,17 @@ namespace FrontendWebApi.ApiControllers : input.tableType == "month" ? input.startTime + "-01-01" : null; ; var endTime = input.tableType == "day" || input.tableType == "week" - ? input.startTime.Split("-")[0] + (input.startTime.Split("-")[1] + 1).ToString() + "-01" - : input.tableType == "month" ? (input.startTime.Split("-")[0] + 1) + "-01-01" + ? input.startTime.Split("-")[0] + "-" + (Int32.Parse(input.startTime.Split("-")[1]) + 1).ToString().PadLeft(2, '0') + "-01" + : input.tableType == "month" ? (Int32.Parse(input.startTime.Split("-")[0]) + 1) + "-01-01" : null; string sqlWhere = ""; if (input.floor_tag != null) - sqlWhere = $@" and substring_index(device_number, '_', 3) == @floor_tag"; + sqlWhere = $@" and substring_index(device_number, '_', 3) = @floor_tag"; var table = "archive_water_meter_" + input.tableType; var dateFormat = input.tableType == "day" || input.tableType == "week" ? "%Y-%m-%d" : input.tableType == "month" ? "%Y-%m" : null; var sql = $@"select device_number, avg_rawdata, DATE_FORMAT(start_timestamp, @dateFormat) as timeStamp from @table - where start_timestamp >= @startTime and end_timestamp < @endTime and point = 'RCV' and substring_index(device_number, '_', 1) == @building_tag + where start_timestamp >= @startTime and end_timestamp < @endTime and point = 'RCV' and substring_index(device_number, '_', 1) = @building_tag {sqlWhere} order by created_at desc;"; var rawData = await backendRepository.GetAllAsync(sql,