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,