[後端] 修改水電表列表錯誤

This commit is contained in:
dev02 2023-05-11 20:05:44 +08:00
parent f95d7109c6
commit 5c2bbe0eb6

View File

@ -53,17 +53,17 @@ 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().PadLeft(2,'0') + "-01"
: input.tableType == "month" ? (input.startTime.Split("-")[0] + 1) + "-01-01"
? input.startTime.Split("-")[0] + "-" + (Int32.Parse(input.startTime.Split("-")[1]) + 1).ToString().PadLeft(2, '0') + "-01"
: input.tableType == "month" ? (Int32.Parse(input.startTime.Split("-")[0]) + 1) + "-01-01"
: null;
string sqlWhere = "";
if (input.floor_tag != null)
sqlWhere = $@" and substring_index(device_number, '_', 3) == @floor_tag";
sqlWhere = $@" and substring_index(device_number, '_', 3) = @floor_tag";
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}
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}
order by created_at desc;";
var rawData = await backendRepository.GetAllAsync<HydroMeterRawDataOutput>(sql,
@ -131,17 +131,17 @@ 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.tableType == "month" ? (input.startTime.Split("-")[0] + 1) + "-01-01"
? input.startTime.Split("-")[0] + "-" + (Int32.Parse(input.startTime.Split("-")[1]) + 1).ToString().PadLeft(2, '0') + "-01"
: input.tableType == "month" ? (Int32.Parse(input.startTime.Split("-")[0]) + 1) + "-01-01"
: null;
string sqlWhere = "";
if (input.floor_tag != null)
sqlWhere = $@" and substring_index(device_number, '_', 3) == @floor_tag";
sqlWhere = $@" and substring_index(device_number, '_', 3) = @floor_tag";
var table = "archive_water_meter_" + input.tableType;
var dateFormat = input.tableType == "day" || input.tableType == "week" ? "%Y-%m-%d" : input.tableType == "month" ? "%Y-%m" : null;
var sql = $@"select device_number, avg_rawdata, DATE_FORMAT(start_timestamp, @dateFormat) as timeStamp
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}
order by created_at desc;";
var rawData = await backendRepository.GetAllAsync<HydroMeterRawDataOutput>(sql,