[前台] 修正 GetAllFlooor API 部分程序 | 修正 MeterList 部分程序
This commit is contained in:
parent
913aa9cbaf
commit
f95d7109c6
@ -693,9 +693,9 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("api/GetAllfloor")]
|
[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)
|
if (!jwtlife)
|
||||||
{
|
{
|
||||||
apiResult.Code = "5000";
|
apiResult.Code = "5000";
|
||||||
@ -705,10 +705,10 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
{
|
{
|
||||||
string sWhere = $@"
|
string sWhere = $@"
|
||||||
SELECT
|
SELECT
|
||||||
full_name
|
floor_guid,full_name,building_tag
|
||||||
FROM floor
|
FROM floor
|
||||||
where building_guid = @building_tag and deleted = 0";
|
where building_tag = @building_tag and deleted = 0";
|
||||||
var floor = await backendRepository.GetAllAsync<string>(sWhere, new { building_tag = building_tag });
|
var floor = await backendRepository.GetAllAsync<Floor>(sWhere, new { building_tag = building_tag });
|
||||||
|
|
||||||
apiResult.Data = floor;
|
apiResult.Data = floor;
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
|
@ -39,7 +39,7 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
apiResult.Msg = "棟別沒有被選取";
|
apiResult.Msg = "棟別沒有被選取";
|
||||||
return BadRequest(apiResult);
|
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.Code = "9999";
|
||||||
apiResult.Msg = "表單類別錯誤";
|
apiResult.Msg = "表單類別錯誤";
|
||||||
@ -53,7 +53,7 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
: input.tableType == "month" ? input.startTime + "-01-01"
|
: input.tableType == "month" ? input.startTime + "-01-01"
|
||||||
: null; ;
|
: null; ;
|
||||||
var endTime = input.tableType == "day" || input.tableType == "week"
|
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"
|
: input.tableType == "month" ? (input.startTime.Split("-")[0] + 1) + "-01-01"
|
||||||
: null;
|
: null;
|
||||||
string sqlWhere = "";
|
string sqlWhere = "";
|
||||||
@ -62,7 +62,7 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
var table = "archive_electric_meter_" + input.tableType;
|
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 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
|
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
|
where start_timestamp >= @startTime and end_timestamp < @endTime and point = 'KWH' and substring_index(device_number, '_', 1) == @building_tag
|
||||||
{sqlWhere}
|
{sqlWhere}
|
||||||
order by created_at desc;";
|
order by created_at desc;";
|
||||||
|
Loading…
Reference in New Issue
Block a user