[前台] 修正 GetAllFlooor API 部分程序 | 修正 MeterList 部分程序

This commit is contained in:
dev01 2023-05-11 18:40:23 +08:00
parent 913aa9cbaf
commit f95d7109c6
2 changed files with 8 additions and 8 deletions

View File

@ -693,9 +693,9 @@ namespace FrontendWebApi.ApiControllers
[HttpPost]
[Route("api/GetAllfloor")]
public async Task<ActionResult<ApiResult<List<string>>>> GetAllfloor(string building_tag)
public async Task<ActionResult<ApiResult<List<Floor>>>> GetAllfloor(string building_tag)
{
ApiResult<List<string>> apiResult = new ApiResult<List<string>>(jwt_str);
ApiResult<List<Floor>> apiResult = new ApiResult<List<Floor>>(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<string>(sWhere, new { building_tag = building_tag });
where building_tag = @building_tag and deleted = 0";
var floor = await backendRepository.GetAllAsync<Floor>(sWhere, new { building_tag = building_tag });
apiResult.Data = floor;
apiResult.Code = "0000";

View File

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