[後端] 修改水電表列表年份問題
This commit is contained in:
parent
c3b09e6452
commit
93fb080c01
@ -73,11 +73,11 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
|
|
||||||
if (input.tableType == "year")
|
if (input.tableType == "year")
|
||||||
{
|
{
|
||||||
sqlGroup = $@" group by DATE_FORMAT(start_timestamp, @dateFormat), DATE_FORMAT(end_timestamp, @dateFormat), device_number ";
|
sqlGroup = $@" group by year(start_timestamp), year(end_timestamp), device_number ";
|
||||||
sqlAvgRawData = " round(avg(avg_rawdata), 2) as avg_rawdata";
|
sqlAvgRawData = " round(avg(avg_rawdata), 2) as avg_rawdata, year(start_timestamp) as start_timestamp, year(end_timestamp) as end_timestamp ";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
sqlAvgRawData = " round(avg_rawdata, 2) as avg_rawdata";
|
sqlAvgRawData = " round(avg_rawdata, 2) as avg_rawdata, start_timestamp, end_timestamp ";
|
||||||
|
|
||||||
var table = input.tableType == "year" ? "archive_electric_meter_day" : "archive_electric_meter_" + input.tableType;
|
var table = input.tableType == "year" ? "archive_electric_meter_day" : "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;
|
||||||
@ -101,7 +101,7 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
)
|
)
|
||||||
) fd
|
) fd
|
||||||
left join (
|
left join (
|
||||||
select device_number, {sqlAvgRawData}, start_timestamp, end_timestamp
|
select device_number, {sqlAvgRawData}
|
||||||
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} {sqlGroup}
|
{sqlWhere} {sqlGroup}
|
||||||
@ -192,11 +192,11 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
|
|
||||||
if (input.tableType == "year")
|
if (input.tableType == "year")
|
||||||
{
|
{
|
||||||
sqlGroup = $@" group by DATE_FORMAT(start_timestamp, @dateFormat), DATE_FORMAT(end_timestamp, @dateFormat), device_number ";
|
sqlGroup = $@" group by year(start_timestamp), year(end_timestamp), device_number ";
|
||||||
sqlAvgRawData = " round(avg(avg_rawdata), 2) as avg_rawdata";
|
sqlAvgRawData = " round(avg(avg_rawdata), 2) as avg_rawdata, year(start_timestamp) as start_timestamp, year(end_timestamp) as end_timestamp ";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
sqlAvgRawData = " round(avg_rawdata, 2) as avg_rawdata";
|
sqlAvgRawData = " round(avg_rawdata, 2) as avg_rawdata, start_timestamp, end_timestamp ";
|
||||||
|
|
||||||
var table = input.tableType == "year" ? "archive_water_meter_day" : "archive_water_meter_" + input.tableType;
|
var table = input.tableType == "year" ? "archive_water_meter_day" : "archive_water_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;
|
||||||
@ -220,7 +220,7 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
)
|
)
|
||||||
) fd
|
) fd
|
||||||
left join (
|
left join (
|
||||||
select device_number, {sqlAvgRawData}, start_timestamp, end_timestamp
|
select device_number, {sqlAvgRawData}
|
||||||
from {table}
|
from {table}
|
||||||
where start_timestamp >= @startTime and end_timestamp < @endTime and point = 'RCV' and SUBSTRING_INDEX(device_number, '_', 1) = @building_tag
|
where start_timestamp >= @startTime and end_timestamp < @endTime and point = 'RCV' and SUBSTRING_INDEX(device_number, '_', 1) = @building_tag
|
||||||
{sqlWhere} {sqlGroup}
|
{sqlWhere} {sqlGroup}
|
||||||
|
@ -10,7 +10,7 @@ namespace FrontendWebApi.Models
|
|||||||
|
|
||||||
public class HydroMeterInput
|
public class HydroMeterInput
|
||||||
{
|
{
|
||||||
public string tableType { get; set; } //day, week, month
|
public string tableType { get; set; } //day, week, month, year
|
||||||
public string building_tag { get; set; }
|
public string building_tag { get; set; }
|
||||||
public List<string> floor_tag { get; set; }
|
public List<string> floor_tag { get; set; }
|
||||||
public string startTime { get; set; }
|
public string startTime { get; set; }
|
||||||
|
Loading…
Reference in New Issue
Block a user