Merge branch 'master' of https://github.com/shanghohui-Company/SolarPower
This commit is contained in:
commit
e2e1190578
@ -131,6 +131,8 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
#region 發電金額
|
#region 發電金額
|
||||||
|
|
||||||
history.MONEY = history.KWH * powerStation.PowerRate;
|
history.MONEY = history.KWH * powerStation.PowerRate;
|
||||||
|
history.TODAYMONEY = history.TodayKWh * powerStation.PowerRate;
|
||||||
|
history.TOTALMONEY = history.TotalKWH * powerStation.PowerRate;
|
||||||
|
|
||||||
//即時發電金額
|
//即時發電金額
|
||||||
switch (powerStation.SolarType)
|
switch (powerStation.SolarType)
|
||||||
@ -229,6 +231,8 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
carbonRate = Convert.ToDouble(await powerStationRepository.GetOneVariableByName("CarbonRate"));
|
carbonRate = Convert.ToDouble(await powerStationRepository.GetOneVariableByName("CarbonRate"));
|
||||||
|
|
||||||
history.CARBON = history.KWH * carbonRate;
|
history.CARBON = history.KWH * carbonRate;
|
||||||
|
history.TODAYCARBON = history.TodayKWh * carbonRate;
|
||||||
|
history.TOTALCARBON = history.TotalKWH * carbonRate;
|
||||||
//if (lastmoneyhistorybyhour != null)
|
//if (lastmoneyhistorybyhour != null)
|
||||||
//{
|
//{
|
||||||
// history.TODAYCARBON = lastmoneyhistorybyhour.TODAYCARBON + history.KWH * carbonRate;
|
// history.TODAYCARBON = lastmoneyhistorybyhour.TODAYCARBON + history.KWH * carbonRate;
|
||||||
|
|||||||
@ -192,57 +192,51 @@ namespace SolarPower.Repository.Implement
|
|||||||
switch (post.SeacrhType)
|
switch (post.SeacrhType)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
sql = $@"SELECT DATE_FORMAT(ps.TIMESTAMP,'%h %p') AS `Time`,
|
sql = $@"SELECT DATE_FORMAT(p.TIMESTAMP,'%h %p') AS `Time`,
|
||||||
SUM(ps.KWH) AS KWH,
|
SUM(p.KWH) AS KWH,
|
||||||
SUM(sh.Irradiance) AS Irradiance,
|
SUM(s.Irradiance) AS Irradiance,
|
||||||
AVG(sh.Temperature) AS Temperature
|
AVG(s.Temperature) AS Temperature
|
||||||
FROM power_station_history_hour ps
|
FROM (SELECT * FROM power_station_history_hour ps WHERE ps.PowerStationId IN @ids AND DATE_FORMAT(ps.TIMESTAMP,'%Y-%m-%d') = '{post.Timerange}') p
|
||||||
LEFT JOIN sensor_history_hour sh
|
LEFT JOIN (SELECT * FROM sensor_history_hour sh WHERE sh.PowerStationId IN @ids AND DATE_FORMAT(sh.TIMESTAMP,'%Y-%m-%d') = '{post.Timerange}') s
|
||||||
ON sh.TIMESTAMP = ps.TIMESTAMP AND sh.PowerStationId = ps.PowerStationId
|
ON p.TIMESTAMP = s.TIMESTAMP AND p.PowerStationId = s.PowerStationId
|
||||||
WHERE ps.PowerStationId IN @ids AND DATE_FORMAT(sh.TIMESTAMP,'%Y-%m-%d') = '{post.Timerange}'
|
GROUP BY p.TIMESTAMP";
|
||||||
GROUP BY ps.TIMESTAMP";
|
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
var time = post.Timerange.Replace(" ","").Split('-');
|
var time = post.Timerange.Replace(" ","").Split('-');
|
||||||
sql = $@"SELECT
|
sql = $@"SELECT
|
||||||
DATE_FORMAT(ps.TIMESTAMP,'%Y-%m-%d') AS `Time`,
|
DATE_FORMAT(p.TIMESTAMP,'%Y-%m-%d') AS `Time`,
|
||||||
SUM(ps.TODAYKWH) AS KWH,
|
SUM(p.TODAYKWH) AS KWH,
|
||||||
SUM(sh.Irradiance) AS Irradiance,
|
SUM(s.Irradiance) AS Irradiance,
|
||||||
AVG(sh.Temperature) AS Temperature
|
AVG(s.Temperature) AS Temperature
|
||||||
FROM power_station_history_day ps
|
FROM (SELECT * FROM power_station_history_day ps WHERE ps.PowerStationId IN @ids AND DATE_FORMAT(ps.TIMESTAMP,'%Y-%m-%d') BETWEEN '{time[0].Replace('/', '-')}' AND '{time[1].Replace('/', '-')}') p
|
||||||
LEFT JOIN sensor_history_day sh
|
LEFT JOIN (SELECT * FROM sensor_history_day sh WHERE sh.PowerStationId IN @ids AND DATE_FORMAT(sh.TIMESTAMP,'%Y-%m-%d') BETWEEN '{time[0].Replace('/', '-')}' AND '{time[1].Replace('/', '-')}') s
|
||||||
ON sh.TIMESTAMP = ps.TIMESTAMP
|
ON s.TIMESTAMP = p.TIMESTAMP AND p.PowerStationId = s.PowerStationId
|
||||||
WHERE ps.PowerStationId IN @ids AND DATE_FORMAT(sh.TIMESTAMP,'%Y-%m-%d') BETWEEN '{time[0].Replace('/', '-')}' AND '{time[1].Replace('/', '-')}'
|
GROUP BY p.TIMESTAMP";
|
||||||
GROUP BY ps.TIMESTAMP";
|
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
sql = $@"SELECT
|
sql = $@"SELECT
|
||||||
DATE_FORMAT(ps.TIMESTAMP,'%Y-%m-%d') AS `Time`,
|
DATE_FORMAT(p.TIMESTAMP,'%Y-%m-%d') AS `Time`,
|
||||||
SUM(ps.TODAYKWH) AS KWH,
|
SUM(p.TODAYKWH) AS KWH,
|
||||||
SUM(sh.Irradiance) AS Irradiance,
|
SUM(s.Irradiance) AS Irradiance,
|
||||||
AVG(sh.Temperature) AS Temperature
|
AVG(s.Temperature) AS Temperature
|
||||||
FROM power_station_history_day ps
|
FROM (SELECT * FROM power_station_history_day ps WHERE ps.PowerStationId IN @ids AND DATE_FORMAT(ps.TIMESTAMP,'%Y-%m') = '{post.Timerange}') p
|
||||||
LEFT JOIN sensor_history_day sh
|
LEFT JOIN (SELECT * FROM sensor_history_day sh WHERE sh.PowerStationId IN @ids AND DATE_FORMAT(sh.TIMESTAMP,'%Y-%m') = '{post.Timerange}') s
|
||||||
ON sh.TIMESTAMP = ps.TIMESTAMP
|
ON s.TIMESTAMP = p.TIMESTAMP AND p.PowerStationId = s.PowerStationId
|
||||||
WHERE ps.PowerStationId IN @ids AND DATE_FORMAT(sh.TIMESTAMP,'%Y-%m') = '{post.Timerange}'
|
GROUP BY p.TIMESTAMP";
|
||||||
GROUP BY ps.TIMESTAMP";
|
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
sql = $@"SELECT
|
sql = $@"SELECT
|
||||||
DATE_FORMAT(ps.TIMESTAMP,'%Y-%m') AS `Time`,
|
DATE_FORMAT(p.TIMESTAMP,'%Y-%m') AS `Time`,
|
||||||
SUM(ps.MONTHKWH) AS KWH,
|
SUM(p.MONTHKWH) AS KWH,
|
||||||
SUM(sh.Irradiance) AS Irradiance,
|
SUM(s.Irradiance) AS Irradiance,
|
||||||
AVG(sh.Temperature) AS Temperature
|
AVG(s.Temperature) AS Temperature
|
||||||
FROM power_station_history_month ps
|
FROM (SELECT * FROM power_station_history_month ps WHERE ps.PowerStationId IN @ids AND DATE_FORMAT(ps.TIMESTAMP,'%Y') = '{post.Timerange}') p
|
||||||
LEFT JOIN sensor_history_month sh
|
LEFT JOIN (SELECT * FROM sensor_history_month sh WHERE sh.PowerStationId IN @ids AND DATE_FORMAT(sh.TIMESTAMP,'%Y') = '{post.Timerange}') s
|
||||||
ON sh.TIMESTAMP = ps.TIMESTAMP
|
ON s.TIMESTAMP = p.TIMESTAMP AND p.PowerStationId = s.PowerStationId
|
||||||
WHERE ps.PowerStationId IN @ids AND DATE_FORMAT(sh.TIMESTAMP,'%Y') = '{post.Timerange}'
|
GROUP BY p.TIMESTAMP";
|
||||||
GROUP BY ps.TIMESTAMP";
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
a = (await conn.QueryAsync<Chartoutput>(sql,new { ids = post.StationIds})).ToList();
|
a = (await conn.QueryAsync<Chartoutput>(sql,new { ids = post.StationIds})).ToList();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -4473,7 +4473,7 @@ namespace SolarPower.Repository.Implement
|
|||||||
|
|
||||||
sql_perSiteDB.Add(temp_sql);
|
sql_perSiteDB.Add(temp_sql);
|
||||||
}
|
}
|
||||||
sql = string.Join(" UNION ", sql_perSiteDB);
|
sql = "SELECT * FROM (" + string.Join(" UNION ", sql_perSiteDB) + ") a ORDER BY a.TIMESTAMP ASC";
|
||||||
|
|
||||||
result = (await conn.QueryAsync<InverterHistory>(sql, new { NowDay = nowDay })).ToList();
|
result = (await conn.QueryAsync<InverterHistory>(sql, new { NowDay = nowDay })).ToList();
|
||||||
}
|
}
|
||||||
@ -4504,7 +4504,7 @@ namespace SolarPower.Repository.Implement
|
|||||||
|
|
||||||
var temp_sql = $@"SELECT
|
var temp_sql = $@"SELECT
|
||||||
DATE_FORMAT(inv.TIMESTAMP, '%Y-%m-%d') AS TIMESTAMP,
|
DATE_FORMAT(inv.TIMESTAMP, '%Y-%m-%d') AS TIMESTAMP,
|
||||||
INVERTERID,
|
inv.INVERTERID,
|
||||||
i.InverterName AS INVERTERName,
|
i.InverterName AS INVERTERName,
|
||||||
inv.Irradiance,
|
inv.Irradiance,
|
||||||
inv.KWH,
|
inv.KWH,
|
||||||
@ -4523,7 +4523,7 @@ namespace SolarPower.Repository.Implement
|
|||||||
|
|
||||||
sql_perSiteDB.Add(temp_sql);
|
sql_perSiteDB.Add(temp_sql);
|
||||||
}
|
}
|
||||||
sql = string.Join(" UNION ", sql_perSiteDB);
|
sql = "SELECT * FROM (" + string.Join(" UNION ", sql_perSiteDB) + ") a ORDER BY a.TIMESTAMP ASC";
|
||||||
|
|
||||||
result = (await conn.QueryAsync<InverterHistory>(sql, new { StartDay = startDay, EndDay = endDay })).ToList();
|
result = (await conn.QueryAsync<InverterHistory>(sql, new { StartDay = startDay, EndDay = endDay })).ToList();
|
||||||
}
|
}
|
||||||
@ -4554,7 +4554,7 @@ namespace SolarPower.Repository.Implement
|
|||||||
|
|
||||||
var temp_sql = $@"SELECT
|
var temp_sql = $@"SELECT
|
||||||
DATE_FORMAT(inv.TIMESTAMP, '%Y-%m-%d') AS TIMESTAMP,
|
DATE_FORMAT(inv.TIMESTAMP, '%Y-%m-%d') AS TIMESTAMP,
|
||||||
INVERTERID,
|
inv.INVERTERID,
|
||||||
i.InverterName AS INVERTERName,
|
i.InverterName AS INVERTERName,
|
||||||
inv.KWH,
|
inv.KWH,
|
||||||
inv.TODAYKWH,
|
inv.TODAYKWH,
|
||||||
|
|||||||
@ -22,12 +22,12 @@
|
|||||||
<div class="col-xl-2">
|
<div class="col-xl-2">
|
||||||
<h1 class="subheader-title">
|
<h1 class="subheader-title">
|
||||||
<span id="power-station-healthStatus"></span>
|
<span id="power-station-healthStatus"></span>
|
||||||
<span id="power-station-title">新竹巨城站</span>
|
<span id="power-station-title">電站名稱</span>
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xl-3 d-flex justify-content-start">
|
<div class="col-xl-3 d-flex justify-content-start">
|
||||||
<p class="card-text px-3"><i class="fal fa-cloud-sun-rain fa-3x" id="weather-icon"></i></p>
|
<p class="card-text px-3"><i class="fal fa-cloud-sun-rain fa-3x" id="weather-icon"></i></p>
|
||||||
<p class="font-weight-bold" id="weather-temp">27°C<br>降雨幾率: 15%</p>
|
<p class="font-weight-bold" id="weather-temp">27°C<br>降雨幾率: 0%</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<ul class="nav nav-tabs mb-5" role="tablist">
|
<ul class="nav nav-tabs mb-5" role="tablist">
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user