debug : 合併電站 - 累計日照欄位
This commit is contained in:
parent
518ec7ec81
commit
437e3e3150
@ -46,7 +46,7 @@ namespace SolarPower.Repository.Implement
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
today = $@" SELECT
|
today = $@" SELECT
|
||||||
AVG(a.Irradiance) AS Now_irradiance
|
AVG(a.irrDayHour) AS Now_irradiance
|
||||||
FROM
|
FROM
|
||||||
sensor_history_day a
|
sensor_history_day a
|
||||||
WHERE a.PowerStationId IN @ids AND DATE_FORMAT(a.TIMESTAMP,'%Y-%m-%d') = '{timerange}'";
|
WHERE a.PowerStationId IN @ids AND DATE_FORMAT(a.TIMESTAMP,'%Y-%m-%d') = '{timerange}'";
|
||||||
@ -101,13 +101,13 @@ namespace SolarPower.Repository.Implement
|
|||||||
FROM
|
FROM
|
||||||
(SELECT AVG(a.today_irradiance) AS Now_irradiance FROM power_station a WHERE a.Id IN (1)
|
(SELECT AVG(a.today_irradiance) AS Now_irradiance FROM power_station a WHERE a.Id IN (1)
|
||||||
UNION
|
UNION
|
||||||
SELECT AVG(b.Irradiance) AS Now_irradiance FROM sensor_history_day b
|
SELECT AVG(b.irrDay) AS Now_irradiance FROM sensor_history_day b
|
||||||
WHERE b.PowerStationId IN (1) AND DATE_FORMAT(b.TIMESTAMP, '%Y/%m/%d') BETWEEN '{time[0].Replace(" ", "")}' AND '{Convert.ToDateTime(time[1].Replace(" ", "")).AddDays(-1).ToString("yyyy/MM/dd")}') c";
|
WHERE b.PowerStationId IN (1) AND DATE_FORMAT(b.TIMESTAMP, '%Y/%m/%d') BETWEEN '{time[0].Replace(" ", "")}' AND '{Convert.ToDateTime(time[1].Replace(" ", "")).AddDays(-1).ToString("yyyy/MM/dd")}') c";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ttot = @$" SELECT
|
ttot = @$" SELECT
|
||||||
AVG(a.Irradiance) AS Now_irradiance
|
AVG(a.irrDay) AS Now_irradiance
|
||||||
FROM
|
FROM
|
||||||
sensor_history_day a
|
sensor_history_day a
|
||||||
WHERE a.PowerStationId IN @ids AND DATE_FORMAT(a.TIMESTAMP, '%Y/%m/%d') BETWEEN '{time[0].Replace(" ", "")}' AND '{time[1].Replace(" ", "")}'";
|
WHERE a.PowerStationId IN @ids AND DATE_FORMAT(a.TIMESTAMP, '%Y/%m/%d') BETWEEN '{time[0].Replace(" ", "")}' AND '{time[1].Replace(" ", "")}'";
|
||||||
@ -181,7 +181,7 @@ namespace SolarPower.Repository.Implement
|
|||||||
AS o,
|
AS o,
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
AVG(a.Irradiance) AS Now_irradiance
|
AVG(a.IrrDay) AS Now_irradiance
|
||||||
from sensor_history_month a
|
from sensor_history_month a
|
||||||
WHERE PowerStationId IN @ids AND DATE_FORMAT(TIMESTAMP, '%Y-%m') = '{post.Timerange}'
|
WHERE PowerStationId IN @ids AND DATE_FORMAT(TIMESTAMP, '%Y-%m') = '{post.Timerange}'
|
||||||
) AS p";
|
) AS p";
|
||||||
@ -220,7 +220,7 @@ namespace SolarPower.Repository.Implement
|
|||||||
AS o,
|
AS o,
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
AVG(a.Irradiance) AS Now_irradiance
|
AVG(a.IrrDay) AS Now_irradiance
|
||||||
from sensor_history_month a
|
from sensor_history_month a
|
||||||
WHERE PowerStationId IN @ids AND DATE_FORMAT(TIMESTAMP, '%Y') = '{post.Timerange}'
|
WHERE PowerStationId IN @ids AND DATE_FORMAT(TIMESTAMP, '%Y') = '{post.Timerange}'
|
||||||
) AS p";
|
) AS p";
|
||||||
@ -263,7 +263,7 @@ namespace SolarPower.Repository.Implement
|
|||||||
FROM (SELECT * FROM power_station_history_hour ps WHERE ps.PowerStationId IN @ids AND DATE_FORMAT(ps.TIMESTAMP,'%Y-%m-%d') = '{post.Timerange}') p
|
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 (SELECT * FROM sensor_history_hour sh WHERE sh.PowerStationId IN @ids AND DATE_FORMAT(sh.TIMESTAMP,'%Y-%m-%d') = '{post.Timerange}') s
|
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 p.TIMESTAMP = s.TIMESTAMP AND p.PowerStationId = s.PowerStationId
|
ON p.TIMESTAMP = s.TIMESTAMP AND p.PowerStationId = s.PowerStationId
|
||||||
GROUP BY p.TIMESTAMP";
|
GROUP BY p.TIMESTAMP order by p.TIMESTAMP";
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
var time = post.Timerange.Replace(" ","").Split('-');
|
var time = post.Timerange.Replace(" ","").Split('-');
|
||||||
@ -275,7 +275,7 @@ namespace SolarPower.Repository.Implement
|
|||||||
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
|
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 (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
|
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 s.TIMESTAMP = p.TIMESTAMP AND p.PowerStationId = s.PowerStationId
|
ON s.TIMESTAMP = p.TIMESTAMP AND p.PowerStationId = s.PowerStationId
|
||||||
GROUP BY p.TIMESTAMP";
|
GROUP BY DATE_FORMAT(p.TIMESTAMP,'%Y-%m-%d') order by p.TIMESTAMP ";
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
sql = $@"SELECT
|
sql = $@"SELECT
|
||||||
@ -286,7 +286,7 @@ namespace SolarPower.Repository.Implement
|
|||||||
FROM (SELECT * FROM power_station_history_day ps WHERE ps.PowerStationId IN @ids AND DATE_FORMAT(ps.TIMESTAMP,'%Y-%m') = '{post.Timerange}') p
|
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 (SELECT * FROM sensor_history_day sh WHERE sh.PowerStationId IN @ids AND DATE_FORMAT(sh.TIMESTAMP,'%Y-%m') = '{post.Timerange}') s
|
LEFT JOIN (SELECT * FROM sensor_history_day sh WHERE sh.PowerStationId IN @ids AND DATE_FORMAT(sh.TIMESTAMP,'%Y-%m') = '{post.Timerange}') s
|
||||||
ON s.TIMESTAMP = p.TIMESTAMP AND p.PowerStationId = s.PowerStationId
|
ON s.TIMESTAMP = p.TIMESTAMP AND p.PowerStationId = s.PowerStationId
|
||||||
GROUP BY p.TIMESTAMP";
|
GROUP BY p.TIMESTAMP order by p.TIMESTAMP";
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
sql = $@"SELECT
|
sql = $@"SELECT
|
||||||
@ -297,7 +297,7 @@ namespace SolarPower.Repository.Implement
|
|||||||
FROM (SELECT * FROM power_station_history_month ps WHERE ps.PowerStationId IN @ids AND DATE_FORMAT(ps.TIMESTAMP,'%Y') = '{post.Timerange}') p
|
FROM (SELECT * FROM power_station_history_month ps WHERE ps.PowerStationId IN @ids AND DATE_FORMAT(ps.TIMESTAMP,'%Y') = '{post.Timerange}') p
|
||||||
LEFT JOIN (SELECT * FROM sensor_history_month sh WHERE sh.PowerStationId IN @ids AND DATE_FORMAT(sh.TIMESTAMP,'%Y') = '{post.Timerange}') s
|
LEFT JOIN (SELECT * FROM sensor_history_month sh WHERE sh.PowerStationId IN @ids AND DATE_FORMAT(sh.TIMESTAMP,'%Y') = '{post.Timerange}') s
|
||||||
ON s.TIMESTAMP = p.TIMESTAMP AND p.PowerStationId = s.PowerStationId
|
ON s.TIMESTAMP = p.TIMESTAMP AND p.PowerStationId = s.PowerStationId
|
||||||
GROUP BY p.TIMESTAMP";
|
GROUP BY p.TIMESTAMP order by p.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();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user