This commit is contained in:
JiaHao Liu 2021-12-02 15:25:45 +08:00
commit e6c028a363
6 changed files with 212 additions and 33 deletions

View File

@ -3289,6 +3289,20 @@ namespace SolarPower.Controllers
} }
else else
{ {
//檢查資料表是否有該欄位
var check_inv_col = await powerStationRepository.CheckInvTableColumn(powerStation.SiteDB, powerStation.Code);
var check_sensor_avg_col = await powerStationRepository.CheckSensorAvgTableColumn(powerStation.SiteDB, powerStation.Code);
if (check_inv_col != 1)
{
await powerStationRepository.AlertColInvTableColumn(powerStation.SiteDB, powerStation.Code);
}
if (check_sensor_avg_col != 1)
{
await powerStationRepository.AlertColSensoravgTableColumn(powerStation.SiteDB, powerStation.Code);
}
await powerStationRepository.StationStatus(Id, 1); await powerStationRepository.StationStatus(Id, 1);
await powerStationRepository.StationStatus(Id, 1, powerStation.SiteDB + "."); await powerStationRepository.StationStatus(Id, 1, powerStation.SiteDB + ".");
apiResult.Msg = "電站啟用成功"; apiResult.Msg = "電站啟用成功";

View File

@ -360,10 +360,35 @@ namespace SolarPower.Repository.Implement
{ {
DateTime start; DateTime start;
DateTime end; DateTime end;
var sql = @$"select pr.FormId as FormId, pr.Id as ErrorID, a.id, site_id, `timestamp`, FROM_UNIXTIME((`timestamp` / 1000), '%Y-%m-%d %H:%i:%s') dev_time , a.sourceState err_status, FROM_UNIXTIME( (a.normalTime / 1000), '%Y-%m-%d %H:%i:%s') normalTime, //var sql = @$"select pr.FormId as FormId, pr.Id as ErrorID, a.id, site_id, `timestamp`, FROM_UNIXTIME((`timestamp` / 1000), '%Y-%m-%d %H:%i:%s') dev_time , a.sourceState err_status, FROM_UNIXTIME( (a.normalTime / 1000), '%Y-%m-%d %H:%i:%s') normalTime,
a.alarmClass, b.alarmClass as alarmClassName,ps.Name as PowerStationName, // a.alarmClass, b.alarmClass as alarmClassName,ps.Name as PowerStationName,
errDevice, err_valueKind, errValue, FROM_UNIXTIME( (a.lastUpdate / 1000), '%Y-%m-%d %H:%i:%s') lastUpdate, // errDevice, err_valueKind, errValue, FROM_UNIXTIME( (a.lastUpdate / 1000), '%Y-%m-%d %H:%i:%s') lastUpdate,
case when c.errMsg_tw is null then d.errMsg_tw else c.errMsg_tw end errMsg // case when c.errMsg_tw is null then d.errMsg_tw else c.errMsg_tw end errMsg
// from err_main a
// left join alarmorion_orionalarmclass b on a.alarmclass = b.id
// left join ref_err_device c on trim(b.alarmClass) = c.deviceType
// left join ref_err_inv d on lower(b.alarmClass) = d.deviceType
// # and case when lower(b.alarmClass) = 'inverter' and err_valuekind = 'e' then errvalue else '' end = d.errCode
// and a.errDeviceBrand = d.brend and a.errDeviceModel = d.model and a.errValue = d.errCode
// left join power_station ps on ps.Code = site_id
// left join operation_record pr on pr.ErrorCode = a.id
// WHERE a.sourceState = @Status AND ps.Id = @PowerStationId ";
var sql = @$"select pr.FormId as FormId, pr.Id as ErrorID, a.id, site_id, `timestamp`, FROM_UNIXTIME((`timestamp` / 1000), '%Y-%m-%d %H:%i:%s') dev_time ,
a.sourceState err_status, FROM_UNIXTIME( (a.normalTime / 1000), '%Y-%m-%d %H:%i:%s') normalTime,
a.alarmClass, b.alarmClass as alarmClassName,ps.Name as PowerStationName, errDevice, err_valueKind, errValue, FROM_UNIXTIME( (a.lastUpdate / 1000), '%Y-%m-%d %H:%i:%s') lastUpdate, c.errMsg_tw cerrMsg_tw, d.errMsg_tw derrMsg_tw,
case when c.errMsg_tw is null then
case when err_valueKind = 'b' then d.errMsg_tw
when err_valueKind = 'd' then CONCAT(d.errMsg_tw, ': ', round(a.errValue, 2))
when d.errMsg_tw is null then a.errValue
when a.errValue is null then d.errMsg_tw
else CONCAT(a.errValue, ', ' , ifNull(d.errMsg_tw, '')) end
else
case when err_valueKind = 'b' then c.errMsg_tw
when err_valueKind = 'd' then CONCAT(c.errMsg_tw, ': ', round(a.errValue, 2))
when c.errMsg_tw is null then a.errValue
when a.errValue is null then c.errMsg_tw
else CONCAT(a.errValue, ', ' , ifNull(c.errMsg_tw, '')) end
end errMsg
from err_main a from err_main a
left join alarmorion_orionalarmclass b on a.alarmclass = b.id left join alarmorion_orionalarmclass b on a.alarmclass = b.id
left join ref_err_device c on trim(b.alarmClass) = c.deviceType left join ref_err_device c on trim(b.alarmClass) = c.deviceType
@ -374,7 +399,6 @@ namespace SolarPower.Repository.Implement
left join operation_record pr on pr.ErrorCode = a.id left join operation_record pr on pr.ErrorCode = a.id
WHERE a.sourceState = @Status AND ps.Id = @PowerStationId "; WHERE a.sourceState = @Status AND ps.Id = @PowerStationId ";
if (!string.IsNullOrEmpty(post.Range)) if (!string.IsNullOrEmpty(post.Range))
{ {
post.StartTime = post.Range.Split('-')[0] + " 00:00:00"; post.StartTime = post.Range.Split('-')[0] + " 00:00:00";
@ -415,10 +439,22 @@ namespace SolarPower.Repository.Implement
{ {
DateTime start; DateTime start;
DateTime end; DateTime end;
var sql = @$"select pr.FormId as FormId, pr.Id as ErrorID, a.id, site_id, `timestamp`, FROM_UNIXTIME((`timestamp` / 1000), '%Y-%m-%d %H:%i:%s') dev_time , a.sourceState err_status, FROM_UNIXTIME( (a.normalTime / 1000), '%Y-%m-%d %H:%i:%s') normalTime, var sql = @$"select pr.FormId as FormId, pr.Id as ErrorID, a.id, site_id, `timestamp`, FROM_UNIXTIME((`timestamp` / 1000), '%Y-%m-%d %H:%i:%s') dev_time ,
a.alarmClass, b.alarmClass as alarmClassName,ps.Name as PowerStationName,ps.Id as PowerStationId, a.sourceState err_status, FROM_UNIXTIME( (a.normalTime / 1000), '%Y-%m-%d %H:%i:%s') normalTime,
errDevice, err_valueKind, errValue, FROM_UNIXTIME( (a.lastUpdate / 1000), '%Y-%m-%d %H:%i:%s') lastUpdate, a.alarmClass, b.alarmClass as alarmClassName,ps.Name as PowerStationName, errDevice, err_valueKind, errValue, FROM_UNIXTIME( (a.lastUpdate / 1000), '%Y-%m-%d %H:%i:%s') lastUpdate, c.errMsg_tw cerrMsg_tw, d.errMsg_tw derrMsg_tw,
case when c.errMsg_tw is null then d.errMsg_tw else c.errMsg_tw end errMsg case when c.errMsg_tw is null then
case when err_valueKind = 'b' then d.errMsg_tw
when err_valueKind = 'd' then CONCAT(d.errMsg_tw, ': ', round(a.errValue, 2))
when d.errMsg_tw is null then a.errValue
when a.errValue is null then d.errMsg_tw
else CONCAT(a.errValue, ', ' , ifNull(d.errMsg_tw, '')) end
else
case when err_valueKind = 'b' then c.errMsg_tw
when err_valueKind = 'd' then CONCAT(c.errMsg_tw, ': ', round(a.errValue, 2))
when c.errMsg_tw is null then a.errValue
when a.errValue is null then c.errMsg_tw
else CONCAT(a.errValue, ', ' , ifNull(c.errMsg_tw, '')) end
end errMsg
from err_main a from err_main a
join alarmorion_orionalarmclass b on a.alarmclass = b.id join alarmorion_orionalarmclass b on a.alarmclass = b.id
left join ref_err_device c on trim(b.alarmClass) = c.deviceType left join ref_err_device c on trim(b.alarmClass) = c.deviceType

View File

@ -2890,19 +2890,20 @@ namespace SolarPower.Repository.Implement
var sql = $@"SELECT var sql = $@"SELECT
s.TIMESTAMP, s.TIMESTAMP,
s.INVERTERID, s.INVERTERID,
a.KWH, s.KWH,
s.TODAYKWH, s.TODAYKWH,
i.Capacity, i.Capacity,
a.KWH/(i.Capacity/4) AS KWHKWP s.KWH/(i.Capacity/4) AS KWHKWP
FROM (SELECT FROM (SELECT
MAX(FROM_UNIXTIME(sub_inv.TIMESTAMP/1000, '%Y-%m-%d %H:%i')) AS TIMESTAMP, MAX(FROM_UNIXTIME(sub_inv.TIMESTAMP/1000, '%Y-%m-%d %H:%i')) AS TIMESTAMP,
sub_inv.INVERTERID, sub_inv.INVERTERID,
SUM(sub_inv.WH)/1000 AS KWH,
MAX(sub_inv.TODAYKWH) AS TODAYKWH MAX(sub_inv.TODAYKWH) AS TODAYKWH
FROM {table_name} sub_inv FROM {table_name} sub_inv
WHERE FROM_UNIXTIME(sub_inv.TIMESTAMP/1000, '%Y-%m-%d %H:%i') BETWEEN @StartDateTime AND @EndDateTime WHERE FROM_UNIXTIME(sub_inv.TIMESTAMP/1000, '%Y-%m-%d %H:%i') BETWEEN @StartDateTime AND @EndDateTime
AND sub_inv.INVERTERID IN @InverterIds AND sub_inv.INVERTERID IN @InverterIds
GROUP BY sub_inv.INVERTERID) s GROUP BY sub_inv.INVERTERID) s
LEFT JOIN ( /*LEFT JOIN (
SELECT MAX(FROM_UNIXTIME(sub_inv.TIMESTAMP/1000, '%Y-%m-%d %H:%i')) AS TIMESTAMP, SELECT MAX(FROM_UNIXTIME(sub_inv.TIMESTAMP/1000, '%Y-%m-%d %H:%i')) AS TIMESTAMP,
sub_inv.INVERTERID, sub_inv.INVERTERID,
SUM(sub_inv.WH)/1000 AS KWH SUM(sub_inv.WH)/1000 AS KWH
@ -2910,10 +2911,10 @@ namespace SolarPower.Repository.Implement
WHERE FROM_UNIXTIME(sub_inv.TIMESTAMP/1000, '%Y-%m-%d %H:%i') BETWEEN @StartDateTime AND @EndDateTime WHERE FROM_UNIXTIME(sub_inv.TIMESTAMP/1000, '%Y-%m-%d %H:%i') BETWEEN @StartDateTime AND @EndDateTime
AND sub_inv.INVERTERID IN @InverterIds AND sub_inv.INVERTERID IN @InverterIds
GROUP BY sub_inv.INVERTERID) a GROUP BY sub_inv.INVERTERID) a
ON s.TIMESTAMP = a.TIMESTAMP AND s.INVERTERID = a. INVERTERID ON s.TIMESTAMP = a.TIMESTAMP AND s.INVERTERID = a. INVERTERID*/
LEFT JOIN {db_name}.inverter i ON s.INVERTERID = REPLACE(i.InverterId, 's', '');"; LEFT JOIN {db_name}.inverter i ON s.INVERTERID = REPLACE(i.InverterId, 's', '');";
result = (await conn.QueryAsync<InverterHistory>(sql, new { StartDateTime = stratDateTime, EndDateTime = dateTime, InverterIds = inverterIds })).ToList(); result = (await conn.QueryAsync<InverterHistory>(sql, new { StartDateTime = stratDateTime, EndDateTime = dateTime, InverterIds = inverterIds }, commandTimeout: 300)).ToList();
} }
catch (Exception exception) catch (Exception exception)
{ {
@ -3008,14 +3009,14 @@ namespace SolarPower.Repository.Implement
AVG(s.RA3) AS RA3, AVG(s.RA3) AS RA3,
AVG(s.RA4) AS RA4, AVG(s.RA4) AS RA4,
AVG(s.RA5) AS RA5, AVG(s.RA5) AS RA5,
a.KWH, SUM(s.WH)/1000 AS KWH,
MAX(s.TODAYKWH) AS TODAYKWH, MAX(s.TODAYKWH) AS TODAYKWH,
MAX(s.TOTALKWH) AS TOTALKWH, MAX(s.TOTALKWH) AS TOTALKWH,
i.Capacity, i.Capacity,
(a.KWH/i.Capacity) AS KWHKWP ((SUM(s.WH)/1000) / i.Capacity) AS KWHKWP
FROM {table_name} s FROM {table_name} s
-- KWH -- KWH
LEFT JOIN ( /*LEFT JOIN (
SELECT SELECT
FROM_UNIXTIME(inv.TIMESTAMP/1000, '%Y-%m-%d %H') AS TIMESTAMP, FROM_UNIXTIME(inv.TIMESTAMP/1000, '%Y-%m-%d %H') AS TIMESTAMP,
inv.INVERTERID, inv.INVERTERID,
@ -3024,26 +3025,26 @@ namespace SolarPower.Repository.Implement
WHERE DATE_FORMAT(FROM_UNIXTIME(inv.TIMESTAMP/1000), '%Y-%m-%d %H') = @DateTime WHERE DATE_FORMAT(FROM_UNIXTIME(inv.TIMESTAMP/1000), '%Y-%m-%d %H') = @DateTime
AND inv.INVERTERID IN @InverterIds AND inv.INVERTERID IN @InverterIds
GROUP BY FROM_UNIXTIME(inv.TIMESTAMP/1000, '%Y-%m-%d %H'), inv.INVERTERID) a GROUP BY FROM_UNIXTIME(inv.TIMESTAMP/1000, '%Y-%m-%d %H'), inv.INVERTERID) a
ON FROM_UNIXTIME(s.TIMESTAMP/1000, '%Y-%m-%d %H') = a.TIMESTAMP AND s.INVERTERID = a. INVERTERID ON FROM_UNIXTIME(s.TIMESTAMP/1000, '%Y-%m-%d %H') = a.TIMESTAMP AND s.INVERTERID = a. INVERTERID*/
-- PR -- PR
LEFT JOIN ( LEFT JOIN (
SELECT SELECT
FROM_UNIXTIME(inv.TIMESTAMP/1000, '%Y-%m-%d %H') AS TIMESTAMP, inv.CrdTime AS TIMESTAMP,
inv.INVERTERID, inv.INVERTERID,
inv.PR inv.PR
FROM {table_name} inv FROM {table_name} inv
WHERE DATE_FORMAT(FROM_UNIXTIME(inv.TIMESTAMP/1000), '%Y-%m-%d %H:%i') = CONCAT(@DateTime, ':55') WHERE left(inv.CrdTime, 16) = CONCAT(@DateTime, ':55')
AND inv.INVERTERID IN @InverterIds AND inv.INVERTERID IN @InverterIds
GROUP BY FROM_UNIXTIME(inv.TIMESTAMP/1000, '%Y-%m-%d %H'), inv.INVERTERID) inv_pr GROUP BY left(inv.CrdTime, 13), inv.INVERTERID) inv_pr
ON FROM_UNIXTIME(s.TIMESTAMP/1000, '%Y-%m-%d %H') = inv_pr.TIMESTAMP AND s.INVERTERID = inv_pr. INVERTERID ON left(s.CrdTime, 13) = inv_pr.TIMESTAMP AND s.INVERTERID = inv_pr. INVERTERID
-- --
LEFT JOIN {db_name}.inverter i ON s.INVERTERID = i.InverterId LEFT JOIN {db_name}.inverter i ON s.INVERTERID = i.InverterId
WHERE FROM_UNIXTIME(s.TIMESTAMP/1000, '%Y-%m-%d %H') = @DateTime WHERE left(s.CrdTime, 13) = @DateTime
AND s.INVERTERID IN @InverterIds AND s.INVERTERID IN @InverterIds
GROUP BY DATE_FORMAT(FROM_UNIXTIME(s.TIMESTAMP/1000), '%Y-%m-%d %H'), s.INVERTERID GROUP BY left(s.CrdTime, 13), s.INVERTERID
"; ";
result = (await conn.QueryAsync<InverterHistory>(sql, new { DateTime = dateTime, InverterIds = inverterIds })).ToList(); result = (await conn.QueryAsync<InverterHistory>(sql, new { DateTime = dateTime, InverterIds = inverterIds }, commandTimeout: 300)).ToList();
} }
catch (Exception exception) catch (Exception exception)
{ {
@ -4467,7 +4468,7 @@ namespace SolarPower.Repository.Implement
inv.RA5 inv.RA5
FROM {table_name} inv FROM {table_name} inv
LEFT JOIN (select * from {sensor_table_name} where TIMESTAMP between @start_timestamp and @end_timestamp)sen 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') ON inv.CrdTime = sen.CrdTime
-- 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 {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 inv.`TIMESTAMP` between @start_timestamp and @end_timestamp WHERE inv.`TIMESTAMP` between @start_timestamp and @end_timestamp
@ -5837,5 +5838,129 @@ namespace SolarPower.Repository.Implement
return resule; return resule;
} }
} }
public async Task<int> CheckInvTableColumn (string dbname, string code)
{
using (IDbConnection conn = this._databaseHelper.GetConnection())
{
conn.Open();
var resule = 0;
try
{
var sql = $@"SELECT count(*) FROM information_schema.columns WHERE table_schema='{dbname}' AND table_name = 's{code}01_inv' AND column_name = 'CrdTime'";
resule = await conn.QueryFirstOrDefaultAsync<int>(sql);
}
catch (Exception exception)
{
throw exception;
}
finally
{
conn.Close();
}
return resule;
}
}
public async Task<int> CheckSensorAvgTableColumn(string dbname, string code)
{
using (IDbConnection conn = this._databaseHelper.GetConnection())
{
conn.Open();
var resule = 0;
try
{
var sql = $@"SELECT count(*) FROM information_schema.columns WHERE table_schema='{dbname}' AND table_name = 's{code}01_sensoravg' AND column_name = 'CrdTime'";
resule = await conn.QueryFirstOrDefaultAsync<int>(sql);
}
catch (Exception exception)
{
throw exception;
}
finally
{
conn.Close();
}
return resule;
}
}
public async Task AlertColInvTableColumn(string dbname, string code)
{
using (IDbConnection conn = this._databaseHelper.GetConnection())
{
conn.Open();
try
{
var sql = $@"ALTER TABLE {dbname}.s{code}01_inv ADD COLUMN CrdTime datetime;
use {dbname};
create trigger trg01_s{code}01_inv
before insert on {dbname}.s{code}01_inv
FOR EACH ROW
begin
set new.CrdTime = FROM_UNIXTIME(new.`TIMESTAMP`/1000,'%Y-%m-%d %H:%i');
end;
use solar_master;
update {dbname}.s{code}01_inv set crdtime = FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i');
CREATE INDEX IDX02_s{code}01 ON {dbname}.s{code}01_inv(Inverterid, CrdTime);";
await conn.ExecuteAsync(sql);
}
catch (Exception exception)
{
throw exception;
}
finally
{
conn.Close();
}
}
}
public async Task AlertColSensoravgTableColumn(string dbname, string code)
{
using (IDbConnection conn = this._databaseHelper.GetConnection())
{
conn.Open();
try
{
var sql = $@"ALTER TABLE {dbname}.s{code}01_sensoravg ADD COLUMN CrdTime datetime;
use {dbname};
create trigger trg01_s{code}01_sensoravg
before insert on {dbname}.s{code}01_sensoravg
FOR EACH ROW
begin
set new.CrdTime = FROM_UNIXTIME(new.`TIMESTAMP`/1000,'%Y-%m-%d %H:%i');
end;
use solar_master;
update {dbname}.s{code}01_sensoravg set crdtime = FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i');
CREATE INDEX IDX{code}01_sensoravg ON {dbname}.s{code}01_sensoravg(CrdTime);";
await conn.ExecuteAsync(sql);
}
catch (Exception exception)
{
throw exception;
}
finally
{
conn.Close();
}
}
}
} }
} }

View File

@ -106,7 +106,7 @@ namespace SolarPower.Repository.Implement
GROUP_CONCAT(DISTINCT GROUP_CONCAT(DISTINCT
CONCAT('max(case when INVERTERID = ''', INVERTERID, ''' then round(a.KWH, 2) end) ''inv_', right(INVERTERID, 2), '''') CONCAT('max(case when INVERTERID = ''', INVERTERID, ''' then round(a.KWH, 2) end) ''inv_', right(INVERTERID, 2), '''')
) INTO @sql ) INTO @sql
FROM inverter_history_hour where powerstationId = {post.PowerStation} and DATE_FORMAT(`TIMESTAMP`,'%Y-%m') = '{post.Time}'; FROM inverter_history_day where powerstationId = {post.PowerStation} and DATE_FORMAT(`TIMESTAMP`,'%Y-%m') = '{post.Time}';
SET @sql = CONCAT('SELECT DATE_FORMAT(a.TIMESTAMP,''%m/%d'') report_date, ', @sql, SET @sql = CONCAT('SELECT DATE_FORMAT(a.TIMESTAMP,''%m/%d'') report_date, ', @sql,
',b.TODAYKWH ''dayKWH'', round((b.TODAYKWH / c.monthKWH)*100,2) ''dayKWHp'', b.SOLARHOUR ''tothour'', b.KWHKWP ''KWHKWP'', b.PR, ',b.TODAYKWH ''dayKWH'', round((b.TODAYKWH / c.monthKWH)*100,2) ''dayKWHp'', b.SOLARHOUR ''tothour'', b.KWHKWP ''KWHKWP'', b.PR,
d.irradiance ''irradiance'', d.Temperature ''temperature'', b.money ''soldmoney'', d.irradiance ''irradiance'', d.Temperature ''temperature'', b.money ''soldmoney'',
@ -153,7 +153,7 @@ namespace SolarPower.Repository.Implement
GROUP_CONCAT(DISTINCT GROUP_CONCAT(DISTINCT
CONCAT('max(case when INVERTERID = ''', INVERTERID, ''' then round(a.KWH, 2) end) ''inv_', right(INVERTERID, 2), '''') CONCAT('max(case when INVERTERID = ''', INVERTERID, ''' then round(a.KWH, 2) end) ''inv_', right(INVERTERID, 2), '''')
) INTO @sql ) INTO @sql
FROM inverter_history_hour where powerstationId = {post.PowerStation} and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') BETWEEN '{times[0]}' AND '{times[1]}'; FROM inverter_history_day where powerstationId = {post.PowerStation} and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') BETWEEN '{times[0]}' AND '{times[1]}';
SET @sql = CONCAT('SELECT DATE_FORMAT(a.TIMESTAMP,''%m/%d'') report_date, ', @sql, SET @sql = CONCAT('SELECT DATE_FORMAT(a.TIMESTAMP,''%m/%d'') report_date, ', @sql,
',b.TODAYKWH ''dayKWH'', round((b.TODAYKWH / c.monthKWH)*100,2) ''dayKWHp'', b.SOLARHOUR ''tothour'', b.KWHKWP ''KWHKWP'', b.PR, ',b.TODAYKWH ''dayKWH'', round((b.TODAYKWH / c.monthKWH)*100,2) ''dayKWHp'', b.SOLARHOUR ''tothour'', b.KWHKWP ''KWHKWP'', b.PR,
d.irradiance ''irradiance'', d.Temperature ''temperature'', b.money ''soldmoney'', d.irradiance ''irradiance'', d.Temperature ''temperature'', b.money ''soldmoney'',
@ -202,7 +202,7 @@ namespace SolarPower.Repository.Implement
GROUP_CONCAT(DISTINCT GROUP_CONCAT(DISTINCT
CONCAT('max(case when INVERTERID = ''', INVERTERID, ''' then round(a.KWH, 2) end) ''inv_', right(INVERTERID, 2), '''') CONCAT('max(case when INVERTERID = ''', INVERTERID, ''' then round(a.KWH, 2) end) ''inv_', right(INVERTERID, 2), '''')
) INTO @sql ) INTO @sql
FROM inverter_history_hour where powerstationId = {post.PowerStation} and DATE_FORMAT(`TIMESTAMP`,'%Y') = '{post.Time}'; FROM inverter_history_month where powerstationId = {post.PowerStation} and DATE_FORMAT(`TIMESTAMP`,'%Y') = '{post.Time}';
SET @sql = CONCAT('SELECT DATE_FORMAT(a.TIMESTAMP,''%Y/%m'') report_date, ', @sql, SET @sql = CONCAT('SELECT DATE_FORMAT(a.TIMESTAMP,''%Y/%m'') report_date, ', @sql,
',b.todayKWH ''dayKWH'', round((b.todayKWH / c.monthKWH)*100,2) ''dayKWHp'', b.SOLARHOUR ''tothour'', b.KWHKWP ''KWHKWP'', c.PR, ',b.todayKWH ''dayKWH'', round((b.todayKWH / c.monthKWH)*100,2) ''dayKWHp'', b.SOLARHOUR ''tothour'', b.KWHKWP ''KWHKWP'', c.PR,
d.irradiance ''irradiance'', d.Temperature ''temperature'', b.money ''soldmoney'', d.irradiance ''irradiance'', d.Temperature ''temperature'', b.money ''soldmoney'',
@ -482,7 +482,7 @@ namespace SolarPower.Repository.Implement
GROUP_CONCAT(DISTINCT GROUP_CONCAT(DISTINCT
CONCAT('max(case when INVERTERID = ''', INVERTERID, ''' then round(a.KWH, 2) end) ''inv_', right(INVERTERID, 2), '''') CONCAT('max(case when INVERTERID = ''', INVERTERID, ''' then round(a.KWH, 2) end) ''inv_', right(INVERTERID, 2), '''')
) INTO @sql ) INTO @sql
FROM inverter_history_hour where powerstationId = {post.PowerStation} and DATE_FORMAT(`TIMESTAMP`,'%Y-%m') = '{post.Time}'; FROM inverter_history_day where powerstationId = {post.PowerStation} and DATE_FORMAT(`TIMESTAMP`,'%Y-%m') = '{post.Time}';
SET @sql = CONCAT('SELECT DATE_FORMAT(a.TIMESTAMP,''%m/%d'') report_date, ', @sql, SET @sql = CONCAT('SELECT DATE_FORMAT(a.TIMESTAMP,''%m/%d'') report_date, ', @sql,
',b.TODAYKWH ''dayKWH'', round((b.TODAYKWH / c.monthKWH)*100,2) ''dayKWHp'', b.SOLARHOUR ''tothour'', b.KWHKWP ''KWHKWP'', b.PR, ',b.TODAYKWH ''dayKWH'', round((b.TODAYKWH / c.monthKWH)*100,2) ''dayKWHp'', b.SOLARHOUR ''tothour'', b.KWHKWP ''KWHKWP'', b.PR,
d.irradiance ''irradiance'', d.Temperature ''temperature'', b.money ''soldmoney'', d.irradiance ''irradiance'', d.Temperature ''temperature'', b.money ''soldmoney'',
@ -529,7 +529,7 @@ namespace SolarPower.Repository.Implement
GROUP_CONCAT(DISTINCT GROUP_CONCAT(DISTINCT
CONCAT('max(case when INVERTERID = ''', INVERTERID, ''' then round(a.KWH, 2) end) ''inv_', right(INVERTERID, 2), '''') CONCAT('max(case when INVERTERID = ''', INVERTERID, ''' then round(a.KWH, 2) end) ''inv_', right(INVERTERID, 2), '''')
) INTO @sql ) INTO @sql
FROM inverter_history_hour where powerstationId = {post.PowerStation} and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') BETWEEN '{times[0]}' AND '{times[1]}'; FROM inverter_history_day where powerstationId = {post.PowerStation} and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') BETWEEN '{times[0]}' AND '{times[1]}';
SET @sql = CONCAT('SELECT DATE_FORMAT(a.TIMESTAMP,''%m/%d'') report_date, ', @sql, SET @sql = CONCAT('SELECT DATE_FORMAT(a.TIMESTAMP,''%m/%d'') report_date, ', @sql,
',b.TODAYKWH ''dayKWH'', round((b.TODAYKWH / c.monthKWH)*100,2) ''dayKWHp'', b.SOLARHOUR ''tothour'', b.KWHKWP ''KWHKWP'', b.PR, ',b.TODAYKWH ''dayKWH'', round((b.TODAYKWH / c.monthKWH)*100,2) ''dayKWHp'', b.SOLARHOUR ''tothour'', b.KWHKWP ''KWHKWP'', b.PR,
d.irradiance ''irradiance'', d.Temperature ''temperature'', b.money ''soldmoney'', d.irradiance ''irradiance'', d.Temperature ''temperature'', b.money ''soldmoney'',
@ -577,7 +577,7 @@ namespace SolarPower.Repository.Implement
GROUP_CONCAT(DISTINCT GROUP_CONCAT(DISTINCT
CONCAT('max(case when INVERTERID = ''', INVERTERID, ''' then round(a.KWH, 2) end) ''inv_', right(INVERTERID, 2), '''') CONCAT('max(case when INVERTERID = ''', INVERTERID, ''' then round(a.KWH, 2) end) ''inv_', right(INVERTERID, 2), '''')
) INTO @sql ) INTO @sql
FROM inverter_history_hour where powerstationId = {post.PowerStation} and DATE_FORMAT(`TIMESTAMP`,'%Y') = '{post.Time}'; FROM inverter_history_month where powerstationId = {post.PowerStation} and DATE_FORMAT(`TIMESTAMP`,'%Y') = '{post.Time}';
SET @sql = CONCAT('SELECT DATE_FORMAT(a.TIMESTAMP,''%Y/%m'') report_date, ', @sql, SET @sql = CONCAT('SELECT DATE_FORMAT(a.TIMESTAMP,''%Y/%m'') report_date, ', @sql,
',b.todayKWH ''dayKWH'', round((b.todayKWH / c.monthKWH)*100,2) ''dayKWHp'', b.SOLARHOUR ''tothour'', b.KWHKWP ''KWHKWP'', c.PR, ',b.todayKWH ''dayKWH'', round((b.todayKWH / c.monthKWH)*100,2) ''dayKWHp'', b.SOLARHOUR ''tothour'', b.KWHKWP ''KWHKWP'', c.PR,
d.irradiance ''irradiance'', d.Temperature ''temperature'', b.money ''soldmoney'', d.irradiance ''irradiance'', d.Temperature ''temperature'', b.money ''soldmoney'',

View File

@ -608,5 +608,9 @@ namespace SolarPower.Repository.Interface
Task UpdateInvStatus(string siteDB, List<string> codes, List<string> inverterIds = null, byte status = 0); Task UpdateInvStatus(string siteDB, List<string> codes, List<string> inverterIds = null, byte status = 0);
Task<List<InvStatusErr>> GetInvStatusErr(List<string> codes); Task<List<InvStatusErr>> GetInvStatusErr(List<string> codes);
Task<Check4table> Check4table(string code, string dbname); Task<Check4table> Check4table(string code, string dbname);
Task<int> CheckInvTableColumn(string dbname, string code);
Task<int> CheckSensorAvgTableColumn(string dbname, string code);
Task AlertColInvTableColumn(string dbname, string code);
Task AlertColSensoravgTableColumn(string dbname, string code);
} }
} }

View File

@ -2812,7 +2812,7 @@
return; return;
} }
$("#Invertercard-Name").html(rel.data.name); $("#Invertercard-Name").html(rel.data.name);
$("#Invertercard-kwh").html(rel.data.kwh.toFixed(2)); $("#Invertercard-kwh").html(rel.data.today_kWh.toFixed(2));
@if (ViewBag.myUser.Role.Auths.Contains("ShowMoney")) @if (ViewBag.myUser.Role.Auths.Contains("ShowMoney"))
{ {
<text> <text>