[solarApp]修正/優化歸檔邏輯,跑報表新增區間跑報表
[solarPower]逆便器分析因應資料搬遷修改語法。電站分析優化發電量圖表及歷史資料語法。
This commit is contained in:
parent
b4c7bac548
commit
e647e6196b
@ -214,9 +214,10 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
var sql_power = @$"SELECT DATE_FORMAT(ps.timestamp,'%H %p') AS Label, ps.KWH AS PowerData, pyr.IrrDayHour AS IrrDayHourData, pyr.Temperature AS TemperatureData
|
||||
FROM power_station_history_hour ps
|
||||
LEFT JOIN sensor_history_hour pyr ON ps.PowerStationId = pyr.PowerStationId AND DATE_FORMAT(ps.timestamp, '%Y-%m-%d %H') = DATE_FORMAT(pyr.timestamp, '%Y-%m-%d %H')
|
||||
LEFT JOIN sensor_history_hour pyr ON ps.PowerStationId = pyr.PowerStationId
|
||||
AND ps.TIMESTAMP = pyr.TIMESTAMP
|
||||
WHERE ps.PowerStationId = @PowerStationId
|
||||
AND DATE_FORMAT(ps.timestamp, '%Y-%m-%d') = @NowDay
|
||||
AND ps.timestamp >= @NowDay AND ps.timestamp < @NowDay + INTERVAL 1 DAY
|
||||
ORDER BY ps.timestamp";
|
||||
|
||||
result = (await conn.QueryAsync<PowerIrradiance>(sql_power, new { PowerStationId = powerStationId, NowDay = nowDay })).ToList();
|
||||
@ -402,7 +403,7 @@ namespace SolarPower.Repository.Implement
|
||||
end = Convert.ToDateTime(post.EndTime).AddHours(-8);
|
||||
var startime = (Int64)(start.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
|
||||
var endtime = (Int64)(end.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
|
||||
sql += @$" AND `timestamp` BETWEEN {startime*1000} AND {endtime*1000}";
|
||||
sql += @$" AND `timestamp` BETWEEN {startime * 1000} AND {endtime * 1000}";
|
||||
}
|
||||
|
||||
|
||||
@ -679,21 +680,24 @@ select pr.FormId as FormId, pr.Id as ErrorID, a.id, site_id, ps.Id PowerStationI
|
||||
case 4: // date-range 選擇不同天
|
||||
if (!string.IsNullOrEmpty(post.HistoryRange))
|
||||
{
|
||||
string d1 = post.HistoryRange.Substring(0, 10).Replace("/", "-");
|
||||
string d2 = post.HistoryRange.Substring(13, 10).Replace("/", "-");
|
||||
if (d1 == d2)
|
||||
{ // range 查詢同一天
|
||||
range2 = @$" AND DATE_FORMAT(C.`TIMESTAMP`,'%Y-%m-%d') BETWEEN '{ d1 }' AND '{ d2 }'";
|
||||
sql = $@" SELECT C.TIMESTAMP, C.KWH AS KWH,C.SOLARHOUR, C.PR,
|
||||
string d1 = post.HistoryRange.Substring(0, 10).Replace("/", "-");
|
||||
string d2 = post.HistoryRange.Substring(13, 10).Replace("/", "-");
|
||||
DateTime startTime = Convert.ToDateTime(d1);
|
||||
DateTime endTime = Convert.ToDateTime(d2).AddDays(1);
|
||||
|
||||
if (d1 == d2)
|
||||
{ // range 查詢同一天
|
||||
range2 = @$" AND C.`TIMESTAMP` >= '{startTime}' AND C.`TIMESTAMP` < '{endTime}'";
|
||||
sql = $@" SELECT C.TIMESTAMP, C.KWH AS KWH,C.SOLARHOUR, C.PR,
|
||||
P.Irradiance, P.IrrDayHour, P.Temperature AS Temp , C.KWHKWP, P.IrrDay, 0 AS DiffSOLARHOUR, C.PR avgPR
|
||||
FROM power_station_history_hour C
|
||||
LEFT JOIN sensor_history_hour P ON P.`TIMESTAMP` =C.`TIMESTAMP` AND P.PowerStationId = C.PowerStationId
|
||||
WHERE C.PowerStationId = {post.PowerstationId}{range2} ";
|
||||
}
|
||||
else
|
||||
{ // range 查詢不同天
|
||||
//string endDate = DateTime.Parse(d2).AddDays(1).ToString("yyyy-MM-dd");
|
||||
range = @$" AND DATE_FORMAT(C.`TIMESTAMP`,'%Y-%m-%d') BETWEEN '{ d1 }' AND '{ d2 }'";
|
||||
}
|
||||
else
|
||||
{ // range 查詢不同天
|
||||
//string endDate = DateTime.Parse(d2).AddDays(1).ToString("yyyy-MM-dd");
|
||||
range = @$" AND C.`TIMESTAMP` BETWEEN '{d1}' AND '{d2}'";
|
||||
|
||||
//sql = $@" SELECT left(C.`TIMESTAMP`, 10) `TIMESTAMP`, C.TODAYKWH AS KWH, C.SOLARHOUR, C.PR, P.Irradiance, P.Temperature AS Temp ,C.KWHKWP, P.IrrDay, 0 AS DiffSOLARHOUR, C.PR avgPR
|
||||
// FROM power_station_history_day C
|
||||
@ -704,19 +708,19 @@ select pr.FormId as FormId, pr.Id as ErrorID, a.id, site_id, ps.Id PowerStationI
|
||||
FROM power_station_history_day C
|
||||
LEFT JOIN sensor_history_day P ON DATE_FORMAT(P.TIMESTAMP, '%Y-%m-%d') = DATE_FORMAT(C.TIMESTAMP, '%Y-%m-%d') AND P.PowerStationId = C.PowerStationId
|
||||
WHERE C.PowerStationId = {post.PowerstationId}{range} order by C.TIMESTAMP"; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 1: // day 沒有 dateRange - 月
|
||||
sql = $@" SELECT C.TIMESTAMP, {kwh} AS KWH, C.SOLARHOUR, C.PR, P.Irradiance, P.IrrDayHour, P.Temperature AS Temp ,C.KWHKWP, P.IrrDay, 0 AS DiffSOLARHOUR, C.PR avgPR
|
||||
sql = $@" SELECT C.TIMESTAMP, {kwh} AS KWH, C.SOLARHOUR, C.PR, P.Irradiance, P.IrrDayHour, P.Temperature AS Temp ,C.KWHKWP, P.IrrDay, 0 AS DiffSOLARHOUR, C.PR avgPR
|
||||
FROM {usedb} C
|
||||
LEFT JOIN {pyrdb} P ON DATE_FORMAT(P.TIMESTAMP, '%Y-%m-%d') = DATE_FORMAT(C.TIMESTAMP, '%Y-%m-%d') AND P.PowerStationId = C.PowerStationId
|
||||
WHERE C.PowerStationId = {post.PowerstationId}{range} order by C.TIMESTAMP"; break;
|
||||
case 2: // month 單月
|
||||
//sql = $@" SELECT C.TIMESTAMP, C.MONTHKWH AS KWH, C.SOLARHOUR, C.PR, P.Irradiance, P.IrrDayHour, P.Temperature AS Temp ,C.KWHKWP, P.IrrDay, 0 AS DiffSOLARHOUR
|
||||
// FROM power_station_history_month C
|
||||
// LEFT JOIN sensor_history_month P ON DATE_FORMAT(P.TIMESTAMP, '%Y-%m') = DATE_FORMAT(C.TIMESTAMP, '%Y-%m') AND P.PowerStationId = C.PowerStationId
|
||||
// WHERE C.PowerStationId = {post.PowerstationId}{range}";
|
||||
//sql = $@" SELECT C.TIMESTAMP, C.MONTHKWH AS KWH, C.SOLARHOUR, C.PR, P.Irradiance, P.IrrDayHour, P.Temperature AS Temp ,C.KWHKWP, P.IrrDay, 0 AS DiffSOLARHOUR
|
||||
// FROM power_station_history_month C
|
||||
// LEFT JOIN sensor_history_month P ON DATE_FORMAT(P.TIMESTAMP, '%Y-%m') = DATE_FORMAT(C.TIMESTAMP, '%Y-%m') AND P.PowerStationId = C.PowerStationId
|
||||
// WHERE C.PowerStationId = {post.PowerstationId}{range}";
|
||||
sql = $@" SELECT C.TIMESTAMP, C.MONTHKWH AS KWH, C.SOLARHOUR, C.PR, P.Irradiance, P.IrrDayHour, P.Temperature AS Temp ,C.KWHKWP, P.IrrDay, 0 AS DiffSOLARHOUR, C.PR avgPR
|
||||
FROM power_station_history_month C
|
||||
LEFT JOIN sensor_history_month P ON DATE_FORMAT(P.TIMESTAMP, '%Y-%m') = DATE_FORMAT(C.TIMESTAMP, '%Y-%m') AND P.PowerStationId = C.PowerStationId
|
||||
@ -735,7 +739,7 @@ select pr.FormId as FormId, pr.Id as ErrorID, a.id, site_id, ps.Id PowerStationI
|
||||
// LEFT JOIN sensor_history_month P ON P.`TIMESTAMP` = C.`TIMESTAMP` AND P.PowerStationId = C.PowerStationId
|
||||
// WHERE C.PowerStationId = {post.PowerstationId}
|
||||
// GROUP BY left(c.`TIMESTAMP`, 4) ORDER BY C.`TIMESTAMP` ";
|
||||
sql = $@"select * from (
|
||||
sql = $@"select * from (
|
||||
select left(c.`TIMESTAMP`, 4) AS `TIMESTAMP`, sum(monthKWH) AS KWH, round(AVG(PR), 2) AS PR , round(AVG(PR), 2) AS avgPR ,
|
||||
ifnull(avg( P.IrrDay), 0) irrDay, avg(P.Temperature) AS Temp, ps.GeneratingCapacity AS GeneratingCapacity
|
||||
FROM power_station_history_month C
|
||||
@ -758,39 +762,39 @@ select pr.FormId as FormId, pr.Id as ErrorID, a.id, site_id, ps.Id PowerStationI
|
||||
//else
|
||||
//{
|
||||
// sql = $@" SELECT C.TIMESTAMP, {kwh} AS KWH, C.SOLARHOUR, C.PR, P.Irradiance, P.Temperature AS Temp ,C.KWHKWP, P.IrrDay, 0 AS DiffSOLARHOUR
|
||||
// FROM {usedb} C
|
||||
// LEFT JOIN {pyrdb} P ON DATE_FORMAT(P.TIMESTAMP,'{timeGroup}') = DATE_FORMAT(C.TIMESTAMP,'{timeGroup}') AND P.PowerStationId = C.PowerStationId
|
||||
// FROM {usedb} C
|
||||
// LEFT JOIN {pyrdb} P ON DATE_FORMAT(P.TIMESTAMP,'{timeGroup}') = DATE_FORMAT(C.TIMESTAMP,'{timeGroup}') AND P.PowerStationId = C.PowerStationId
|
||||
// WHERE C.PowerStationId = {post.PowerstationId}{range}";
|
||||
// /*
|
||||
// sql = @$"SELECT {select}
|
||||
// FROM
|
||||
// (
|
||||
// SELECT B.*, IFNULL(A.SOLARHOUR,0) AS PSValue
|
||||
// FROM
|
||||
// (
|
||||
// SELECT DENSE_RANK() OVER(ORDER BY C.TIMESTAMP) AS ROWID
|
||||
// , (DENSE_RANK() OVER(ORDER BY C.TIMESTAMP)) - 1 AS PreROWID,
|
||||
// C.TIMESTAMP,{kwh} AS KWH,C.SOLARHOUR,C.PR,P.Irradiance,P.Temperature AS Temp
|
||||
// FROM {usedb} C
|
||||
// LEFT JOIN {pyrdb} P ON DATE_FORMAT(P.TIMESTAMP,'{timeGroup}') = DATE_FORMAT(C.TIMESTAMP,'{timeGroup}') AND P.PowerStationId = C.PowerStationId
|
||||
// SELECT B.*, IFNULL(A.SOLARHOUR,0) AS PSValue
|
||||
// FROM
|
||||
// (
|
||||
// SELECT DENSE_RANK() OVER(ORDER BY C.TIMESTAMP) AS ROWID
|
||||
// , (DENSE_RANK() OVER(ORDER BY C.TIMESTAMP)) - 1 AS PreROWID,
|
||||
// C.TIMESTAMP,{kwh} AS KWH,C.SOLARHOUR,C.PR,P.Irradiance,P.Temperature AS Temp
|
||||
// FROM {usedb} C
|
||||
// LEFT JOIN {pyrdb} P ON DATE_FORMAT(P.TIMESTAMP,'{timeGroup}') = DATE_FORMAT(C.TIMESTAMP,'{timeGroup}') AND P.PowerStationId = C.PowerStationId
|
||||
// WHERE C.PowerStationId = {post.PowerstationId}{range2} GROUP BY C.TIMESTAMP ORDER BY C.TIMESTAMP
|
||||
// ) A
|
||||
// RIGHT OUTER JOIN
|
||||
// (
|
||||
// SELECT DENSE_RANK() OVER(ORDER BY C.TIMESTAMP) AS ROWID
|
||||
// , (DENSE_RANK() OVER(ORDER BY C.TIMESTAMP)) - 1 AS PreROWID,
|
||||
// C.TIMESTAMP,{kwh} AS KWH,C.SOLARHOUR,C.PR,P.Irradiance,P.Temperature AS Temp ,C.KWHKWP,P.IrrDay
|
||||
// FROM {usedb} C
|
||||
// LEFT JOIN {pyrdb} P ON DATE_FORMAT(P.TIMESTAMP,'{timeGroup}') = DATE_FORMAT(C.TIMESTAMP,'{timeGroup}') AND P.PowerStationId = C.PowerStationId
|
||||
// ) A
|
||||
// RIGHT OUTER JOIN
|
||||
// (
|
||||
// SELECT DENSE_RANK() OVER(ORDER BY C.TIMESTAMP) AS ROWID
|
||||
// , (DENSE_RANK() OVER(ORDER BY C.TIMESTAMP)) - 1 AS PreROWID,
|
||||
// C.TIMESTAMP,{kwh} AS KWH,C.SOLARHOUR,C.PR,P.Irradiance,P.Temperature AS Temp ,C.KWHKWP,P.IrrDay
|
||||
// FROM {usedb} C
|
||||
// LEFT JOIN {pyrdb} P ON DATE_FORMAT(P.TIMESTAMP,'{timeGroup}') = DATE_FORMAT(C.TIMESTAMP,'{timeGroup}') AND P.PowerStationId = C.PowerStationId
|
||||
// WHERE C.PowerStationId = {post.PowerstationId}{range2} GROUP BY C.TIMESTAMP ORDER BY C.TIMESTAMP
|
||||
// ) B
|
||||
// ON A.ROWID = B.PreROWID
|
||||
// ) B
|
||||
// ON A.ROWID = B.PreROWID
|
||||
// ) V {range} {out_group}";
|
||||
// */
|
||||
//}
|
||||
result = (await conn.QueryAsync<HistoryTable>(sql)).ToList();
|
||||
}
|
||||
catch (Exception exception)
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
@ -820,38 +824,38 @@ select pr.FormId as FormId, pr.Id as ErrorID, a.id, site_id, ps.Id PowerStationI
|
||||
where datestamp = '{DateTime.Now.ToString("yyyy-MM-dd")}' and ps.`Code` is not null and priority < 20
|
||||
) a LEFT JOIN notice_schedule ns ON ns.ExceptionId = a.id
|
||||
WHERE ns.Id IS NULL ";
|
||||
// var sql = $@"
|
||||
// SELECT a.`*`,ns.Id FROM
|
||||
// (
|
||||
//select pr.FormId as FormId, pr.Id as ErrorID, priority, a.id, site_id, `timestamp`, a.sourceState,
|
||||
//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_zh as alarmClassName,ps.Name as PowerStationName, ps.Id as PowerStationId,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
|
||||
// #, a.errDeviceBrand , d.brend , a.errDeviceModel, d.model , a.errValue , d.errCode
|
||||
//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 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 sourceState = 1 and ps.`Code` is not null and priority < 20
|
||||
// ) a LEFT JOIN notice_schedule ns ON ns.ExceptionId = a.id
|
||||
// WHERE ns.Id IS NULL ";
|
||||
// var sql = $@"
|
||||
// SELECT a.`*`,ns.Id FROM
|
||||
// (
|
||||
//select pr.FormId as FormId, pr.Id as ErrorID, priority, a.id, site_id, `timestamp`, a.sourceState,
|
||||
//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_zh as alarmClassName,ps.Name as PowerStationName, ps.Id as PowerStationId,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
|
||||
// #, a.errDeviceBrand , d.brend , a.errDeviceModel, d.model , a.errValue , d.errCode
|
||||
//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 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 sourceState = 1 and ps.`Code` is not null and priority < 20
|
||||
// ) a LEFT JOIN notice_schedule ns ON ns.ExceptionId = a.id
|
||||
// WHERE ns.Id IS NULL ";
|
||||
exceptionEmailInfos = (await conn.QueryAsync<ExceptionEmailInfo>(sql)).ToList();
|
||||
}
|
||||
catch (Exception exception)
|
||||
|
||||
@ -4747,69 +4747,72 @@ namespace SolarPower.Repository.Implement
|
||||
var sql = "";
|
||||
foreach (var entity in entities)
|
||||
{
|
||||
var table_name = string.Format("`{0}`.`s{1}01_inv`", entity.SiteDB, entity.Code);
|
||||
var sensor_table_name = string.Format("`{0}`.`s{1}01_sensoravg`", entity.SiteDB, entity.Code);
|
||||
var table_name_hot = string.Format("`{0}`.`s{1}01_inv`", entity.SiteDB, entity.Code);
|
||||
var sensor_table_name_hot = string.Format("`{0}`.`s{1}01_sensoravg`", entity.SiteDB, entity.Code);
|
||||
|
||||
var table_name_cold = string.Format("`{0}_history`.`s{1}01_inv`", entity.SiteDB, entity.Code);
|
||||
var sensor_table_name_cold = string.Format("`{0}_history`.`s{1}01_sensoravg`", entity.SiteDB, entity.Code);
|
||||
|
||||
var inverterIds = string.Join("','", entity.InverterIds);
|
||||
|
||||
var temp_sql = $@"SELECT
|
||||
// 熱區 SQL
|
||||
var sql_hot = $@"
|
||||
SELECT
|
||||
FROM_UNIXTIME(inv.TIMESTAMP/1000, '%H:%i') AS TIMESTAMP,
|
||||
inv.INVERTERID,
|
||||
i.InverterName AS INVERTERName,
|
||||
sen.{entity.Sensor} AS Irradiance,
|
||||
((inv.DC1W + inv.DC2W + inv.DC3W + inv.DC4W + inv.DC5W) / 1000) AS DCKW,
|
||||
((inv.AC1W + inv.AC2W + inv.AC3W) / 1000) AS ACKW,
|
||||
inv.AC1V,
|
||||
inv.AC1A,
|
||||
inv.AC1W,
|
||||
inv.AC1F,
|
||||
inv.AC1WH,
|
||||
inv.AC2V,
|
||||
inv.AC2A,
|
||||
inv.AC2W,
|
||||
inv.AC2F,
|
||||
inv.AC2WH,
|
||||
inv.AC3V,
|
||||
inv.AC3A,
|
||||
inv.AC3W,
|
||||
inv.AC3F,
|
||||
inv.AC3WH,
|
||||
inv.DC1V,
|
||||
inv.DC1A,
|
||||
inv.DC1W,
|
||||
inv.DC1WH,
|
||||
inv.DC2V,
|
||||
inv.DC2A,
|
||||
inv.DC2W,
|
||||
inv.DC2WH,
|
||||
inv.DC3V,
|
||||
inv.DC3A,
|
||||
inv.DC3W,
|
||||
inv.DC3WH,
|
||||
inv.DC4V,
|
||||
inv.DC4A,
|
||||
inv.DC4W,
|
||||
inv.DC4WH,
|
||||
inv.DC5V,
|
||||
inv.DC5A,
|
||||
inv.DC5W,
|
||||
inv.DC5WH,
|
||||
inv.PR,
|
||||
inv.RA1,
|
||||
inv.RA2,
|
||||
inv.RA3,
|
||||
inv.RA4,
|
||||
inv.RA5
|
||||
FROM {table_name} inv
|
||||
LEFT JOIN (select * from {sensor_table_name} where TIMESTAMP between @start_timestamp and @end_timestamp)sen
|
||||
inv.AC1V, inv.AC1A, inv.AC1W, inv.AC1F, inv.AC1WH,
|
||||
inv.AC2V, inv.AC2A, inv.AC2W, inv.AC2F, inv.AC2WH,
|
||||
inv.AC3V, inv.AC3A, inv.AC3W, inv.AC3F, inv.AC3WH,
|
||||
inv.DC1V, inv.DC1A, inv.DC1W, inv.DC1WH,
|
||||
inv.DC2V, inv.DC2A, inv.DC2W, inv.DC2WH,
|
||||
inv.DC3V, inv.DC3A, inv.DC3W, inv.DC3WH,
|
||||
inv.DC4V, inv.DC4A, inv.DC4W, inv.DC4WH,
|
||||
inv.DC5V, inv.DC5A, inv.DC5W, inv.DC5WH,
|
||||
inv.PR, inv.RA1, inv.RA2, inv.RA3, inv.RA4, inv.RA5
|
||||
FROM {table_name_hot} inv
|
||||
LEFT JOIN (SELECT * FROM {sensor_table_name_hot} WHERE TIMESTAMP BETWEEN @start_timestamp AND @end_timestamp) sen
|
||||
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 {entity.SiteDB}.inverter i ON inv.INVERTERID = i.InverterId
|
||||
WHERE inv.`TIMESTAMP` between @start_timestamp and @end_timestamp
|
||||
-- WHERE FROM_UNIXTIME(inv.TIMESTAMP/1000, '%Y-%m-%d') = @NowDay
|
||||
AND inv.INVERTERID IN ('{inverterIds}')";
|
||||
LEFT JOIN {entity.SiteDB}.inverter i ON inv.INVERTERID = i.InverterId
|
||||
WHERE inv.TIMESTAMP BETWEEN @start_timestamp AND @end_timestamp
|
||||
AND inv.INVERTERID IN ('{inverterIds}')
|
||||
";
|
||||
|
||||
// 冷區 SQL
|
||||
var sql_cold = $@"
|
||||
SELECT
|
||||
FROM_UNIXTIME(inv.TIMESTAMP/1000, '%H:%i') AS TIMESTAMP,
|
||||
inv.INVERTERID,
|
||||
i.InverterName AS INVERTERName,
|
||||
sen.{entity.Sensor} AS Irradiance,
|
||||
((inv.DC1W + inv.DC2W + inv.DC3W + inv.DC4W + inv.DC5W) / 1000) AS DCKW,
|
||||
((inv.AC1W + inv.AC2W + inv.AC3W) / 1000) AS ACKW,
|
||||
inv.AC1V, inv.AC1A, inv.AC1W, inv.AC1F, inv.AC1WH,
|
||||
inv.AC2V, inv.AC2A, inv.AC2W, inv.AC2F, inv.AC2WH,
|
||||
inv.AC3V, inv.AC3A, inv.AC3W, inv.AC3F, inv.AC3WH,
|
||||
inv.DC1V, inv.DC1A, inv.DC1W, inv.DC1WH,
|
||||
inv.DC2V, inv.DC2A, inv.DC2W, inv.DC2WH,
|
||||
inv.DC3V, inv.DC3A, inv.DC3W, inv.DC3WH,
|
||||
inv.DC4V, inv.DC4A, inv.DC4W, inv.DC4WH,
|
||||
inv.DC5V, inv.DC5A, inv.DC5W, inv.DC5WH,
|
||||
inv.PR, inv.RA1, inv.RA2, inv.RA3, inv.RA4, inv.RA5
|
||||
FROM {table_name_cold} inv
|
||||
LEFT JOIN (SELECT * FROM {sensor_table_name_cold} WHERE TIMESTAMP BETWEEN @start_timestamp AND @end_timestamp) sen
|
||||
ON inv.CrdTime = sen.CrdTime
|
||||
LEFT JOIN {entity.SiteDB}.inverter i ON inv.INVERTERID = i.InverterId
|
||||
WHERE inv.TIMESTAMP BETWEEN @start_timestamp AND @end_timestamp
|
||||
AND inv.INVERTERID IN ('{inverterIds}')
|
||||
";
|
||||
|
||||
// 熱區 + 冷區 合併
|
||||
var temp_sql = $"({sql_hot}) UNION ALL ({sql_cold})";
|
||||
|
||||
sql_perSiteDB.Add(temp_sql);
|
||||
}
|
||||
|
||||
sql = "SELECT * FROM (" + string.Join(" UNION ", sql_perSiteDB) + ") a ORDER BY a.TIMESTAMP ASC";
|
||||
|
||||
result = (await conn.QueryAsync<InverterHistory>(sql, new { start_timestamp = start_timestamp, end_timestamp = end_timestamp }, commandTimeout: 300)).ToList();
|
||||
@ -4839,7 +4842,8 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
var inverterIds = string.Join("','", entity.InverterIds);
|
||||
|
||||
var temp_sql = $@"SELECT
|
||||
// 熱區 SQL
|
||||
var sql_hot = $@"SELECT
|
||||
DATE_FORMAT(inv.TIMESTAMP, '%Y-%m-%d') AS TIMESTAMP,
|
||||
inv.INVERTERID,
|
||||
i.InverterName AS INVERTERName,
|
||||
@ -4858,6 +4862,30 @@ namespace SolarPower.Repository.Implement
|
||||
AND inv.INVERTERID IN ('{inverterIds}')
|
||||
AND inv.TIMESTAMP BETWEEN @StartDay AND @EndDay";
|
||||
|
||||
// 冷區 SQL
|
||||
var sql_cold = $@"SELECT
|
||||
DATE_FORMAT(inv.TIMESTAMP, '%Y-%m-%d') AS TIMESTAMP,
|
||||
inv.INVERTERID,
|
||||
i.InverterName AS INVERTERName,
|
||||
inv.Irradiance,
|
||||
inv.KWH,
|
||||
inv.TODAYKWH,
|
||||
inv.PR,
|
||||
inv.RA1,
|
||||
inv.RA2,
|
||||
inv.RA3,
|
||||
inv.RA4,
|
||||
inv.RA5
|
||||
FROM solar_master_offline.inverter_history_day inv
|
||||
LEFT JOIN {entity.SiteDBName}.inverter i ON inv.INVERTERID = i.InverterId
|
||||
WHERE inv.PowerStationId = {entity.PowerStationId}
|
||||
AND inv.INVERTERID IN ('{inverterIds}')
|
||||
AND inv.TIMESTAMP BETWEEN @StartDay AND @EndDay
|
||||
";
|
||||
|
||||
// 熱區 + 冷區 合併
|
||||
var temp_sql = $"({sql_hot}) UNION ALL ({sql_cold})";
|
||||
|
||||
sql_perSiteDB.Add(temp_sql);
|
||||
}
|
||||
sql = "SELECT * FROM (" + string.Join(" UNION ", sql_perSiteDB) + ") a ORDER BY a.TIMESTAMP ASC";
|
||||
|
||||
@ -648,6 +648,8 @@
|
||||
powerids.splice($.inArray(this.value, powerids), 1);
|
||||
}
|
||||
|
||||
if (powerids.length === 0) return;
|
||||
|
||||
GetStationsCard();//5張卡片值
|
||||
photoshow();//輪播圖片
|
||||
|
||||
|
||||
@ -384,7 +384,7 @@ namespace solarApp.Service
|
||||
catch (Exception ex)
|
||||
{
|
||||
TimeSpan duration = DateTime.Now - dt_start1;
|
||||
arclog.insert_log(_powerStationID, @$"move raw s1 - {move_month}", duration.TotalSeconds, $"{_siteDB}.s{_siteID01}_station", $"{_siteDB}_history.s{_siteID01}_station", "1", ex.Message, "err", conn, null);
|
||||
arclog.insert_log(_powerStationID, @$"move raw s1 - {move_month}", duration.TotalSeconds, $"{_siteDB}.s{_siteID01}_inv", $"{_siteDB}_history.s{_siteID01}_inv", "1", ex.Message, "err", conn, null);
|
||||
//arclog.insert_log(_powerStationID, "sensor step1", duration.TotalSeconds, "sensor_history_hour", "insert sensor hour", "0", "", rowCT.ToString(), conn, cmd);
|
||||
throw ex;
|
||||
}
|
||||
|
||||
@ -228,6 +228,20 @@ namespace solarApp.Service
|
||||
}
|
||||
}
|
||||
|
||||
public List<station_list> get_station_list32_by_range(int startId, int endId)
|
||||
{
|
||||
using (MySqlConnection conn = new MySqlConnection(Connection1))
|
||||
{
|
||||
conn.Open();
|
||||
string sql = @"select id, CompanyId, `code`, SerialNumber, CONCAT(`code` ,'01') SiteID, SiteDB, `name` SiteName
|
||||
from power_station
|
||||
where deleted = 0 and `status`= 1 and id >= @startId and id <= @endId";
|
||||
List<station_list> ds = conn.Query<station_list>(sql, new { startId, endId }).AsList<station_list>();
|
||||
conn.Close();
|
||||
return ds;
|
||||
}
|
||||
}
|
||||
|
||||
public List<PowerStation> get_powerStation()
|
||||
{
|
||||
using (MySqlConnection conn = new MySqlConnection(Connection1))
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
using System;
|
||||
using MySql.Data.MySqlClient;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
using MySql.Data.MySqlClient;
|
||||
|
||||
namespace solarApp.Service
|
||||
{
|
||||
@ -26,6 +27,10 @@ namespace solarApp.Service
|
||||
}
|
||||
else _cmd = cmd;
|
||||
|
||||
if (myCon.State != ConnectionState.Open)
|
||||
myCon.Open();
|
||||
|
||||
|
||||
string errMsg = string.Empty;
|
||||
if (!string.IsNullOrEmpty(errMessage))
|
||||
{
|
||||
@ -34,6 +39,10 @@ namespace solarApp.Service
|
||||
|
||||
string nowTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
//string procResult = (string.IsNullOrEmpty(errMessage)) ? "0" : "1";
|
||||
if (procResult == "err")
|
||||
{
|
||||
procResult = "1"; // 1: error
|
||||
}
|
||||
string sql = @"INSERT INTO `solar_master`.`log_archive`(power_stationID, `action_name`, `action_time`, `duration_sec`, `src_table`, `dest_table`, `result`, `err_txt`, `note`)
|
||||
VALUES ("+ power_stationID + ", '" + action_name + "', '" + nowTime + "', " + duration_sec + ", '" + // action_time, duration_sec
|
||||
src_table + "', '"+ dest_table + "', b'"+ procResult + "', '" + // src_table, dest_table, result
|
||||
|
||||
@ -253,39 +253,63 @@ namespace solarApp.Service
|
||||
{
|
||||
logger.Information("【ProcInvSvc】開始執行[{0}]在{1}逆變器hour補償", _siteID, _date1);
|
||||
|
||||
sql = @$"DROP TEMPORARY TABLE IF EXISTS Inv_day_" + _powerStationID + @"_s2;
|
||||
CREATE TEMPORARY TABLE Inv_day_" + _powerStationID + @"_s2
|
||||
SELECT " + _powerStationID + @" powerStationID, a.INVERTERID, a.reportDate,a.AC1V, a.AC1A, a.AC1W, a.AC1F, a.AC1WH, a.AC2V, a.AC2A, a.AC2W, a.AC2F, a.AC2WH,
|
||||
a.AC3V, a.AC3A, a.AC3W, a.AC3F, a.AC3WH, a.DC1V, a.DC1A, a.DC1W, a.DC1WH, a.DC2V, a.DC2A, a.DC2W, a.DC2WH, a.DC3V, a.DC3A, a.DC3W,
|
||||
a.DC3WH, a.DC4V, a.DC4A, a.DC4W, a.DC4WH, a.DC5V, a.DC5A, a.DC5W, a.DC5WH,
|
||||
a.RA1, a.RA2, a.RA3, a.RA4, a.RA5, a.KWH, a.TODAYKWH, a.TOTALKWH,
|
||||
IFNULL(Irradiance, 0) irr, IFNULL(IrrDay, 0) IrrDay, 0 as PR, ((DC1W + DC2W + DC3W + DC4W + DC5W) / 1000) DCKW, ((AC1W + AC2W + AC3W) / 1000) ACKW, (a.KWH / i.Capacity) AS KWHKWP
|
||||
from
|
||||
(-- 取得該時間區間的KWH
|
||||
SELECT concat(left(crdTime, 13), ':00:00') reportDate, INVERTERID,
|
||||
AVG(AC1V) AS AC1V, AVG(AC1A) AS AC1A, round(SUM(AC1W), 5) AS AC1W, AVG(AC1F) AS AC1F, SUM(AC1WH) AS AC1WH, AVG(AC2V) AS AC2V,
|
||||
AVG(AC2A) AS AC2A, round(SUM(AC2W), 5) AS AC2W, AVG(AC2F) AS AC2F, SUM(AC2WH) AS AC2WH, AVG(AC3V) AS AC3V, AVG(AC3A) AS AC3A,
|
||||
round(SUM(AC3W), 5) AS AC3W, AVG(AC3F) AS AC3F, SUM(AC3WH) AS AC3WH, AVG(DC1V) AS DC1V, AVG(DC1A) AS DC1A, SUM(DC1W) AS DC1W,
|
||||
SUM(DC1WH) AS DC1WH, AVG(DC2V) AS DC2V, AVG(DC2A) AS DC2A, SUM(DC2W) AS DC2W, SUM(DC2WH) AS DC2WH, AVG(DC3V) AS DC3V,
|
||||
AVG(DC3A) AS DC3A, AVG(DC3W) AS DC3W, AVG(DC3WH) AS DC3WH, AVG(DC4V) AS DC4V, AVG(DC4A) AS DC4A, SUM(DC4W) AS DC4W,
|
||||
SUM(DC4WH) AS DC4WH, AVG(DC5V) AS DC5V, AVG(DC5A) AS DC5A, SUM(DC5W) AS DC5W, SUM(DC5WH) AS DC5WH,
|
||||
AVG(RA1) AS RA1, AVG(RA2) AS RA2, AVG(RA3) AS RA3,
|
||||
AVG(RA4) AS RA4, AVG(RA5) AS RA5, MAX(TODAYKWH) AS TODAYKWH, MAX(TOTALKWH) AS TOTALKWH, (SUM(WH) / 1000) AS KWH
|
||||
FROM del_Inv_day_" + _powerStationID + @"_s1
|
||||
GROUP BY left(crdTime, 13), INVERTERID
|
||||
) a
|
||||
-- 取得逆變器容量
|
||||
LEFT JOIN " + _siteDB + @".inverter i ON a.INVERTERID = i.InverterId
|
||||
-- 取日照度-------------------- -
|
||||
left join(
|
||||
select concat(DATE_FORMAT(`TIMESTAMP`, '%Y-%m-%d %H'), ':00:00') AS reportDate, Irradiance, IrrDay
|
||||
from sensor_history_hour
|
||||
where powerstationID = " + _powerStationID + @" and DATE_FORMAT(`TIMESTAMP`, '%Y-%m-%d') = @date1
|
||||
)irr on a.reportDate = irr.reportDate
|
||||
where i.enabled = 1;";
|
||||
//int ct = conn.Execute(sql, new { date1 = _date1 });
|
||||
sql = @$"
|
||||
-- 刪除暫存資料表(若存在)
|
||||
DROP TEMPORARY TABLE IF EXISTS Inv_day_{_powerStationID}_s2;
|
||||
|
||||
-- 建立暫存表
|
||||
CREATE TEMPORARY TABLE Inv_day_{_powerStationID}_s2
|
||||
SELECT
|
||||
{_powerStationID} AS powerStationID,
|
||||
a.INVERTERID,
|
||||
a.reportDate,
|
||||
a.AC1V, a.AC1A, a.AC1W, a.AC1F, a.AC1WH,
|
||||
a.AC2V, a.AC2A, a.AC2W, a.AC2F, a.AC2WH,
|
||||
a.AC3V, a.AC3A, a.AC3W, a.AC3F, a.AC3WH,
|
||||
a.DC1V, a.DC1A, a.DC1W, a.DC1WH,
|
||||
a.DC2V, a.DC2A, a.DC2W, a.DC2WH,
|
||||
a.DC3V, a.DC3A, a.DC3W, a.DC3WH,
|
||||
a.DC4V, a.DC4A, a.DC4W, a.DC4WH,
|
||||
a.DC5V, a.DC5A, a.DC5W, a.DC5WH,
|
||||
a.RA1, a.RA2, a.RA3, a.RA4, a.RA5,
|
||||
a.KWH, a.TODAYKWH, a.TOTALKWH,
|
||||
COALESCE(irr.Irradiance, 0) AS irr,
|
||||
COALESCE(irr.IrrDay, 0) AS IrrDay,
|
||||
0 AS PR,
|
||||
(a.DC1W + a.DC2W + a.DC3W + a.DC4W + a.DC5W) / 1000 AS DCKW,
|
||||
(a.AC1W + a.AC2W + a.AC3W) / 1000 AS ACKW,
|
||||
(a.KWH / IFNULL(i.Capacity, 1)) AS KWHKWP
|
||||
FROM (
|
||||
SELECT
|
||||
DATE_FORMAT(crdTime, '%Y-%m-%d %H:00:00') AS reportDate,
|
||||
INVERTERID,
|
||||
AVG(AC1V) AS AC1V, AVG(AC1A) AS AC1A, ROUND(SUM(AC1W), 5) AS AC1W, AVG(AC1F) AS AC1F, SUM(AC1WH) AS AC1WH,
|
||||
AVG(AC2V) AS AC2V, AVG(AC2A) AS AC2A, ROUND(SUM(AC2W), 5) AS AC2W, AVG(AC2F) AS AC2F, SUM(AC2WH) AS AC2WH,
|
||||
AVG(AC3V) AS AC3V, AVG(AC3A) AS AC3A, ROUND(SUM(AC3W), 5) AS AC3W, AVG(AC3F) AS AC3F, SUM(AC3WH) AS AC3WH,
|
||||
AVG(DC1V) AS DC1V, AVG(DC1A) AS DC1A, SUM(DC1W) AS DC1W, SUM(DC1WH) AS DC1WH,
|
||||
AVG(DC2V) AS DC2V, AVG(DC2A) AS DC2A, SUM(DC2W) AS DC2W, SUM(DC2WH) AS DC2WH,
|
||||
AVG(DC3V) AS DC3V, AVG(DC3A) AS DC3A, AVG(DC3W) AS DC3W, AVG(DC3WH) AS DC3WH,
|
||||
AVG(DC4V) AS DC4V, AVG(DC4A) AS DC4A, SUM(DC4W) AS DC4W, SUM(DC4WH) AS DC4WH,
|
||||
AVG(DC5V) AS DC5V, AVG(DC5A) AS DC5A, SUM(DC5W) AS DC5W, SUM(DC5WH) AS DC5WH,
|
||||
AVG(RA1) AS RA1, AVG(RA2) AS RA2, AVG(RA3) AS RA3, AVG(RA4) AS RA4, AVG(RA5) AS RA5,
|
||||
MAX(TODAYKWH) AS TODAYKWH, MAX(TOTALKWH) AS TOTALKWH,
|
||||
SUM(WH) / 1000 AS KWH
|
||||
FROM del_Inv_day_{_powerStationID}_s1
|
||||
GROUP BY DATE_FORMAT(crdTime, '%Y-%m-%d %H:00:00'), INVERTERID
|
||||
) a
|
||||
LEFT JOIN {_siteDB}.inverter i ON a.INVERTERID = i.InverterId AND i.enabled = 1
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
CONCAT(DATE_FORMAT(`TIMESTAMP`, '%Y-%m-%d %H'), ':00:00') AS reportDate,
|
||||
Irradiance, IrrDay
|
||||
FROM sensor_history_hour
|
||||
WHERE powerstationID = {_powerStationID} AND DATE(`TIMESTAMP`) = @date1
|
||||
) irr ON a.reportDate = irr.reportDate;
|
||||
";
|
||||
|
||||
//int ct = conn.Execute(sql, new { date1 = _date1 });
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandTimeout = 720;
|
||||
cmd.CommandTimeout = 1200;
|
||||
cmd.Parameters.AddWithValue("@date1", _date1);
|
||||
cmd.Parameters.AddWithValue("@PowerStationID", _powerStationID);
|
||||
cmd.CommandText = sql;
|
||||
|
||||
@ -257,9 +257,12 @@ namespace solarApp.Service
|
||||
order by 1 desc limit 1
|
||||
)a1 on a.siteID = a1.siteID join
|
||||
(
|
||||
select a.id, `code` siteID, PowerRate, GeneratingCapacity Capacity, (select `value` from solar_master.`variable` where `name` = 'CarbonRate') as CarbonRate, SolarType, IrrDay
|
||||
from solar_master.power_station a join sensor_history_day b on a.id = b.PowerStationID
|
||||
where `code` = @siteID and left(`TIMESTAMP`, 10) = @date1
|
||||
select a.id, `code` siteID, PowerRate, GeneratingCapacity Capacity, (select `value` from solar_master.`variable` where `name` = 'CarbonRate') as CarbonRate, SolarType
|
||||
-- , IrrDay
|
||||
from solar_master.power_station a
|
||||
-- join sensor_history_day b on a.id = b.PowerStationID
|
||||
where `code` = @siteID
|
||||
-- and left(`TIMESTAMP`, 10) = @date1
|
||||
) b on a.siteID = b.siteID ";
|
||||
// sql = @" INSERT INTO solar_master.power_station_history_day( PowerStationId, `TIMESTAMP`, SITEID, SITETYPE, TODAYKWH, TOTALKWH, KWHKWP,
|
||||
// PR, MP, SOLARHOUR, MONEY, TOTALMONEY, CARBON, TOTALCARBON)
|
||||
|
||||
54
solarApp/fmArchive.Designer.cs
generated
54
solarApp/fmArchive.Designer.cs
generated
@ -89,6 +89,11 @@ namespace solarApp
|
||||
lbUserName = new System.Windows.Forms.Label();
|
||||
tbUserName = new System.Windows.Forms.TextBox();
|
||||
btSendMail = new System.Windows.Forms.Button();
|
||||
this.lbStationIdRange = new System.Windows.Forms.Label();
|
||||
this.tbStationIdStart = new System.Windows.Forms.TextBox();
|
||||
this.lbStationIdDash = new System.Windows.Forms.Label();
|
||||
this.tbStationIdEnd = new System.Windows.Forms.TextBox();
|
||||
this.bt_procStep2Range = new System.Windows.Forms.Button();
|
||||
timer1 = new System.Windows.Forms.Timer(components);
|
||||
tabControl1.SuspendLayout();
|
||||
tabPage1.SuspendLayout();
|
||||
@ -165,6 +170,11 @@ namespace solarApp
|
||||
splitContainer1.Panel1.Controls.Add(bt_site);
|
||||
splitContainer1.Panel1.Controls.Add(bt_Inv);
|
||||
splitContainer1.Panel1.Controls.Add(bt_Sensor);
|
||||
splitContainer1.Panel1.Controls.Add(this.lbStationIdRange);
|
||||
splitContainer1.Panel1.Controls.Add(this.tbStationIdStart);
|
||||
splitContainer1.Panel1.Controls.Add(this.lbStationIdDash);
|
||||
splitContainer1.Panel1.Controls.Add(this.tbStationIdEnd);
|
||||
splitContainer1.Panel1.Controls.Add(this.bt_procStep2Range);
|
||||
//
|
||||
// splitContainer1.Panel2
|
||||
//
|
||||
@ -178,7 +188,7 @@ namespace solarApp
|
||||
//
|
||||
// bt_procStep2
|
||||
//
|
||||
bt_procStep2.Location = new System.Drawing.Point(109, 910);
|
||||
bt_procStep2.Location = new System.Drawing.Point(10, 910);
|
||||
bt_procStep2.Name = "bt_procStep2";
|
||||
bt_procStep2.Size = new System.Drawing.Size(166, 57);
|
||||
bt_procStep2.TabIndex = 21;
|
||||
@ -186,6 +196,42 @@ namespace solarApp
|
||||
bt_procStep2.UseVisualStyleBackColor = true;
|
||||
bt_procStep2.Click += bt_procStep2_Click;
|
||||
//
|
||||
// lbStationIdRange
|
||||
//
|
||||
this.lbStationIdRange.Name = "lbStationIdRange";
|
||||
this.lbStationIdRange.Location = new System.Drawing.Point(384, 932);
|
||||
this.lbStationIdRange.Size = new System.Drawing.Size(90, 27);
|
||||
this.lbStationIdRange.Text = "電站ID區間:";
|
||||
//
|
||||
// tbStationIdStart
|
||||
//
|
||||
this.tbStationIdStart.Name = "tbStationIdStart";
|
||||
this.tbStationIdStart.Location = new System.Drawing.Point(479, 930);
|
||||
this.tbStationIdStart.Size = new System.Drawing.Size(60, 27);
|
||||
//
|
||||
// lbStationIdDash
|
||||
//
|
||||
this.lbStationIdDash.Name = "lbStationIdDash";
|
||||
this.lbStationIdDash.Location = new System.Drawing.Point(544, 930);
|
||||
this.lbStationIdDash.Size = new System.Drawing.Size(15, 27);
|
||||
this.lbStationIdDash.Text = "~";
|
||||
//
|
||||
// tbStationIdEnd
|
||||
//
|
||||
this.tbStationIdEnd.Name = "tbStationIdEnd";
|
||||
this.tbStationIdEnd.Location = new System.Drawing.Point(564, 930);
|
||||
this.tbStationIdEnd.Size = new System.Drawing.Size(60, 27);
|
||||
//
|
||||
// bt_procStep2Range
|
||||
//
|
||||
this.bt_procStep2Range.Name = "bt_procStep2Range";
|
||||
this.bt_procStep2Range.Location = new System.Drawing.Point(208, 910);
|
||||
this.bt_procStep2Range.Size = new System.Drawing.Size(166, 57);
|
||||
this.bt_procStep2Range.TabIndex = 22;
|
||||
this.bt_procStep2Range.Text = "區間跑報告";
|
||||
this.bt_procStep2Range.UseVisualStyleBackColor = true;
|
||||
this.bt_procStep2Range.Click += new System.EventHandler(this.bt_procStep2Range_Click);
|
||||
//
|
||||
// button3
|
||||
//
|
||||
button3.Font = new System.Drawing.Font("Microsoft JhengHei UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
@ -858,5 +904,11 @@ namespace solarApp
|
||||
private System.Windows.Forms.Button btSyncErr;
|
||||
private System.Windows.Forms.Button bt_MoveRawData;
|
||||
private System.Windows.Forms.Button bt_procStep2;
|
||||
// 在 bt_procStep2 附近新增
|
||||
private System.Windows.Forms.Label lbStationIdRange;
|
||||
private System.Windows.Forms.TextBox tbStationIdStart;
|
||||
private System.Windows.Forms.Label lbStationIdDash;
|
||||
private System.Windows.Forms.TextBox tbStationIdEnd;
|
||||
private System.Windows.Forms.Button bt_procStep2Range;
|
||||
}
|
||||
}
|
||||
@ -872,8 +872,8 @@ namespace solarApp
|
||||
//for sensor_history_hour
|
||||
foreach (DateTime day in EachDay(DateTime.Parse(date1), DateTime.Parse(date2)))
|
||||
{
|
||||
sensorSvc.archiveSensorHistoryHourData(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd"));
|
||||
sensorSvc.isFirst = false;
|
||||
//sensorSvc.archiveSensorHistoryHourData(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd"));
|
||||
//sensorSvc.isFirst = false;
|
||||
invSvc.report_invDay(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd"));
|
||||
}
|
||||
}
|
||||
@ -886,8 +886,8 @@ namespace solarApp
|
||||
//for sensor_history_hour
|
||||
foreach (DateTime day in EachDay(DateTime.Parse(date1), DateTime.Parse(date2)))
|
||||
{
|
||||
sensorSvc.archiveSensorHistoryHourData(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd"));
|
||||
sensorSvc.isFirst = false;
|
||||
//sensorSvc.archiveSensorHistoryHourData(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd"));
|
||||
//sensorSvc.isFirst = false;
|
||||
invSvc.report_invDay(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd"));
|
||||
}
|
||||
}
|
||||
@ -895,6 +895,39 @@ namespace solarApp
|
||||
lbMsgTitle.Text = System.DateTime.Now.ToString() + " 完成!";
|
||||
}
|
||||
|
||||
private void bt_procStep2Range_Click(object sender, EventArgs e)
|
||||
{
|
||||
// 防呆:檢查是否有輸入
|
||||
if (string.IsNullOrWhiteSpace(tbStationIdStart.Text) || string.IsNullOrWhiteSpace(tbStationIdEnd.Text))
|
||||
{
|
||||
MessageBox.Show("請輸入電站ID區間(起始與結束)");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!int.TryParse(tbStationIdStart.Text, out int startId) || !int.TryParse(tbStationIdEnd.Text, out int endId))
|
||||
{
|
||||
MessageBox.Show("電站ID區間請輸入有效數字");
|
||||
return;
|
||||
}
|
||||
|
||||
var site_list = stationSvc.get_station_list32_by_range(startId, endId);
|
||||
|
||||
string date1 = dtSelect1.Value.ToString("yyyy-MM-dd");
|
||||
string date2 = dtSelect2.Value.ToString("yyyy-MM-dd");
|
||||
procSensorSvc sensorSvc = new procSensorSvc();
|
||||
procInvSvc invSvc = new procInvSvc();
|
||||
sensorSvc.isFirst = true;
|
||||
foreach (var item in site_list)
|
||||
{
|
||||
foreach (DateTime day in EachDay(DateTime.Parse(date1), DateTime.Parse(date2)))
|
||||
{
|
||||
invSvc.report_invDay(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd"));
|
||||
}
|
||||
}
|
||||
|
||||
lbMsgTitle.Text = System.DateTime.Now.ToString() + " 區間報告完成!";
|
||||
}
|
||||
|
||||
//test for email format
|
||||
//private void button3_Click(object sender, EventArgs e)
|
||||
//{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user