[儀錶板] 取得各棟總電表 api 建置

This commit is contained in:
dev01 2023-06-09 10:49:44 +08:00
parent afc2604353
commit f03491e9f6
2 changed files with 37 additions and 0 deletions

View File

@ -67,5 +67,35 @@ namespace FrontendWebApi.ApiControllers
}
return Ok(apiResult);
}
[HttpPost]
[Route("api/Dashboard/GetTotalElec")]
public async Task<ActionResult<ApiResult<List<TotalElec>>>> GetTotalElec()
{
ApiResult<List<TotalElec>> apiResult = new ApiResult<List<TotalElec>>();
try
{
var sqlString = $@"SELECT
system_key AS 'building_tag',
system_value AS 'device_number',
system_remark AS 'remark'
FROM variable
WHERE
system_type = 'dashboard_total_elec'
AND deleted = '0'";
var ess = await backendRepository.GetAllAsync<TotalElec>(sqlString);
apiResult.Code = "0000";
apiResult.Data = ess;
}
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
return Ok(apiResult);
}
return Ok(apiResult);
}
}
}

View File

@ -7,4 +7,11 @@
public int DispatchCnt{ get; set; }
public int NotDispatchCnt { get; set; }
}
public class TotalElec
{
public string building_tag { get; set; }
public string device_number { get; set; }
public string remark { get; set; }
}
}