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;";