1. 修改逆變器分析 讀取rawdata方式
This commit is contained in:
parent
fc06f498c6
commit
3c61e79575
@ -110,7 +110,13 @@ namespace SolarPower.Controllers
|
|||||||
StationCodeWithInverterIdsList.Add(stationCodeWithInverterIds);
|
StationCodeWithInverterIdsList.Add(stationCodeWithInverterIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
inverterHistories = await powerStationRepository.GetInverterHistoryRowData(post.SelectedDate, StationCodeWithInverterIdsList);
|
var date_start = Convert.ToDateTime(post.SelectedDate.Trim() + " 00:00:00");
|
||||||
|
var date_end = Convert.ToDateTime(post.SelectedDate.Trim() + " 23:59:59");
|
||||||
|
|
||||||
|
var start_timestamp = (long)date_start.Subtract(new DateTime(1970, 1, 1).AddHours(8)).TotalMilliseconds;
|
||||||
|
var end_timestamp = (long)date_end.Subtract(new DateTime(1970, 1, 1).AddHours(8)).TotalMilliseconds;
|
||||||
|
|
||||||
|
inverterHistories = await powerStationRepository.GetInverterHistoryRowData(start_timestamp, end_timestamp, StationCodeWithInverterIdsList);
|
||||||
|
|
||||||
analysisInverter.XAxis = inverterHistories.Select(x => x.TIMESTAMP).Distinct().ToList();
|
analysisInverter.XAxis = inverterHistories.Select(x => x.TIMESTAMP).Distinct().ToList();
|
||||||
|
|
||||||
|
|||||||
@ -4402,7 +4402,7 @@ namespace SolarPower.Repository.Implement
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<InverterHistory>> GetInverterHistoryRowData(string nowDay, List<StationCodeWithInverterIds> entities)
|
public async Task<List<InverterHistory>> GetInverterHistoryRowData(long start_timestamp, long end_timestamp, List<StationCodeWithInverterIds> entities)
|
||||||
{
|
{
|
||||||
List<InverterHistory> result;
|
List<InverterHistory> result;
|
||||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||||
@ -4466,16 +4466,19 @@ namespace SolarPower.Repository.Implement
|
|||||||
inv.RA4,
|
inv.RA4,
|
||||||
inv.RA5
|
inv.RA5
|
||||||
FROM {table_name} inv
|
FROM {table_name} inv
|
||||||
LEFT JOIN {sensor_table_name} sen ON FROM_UNIXTIME(inv.TIMESTAMP/1000, '%Y-%m-%d %H:%i') = FROM_UNIXTIME(sen.TIMESTAMP/1000, '%Y-%m-%d %H:%i')
|
LEFT JOIN (select * from {sensor_table_name} where TIMESTAMP between @start_timestamp and @end_timestamp)sen
|
||||||
|
ON FROM_UNIXTIME(inv.TIMESTAMP/1000, '%Y-%m-%d %H:%i') = FROM_UNIXTIME(sen.TIMESTAMP/1000, '%Y-%m-%d %H:%i')
|
||||||
|
-- LEFT JOIN {sensor_table_name} sen ON FROM_UNIXTIME(inv.TIMESTAMP/1000, '%Y-%m-%d %H:%i') = FROM_UNIXTIME(sen.TIMESTAMP/1000, '%Y-%m-%d %H:%i')
|
||||||
LEFT JOIN {entity.SiteDB}.inverter i ON inv.INVERTERID = i.InverterId
|
LEFT JOIN {entity.SiteDB}.inverter i ON inv.INVERTERID = i.InverterId
|
||||||
WHERE FROM_UNIXTIME(inv.TIMESTAMP/1000, '%Y-%m-%d') = @NowDay
|
WHERE inv.`TIMESTAMP` between @start_timestamp and @end_timestamp
|
||||||
|
-- WHERE FROM_UNIXTIME(inv.TIMESTAMP/1000, '%Y-%m-%d') = @NowDay
|
||||||
AND inv.INVERTERID IN ('{inverterIds}')";
|
AND inv.INVERTERID IN ('{inverterIds}')";
|
||||||
|
|
||||||
sql_perSiteDB.Add(temp_sql);
|
sql_perSiteDB.Add(temp_sql);
|
||||||
}
|
}
|
||||||
sql = "SELECT * FROM (" + string.Join(" UNION ", sql_perSiteDB) + ") a ORDER BY a.TIMESTAMP ASC";
|
sql = "SELECT * FROM (" + string.Join(" UNION ", sql_perSiteDB) + ") a ORDER BY a.TIMESTAMP ASC";
|
||||||
|
|
||||||
result = (await conn.QueryAsync<InverterHistory>(sql, new { NowDay = nowDay }, commandTimeout: 300)).ToList();
|
result = (await conn.QueryAsync<InverterHistory>(sql, new { start_timestamp = start_timestamp, end_timestamp = end_timestamp }, commandTimeout: 300)).ToList();
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -574,7 +574,7 @@ namespace SolarPower.Repository.Interface
|
|||||||
Task<List<PowerStation>> GetPowerStationsByCompanyId(MyUser myUser);
|
Task<List<PowerStation>> GetPowerStationsByCompanyId(MyUser myUser);
|
||||||
Task<List<PowerStationInverter>> GetPowerStationInverter(Dictionary<string, List<int>> dic, string filter);
|
Task<List<PowerStationInverter>> GetPowerStationInverter(Dictionary<string, List<int>> dic, string filter);
|
||||||
Task<List<PowerStationDevice>> GetPowerStationDevice(Dictionary<string, List<int>> dic, string filter);
|
Task<List<PowerStationDevice>> GetPowerStationDevice(Dictionary<string, List<int>> dic, string filter);
|
||||||
Task<List<InverterHistory>> GetInverterHistoryRowData(string nowDay, List<StationCodeWithInverterIds> entities);
|
Task<List<InverterHistory>> GetInverterHistoryRowData(long start_timestamp, long end_timestamp, List<StationCodeWithInverterIds> entities);
|
||||||
Task<List<InverterHistory>> GetInverterHistoryByDate(string startDay, string endDay, List<StationIdWithInverterIds> entities);
|
Task<List<InverterHistory>> GetInverterHistoryByDate(string startDay, string endDay, List<StationIdWithInverterIds> entities);
|
||||||
Task<List<InverterHistory>> GetInverterHistoryByYear(string year, List<StationIdWithInverterIds> entities);
|
Task<List<InverterHistory>> GetInverterHistoryByYear(string year, List<StationIdWithInverterIds> entities);
|
||||||
Task<List<PowerStationIdAndCity>> GetPowerStationsByCompanyIdWithfilter(MyUser myUser, string filter);
|
Task<List<PowerStationIdAndCity>> GetPowerStationsByCompanyIdWithfilter(MyUser myUser, string filter);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user