From f95d7109c69b05f0f9955a412803200f613985a7 Mon Sep 17 00:00:00 2001 From: dev01 Date: Thu, 11 May 2023 18:40:23 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=89=8D=E5=8F=B0]=20=E4=BF=AE=E6=AD=A3=20Get?= =?UTF-8?q?AllFlooor=20API=20=E9=83=A8=E5=88=86=E7=A8=8B=E5=BA=8F=20|=20?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20MeterList=20=E9=83=A8=E5=88=86=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FrontendWebApi/ApiControllers/BuildController.cs | 10 +++++----- FrontendWebApi/ApiControllers/HydroMeterController.cs | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/FrontendWebApi/ApiControllers/BuildController.cs b/FrontendWebApi/ApiControllers/BuildController.cs index af06e51..a71651c 100644 --- a/FrontendWebApi/ApiControllers/BuildController.cs +++ b/FrontendWebApi/ApiControllers/BuildController.cs @@ -693,9 +693,9 @@ namespace FrontendWebApi.ApiControllers [HttpPost] [Route("api/GetAllfloor")] - public async Task>>> GetAllfloor(string building_tag) + public async Task>>> GetAllfloor(string building_tag) { - ApiResult> apiResult = new ApiResult>(jwt_str); + ApiResult> apiResult = new ApiResult>(jwt_str); if (!jwtlife) { apiResult.Code = "5000"; @@ -705,10 +705,10 @@ namespace FrontendWebApi.ApiControllers { string sWhere = $@" SELECT - full_name + floor_guid,full_name,building_tag FROM floor - where building_guid = @building_tag and deleted = 0"; - var floor = await backendRepository.GetAllAsync(sWhere, new { building_tag = building_tag }); + where building_tag = @building_tag and deleted = 0"; + var floor = await backendRepository.GetAllAsync(sWhere, new { building_tag = building_tag }); apiResult.Data = floor; apiResult.Code = "0000"; diff --git a/FrontendWebApi/ApiControllers/HydroMeterController.cs b/FrontendWebApi/ApiControllers/HydroMeterController.cs index 8ff4b5e..94790e5 100644 --- a/FrontendWebApi/ApiControllers/HydroMeterController.cs +++ b/FrontendWebApi/ApiControllers/HydroMeterController.cs @@ -39,7 +39,7 @@ namespace FrontendWebApi.ApiControllers apiResult.Msg = "棟別沒有被選取"; return BadRequest(apiResult); } - else if (input.tableType == null || tableType.Contains(input.tableType)) + else if (input.tableType == null || !tableType.Contains(input.tableType)) { apiResult.Code = "9999"; apiResult.Msg = "表單類別錯誤"; @@ -53,7 +53,7 @@ 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.startTime.Split("-")[0] + "-" + (input.startTime.Split("-")[1] + 1).ToString().PadLeft(2,'0') + "-01" : input.tableType == "month" ? (input.startTime.Split("-")[0] + 1) + "-01-01" : null; string sqlWhere = ""; @@ -62,7 +62,7 @@ namespace FrontendWebApi.ApiControllers 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 + from {table} 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;";